;======================================================================
;======================================================================
; -3 states file for "Warakia_X"
;======================================================================
;======================================================================

;----------------------------------------------------------------------
; Automatic ChangeState
;----------------------------------------------------------------------
;
; var(55) 	- Variable (e.g. Walk)
; var(56)	- Attack or No-Attack(Randomize)
; var(57)	- 
; var(58)	-
; var(59)	- A.C Flag

;----------------------------------------------------------------------
; Walk(AC)

[Statedef 40020]
type    = S
physics = S
sprpriority = 0

[State 40020, 1]
type = VelSet
trigger1 = var(55) = 1
x = const(velocity.walk.fwd.x)

[State 40020, 2]
type = VelSet
trigger1 = var(55) = 2
x = const(velocity.walk.back.x)

[State 40020, 3]
type = ChangeAnim
triggerall = vel x > 0
trigger1 = Anim != 20 && Anim != 5
trigger2 = Anim = 5 && AnimTime = 0
value = 20

[State 40020, 4]
type = ChangeAnim
triggerall = vel x < 0
trigger1 = Anim != 21 && Anim != 5
trigger2 = Anim = 5 && AnimTime = 0
value = 21

[State 40020, AC_Walk]
type = VarSet
triggerall = Alive
triggerall = RoundState = 2
triggerall = var(59) = 1
triggerall = var(55) = 1
trigger1 = ceil(P2Dist X) <= 70
var(55) = 0

[State 40020, AC_Walk]
type = VarSet
triggerall = Alive
triggerall = RoundState = 2
triggerall = var(59) = 1
triggerall = var(55) = 2
trigger1 = ceil(P2Dist X) >= 220
var(55) = 0

[State 40020, ChangeState]
type = ChangeState
trigger1 = var(55) = 0
value = 0

[Statedef -3]

;----------------------------------------------------------------------
; Initialize

[State -3, VarSet]
type = VarSet
triggerall = Alive
triggerall = RoundState = 2
trigger1 = command = "AC_01"
var(59) = 1
ignorehitpause = 1

[State -3, AC]
type = Null;CtrlSet
trigger1 = var(59) = 1
value = 0
ignorehitpause = 1

[State -3, VarRandom]
type = VarRandom
triggerall = Alive
triggerall = RoundState = 2
triggerall = var(59) = 1
trigger1 = GameTime % 30 = 0
v = 56
range = 0,99
ignorehitpause = 1

;----------------------------------------------------------------------
; Guard

[State -3, AC_Guard_Stand]
type = ChangeState
triggerall = Alive
triggerall = RoundState = 2
triggerall = var(59) = 1
triggerall = StateType != A
triggerall = Ctrl
triggerall = var(56) = [0,39]
triggerall = StateNo != [530,563]
trigger1 = InGuardDist
;trigger1 = EnemyNear,StateType = S
;trigger1 = EnemyNear,MoveType = A
;trigger1 = EnemyNear,HitDefAttr = SCA,NA,SA,HA,NP,SP,HP
;trigger2 = InGuardDist
;trigger2 = Enemy,NumHelper > 0 || Enemy,NumProj > 0
value = 120

[State -3, AC_Guard_Stand]
type = Null;ChangeState
triggerall = Alive
triggerall = RoundState = 2
triggerall = var(59) = 1
triggerall = StateType != A
triggerall = Ctrl
triggerall = var(56) = [0,39]
triggerall = StateNo != [530,563]
trigger1 = InGuardDist
trigger1 = EnemyNear,StateType = C
trigger1 = EnemyNear,MoveType = A
trigger1 = EnemyNear,HitDefAttr = SCA,NA,SA,HA,NP,SP,HP
trigger2 = InGuardDist
trigger2 = Enemy,NumHelper > 0 || Enemy,NumProj > 0
value = 131

;----------------------------------------------------------------------
; Recover

