Spawn Triggers With Rally Points

Status
Not open for further replies.
Level 3
Joined
Apr 25, 2013
Messages
38
So I'm finally in the 'clean up' phase of my maps production and that involves among other things deleaking the map as much as possible. I'm starting with the Spawn Triggers as I'm sure that is the biggest source of leaks in the map so far. I have made it where the Spawn Building's Rally Point also works for the Spawned Units. I was curious if that function would leak as well and thus would require its own removal?

rXg9LZ5.jpg


Edit: Just for reference I spam a bunch of A's in front of a variable I want at the top of the list! And I also updated the actual location of the unit spawn to be the variable after this screenshot but still am curious about the rally point reference!
 
You can just use [TRIGGER][/TRIGGER] tags the next time you post code. They're a lot easier than taking a screenshot.

Anyway, you are technically removing leaks, but you still leak. Why you might ask? Well, you aren't even using the variables you stored the location into. Also, you don't have to create a create/remove locations if they are still the same one. You can easily just store (Center of Spawn Barad Eithel <gen>) at the beginning, and remove once at the end.

  • Example:
    • Set SpawnPoint = (Center of Spawn Barad Eithel)
    • Unit - Create 1 Hithlum for Player 1 (Red) at (Center of Spawn Barad Eithel <gen>) facing Default building facing degrees
    • Custom script: call RemoveLocation(udg_SpawnPoint)
    You're creating a NEW location with (Center of Spawn Barad Eithel <gen>). It should be:
    • Set SpawnPoint = (Center of Spawn Barad Eithel)
    • Unit - Create 1 Hithlum for Player 1 (Red) at SpawnPoint facing Default building facing degrees
    • Custom script: call RemoveLocation(udg_SpawnPoint)
  • Like I said above, if you're reusing the location, you don't have to keep creating and removing the location if they are the same. You ONLY have to remove a location if you're overwriting it with something new. Example:
    • Set SpawnPoint = (Center of (Playable map area))
    • Unit - Create 1 Hithlum for Player 1 (Red) at SpawnPoint facing Default building facing degrees
    • Unit - Order (Last created unit) to attack move to SpawnPoint
    • Custom script: call RemoveLocation(udg_SpawnPoint)
    • Set SpawnPoint = (Center of Region01 <gen>)
    • Unit - Create 1 Hithlum for Player 1 (Red) at SpawnPoint facing Default building facing degrees
    • Custom script: call RemoveLocatioon(udg_SpawnPoint)
    Do you see how I used SpawnPoint twice before actually removing it once? I only removed it because i had to store a different location into SpawnPoint. Overwriting it without removing the original reference is what causes the leak.

With all that in mind, this is how your trigger SHOULD look:
  • Set SpawnPoint = (Center of Spawn Barad Eithel <gen>)
  • Set TempPoint = (Center of Barad Eithel (Spawn) 0013 <gen>)
  • For each (Integer A) from 1 to 3, do (Actions)
    • Loop - Actions
      • Unit - Create 1 Hithlum Swordsman for Player 1 (Red) at SpawnPoint facing Default building facing degrees
      • Unit - Order (Last created unit) to Attack-Move to TempPoint
  • Custom script: call RemoveLocation(udg_SpawnPoint)
  • Custom script: call RemoveLocation(udg_TempPoint)
 
Last edited:
Level 3
Joined
Apr 25, 2013
Messages
38
Thanks again! I'm just curious your 'Order' line has a '?' is that different from the 'Unit - Order' line I'm using? Mine still has same unit icon as the 'Unit - Create' function. Unfortunately, I'm going out of town tomorrow so will make and post the corrections Sunday. I have a couple IF conditions that use a different spawn location each in spawn trigger for the cavalry units. Let's see if I can take what I've learned and 1 shot it. :)
 
