;Statedef -2
[Statedef -2]

;---------------------------------------(AfterImage)
[State -2, Afterimage]
type = AfterImage
triggerall = var(11) = 1 ;!= 0 ;= 1
trigger1 = time = 0
trigger1 =(stateno= 0) || (stateno= 20) || (stateno= 21)
time = 9999
TimeGap  = 1
FrameGap = 4
length = 15
PalBright   = 0,0,0
PalContrast = 255,255,255
PalMul      = .8,.8,.8

[State -2, Afterimage2]
type = AfterImage
triggerall= 1
triggerall = var(11) != 1 ;= 0
trigger1 = time = 0
time = 1
TimeGap  = 1
FrameGap = 4
length = 15
PalBright   = 0,0,0
PalContrast = 255,255,255
PalMul      = .8,.8,.8

;---------------------------------------(AngleDraw)
[State 3000,A];
type = angledraw
trigger1 = Time = [60,68]
trigger1 = anim = 7100 ;Time = 60
value = 0
scale = 2,2

;---------------------------------------(AttackMulset)
[State -2, 黒ドナルド攻撃力アップ]
type = attackmulset
triggerall = 1
triggerall = Life <= 250
trigger1 = PalNo = 12 || Var(40) = 1
value = 10

[State -2, 黒ドナルド攻撃力アップ]
type = attackmulset
triggerall = 1
triggerall = Life >= 250
triggerall = Life <= 500
trigger1 = PalNo = 12 || Var(40) = 1
value = 5

[State -2, 黒ドナルド攻撃力アップ]
type = attackmulset
triggerall = 1
triggerall = Life >= 500
trigger1 = PalNo = 12 || Var(40) = 1
value = 1.5

[State -2, Set Powered Up Attack]
type = AttackMulSet
trigger1 = var(14) = 1 || var(14) = -1
value = 2

[State -2, Attack Fix]
type = AttackMulSet
trigger1 = 1
value = ifelse(fvar(3),fvar(3),.1)

;---------------------------------------(ChangeState)
[State -2, ステート変更]
type = ChangeState
triggerall = stateno != 16500
triggerall = stateno != 50
triggerall = stateno != 51
triggerall = movetype = H
triggerall = RoundState = 2
triggerall = PalNo = 12 || Var(40) = 1
trigger1 = GetHitVar(hitcount) >= 30
trigger2 = GetHitVar(damage) >= 500
trigger3 = GetHitVar(fall.damage) >= 500
value = 16500
ctrl = 1

;---------------------------------------(CtrlSet)
[State -2, ]
type = CtrlSet
trigger1 = PalNo = 12 || Var(40) = 1
trigger1 = movetype = H
trigger1 = Life <= 500
trigger1 = ALIVE
value = 1

;---------------------------------------(DefenceMulset)
[State -2, 黒ドナルド防御力アップ]
type = defencemulset
triggerall = 1
triggerall = Life <= 250
trigger1 = PalNo = 12 || Var(40) = 1
value = 0.1

[State -2, 黒ドナルド防御力アップ]
type = defencemulset
triggerall = 1
triggerall = Life >= 250
triggerall = Life <= 500
trigger1 = PalNo = 12 || Var(40) = 1
value = 0.5

[State -2, 黒ドナルド防御力アップ]
type = defencemulset
triggerall = 1
triggerall = Life >= 500
trigger1 = PalNo = 12 || Var(40) = 1
value = 1

;---------------------------------------(Explod)
[State 1050, エフェクト表示]
type = Explod
trigger1 = stateno = 1610
;;trigger2 = var(13) = 1
;trigger1 = Time = 1
anim = 1612
postype = back
pos = 0, 0
scale = 1,1
bindtime = -1
sprpriority = 5
ownpal = 1
removeongethit = 1
ignohitpause = 1

;---------------------------------------(Helper)
[State 195, 即死ヘルパー ]
type=helper
helpertype=player
triggerall=stateno=1610
triggerall= Time = 21000
triggerall=var(37)!=13
trigger1=numhelper(40010)<=0
;trigger1=1
name="SPsummon"
id=40010
pos=0,-83+12000
postype=p1
facing=1
stateno=40060

[State ]
type = Helper
trigger1 = numHelper(485000) = 0
helpertype=normal
name = "Kyurem-CMD-Helper"
ID = 485000
stateno = 485000
ignorehitpause=1
persistent = 1
time = 9999999999999
movetime = 9999999999999

