- Joined
- Sep 12, 2008
- Messages
- 657
hey, i've made a code that stuns a unit for X time,
then un-stuns it, after the amount of time stated.
it all works good, but for some reason it never unstuns.
any help is appreciated =]
thanks in advance
then un-stuns it, after the amount of time stated.
it all works good, but for some reason it never unstuns.
any help is appreciated =]
JASS:
library StunTarget initializer OnInit
struct Stun
private static constant string StunObjectPath = "Abilities\\Spells\\Human\\Thunderclap\\ThunderclapTarget.mdl"
private static thistype c = 0
private static thistype c2 = 0
private static integer c3 = 0
private unit caster = null
private unit target = null
private real duration = 0
private real dps = 0
private effect eff = null
static method create takes unit caster, unit target, real duration, real dps returns Stun
if IsUnitPaused(target) then
set c = c + 1
set c3 = c3 + 1
set c.caster = caster
set c.target = target
set c.duration = duration
set c.dps = dps
call PauseUnit(c.target, true)
call IssueImmediateOrder(c.target, "stop")
call ResetUnitAnimation(c.target)
set c.eff = AddSpecialEffectTarget(StunObjectPath, c.target, "overhead")
else
return null
endif
return c
endmethod
method setTarget takes unit new, boolean unpauselast returns nothing
if unpauselast then
call PauseUnit(this.target, false)
endif
set this.target = new
endmethod
method setCaster takes unit new returns nothing
set this.caster = new
endmethod
method setDuration takes real time returns nothing
set this.duration = time
endmethod
method setDPS takes real damage returns nothing
set this.dps = damage
endmethod
static method onLoop takes nothing returns nothing
if c > 0 then
loop
set c2 = c2 + 1
if c2.duration > 0 then
set c2.duration = c2.duration - 0.032
if c2.dps != 0 then
// not equal to 0, cuz it can heal aswell, while using -
call UnitDamageTarget(c2.caster, c2.target, c2.dps, false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
endif
else
call PauseUnit(c2.target, false)
set c2.dps = 0
set c2.duration = 0
set c2.caster = null
set c2.target = null
call DestroyEffect(c2.eff)
set c3 = c3 - 1
if c3 == 0 then
set c = 0
set c2 = 0
endif
endif
exitwhen c2 >= c
endloop
endif
endmethod
endstruct
private function OnInit takes nothing returns nothing
call TimerStart(CreateTimer(), 0.032, true, function s__Stun_onLoop)
endfunction
endlibrary
thanks in advance