Spawning Units For Lanes

Carl-Fredrik

New Member
Reaction score
51
Hello everyone... I've been trying to make a trigger that spawns units for 4 different lanes and then send them away towards each other, but for some reason it doesn't work :/

The units are not created...
So, here's one of the four triggers that's supposed to do this:

JASS:
scope LifeSpawn1 initializer InitSpawnL1

private function Actions takes nothing returns nothing
    local location SpawnLoc = GetRectCenter(gg_rct_LifeSpawn)
    local location SendLoc = GetRectCenter(gg_rct_Region_028)
    local real w = 0.5
    local integer ExtraWave
    call BJDebugMsg("Wtf?1")
    if ExtraWave == 3 then
        call CreateUnitAtLoc(Player(10), 'n00A', SpawnLoc, bj_UNIT_FACING)
        set ExtraWave = 1
        call TriggerSleepAction(w)
        call BJDebugMsg("Wtf?2")
    else
        set ExtraWave = ExtraWave + 1
        call BJDebugMsg("Wtf?3")
    endif
    call BJDebugMsg("Wtf?4")
    call CreateUnitAtLoc(Player(10), 'n001', SpawnLoc, bj_UNIT_FACING)
    call IssuePointOrderLoc(GetLastCreatedUnit(), "attack", SendLoc)
    call TriggerSleepAction(w)
    call CreateUnitAtLoc(Player(10), 'n001', SpawnLoc, bj_UNIT_FACING)
    call IssuePointOrderLoc(GetLastCreatedUnit(), "attack", SendLoc)
    call TriggerSleepAction(w)
    call CreateUnitAtLoc(Player(10), 'n002', SpawnLoc, bj_UNIT_FACING)
    call IssuePointOrderLoc(GetLastCreatedUnit(), "attack", SendLoc)
    call TriggerSleepAction(w)
    call CreateUnitAtLoc(Player(10), 'n007', SpawnLoc, bj_UNIT_FACING)
    call IssuePointOrderLoc(GetLastCreatedUnit(), "attack", SendLoc)
    call RemoveLocation(SpawnLoc)
    call RemoveLocation(SendLoc)
    set SpawnLoc = null
    set SendLoc = null
endfunction

private function InitSpawnL1 takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterTimerEvent(t, 30, true)
    call TriggerAddAction(t, function Actions)
endfunction

endscope


And I was also wondering, if I put this into a bigger trigger (all 4 of the others) will they run at the same time or will the functions go off one at a time?

Edit:

I added BJDebugMsg to check where the trigger it stops. The first one is shown but none of the others.. :S
 

Viikuna

No Marlo no game.
Reaction score
265
GetLastCreatedUnit only works with GUIs CreateNUnitsAtLoc, because it does this:

JASS:
set bj_lastCreatedUnit = CreateUnitAtLoc(id, unitid, loc, face)

GetLastCreatedUnit looks like this:
JASS:
function GetLastCreatedUnit takes nothing returns unit
    return bj_lastCreatedUnit
endfunction


You should always use NewGens function list to check what those red functions ( BJs ) actually do.

It would be best to just do it like this:

JASS:

local unit u
set u=CreateUnitAtLoc(Player(11), 'o004', SpawnLoc, bj_UNIT_FACING)
call IssuePointOrderLoc(u, "attack", SendLoc)
 

Carl-Fredrik

New Member
Reaction score
51
GetLastCreatedUnit only works with GUIs CreateNUnitsAtLoc, because it does this:

JASS:
set bj_lastCreatedUnit = CreateUnitAtLoc(id, unitid, loc, face)

GetLastCreatedUnit looks like this:
JASS:
function GetLastCreatedUnit takes nothing returns unit
    return bj_lastCreatedUnit
endfunction


You should always use NewGens function list to check what those red functions ( BJs ) actually do.

It would be best to just do it like this:

JASS:
local unit u
set u=CreateUnitAtLoc(Player(11), 'o004', SpawnLoc, bj_UNIT_FACING)
call IssuePointOrderLoc(u, "attack", SendLoc)

Ok :O

I will in the future ^^
That doesn't explain why they're not spawned though...

Edit:

It seems as if the code if stopping after the if...

The first message is displayed but not the others.
JASS:
scope LifeSpawn1 initializer InitSpawnL1

private function Actions takes nothing returns nothing
    local location SpawnLoc = GetRectCenter(gg_rct_LifeSpawn)
    local location SendLoc = GetRectCenter(gg_rct_Region_028)
    local real w = 0.5
    local integer ExtraWave
    call BJDebugMsg("Wtf?1")
    if ExtraWave == 3 then
        call CreateUnitAtLoc(Player(10), 'n00A', SpawnLoc, bj_UNIT_FACING)
        set ExtraWave = 1
        call TriggerSleepAction(w)
        call BJDebugMsg("Wtf?2")
    else
        set ExtraWave = ExtraWave + 1
        call BJDebugMsg("Wtf?3")
    endif
    call BJDebugMsg("Wtf?4")
    call CreateUnitAtLoc(Player(10), 'n001', SpawnLoc, bj_UNIT_FACING)
    call IssuePointOrderLoc(GetLastCreatedUnit(), "attack", SendLoc)
    call TriggerSleepAction(w)
    call CreateUnitAtLoc(Player(10), 'n001', SpawnLoc, bj_UNIT_FACING)
    call IssuePointOrderLoc(GetLastCreatedUnit(), "attack", SendLoc)
    call TriggerSleepAction(w)
    call CreateUnitAtLoc(Player(10), 'n002', SpawnLoc, bj_UNIT_FACING)
    call IssuePointOrderLoc(GetLastCreatedUnit(), "attack", SendLoc)
    call TriggerSleepAction(w)
    call CreateUnitAtLoc(Player(10), 'n007', SpawnLoc, bj_UNIT_FACING)
    call IssuePointOrderLoc(GetLastCreatedUnit(), "attack", SendLoc)
    call RemoveLocation(SpawnLoc)
    call RemoveLocation(SendLoc)
    set SpawnLoc = null
    set SendLoc = null
endfunction

private function InitSpawnL1 takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterTimerEvent(t, 30, true)
    call TriggerAddAction(t, function Actions)
endfunction

endscope
 

saw792

Is known to say things. That is all.
Reaction score
280
The thread is ending because ExtraWave is uninitialised when you compare it to 3.
 

Naga'sShadow

Ultra Cool Member
Reaction score
49
Ok... I didn't set it to one because I was afraid the trigger would do that every time

It will, extrawave probably should be a global so you can call it in the function but not alter it between waves. As it is it's recreated every 30 seconds, and will never be higher than 1.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top