YesNoOk
avatar

Trigger Redirection (CNS) (Read 13236 times)

Started by JustNoPoint, September 08, 2015, 10:33:52 pm
Share this topic:
Trigger Redirection (CNS)
#1  September 08, 2015, 10:33:52 pm
  • ******
    • www.justnopoint.com/
One might wish to check the statetime of the player's target, or the player's parent (if the player is a helper), etc. This is possible using so-called trigger redirection. See Expressions for details.



Spoiler: Condition- and function-type triggers Lead in to redirections (click to see content)

In the above example, the time trigger returned the statetime of the player. But sometimes, one might wish to check the statetime of the player's target, or the player's parent (if the player is a helper), etc. This can be accomplished by preceding the trigger name by a keyword indicating whose information should be returned. This process is known as trigger redirection. For example,

5 + (parent, time)

returns 5 + the player's parent's statetime.

The complete list of redirection keywords is the following:

parent

Redirects the trigger to the player's parent. (Player must be a helper.)

root

Redirects the trigger to the root.

helper

Redirects the trigger to the first helper found. See the related trigger "NumHelper" in the trigger documentation.

helper(ID)

ID should be a well-formed expression that evaluates to a positive integer. The trigger is then redirected to a helper with the corresponding ID number.

target

Redirects the trigger to the first target found.

target(ID)

ID should be a well-formed expression that evaluates to a non- negative integer. The trigger is then redirected to a target with the corresponding targetID. The targetID is specified in the "ID" parameter of a HitDef controller.

partner

Redirects the trigger to the player's partner. Normal helpers and neutral players are not considered opponents. See the related trigger "numpartner" in the trigger documentation.

enemy

Redirects the trigger to the first opponent found. Normal helpers and neutral players are not considered opponents. See the related trigger "numenemy" in the trigger documentation.

enemy(n)

n should be a well-formed expression that evaluates to a non- negative integer. The trigger is redirected to the n'th opponent.

enemyNear

Redirects the trigger to the nearest opponent.

enemyNear(n)

n should be a well-formed expression that evaluates to a non- negative integer. The trigger is redirected to the n'th-nearest opponent.

playerID(ID)

n should be a well-formed expression that evaluates to a non- negative integer. The trigger is redirected to the player with unique ID equal to ID. See the "ID" and "PlayerExistID" triggers in the trigger documentation.

If the trigger is redirected to an invalid destination (for instance, if it is retargeted to a helper when none exist), then bottom is returned.

Note: recursive redirection (e.g., "root,target,time") is not supported.
Last Edit: October 07, 2015, 03:24:43 am by Just No Point
Re: Trigger Redirection (CNS)
#2  September 09, 2015, 08:36:57 pm
  • ******
  • Hedgehog Whisperer
  • Red Bull addict
    • Spain
    • xgargoyle.mgbr.net
Trigger redirection is probably one of the most important areas to study and understand. It basically lets you check whatever you want from any player, enemy or helper. Trigger redirection can be performed by both players and helpers.

Some examples of application:
- Moving the content of a player's variable to a helper's variable, and viceversa
- Check enemy constants/states/variables
- Synchronize code between player and helper
- Check target's properties
XGargoyle: Battle posing since 1979
http://xgargoyle.mgbr.net
http://www.pandorabots.com/pandora/talk?botid=e71c0d43fe35093a  <-- Please click that link
http://paypal.me/XGargoyle  <-- Donations welcome!

GT

Re: Trigger Redirection (CNS)
#3  September 09, 2015, 10:04:19 pm
  • *****
    • USA
    • Skype - gt_ruby
I think it should also be noted that trigger redirection(s) cannot be stacked.

Code:
target,time
This will return the target's time.

Code:
target,enemynear,time
This will return an error. :P
Yeah Titiln, in fact, You Made Him
Re: Trigger Redirection (CNS)
#4  September 09, 2015, 11:43:27 pm
  • ******
  • Hedgehog Whisperer
  • Red Bull addict
    • Spain
    • xgargoyle.mgbr.net
which is already explained on JNP's post...
XGargoyle: Battle posing since 1979
http://xgargoyle.mgbr.net
http://www.pandorabots.com/pandora/talk?botid=e71c0d43fe35093a  <-- Please click that link
http://paypal.me/XGargoyle  <-- Donations welcome!
Re: Trigger Redirection (CNS)
#5  September 09, 2015, 11:48:14 pm
  • ******
    • www.justnopoint.com/
