Superarmor

From M.U.G.E.N Wiki

Jump to: navigation, search

Contents

Definition, Purpose

Superarmor is a special state of a character where attacks don't have an effect besides their damage. The state, position, velocity, animation, etc of the character remains unaffected, and everything from the hit is ignored, except the damage itself.

Superarmor can be used for various purposes. It's generally useful for boss characters or boss modes where the character acts/moves in a predetermined pattern which cannot be interrupted by hits. The Story Mode in Touhou fighter games act like this for example. It's useful when making a character that isn't supposed to be visibly affected by hits, like a giant robot, training dummy, etc... it's also useful as a last resort if your character doesn't have any required getting hit sprites and animations for it or you want to override the default behavior somehow. Other uses include attacks that are uninterruptable by hits, special moves where your character is absorbing incoming damage instead of attacking and such, and certain type of shields.

Effects

A superarmor prevents any parameter of the character from getting changed by hits. It also prevents the character from becoming a target, and a character using superarmor cannot be thrown or put into custom states either. It allows managing or altering incoming damage to a certain extent. Due to the character not becoming a target, hitsparks using the Numtarget trigger will not appear, and damage dampeners using the Numtarget trigger will not dampen damage. This is why using that trigger for those purposes is not recommended. Always use Movehit=1 for hitspark and especially damage dampener triggers when coding attacks to avoid this.

Methods

There are only two methods for coding a Superarmor at the moment. You can either use hitoverride on your character directly, or make you character immune to all attacks and let a helper take care of it.

Hitoverride method

This method works by inserting hitoverride directly into our character code. Hotoverride, however, changes the state number, resets time to zero even if the new state is the same as the old one, and also executes the statedef block, so it effectively restarts the move you were performing completely. To make it work without restarting your move, you have to alter the coding specifically to work together with the superarmor properly. The hitoverride method needs to be coded individually for every state where you want it to work, so it is suitable if you want superarmor to be active only during a certain attack.

This is an example state that we want to apply superarmor to :

[Statedef 12000]
Type=S
Movetype=A
Physics=S
ctrl=0
velset=0,0

[State 12007]
Type=Something1
Trigger1=time=0

[State 12007]
Type=Something2
Trigger1=time=12

[State 12007]
Type=Hitdef
Trigger1=Something
...

[State 12007]
Type=ChangeState
Trigger1=Animtime=0
Value=0
ctrl=1

This is how you need to change it to work :

; The original statedef of the state now acts as the “startup state” of the attack.
[Statedef 12000]
Type     = S ; Keep everything from your original statedef here.
MoveType = A ; You only want to set these at the start of the attack
Physics  = S ; Not when taking a hit
Ctrl     = 0
Velset	 =0,0

[State 240]
Type = Something
Trigger1 = time=0
; Anything that needs to happen on time=0, or before the attack comes to this state.

[State 12000]
Type= VarSet
Trigger1=1
var(9)=-1
; Var(9) is your time variable. Time gets reset to zero after every hit taken, so we need to count it ourselves!

[State 240]
Type = ChangeState
Trigger1 =1 ; If you want the character to spend some time in this state (for example to execute a superpause before the actual attack. Note that the Superarmor is not active while the character is in this state), add time>x here instead.
Value = 12007

[Statedef 12007]
Type=U ;  State type is unchanged. This is very important because leaving this line out would make it default to S(tanding) instead of unchanged.
Movetype=H  ; This is a hit state, so we can take damage in it. Change this to I, and use Lifeadd with Gethitvar(damage) if you want to have control over how much damage you are taking.

[State 592]
type = HitOverride
trigger1 = Condition for attack still going on. It must be the negated version of attack over condition. In case of animtime=0, this is animtime!=0.
attr = SCA, AA, AP, AT
stateno = 12007
slot = 6
time = 1

[State 12007]
Type=HitFallSet
Trigger1=1
Value=0

[State 12007]
Type=VarAdd
Trigger1=1
var(9)=1

[State 12007]
Type=Something2
Trigger1=var(9)=12 ; You have to replace the time trigger with var(9)!

[State 12007]
Type=ChangeState
Trigger1=Condition for attack over. (Usually Animtime=0)
Value=0
ctrl=1

Note that if you need to have an active hitdef in the superarmor state, it won't work because the movetype is H.

