;Contains...
;ChangeState that prevents Y.A.M.E.T.E from moving on her own without attacking
;The rest of the SuperArmor coding (by Brergrsart)
;Timer for AI to space out their attacks.
;Variables for the Light and Cross attack
;Special palettes modes that are just cosmetic.

[Statedef -2]

;--------------------------------------------------
 ;Super Armor Coding by Brergrsart

;This puts you to whatever death state you want. Make sure the state takes you to 5150 after you "die" to actually die.
[State 0, SelfState]
type = SelfState
trigger1 = life <= 0 && stateno != 7150
trigger1 = stateno != [5000,5210]
value =  5050;The state you go into before you die. You can also go straight to 5150 too if you want.
ctrl = 0

;This spawns the super armor helper. If this helper is triggered via a move, move this controller there.
;Or, if you want this helper to be on a timer, keep this controller here, and a trigger that checks if a var (Which is turned into a nonzero value from the state that "spawns" this helper) is > 0. Then have a varadd in -2 that counts down the var until it hits 0, so the helper stops spawning
[State 0, Helper]
type = Helper
trigger1 = numhelper(1006) = 0 ;You don't want more than one of these.
helpertype = normal ;player
name = "Super Armor"
ID = 1006
stateno = 1006 
pos = 0,0
postype = p1    ;p2,front,back,left,right
facing = 1
keyctrl = 0
ownpal = 1
supermovetime = 9999999
pausemovetime = 9999999

[State 0, AssertSpecial]
type = AssertSpecial
trigger1 = 1
flag = nostandguard
flag2 = nocrouchguard
flag3 = noairguard

;This where you start taking the damage set by the helper in state 1007.
[State 0, LifeAdd]
type = LifeAdd
trigger1 = numhelper(1006)
trigger1 = fvar(12) > 0
value = -floor(fvar(12))
ignorehitpause = 1

;Right after you take the damage, you IMMEDIATELY subtract the damage from fvar(10) by itself. If you want, this can also be a varset that sets it to 0. I never tried it myself, but it should work too.
[State 0, VarAdd]
type = VarAdd
trigger1 = 1
fv = 12
value = -floor(fvar(12))
ignorehitpause=  1

;This makes you invincible while the helper is out, but as the great prophets of Yu-Gi-Oh! Arc-V say: BUT YOU'LL STILL TAKE THE DAMAGE!
[State 0, NotHitBy]
type = NotHitBy
trigger1 = numhelper(1006)
value = SCA,NA,SA,HA,NP,SP,HP,NT,ST,HT

;Optional - You will flash white for a bit when you get hit
[State 0, PalFX]
type = PalFX
trigger1 = numhelper(1006)
trigger1 = helper(1006), movetype = H
time = 3
add = 120,120,120
mul = 256,256,256
sinadd = 0,0,0,1
invertall = 1
color = 256

;This prevent Y.A.M.E.T.E from being pushed like a volleyball
[State 0, PlayerPush]
type=PlayerPush
trigger1=1 
value = 0 ;0 means that P1 will pass through P2, default is 1) 

;-------------------------------------------------------------------------------------------------------------------------------------------------
;Timer for AI to space out their attacks.

[State 0, VarAdd]
type = VarAdd
trigger1 = 1
v = 42
value = 1

;-------------------------------------------------------------------------------------------------------------------------------------------------
;Variables for the fullscreen and the cross attack

;In a nutshell, Y.A.M.E.T.E can only use the light fullscreen attack once after every 3 attacks or more
;If she uses the fullscreen, the varibale will reset to 0
[State 0, VarAdd]
type = VarAdd
trigger1 = time = 1
trigger1 = stateno = 200
trigger2 = time = 1
trigger2 = stateno = 220
trigger3 = time = 1
trigger3 = stateno = 230
trigger4 = time = 1
trigger4 = stateno = 250
trigger5 = time = 1
trigger5 = stateno = 270
trigger6 = time = 1
trigger6 = stateno = 280
trigger7 = time = 1
trigger7 = stateno = 290
v = 55
value = 1

[State 0, VarSet]
type = VarSet
trigger1 = var(55) < 0
v = 55
value = 0

;Same but for the Cross attack
[State 0, VarAdd]
type = VarAdd
trigger1 = time = 1
trigger1 = stateno = 200
trigger2 = time = 1
trigger2 = stateno = 220
trigger3 = time = 1
trigger3 = stateno = 230
trigger4 = time = 1
trigger4 = stateno = 250
trigger5 = time = 1
trigger5 = stateno = 270
trigger6 = time = 1
trigger6 = stateno = 280
trigger7 = time = 1
trigger7 = stateno = 290
v = 56
value = 1

[State 0, VarSet]
type = VarSet
trigger1 = var(56) < 0
v = 56
value = 0

[State NoMusicFailSafe]
type = AssertSpecial
trigger1 = numexplod(40006) = 1
flag = nomusic
flag2 = noBG
flag3 = noFG
;-------------------------------------------------------------------------------------------------------------------------------------------------
;It's just cosmetic ! 

