;---------------------------------------------------------------------------
; SP Recovery
[Statedef 300]
type    = C
movetype= I
physics = C
ctrl = 0
anim = 182

[State 300, PowerAdd]
type = PowerAdd
trigger1 = time % 90 = 89
value = 250

[State 300, Explod]
type = Explod
trigger1 = time % 90 = 89
anim = 959
ID = 300
pos = 0,-60 * const(size.yscale)
postype = p1  ;p2,front,back,left,right
facing = facing
vfacing = 1
bindtime = 1
vel = 0,-1
removetime = 45
scale = const(size.xscale),const(size.yscale)
sprpriority = 5
ownpal = 1
ontop = 1
ownpal = 1

[State 300, PlaySnd]
type = PlaySnd
trigger1 = time % 90 = 89
value = 300,0

[state 300, end]
type = changestate
trigger1 = var(1) != 1 && command != "holdz"
trigger2 = var(1) = 1 && time > 90 && p2movetype != H
value = 11
ctrl = 1





;---------------------------------------------------------------------------
;---------------------------------------------------------------------------
; SUPER Soul Strike
[statedef 3000]
type = A
movetype = A
physics = A
anim = 2025
ctrl = 0
sprpriority = 0

[State 3000, SuperPause]
type = SuperPause
trigger1 = time = 3
time = 45
pos = 0, -100
anim = 100
sound = F20, 0
poweradd = -5500

[state 3000, setnumstrikes]
type = varset
trigger1 = time = 3
var(7) = 0

[state 3000, changestate]
type = changestate
trigger1 = time = 3
value = 3001

[statedef 3001]
type = A
movetype = A
physics = A
anim = 2025
ctrl = 0
poweradd = -300
sprpriority = 0

[state 3001, setnumstrikes]
type = varset
trigger1 = time = 0
var(7) = var(7) + 1

[state 3001, velset]
type = velset
trigger1 = time = 0
y = -12
x = -4

[State 3001, TextBoxHelper]
type = Helper
trigger1 = time = 0 && var(7) = 1
helpertype = normal ;player
name = "soulstriketext"
ID = 2024
stateno = 2024
pos = ifelse(facing=1,backedgedist,frontedgedist),0
postype = left    ;p2,front,back,left,right
facing = 1

[State 3001, SoulStrikeMaker]
type = Helper
trigger1 = time = 8
helpertype = normal ;player
name = "soulstrikemaker"
ID = 2021
stateno = 2021
pos = -12, -80
postype = p1    ;p2,front,back,left,right
facing = 1

[state 3001, castdelay]
type = varset
trigger1 = time = 0 && var(7) >= 5
var(8) = 120

[state 3001, castdelay]
type = changestate
trigger1 = (time >= 20 + (random / 50)) && var(7) < 5
value = 3001










;---------------------------------------------------------------------------
;---------------------------------------------------------------------------
; Safety Coat
[statedef 3100]
type = S
movetype = I
physics = S
anim = 1500
ctrl = 0
sprpriority = 0

[State 3100, SuperPause]
type = SuperPause
trigger1 = time = 0
time = 15
pos = 0, -50
anim = 100
sound = S3100, 1
poweradd = -3500

[State 3100, coat]
type = null ;PlaySnd
trigger1 = animelem = 10
value = 1

[state 3100, changestate]
type = changestate
trigger1 = animtime = 0
value = 0
ctrl = 1











;---------------------------------------------------------------------------
;---------------------------------------------------------------------------
; Vertical Firewall
[statedef 3200]
type = S
movetype = A
physics = S
anim = 2150
ctrl = 0
sprpriority = 0

[state 3200, cast_delay]
type = varset
trigger1 = time = 0
var(8) = 180

[State 3200, SuperPause]
type = SuperPause
trigger1 = time = 0
time = 30
pos = 0, -50
anim = 100
sound = F20, 0
poweradd = -2000

[state 3200, end]
type = changestate
trigger1 = animtime = 0
value = 3201

; - Vertical Firewall Middle
[statedef 3201]
type = S
movetype = A
physics = S
anim = 2151
ctrl = 0
sprpriority = 0