[State -3, AC_Recover]
type = ChangeState
triggerall = Alive
triggerall = RoundState = 2
triggerall = var(59) = 1
triggerall = CanRecover
trigger1 = stateno = 5050 || stateno = 5060
value = 5210

;----------------------------------------------------------------------
; Turn

[State -3, Turn];Incomplete, Need more statement.
type = Turn
triggerall = Alive
triggerall = RoundState = 2
triggerall = var(59) = 1
triggerall = ceil(P2Dist X) < -10
trigger1 = Ctrl

;----------------------------------------------------------------------
; Walk

[State -3, AC_Walk]
type = VarSet
triggerall = Alive
triggerall = RoundState = 2
triggerall = var(59) = 1
triggerall = StateNo != 40020
triggerall = var(56) = [0,49]
trigger1 = ceil(P2Dist X) = [100,200]
trigger1 = Enemynear,MoveType != A
var(55) = 1

[State -3, AC_Walk]
type = VarSet
triggerall = Alive
triggerall = RoundState = 2
triggerall = var(59) = 1
triggerall = StateNo != 40020
triggerall = var(56) = [50,99]
trigger1 = ceil(P2Dist X) <= 40
trigger1 = Enemynear,MoveType != A
var(55) = 2

[State -3, AC_Walk]
type = ChangeState
triggerall = Alive
triggerall = RoundState = 2
triggerall = var(59) = 1
triggerall = StateType != A
triggerall = Ctrl
trigger1 = StateNo = 0
trigger1 = var(55) != 0
value = 40020

;----------------------------------------------------------------------
; Run

[State -3, AC_Run]
type = ChangeState
triggerall = Alive
triggerall = RoundState = 2
triggerall = var(59) = 1
triggerall = StateType != A
triggerall = Ctrl
triggerall = ceil(P2Dist X) >= 150
triggerall = var(56) = [0,49]
trigger1 = StateNo = 0
trigger2 = StateNo = 40020
value = 100

[State -3, AC_Run]
type = ChangeState
triggerall = Alive
triggerall = RoundState = 2
triggerall = var(59) = 1
triggerall = StateType != A
triggerall = Ctrl
triggerall = ceil(P2Dist X) <= 80
triggerall = var(56) = [50,99]
trigger1 = StateNo = 0
trigger2 = StateNo = 40020
value = 105

;----------------------------------------------------------------------
; Creature Channel

[State -3, AC_Shield]
type = ChangeState
triggerall = Alive
triggerall = RoundState = 2
triggerall = var(59) = 1
triggerall = StateType != A
triggerall = Ctrl
triggerall = StateNo != [530,563]
triggerall = FrontEdgeBodyDist >= 120 || BackEdgeBodyDist <= 60
trigger1 = var(56) = [50,79]
trigger1 = EnemyNear,MoveType = A
trigger1 = InGuardDist
trigger2 = var(56) = [50,79]
trigger2 = Enemy,NumHelper > 0 || Enemy,NumProj > 0
trigger2 = EnemyNear,MoveType = A
trigger3 = EnemyNear,HitDefAttr = SCA,NT,ST,HT
value = 1410

[State -3, AC_Shield]
type = ChangeState
triggerall = Alive
triggerall = RoundState = 2
triggerall = var(59) = 1
triggerall = StateType != A
triggerall = Ctrl
triggerall = var(56) = [40,79]
triggerall = StateNo != [530,563]
triggerall = FrontEdgeBodyDist < 120 || BackEdgeBodyDist > 60
trigger1 = var(56) = [50,79]
trigger1 = EnemyNear,MoveType = A
trigger1 = InGuardDist
trigger2 = var(56) = [50,79]
trigger2 = Enemy,NumHelper > 0 || Enemy,NumProj > 0
trigger2 = EnemyNear,MoveType = A
trigger3 = EnemyNear,HitDefAttr = SCA,NT,ST,HT
value = 1420

;----------------------------------------------------------------------
; Shield

