AddTimedEffect (string model, real x, real y, real time)
by Zacharias
by Zacharias
Include this code in your map and you will gain access to AddTimedEffect. This function gives you the ability to create an effect on a specific point in the map, lasting for a specific duration.
Use this function to start the effect, everything else, including cleaning up, will be done automatically:
name | AddTimedEffect | |
return type | void | |
parameter | ||
type | name | comment |
string | model | the effect model you want to use(similar to AddSpecialeffect) |
real | x | x-coordinate of target point |
real | y | y-coordinate of target point |
real | time | duration |
Have fun and give credits
JASS:
globals
effect array effectarray
real array effectarrayTime
integer effectarrayCount = 0
timer effectarrayTimer = CreateTimer()
endglobals
function exeTimedEffect takes nothing returns nothing
local integer i = 0
local integer counted = 0
//call Print(I2S(effectarrayCount)+" effects in timer")
if effectarrayCount == 0 then
call PauseTimer(effectarrayTimer)
//call Print("stop timer")
else
loop
exitwhen counted>=effectarrayCount
if effectarray[i] != null then
set effectarrayTime[i] = effectarrayTime[i]-0.1
//call Print("time[" + I2S(i) + "]=" + R2S(effectarrayTime[i]))
if(effectarrayTime[i] <= 0) then
call DestroyEffect(effectarray[i])
set effectarrayCount=effectarrayCount-1
set effectarrayTime[i] = 0
set effectarray[i] = null
//call Print("destroy "+I2S(i))
else
set counted=counted+1
endif
endif
set i=i+1
endloop
endif
endfunction
function AddTimedEffect takes string model, real x, real y, real time returns nothing
local integer i = 0
// find free slot
loop
exitwhen effectarray[i] == null
set i=i+1
endloop
// add a effect
//call Print("add effect in slot "+I2S(i))
set effectarrayCount = effectarrayCount+1
set effectarray[i] = AddSpecialEffect(model,x,y)
set effectarrayTime[i] = time
if effectarrayCount == 1 then
call TimerStart(effectarrayTimer, 0.1, true, function exeTimedEffect)
//call Print("start timer")
endif
endfunction
Note: I didn´t delete the print("") comments, add this simple function to your code and delete the // to ease debug work:
JASS:
function Print takes string str returns nothing
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, str)
endfunction
Last edited: