;==================================================================================
;==================================================================================
;==================================================================================


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

[Statedef -3]

;CONFIG FOR HYPER PORTRAIT EFFECT
[State -3, Optional Hyper Portrait]
type = VarSet
trigger1 = !time
v = 5
value = 1
; 0 = Marvel vs. Capcom 2 Hyper Effect
; 1 = X-Men vs. Street Fighter Hyper Effect
; NOTE: Using the X-Men vs. Streen Fighter Effect will disable Hyper Backgrounds

;LEAVE EVERYTHING ELSE BELOW ALONE!!!!!!!!!!!!!!!!!!!!!!!!!!!

[State -3, Just in case someone doesn't know what they are doing... -_-]
type = VarSet
trigger1 = var(5)>1
v = 5
value = 0

[State -3, RemoveExplod]
type = RemoveExplod
trigger1 = stateno != 225
id = 225
ignorehitpause = 1
[State -3, RemoveExplod]
type = RemoveExplod
trigger1 = stateno != 250
id = 250
ignorehitpause = 1
[State -3, RemoveExplod]
type = RemoveExplod
trigger1 = stateno != [1100,1109]
id = 1100
ignorehitpause = 1
[State -3, RemoveExplod]
type = RemoveExplod
trigger1 = stateno != [1200,1205]
id = 1205
ignorehitpause = 1
[State -3, RemoveExplod]
type = RemoveExplod
trigger1 = stateno != [1300,1309]
id = 1300
ignorehitpause = 1
[State -3, RemoveExplod]
type = RemoveExplod
trigger1 = stateno != [1400,1409]
id = 1400
ignorehitpause = 1
[State -3, RemoveExplod]
type = RemoveExplod
trigger1 = stateno != [3000,3005]
id = 3000
ignorehitpause = 1
[State -3, RemoveExplod]
type = RemoveExplod
trigger1 = stateno != [3100,3105]
id = 3100
ignorehitpause = 1
[State -3, RemoveExplod]
type = RemoveExplod
trigger1 = stateno != [3200,3205]
id = 3200
ignorehitpause = 1
[State -3, RemoveExplod]
type = RemoveExplod
trigger1 = stateno != [3300,3305]
id = 3300
ignorehitpause = 1
[State -3, RemoveExplod]
type = RemoveExplod
trigger1 = stateno != [3400,3405]
id = 3400
ignorehitpause = 1
[State -3, RemoveExplod]
type = RemoveExplod
trigger1 = stateno != [3500,3505]
id = 3500
ignorehitpause = 1

[State -3, Ariel Assault Var]
type = VarAdd
triggerall = time=1
trigger1 = stateno =500
var(8) = 1

[State -3, Reset Ariel Assault Var]
type = VarSet
trigger1 = statetype !=A&&Var(8)!=0
trigger2 = (stateno = [40,52])||((stateno=625||stateno=650||stateno=655)&&movecontact)
trigger3 = Movetype=H
var(8) = 0

[State -3, Super Jump Reset]
type = VarSet
trigger1 = statetype!=A&&var(11)!=0
trigger2 = stateno=[40,52]
var(11)=0

[State -3, Wall Jump Reset]
type = VarSet
trigger1 = statetype!=A&&var(15)!=0
trigger2 = (stateno=45)
var(15)=0

[State -3, Wall Jump Var]
type = VarAdd
triggerall = time=1
trigger1 = stateno = 103
var(15)=1

[State -3, Head Stomp Var]
type = VarAdd
triggerall = time=1
trigger1 = stateno =645
var(19) = 1

[State -3, Reset Head Stomp Var]
type = VarSet
trigger1 = statetype !=A&&Var(19)!=0
trigger2 = stateno = [40,52]
var(19) = 0

[State -3, Air Dash Var]
type = VarAdd
triggerall = time=1
trigger1 = stateno =102
trigger2 = stateno =107
var(20) = 1

[State -3, Reset Air Dash Var]
type = VarSet
trigger1 = statetype !=A&&Var(20)!=0
trigger2 = stateno = [40,52]
var(20) = 0

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


; Kamek and Luchini appear to have been the first ones to use the IsHomeTeam AI activation concept.
; Feel free to move this controller to your character's intro state for slightly better efficiency.
[State -3, SetAI]
type = VarSet
triggerall = !RoundState
triggerall = IsHomeTeam
trigger1 = (TeamSide = 2)
trigger2 = (MatchNo > 1)
var(59) = 1

; Feel free to move this controller to your character's intro state for slightly better efficiency.
; Note that it may give P2 a slight unfair advantage in simul team vs mode, so you
; may want to disable it.  But then, since when has Mugen been about fairness? =P
[State -3, Unfair]; Is this reliable?
type = VarSet
trigger1 = !RoundState
trigger1 = (var(59) != 1)
trigger1 = NumPartner
trigger1 = (ID > Partner,ID)
trigger1 = (TeamSide = 2)
var(59) = 1

[State -3, AI Helper (Compatibly Partnered Version)]
type = Helper
trigger1 = !var(59)
trigger1 = !NumHelper(9742)
trigger1 = (RoundState = 2)
trigger1 = Alive
trigger1 = NumPartner
trigger1 = Partner,SelfAnimExist(9741)
HelperType = normal
name = "AI Helper (Simul Version)"
ID = 9742
pos = 9999999,99999
StateNo = 9742
KeyCtrl = 1
PauseMoveTime = 999999999
SuperMoveTime = 999999999

; If you want to use the Guard mode, Dummy mode, Distance, or Button jam dummy control
; options in Training mode without activating the dummy's AI while working on your
; character, then all you need to do is temporarily disable this controller.
; Or, if you want to permanently disable this controller in Training mode,
; then you could use the Training mode detection code available on my site
; ( http://www.shinmugen.net/winane/ ), and then just add a "(var(59)&63)>30"
; triggerall to this controller.
[State -3, AI Helper]
type = Helper
triggerall = !var(59)
triggerall = !NumHelper(9741)
triggerall = (RoundState = 2)
triggerall = Alive
trigger1 = !NumPartner
trigger2 = !(Partner,SelfAnimExist(9741))
HelperType = normal
name = "AI Helper"
ID = 9741
pos = 9999999,99999
StateNo = 9741
KeyCtrl = 1
PauseMoveTime = 999999999
SuperMoveTime = 999999999

[State -3, TurnBackOnAI]
type = VarSet
trigger1 = (var(59) = -2)
trigger1 = (RoundState = 2)
trigger1 = Alive
var(59) = 1

[State -3, HitPauseTime Helper]
type = Helper
triggerall = var(59)!=1
triggerall = !NumHelper(9743)
triggerall = (RoundState = 2)
triggerall = Alive
trigger1 = (MatchNo = 1)
trigger2 = NumPartner
trigger2 = (ID > Partner,ID)
HelperType = normal
name = "HitPauseTime"
ID = 9743
pos = 9999999,99999
StateNo = 9743
PauseMoveTime = 999999999
SuperMoveTime = 999999999

; According to Roque, this method works in Linux Mugen version 2002.04.14,
; whereas the old humanly-impossible commands method does not.
; It is very important that this controller NOT be moved to State -2.
; Note that this part won't work if AI.Cheat is turned off in mugen.cfg.
;[State -3, XOR]
;type = VarSet
;triggerall = var(59)!=1
;triggerall = (var(57) = GameTime-1)
;triggerall = NumHelper(9743)
;triggerall = !(Helper(9743),var(1))
;trigger1 = (command = "a") ^^ (command = "a2")
;trigger2 = (command = "b") ^^ (command = "b2")
;trigger3 = (command = "c") ^^ (command = "c2")
;trigger4 = (command = "x") ^^ (command = "x2")
;trigger5 = (command = "y") ^^ (command = "y2")
;trigger6 = (command = "z") ^^ (command = "z2")
;trigger7 = (command = "start") ^^ (command = "start2")
;trigger8 = (command = "holda") ^^ (command = "holda2")
;trigger9 = (command = "holdb") ^^ (command = "holdb2")
;trigger10 = (command = "holdc") ^^ (command = "holdc2")
;trigger11 = (command = "holdx") ^^ (command = "holdx2")
;trigger12 = (command = "holdy") ^^ (command = "holdy2")
;trigger13 = (command = "holdz") ^^ (command = "holdz2")
;trigger14 = (command = "holdstart") ^^ (command = "holdstart2")
;trigger15 = (command = "holdfwd") ^^ (command = "holdfwd2")
;trigger16 = (command = "holdback") ^^ (command = "holdback2")
;trigger17 = (command = "holdup") ^^ (command = "holdup2")
;trigger18 = (command = "holddown") ^^ (command = "holddown2")
;trigger19 = (command = "recovery") ^^ (command = "recovery2")
;Add more as desired. (See my notes in the CMD.)
;var(59) = 1

; It is very important that this controller NOT be moved to State -2, as putting
; it there would defeat the entire purpose of the controller, allowing the
; helper method or the XOR method to erroneously set the AI variable.
; And within State -3, don't put any ChangeState controllers before this
; controller, lest you unnecessarily delay your character's AI activation.
[State -3, GameTimeVar]
type = VarSet
trigger1 = 1
var(57) = GameTime
IgnoreHitPause = 1

; Within StateDef -3, none of your own AI-related code should come after the code
; provided here (and putting it before the code is also generally a bad idea).
; It's better to use State -1 (or, in special circumstances, State -2) instead.

;==================================================================================
;==================================================================================
;==================================================================================

;Ths controller plays a sound everytime the player lands from a jump, or
;from a back-dash.
[State -3, Landing Sound]
type = PlaySnd
triggerall = Time = 1
trigger1 = stateno = 52 ;Jump land
trigger2 = stateno = 106 ;Run-back land
trigger3 = stateno = [900,901]
trigger4 = stateno = 1110
value = s100,0

[State -3, Landing Sound]
type = PlaySnd
triggerall = Time = 1
;trigger1 = stateno = 100 ;Jump land
trigger1 = stateno = 105 ;Run-back land
value = s100,1

[State -3, Landing Anim]
type = Explod
triggerall = Time = 1
trigger1 = stateno = 52 ;Jump land
trigger2 = stateno = 106
trigger3 = stateno = 1110
trigger4 = stateno = 1202
anim = 7503
ID = 8030
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 = -2
supermove = 9999
pausemove = 9999
scale = .6,.6
sprpriority = -1
ontop = 0
shadow = 0,0,0
ownpal = 1
removeongethit = 0
ignorehitpause =1
persistent =0

[State -3, AfterImagePersist]
type=afterimagetime
trigger1=stateno=[3000,3005]
trigger2=stateno=[3100,3105]
trigger3=stateno=[3200,3205]
trigger4=stateno=[3300,3305]
trigger5=stateno=[3400,3405]
trigger6=stateno=[3500,3510]
time=2

[State -3, StopSnd]
type = StopSnd
trigger1 = movetype = H
trigger2 = stateno != [3000,3999]
channel = 15
ignorehitpause = 1

[State -3, AfterImageTime]
type = AfterImageTime
trigger1 = numhelper(7005)=1
time = 0
ignorehitpause = 1
;persistent =  0

;------------------------------------------------------------------------------------------------------
;wall hit
[state 5100,2]
type = explod
triggerall = stateno!=0
triggerall = stateno!=3005
triggerall = stateno!=3000
triggerall = stateno!=1000
triggerall = stateno!=1005
triggerall = stateno!=1010
triggerall = stateno!=50
;triggerall = stateno!=[5000,5999]
;triggerall = movetype ! =H
triggerall = var(42)
triggerall = enemynear,stateno != [120,159]
trigger1 = enemynear,movetype = h
trigger1 = enemynear,backedgedist <= 15
trigger1 = enemynear,statetype = a
trigger1 = enemynear,vel x < 0
anim = 7024
pos = (enemy,const(size.mid.pos.x))-20,(target,const(size.mid.pos.y))
postype = p2
scale = 0.6,0.52
sprpriority = 3
bindtime = 1
facing = -1
removetime = -2
id = 7024
shadow = 0,0,0
ownpal = 1
;removeongethit = 1
;ignorehitpause = 1
;vel = -2,0
;accel = -0.1,0

[state 5100,2]
type = explod
triggerall = stateno!=0
triggerall = stateno!=3005
triggerall = stateno!=3000
triggerall = stateno!=1000
triggerall = stateno!=1005
triggerall = stateno!=1010
triggerall = stateno!=50
;triggerall = stateno!=[5000,5999]
;triggerall = movetype ! =H
triggerall = var(42)
triggerall = enemynear,stateno != [120,159]
trigger1 = enemynear,movetype = h
trigger1 = enemynear,backedgedist <= 15
trigger1 = enemynear,statetype = a
trigger1 = enemynear,vel x < 0
anim = 7024
pos = (enemy,const(size.mid.pos.x))-20,(target,const(size.mid.pos.y))
postype = p2
sprpriority = -3
bindtime = 1
facing = -1
scale = 0.6,0.52
removetime = -2
id = 7024
shadow = -1
ownpal = 1
;removeongethit = 1
;ignorehitpause = 1
;vel = -2,0
;accel = -0.1,0

[state 5100,2]
type = playsnd
triggerall = stateno!=0
triggerall = stateno!=3005
triggerall = stateno!=3000
triggerall = stateno!=1000
triggerall = stateno!=1005
triggerall = stateno!=1010
triggerall = stateno!=50
;triggerall = stateno!=[5000,5999]
;triggerall = movetype ! =H
triggerall = var(42)
triggerall = numenemy
triggerall = enemynear,stateno != [120,159]
trigger1 = stateno != 4003
trigger1 = enemynear,movetype = h
trigger1 = enemynear,backedgedist < 15
trigger1 = enemynear,statetype = a
trigger1 = enemynear,vel x < 0
persistent = 0
value = 7000,2
channel = 4
volume = 255

[state 200, 3]
type = varset
;triggerall = stateno!=[5000,5999]
;triggerall = movetype ! =H
triggerall = var(42)
triggerall = numenemy
trigger1 = enemynear,movetype = h
trigger1 = enemynear,backedgedist < 15
trigger1 = enemynear,statetype = a
trigger1 = enemynear,vel x < 0
v = 42
value = 0

[state -3, 2];combo hosei
type = varset
trigger1 = 1
v = 24
value = var(22)

[state -3, 2];combo hosei
type = varset
trigger1 = 1
v = 22
value = var(25)+hitcount

[state -3, 2];combo hosei
type = varset
trigger1 = enemynear,movetype != H
v = 25
value = 0

;***************
[state -3, 2];combo
type = varset
trigger1 = var(22)>var(24)
v = 42
value = 1

[State -3, VarSet]
type = VarSet
trigger1 = stateno != [3000,3999]
;trigger1 = animtime = 0
v = 45   ;fv = 10
value = 0

