;-----------------------------------------------------------------------------
[Statedef -2];常時監視ステート(相手に行動を制御されても関係無く常に実行される)
;-----------------------------------------------------------------------------
;=============================================================================
;Variable de quemar (Copiado del Kyo de Zelgadis)
[State 2300, Burn]
type = Varset
triggerall = p2movetype = H
trigger1 = Anim = [1000,1099]
trigger1 = Movehit
trigger2 = Anim = [2100,2199]
trigger2 = Movehit
trigger3 = Anim = [3100,3199]
trigger3 = Movehit
trigger4 = Anim = [1700,1799]
trigger4 = Movehit
trigger5 = Anim = [1400,1499]
persistent = 0
ignorehitpause = 1
var(42) = 1

;P2 en el Suelo (Copiado del Kyo de Zelgadis)
[State 1000, explods]
type = Explod
triggerall = (p2stateno = [5100,5110]) && p2movetype = H
trigger1 = var(42) > 0 && Random < 70
anim = 4200
pos = 0,0
facing = -1
postype = p2
sprpriority = 999
bindtime = 1
random = 100,0
ownpal = 1
supermove = 1
ignorehitpause = 1

;P2 en el Suelo (Copiado del Kyo de Zelgadis)
[State 1000, VarSet]
type = VarSet
trigger1 = p2movetype != H
v = 42
value = 0
persistent = 0

;-----------------------------------------------------------------------------
[State -2, No 98 Bars]
type = AssertSpecial
trigger1 = roundstate = [0,1]
trigger2 = Ctrl = 0 && (Anim = [0,2]) && MoveType != H
flag = NoBarDisplay
ignorehitpause = 1

[State -2, detect]
type = VarSet
trigger1 = p2name = "R1" || p4name = "R1"
trigger2 = p2name = "R_FullPower" || p4name = "R_FullPower"
var(55) = 1

;Advanced Mode (Ehnyd)
[State -2, StartOnLeft]
type = VarSet
trigger1 = var(23) = 0
trigger1 = Pos X < 0
v = 23
value = 1

[State -2, StartOnRight]
type = VarSet
trigger1 = var(23) = 0
trigger1 = Pos X >= 0
v = 23
value = 2

[State -2, CountDown]
type = VarSet
trigger1 = var(17) < 0
var(17) = 0
ignorehitpause = 1

[State -2, CountDown]
type = VarAdd
trigger1 = var(17) > 0
v = 17
ignorehitpause = 1
value = -1

[State -2, ExplodCountdown]
type = ModifyExplod
trigger1 = Var(17) != 0
ID = 4102
scale = (1100 - Var(17)) / 1100.0,1
ontop = 1

[State -2, ResetDamageBonus]
type = AttackMulSet
trigger1 = Var(17) <= 0 && NumExplod(4100) != 0
value = 1

[State -2, BarRemovalAnimLeft]; P1, no tocar
type = Explod
trigger1 = Var(17) <= 0 && Var(23) = 1 && NumExplod(4100) != 0
anim =4101
postype = left
pos = 7,208
ontop = 1
supermove = 1
ignorehitpause = 1
ignoresuperpause = 1
bindtime = 30
ownpal = 1

[State -2, BarRemovalAnimRight]
type = Explod
trigger1 = Var(17) <= 0 && Var(23) = 2 && NumExplod(4100) != 0
anim = 4106
postype = right
pos = -84,208
ontop = 1
supermove = 1
ignorehitpause = 1
ignoresuperpause = 1
bindtime = 30
ownpal = 1

[State -2, RemoveMAXCounterBar]
type = RemoveExplod
trigger1 = Var(17) <= 0 && NumExplod(4100) != 0
id = 4102

[State -2, RemoveMAXBar]
type = RemoveExplod
trigger1 = Var(17) <= 0 & NumExplod(4100) != 0
id = 4100

[State -2, KillMAX]
type = VarSet
trigger1 = Life = 0
v = 17
value = 0

;Extra Mode: Power Charge at MAX
[State 100, StopSnd]
type = StopSnd
trigger1 = stateno != 910 && stateno != 911
channel = 8

[State 100, StopSnd]
type = StopSnd
trigger1 = stateno != 910 && stateno != 911
channel = 9
;=============================================================================
;-----------------------------------------------------------------------------

[State -2, 二人目のイントロ]
type = ChangeState             ;二人目でもイントロを作る
value = 190                    ;イントロへ
triggerall = RoundsExisted = 0 ;自分が初参戦時
triggerall = TeamMode = Turns  ;ターンモード
trigger1 = stateno = 5900      ;5900番