[State 3201, FireWall1]
type = Helper
trigger1 = time = 0 && numhelper(2155)
helpertype = normal
name = "FireWall"
ID = 3210
stateno = 3210
pos = (helper(2155), pos x) - pos x,20
postype = p1    ;p2,front,back,left,right
facing = 1
ownpal = 1
size.xscale = 3.5 * const(size.xscale)
size.yscale = 10.5 * const(size.yscale)

[State 3201, FireWall2]
type = Helper
trigger1 = time = 0 && numhelper(2156)
helpertype = normal
name = "FireWall"
ID = 3211
stateno = 3210
pos = (helper(2156), pos x) - pos x,10
postype = p1    ;p2,front,back,left,right
facing = 1
ownpal = 1
size.xscale = 3 * const(size.xscale)
size.yscale = 9 * const(size.yscale)

[State 3201, FireWall]
type = Helper
trigger1 = time = 0 && numhelper(2157)
helpertype = normal
name = "FireWall"
ID = 3212
stateno = 3210
pos = (helper(2157), pos x) - pos x,0
postype = p1    ;p2,front,back,left,right
facing = 1
ownpal = 1
size.xscale = 2.5 * const(size.xscale)
size.yscale = 7.5 * const(size.yscale)

[state 3201, end]
type = changestate
trigger1 = time = 34
value = 2152


; -- Vertical Firewall Flame
[statedef 3210]
type = S
movetype = A
physics = N
anim = 3210
ctrl = 0
sprpriority = 4

[State 3201, PlaySnd]
type = PlaySnd
trigger1 = time = 0
value = S2070,0

[state 3210, turn]
type = turn
trigger1 = facing = enemynear, facing

[state 3210, nohit]
type = nothitby
trigger1 = 1
value = SCA,NA,SA,HA,NP,SP,HP,NT,ST,HT
time = 1
ignorehitpause = 1

[State 3210, HitDef]
type = HitDef
trigger1 = 1
attr = S,SP        ;SCA,NA,SA,HA,NP,SP,HP,NT,ST,HT
hitflag = MAFD        ;HLAFD+-
guardflag = MA         ;HLA
getpower = 0,0
animtype = light          ;light,medium,hard,back,up,diagup
air.animtype = light
priority = 7,Hit   ;Hit,Miss,Dodge
damage = ceil(10 * (root, fvar(4))) ; Game value is 30
pausetime = 3,4
sparkno = S201
sparkxy = -40, (enemynear, pos y) - ((enemynear, const(size.height)) / 2)
hitsound = S2,0
guardsound = S1,0
ground.type = low      ;Low,Trip,None
ground.slidetime = 10
ground.hittime = 10
air.hittime = 20
ground.velocity = -1,-8
air.velocity = -1,-8

[state 3210, end]
type = changestate
trigger1 = time >= 10
value = 2157






;---------------------------------------------------------------------------
; States that are always executed (use statedef -2)
;---------------------------------------------------------------------------
[statedef -2]

[state -2, stoppower]
type = powerset
trigger1 = roundstate = 2 && power > var(11) && movetype = H && time = 0
value = var(11)

[state -2, SPRecovery]
type = poweradd
trigger1 = var(6) = 0 && RoundState = 2
value = 600

[state -2, stoppower2]
type = varset
trigger1 = 1
var(11) = power

[state -2, HPRecovery]
type = lifeadd
trigger1 = var(6) = 0 && RoundState = 2
value = 18

[state -2, recoverycounterreg]
type = varset
trigger1 = RoundState = 2
var(6) = var(6) + 1
ignorehitpause = 1

[state -2, recoverycounterstand]
type = varset
trigger1 = movetype = I && statetype = S && command != "holdfwd" && RoundState = 2
var(6) = var(6) + 1
ignorehitpause = 1

[state -2, recoverycountercrouch]
type = varset
trigger1 = movetype = I && statetype = C && RoundState = 2
var(6) = var(6) + 3
ignorehitpause = 1

[state -2, HPSPRecover]
type = varset
trigger1 = var(6) >= 600 && RoundState = 2;Normal ; used to be 480
;trigger2 = movetype = I && statetype = S && command != "holdfwd" && var(6) >= 240
;trigger3 = movetype = I && statetype = C && var(6) >= 120
var(6) = 0

[state -2, castdelay]
type = varset
trigger1 = var(8) > 0
var(8) = var(8) - 1

