=============
Resurrection:
=============
Created by NodeX
Special thanks to [E] for the projectile suggestion.

;---------------------------------------------------------------------------
Resurrection: The ability to revive if your character is defeated. Gill from
SF3 is one character with such an ability. (Heck, it's his signature move!)
;---------------------------------------------------------------------------
This helper keeps the round from ending when you lose the match

[State -3, Helper]
type = Helper
trigger1 = (RoundState = 2) && (NumHelper(9000) = 0)
helpertype = Player
name = "Resurrection Super"
id = 9000
postype = p1
stateno = 9000
ignorehitpause = 1
pausemovetime = 999999999999999999999
size.ground.back = 1
size.ground.front = 1
size.air.back = 1
size.air.front = 1

Next, you have to override State 5150. If your character uses its own common states
file, then add the two states to State 5150 (the two states are numbered 10 and 11):

; HIT_LIEDEAD
[Statedef 5150]
type    = L
movetype= H
physics = N
sprpriority = -3

[State 5150, 1] ;Normal anim
type = ChangeAnim
triggerall = Time = 0
triggerall = SelfAnimExist(5140)
trigger1 = (anim != [5111,5119]) && (anim != [5171,5179])
trigger2 = !SelfAnimExist(5140 + (anim % 10))
value = 5140

[State 5150, 3] ;Hit up type anim
type = ChangeAnim
trigger1 = Time = 0
trigger1 = (anim = [5111,5119]) || (anim = [5171,5179])
trigger1 = SelfAnimExist(5140 + (anim % 10))
value = 5140 + (anim % 10)

[State 5150, 4] ;Match over anim
type = ChangeAnim
persistent = 0
;trigger1 = Time = 0
trigger1 = MatchOver = 1
trigger1 = Anim = [5140,5149]
trigger1 = SelfAnimExist(anim+10)
value = anim+10

[State 5150, 5] ;Switch to 5110 if liedead anim does not exist
type = ChangeAnim
trigger1 = Time = 0
trigger1 = Anim != [5140,5159]
trigger1 = Anim != [5110,5119]
value = 5110

[State 5150, 6] ;Friction
type = VelMul
trigger1 = 1
x = 0.85

[State 5150, 7] ;Friction
type = VelSet
trigger1 = Vel x < .05
persistent = 0
x = 0

[State 5150, 9]
type = NotHitBy
trigger1 = 1
value = SCA
time = 1

[State 5150, 10]
type = ChangeState
trigger1 = Life > 0
value = 5120

[State 5150, 11]
type = ChangeState
trigger1 = (Life <= 0) && (Var(0) = 0) && (NumHelper(9000) > 0) && (Power >= 1000)
value = 9000

Now, add this to your AIR file. If you change the action number, make sure to
change it in the Resurrection super states:
 
;Used for projectiles...
[Begin Action 9010]
Clsn2: 1
 Clsn2[0] = -23,-640, 19,  0
0,-1, 0,0, -1

The Resurrection super states:

;===================
; Resurrection Super
;===================

[Statedef 9000]
type = S
movetype = I
velset = 0,0
anim = 0
ctrl = 0
poweradd = -1000 
sprpriority = 2

This var keeps the Resurrection Super from being used twice in the same round.
[State 9000, VarSet]
type = VarSet
trigger1 = Time = 0
v = 0
value = 1

This NotHitby allows the player to recover at least 10% of their life.
The formula used in the trigger goes like this:

life * 10% / 5 (value used in the lifeadd) * 2 (value that is "modding" the time in the lifeadd)

[State 9000, NotHitBy]
type = NotHitBy
trigger1 = Time <= const(data.life) * 0.10 / 5 * 2
;trigger1 = life >= const(data.life) * 0.10  ;An alternate trigger
value = SCA

[State 9000, Width]
type = Width
trigger1 = 1
player = 45

; The reverse vacuum pushes the player away.
[State 9000, Reverse Vacuum]
type = Helper
trigger1 = (Time%3) = 0
name = "Reverse Vacuum"
pos = 0, 0
postype = p1
stateno = 9015
helpertype = normal
facing = 1 ;ifelse(random >= 500, 1, -1)
ignorehitpause = 1
size.ground.back = 1
size.ground.front = 1
size.air.back = 1
size.air.front = 1

[State 9000, Reverse Vacuum]
type = Helper
trigger1 = (Time%3) = 0
name = "Reverse Vacuum"
pos = 0, 0
postype = p1
stateno = 9015
helpertype = normal
facing = -1 ;ifelse(random >= 500, 1, -1)
ignorehitpause = 1
size.ground.back = 1
size.ground.front = 1
size.air.back = 1
size.air.front = 1

[State 9000, LifeAdd]
type = LifeAdd
trigger1 = (Time%2) = 0
value = 5

; This "invisible" projectile will "slow down" any projectiles. Thanks to [E] for the suggestion.
[State 9000, Projectile]
type = Projectile
trigger1 = (Time&25) = 0
projanim = 9010
offset = 0,0
velocity = 1, 0 
projpriority = 1
projremovetime = 25
; HitDef part of projectile info
attr = S, HP
sparkno = -1
guard.sparkno = -1

[State 9000, ChangeState]
type = ChangeState
trigger1 = life = const(data.life)
value = 0
ctrl = 1

;===========================
; Resurrection Helper States
;===========================

[Statedef 9010]

[State 9010, Invisible]
type = AssertSpecial
trigger1 = 1
flag = invisible

[State 9010, PlayerPush]
type = PlayerPush
trigger1 = 1
value = 0

[State 9010, NotHitBy]
type = NotHitBy
trigger1 = 1
value = SCA

[State 9010, Bind]
type = BindToParent
trigger1 = 1

[State 9010, DestroySelf]
type = DestroySelf
triggerall = parent, life <= 0
trigger1 = (parent, power < 1000) || (parent, var(0) = 1)

;===============
; Reverse Vacuum
;===============

[Statedef 9015]
;type    = A
anim = 9015

[State 9015, VarRandom]
type = VarRandom
trigger1 = Time = 0
v = 8
range = 1,5

[State 9015, VelSet]
type = VelSet
trigger1 = Time = 0
x = 5 * (3 * var(8)) + 10  ;30 

[State 4015, PlayerPush]
type = PlayerPush
trigger1 = p2bodydist X >= 1
value = 1

[State 9015, NotHitBy]
type = NotHitBy
trigger1 = 1
value = SCA

[State 9015, DestoySelf]
type = DestroySelf
trigger1 = Time > 20

