Xorifelse
I'd love to elaborate about discussions...........
- Reaction score
- 87
I'm still trying to improve the struct found in this topic, but I'm not sure if the code is efficient.
The thing is, I know jass very well and looking at this code it looks very efficient to me.
But I do not know the limitations or boundary's of vjass.
I've heard from a friend that i should use something called a timerObject library, but would it be more efficient?
JASS:
library Effects requires HandleVars
struct sfx
timer t = CreateTimer()
string m
real x
real y
real d
method onDestroy takes nothing returns nothing
set .t = null
set .m = null
set .x = 0
set .y = 0
set .d = 0
endmethod
static method CallBack takes nothing returns nothing
local sfx a = GetHandleInteger( GetExpiredTimer(), "i" )
call DestroyEffect( AddSpecialEffect( a.m, GetRandomReal( a.x - a.d, a.x + a.d ), GetRandomReal( a.y - a.d, a.y + a.d ) ) )
endmethod
method Stop takes nothing returns nothing
call PauseTimer( .t )
call DestroyTimer( .t )
call FlushHandleInteger( .t, "i" )
endmethod
method Pause takes nothing returns nothing
call PauseTimer( .t )
endmethod
method Start takes real timeout, string m, real x, real y, real d returns nothing
local sfx a = sfx.create()
set a.m = m
set a.x = x
set a.y = y
set a.d = d
call SetHandleInteger( .t, "i", a )
call TimerStart( .t, timeout, true, function sfx.CallBack )
endmethod
endstruct
endlibrary
JASS:
scope test initializer init
function Actions takes nothing returns nothing
local sfx a = sfx.create()
local sfx b = sfx.create()
call FogModifierStart( CreateFogModifierRect( Player( 0 ), FOG_OF_WAR_VISIBLE, GetWorldBounds(), true, true ) )
call a.Start( 0.2, "Abilities\\Spells\\Human\\SpellSteal\\SpellStealMissile.mdl", -650, -900, 300 )
call b.Start( 1, "Abilities\\Weapons\\Bolt\\BoltImpact.mdl", 650, 350, 500 )
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerAddAction( t, function Actions )
call TriggerExecute( t )
set t = null
endfunction
endscope
The thing is, I know jass very well and looking at this code it looks very efficient to me.
But I do not know the limitations or boundary's of vjass.
I've heard from a friend that i should use something called a timerObject library, but would it be more efficient?