[state -2, energycoatdecrease]
type = varset
trigger1 = var(9) > 0
var(9) = var(9) - 1
ignorehitpause = 1

[state -2, energycoatreindicatorp1]
type = Explod
triggerall = TeamSide = 1
trigger1 = NumExplod(2033) = 0 && var(9) > 0
ID = 2033
anim = 2033
pos = 10,66
postype = left
removetime = -1
bindtime = -1
scale = 1,1
sprpriority = 5
ontop = 1
ownpal = 1
removeongethit = 0
ignorehitpause = 1

[state -2, energycoatreindicatorp2]
type = Explod
triggerall = TeamSide = 2
trigger1 = NumExplod(2033) = 0 && var(9) > 0
ID = 2033
anim = 2033
pos = -42,66
postype = right
removetime = -1
bindtime = -1
scale = 1,1
sprpriority = 5
ontop = 1
ownpal = 1
removeongethit = 0
ignorehitpause = 1

[state -2, endcoatindicator]
type = ModifyExplod
trigger1 = NumExplod(2033) > 0 && var(9) <= 0
id = 2033
removetime = 1

[state -2, useenergycoat]
type = varset
trigger1 = var(9) > 0 && movetype = H && time = 0
var(10) = power * GetHitVar(damage) / 10000
ignorehitpause = 1

[state -2, RestartEnergyCoatPalFX]
type = PalFX
trigger1 = var(9) > 0 ;&& (time = 0 || animtime = 0)
time = var(9)
add = 0,0,50
mul = 256,256,256
;sinadd = 0,0,0,10
invertall = 0
color = 256

[State -2, LifeAdd]
type = LifeAdd
trigger1 = var(9) > 0 && movetype = H && time = 0
value = ifelse(power >= var(10) * 8, var(10), power / 8)
kill = 0
absolute = 1
ignorehitpause = 1

[State -2, PowerAdd]
type = PowerAdd
trigger1 = var(9) > 0 && movetype = H && time = 0
value = -(var(10) * 8)
ignorehitpause = 1

[state -2, cleartime]
type = varset
trigger1 = RoundState = 2
var(12) = var(12) + 1
ignorehitpause = 1

[state -2, updateNMEdmg]
type = varset
trigger1 = p2life < var(15)
var(14) = var(14) + var(15) - p2life

[state -2, updatep2life]
type = varset
trigger1 = 1
var(15) = p2life

[state -2, updateDMGrecv]
type = varset
trigger1 = life < var(17)
var(16) = var(16) + var(17) - life

[state -2, updatelife]
type = varset
trigger1 = 1
var(17) = life

[State -2, resetGravity]
type = VarSet
trigger1 = statetype != A || movetype = H
fv = 1
persistent = 1
value = 0

[State -2, remove_bluefoot]
type = removeexplod
trigger1 = movetype = H
id = 1041

[state -2, setfrostdriver]
type = varset
trigger1 = p2stateno = 2090 && p2movetype = H
var(20) = 1

[state -2, unsetfrostdriver]
type = varset
trigger1 = p2movetype != H && var(20)
var(20) = 0

[State -2, phys_dmg_mult]
type = varset
trigger1 = 1
fvar(3) = (var(5) / 100.0) * cond(var(20), 1.5, 1.0) * cond(NumHelper(2106), 1.5, 1.0) * (1.0 - var(4) * 0.05)

[State -2, magic_dmg_mult]
type = varset
trigger1 = 1
fvar(4) = cond(var(20), 0.4, 0.8) * cond(NumHelper(2106), 1.5, 1.0) ;This one is the "middle ground"
;fvar(4) = cond(var(20), 0.5, 1) * cond(NumHelper(2106), 1.5, 1.0) ;This one is "pure" RBO
;fvar(4) = cond(var(20), 0.3575, 0.715) * cond(NumHelper(2106), 1.5, 1.0) ;This one is the "Heavy Mugen Balanced"

[State -2, safetywall_block_dmg]
type = nothitby
trigger1 = numhelper(2124) > 0
trigger1 = pos y > (helper(2124), pos y) - 400
trigger1 = pos x > (helper(2124), pos x) - 100
trigger1 = pos x < (helper(2124), pos x) + 100
value = SCA

