===============
Projectile Repel
===============
Created by The Necromancer

;---------------------------------------------------------------------------
Projectile Repel -- Uncommon in most fighting games, but VERY
common for the DBZ genre, this ability allows your character
to redirect the opponent's projectile back at him/her.

This example shows how the "Hajiku" move of the Super
Boutuden games is made.

Notes:

-3 Vars are required for this move.

Var(0): Opponent's projectile damage value
Var(1): Records the number of taps pressed.
Var(2): The number of taps required. (Equation: Opponent damage divided by 30)

Var(0) and Var(1) are resetted whenever the character goes into his/her recovery
state. (After the projectile has been repelled/destroyed.)

Var(2) is resetted at the beginning of the projectile repel attempt state.
;---------------------------------------------------------------------------
;Hajiku - Stance
[Statedef 9000]
type  = S
movetype = I
physics = S
anim = 9000 ;A blocking type animation

[State 9000: HitOverride]
type = HitOverride
trigger1 = 1
slot = 1
attr = SCA, AP
stateno = 9001
time = 1

[State 9000: ChangeState]
type = ChangeState
trigger1 = (Command != "holdb") || (Command != "holdc")
value = 0
ctrl = 1

;---------------------------------------------------------------------------
;Hajiku - Repel Attempt
[Statedef 9001]
type = S
movetype = H
physics = S
anim = 9001 ; A blocking type animation
sprpriority = -2

[State 9001: HitOverride]
type = HitOverride
trigger1 = 1
slot = 0
attr = SCA, AP
stateno = 9001
time = 1

;Used for projectile damage in state 9002. (If successfuly repelled.)
[State 9001: VarAdd]
type = VarAdd
trigger1 = Time = 0
v = 0
value = Ceil(GetHitVar(Damage)*(-1))

;Used for "tapping" feature. (3 taps for every 100 points of damage of the opponent's projectile.)
[State 9001: VarSet]
type = VarSet
trigger1 = Time = 1
v = 1
value = Floor(Var(0)/30)*(-1)

;Used for number of taps made. (Reset at start)
[State 9001: VarSet]
type = VarSet
trigger1 = Time = 0
v = 2
value = 0

;Used for number of taps made. (Add tap value)
[State 9001: VarAdd]
type = VarAdd
triggerall = Time <= 100
trigger1 = (Command = "x") || (Command = "y") || (Command = "z") || (Command = "a") || (Command = "b") || (Command = "c")
v = 2
value = 1

;Get pushed by the opponent's projectile. (Divided by 2.)
[State 9001: VelSet]
type = VelSet
trigger1 = Time = 0
x = IfElse(Facing = 1,(GetHitVar(XVel)/2),(GetHitVar(XVel)/2*(-1)))
y = 0

;Projectile explod animation (On character)
[State 9001: Explod]
type = Explod
trigger1 = Time = 0
anim = (whatever)
id = (whatever)
pos = (Position of projectile)
postype = p1
bindtime = -1
removetime = -1
ontop = 1
ownpal = 1
removeongethit = 1

;Remove projectile explod animation.
[State 9001: RemoveExplod]
type = RemoveExplod
trigger1 = AnimTime = 0
id = (whatever)

;If projectile was successfully tapped, go to projectile repel state.
[State 9001: ChangeState]
type = ChangeState
trigger1 = (AnimTime = 0) && (Var(2) > Var(1))
value = 9002

;If projectile was not successfully tapped, go to get hit state. (Projectile will explod on character in next state.)
[State 9001: ChangeState]
type = ChangeState
trigger1 = (AnimTime = 0) && (Var(2) <= Var(1))
value = 9003

;---------------------------------------------------------------------------
;Hajiku - Proj Cancel Success
[Statedef 9002]
type = S
movetype = I
physics = S
anim = 9002 ;Animation to repel projectile, or a blocking type animation.
velset = 0,0
ctrl = 0

;Recovery: Lose no life from the opponent's original projectile.
;Note: This equation applies only if the LIFE setting in Mugen is set to default. (100%)
[State 9002: LifeAdd]
type = LifeAdd
trigger1 = Time = 0
value = Ceil(Var(0)*(-1))

;VarSet: Reset the tapping values.
[State 9002: VarSet]
type = VarSet
trigger1 = Time = 0
v = 1
value = 0

;VarSet: Rest the opponent's projectile value. (Must be AFTER the projectile has been released.)
[State 9002: VarSet]
type = VarSet
trigger1 = AnimTime = 0
v = 0
value = 0

[State 9002: Projectile]
type = Projectile
trigger1 = (whatever)
projid = (whatever)
projanim = (whatever)
projhitanim = (whatever)
projremanim = (whatever)
projcancelanim = (whatever)
projremove = 1
projremovetime = 100
velocity = *,*
projpriority = 9
projsprpriority = 4
projedgebound = 1000
projstagebound = 1000
projheightbound = -1000,1
offset = *,* ;Must be the same offset as the projectile explod animation.
postype = p1
;------------------
attr = S, HP
hitflag = MAFP
guardflag = MA
animtype = Heavy
priority = 1, Hit
damage = Ceil(Var(0)*(-1)),(Var(0)*(-1))/2
etc...

[State 9002: ChangeState]
type = ChangeState
trigger1 = AnimTime = 0
value = 0
ctrl = 1

;---------------------------------------------------------------------------
;Hajiku - Proj Cancel Failed
[Statedef 9003 ]
type = S
movetype = I
physics = S
anim = 9003 ;Blocking type animation, or get hit animation. 

;VarSet: Reset the tapping values.
[State 9003: VarSet]
type = VarSet
trigger1 = Time = 0
v = 1
value = 0

;VarSet: Rest the opponent's projectile value. (Must be AFTER the projectile has been released.)
[State 9003: VarSet]
type = VarSet
trigger1 = AnimTime = 0
v = 0
value = 0

;Projectile explosion animtion.
[State 9003: Explod]
type = Explod
trigger1 = Time = 0
anim = (whatever)
id = (whatever)
pos = 0,0
postype = p1
bindtime = 1
removetime = -2
ontop = 1
ownpal = 1

If dies, go to custom KOed  state.
[State 9003: ChangeState]
type = ChangeState
trigger1 = Life <= 0
value = *

;Ends the move.
[State 9003: ChangeState]
type = ChangeState
trigger1 = AnimTime = 0
value = 0
ctrl = 1