[State -3, AC_Shield]
type = Null;ChangeState
triggerall = Alive
triggerall = RoundState = 2
triggerall = var(59) = 1
triggerall = StateType != A
triggerall = Ctrl
triggerall = var(56) = [85,99]
triggerall = StateNo != [530,563]
trigger1 = EnemyNear,StateType = S
trigger1 = EnemyNear,MoveType = A
trigger1 = InGuardDist
trigger2 = Enemy,NumHelper > 0 || Enemy,NumProj > 0
trigger2 = EnemyNear,MoveType = A
value = 540

[State -3, AC_Shield]
type = Null;ChangeState
triggerall = Alive
triggerall = RoundState = 2
triggerall = var(59) = 1
triggerall = StateType != A
triggerall = Ctrl
triggerall = var(56) = [85,99]
triggerall = StateNo != [530,563]
trigger1 = EnemyNear,StateType = C
trigger1 = EnemyNear,MoveType = A
trigger1 = InGuardDist
trigger2 = Enemy,NumHelper > 0 || Enemy,NumProj > 0
trigger2 = EnemyNear,MoveType = A
value = 550

;----------------------------------------------------------------------
; Shield to Counter

[State -3, AC_Shield_Counter]
type = ChangeState
triggerall = Alive
triggerall = RoundState = 2
triggerall = var(59) = 1
triggerall = StateType != A
triggerall = Ctrl
triggerall = Random % 100 = [0,49]
trigger1 = (StateNo = 541) && (Time > 2)
trigger2 = (StateNo = 551) && (Time > 2)
value = 1410

[State -3, AC_Shield_Counter]
type = ChangeState
triggerall = Alive
triggerall = RoundState = 2
triggerall = var(59) = 1
triggerall = StateType != A
triggerall = Ctrl
triggerall = Random % 100 = [50,99]
trigger1 = (StateNo = 541) && (Time > 2)
trigger2 = (StateNo = 551) && (Time > 2)
value = 1420

;----------------------------------------------------------------------
; Throw

[State -3, AC_Crouch_Light_Attack]
type = ChangeState
triggerall = Alive
triggerall = RoundState = 2
triggerall = var(59) = 1
triggerall = StateType != A
triggerall = var(56) = [0,49]
triggerall = Random % 10 = [0,4]
triggerall = P2BodyDist X < 20
triggerall = P2MoveType != H
triggerall = P2StateType != A
trigger1 = Ctrl
value = 500

;----------------------------------------------------------------------
; Stand Attack

[State -3, AC_Stand_Medium_Attack]
type = ChangeState
triggerall = Alive
triggerall = RoundState = 2
triggerall = var(59) = 1
triggerall = StateType != A
triggerall = EnemyNear,StateType != L
trigger1 = var(56) = [0,49]
trigger1 = Random % 10 = [0,3]
trigger1 = Ctrl
trigger1 = ceil(P2Dist X) = [80,130]
trigger2 = StateNo = 300 && (var(2) = 1) && (var(4)/10%10 = 0) && (Random % 100) = [0,49]
value = 210

[State -3, AC_Stand_Medium_Attack]
type = ChangeState
triggerall = Alive
triggerall = RoundState = 2
triggerall = var(59) = 1
triggerall = StateType != A
triggerall = EnemyNear,StateType != L
trigger1 = StateNo = 210 && (var(2) = 1) && (var(4)/100000%10 = 0) && AnimElemTime(5) >= 1  && (Random % 100) = [0,49]
trigger2 = StateNo = 310 && (var(2) = 1) && (var(4)/100000%10 = 0) && AnimElemTime(4) > 0  && (Random % 100) = [0,49]
value = 220

;----------------------------------------------------------------------
; Crouch Attack

[State -3, AC_Crouch_Light_Attack]
type = ChangeState
triggerall = Alive
triggerall = RoundState = 2
triggerall = var(59) = 1
triggerall = StateType != A
triggerall = EnemyNear,StateType != L
triggerall = var(56) = [0,49]
trigger1 = Ctrl
trigger1 = ceil(P2Dist X) < 90
value = 300

