• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[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