[SOLVED](YEP_ActionSequencePacks)Code applies State when needed conditions aren't met

I swear, i'm starting to become really annoying, sorry for opening so many threads.
Let's get to the point: I made this code for the Basic attack:


Code:
<target action>
action effect
if (target.result().evaded)
{
}
else
{
   if (target.result().missed)
   {
   }
   else
   {
      if(user.isStateAffected(36))
      {
         if ((Math.random() * 100)+1 < 15+Math.floor((user.param(5) - 10) / 2))
         {
            add state 5: target
         }
         end
      }
      end
   }
   end
}
end
</target action>

In short, this should apply State 5 when the attack lands, and only if the user is affected by State 36.
This doesn't happen though: i tested the code in a fight with an actor that had the Status 36 and an actor that doesn't, and the Status has always the chance to being applied, even if the attack missed or the user isn't affected by State 36.
I guess the problem is with the IF Statements? Again, thanks in advance!
Hi, since your conditions are all mutually exclusives you should use } else if () { statement instead as it would render simplier syntax.
Beside you're using javascript in an action sequence notetag. You can use a conditionnal branch in an action sequence but with a slightly diffrent syntax... I suggest you consult the plugin instructions.
Hi, since your conditions are all mutually exclusives you should use } else if () { statement instead as it would render simplier syntax.
Beside you're using javascript in an action sequence notetag. You can use a conditionnal branch in an action sequence but with a slightly diffrent syntax... I suggest you consult the plugin instructions.
Alright, I guess this is how i should write it?

Code:
<target action>
action effect
if target.result().evaded

else if target.result().missed

   else if user.isStateAffected(36)
         if (Math.random() * 100)+1 < 15+Math.floor((user.param(5) - 10) / 2)
            add state 5: target
         end
end
</target action>

EDIT: Changed some stuff
Yeah, much better!
Does it work?
How about that action effect line on the top of the sequence? It should be assigned a target, most likely action effect: target...
Yeah, much better!
Does it work?
How about that action effect line on the top of the sequence? It should be assigned a target, most likely action effect: target...
Ahhhh, of course -.-"
I'll change that and tell you if it works.

EDIT: Still doesn't work 🙁 I even tried by changing the Status chance to "(Math.random() * 100)+1 <= 100+Math.floor((user.param(5) - 10) / 2", but nothing.

The code now is this:
Code:
<target action>
motion attack: user
action animation
action effect: target
if target.result().evaded

else if target.result().missed

   else if user.isStateAffected(36)
         if Math.floor(Math.random() * 100)+1 <= 100+Math.floor((user.param(5) - 10) / 2)
            add state 5: target
         end
end
wait for animation
</target action>
If it still doesn't work, try removing the whole Math bla bla bla condition and check if it work with simplier syntax:
Code:
<target action>
if target.result().hpDamage && user.isStateAffected(36)
   add state 5: target
end
</target action>
I used hpDamage cause instead of double check if its evaded then missed, it just check if there's some damage dealt, meaning that the hit has landed.
Also, I think that we can't put an if block inside another if block in the action sequence, so try this above and if it work, add your math condition with another &&.
Hope that helped a bit!
If it still doesn't work, try removing the whole Math bla bla bla condition and check if it work with simplier syntax:
Code:
<target action>
if target.result().hpDamage && user.isStateAffected(36)
   add state 5: target
end
</target action>
I used hpDamage cause instead of double check if its evaded then missed, it just check if there's some damage dealt, meaning that the hit has landed.
Also, I think that we can't put an if block inside another if block in the action sequence, so try this above and if it work, add your math condition with another &&.
Hope that helped a bit!
It still doesn't work 🙁 (I left the "missed" and "evaded" check because in my project it can happen that an attack deals 0 damage)


Code:
<target action>
motion attack: user
action animation
action effect: target
if target.result().evaded && target.result().missed

   else if user.isStateAffected(36)
            add state 5: target
end
wait for animation
</target action>
Ok, then... Try this:
Code:
if target.result().missed === false && target.result().evaded === false && user.isStateAffected(36)
  add state 5: target
end
I tested it... 😉
Ok, then... Try this:
Code:
if target.result().missed === false && target.result().evaded === false && user.isStateAffected(36)
  add state 5: target
end
I tested it... 😉
Nothing 🙁

EDIT: Could the problem be that i put the code in <Target Action>?
No, that's how I tested it and it worked well... Here's the sequence I tested:
Code:
<target action>
   motion walk: user
   move user: target, front base, 15, auto offset x -20
   animation wait: 4
   motion attack: user
   motion wait: user
   action animation
   animation wait: 4
   action effect: target
   if !target.result().missed && !target.result().evaded && user.isStateAffected(4)
     add state 5: target
   end
   death break
</target action>
*note: I changed target.result().missed === false by !target.result().missed after my last post as it provided better syntax, but it work either way so that isn't the problem... (I also used state 4 instead of 36 to fit my database...)

Can you provide the whole sequence you tested?
No, that's how I tested it and it worked well... Here's the sequence I tested:
Code:
<target action>
   motion walk: user
   move user: target, front base, 15, auto offset x -20
   animation wait: 4
   motion attack: user
   motion wait: user
   action animation
   animation wait: 4
   action effect: target
   if !target.result().missed && !target.result().evaded && user.isStateAffected(4)
     add state 5: target
   end
   death break
</target action>
*note: I changed target.result().missed === false by !target.result().missed after my last post as it provided better syntax, but it work either way so that isn't the problem... (I also used state 4 instead of 36 to fit my database...)

Can you provide the whole sequence you tested?
here:

Code:
<target action>
motion attack: user
action animation
action effect: target
if target.result().missed === false && target.result().evaded === false && user.isStateAffected(36)
  add state 5: target
end
wait for animation
</target action>
I see nothing wrong in that sequence. It is in the notexbox of your first skill in the database right?
How do you apply the state 36 to the attacker?
When you attack, does the user move and attack, and deal damage?
I see nothing wrong in that sequence. It is in the notexbox of your first skill in the database right?
How do you apply the state 36 to the attacker?
When you attack, does the user move and attack, and deal damage?
Yes it is.
The attacker has the State has a passive State (i used YEP_AutoPassiveStates)
And yes, he attacks and deals damage.
okay... Does the passive state is active? Does your passive state is conditionnal to something?
Does your passive state has an icon, if not, put one just to check if your actor is really affected by that state.
*Just to be sure, I tryied it with my own passive state and it worked as well...
okay... Does the passive state is active? Does your passive state is conditionnal to something?
Does your passive state has an icon, if not, put one just to check if your actor is really affected by that state.
*Just to be sure, I tryied it with my own passive state and it worked as well...
Weird, it doesn't appear :/
I checked the ability that should apply it, and the tag is there: <Equip State: 36>
hum... ok, but the correct tag is <Passive State: 36> 😛
hum... ok, but the correct tag is <Passive State: 36> 😛

Oh... and to say that other passive states I put them correctly :’D
I left home right now, when I come back i’ll give you news. Thank you!

EDIT: Yep, now it works. Thank you TSR! ^_^

Original thread: https://forums.rpgmakerweb.com/threads/solved-yep_actionsequencepacks-code-applies-state-when-needed-conditions-arent-met.116483/