YesNoOk
avatar

Fix (Sort Of) for Poison Effect Problem (Read 9874 times)

Started by Bane84, January 12, 2015, 03:16:13 AM
Share this topic:
Fix (Sort Of) for Poison Effect Problem
#1  January 12, 2015, 03:16:13 AM
  • avatar
  • ***
  • Original characters are my forte.
    • http://network.mugenguild.com/bane84/
There have been numerous topics where creators have asked how to implement a poison effect on an opponent.  I am not here to explain how to do it, so please refer to these topics:
http://mugenguild.com/forum/topics/poison-effect-solved--123787.0.html
http://mugenguild.com/forum/topics/-solved-sadly-poison-effect-almost-successful-except--133025.0.html
http://mugenguild.com/forum/topics/drain-p2s-life-while-hes-not-being-hit-147277.0.html

One of the problems of this implementation is that if the user blocks or otherwise moves backwards, the effect will stop working until they exit that state.  I myself have encountered this problem and have found a fix for it.

The idea is to have the helper use a variable to store the target's current value (life or power) on an otherwise uninitialized variable before the move takes effect.  The helper will then proceed to drain this value for the duration of the move.  When the time expires, the effect should stop, but the helper should not immediately be destroyed.  It will need to perform a final check to see if the target's current value is an expected value.  If not, it should perform some math to subtract the amount that should have been drained during the move's lifespan before destroying itself.

Here is some example code from one of my characters:
Code:
;---------------------------------------------------------------------------
; Spirit Needles (Helper State)
; This move is exploiting a known bug in MUGEN where this helper can retain
; the ID of the target that was hit even if the target is not in a hitstate.
; However, the target is lost whenever the opponent is hit by something else
; or the target is blocking.  To fix this bug, a variable will be used to store
; the target's Power at the start.  Once the time expires, the helper will
; first check to see if the full amount of power has been drained.  If not,
; it will remove the remaining power that should have been depleted before
; destroying itself.
[Statedef 3008]
type    = S
movetype= A
physics = N
ctrl = 0
anim = 1008

; Set the target's starting power.
[State 3008, CurrentPower]
type = VarSet
trigger1 = NumTarget > 0
trigger1 = var(0) = 0
v = 0
value = target,Power

; Decrease the hit counter.
[State 3008, HitTakeAway]
type = HitAdd
trigger1 = Time = 0
value = -1

; Play a power down sound.
[State 3008, PowerDown]
type = PlaySnd
trigger1 = Time = 0
value = 3005,0

; Hold the target we just hit.
[State 3008, HoldTarget]
type = ReversalDef
trigger1 = NumTarget = 0
reversal.attr = C, HT
sparkno = -1

; Drain the target's super bar.
[State 3008, PowerDrain]
type = TargetPowerAdd
trigger1 = Time <= 300
trigger1 = NumTarget > 0
trigger1 = target,Power > 0
value = IfElse(target,Power-ceil((target,PowerMax*0.5)/300)>0, -ceil((target,PowerMax*0.5)/300), -target,Power)

; If the time period has expired and the target's power is not at the expected level,
; set it now.
[State 3008, FinalPowerAbove0]
type = TargetPowerAdd
trigger1 = Time > 300
trigger1 = NumTarget > 0
trigger1 = var(0)-ceil(target,PowerMax*0.5) > 0 && target,Power > var(0)-ceil(target,PowerMax*0.5)
value = -(target,Power-(var(0)-ceil(target,PowerMax*0.5)))

[State 3008, FinalPower0]
type = TargetPowerAdd
trigger1 = Time > 300
trigger1 = NumTarget > 0
trigger1 = var(0)-ceil(target,PowerMax*0.5) <= 0 && target,Power > 0
value = -(target,Power)

[State 3008, Destroy]
type = DestroySelf
; Only destroy ourselves if the complete amount of power was taken away.
triggerall = NumTarget > 0
trigger1 = Time > 300
trigger1 = target,Power <= 0 || target,Power = var(0)-ceil(target,PowerMax*0.5)
trigger2 = !target,Alive

As you can see, this move is used to drain the power of a target that it hits.  It will not destroy itself until the correct amount has been depleted after the move time expires or the target is no longer alive.

Keep in mind that this method does not take into account if there are other factors that affect the life/power values (such as healing, addtional damage incurred, or if the target gains/loses power through some external means).  This method may need optimization to account for these external factors, but it's at least a fix in the meantime.