*Some of the coding has been edited to work better thanks to Seravy's feedback. Some issues might still exist.
This first batch of coding is the helper which is the super armor.
Mostly everything is explained in the coding.
I'll be using my personal stateno which is 800. You can change it to whatever you want, but the most commonly used stateno for super armor is 9000.
;==============================================================================
;--| Super Armor |-------------------------------------------------------------
;==============================================================================
[Statedef 800]
type = S
movetype= I
physics = S
velset = 0,0
[State 0, AssertSpecial]
type = AssertSpecial ;This is so the animation that this helper is using isn't visible. Without this, you'll basically be seeing a fully colored afterimage of your character.
trigger1 = 1
flag = invisible
flag2 = noshadow
[State 0, Turn]
type = Turn ;This is to turn the helper when your character turns.
trigger1 = facing != root,facing
[State 0, ChangeAnim]
type = ChangeAnim ;This is so the helpers animation is the exact same as your characters animation.
trigger1 = anim != Root,anim
value = Root,animelemno(0)
ignorehitpause = 1
[State 0, StateTypeSet]
type = StateTypeSet ;This is so your helper is read as S statetype when your character's statetype is S.
trigger1 = root,statetype = S
statetype = S
ignorehitpause = 1
[State 0, StateTypeSet]
type = StateTypeSet ;This is so your helper is read as C statetype when your character's statetype is C.
trigger1 = root,statetype = C
statetype = C
ignorehitpause = 1
[State 0, StateTypeSet]
type = StateTypeSet;This is so your helper is read as A statetype when your character's statetype is A.
trigger1 = root,statetype = A
statetype = A
ignorehitpause = 1
[State 0, StateTypeSet]
type = StateTypeSet ;This is so your helper is read as L statetype when your character's statetype is L.
trigger1 = root,statetype = L
statetype = L
ignorehitpause = 1
;[State 800, 1]
;type = NotHitBy
;trigger1 = root,stateno = [120,159] ;This is so your character can block, but this super armor is not kind to blocking. It's better to disable guarding.
;value = SCA
;time = 1
[State 800, 2]
type = BindToParent ;This is so the helper stays on you at all times
trigger1 = 1
pos = 0,0
[State 800, 3]
type = ParentVarSet ;This sets the var that will control your health when the helper gets hit later on.
trigger1 = time = 0
v = 8
value = 0
[State 800, 4]
type = HitOverride ;This is so when the helper gets hit, it changes to stateno 801.
trigger1 = 1
attr = SCA, NA, SA, HA, NP, SP, HP, NT, ST, HT
stateno = 801
time = -1
[State 800, 5]
type = ChangeState ;This is so when you die or when more than one of these helpers exists, it'll destroy itself. You can add more triggers if you want. For example, a burst mode with super armor that is activated when var(50)=1. The burst mode and super armor deactivate when var(50)=0. You would want to put a "trigger3 = var(50)=0".
trigger1 = parent,life = 0
trigger2 = parent,numhelper(800) > 1
value = 802
;------------------------------------------------------------------------------
[Statedef 801]
type = S
movetype= H
physics = S
ctrl = 0
velset = 0,0
[State 0, AssertSpecial]
type = AssertSpecial
trigger1 = 1
flag = invisible
flag2 = noshadow
[State 0, Turn]
type = Turn
trigger1 = facing != root,facing
[State 0, ChangeAnim]
type = ChangeAnim
trigger1 = anim != Root,anim
value = Root,animelemno(0)
ignorehitpause = 1
[State 801, 0]
type = ParentVarSet ;This var will read how much damage you've just taken and how many times you were hit.
trigger1 = time = 0
v = 8
value = floor(GetHitVar(damage) / GetHitVar(HitCount))
[State 801, 1]
type = ChangeState ;This will destroy the helper when you die.
trigger1 = parent,life = 0
value = 802
[State 801, 2]
type = ChangeState ;This changes the state back to helper 800.
trigger1 = Time = 1
value = 800
;------------------------------------------------------------------------------
[Statedef 802] ;This is the state that destroys the helper.
type = S
movetype= I
physics = N
poweradd = 0
ctrl = 0
velset = 0, 0
anim = 9999 ;This is my blank animation used for destroying helpers. It's got a time of -1 and no image playing. Completely blank.
[state 802, 0]
type = destroyself
trigger1 = Time = 1
That's it for the helper. The next part is creating the helper.
[State -2, Helper] ;This does NOT have to be in your [Statedef -2]. It can be wherever. It's just most effective in your [Statedef -2] when spawning it through vars.
type = Helper
;Feel free to add as many triggers as you want. The triggers below are just required to prevent errors.
trigger1 = NumHelper(800) = 0 ;This is so it will only spawn if the helper doesn't already exist.
trigger1 = alive ;This is so it will only spawn if you're not dead.
stateno = 800
id = 800
name = "Super Armor"
keyctrl = 0
ownpal = 1
[State -2, VarSet] ;This var is necessary to make the next part of the coding work better and this belongs in your [Statedef -2].
type = VarSet
trigger1 = NumHelper(800) = 1
var(9) = 1
ignorehitpause = 1
[State -2, AssertSpecial]
type = AssertSpecial ;This is to disable blocking when the super armor is active because blocking messes up this super armor.
trigger1 = NumHelper(800) = 1
trigger1 = var(9)
flag = nostandguard
flag2 = nocrouchguard
flag3 = noairguard
The next part is a necessity and belongs in your [Statedef -3].
[State -3, NotHitBy] ;This is so your character does not get hit when the super armor is activated.
type = NotHitBy
trigger1 = var(9)
trigger1 = stateno != [120,159]
value = SCA
time = 1
[State -3, LifeAdd] ;This is the first part of the LifeAdd's that makes you take damage when the super armor is active.
type = LifeAdd
trigger1 = alive = 1
trigger1 = var(9)
trigger1 = Var(8)
time = 1
value = -Var(8)
[State -3, LifeAdd] ;This is the second part of the LifeAdd's that makes you take damage when the super armor is active.
type = LifeAdd
trigger1 = alive = 1
trigger1 = movetype = H
trigger1 = stateno != [120,159]
trigger1 = var(9) && !Var(8)
value = -floor(GetHitVar(damage) / GetHitVar(HitCount))
[State -3, SelfState] ;This was for when Guarding was not disabled. It's purpose was to send you straight to Stateno 0 should you get hit while stand/crouch guarding, but it doesn't work. You can disable this and the one below if you want. Or you can enable guarding and try to make it work.
type = SelfState
trigger1 = alive = 1
trigger1 = movetype = H
trigger1 = stateno != [120,159]
trigger1 = statetype != A
trigger1 = var(9)
value = 0
ctrl = 1
[State -3, SelfState] ;This was for when Guarding was not disabled. It's purpose was to send you straight to Stateno 50 should you get hit while air guarding, but it doesn't work.
type = SelfState
trigger1 = alive = 1
trigger1 = movetype = H
trigger1 = stateno != [120,159]
trigger1 = statetype = A
trigger1 = var(9)
value = 50
ctrl = 1
[State -3, VarSet] ;This removes var(9) when the super armor helper no longer exists.
type = VarSet
trigger1 = NumHelper(800) = 0
var(9) = 0
ignorehitpause = 1
I've never had problems with this piece of coding. I always use it. If someone comes across a problem or if I'm missing something please comment.