- Joined
- Apr 6, 2008
- Messages
- 760
Credits
Redscores: For showing me timer "stacks"
Fixes:
A minor improvment
Changed the code abit and addes textmacros
This is a simple system i wrote to create effect on units or at locations(x/y). u can decide how long it will last and is very easy to use
To come:
Add support for Lightnings
Requires: Jass NewGen Pack
Redscores: For showing me timer "stacks"
Fixes:
A minor improvment
Changed the code abit and addes textmacros
JASS:
globals
constant real intervals = .05
endglobals
//! textmacro Effect takes NAME, TYPE, TAKES, RETURN, KIND, ACTION, DESTROY
globals
timer $NAME$_Time = CreateTimer()
integer $NAME$_Total = 0
integer array $NAME$_Struct
endglobals
public struct $NAME$_Data
$TYPE$
unit u
unit t
real dura
real maxdur
static method create takes $TAKES$ returns $NAME$_Data
local $NAME$_Data d = $NAME$_Data.allocate()
set d.u = u
set d.$NAME$ = $ACTION$
set d.dura = 0.
set d.maxdur = dura
if $NAME$_Total == 0 then
call TimerStart($NAME$_Time,intervals,true,function $NAME$_Data.Exe)
endif
set $NAME$_Struct[$NAME$_Total] = d
set $NAME$_Total = $NAME$_Total + 1
return d
endmethod
static method Exe takes nothing returns nothing
local $NAME$_Data d
local integer index = 0
loop
exitwhen index >= $NAME$_Total
set d = $NAME$_Struct[index]
set d.dura = d.dura + intervals
if d.dura >= d.maxdur then
set $NAME$_Total = $NAME$_Total - 1
set $NAME$_Struct[index] = $NAME$_Struct[$NAME$_Total]
if $NAME$_Total == 0 then
call PauseTimer($NAME$_Time)
endif
call d.destroy()
endif
set index = index + 1
endloop
endmethod
method onDestroy takes nothing returns nothing
call $DESTROY$(.$NAME$)
set .$NAME$ = null
set .u = null
set .t = null
set .dura = 0.
set .maxdur = 0.
endmethod
endstruct
function Create$NAME$$KIND$ takes $TAKES$ returns nothing
local $NAME$_Data d = $NAME$_Data.create($RETURN$)
endfunction
//! endtextmacro
library EffectSystem
//! runtextmacro Effect("Effect","effect Effect","unit u,real dura,string SFX,string attachPoint","u,dura,SFX,attachPoint","Unit","AddSpecialEffectTarget(SFX,d.u,attachPoint)","DestroyEffect")
endlibrary
This is a simple system i wrote to create effect on units or at locations(x/y). u can decide how long it will last and is very easy to use
To come:
Add support for Lightnings
Requires: Jass NewGen Pack
Last edited: