
;---------------------------------------------------------------------------
; Override common states (use same number to override) :
;---------------------------------------------------------------------------

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

; **IMPORTANT NOTE**
; YOU WON'T HAVE TO WORRY FOR THE AI ACTIVATION OR VARIABLE.
; IT IS ALREADY CODED HERE, ALL YOU HAVE TO DO, IS MAKE AI CODES
; IN THE COMMAND FILE


;==================================================================================
;======| RELACIONADO À AI - AI RELATED |===========================================
;==================================================================================

; Within StateDef -2, none of your own AI-related code should be placed
; above these next two controllers.

[State -2, StopAI]
type = VarSet
triggerall = (var(59) > 0)
trigger1 = (RoundState != 2)
trigger2 = !Alive
var(59) = -2
IgnoreHitPause = 1

; This controller is optional.  It allows you treat the AI flag as a boolean
; value rather than an integer value, letting you trigger your AI directives
; with "var(0)" instead of "var(59)>0", and letting you make moves usable only
; by humans by using "!var(0)" instead of "var(59)<1", thus slightly improving
; the size and efficiency of your code.
; Another benefit is that it makes it much easier for users to disable your AI,
; if they so choose.
[State -2, Simplifier]
type = VarSet
trigger1 = (var(59) = 1)
trigger2 = (var(0):=0)
var(0) = 1	; Another option is to replace 1 with something like MatchNo, if
		; you want to design your AI to have varying levels of difficulty.
IgnoreHitPause = 1

[State -2, varKOsnd]
type=varset
trigger1=alive&&var(18)>0
trigger2=!alive&&var(18)<2
var(18)=ifelse(alive,0,var(18)+1)
ignorehitpause=1

[State -3, GetHit Snd]
type=playsnd
triggerall=alive&&time=1
triggerall=stateno=5000||stateno=5010
trigger1=gethitvar(animtype)>=2&&random<500
trigger2=gethitvar(animtype)=1&&random<375
trigger3=gethitvar(animtype)=0&&random<250
value=s5000,(0+(random%6));*10,ceil(random/200)
channel=5
ignorehitpause=1

[State -3, GetHit Snd]
type=playsnd
triggerall=alive&&time=1
trigger1=(stateno=5000||stateno=5010)&&numenemy
trigger1=gethitvar(fall)||(enemynear,hitdefattr=SCA,SA,HA)
trigger2=(stateno=5020||stateno=5070||stateno=5080)
trigger3=(stateno=5050||stateno=5100)&&(prevstateno!=[5000,5199])
value=s5000,(0+(random%6));*10,ceil(random/200)
channel=5
ignorehitpause=1

[State -2, KOsnd]
type=playsnd
trigger1=!alive&&var(18)=1
trigger1=var(18):=2
value=5500,0;ifelse((var(1)=2),2,1)+2*(stateno=5130)
ignorehitpause=1
persistent=0

;---------------------------------------------------
[State -2, Hyper Combo Finish!!]
type = Helper
triggerall = NumHelper(9999) <= 0
triggerall = NumHelper(7610) <= 0
triggerall = (stateno = [3000,3999]) ;|| (stateno = [3700,3799]) || (stateno = [3900,3949])
triggerall = roundstate = 3
trigger1 = Winko
helpertype = normal
name = "HyperFinish"
ID = 9999
stateno = 9999
ownpal = 1
supermovetime = 9999
pausemovetime = 9999
ignorehitpause = 1

[State -2, Fffffinish!!]
type = Helper
triggerall = NumHelper(9998) <= 0
triggerall = NumHelper(9999) <= 0
triggerall = NumHelper(7610) <= 0
triggerall = stateno != [3000,3999]
triggerall = roundstate = 3
trigger1 = Winko
helpertype = normal
name = "Finish"
ID = 9998
stateno = 9998
ownpal = 1
supermovetime = 9999
pausemovetime = 9999
ignorehitpause = 1

;------------------------------------------------------
;signs

[State -2, VS_Combo]
type = VarSet
trigger1 = var(28) >= 3
trigger2 = var(28)=-1 && (movehit || p2movetype = H && p2stateno != [120,159]);p2stateno = [5000,5899])
var(29) = 1+(var(28)>4)+(var(28)>5)+(var(28)>7)+(var(28)>9)+(var(28)>29)+(var(28)>49)+(var(28)>69)-(var(28)=-1)
ignorehitpause = 1

[State -2, Danger]
type = VarSet
trigger1 = var(30) !=1 && roundstate=2 && life = [1,250]
var(29) = 9
ignorehitpause = 1

; sound First attack
[State -2, First Attack]
type = PlaySnd
triggerall = var(28)=-1
triggerall = NumExplod(8701) = 0
trigger1 = var(28)=-1 && (movehit || p2movetype = H && p2stateno != [120,159]);p2stateno = 6300 || p2movetype = H);p2stateno = [5000,5899])
persistent = 0
value = 7050,0
volume=255
ignorehitpause = 1

; Telop sound
[State -2, Combo Sound]
type = PlaySnd
trigger1 = NumExplod(8701) = 0
trigger1 = var(28)=0 && var(29)!=0
persistent = 0;1
value = 7050,var(29)
volume=255
ignorehitpause = 1