;ここでtrigger用に自分の初期ライフを確認します
[State -2, ライフ確認]
type = VarSet
triggerall = RoundState = [0,1] ;開始前の間
trigger1 = RoundNo = 1          ;一試合目
trigger2 = TeamMode = Turns     ;5900でイントロを作らないと ↓
trigger2 = RoundsExisted = 0    ;これは使えません
v = 22
value = Life   ;Var(22)に自分のライフを保存

[State -2, ライフ取得ミス対策]
type = VarSet
triggerall = Var(22) = [0,100] ;ライフが100以下と認識されたら
triggerall = Time = 1
trigger1 = RoundNo = 1
trigger2 = RoundsExisted = 0
v = 22
value = const(data.life) ;自分のデータに書かれたLifeにする


;----------------------------------------------------------------------------

[State -2, 残像]
type = AfterImage
trigger1 = Movetype = H
time = 1

[State -2,]
type = StopSnd
trigger1 = Movetype = H
channel = 4

[State -2,]
type = StopSnd
trigger1 = command != "holdfwd"
trigger2 = Anim != 100
channel = 6

[State -2,]
type = StopSnd
trigger1 = Movetype = H
channel = 7

[State -2,]
type = StopSnd
trigger1 = Movetype = H
channel = 9

[State 1000, ヘルパーを出す]
type = Helper
trigger1 = Projhit1000 = 1
trigger2 = Projhit1800 = 1
trigger3 = Projhit2000 = 1
name = "Slow"
stateno = 4900
ID = 4900
helpertype = normal
pos = 0,0
postype = p1
keyctrl = 0
ownpal = 1
ignorehitpause = 1

;---------------------------------------------------------------------------
;スロー処理

[Statedef 4900]
type     = A
movetype = I
physics  = N
juggle   = 0
ctrl     = 0
anim     = 4900
sprpriority = 1

[State 1001,]
type = Pause
trigger1 = (GameTime%3) = 0
trigger1 = time = [0,20]
time = 1

[State 1001,]
type = Pause
trigger1 = (GameTime%6) = 0
trigger1 = time = [21,30]
time = 1

[State 4110, DestroySelf]
type = DestroySelf
trigger1 = Animtime = 0

;---------------------------------------------------------------------------
;ブリッツボールエフェクト

[Statedef 1001]
type     = A
movetype = I
physics  = N
ctrl     = 0
anim     = 1001
sprpriority = 15

[State 170, 無敵]
type = NotHitBy
trigger1 = 1
value = SCA

[State 1001, 特殊効果]
type = AssertSpecial
trigger1 = 1
flag = NoShadow ;影を消す

[State 1000, ]
type = Velset
triggerall = Root,Stateno = 1000 || Root,Stateno = 1050
trigger1 = time >= 0
x = 4

[State 1000, ]
type = Velset
triggerall = Root,Stateno = 1025 || Root,Stateno = 1075
trigger1 = time >= 0
x = 8

[State 3000]
type = Explod
trigger1 = Vel X = 4
trigger1 = (GameTime%6) = 0
trigger2 = Vel X = 8
trigger2 = (GameTime%4) = 0
anim = 1015
pos = 0,0
postype = p1
sprpriority = 15
ownpal = 1

[State 1001, このヘルパーを消す]
type = DestroySelf
trigger1 = Root,numprojID(1000) = 0


;---------------------------------------------------------------------------------
[Statedef -3];常時監視ステート(p2statenoなどで相手に行動を制御された時は実行しない)
;---------------------------------------------------------------------------------

[State -3, コマンドを入れたらVarをON] 
type = VarSet
trigger1 = command = "jump"
trigger1 = ctrl
trigger1 = statetype = S
v = 3
value = 1

[State -3, sysvarを引継ぐ]
type = VarSet
trigger1 = Var(3) = 1
trigger1 = stateno = 40
trigger1 = AnimTime = 0
var(3) = ifelse(sysvar(1)=0, 2, ifelse(sysvar(1)=1, 3, 4))

[State -3, varをOFFにするステート]
type = VarSet
triggerall = Time = 2
trigger1 = stateno = 50
trigger2 = stateno != [40,59]
v = 3
value = 0

[State -3, 前にボタンを押してたら前にも加速]
type = VelAdd
trigger1 = var(3) = 3
trigger1 = stateno = 50
y = -0.8
x = 2

[State -3, 後ろなら後ろに加速]
type = VelAdd
trigger1 = var(3) = 4
trigger1 = stateno = 50
y = -0.8
x = -2.1

[State -3, 垂直ジャンプにveladdを使って上に加速]
type = VelAdd
trigger1 = var(3) = 2
trigger1 = stateno = 50
y = -2