;Background
[State 0, Explod]
type = Explod
triggerall = palno = [7,12]
triggerall = NumExplod(25000) = 0
trigger1 = time = 0
anim = 25000
ID = 25000
pos = 120,100
postype = left  
facing = 1
vfacing = 1
bindtime = -1
removetime = -1
pausemovetime = 99999
supermovetime = 99999
scale = 1.1,0.9
sprpriority = -5
ontop = 0
ownpal = 1
removeongethit = 0

;Song
[State 0, PlaySnd]
type = PlaySnd
Triggerall = Roundstate >= 2
trigger1 = palno = [7,12]
trigger1 = NumHelper(20002) = (0)
trigger1 = NumExplod(40006) = (0)
value = S12000,0
volumescale = 100
channel = 2
lowpriority = 1
freqmul = 1.0
loop = 1
pan = 0

;Red balls that fills the screen
[State Explod]
type = Explod
triggerall = palno = [7,12]
trigger1 = gametime%5 = 0
anim = 25001
sprpriority = 999
postype = back
pos = 160,240
random = 320,20
vel = 2,-3 + (random%2)
facing = -1
scale = 1,1;.3,.3
under = 0
ownpal = 1
trans = add
ignorehitpause = 0

[State Explod]
type = Explod
triggerall = palno = [7,12]
trigger1 = gametime%5 = 0
anim = 25001
sprpriority = 999
postype = back
pos = 160,240
random = 320,20
vel = 0,-4 + (random%2)
facing = -1
scale = .5,.5;.3,.3
under = 0
ownpal = 1
trans = add
ignorehitpause = 0

[State Explod]
type = Explod
triggerall = palno = [7,12]
trigger1 = gametime%5 = 0
anim = 25001
sprpriority = 999
postype = back
pos = 160,240
random = 320,20
vel = 0,-5 + (random%2)
facing = -1
scale = .6,.6;.3,.3
under = 0
ownpal = 1
trans = add
ignorehitpause = 0

[State Explod]
type = Explod
triggerall = palno = [7,12]
trigger1 = gametime%5 = 0
anim = 25001
sprpriority = 999
postype = back
pos = 160,240
random = 320,20
vel = 0,-5 + (random%2)
facing = -1
scale = .8,.8;.3,.3
under = 0
ownpal = 1
trans = add
ignorehitpause = 0

[State Explod]
type = Explod
triggerall = palno = [7,12]
trigger1 = gametime%5 = 0
anim = 25001
sprpriority = 999
postype = back
pos = 160,220
random = 320,20
vel = 0,-5 + (random%2)
facing = -1
scale = .3,.3
under = 0
ownpal = 1
trans = add
ignorehitpause = 0

[State Explod]
type = Explod
triggerall = palno = [7,12]
trigger1 = gametime%5 = 0
anim = 25001
sprpriority = 999
postype = back
pos = 160,220
random = 320,20
bindtime = -1
removetime = 13
supermove = 0
ownpal = 1
scale = .3,.3
under = 0
ownpal = 1
trans = add
ignorehitpause = 0

[State Explod]
type = Explod
triggerall = palno = [7,12]
trigger1 = gametime%5 = 0
anim = 25001
sprpriority = 999
postype = back
pos = 160,220
random = 320,20
vel = 0,-6 + (random%3)
facing = -1
scale = .8,.8;.3,.3
under = 0
ownpal = 1
trans = add
ignorehitpause = 0

[State Explod]
type = Explod
triggerall = palno = [7,12]
trigger1 = gametime%5 = 0
anim = 25001
sprpriority = 999
postype = back
pos = 160,220
random = 320,20
vel = -3+ (random%6),-3
facing = -1
scale = 0.8,0.8
under = 0
ownpal = 1
trans = add
ignorehitpause = 0

[State Explod] 
type = Explod
triggerall = palno = [7,12]
trigger1 = gametime%5 = 0
anim = 25001
sprpriority = 999
postype = back
pos = 160,220
random = 320,20
vel = 0,-3 + (random%3)
facing = -1
scale = .8,.8;.3,.3
under = 0
ownpal = 1
trans = add
ignorehitpause = 0

;---------------------------

[State 0, Beam]
type = Explod
triggerall = alive = 1
triggerall = stateno = 220
trigger1 = time = 59
anim = 11602
ID = 11602
pos = 28,-46
postype = p1  ;p2,front,back,left,right
facing = 1
vfacing = 1
bindtime = 1
vel = 0,0
accel = 0,0
random = 0,0
removetime = 223
pausemovetime = 0
scale = 1.5,1
sprpriority = 5
ontop = 0
shadow = 0,0,0
ownpal = 1
removeongethit = 0

