- Joined
- Oct 11, 2012
- Messages
- 711
Does it leak? If so, how to deal with it?
Thanks a lot.
Thanks a lot.
No leak.
loop
set u = FirstOfGroup(g)
exitwhen u == null
call GroupRemoveUnit(g,u)
call UnitDamageTarget(gg_unit_H02Y_0001,u,33.,true,false,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_DEMOLITION,null)
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Other\\Monsoon\\MonsoonBoltTarget.mdl",u,"origin"))
endloop
library SpecialEffect requires Table
/* This allow you to create timed effects */
globals
private HandleTable tab
endglobals
private struct SpecialEffect
effect e
timer t
//Chobibo wanted conventionnal stuff
static method create takes nothing returns thistype
local thistype this = thistype.allocate()
set this.t = CreateTimer()
return this
endmethod
private static method onInit takes nothing returns nothing
set tab = HandleTable.create()
endmethod
endstruct
private function End takes nothing returns nothing
local timer t = GetExpiredTimer()
local SpecialEffect this = tab[t]
call DestroyEffect(this.e)
call tab.flush(t)
call this.destroy()
call DestroyTimer(t)
set t = null
endfunction
function AddSpecialEffectTimed takes string modelName, real x, real y, real time returns nothing
local SpecialEffect this = SpecialEffect.create()
set this.e = AddSpecialEffect(modelName, x, y)
set tab[this.t] = this
call TimerStart(this.t, time, false, function End)
endfunction
function AddSpecialEffectTargetTimed takes string modelName, widget target, string attachPointName, real time returns nothing
local SpecialEffect this = SpecialEffect.create()
set this.e = AddSpecialEffectTarget(modelName, target, attachPointName)
set tab[this.t] = this
call TimerStart(this.t, time, false, function End)
endfunction
endlibrary
Alrighty, thanks!If you wanted to do it yourself, then you need to create the effect, save it (hashtables, array or anything else you use) and then use some sort of timer or jass timers and then destroy it. If you're good using systems on the site, you can use this.
It uses Table by Vexorian but you can use a normal hashtable too :
JASS:library SpecialEffect requires Table /* This allow you to create timed effects */ globals private HandleTable tab endglobals private struct SpecialEffect effect e timer t = CreateTimer() private static method onInit takes nothing returns nothing set tab = HandleTable.create() endmethod endstruct private function End takes nothing returns nothing local timer t = GetExpiredTimer() local SpecialEffect this = tab[t] call DestroyEffect(this.e) call tab.flush(t) call this.destroy() call DestroyTimer(t) set t = null endfunction function AddSpecialEffectTimed takes string modelName, real x, real y, real time returns nothing local SpecialEffect this = SpecialEffect.create() set this.e = AddSpecialEffect(modelName, x, y) set tab[this.t] = this call TimerStart(this.t, time, false, function End) endfunction function AddSpecialEffectTargetTimed takes string modelName, widget target, string attachPointName, real time returns nothing local SpecialEffect this = SpecialEffect.create() set this.e = AddSpecialEffectTarget(modelName, target, attachPointName) set tab[this.t] = this call TimerStart(this.t, time, false, function End) endfunction endlibrary