[State -2, Left]
type = explod
trigger1 = var(28)=0 && var(29)!=0
trigger2 = var(28)=-1 && (movehit || p2movetype = H && p2stateno != [120,159]);p2stateno = 6300 ||p2movetype = H);p2stateno = [5000,5899])
triggerall = TeamSide = 1 && NumExplod(8701) = 0
anim = (7050 + var(29))
ID = 8701
postype = left
pos = 3,90
ontop = 1
bindtime = -1
removetime = 60
ownpal = 1
supermovetime = 60
pausemovetime = 60
scale = 0.5,0.5
persistent = 0
ignorehitpause = 1

[State -2, Right]
type = explod
trigger1 = var(28)=0 && var(29)!=0
trigger2 = var(28)=-1 && (movehit || p2movetype = H && p2stateno != [120,159]);p2stateno = 6300 ||p2movetype = H);p2stateno = [5000,5899])
triggerall = TeamSide = 2 && NumExplod(8701) = 0
anim = (7150+ var(29));8011;8720;
ID = 8701
postype = right
pos = -10,90;130;82
ontop = 1
bindtime = -1
removetime = 60;90
ownpal = 1
supermovetime = 60;90
pausemovetime = 60;90
scale = 0.5,0.5
persistent = 0;1
ignorehitpause = 1

[State -2, VS_Combo]
type = VarAdd
trigger1 = enemynear, time = 0
trigger1 = enemynear, Hitshakeover = 0
trigger1 = (p2movetype = H && p2stateno != [120,159]);p2stateno = 6300 || p2movetype = H;p2stateno = [5000,5899]
trigger2 = var(28)=-1 && (movehit || p2movetype = H && p2stateno != [120,159]);p2stateno = 6300 || p2movetype = H);p2stateno = [5000,5899])
var(28) = 1 + (var(28)=-1)
ignorehitpause = 1

[State -2, VS_Combo]
type = VarSet
trigger1 = var(28)!=-1 && (p2movetype!=H || enemynear, ctrl)
trigger2 = var(28)=-1 && movetype = H;p2stateno = [5000,5899])
var(28) = 0 - (roundstate<2)
ignorehitpause = 1

[State -2, VS_Combo]
type = VarSet
triggerall = numexplod(8701)!=0
trigger1 = var(28)=0
var(29) = 0
ignorehitpause = 1

[State -2, Score]
type = Varadd
trigger1 = enemynear, time=0
trigger1 = enemynear, Hitshakeover=0
trigger1 = moveguarded || p2stateno = 6300 || p2movetype = H;p2stateno = [5000,5899])
trigger2 = var(28)=-1 && (movehit || p2stateno = 6300 || p2movetype = H);p2stateno = [5000,5899])
trigger3 = roundstate=4 && time=0 && stateno = [180,189]
var(21) = ceil(stateno/50)*var(28) + (life)*(roundstate=4) + (moveguarded)
ignorehitpause = 1

[State -2, Normalize Score]
type = Varset
triggerall = numpartner=1
trigger1 = var(21)< partner, var(21)
var(21) = partner, var(21)

[State -2, Is Danger]
type = VarSet
trigger2 = var(30) = 0 && life <= 250
trigger1 = var(30) = 1 && roundstate!=2
var(30) = (roundstate>1)
ignorehitpause = 1

[State -2, Is First Attack p3]
type = VarSet
triggerall = numpartner=1
trigger1 = partner, movehit
trigger1 = partner, var(28) != -1
var(28) = 0
ignorehitpause = 1

[State -2, AssertSpecial]
type = AssertSpecial
triggerall = roundno = 1
trigger1 = roundstate < 2
flag = nomusic

[State -2, Clipboard]
type = DisplayToClipboard
trigger1 = 1
text = "damage = %f || p2bdX = %f || p2bdY = %f || BED=%d||FED=%d"
params = fVar(10), p2bodydist X, p2bodydist Y, backedgedist, frontedgedist

[State -2, Damage based on hits]
type=varset
trigger1= numenemy
fvar(12)=enemynear,gethitvar(hitcount)
ignorehitpause=1

[State -2, Reset var when the opponent recovers]
type=varset
trigger1= numenemy
trigger1= (enemynear,movetype!=H)
trigger2= !numenemy
fvar(12)=1

[State -2, Dampener]
type=varset
trigger1=stateno!= [1000,3999]
fvar(10)= ifelse(fvar(12)=0, 1, ifelse(fvar(12)=1, 1, .8**fvar(12)))
ignorehitpause=1

[State -2, Dampener]
type=varset
trigger1=stateno= [1000,1999]
fvar(10)= ifelse(fvar(12)=0, 1, ifelse(fvar(12)=1, 1, .9**fvar(12)))
ignorehitpause=1

[State -2, Dampener]
type=varset
trigger1=stateno = [3000,3999]
fvar(10)= ifelse(fvar(12)=0, 1, ifelse(fvar(12)=1, 1, .95**fvar(12)))
ignorehitpause=1

[State -2, Dampener itself]
type=attackmulset
trigger1= 1
value=fvar(10)
ignorehitpause=1

