;-----------------------------------------------------------------------------
[Statedef -2];常時監視ステート(相手に行動を制御されても関係無く常に実行される)
;-----------------------------------------------------------------------------
;-----------------------------------------------------------------------------

[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にする


;----------------------------------------------------------------------------
;デバッグ支援記述集

; ※ この一連の記述は、キャラが完成したら消すか";"を付けて無効化しましょう。
;　　僅かにでも処理が重くなることが理由です。（ちなみにNullではダメです）


;デバッグモードに白い文字の表示を加える
;[State -2, デバッグ表示]
;type = DisplayToClipboard
;trigger1 = 1
;text = "V1-C=%d,V3-J=%d,V4-D=%d,V5-B=%d,V20-A=%d"
;params = var(1),var(3),var(4),var(5),var(20)
;ignorehitpause = 1

;表示を横に加える
;[State -2, デバッグ表示その2]
;type = AppendToClipboard
;trigger1 = 1
;text = " V22-L=%d,V21-R=%d,Pos X=%d,Y=%d"
;params = var(22),var(21),ceil(Pos X),floor(Pos Y)
;ignorehitpause = 1

;表示を下に加える
;[State -2, デバッグ表示その3]
;type = AppendToClipboard
;trigger1 = 1
;text = "\nDist X=%d,Y=%d, Vel X=%d/10,Y=%d/10 : Power=%d"
;params = floor(P2BodyDist X),ceil(P2BodyDist Y),ceil(Vel X*10),floor(Vel Y*10),Power
;ignorehitpause = 1


; ※ 関数説明：floor(1.5) = 1、ceil(1.5) = 2になります。 小数を含む場合によく使います。
;　　小数を詳しく見たい場合は%dの代わりに%fを使います。 MUGENに限らず結構常識です。
;　　Vel X*10に対し、表記はVel X=%d/10になっています。 10で割った数値が目安のVel Xです。
;　　PosとDistはfloorとceilが逆になっています。




;無人デバッグ用（かなり長時間CPUに任せるデバッグ法）
;ウォッチ、サバイバル(ctrl+2使用)のチーム戦が良いと思う
;[State -2, バグ発生警報]
;type = VarSet
;triggerall = RoundState = 2
;triggerall = Var(20) >= 0
;trigger1 = floor(Pos Y) < -5 ;よくあるバグとして、宙に浮かぶことが挙げられる
;trigger1 = stateno = [0,22]  ;宙で立つ、しゃがむ、歩く
;trigger1 = Time = 1
;trigger2 = Anim != [5110,5120]
;trigger2 = Ctrl = 0     ;行動不能のまま
;trigger2 = Life > 0     ;まだ息があり
;trigger2 = !Lose        ;負けていないのに
;trigger2 = Time = 2047  ;長時間固まる
;var(20)  = -4           ;上記バグが出るとセットされます。

;[State -2, 永久戦闘デバッグ]
;type = LifeAdd
;trigger1 = TeamMode = Simul ;必要に応じて条件を変える
;value = 20  ;HPが減らない
;ignorehitpause = 1

[State -2,]
type = Explod
triggerall = p2movetype = H
trigger1 = Anim = 1601
trigger1 = Random < 150
trigger1 = Movehit
trigger2 = Anim = 1610
trigger2 = Random < 150
trigger2 = Movehit
trigger3 = Anim = 1620
trigger3 = Random < 150
trigger3 = Movehit
trigger4 = Anim = 1700
trigger4 = Random < 150
trigger4 = Movehit
trigger5 = Anim = 1630
trigger5 = Random < 150
trigger5 = Movehit
trigger6 = Anim = 1720
trigger6 = Random < 150
trigger6 = Movehit
trigger7 = Anim = 1730
trigger7 = Random < 150
trigger7 = Movehit
trigger8 = Anim = 1710
trigger8 = Random < 150
trigger8 = Movehit
trigger9 = Anim = 1155
trigger9 = Random < 150
trigger9 = Movehit
trigger10 = Anim = 1105
trigger10 = Random < 150
trigger10 = Movehit
trigger11 = Anim = 1500
trigger11 = Random < 150
trigger11 = Movehit
trigger12 = Anim = 1405
trigger12 = Random < 150
trigger12 = Movehit
trigger13= Anim = 31012
trigger13 = Random < 150
trigger13 = Movehit
trigger14= Anim = 31014
trigger14 = Random < 150
trigger14 = Movehit
trigger15= Anim = 11111
trigger15 = Random < 150
trigger15 = Movehit
anim = 4430
pos = 0,-50
postype = p2
sprpriority = 999
bindtime = 1
random = 100,100
ownpal = 1
ignorehitpause = 1

[State -2,]
type = Explod
triggerall = p2movetype = H
trigger1 = Anim = 1601
trigger1 = Random < 150
trigger1 = Movehit
trigger2 = Anim = 1610
trigger2 = Random < 150
trigger2 = Movehit
trigger3 = Anim = 1620
trigger3 = Random < 150
trigger3 = Movehit
trigger4 = Anim = 1700
trigger4 = Random < 150
trigger4 = Movehit
trigger5 = Anim = 1630
trigger5 = Random < 150
trigger5 = Movehit
trigger6 = Anim = 1720
trigger6 = Random < 150
trigger6 = Movehit
trigger7 = Anim = 1730
trigger7 = Random < 150
trigger7 = Movehit
trigger8 = Anim = 1710
trigger8 = Random < 150
trigger8 = Movehit
trigger9 = Anim = 1155
trigger9 = Random < 150
trigger9 = Movehit
trigger10 = Anim = 1105
trigger10 = Random < 150
trigger10 = Movehit
trigger11 = Anim = 1500
trigger11 = Random < 150
trigger11 = Movehit
trigger12 = Anim = 1405
trigger12 = Random < 150
trigger12 = Movehit
trigger13= Anim = 31012
trigger13 = Random < 150
trigger13 = Movehit
trigger14= Anim = 31014
trigger14 = Random < 150
trigger14 = Movehit
trigger15= Anim = 11111
trigger15 = Random < 150
trigger15 = Movehit
anim = 4435
pos = 0,-50
postype = p2
sprpriority = 999
bindtime = 1
random = 100,100
ownpal = 1
ignorehitpause = 1

[State -2,]
type = Explod
triggerall = p2movetype = H
trigger1 = Anim = 1601
trigger1 = Random < 150
trigger1 = Movehit
trigger2 = Anim = 1610
trigger2 = Random < 150
trigger2 = Movehit
trigger3 = Anim = 1620
trigger3 = Random < 150
trigger3 = Movehit
trigger4 = Anim = 1700
trigger4 = Random < 150
trigger4 = Movehit
trigger5 = Anim = 1630
trigger5 = Random < 150
trigger5 = Movehit
trigger6 = Anim = 1720
trigger6 = Random < 150
trigger6 = Movehit
trigger7 = Anim = 1730
trigger7 = Random < 150
trigger7 = Movehit
trigger8 = Anim = 1710
trigger8 = Random < 150
trigger8 = Movehit
trigger9 = Anim = 1155
trigger9 = Random < 150
trigger9 = Movehit
trigger10 = Anim = 1105
trigger10 = Random < 150
trigger10 = Movehit
trigger11 = Anim = 1500
trigger11 = Random < 150
trigger11 = Movehit
trigger12 = Anim = 1405
trigger12 = Random < 150
trigger12 = Movehit
trigger13= Anim = 31012
trigger13 = Random < 150
trigger13 = Movehit
trigger14= Anim = 31014
trigger14 = Random < 150
trigger14 = Movehit
trigger15= Anim = 11111
trigger15 = Random < 150
trigger15 = Movehit
anim = 4440
pos = 0,-50
postype = p2
sprpriority = 999
bindtime = 1
random = 100,100
ownpal = 1
ignorehitpause = 1

[State -2,]
type = Explod
triggerall = p2movetype = H
trigger1 = Anim = 1601
trigger1 = Random < 150
trigger1 = Movehit
trigger2 = Anim = 1610
trigger2 = Random < 150
trigger2 = Movehit
trigger3 = Anim = 1620
trigger3 = Random < 150
trigger3 = Movehit
trigger4 = Anim = 1700
trigger4 = Random < 150
trigger4 = Movehit
trigger5 = Anim = 1630
trigger5 = Random < 150
trigger5 = Movehit
trigger6 = Anim = 1720
trigger6 = Random < 150
trigger6 = Movehit
trigger7 = Anim = 1730
trigger7 = Random < 150
trigger7 = Movehit
trigger8 = Anim = 1710
trigger8 = Random < 150
trigger8 = Movehit
trigger9 = Anim = 1155
trigger9 = Random < 150
trigger9 = Movehit
trigger10 = Anim = 1105
trigger10 = Random < 150
trigger10 = Movehit
trigger11 = Anim = 1500
trigger11 = Random < 150
trigger11 = Movehit
trigger12 = Anim = 1405
trigger12 = Random < 150
trigger12 = Movehit
trigger13= Anim = 31012
trigger13 = Random < 150
trigger13 = Movehit
trigger14= Anim = 31014
trigger14 = Random < 150
trigger14 = Movehit
trigger15= Anim = 11111
trigger15 = Random < 150
trigger15 = Movehit
anim = 4445
pos = 0,-50
postype = p2
sprpriority = 999
bindtime = 1
random = 100,100
ownpal = 1
ignorehitpause = 1

[State 700,]
type = palfx
trigger1 = var(33) != 0
trigger1 = 1
time = 20
add = 90,50,0

[State 1100, ]
type = Varset
triggerall = var(33) != 0
trigger1 = enemy,movetype = H
trigger1 = enemy,Gethitvar(hitcount) >= 2
fvar(1) = enemy,Gethitvar(hitcount)

[State 1100, ]
type = Varset
trigger1 = var(33) = 0
trigger2 = stateno = 0
trigger3 = Enemy,stateno = 0
fvar(1) = 0

[State 1100, ]
type = Varset
trigger1 = fvar(1) >= 13
fvar(1) = 13

[State 1100, ]
type = AttackMulSet
trigger1 = var(33) != 0
value = ((10.0-(((fvar(1))*3.2)/10)*2)/10.0)

[State 1100, ]
type = AttackMulSet
trigger1 = stateno = 0
value = 1

[State 1100, ]
type = Varadd
trigger1 = (GameTime%2) = 0 && var(33) != 0
var(33) = -1
persistent = 0

[State 1000, ]
type = Varset
trigger1 = Enemy,Stateno = 5100
trigger2 = Enemy,Stateno = 0
var(17) = 0

[State 1000, ]
type = Varset
trigger1 = Stateno = 0
var(18) = 0

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

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

[State -2,bunshin]
type = SelfState
trigger1 = IsHelper(2205)
trigger1 = stateno != 2205
value = 2025

[State 1000, ヘルパーを出す]
type = Helper
trigger1 = Projhit1000 = 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 -3];常時監視ステート(p2statenoなどで相手に行動を制御された時は実行しない)
;---------------------------------------------------------------------------------

;※※※※※※※※※※※※※※※※※※※※ハイジャンプ・東方萃夢想風味
;理論は簡単
;ハイジャンプコマンドを入れた「瞬間」、varスイッチを１にする。
;でハイジャンプのコマンドは最後がU、つまりジャンプする。
;そしてジャンプステート５０の時にvarスイッチが１以上ならveladdで加速します。
;varスイッチを０にするトリガーは「ステート５０の２フレーム目」です。

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

[State -3, sysvarを引継ぐ]
type = VarSet
trigger1 = Var(3) = 1
trigger1 = stateno = 40 ;ジャンプする前のステート
trigger1 = AnimTime = 0 ;ジャンプ方向を決めるsysvarがリセットされる寸前
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.6
x = 1.8

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

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

[State -3, 成功したときの残像]
type = AfterImage
trigger1 = var(3) >= 1
trigger1 = stateno = 50
time = 25
trans = add1
length = 4
timeGap = 3
frameGap = 1
palBright = 0, 0, 0
palContrast = 128, 128, 128
palAdd = 0, 0, 0
palMul = 1, 1, 1

;※常時監視ステートは常に有効にしたいステートコントローラをどんどん追加していきます。

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

;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

