;===========================================================================
; - - - - - - - - WELCOME TO THE SHOP ! OWNED BY TINGLE - - - - - - - - - - 
;  EVEN IF HE'S YOUR FRIEND, DON'T EXPECT HIM TO MAKE YOU SOME LOW PRICES !
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;===========================================================================

;===========================================================================
; TINGLE APPEARS
;===========================================================================
[StateDef 19000] ; "I'm flying like a fairy !"
type = A
movetype = I
physics = N
ctrl = 0
anim = 19000
velset = .5,1
sprpriority = 5

[State 19000, Pos - Solo]
type = PosSet
triggerall = Time = 0
trigger1 = !NumPartner
trigger2 = NumPartner
trigger2 = (Root, ID) < (Partner, ID)
X = 10*(1-2*(TeamSide = 2))
Y = -(Root, ScreenPos Y)-90

[State 19000, Pos - Partner]
type = PosSet
trigger1 = Time = 0
trigger1 = NumPartner
trigger1 = (Root, ID) > (Partner, ID)
X = 40*(1-2*(TeamSide = 2))
Y = -(Root, ScreenPos Y)-90

[State 19000, I'm here, don't fight !]
type = AssertSpecial
trigger1 = Vel Y >= 0
flag = intro

[State 19000, Wow-wow]
type = VelMul
trigger1 = !(Time%20)
trigger1 = Anim = 19000
trigger1 = Time
X = -1

