;===============================================================================

; ------- Damage Dampener --------

;===============================================================================

;Used to add Counter Hit Scaling

[State -2, Counter Flag]

type = VarSet

trigger1 = NumEnemy

fvar(8) = (EnemyNear, MoveType = A)

ignoreHitPause = 1

;Keeps track of current combo count

[State -2, Hit Count]

type = VarAdd

trigger1 = !IsHelper

trigger1 = MoveHit = 1

trigger1 = !HitPauseTime

trigger1 = !(HitDefAttr = SCA, AT)

fvar(13) = 1

[State -2, Hit Count Reset]

type = VarSet

trigger1 = NumEnemy && fvar(13)

trigger1 = (EnemyNear, MoveType != H) && (EnemyNear, StateNo != 5300)

fvar(13) = 0

ignoreHitPause = 1

[State -2, Scaling]

type = VarSet

trigger1 = 1

fvar(10) = ifElse(fvar(13) > 2, 1 - 0.10 * (fvar(13) - 1), 1)

ignoreHitPause = 1

;This is my favourite bit of code. How it works is like this

;If Fvar(13) (Hit Count) is over 2, the value become 1 - 0.10 times Hit Count minus 1. This bascially means

;that the value is calculated by how many hits are in the combo minus 1, so at minimum the value becomes 2,so

;its really saying

;Ifelse(fvar(13) > 2, 1- 0.10 * 2, 1)

;And since the hit count rises as the combo continues, it becomes 3, 4, 5, etc basically subtracting 20, then

;30 percent and so on from the damage. So if you did say, LP,LP,LP, this is what happens

;LP = Fvar(13) = 1, no calculation, damage = 25

;LP = Fvar(13) = 2, no calculation, damage = 25

;LP = Fvar(13) = 3, - 20%, damage = 20

[State -2, Scaling Limit]

type = VarSet

trigger1 = fvar(10) < 0

fvar(10) = 0.10

ignoreHitPause = 1

;Minimum of 10%

[State -2, Root Dampener]

type = VarSet

trigger1 = 1

fvar(11) = fvar(10) * ifElse(fvar(8), 1.2, 1) ;* fvar(9)

ignoreHitPause = 1

;Hitdef

;damage = ceil(ifElse(fvar(13) > 2, fvar(11) * BASE_DAMAGE , BASE_DAMAGE))

;===============================================================================

; ------- Damage Dampener --------

;===============================================================================

;Used to add Counter Hit Scaling

[State -2, Counter Flag]

type = VarSet

trigger1 = (enemynear, movetype = A)

fvar(8) = 1

ignoreHitPause = 1

[State -2, Counter Flag Reset]

type = VarSet

trigger1 = (enemynear,movetype != A)

fvar(8) = 0

ignoreHitPause = 1

;Decreases damage if opponent has 50 0r 30% life

[State -2, Life Scaling]

type = varset

trigger1 = (enemynear, life > lifemax * 0.50) ;No scaling if over 50% life

fvar(9) = 1

ignorehitpause = 1

[State -2, Life Scaling reduction1]

type = varset

trigger1 = 1

fvar(9) = ifelse((enemynear, life <= lifemax * 0.50), (1 - 0.10), 1)

ignorehitpause = 1

[State -2, Life Scaling reduction2]

type = varset

trigger1 = fvar(9) < 1

fvar(9) = ifelse((enemynear, life <= lifemax * 0.30), (1 - 0.15), 0.90)

ignorehitpause = 1

;Keeps track of current combo count

[State -2, Hit Count]

type = VarAdd

trigger1 = !IsHelper

trigger1 = MoveHit = 1

trigger1 = !HitPauseTime

trigger1 = !(HitDefAttr = SCA, AT)

fvar(13) = 1

[State -2, Hit Count Reset]

type = VarSet

trigger1 = NumEnemy && fvar(13)

trigger1 = (EnemyNear, MoveType != H) && (EnemyNear, StateNo != 5300)

fvar(13) = 0

ignoreHitPause = 1

[State -2, Scaling]

type = VarSet

trigger1 = 1

fvar(10) = ifElse(fvar(13) >= 2, 1 - (0.10 * fvar(13)), 1)

ignoreHitPause = 1

[State -2, Scaling Limit]

type = VarSet

trigger1 = fvar(10) < 0

fvar(10) = 0.10

ignoreHitPause = 1

[State -2, Root Dampener]

type = VarSet

trigger1 = 1

fvar(11) = fvar(10) * ifElse(fvar(8) = 1, 1.2, 1) * fvar(9)

ignoreHitPause = 1

;Hitdef

;damage = ceil(fvar(11) * BASE_DAMAGE)