[State -3, AC_Crouch_Medium_Attack]
type = ChangeState
triggerall = Alive
triggerall = RoundState = 2
triggerall = var(59) = 1
triggerall = StateType != A
triggerall = EnemyNear,StateType != L
trigger1 = var(56) = [0,49]
trigger1 = Random % 10 = [4,9]
trigger1 = Ctrl
trigger1 = ceil(P2Dist X) = [90,120]
trigger2 = StateNo = 300 && (var(2) = 1) && (var(4)/10000%10 = 0) && (Random % 100) = [50,99]
value = 310

[State -3, AC_Crouch_Strong_Attack]
type = ChangeState
triggerall = Alive
triggerall = RoundState = 2
triggerall = var(59) = 1
triggerall = StateType != A
triggerall = EnemyNear,StateType != L
trigger1 = StateNo = 210 && (var(2) = 1) && (var(4)/100000%10 = 0) && AnimElemTime(5) >= 1  && (Random % 100) = [50,99]
trigger2 = StateNo = 310 && (var(2) = 1) && (var(4)/100000%10 = 0) && AnimElemTime(4) > 0  && (Random % 100) = [50,99]
value = 320

;----------------------------------------------------------------------
; Bad News(Lie)

[State -3, AC_Bad_News]
type = ChangeState
triggerall = Alive
triggerall = RoundState = 2
triggerall = var(59) = 1
triggerall = StateType != A
triggerall = EnemyNear,StateType != L
trigger1 = var(56) = [50,59]
trigger1 = Random % 10 = [0,4]
trigger1 = Ctrl
trigger1 = ceil(P2Dist X) = [40,140]
trigger2 = StateNo = 220 && (var(2) = 1) && AnimElemTime(6) >= 1 && (Random % 100) = [0,29]
trigger3 = StateNo = 320 && (var(2) = 1) && AnimElemTime(7) >= 1 && (Random % 100) = [0,29]
value = 1010

;----------------------------------------------------------------------
; Bad News(Maris)

[State -3, AC_Bad_News]
type = ChangeState
triggerall = Alive
triggerall = RoundState = 2
triggerall = var(59) = 1
triggerall = StateType != A
triggerall = EnemyNear,StateType != L
trigger1 = var(56) = [0,69]
trigger1 = Ctrl
trigger1 = (ceil(P2Dist X) = [40,90]) && ceil(P2Dist Y) < -40
value = 1110

;----------------------------------------------------------------------
; Replicant Coordinator(41236+A)

[State -1, 41236A - Warakia]
type = ChangeState
triggerall = Alive
triggerall = RoundState = 2
triggerall = var(59) = 1
triggerall = StateType != A
triggerall = NumHelper(11300) < 1
trigger1 = Ctrl
trigger1 = ceil(P2Dist X) > 200
trigger1 = var(56) = [0,9]
trigger2 = StateNo = 320 && (var(2) = 1) && AnimElemTime(7) >= 1 && (Random % 100) = [70,99]
value = 1300

[State 1300, VarSet]
type = VarSet
triggerall = Alive
triggerall = RoundState = 2
triggerall = var(59) = 1
triggerall = StateNo = 1300
trigger1 = ceil(P2Dist X) > 150
var(57) = 2

[State 1300, VarSet]
type = VarSet
triggerall = Alive
triggerall = RoundState = 2
triggerall = var(59) = 1
triggerall = StateNo = 1300
trigger1 = PrevStateNo = 320
var(57) = 1

;----------------------------------------------------------------------
; Replicant Coordinator(41236+B)