[State 19000, Stop, please : I'm falling !]
type = VelSet
trigger1 = Anim != 19000
trigger1 = Vel X
X = 0

[State 19000, Woops !]
type = ChangeAnim
triggerall = Root, command = "start"
triggerall = Anim = 19000
triggerall = Vel Y = 0
trigger1 = !NumPartner
trigger2 = NumPartner
trigger2 = Partner, name != "Link 0.95"
trigger3 = NumPartner
trigger3 = Partner, name = "Link 0.95"
trigger3 = !(Partner, NumHelper(19000))
trigger4 = NumPartner
trigger4 = Partner, name = "Link 0.95"
trigger4 = !(Partner, NumHelper(19001))
value = 19001

[State 19000, StopPartner]
type = Helper
trigger1 = Anim = 19001
trigger1 = !NumHelper(19001)
name = "stoppartner"
ID = 19001
stateno = 19010

[State 19000, Falling]
type = ChangeState
trigger1 = Anim = 19001
trigger1 = AnimTime = 0
value = 19001

[State 19000, Stop&Bye]
type = VelAdd
triggerall = Anim = 19000
trigger1 = Time = 80
trigger2 = Time = 200
Y = -1

[State 19000, Snd]
type = PlaySnd
trigger1 = Vel Y = -1
persistent = 0
value = 190,3

[State 19000, Bye !]
type = DestroySelf
trigger1 = ScreenPos Y <= -100

;------------------------------------------------
[StateDef 19001] ; "Woops... I guess I don't have wings :("
type = A
movetype = I
physics = N
velset = 0,0
anim = 19002

[State 19001, I'm here, don't fight !]
type = AssertSpecial
trigger1 = 1
flag = intro

[State 19001, Pos]
type = PosAdd
trigger1 = Time = 0
X = 16
Y = 92

[State 19002, Snd]
type = PlaySnd
trigger1 = Time = 0
value = 5,1

[State 19001, debug]
type = DisplayToClipboard
trigger1 = 1
text = "pos = (%d,%d), vel = %f"
params = Floor(Pos X), Floor(Pos Y), (Vel Y)

[State 19001, Hu-ho...]
type = VelSet
trigger1 = Time = 20
Y = 5

[State 19001, Fly ! Fly ! Fly !]
type = VelMul
trigger1 = Pos Y > -50
trigger1 = Vel Y > .5
Y = 0.9

[State 19001, Land]
type = StateTypeSet
trigger1 = Pos Y > 0
trigger1 = Vel Y >= 0
statetype = S

[State 19001, Stay on the ground]
type = VelSet
trigger1 = Vel Y > 0
trigger1 = StateType = S
Y = 0

[State 19001, Replace]
type = PosSet
trigger1 = StateType = S
trigger1 = Pos Y > 0
Y = 0

[State 19001, I want to fly again !]
type = ChangeState
trigger1 = StateType = S
trigger1 = (Pos Y = 0) && (Vel Y = 0)
value = 19002

;------------------------------------------------
[StateDef 19002] ; I'm on the ground again...
type = S
movetype = I
physics = N

[State 19001, debug]
type = DisplayToClipboard
trigger1 = 1
text = "pos = (%d,%d), vel = %f"
params = Floor(Pos X), Floor(Pos Y), (Vel X)

[State 19002, Jump]
type = VelSet
trigger1 = Time = 10
X = 3
Y = -3

[State 19002, R-Type]
type = StateTypeSet
trigger1 = StateType = S
trigger1 = Pos Y < 0
StateType = A

[State 19002, I'm here, don't fight !]
type = AssertSpecial
trigger1 = 1
flag = intro
flag2 = noautoturn

[State 19002, Yeepee !]
type = ChangeAnim
trigger1 = StateType = A
value = 19003
elem = 2

[State 19002, What a fucking gravity :þ]
type = VelAdd
trigger1 = StateType = A
Y = .3

[State 19002, Land]
type = StateTypeSet
trigger1 = StateType = A
trigger1 = Pos Y >= 0
statetype = S

[State 19002, GBA]
type = Helper
trigger1 = StateType = S
trigger1 = !NumHelper(19100)
trigger1 = facing = 1
name = "GBA"
ID = 19100
stateno = 19100
ownpal = 1

[State 19002, Land]
type = VelSet
trigger1 = StateType = S
trigger1 = Vel Y > 0
Y = 0

[State 19002, Land]
type = PosSet
trigger1 = StateType = S
trigger1 = Pos Y > 0
Y = 0

[State 19002, Snd]
type = PlaySnd
trigger1 = Pos Y = 0
trigger1 = Vel Y = 0
trigger1 = StateType = S
persistent = 0
value = 190,3

[State 19002, Bye !]
type = DestroySelf
trigger1 = Screenpos X != [-60,380]

;------------------------------------------------
[StateDef 19010] ; Avoid Link Partner opens his own shop
type = A
movetype = I
physics = N
anim = 362
ctrl = 0

[State 19010, Shop]
type = VarSet
trigger1 = NumHelper(19100)
var(0) = 1

[State 19010]
type = DestroySelf
trigger1 = var(0)
trigger1 = !NumHelper(19100)

;===========================================================================
; THE GAME-BOY ADVANCE MODULE
;===========================================================================
[StateDef 19100] ; The GBA appears
type = A
movetype = I
physics = N
anim = 19100
ctrl = 0
sprpriority = 4

[State 19100, Intro]
type = AssertSpecial
trigger1 = 1
flag = intro

[State 19100, StartPos]
type = PosSet
trigger1 = time = 0
X = IfElse((parent, Facing) = 1,-512,188)
Y = -ScreenPos Y

[State 19100, VelIni]
type = VelSet
trigger1 = time = 0
X = IfElse((Pos X) < 0,5,-5)

[State 19100, Replace]
type = PosSet
trigger1 = Pos X > -162
X = -162

[State 19100, Stop]
type = VelSet
trigger1 = Pos X = -162
X = 0

[State 19100, Screen]
type = Explod
trigger1 = Pos X = -162
trigger1 = !NumExplod(19101)
anim = 19101
ID = 19101
postype = left
pos = 90,82
bindtime = -1
sprpriority = 5

[State 19100, This is the end]
type = ChangeState
triggerall = Pos X = -162
trigger1 = Root, command = "start"
trigger2 = Root, var(58) < 50
value = 19110

;------------------------------------------------
[StateDef 19110] ; The GBA disappears
type = A
movetype = I
physics = N
velset = 5,0

[State 19110, StopScreen]
type = RemoveExplod
trigger1 = Time = 0
ID = 19101

[State 19110, Snd]
type = PlaySnd
trigger1 = Time = 0
value = 11000,4

[State 19110, Intro]
type = AssertSpecial
trigger1 = Pos X < 120
flag = intro

[State 19110, End]
type = DestroySelf
trigger1 = RoundState = 2

;------------------------------------------------
[StateDef 19200] ; Object Selection
type = A
movetype = I
physics = N
velset = 0,0
anim = 19201
ctrl = 0
sprpriority = 5

[State 19200, NoFG]
type = AssertSpecial
trigger1 = 1
flag = nofg

[State 19200, FadeBG]
type = BGPalFX
trigger1 = 1
time = 1
add = -100,-100,-100

[State 19200, On The Screen]
type = PosSet
trigger1 = Time = 0
X = -70
Y = -(screenpos Y)+82

[State 19200, NoCommand]
type = VarSet
trigger1 = var(0)
trigger1 = AnimElem = 1, = 10
var(0) = 0

[State 19200, TypeAnim]
type = VarSet
trigger1 = !var(1)
trigger1 = Anim = [19301,19325]
trigger2 = var(1)
trigger2 = Anim = [19201,19225]
var(1) = 1-var(1)

[State 19200, Command]
type = VarSet
trigger1 = !var(0)
trigger1 = root, command = "holdfwd"
var(0) = 1

[State 19200, Command]
type = VarSet
trigger1 = !var(0)
trigger1 = root, command = "holdback"
var(0) = -1

[State 19200, Arrow]
type = Explod
trigger1 = abs(var(0)) = 1
trigger1 = !NumExplod(19980)
anim = 19981+var(0)
ID = 19980
pos = 1+134*(var(0)=1),42
removetime = -1
ontop = 1
ownpal = 1

[State 19200, EndCommand]
type = VarSet
trigger1 = var(0)
trigger1 = !(root, command = "holdfwd")
trigger1 = !(root, command = "holdback")
var(0) = var(0)*2

[State 1920, EndArrow]
type = RemoveExplod
trigger1 = !var(0)
trigger1 = NumExplod(19980)
ID = 19980

[State 19200, Command]
type = VarSet
triggerall = !var(5)
trigger1 = root, command = "holdup"
trigger2 = root, command = "holddown"
var(5) = 1

[State 19200, EndCommand]
type = VarSet
trigger1 = var(5) = 1
trigger1 = !(root, command = "holdup")
trigger1 = !(root, command = "holddown")
var(5) = 2

[State 19200, ItemSnd]
type = PlaySnd
trigger1 = abs(var(0)) = 1
trigger1 = AnimElem = 1, > 9
trigger2 = abs(var(0)) = 2
value = 11000,5

[State 19200, Item Up]
type = ChangeAnim
trigger1 = var(0) > 0
trigger1 = AnimElem = 1, > 9
value = IfElse((Anim-100*var(1) < 19225),(Anim-100*var(1))+1,(Anim-100*var(1))-24)

[State 19200, Item Down]
type = ChangeAnim
trigger1 = var(0) < 0
trigger1 = AnimElem = 1, > 9
value = IfElse((Anim-100*var(1) > 19201),(Anim-100*var(1))-1,(Anim-100*var(1))+24)

;-----------------------------------------------------------------------------------------------;
; The following controller is really important !!!						;
; DO NOT MODIFY IT IF YOU DON'T UNDERSTAND HOW IT WORKS OR YOU MAY RUIN THE SHOP SYSTEM !!!!! 	;
; The following controller check if the displayed object on the GBA can be bought or not. So it ;
; checks the following points :									;
; * Do you have enough money ?									;
; * Do you already own the object (except for Bottles, Bottle items, Arrows and Bombs) ?	;
; * Do you have the needed objects to buy this one ?						;
; * For Bottles : do you already have four bottles ?						;
; * For Bottle Items : are your bottles already all filled ?					;
; * For Bombs and Arrows : have you already the max number of these items ?			;
;-----------------------------------------------------------------------------------------------;

[State 19200, Unavailable]
type = ChangeAnim
triggerall = Anim < 19300 ; not already unavailable
;---------------------------------------------------------------------------
trigger1 = root, var(58) < 50 ; not enough money !
;---------------------------------------------------------------------------
trigger2 = Anim = [19201,19218] ; "Normal" object... 
trigger2 = (root, var(57) & 2**(Anim-19201)) != 0 ; ...aleady bought
;---------------------------------------------------------------------------
trigger3 = Anim = 19204 ; Hylian Symbol
trigger3 = (root, var(58)) < 100
;---------------------------------------------------------------------------
trigger4 = Anim = 19205 ; Hammer
trigger4 = (MatchNo < 3) || ((root, var(57) & 1) = 0)
;---------------------------------------------------------------------------
trigger5 = Anim = 19206 ; Ocarina
trigger5 = (MatchNo < 3) || (root, var(58) < 100) || ((root, var(57) & 8) = 0)
;---------------------------------------------------------------------------
trigger6 = Anim = 19207 ; Hookshot
trigger6 = (MatchNo < 3) || (root, var(58) < 150) || ((root, var(57) & 8) = 0) || ((root, var(57) & 4) = 0)
;---------------------------------------------------------------------------
trigger7 = Anim = 19208 ; Poisonned Arrows
trigger7 = ((root, var(57) & 2) = 0) || (MatchNo < 4) || (root, var(58) < 100)
;---------------------------------------------------------------------------
trigger8 = Anim = 19209 ; Powder Keg
trigger8 = (MatchNo < 4) || (root, var(58) < 150) || ((root, var(57) & 1) = 0) || (Floor((root, fvar(38)-Floor(root, fvar(38)))*100) = 0)
;---------------------------------------------------------------------------
trigger9 = Anim = 19210 ; Inquirring Arrows
trigger9 = (MatchNo < 5) || (root, var(58) < 100) || ((root, var(57) & 2) = 0) || ((root, var(57) & 32) = 0)
;---------------------------------------------------------------------------
trigger10 = Anim = [19211,19212] ; Ice & Fire Staffs
trigger10 = (MatchNo < 5) || (root, var(58) < 200) || ((root, var(57) & 8) = 0) || ((root, var(57) & 2) = 0)
;---------------------------------------------------------------------------
trigger11 = Anim = 19213 ; Mushu
trigger11 = (MatchNo < 6) || (root, var(58) < 250) || ((root, var(57) & 64) = 0)
;---------------------------------------------------------------------------
trigger12 = Anim = 19214 ; Biggoron Sword
trigger12 = (MatchNo < 6) || (root, var(58) < 300) || ((root, var(57) & 8) = 0) || ((root, var(57) & 1) = 0) || ((root, var(57) & 64) = 0)
;---------------------------------------------------------------------------
trigger13 = Anim = 19215 ; Mirror Shield
trigger13 = (MatchNo < 7) || (root, var(58) < 300) || ((root, var(57) & 8192) = 0)
;---------------------------------------------------------------------------
trigger14 = Anim = 19216 ; Spooky's Mask
trigger14 = (MatchNo < 7) || (root, var(58) < 400) || ((root, var(57) & 2048) = 0)
;---------------------------------------------------------------------------
trigger15 = Anim = 19217 ; Nayru's love
trigger15 = (MatchNo < 8) || (root, var(58) < 500) || ((root, var(57) & 32768) = 0)
;---------------------------------------------------------------------------
trigger16 = Anim = 19218 ; Majora's Mask - Not Used Yet
;---------------------------------------------------------------------------
trigger17 = Anim = 19219 ; Bottle
trigger17 = (root, var(58)<100) || ((Floor(root, fvar(39)*10) != 0) && (Floor(root, fvar(39)*100)%10 != 0) && (Floor(root, fvar(39)*1000)%10 != 0) && (Floor(root, fvar(39)*10000)%10 != 0))
;---------------------------------------------------------------------------
trigger18 = Anim = 19220 ; Bottle item = fairy
trigger18 = (MatchNo < 3) || (root, var(58)<100) || ((Floor(root, fvar(39)*10) != 1) && (Floor(root, fvar(39)*100)%10 != 1) && (Floor(root, fvar(39)*1000)%10 != 1) && (Floor(root, fvar(39)*10000)%10 != 1))
;---------------------------------------------------------------------------
trigger19 = Anim = [19221,19222] ; Bottle item = life or mana potion
trigger19 = (MatchNo < 3) || (root, var(58)<150) || ((Floor(root, fvar(39)*10) != 1) && (Floor(root, fvar(39)*100)%10 != 1) && (Floor(root, fvar(39)*1000)%10 != 1) && (Floor(root, fvar(39)*10000)%10 != 1))
;---------------------------------------------------------------------------
trigger20 = Anim = 19223 ; Bottle item = complete potion
trigger20 = (MatchNo < 3) || (root, var(58)<200) || ((Floor(root, fvar(39)*10) != 1) && (Floor(root, fvar(39)*100)%10 != 1) && (Floor(root, fvar(39)*1000)%10 != 1) && (Floor(root, fvar(39)*10000)%10 != 1))
;---------------------------------------------------------------------------
trigger21 = Anim = 19224 ; Arrows
trigger21 = (MatchNo < 3) || ((root, var(57) & 2) = 0) || (Floor(root, fvar(38)) = Floor(root, fvar(37))) || (root, var(56) & 16)
;---------------------------------------------------------------------------
trigger22 = Anim = 19225 ; Bombs
trigger22 = Floor((root, fvar(38)-Floor(root, fvar(38)))*100) = Floor((root, fvar(37)-Floor(root, fvar(37)))*100) || (root, var(56) & 64)
;---------------------------------------------------------------------------
value = Anim + 100

[State 19200, Unavailable Reason : already owned]
type = Explod
trigger1 = anim > 19300
trigger1 = !NumExplod(19219)
trigger1 = Anim = [19301,19318] ; "Normal" object... 
trigger1 = (root, var(57) & 2**(Anim-19301)) != 0 ; ...aleady owned
ID = 19219
anim = 19505
postype = left
pos = 160,100
ownpal = 1
ontop = 1
removetime = -1

[State 19200, Unavailable Reason : Stock Max]
type = Explod
triggerall = anim > 19300
triggerall = !NumExplod(19219)
trigger1 = Anim = 19319
trigger1 = Floor(root,fvar(39)*10) > 0
trigger1 = Floor(root,fvar(39)*100)%10 > 0
trigger1 = Floor(root,fvar(39)*1000)%10 > 0
trigger1 = Floor(root,fvar(39)*10000)%10 > 0
trigger2 = Anim = 19324
trigger2 = (Floor(root,fvar(38)) = Floor(root,fvar(37))) || (root, var(56) & 16)
trigger3 = Anim = 19325
trigger3 = (Floor(root,fvar(38)*100)%100 = Floor(root,fvar(37)*100)%100) || (root, var(56) & 64)
ID = 19219
anim = 19502
postype = left
pos = 160,100
ownpal = 1
ontop = 1
removetime = -1

[State 19200, Unavailable Reason : Full Bottles]
type = Explod
triggerall = anim = [19320,19323]
triggerall = !NumExplod(19219)
trigger1 = Floor(root,fvar(39)*10)%10 != 1
trigger1 = Floor(root,fvar(39)*100)%10 != 1
trigger1 = Floor(root,fvar(39)*1000)%10 != 1
trigger1 = Floor(root,fvar(39)*10000)%10 != 1
ID = 19219
anim = 19501
postype = left
pos = 160,100
ownpal = 1
ontop = 1
removetime = -1

[State 19200, Unavailable Reason : not enough experience]
type = Explod
triggerall = anim > 19300
triggerall = !NumExplod(19219)
trigger1 = (Anim = [19305,19307]) || (Anim = [19321,19323])
trigger1 = MatchNo < 3
trigger2 = Anim = [19308,19309]
trigger2 = MatchNo < 4
trigger3 = Anim = [19310,19312]
trigger3 = MatchNo < 5
trigger4 = Anim = [19313,19314]
trigger4 = MatchNo < 6
trigger5 = Anim = [19315,19316]
trigger5 = MatchNo < 7
trigger6 = Anim = 19317
trigger6 = MatchNo < 8
trigger7 = Anim = 19318
ID = 19219
anim = 19500
postype = left
pos = 160,100
ownpal = 1
ontop = 1
removetime = -1

[State 19200, Unavailable Reason : Missing object]
type = Explod
triggerall = anim > 19300
triggerall = !NumExplod(19219)
trigger1 = Anim = 19305
trigger1 = (root, var(57) & 1) = 0
trigger2 = Anim = 19306
trigger2 = (root, var(57) & 8) = 0
trigger3 = Anim = 19307
trigger3 = ((root, var(57) & 4) = 0) || ((root, var(57) & 8) = 0)
trigger4 = (Anim = 19308) || (Anim = 19324)
trigger4 = (root, var(57) & 2) = 0
trigger5 = Anim = 19309
trigger5 = ((root, var(57) & 1) = 0) || (Floor(root,fvar(38)*100)%100=0)
trigger6 = Anim = 19310
trigger6 = ((root, var(57) & 2) = 0) || ((root, var(57) & 32) = 0)
trigger7 = Anim = [19311,19312]
trigger7 = ((root, var(57) & 2) = 0) || ((root, var(57) & 8) = 0)
trigger8 = Anim = 19313
trigger8 = (root, var(57) & 64) = 0
trigger9 = Anim = 19314
trigger9 = ((root, var(57) & 1) = 0) || ((root, var(57) & 64) = 0)
trigger10 = Anim = 19315
trigger10 = (root, var(57) & 8192) = 0
trigger11 = Anim = 19316
trigger11 = (root, var(57) & 2048) = 0
trigger12 = Anim = 19317
trigger12 = (root, var(57) & 8) = 0
trigger12 = (root, var(57) & 32768) = 0
ID = 19219
anim = 19504
postype = left
pos = 160,100
ownpal = 1
ontop = 1
removetime = -1

[State 19200, Unavailable Reason : not enough money]
type = Explod
triggerall = anim > 19300
triggerall = !NumExplod(19219)
trigger1 = (Anim = [19301,19303]) || (Anim = 19305) || (Anim = [19324,19325])
trigger1 = Root, var(58) < 50
trigger2 = (Anim = 19304) || (Anim = 19306) || (Anim = 19308) || (Anim = 19310) || (Anim = [19319,19320])
trigger2 = Root, var(58) < 100
trigger3 = (Anim = 19307)  || (Anim = 19309) || (Anim = [19321,19322])
trigger3 = Root, var(58) < 150
trigger4 = (Anim = [19311,19312]) || (Anim = 19323)
trigger4 = Root, var(58) < 200
trigger5 = Anim = 19313
trigger5 = Root, var(58) < 250
trigger6 = Anim = [19314,19315]
trigger6 = Root, var(58) < 300
trigger7 = Anim = 19316
trigger7 = Root, var(58) < 400
trigger8 = Anim = 19317
trigger8 = Root, var(58) < 500
ID = 19219
anim = 19503
postype = left
pos = 160,100
ownpal = 1
ontop = 1
removetime = -1

[State 19200, Pay !]
type = ParentVarAdd
triggerall = var(5) = 2
trigger1 = var(2):= ((Anim = [19201,19203]) || (Anim = 19205) || (Anim = 19218) || (Anim = [19224,19225]))
trigger2 = var(2):= 2*((Anim = 19204) || (Anim = 19206) || (Anim = 19208) || (Anim = 19210) || ((Anim = [19219,19220]) && (var(5)=2)))
trigger3 = var(2):= 3*((Anim = 19207) || (Anim = 19209) || ((Anim = [19221,19222]) && (var(5)=2)))
trigger4 = var(2):= 4*((Anim = [19211,19212]) || ((Anim = 19223) && (var(5)=2)))
trigger5 = var(2):= 5*(Anim = 19213)
trigger6 = var(2):= 6*(Anim = [19214,19215])
trigger7 = var(2):= 8*(Anim = 19216)
trigger8 = var(2):= 10*(Anim = 19217)
var(58) = -50*var(2)

[State 19200, Buy a normal object]
type = ParentVarAdd
trigger1 = Anim = [19201,19218]
trigger1 = var(5) = 2
var(57) = 2**(Anim-19201)

[State 19200, Debug]
type = DisplayToClipboard
trigger1 = 1
text = "fv(38)=%d"
params = (root, fvar(38))

[State 19200, Buy a bottle]
type = ParentVarAdd
trigger1 = Anim = 19219
trigger1 = var(5) = 2
fvar(39) = IfElse(Floor(root, fvar(39)*10)%10 = 0,0.1,IfElse(Floor(root, fvar(39)*100)%10 = 0,0.01,IfElse(Floor(root, fvar(39)*1000)%10 = 0,0.001,0.0001)))

[State 19200, Buy a bottle item]
type = ParentVarAdd
trigger1 = Anim = [19220,19223]
trigger1 = var(5) = 2
fvar(39) = IfElse(Floor(root, fvar(39)*10)%10 = 1,0.1*(Anim-19219),IfElse(Floor(root, fvar(39)*100)%10 = 1,0.01*(Anim-19219),IfElse(Floor(root, fvar(39)*1000)%10 = 1,0.001*(Anim-19219),0.0001*(Anim-19219))))

[State 19200, Buy Arrows]
type = ParentVarSet
trigger1 = Anim = 19224
trigger1 = var(5) = 2
fvar(38) = IfElse(Floor((root,fvar(38))+Floor(root,fvar(35)))>(Floor(root,fvar(37))),Floor(root,fvar(37))+(root,fvar(38)-Floor(root,fvar(38))),Floor(root,fvar(35))+root,fvar(38))
;10.0+(root,fvar(38)-Floor(root,fvar(38)))

[State 19200, Buy Bombs]
type = ParentVarSet
trigger1 = Anim = 19225
trigger1 = var(5) = 2
fvar(38) = IfElse((root,fvar(37)-Floor(root,fvar(37)))>((root,fvar(38)-Floor(root,fvar(38)))+((root,fvar(35)-Floor(root,fvar(35))))),(root,fvar(38)+(root,fvar(35)-Floor(root,fvar(35)))),Floor(root,fvar(38))+(root,fvar(37)-Floor(root,fvar(37))))
;Floor(root,fvar(38))+0.10

[State 19200, BuySnd]
type = PlaySnd
trigger1 = Anim = [19201,19225]
trigger1 = var(5) = 2
value = 19000,1 ; 320,0

[State 19200, Can't Buy Snd]
type = PlaySnd
trigger1 = Anim = [19301,19325]
trigger1 = var(5) = 2
value = 320,3

[State 19200, ResetBuy]
type = VarSet
trigger1 = var(5) = 2
;trigger2 = time %10 = 0
var(5) = 0

[State 19200, RemoveReason]
type = RemoveExplod
trigger1 = var(0)
trigger2 = var(5)
trigger3 = root, command = "start"
trigger4 = root, var(58) < 50
ID = 19219

[State 19200, End]
type = DestroySelf
trigger1 = root, command = "start"
trigger2 = root, var(58) < 50








