• 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.

spawning with integer

Status
Not open for further replies.
Level 2
Joined
Feb 13, 2013
Messages
7
Hi,

every x second map is spawning wagon. This wagon will move to some region and destroy itself.

now i want spawn 1 ghoul, every y second, for each wagon that reach region.

Can somebody help me and explain me how to do that?
thx
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
  • Untitled Trigger 079
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in region matching (((Unit-type of (Matching unit)) Equal to Wagon) and (((Matching unit) is alive) Equal to True))) and do (Actions)
        • Loop - Actions
          • Set point = (Position of (Picked unit))
          • Unit - Create 1 Ghoul for SomePlayer at point facing Default building facing degrees
          • Custom script: call RemoveLocation(udg_point)
          • Custom script: set udg_point = null
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
This is what DSG has to say about this topic:

I'm not knowledgeable enough about the underlying mechanics to verify any of this, but his post does seem to make sense.

JASS:
library LeakTest
    globals
        private integer k = 0
    endglobals

    function looping takes nothing returns nothing
        local integer i = 500
        local location l
        loop
            exitwhen i == 0
            set l = Location(GetRandomReal(-1000, 1000), (GetRandomReal(-1000, 1000))) 
            //set u = CreateUnit(Player(15), 'hfoo', 0, 0, 0)
            //call UnitApplyTimedLife(u, 1, 0.01)
            //call UnitApplyTimedLife(CreateUnit(Player(15), 'hfoo', 0, 0, 0), 1, 0.01)
            call RemoveLocation(l)
            set k = k + 1
            set i = i - 1
            //set l = null
        endloop
    endfunction

    function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
        if udg_i == 0 then
            set udg_i = 1
            call BJDebugMsg("start")
            call TimerStart(udg_tmr, 0.01, true, function looping)
        else
            set udg_i = 0
            call BJDebugMsg("stop")
            call BJDebugMsg(I2S(k))
            call PauseTimer(udg_tmr)
        endif
    endfunction

    //===========================================================================
    function InitTrig_Untitled_Trigger_001_Copy takes nothing returns nothing
        local unit u
        set gg_trg_Untitled_Trigger_001_Copy = CreateTrigger(  )
        set u = CreateUnit(Player(15), 'hfoo', 0, 0, 0)
        call UnitApplyTimedLife(u, 1, 0.01)
        call TriggerRegisterPlayerEventEndCinematic( gg_trg_Untitled_Trigger_001_Copy, Player(0) )
        call TriggerAddAction( gg_trg_Untitled_Trigger_001_Copy, function Trig_Untitled_Trigger_001_Actions )
        set u = null
    endfunction
endlibrary

If the l = null is commented out, the memory usage of War3.exe grows constantly. If it is not commented out, the memory usage will not grow at all. It applies to globals also.
 
Status
Not open for further replies.
Top