[State -1, 41236B - Warakia]
type = ChangeState
triggerall = Alive
triggerall = RoundState = 2
triggerall = var(59) = 1
triggerall = StateType != A
triggerall = NumHelper(11310) < 1
trigger1 = Ctrl
trigger1 = ceil(P2Dist X) > 150
trigger1 = var(56) = [30,39]
trigger2 = StateNo = 210 && (var(2) = 1) && AnimElemTime(5) >= 1 && (Random % 100 = [0,29]) && (EnemyNear,StateNo = [120,155])
trigger3 = StateNo = 220 && (var(2) = 1) && AnimElemTime(6) >= 1 && (Random % 100 = [0,29]) && (EnemyNear,StateNo = [120,155])
value = 1310

[State 1310, VarSet]
type = VarSet
triggerall = Alive
triggerall = RoundState = 2
triggerall = var(59) = 1
triggerall = StateNo = 1310
trigger1 = ceil(P2Dist X) > 150
var(57) = 1

[State 1310, VarSet]
type = VarSet
triggerall = Alive
triggerall = RoundState = 2
triggerall = var(59) = 1
triggerall = StateNo = 1310
trigger1 = PrevStateNo = [200,320]
var(57) = 2

;----------------------------------------------------------------------
; Replicant Coordinator(41236+C)

[State -1, 41236C - Warakia]
type = ChangeState
triggerall = Alive
triggerall = RoundState = 2
triggerall = var(59) = 1
triggerall = StateType != A
triggerall = NumHelper(11320) < 1
trigger1 = Ctrl
trigger1 = ceil(P2Dist X) = [80,160]
trigger1 = var(56) = [50,59]
trigger2 = StateNo = 210 && (var(2) = 1) && AnimElemTime(5) >= 1 && (Random % 100 = [30,39])
trigger3 = StateNo = 220 && (var(2) = 1) && AnimElemTime(6) >= 1 && (Random % 100 = [30,39])
trigger4 = StateNo = 320 && (var(2) = 1) && AnimElemTime(7) >= 1 && (Random % 100 = [50,89])
value = 1320

[State 1310, VarSet]
type = VarSet
triggerall = Alive
triggerall = RoundState = 2
triggerall = var(59) = 1
triggerall = StateNo = 1320
trigger1 = ceil(P2Dist X) = [80,160]
trigger1 = GameTime % 60 < 30
trigger2 = (PrevStateNo = 320) && (EnemyNear,StateNo != [120,155])
var(57) = 1

[State 1310, VarSet]
type = VarSet
triggerall = Alive
triggerall = RoundState = 2
triggerall = var(59) = 1
triggerall = StateNo = 1320
trigger1 = ceil(P2Dist X) = [80,160]
trigger1 = GameTime % 60 >= 30
trigger2 = PrevStateNo = [200,220]
var(57) = 2

;----------------------------------------------------------------------
; Replicant Coordinator(63214+A)

[State -1, 41236A - Warakia]
type = ChangeState
triggerall = Alive
triggerall = RoundState = 2
triggerall = var(59) = 1
triggerall = StateType != A
triggerall = NumHelper(11500) < 1
trigger1 = Ctrl
trigger1 = ceil(P2Dist X) = [80,160]
trigger1 = var(56) = [10,19]
trigger2 = StateNo = 210 && (var(2) = 1) && AnimElemTime(5) >= 1 && (Random % 100 = [50,79]) && (EnemyNear,StateNo = [120,155])
trigger3 = StateNo = 220 && (var(2) = 1) && AnimElemTime(6) >= 1 && (Random % 100 = [50,79]) && (EnemyNear,StateNo = [120,155])
trigger4 = StateNo = 310 && (var(2) = 1) && AnimElemTime(4) >= 1 && (Random % 100 = [50,79]) && (EnemyNear,StateNo = [120,155])
trigger5 = StateNo = 320 && (var(2) = 1) && AnimElemTime(6) >= 1 && (Random % 100 = [50,79]) && (EnemyNear,StateNo = [120,155])
value = 1500