In that case, a movetype of A, and

Type=LifeAdd
Trigger1=time=0
value=-Gethitvar(damage)

is necessary. In addition, hitdefpersists is also necessary, to prevent it from turning off from incoming attacks if the hitdef needs to remain active for more than one tick.

Helper Method

The helper method uses the Nothitby sctrl to make the player immune to all hits, and creates a helper that can take those hits through a hitoverride instead. This way, the character remains unaffected by the hit, but the damage can still be subtracted using a variable set by the helper.

The helper method can be applied to any number of states or the entire character without any change necessary in those states, so it is ideal when you need to have superarmor on a large number of states, or globally on the entire character

To add this kind of superarmor, you only need to copy-paste the following code into your character :

Into your statedef -2, add :

[State -2]
Type = Helper
Triggerall = NumHelper(11777) = 0 ; Create the superarmor helper if it doesn't exist.
Trigger1 = Condition when Superarmor needs to be active comes here.
OwnPal = 1
PosType = P1
Pos = 0, 0
ID = 11777
StateNo = 11777
PauseMoveTime = 999999
SuperMoveTime = 999999
Name = "SuperArmor"

[State -2, LifeAdd]
Type = LifeAdd
Trigger1 = NumHelper(11777) > 0 ; If the superarmor helper exists, subtract taken damage from life.
Trigger1 = fVar(29) >=1
Value = -floor(fVar(29))
ignorehitpause=1

[State -2, VarSet]
Type = VarAdd
Trigger1 = 1
FV = 29
Value = -floor(fvar(29)) ; Damage already subtracted needs to be removed from the variable
ignorehitpause=1

[State -2]
Type= NotHitBy
Trigger1= NumHelper(11777)>0 ; If the superarmor helper is active, the character cannot be hit by anything.
value=SAC

[State -2]
Type= NotHitBy
Trigger1= NumHelper(11777)>0 ; If the superarmor helper is active, the character cannot be hit by anything.
value2=SAC ; This is for safety, as another Nothitby might override the first one, so better be safe and apply it to both slots.

And the helper state :

[StateDef 11777]
Type = U
MoveType = H
Physics = N
ctrl=0

[State 11777]
Type=StateTypeSet ; You want to mimic the statetype of the player, to let the correct types of attacks hit only
Trigger1=root,statetype=A
Statetype=A

[State 11777]
Type=StateTypeSet
Trigger1=root,statetype=C
Statetype=C

[State 11777]
Type=StateTypeSet
Trigger1=root,statetype=S
Statetype=S

[State 11777]
Type=StateTypeSet
Trigger1=root,statetype=L
Statetype=L

[State 6965]
Type=ChangeAnim ; Helper copies the animation of the player.
Trigger1=anim!=Root,anim
value=Root,anim
ignorehitpause=1

[State 6965]
Type=Assertspecial ; But is invisible
Trigger1=1
flag=invisible
flag2=noshadow
ignorehitpause=1

[State 6965, HitOverride]
Type = HitOverride
Trigger1 = 1
Attr = SCA, AA, AP , AT
StateNo = 11777
Time = 1
ForceAir = 0
ignorehitpause=1

[State 6965, BindToRoot]
Type = BindToRoot
Trigger1 = 1
Time = 1
Facing = 1
Pos = 0, 0
ignorehitpause=1

[State 6966, ParentVarAdd]
Type = ParentVarAdd
Trigger1 = Time = 0
fV = 29
Value = GetHitVar(damage)
ignorehitpause=1

[State 6966, ParentVarAdd]
Type=Hitfallset
Triger1=1
value=0

[State 6965, DestroySelf]
Type = DestroySelf
Trigger1 = Superarmor ending condition.
ignorehitpause=1

Note that the helper does need to be able to take damage from every attack, and the hitoverride prevents getting into custom states by itself, so there is no need to add immunity to throws by adding a Nothitby, value=,AT. If anything, doing that will cause problems instead of preventing them : the character will be immune to T type attacks even if those attacks are not custom stated, and won't take the damage from them when it was supposed to.

Also note that if the character has any active Nothitby effects from moves while the superarmor is on, you have to apply those nothitby effects to your helper instead of the player to keep them working.

This guide was written by Seravy
Personal tools