def custom_formula_normalatk(a, value = (a.atk - b.def) + rand(5) c = (a.mat - b.mat) d = (b.agi + b.luk) if c > 14 and c > d if b.state?(68) a.tp -= 10 b.tp += 10 return value else b.add_state (68) a.tp -= 10 b.tp += 10 return value end else a.tp -= 10 b.tp += 10 return value endend-This is the code I've used to determine whether or not a skill (normal attack) adds stun (state 68).
-I've purposely written it so that if the target is already stunned, it does not refresh the state.
-in my game, stun lasts 2 turns (because 1 turn is effectively 0 if the user always acts before the enemy in a 1on1 fight).
Everything works perfectly until turn 5, and what's REALLY strange is that it deviates from how things work at turn 3 (which is how it's intended to work).
Here's what happens:
Turn1
Actor attacks Enemy. Enemy attacks (and stuns) Actor.
Turn 2
Actor is stunned. Enemy attacks actor.
-Stun is removed from Actor-
Turn 3
Actor attacks Enemy. Enemy attacks (and stuns) Actor.
Turn 4
Actor is stunned. Enemy attacks actor.
-Stun is removed from Actor-
Turn5
After selecting attack, the Enemy attacks (and stuns) me before I can act.
This is unlike Turn 3, where I had just recovered from stun, was able to select attack, and successfully got in a hit before he re-stunned me.
The pattern continues like this; Turn 3 is the only time where the Actor's selected action manifests before he is re-stunned.
So not only am I dumbfounded as to why this is, I obviously want it to be so that after the stun expires, the actor's action takes place (assuming his speed is high enough, which it is in this case) before the Enemy's (since it will re-apply the stun).
-I've purposely written it so that if the target is already stunned, it does not refresh the state.
-in my game, stun lasts 2 turns (because 1 turn is effectively 0 if the user always acts before the enemy in a 1on1 fight).
Everything works perfectly until turn 5, and what's REALLY strange is that it deviates from how things work at turn 3 (which is how it's intended to work).
Here's what happens:
Turn1
Actor attacks Enemy. Enemy attacks (and stuns) Actor.
Turn 2
Actor is stunned. Enemy attacks actor.
-Stun is removed from Actor-
Turn 3
Actor attacks Enemy. Enemy attacks (and stuns) Actor.
Turn 4
Actor is stunned. Enemy attacks actor.
-Stun is removed from Actor-
Turn5
After selecting attack, the Enemy attacks (and stuns) me before I can act.
This is unlike Turn 3, where I had just recovered from stun, was able to select attack, and successfully got in a hit before he re-stunned me.
The pattern continues like this; Turn 3 is the only time where the Actor's selected action manifests before he is re-stunned.
So not only am I dumbfounded as to why this is, I obviously want it to be so that after the stun expires, the actor's action takes place (assuming his speed is high enough, which it is in this case) before the Enemy's (since it will re-apply the stun).


