Using the IfElse trigger. (Read 2630 times)

Started by BC, November 04, 2008, 03:04:27 am
Share this topic:


Using the IfElse trigger.
#1  November 04, 2008, 03:04:27 am
  • ****
    • UK
This is for people who don't know how the ifelse trigger works and would like to know how it works but can't understand the document explanation.

here is the explanation from the trigger.txt file located in mugen docs folder.


    Expression to test.
    Expression specifying value to return if exp_cond is nonzero.
    Expression specifying value to return if exp_false is zero.

now to some people tht can be a little confusing so ill give an easier explanation.

if blah blah. do this..... else do that.  now using that thought when looking at it does work lets look at the format again.


so if.. exp_cond, if it meets the condition which makes it true, then do this, if it doesnt meet the condition it becomes false, else do that.

now mayb im not the best at exaplaning things but you will understand this in a second if your already not... heres an example of how you can use ifelse for close range moves.

anim = ifelse(p2bodydist X < 20,201,200)
(this can be used in the statedef)

ok if p2bodydist X < 20 play animation 201... if its not less than 20(so its more) play animation 200. simple now? yes.

p2bodydist X < 20 being exp_cond....201 being exp_true, 200 being exp_false.

lets look at another way of using it.... this one is good for projectiles...if when your close to p2 you want the projectile to make him fall when hit, but when far away not make p2 fall you can do this...

(coded in the hitdef)

fall = ifelse(p2bodydist X < 30,1,0)

basically this says... if p2bodydist X < 30 then fall = 1, if its more than 30, fall = 0.

p2bodydist X < 30 means less than 30 pixels away from p1.

the exact explanation from mugen docs

trigger1 = P2BodyDist X < 30

Triggers if the front of P2 is within 30 pixels of the front of P1. 

ok it said within i said less than... but if its within 30 shouldnt it be <= less than or equal to... anyway this is supposed to be for you not me hehehe.

heres one i did for my character for damage.(for p1 this time)

damage = ifelse(vel x < 15, 59, 26), 50

if velocity X(horizontal movement) is less than 15("within"?) then damage = 59, if its faster, damage = 26

and after the close bracket(parenthesis) you'll notice ,50   thats guard damage.

(just for wonder why if p1's X velocity is faster than 15 is the damage lower....the answer because theres more hits involved when faster but thats another explanation :P)

ok well ive waffled on long enough...mayb im not the best with wording..but hopefully ive explained this so you'll understand on how it works and how to implement it in your code.

happy coding...

Retired from mugen but not development