Level 3
Joined
Apr 25, 2013
Messages
38
  • Set AAAAAASpawnPoint = (Center of Spawn Barad Eithel <gen>)
  • Set AAAAAAAttackMovePoint = (Center of A Doors of Night Base <gen>)
  • Unit - Create 1 Hithlum Swordsman (Hithlum) for Player 1 (Red) at AAAAAASpawnPoint facing Default building facing (270.0) degrees
  • Unit - Order (Last created unit) to Attack-Move To AAAAAARAttackMovePoint
  • Unit - Create 1 Hithlum Swordsman (Hithlum) for Player 1 (Red) at AAAAAASpawnPoint facing Default building facing (270.0) degrees
  • Unit - Order (Last created unit) to Attack-Move To AAAAAARAttackMovePoint
  • Unit - Create 1 Hithlum Archer (Hithlum) for Player 1 (Red) at AAAAAASpawnPoint facing Default building facing (270.0) degrees
  • Unit - Order (Last created unit) to Attack-Move To AAAAAARAttackMovePoint
  • Custom script: call RemoveLocation (udg_AAAAAASpawnPoint)
    • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • CastleLevel[1] Greater than or equal to (>=) 1
      • Then - Actions
        • Set AAAAAASpawnPoint = (Center of Spawn Barad Eithel <gen>)
        • Unit - Create 1 Hithlum Swordsman (Hithlum) for Player 1 (Red) at AAAAAASpawnPoint facing Default building facing (270.0) degrees
        • Custom script: call RemoveLocation (udg_AAAAAASpawnPoint)
        • Unit - Order (Last created unit) to Attack-Move To AAAAAARAttackMovePoint
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in (Units owned by Player 1 (Red) of type Hithlum Knight (Hithlum))) Less than (<) 24
            • Then - Actions
              • Set AAAAAASpawnPoint = (Center of Cavalry Red <gen>)
              • Unit - Create 1 Hithlum Knight (Hithlum) for Player 1 (Red) at AAAAAASpawnPoint facing Default building facing (270.0) degrees
              • Custom script: call RemoveLocation (udg_AAAAAASpawnPoint)
              • Unit - Order (Last created unit) to Attack-Move To AAAAAARAttackMovePoint
            • Else - Actions
      • Else - Actions
    • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • CastleLevel[1] Greater than or equal to (>=) 2
      • Then - Actions
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Number of units in (Units owned by Player 1 (Red) of type Hithlum Knight (Hithlum))) Less than (<) 24
          • Then - Actions
            • Set AAAAAASpawnPoint = (Center of Cavalry Red <gen>)
            • Unit - Create 1 Hithlum Knight (Hithlum) for Player 1 (Red) at AAAAAASpawnPoint facing Default building facing (270.0) degrees
            • Custom script: call RemoveLocation (udg_AAAAAASpawnPoint)
            • Unit - Order (Last created unit) to Attack-Move To AAAAAARAttackMovePoint
          • Else - Actions
        • Set AAAAAASpawnPoint = (Center of Spawn Barad Eithel <gen>)
        • Unit - Create 1 Hithlum Archer (Hithlum) for Player 1 (Red) at AAAAAASpawnPoint facing Default building facing (270.0) degrees
        • Custom script: call RemoveLocation (udg_AAAAAASpawnPoint)
        • Unit - Order (Last created unit) to Attack-Move To AAAAAARAttackMovePoint
      • Else - Actions
    • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • CastleLevel[1] Greater than or equal to (>=) 3
      • Then - Actions
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Number of units in (Units owned by Player 1 (Red) of type Hithlum Legionaire (Hithlum))) Less than (<) 12
          • Then - Actions
            • Set AAAAAASpawnPoint = (Center of Spawn Barad Eithel <gen>)
            • Unit - Create 1 Hithlum Legionaire (Hithlum) for Player 1 (Red) at AAAAAASpawnPoint facing Default building facing (270.0) degrees
            • Custom script: call RemoveLocation (udg_AAAAAASpawnPoint)
            • Unit - Order (Last created unit) to Attack-Move To AAAAAARAttackMovePoint
          • Else - Actions
      • Else - Actions
  • Custom script: call RemoveLocation (udg_AAAAAAAttackMovePoint)
So, because I have the cavalry spawn at a different location I create and remove the reference at each point. I could break the Cavalry off to a separate trigger if that would be more efficient. I also noticed you looped the swordsman spawn. So I still have that to do. Let me know if I should break the cavalry off in to a separate trigger.
 