[State -3, VarSet]
type = VarSet
triggerall = Alive
triggerall = RoundState = 2
triggerall = var(59) = 1
triggerall = StateNo = 1500
trigger1 = ceil(P2Dist X) = [80,160]
trigger1 = PrevStateNo != [200,320]
var(57) = 2

[State -3, VarSet]
type = VarSet
triggerall = Alive
triggerall = RoundState = 2
triggerall = var(59) = 1
triggerall = StateNo = 1500
trigger1 = PrevStateNo = [200,320]
var(57) = 1

;----------------------------------------------------------------------
; Replicant Coordinator(63214+A)

[State -1, 41236A - Warakia]
type = ChangeState
triggerall = Alive
triggerall = RoundState = 2
triggerall = var(59) = 1
triggerall = StateType != A
triggerall = NumHelper(11510) < 1
trigger1 = Ctrl
trigger1 = ceil(P2Dist X) = [80,120]
trigger1 = var(56) = [20,29]
trigger2 = StateNo = 210 && (var(2) = 1) && AnimElemTime(5) >= 1 && (Random % 100 = [80,84]) && (EnemyNear,StateNo = [120,155])
trigger3 = StateNo = 220 && (var(2) = 1) && AnimElemTime(6) >= 1 && (Random % 100 = [80,84]) && (EnemyNear,StateNo = [120,155])
trigger4 = StateNo = 310 && (var(2) = 1) && AnimElemTime(4) >= 1 && (Random % 100 = [80,84]) && (EnemyNear,StateNo = [120,155])
trigger5 = StateNo = 320 && (var(2) = 1) && AnimElemTime(6) >= 1 && (Random % 100 = [80,84]) && (EnemyNear,StateNo = [120,155])
value = 1510

[State -3, VarSet]
type = VarSet
triggerall = Alive
triggerall = RoundState = 2
triggerall = var(59) = 1
triggerall = StateNo = 1510
trigger1 = ceil(P2Dist X) = [80,160]
trigger1 = PrevStateNo != [200,320]
var(57) = 1

[State -3, VarSet]
type = VarSet
triggerall = Alive
triggerall = RoundState = 2
triggerall = var(59) = 1
triggerall = StateNo = 1510
trigger1 = PrevStateNo = [200,320]
var(57) = 2

;----------------------------------------------------------------------
; Replicant Coordinator(63214+C)

[State -1, 41236A - Warakia]
type = ChangeState
triggerall = Alive
triggerall = RoundState = 2
triggerall = var(59) = 1
triggerall = StateType != A
triggerall = NumHelper(11520) < 1
trigger1 = Ctrl
trigger1 = ceil(P2Dist X) = [100,200]
trigger1 = var(56) = [20,29]
trigger2 = StateNo = 210 && (var(2) = 1) && AnimElemTime(5) >= 1 && (Random % 100 = [85,99]) && (EnemyNear,StateNo = [120,155])
trigger3 = StateNo = 220 && (var(2) = 1) && AnimElemTime(6) >= 1 && (Random % 100 = [85,99]) && (EnemyNear,StateNo = [120,155])
trigger4 = StateNo = 310 && (var(2) = 1) && AnimElemTime(4) >= 1 && (Random % 100 = [85,99]) && (EnemyNear,StateNo = [120,155])
trigger5 = StateNo = 320 && (var(2) = 1) && AnimElemTime(6) >= 1 && (Random % 100 = [85,99]) && (EnemyNear,StateNo = [120,155])
value = 1520

[State -3, VarSet]
type = VarSet
triggerall = Alive
triggerall = RoundState = 2
triggerall = var(59) = 1
triggerall = StateNo = 1510
trigger1 = ceil(P2Dist X) = [100,200]
trigger1 = PrevStateNo != [200,320]
var(57) = 1

[State -3, VarSet]
type = VarSet
triggerall = Alive
triggerall = RoundState = 2
triggerall = var(59) = 1
triggerall = StateNo = 1510
trigger1 = PrevStateNo = [200,320]
var(57) = 2