;---------------------------------------(HitBy)
[State -2, 無敵解除]
type = hitby
triggerall = PalNo = 12 || Var(40) = 1
trigger1 = stateno != 5000
trigger2 = stateno != 5001
trigger3 = stateno != 5010
trigger4 = stateno != 5011
trigger5 = stateno != 5020
trigger6 = stateno != 5030
trigger7 = stateno != 5035
trigger8 = stateno != 5040
trigger9 = stateno != 5050
trigger10 = stateno != 5070
trigger11 = stateno != 5071
trigger12 = stateno != 5080
trigger13 = stateno != 5081
trigger14 = stateno != 5100
trigger15 = stateno != 5101
trigger16 = stateno != 5110
trigger17 = stateno != 5120
trigger18 = stateno != 5150
trigger19 = stateno != 5200
trigger20 = stateno != 5201
trigger21 = stateno != 5210
trigger22 = stateno != 0
trigger23 = stateno != 10
trigger24 = stateno != 11
trigger25 = stateno != 12
trigger26 = stateno != 20
trigger27 = stateno != 40
trigger28 = stateno != 52
trigger29 = stateno != 100
trigger30 = stateno != 16500
trigger31 = HitDefAttr = SCA, NT, ST, HT
value = SCA,NASAHANPSPHPNTSTHT
time = 0

;---------------------------------------(LifeAdd)
[State -2, 黒ドナルドライフ回復]
type = lifeadd
triggerall = 1
triggerall = Life >= 1
triggerall = Life <= 100
trigger1 = PalNo = 12 || Var(40) = 1
value = 1

[State -2, 黒ドナルドライフ回復]
type = lifeadd
triggerall = Time = 1
triggerall = Life >= 100
trigger1 = PalNo = 12 || Var(40) = 1
value = 1

[State -2, ]
type = lifeadd
trigger1 = 1
trigger1 = PalNo = 12 || Var(40) = 1
trigger1 = GetHitVar(damage) >= 200
value = 0 + (GetHitVar(damage))

;---------------------------------------(MoveHitReset)
[State -2, MoveContact]
type = Null ;MoveHitReset
trigger1 = MoveContact
trigger1 = stateno != 1060 && stateno != 1070
trigger1 = stateno != 1101 ;1402 ;&& stateno != 1301
trigger1 = stateno != [3000,3099]
;trigger1 = stateno != [3300,3399]
ignorehitpause = 1

;---------------------------------------(NotHitBy)
[State -2,]
type = NotHitBy
triggerall = roundstate != 2
trigger1 = 1
value = SCA
ignorehitpause = 1

[State -2, 無敵]
type = nothitby
triggerall = PalNo = 12 || Var(40) = 1
trigger1 = GetHitVar(hitcount) >= 30
value = SCA,NASAHANPSPHPNTSTHT
time = 0

[State -2,本体無敵]
type=NotHitBy
triggerall=1
trigger1=Stateno =1610
;trigger2=Stateno =16500
value=SCA
time=-1
ignorehitpause=1

;---------------------------------------(PalFX)
[State -2, PalFX]
type = PalFX
triggerall = var(5) = 1
trigger1 = (var(15) % 30) = 0
time = 4
add = 190,0,0
mul = 266,256,256
sinadd = 180,0,0,30
invertall = 0
color = 256
ignorehitpause = 1

;---------------------------------------(PowerAdd)
[State -2, 黒ドナルドゲージ回復]
type = poweradd
triggerall = 1
triggerall = Life <= 300
trigger1 = PalNo = 12 || Var(40) = 1
value = 50

[State -2, 黒ドナルドゲージ回復]
type = poweradd
triggerall = 1
triggerall = Life >= 300
triggerall = Life <= 600
trigger1 = PalNo = 12 || Var(40) = 1
value = 5

[State -2, 黒ドナルドゲージ回復]
type = poweradd
triggerall = 1
triggerall = Life >= 600
trigger1 = PalNo = 12 || Var(40) = 1
value = 1

;---------------------------------------(PlaySnd)
[State -2, Pain Sounds]
type = PlaySnd
triggerall = Time = 1
triggerall = alive
trigger1 = stateno = 5001 || stateno = 5011
trigger1 = (anim%10) != 0
trigger2 = stateno = 5040 || stateno = 5050
trigger2 = random < 500
trigger3 = stateno = 5070
;value = 5000,ifelse(random<500,0,1)
value = 5000,0+random%7

