• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Inefficient

Status
Not open for further replies.
Level 5
Joined
Sep 19, 2006
Messages
152
This code seems needless complex. The trigger just takes every item laying on the ground in the playable map area, and reduces its life at intervals. Is there a more efficient way to do this?


JASS:
function Every30Seconds_Action02 takes nothing returns nothing
    call SetWidgetLife (GetEnumItem(), (GetWidgetLife (GetEnumItem()) - 20.00))
endfunction

function Every30Seconds_Action01 takes nothing returns nothing
    local rect r = Rect (-7424.000, -11776.000, 7424.000, 11264.000)
    call EnumItemsInRect (r, null, function Every30Seconds_Action02)
    call RemoveRect (r)
    set r = null
endfunction

function InitTrig_Every30Seconds takes nothing returns nothing
    set gg_trg_Every30Seconds = CreateTrigger ()
    call DisableTrigger (gg_trg_Every30Seconds)
    call TriggerRegisterTimerEventPeriodic (gg_trg_Every30Seconds, 30.00)
    call TriggerAddAction (gg_trg_Every30Seconds, function Every30Seconds_Action01)
endfunction
 
Level 11
Joined
Feb 18, 2004
Messages
394
As far as i can see, thats as simplistic as it gets. You could use a timer instead of a trigger using a timed event, but thats pretty much as complicated. You could also use the bj_mapInitialPlayableArea rect instead of creating and destroying one every 30 seconds. (DON'T destroy that rect, of course)
 
Level 5
Joined
Sep 19, 2006
Messages
152
So which line in

function InitTrig_Every30Seconds takes nothing returns nothing
set gg_trg_Every30Seconds = CreateTrigger ()
call DisableTrigger (gg_trg_Every30Seconds)
call TriggerRegisterTimerEventPeriodic (gg_trg_Every30Seconds, 30.00)
call TriggerAddAction (gg_trg_Every30Seconds, function Every30Seconds_Action01)

would

call TriggerRegisterTimerEvent (gg_trg_Every30Seconds, 30,true)

replace?
 
Status
Not open for further replies.
Top