[State -3, Afterimage]
type = Afterimage
trigger1 = var(3) >= 1
trigger1 = stateno = 50
trigger2 = AnimTime = 0
trigger2 = prevstateno = 100 ;RUN_FWD
trigger2 = sysvar(1) = 1
time = 2
length = 7
PalBright = 0,0,0
PalContrast = 256,256,256
PalAdd = 0,0,0
PalMul = 1,1,1
FrameGap = 3

[State 2041, 2]
type = Afterimagetime
triggerall = Var(3) = 0
trigger1 = stateno = 50
trigger1 = time%2 = 0 && Time < 15
time = 2

;------------------------------------------------------------------------------
;状況による行動制限編（必殺技・ガード）

;p2movetype、p2statetype、power、Lifeなど
;互いの状況をおもに利用した行動を取らせる様にしています。


[State -3, 空中ガード]
type  = ChangeState
value = 132
triggerall = p2movetype = A          ;相手が攻撃中
triggerall = statetype = A           ;自分が空中
triggerall = var(20) = 1             ;CPU時
triggerall = ctrl                    ;自由に動けるとき
triggerall = stateno != [190,194]    ;いろいろとバグ対策などを施しておきましょう(例)
triggerall = p2statetype = A         ;相手が空中
trigger1   = P2BodyDist X = [40,80]  ;遠距離用
trigger1   = var(21) = [0,39]        ;確率低い
trigger2   = P2BodyDist X = [-20,39] ;近距離用(背後も含めている)
trigger2   = var(21) = [0,59]        ;確率高い

[State -3, 対地 立ちガード]
type  = ChangeState
value = 130
triggerall = p2movetype = A
triggerall = statetype != A
triggerall = var(20) = 1
triggerall = ctrl
triggerall = stateno != [190,194]
triggerall = p2statetype = S
trigger1   = P2BodyDist X = [40,90]
trigger1   = var(21) = [0,14]         ;CPUのガードが固いと気分が悪くないですか？
trigger2   = P2BodyDist X = [-15,39]
trigger2   = var(21) = [10,29]
trigger3   = enemy,teammode = simul   ;相手がチームモード
trigger3   = P2BodyDist X = [-50,-16] ;後ろを向いているときに攻撃された場合
trigger3   = var(21) = [0,39]
trigger4   = P2BodyDist X = [-15,39]
trigger4   = enemy,hitdefattr = S, NA,SA,HA ;相手がまさに立ち攻撃をした瞬間
trigger4   = Random < 200                   ;高確率でガード

[State -3, 対空 立ちガード]
type  = ChangeState
value = 130
triggerall = p2movetype = A
triggerall = statetype != A
triggerall = var(20) = 1
triggerall = ctrl
triggerall = stateno != [190,194]
triggerall = p2statetype = A
trigger1   = P2BodyDist X = [40,90]
trigger1   = var(21) = [0,15]
trigger2   = P2BodyDist X = [-40,39] ;めくり対策を含む
trigger2   = var(21) = [0,32]
trigger3   = P2BodyDist X = [-40,39]
trigger3   = enemy,hitdefattr = A, NA,SA,HA ;相手がまさに空中攻撃をした瞬間
trigger3   = Random < 400

[State -3, しゃがみガード]
type  = ChangeState
value = 131
triggerall = p2movetype = A
triggerall = statetype != A
triggerall = var(20) = 1
triggerall = ctrl
triggerall = stateno != [190,194]
trigger1   = p2statetype = C
trigger1   = P2BodyDist X = [40,85]
trigger1   = var(21) = [0,24]
trigger2   = p2statetype = C
trigger2   = P2BodyDist X = [-20,39]
trigger2   = var(21) = [0,39]
trigger3   = p2statetype = S         ;立ち下段対策…
trigger3   = P2BodyDist X = [-15,39]
trigger3   = var(21) = [0,9]
trigger4   = p2statetype = C
trigger4   = enemy,teammode = simul
trigger4   = P2BodyDist X = [-50,-16]
trigger4   = var(21) = [0,39]
trigger5   = P2BodyDist X = [-20,39]
trigger5   = enemy,hitdefattr = C, NA,SA,HA ;相手がまさに屈み攻撃をした瞬間
trigger5   = Random < 300

[State -3, 投げ]
type  = ChangeState
value = 800
triggerall = var(20) = 1
triggerall = roundstate = 2
triggerall = Random = [0,59]
triggerall = statetype = S
triggerall = ctrl
trigger1   = P2BodyDist X = [-3,3)
trigger1   = p2statetype != A
trigger1   = p2statetype != L
trigger1   = p2movetype != H