[State -2, Shocked]
type = PlaySnd
trigger1 = Time = 1
trigger1 = anim = 7696
value = 7696,0

[State -2, Burned]
type = PlaySnd
trigger1 = Time = 1
trigger1 = anim = 7697
value = 7697,0

[State -2, Frozen]
type = PlaySnd
trigger1 = Time = 1
trigger1 = anim = 7990
value = 7990,0

[State -2, Frozen2]
type = PlaySnd
trigger1 = Time = 1
trigger1 = anim = 7991
value = 7990,0

[State -2, Squashed]
type = PlaySnd
trigger1 = Time = 1
trigger1 = anim = 7689
value = 7689,0

[State -2, Continue?]
type = PlaySnd
trigger1 = Time = 1
trigger1 = anim = 5500
value = 5500,0
loop = 0

[State Yay wall bounce]
type = PlaySnd
triggerall = numtarget
trigger1 = target,movetype = H
trigger1 = target,stateno = 9027 ;1027
trigger1 = target,time=1
value = S5,11 ;9
volume = 255
abspan = (target,screenpos X)-160
ignorehitpause=1
persistent=0

[State -2, 喰らい]
type = PlaySnd
triggerall = anim = 2 ;3
trigger1 = animelem = 4 ;3
trigger2 = animelem = 10 ;7
value = 3, 0
channel = 4

;---------------------------------------(Selfstate)
[State -]
type = SelfState
trigger1 = IsHelper(485000)
value=485000
ignorehitpause = 1
supermovetime = 9999999999
pausemovetime = 9999999999

[State 0, SelfState]
type = SelfState
triggerall = ishelper(485000)
trigger1=stateno!=485000
value = 485000
ignorehitpause = 1
persistent = 1
pausemovetime = 9999999999
supermovetime = 9999999999

;---------------------------------------(VarAdd)
[State -2, Increment Timer]
type = VarAdd
trigger1 = var(11)
v = 35
value = 1
ignorehitpause = 1

[State -2, Add to Timer]
type = VarAdd
trigger1 = var(5) = 1 || var(5) = -1
v = 15
value = 1

[State -2, Attack Fix]
type = VarAdd
trigger1 = 1
fvar(3) = ifelse(life < 150,.1,ifelse(life < 300,.05,0))

[State -2, Attack Fix]
type = VarAdd
trigger1 = Var(26) > 5
fvar(3) = -(4.125*var(26)-5)/100

[State -2, Combo]
type = VarAdd
trigger1 = MoveHit
var(26) = 1
ignorehitpause = 1

[State -2, MoveContact]
type = VarAdd
trigger1 = var(12)
var(12) = 1
ignorehitpause = 1

;---------------------------------------(VarSet)
[State -2, Leave PowerUp Mode]
type = VarSet
triggerall = var(11)=1
trigger1 = var(35) >= 1300 ;700
v = 11
value = 0

[State -2,t]
type = varset
trigger1 = Time = 0
trigger2 = !gethitvar(isbound)
v = 18 ;12 ;11
value = 1 ;2

[State -2,t]
type = varset
trigger1 = !gethitvar(isbound)
trigger1 = !var(43)
var(43) = var(18)

[State -2,t]
type = varset
trigger1 = !gethitvar(isbound)
trigger1 = !var(44)
trigger1 = var(18) != var(43)
var(44) = var(18)

[State -2,t]
type = varset
trigger1 = !gethitvar(isbound)
trigger1 = !var(45)
trigger1 = var(18) != var(43)
trigger1 = var(18) != var(44)
var(45) = var(18)

[State -2,t]
type = varset
trigger1 = !gethitvar(isbound)
trigger1 = !var(46)
trigger1 = var(18) != var(43)
trigger1 = var(18) != var(44)
trigger1 = var(18) != var(45)
var(46) = var(18)

[State -2,t]
type = varset
trigger1 = !gethitvar(isbound)
trigger1 = !var(47)
trigger1 = var(18) != var(43)
trigger1 = var(18) != var(44)
trigger1 = var(18) != var(45)
trigger1 = var(18) != var(46)
var(47) = var(18)