[state -2, showbgemp1]
type = Explod
triggerall = TeamSide = 1 && RoundState = 2
trigger1 = NumExplod(2127) = 0 && (var(19) = 1 || var(19) = 3)
ID = 2127
anim = 2127
pos = 70, 50
postype = left
removetime = -1
bindtime = -1
scale = 1,1
sprpriority = 5
ontop = 1
ownpal = 1
removeongethit = 0
ignorehitpause = 1

[state -2, showbgemp2]
type = Explod
triggerall = TeamSide = 2 && RoundState = 2
trigger1 = NumExplod(2127) = 0 && (var(19) = 1 || var(19) = 3)
ID = 2127
anim = 2127
pos = -90,50
postype = right
removetime = -1
bindtime = -1
scale = 1,1
sprpriority = 5
ontop = 1
ownpal = 1
removeongethit = 0
ignorehitpause = 1

[state -2, hidebgem]
type = ModifyExplod
trigger1 = NumExplod(2127) > 0 && RoundState > 2
ID = 2127
removetime = 1

[state -2, showbgemcountp1]
type = Explod
triggerall = TeamSide = 1 && RoundState = 2
trigger1 = var(19) = 1 || var(19) = 3
ID = 2130
anim = cond(var(22) <= 9, var(22), 9) + 2130
pos = 78, 52
postype = left
removetime = 2
bindtime = -1
scale = 1,1
sprpriority = 5
ontop = 1
ownpal = 1
removeongethit = 0
ignorehitpause = 1

[state -2, showbgemcountp2]
type = Explod
triggerall = TeamSide = 2 && RoundState = 2
trigger1 = var(19) = 1 || var(19) = 3
ID = 2130
anim = cond(var(22) <= 9, var(22), 9) + 2130
pos = -82,52
postype = right
removetime = 2
bindtime = -1
scale = 1,1
sprpriority = 5
ontop = 1
ownpal = 1
removeongethit = 0
ignorehitpause = 1

[state -2, RestartSafetyCoatPalFX]
type = PalFX
trigger1 = numhelper(2124) > 0 && (helper(2124), anim) = 2128
time = 2
add = 40,-10,40
mul = 256,200,256
invertall = 0
color = 256
ignorehitpause = 1


;---------------------------------------------------------------------------
; States that are executed when in self's state file (use statedef -3)
;---------------------------------------------------------------------------
[Statedef -3]

;Each time control is regained, reset the dex var to 0
[State -3, ResetDexVar]
type = VarSet
trigger1 = (ctrl) && statetype != A
var(4) = 0

;Each time control is regained (and not in air), reset the damage multiplier
[State -3, ResetDmgVar]
type = VarSet
trigger1 = (ctrl) && statetype != A
var(5) = 100

;In the air, Mage should not push into people (moves are hard that way)
[State -3, AirPushNegate]
type = PlayerPush
trigger1 = statetype = A
ignorehitpause = 1
value = 0

[State -3, flipbgemcount]
type = varset
trigger1 = RoundState > 2 && var(22) > 0
var(22) = -var(22)

[State -3, givebgem]
type = varset
trigger1 = RoundState < 2 && var(22) <= 0
var(22) = 1 - var(22)

[state -3, PrePerfectShield]
type = varset
trigger1 = command = "holdback"
var(24) = var(24) + 1
ignorehitpause = 1

[state -3, NotPerfectShield]
type = varset
trigger1 = command != "holdback"
var(24) = -1
ignorehitpause = 1

[state -3, PerfectShield]
type = changestate
trigger1 = (stateno = [150,153]) && var(24) < 6 && time = 0
value = stateno + 6360
ignorehitpause = 1

;This is for fun, don't actually use this in battle
; [state -3, PartnerHPRecovery]
; type = helper
; trigger1 = numhelper(3100) = 0
; trigger1 = roundstate = 2
; trigger1 = !ishelper
; helpertype = normal ;player
; name = "hprec"
; ID = 3100
; stateno = 3100
; pos = 0,-10
; postype = p1    ;p2,front,back,left,right
; facing = 1
; 
; [state -3, helperbind]
; type = bindtoparent
; trigger1 = ishelper
; bindtime = 10
; pos = 0, -10