Last edited:
I'd only recommend splitting the triggers if they have different events. On a side note:
  • In Then - Actions where you check if CastleLevel[1] Greater than or equal to 1, you set SpawnPoint to (Center of Spawn Barad Eithel). That is still the same reference to your first SpawnPoint, so there is no need to remove and set it again. Like I said before, you only need to use call RemoveLocation() if you are going to overwrite the previous reference to a new one.
  • From the looks of it, you can simplify your multiple If/Then/Else statements to something like this:
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • CastleLevel[1] Greater than or equal to 1
      • Then - Actions
        • Unit - Create CastleLeve[1] Hithlum Knight (Hithlum) for Player 1 (Red) at SpawnPoint facing Default building facing degrees
        • Unit - Order (Last created unit) to Attack-Move To AttackMovePoint
      • Else - Actions
 
Level 3
Joined
Apr 25, 2013
Messages
38
What about this? I made a separate variable for the Cavalry Location. Initialize it in the beginning, remove it at the end irregardless of spawn levels.

  • Set AAAAAASpawnPoint = (Center of Spawn Barad Eithel <gen>)
  • Set AAAAAACalvSpawnPoint = (Center of Cavalry Red <gen>)
  • Set AAAAAAAttackMovePoint = (Rally-Point of Barad Eithel (Spawn) 0013 <gen> as a point)
  • Unit - Create 1 Hithlum Swordsman (Hithlum) for Player 1 (Red) at AAAAAASpawnPoint facing Default building facing (270.0) degrees
  • Unit - Order (Last created unit) to Attack-Move To AAAAAAAttackMovePoint
  • Unit - Create 1 Hithlum Swordsman (Hithlum) for Player 1 (Red) at AAAAAASpawnPoint facing Default building facing (270.0) degrees
  • Unit - Order (Last created unit) to Attack-Move To AAAAAAAttackMovePoint
  • Unit - Create 1 Hithlum Archer (Hithlum) for Player 1 (Red) at AAAAAASpawnPoint facing Default building facing (270.0) degrees
  • Unit - Order (Last created unit) to Attack-Move To AAAAAAAttackMovePoint
    • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • CastleLevel[1] Greater than or equal to (>=) 1
      • Then - Actions
        • Unit - Create 1 Hithlum Swordsman (Hithlum) for Player 1 (Red) at AAAAAASpawnPoint facing Default building facing (270.0) degrees
        • Unit - Order (Last created unit) to Attack-Move To AAAAAAAttackMovePoint
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in (Units owned by Player 1 (Red) of type Hithlum Knight (Hithlum))) Less than (<) 24
            • Then - Actions
              • Unit - Create 1 Hithlum Knight (Hithlum) for Player 1 (Red) at AAAAAACalvSpawnPoint facing Default building facing (270.0) degrees
              • Unit - Order (Last created unit) to Attack-Move To AAAAAAAttackMovePoint
            • Else - Actions
      • Else - Actions
    • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • CastleLevel[1] Greater than or equal to (>=) 2
      • Then - Actions
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Number of units in (Units owned by Player 1 (Red) of type Hithlum Knight (Hithlum))) Less than (<) 24
          • Then - Actions
            • Unit - Create 1 Hithlum Knight (Hithlum) for Player 1 (Red) at AAAAAACalvSpawnPoint facing Default building facing (270.0) degrees
            • Unit - Order (Last created unit) to Attack-Move To AAAAAAAttackMovePoint
          • Else - Actions
        • Unit - Create 1 Hithlum Archer (Hithlum) for Player 1 (Red) at AAAAAASpawnPoint facing Default building facing (270.0) degrees
        • Unit - Order (Last created unit) to Attack-Move To AAAAAAAttackMovePoint
      • Else - Actions
    • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • CastleLevel[1] Greater than or equal to (>=) 3
      • Then - Actions
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Number of units in (Units owned by Player 1 (Red) of type Hithlum Legionaire (Hithlum))) Less than (<) 12
          • Then - Actions
            • Unit - Create 1 Hithlum Legionaire (Hithlum) for Player 1 (Red) at AAAAAASpawnPoint facing Default building facing (270.0) degrees
            • Unit - Order (Last created unit) to Attack-Move To AAAAAAAttackMovePoint
          • Else - Actions
      • Else - Actions
  • Custom script: call RemoveLocation (udg_AAAAAASpawnPoint)
  • Custom script: call RemoveLocation (udg_AAAAAACalvSpawnPoint)
  • Custom script: call RemoveLocation (udg_AAAAAAAttackMovePoint)