[State 0, Dissapears]
type = ModifyExplod
trigger1 = alive = 0
trigger1 = time = 1
ID = 11602
anim = 11602
pos = 0,0
postype = p1  ;p2,front,back,left,right
facing = 1
vfacing = 1
bindtime = 1
vel = 0,0
accel = 0,0
random = 0,0
removetime = 1
pausemovetime = 0
scale = 0.00001,0.00001
sprpriority = 0
ontop = 0
shadow = 0,0,0
ownpal = 0
removeongethit = 1

[State 0, Beam]
type = Explod
trigger1 = stateno = 220
trigger1 = time = 282
anim = 11603
ID = 11603
pos = 28,-46
postype = p1  ;p2,front,back,left,right
facing = 1
vfacing = 1
bindtime = 1
vel = 0,0
accel = 0,0
random = 0,0
removetime = -2
pausemovetime = 0
scale = 1.5,1
sprpriority = 5
ontop = 0
shadow = 0,0,0
ownpal = 1
removeongethit = 0

;Play the firing beam sound effect
[State 0, PlaySnd]
type = PlaySnd
trigger1 = stateno = 220
trigger1 = time = 59
value = S201,0
volumescale = 90
channel = 5
freqmul = 1.0
loop = 0
pan = 0

;Stop the sound too.
[State 0, StopSnd]
type = StopSnd
trigger1 = stateno = 5050
channel = 5


[State 0, NotHitBy]
type = NotHitBy
trigger1 = time = 250
value = SCA
time = 9999999999999

;Some charging sounds
[State 0, PlaySnd]
type = PlaySnd
trigger1 = alive = 1
triggerall = stateno = 20000
trigger1 = time = 1
value = S21000,0
volumescale = 100
channel = 7
freqmul = 1.0
loop = 0
pan = 0

;Stop the sound too.
[State 0, StopSnd]
type = StopSnd
trigger1 = stateno = 5050
channel = 7

;Some explods below Y.A.M.E.T.E
[State 0, Explod]
type = Explod
triggerall = alive = 1
triggerall = stateno = 20000
trigger1 = time = 1
anim = 6425
ID = 6425
pos = 0,30
postype = p1  ;p2,front,back,left,right
facing = 1
vfacing = 1
bindtime = 1
vel = 0,0
accel = 0,0
random = 0,0
removetime = 300
pausemovetime = 0
scale = 1,1
sprpriority = 7
ontop = 0
shadow = 0,0,0
ownpal = 1
removeongethit = 0

[State 0, Dissapears]
type = ModifyExplod
trigger1 = alive = 0
trigger1 = time = 1
ID = 6425
anim = 6425
pos = 0,0
postype = p1  ;p2,front,back,left,right
facing = 1
vfacing = 1
bindtime = 1
vel = 0,0
accel = 0,0
random = 0,0
removetime = 1
pausemovetime = 0
scale = 0.00001,0.00001
sprpriority = 0
ontop = 0
shadow = 0,0,0
ownpal = 0
removeongethit = 1


;-------------------------------------

;Spawns A Thingy Controller if one doesn't exist already.
[State -2, Helper]
type = Helper
triggerall = NumHelper(50000) = 0
triggerall = Roundstate = 2
trigger1 = 1
helpertype = normal
name = "Explods Master Controller"
ID = 50000
stateno = 50000
pos = 0,-500
postype = p1    ;p2,front,back,left,right
facing = 1
keyctrl = 0
ownpal = 1
supermovetime = 99999
pausemovetime = 99999
ignorehitpause = 1

[State 0, NotHitBy]
type = NotHitBy
trigger1 = 1
value = SCA, AA, AP ,AT

[State -2, Helper]
type = Helper
triggerall = NumHelper(60000) = 0
triggerall = Roundstate = 2
trigger1 = 1
helpertype = normal
name = "Explods Master Controller"
ID = 60000
stateno = 60000
pos = 0,-500
postype = p1    ;p2,front,back,left,right
facing = 1
keyctrl = 0
ownpal = 1
supermovetime = 99999
pausemovetime = 99999
ignorehitpause = 1

[State 0, NotHitBy]
type = NotHitBy
trigger1 = 1
value = SCA, AA, AP ,AT

;StopTheBGM
[State -2, NoMusic]
type = Helper
triggerall = NumHelper(70000) = 0
triggerall = palno = [7,12]
trigger1 = 1
helpertype = normal
name = "NoMusic"
ID = 70000
stateno = 70000
pos = 0,-1000
postype = p1    ;p2,front,back,left,right
facing = 1
keyctrl = 0
ownpal = 1
supermovetime = 9999999999
pausemovetime = 9999999999
ignorehitpause = 1

[State 0, NotHitBy]
type = NotHitBy
trigger1 = 1
value = SCA, AA, AP ,AT

[Statedef 70000]
type = S
movetype = I
physics = N
anim = 70000
velset = 0,0
sprpriority = -9

[State NoMusicFailSafe]
type = AssertSpecial
trigger1 = 1 
flag = nomusic
flag2 = noBG
flag3 = noFG
