Help with state mechanic (upgrading states and Tsukihime's Conditional State)

Hello, everyone!

I'm looking to create this specific mechanic:

If enemy is hit with a weakness, apply state 1.
If enemy is hit with a weakness again, applies state 2. Removes state 1. That can happen 3 times, from state 1 to state 4, which is the last one.

For applying a state when the enemy is hit with a weakness, I'm using this in the damage formula b.element_rate(element_id) > 1 ? b.add_state(state_id): damage. For the state upgrade, I'm using Tsukihime's Conditional State (can be found here) and the following formula:
<conditional state>
if a.state?(state1)
state2
else
state1
end
</conditional state>

So I have 2 questions/requests:

1) that applying state formula in the damage formula seems clunky. Is there any other way to do it? (if not or this is the best way, I'm happy to use it because it worked, but I'm afraid it can be troublesome later)

2) I wasn't able to make state2 upgrade to state3 and so on when applying state1 again. How could I do it?

Thanks in advance!
Bump?
Moved to: RGSSx Script Support
What you have should be fine. I don't have any scripts that do what you want specifically.
So keep going with what you have.
However I'm curious to know if you have it set the way TsukiHime describes in the script?
If so then this would be on state 14
<conditional state>
if a.state?(12)
13
elsif a.state?(11)
12
elsif a.state?(10)
11
else
10
end
</conditional state>
Oh, it worked! I got the syntax and the order of states wrong lol
There's still some things to figure out, but I guess I can do it on my own. Thank you so much for the help!!!

Original thread: https://forums.rpgmakerweb.com/threads/help-with-state-mechanic-upgrading-states-and-tsukihimes-conditional-state.155738/