Jump to content

[SOLVED]A Switch/Select Case For VEX?


Atom

Recommended Posts

Hi All,

 

I am wondering if VEX has the equivalent of the C style switch statement, or an IFELSE?

 

Basically I am running into a small problem with just using IF statements only.

 

Consider code...

if (s@state_current == "attack") {
    // Should I switch to defend?
    float decide = rand(i@id+current_time+ch("rand_seed"));
    if (decide > f@sf_defend_chance) {
        printf("Switching from ATTACK to DEFEND for id#%d.\n", i@id);
        // Switching to defend mode.
        i@crowdtrigger_attack_defend = 1;
        s@state_current == "defend";
    }
}
if (s@state_current == "defend") {
    // Should I switch to attack?
    float decide = rand(i@id+@Frame+ch("rand_seed"));
    if (decide > f@sf_attack_chance) {
        printf("Switching from DEFEND to ATTACK for id#%d.\n", i@id);
        // Switching to attack mode.
        i@crowdtrigger_defend_attack = 1;
        s@state_current == "attack";
    }
}

In this case, if I am attacking and I randomly switch back to defend when I drop out of that 1st IF statement there is still a random chance that I could actually flip-flop back to attack again, which I don't want to ever happen.

 

If only VEX had a switch or select case or something...?

Edited by Atom
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...