[State -2,t]
type = varset
trigger1 = !gethitvar(isbound)
trigger1 = !var(48)
trigger1 = var(18) != var(43)
trigger1 = var(18) != var(44)
trigger1 = var(18) != var(45)
trigger1 = var(18) != var(46)
trigger1 = var(18) != var(47)
var(48) = var(18)

[State -2,t]
type = varset
trigger1 = !gethitvar(isbound)
trigger1 = !var(49)
trigger1 = var(18) != var(43)
trigger1 = var(18) != var(44)
trigger1 = var(18) != var(45)
trigger1 = var(18) != var(46)
trigger1 = var(18) != var(47)
trigger1 = var(18) != var(48)
var(49) = var(18)

; ダメージ補正
[State -2, Attack Fix]
type = VarSet
trigger1 = 1
fvar(3) = ifelse(power >= 3000,1.15,ifelse(power >= 2000,1.1,ifelse(power >= 1000,1.05,1.0)))

[State -2, Combo]
type = VarSet
trigger1 = numenemy
trigger1 = enemy,MoveType != H
var(26) = 0
ignorehitpause = 1

[State -2, MoveContact]
type = VarSet
trigger1 = MoveContact
var(12) = 1
ignorehitpause = 1

[State -2, MoveContact]
type = VarSet
trigger1 = ctrl || Time = 1 || stateno != [200,5000)
var(12) = 0

[State -2, MoveContact]
type = VarSet
trigger1 = NumTarget=0
trigger2 = MoveContact
trigger2 = stateno != 1101 ;1301
var(28) = 0

; Combo Messages and Score control =====================================
;>3 Yes
;>4 Good
;>5 Great
;>7 Very Good
;>9 Wonderful
;>11 Fantastic
;>14 Monster
;>20 Marvelous

[State -2, VS Combo]
type = VarSet
trigger1 = var(55) >= 3
trigger2 = var(55)=-1 && (movehit || p2stateno = 6300 || p2stateno = [5000,5899])
var(56) = 1+(var(55)>3)+(var(55)>4)+(var(55)>6)+(var(55)>8)+(var(55)>10)+(var(55)>13)+(var(55)>19)-(var(55)=-1)
ignorehitpause = 1

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

[State -2, First Attack]
type = PlaySnd
triggerall = var(55)=-1
triggerall = NumExplod(8701) = 0
trigger1 = var(55)=-1 && (movehit || p2stateno = 6300 || p2stateno = [5000,5899])
persistent = 0
value = S230,0
volume=255
ignorehitpause = 1

[State -2, Combo Sound]
type = PlaySnd
trigger1 = NumExplod(8701) = 0
trigger1 = var(55)=0 && var(56)!=0
persistent = 0;1
value = 230,var(56)
volume=255
ignorehitpause = 1

[State -2, Left]
type = explod
trigger1 = var(55)=0 && var(56)!=0
trigger2 = var(55)=-1 && (movehit || p2stateno = 6300 || p2stateno = [5000,5899])
triggerall = TeamSide = 1 && NumExplod(8701) = 0
anim = (80000 + var(56))
ID = 8701
postype = left
pos = 10,80
ontop = 1
bindtime = -1
removetime = 60
supermovetime = 60
pausemovetime = 60
scale = 0.5,0.5
persistent = 0
ignorehitpause = 1

[State -2, Right]
type = explod
trigger1 = var(55)=0 && var(56)!=0
trigger2 = var(55)=-1 && (movehit || p2stateno = 6300 || p2stateno = [5000,5899])
triggerall = TeamSide = 2 && NumExplod(8701) = 0
anim = (81000+ var(56))
ID = 8701
postype = right
pos = -10,80
ontop = 1
bindtime = -1
removetime = 60
supermovetime = 60
pausemovetime = 60
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 = p2stateno = 6300 || p2stateno = [5000,5899]
trigger2 = var(55)=-1 && (movehit || p2stateno = 6300 || p2stateno = [5000,5899])
var(55) = 1 + (var(55)=-1)
ignorehitpause = 1

[State -2, VS Combo]
type = VarSet
trigger1 = var(55)!=-1 && (p2movetype!=H || enemynear, ctrl)
trigger2 = var(55)=-1 && stateno = [5000,5899]
var(55) = 0 - (roundstate<2)
ignorehitpause = 1

[State -2, VS Combo]
type = VarSet
triggerall = numexplod(8701)!=0
trigger1 = var(55)=0
var(56) = 0
ignorehitpause = 1

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

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

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

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