I was thinking about spacing out the spawn triggers by a second or half second to lessen the unit spawn impact. Any feedback on that? There are 8 players so I could do 1 player on each team spaced out by 1 second so 30 units max spawn over 4 seconds instead of 120 at once (When spawns are fully maxed).
 
It looks good, but you still leak some unit groups and it can easily be condesed.

The unit group leaks are found in some of your condition statements. Here's an example:
  • (Number of units in (Units owned by Player 1 (Red) of type Hithlum Legionaire (Hithlum))) Less than (<) 12
The function creates a unit group.

I believe you can condense all the If/Then/Else functions, I just need to get a better understanding of what this trigger does. From first look, this is what I think it does:
  • Always creates 2 swordsman and 1 archer
  • When CastleLevel[1] is Greater than or equal to 1: Create 1 extra swordsman. If the number of Hithlum Knights are less than 24, create 1 knight.
  • When CastleLevel[1] is Greater than or equal to 2: Create 1 extra swordsman and 1 extra archer. If the number of Hithlum Knights are less than 24, create 2 knights.
  • When CastleLevel[1] is Greater than or equal to 3: Create 1 extra swordsman, 1 extra archer. If the number of Hithlum Knights are less than 24, create 2 knights. If the number of Legionaires are less than 12, create 1 Legionaire.

On a side note, can CastleLevel[1] ever be less than one?
 
Level 3
Joined
Apr 25, 2013
Messages
38
It looks good, but you still leak some unit groups and it can easily be condesed.

The unit group leaks are found in some of your condition statements. Here's an example:
  • (Number of units in (Units owned by Player 1 (Red) of type Hithlum Legionaire (Hithlum))) Less than (<) 12
The function creates a unit group.

I believe you can condense all the If/Then/Else functions, I just need to get a better understanding of what this trigger does. From first look, this is what I think it does:
  • Always creates 2 swordsman and 1 archer
  • When CastleLevel[1] is Greater than or equal to 1: Create 1 extra swordsman. If the number of Hithlum Knights are less than 24, create 1 knight.
  • When CastleLevel[1] is Greater than or equal to 2: Create 1 extra swordsman and 1 extra archer. If the number of Hithlum Knights are less than 24, create 2 knights.
  • When CastleLevel[1] is Greater than or equal to 3: Create 1 extra swordsman, 1 extra archer. If the number of Hithlum Knights are less than 24, create 2 knights. If the number of Legionaires are less than 12, create 1 Legionaire.

On a side note, can CastleLevel[1] ever be less than one?

Yes, players start at 0. In most spawn based maps to improve spawns you build a castle or barracks at a spawn. In this its an actual upgrade that has 3 levels -- the upgrade among other things sets the castle level. There is a Limit on Cavalry and Legionaries. In some other spawn based maps I've work on there is a whole set of create unit functions for each castle level. In this I tried making it progressive as the spawn improves. Also then can the unit group leak be removed as well to fully de leak the trigger?
 
Also then can the unit group leak be removed as well to fully de leak the trigger?
Yes, but you have to be careful with the "unit-type" filter. The function you're using in your conditional statements has a reference leak that can't be removed via GUI
JASS:
function GetUnitsOfTypeIdAll takes integer unitid returns group
    local group   result = CreateGroup()
    local group   g      = CreateGroup()
    local integer index

    set index = 0
    loop
        set bj_groupEnumTypeId = unitid
        call GroupClear(g)
        call GroupEnumUnitsOfPlayer(g, Player(index), filterGetUnitsOfTypeIdAll)
        call GroupAddGroup(g, result)

        set index = index + 1
        exitwhen index == bj_MAX_PLAYER_SLOTS
    endloop
    call DestroyGroup(g) //<-- should be nulled as well 

    return result
endfunction

There are plenty more functions in GUI that do the same thing. My work around this one specifically is something like this:
  • Custom script: set bj_wantDestroyGroup = true
  • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
    • Loop - Actions
      • Set TempUnit = (Picked unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of TempUnit) Equal to Hithlum Legionaire
        • Then - Actions
          • -------- TempUnit passed Unit-type filter, do actions --------
        • Else - Actions
          • -------- TempUnit failed Unit-type filter, do nothing --------
 
Last edited:
Status
Not open for further replies.
Top