;Coding/Tutorial by Flawless & Humanoid Typhoon & Seravy
;Use Ctrl+F to navigate easier.

;Sometimes the command="start" is supposed to be command="s"
;It varies by character. Change In (Statedef 12345) or in the character's .CMD file.

;If you have to you can change these variables into variables that you're character is NOT using.


;Variables IN USE for this TOOL

;fvar(36)
;fvar(37)
;fvar(38)
;fvar(39)



;Cut this out and put this in the character overrides area which is - (Statedef -2)




 
;These Initialize before the start of the round. (statedef 5900)
;You can also disable XCOSTUME by changing a value (see below).

[statedef 5900]
type = S

[state 5900, Reset Variables]
type = varrangeset
trigger1 = !roundsexisted && matchno = 1
value = 0
[state 5900, Reset Variables]
type = varrangeset
trigger1 = !roundsexisted && matchno = 1
fvalue = 0

 ; Palette Selector
[State 5900, Palette Selector]
type = VarSet
trigger1 = 1
fv = 37
value = 1

; If value = 1 Palette Selector is ON
; If value = 0 Palette Selector is OFF 
 
 
[State 5900, Pal Selector on]
type=helper
triggerall=fvar(37)&&!numhelper(12345)&&!AILevel&&numenemy
trigger1= roundno = 1 && matchno=1 && !(teammode = simul) && !(enemy, teammode = simul)
trigger2= !fvar(36) 
trigger3=(teammode = turns)
trigger3=!roundsexisted && (enemy,roundsexisted)
id=12345
stateno=12345
facing=facing
ownpal=1
size.xscale = .25
size.yscale = .25

[state 5900, No Palette selector]
type = remappal
trigger1 = !fvar(37)||AILevel
source = 1, 1
dest = 1, palno
ignorehitpause = 1

[State 5900, Intro]
type = ChangeState
trigger1 = roundno = 1
value = 190

[State 5900, Turns Intro]
type = ChangeState
trigger1 = !RoundsExisted
trigger1 = teammode = Turns
value = 190

[State 5900, Start round timer if No Intro Available]
type = ChangeState
trigger1 = 1
value = 0
 
 
 
 
;This is the palette selector helper (statedef 12345)
;You can change the animation size using the x-y scales.

[Statedef 12345]
physics = N
anim = 12345
velset=0,0
sprpriority=99999
 
[State 12345, PosSet]
type = PosSet
trigger1 =!time 
x = root,facing*-90
y = 25
ignorehitpause = 1
 
[State 12345, AS]
type=assertspecial
trigger1=1
flag=intro
flag2=noshadow

[State 12345, Reset]
type=varset
trigger1=!time
fvar(38)=200

[State 12345, Pal]
type=varset
trigger1=!time
fvar(36)=root,palno
 
[State 12345, Varset]
type=varset
trigger1=fvar(36)<1||fvar(36)>13 ; last palette
fvar(36)=1+(fvar(36)<1)*12 ; subtract -1 from your last palette
 
[State 12345, PlaySnd]
type = PlaySnd
trigger1 =fvar(39)=2 
value = S12345,0
volumescale = 100
channel = 20

[State 12345, PlaySnd]
type = PlaySnd
triggerall=ishelper(12345)
trigger1=  root,command="x"||root,command="a"||root,command="z"||root,command="c"||root,command="y"||root,command="b"
value = S12345,1
volumescale = 100
channel = 20
persistent =0 
 
[State 12345, Countdown]
type = VarAdd
trigger1 =1 
fvar(38)=-1

[State 12345, Countdown]
type = VarAdd
trigger1=!fvar(39)&&fvar(38)<150
trigger1=root,command="holdup"||root,command="holddown"||root,command="holdback"||root,command="holdfwd"
fvar(38)=25
 
[State 12345, Varadd]
type=varadd
trigger1=!fvar(39)
trigger1=root,command="holdup"||root,command="holddown"||root,command="holdback"||root,command="holdfwd"
fvar(36)=1-(root,command="holddown"||root,command="holdback"&&facing=1||root,command="holdfwd"&&facing=-1)*2
 
[State 12345, Varadd]
type=varadd
trigger1=(root,command="holdup"||root,command="holddown"||root,command="holdback"||root,command="holdfwd")&&!fvar(39)||fvar(39)
fvar(39)=1
 
[State 12345, Varset]
type=varset
trigger1=!time||fvar(39)>=17
fvar(39)=0
 
[State 12345, End]
type=destroyself
triggerall=ishelper(12345)
trigger1= root,command="x"||root,command="a"||root,command="z"||root,command="c"||root,command="y"||root,command="b"||root,command="start"
trigger2=root,AILevel