It's worded differently so it might be more clear to someone.

GT

Re: Trigger Redirection (CNS)
#6  September 10, 2015, 02:06:56 am
  • *****
    • USA
    • Skype - gt_ruby
He's right, though. I didn't read that last part of your post properly (Although, I've never seen the phrase "Recursive redirection"). :grrr:
Yeah Titiln, in fact, You Made Him
Re: Trigger Redirection (CNS)
#7  September 10, 2015, 02:50:39 am
  • ****
  • Robotics Engineer
    • USA
    • altoiddealer@gmail.com
Here is a very useful technique that I would recommend anyone and everyone to implement in their characters.

Credits to @Алексей because he taught me this

"P2 type" Triggers that redirect to the enemy, such as "enemy," / "enemynear," are often used based on the assumption that the game is being played 1 versus 1.

The same applies to triggers such as "P2BodyDist" / "P2Dist" / etc.  Additionally, these triggers FAIL in Win Poses because there technically is no "Player 2" during these phases of the match.

The redirection "target," is much more reliable when possible.  BUT the reason this isn't always the right choice, of course, is that the enemy has to be recognized as a target for it to work.


The best, most reliable, and seamingly most underused redirection, is "Player(ID),"

All you have to do is log the opponent's ID in a var, and you can use it.  Just copy this code, paste it into your character's State -2, and assign it to the var of your choosing.

Code:
[State -2, Log the current target's PlayerID]
type = VarSet
trigger1 = numtarget
trigger1 = target,IsHelper = 0 ;Do not trigger for helpers
var(58) = target,ID
ignorehitpause = 1

Now, you can use that ID to establish a solid and reliable trigger.

Code:
[State 1100,4] ;Spear sinks in sound
type = PlaySnd
trigger1 = PlayerIdExist(var(58)) ;enemy exists
trigger1 = PlayerId(var(58)),StateNo = 1105 ;enemy is in custom hit state
trigger2 = !PlayerIdExist(var(58)) ;fallback code
trigger2 = p2stateno = 1105 ;fallback code
value = 1100,2
persistent = 0
ignorehitpause = 1

As you can see above, I also included a "fallback" code in case for some reason the ID doesn't match.

"fallback code", such as what is used in my example, IS REQUIRED for triggers that can be tripped before the enemy is ever recognized as a target!

Re: Trigger Redirection (CNS)
#8  April 11, 2016, 06:42:23 pm
  • *****
  • Thanks and God bless
    • USA
    • ricepigeon.neocities.org
One other thing to point out is that because of the way mugen processes the order of players and helpers, there is a 1 tick delay when using trigger redirection from the root player to any helper redirection. This may not be entirely evident from root to helper, but when checking a series of helpers and their "children", the time it takes to reach from the end to the root will vary (for instance, a chain of 15 helpers, each one a child of the previous helper, will take 15 ticks for that information to reach the root, assuming that each helper is using redirection to read the value of the child 's variable and setting its own variable equal to this one)
Re: Trigger Redirection (CNS)
#9  April 12, 2016, 12:00:34 pm
  • ******
  • Legendary XIII
  • I am the eye of the storm to come!
    • New Zealand
    • network.mugenguild.com/cyanide/
If you wish a variable to make its way down a chain, or otherwise be set, do not use a variable at all. Projectiles are ALWAYS owned by the root, and make excellent alternatives when a helper is a long way down a chain. Especially if you have not used unique identifiers (not always possible)

The helper can create a projectile and all helpers can tell that root, numprojID straight away. As a bonus, these projectiles have built in timers for buffering etc.


In M.U.G.E.N there is no magic button

They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance.
Re: Trigger Redirection (CNS)
#10  May 15, 2016, 09:52:09 pm
  • **
  • always trying to edit mugen chars as original game
thanks a lot Ricepigeon for the information about 1 frame delay this the basis of my edit of some ikaruga's kof98 chars that i converted them to kof97 ones I tacked advantage of enemynear,stateno is not always equal to p2stateno,
when the char is the home team enemynear,stateno has high priority it gives you the previous p2stateno but if the char is not the home team enemynear,stateno=p2stateno
you can check this coding at my edits of ikaruga's chars:
http://www.mediafire.com/download/null30t2ha31s3l/Clark-KOF97.zip
http://www.mediafire.com/download/ggb5wp1apmgzsku/OrochiYashiro98-97.zip
for orochi yashiro hold start button at character selection screen to get kof97 gameplay