• 🏆 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!

[Trigger] Improving waypoint move trigger & leak

Status
Not open for further replies.
Level 2
Joined
Jul 9, 2011
Messages
10
hi, i am having trouble with my waypoint trigger
it orders units that reach their WP to move to the next one
and units that are stopped to move again

the problems:
it is verry ineficient, when the number of units it checks is above 100 the games performance decreases
another thing is the leaks with location when(i think its here) Unit_Rally_Point is set to the next waypoint. if i try to remove the location all other units that are moving to the same WP have the location removed also and stop. i added a comment where i put the RemoveLocation

i'm using the original world editor, but you can suggest JASS, i don't know JASS if needed i can look into it

  • Waypoint Move
    • Events
    • Conditions
    • Actions
      • Set i_Wave_Created = i_Wave_Creating
      • For each (Integer For_West[0]) from 0 to i_Wave_Created, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit_Array[For_West[0]] is alive) Equal to True
            • Then - Actions
              • Set Temp_Pos = (Position of Unit_Array[For_West[0]])
              • Set Unit_Distance_Array[For_West[0]] = (Distance between Temp_Pos and Unit_Rally_Point[For_West[0]])
              • Custom script: call RemoveLocation(udg_Temp_Pos)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Unit_Distance_Array[For_West[0]] Less than 200.00
                • Then - Actions
                  • If (Unit_Current_Waypoint[For_West[0]] Greater than 87) then do (Unit - Remove (Triggering unit) from the game) else do (Do nothing)
                  • Set Unit_Current_Waypoint[For_West[0]] = (Unit_Current_Waypoint[For_West[0]] + 8)
                  • -------- Custom script: call RemoveLocation( udg_Unit_Rally_Point[udg_For_West[0]] ) --------
                  • Set Temp_Pos = (Position of Unit_Array[For_West[0]])
                  • Set Unit_Rally_Point[For_West[0]] = Waypoints[Unit_Current_Waypoint[For_West[0]]]
                  • Set Unit_Distance_Array[For_West[0]] = (Distance between Temp_Pos and Unit_Rally_Point[For_West[0]])
                  • Custom script: call RemoveLocation(udg_Temp_Pos)
                  • Unit - Order Unit_Array[For_West[0]] to Move To Unit_Rally_Point[For_West[0]]
                • Else - Actions
            • Else - Actions
      • Wait 0.10 seconds
      • For each (Integer For_West[0]) from 0 to i_Wave_Created, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit_Array[For_West[0]] is alive) Equal to True
            • Then - Actions
              • If (Unit_Current_Waypoint[For_West[0]] Greater than 87) then do (Unit - Remove (Triggering unit) from the game) else do (Do nothing)
              • Set Temp_Pos = (Position of Unit_Array[For_West[0]])
              • Set Unit_Distance_Array2[For_West[0]] = (Distance between Temp_Pos and Unit_Rally_Point[For_West[0]])
              • Custom script: call RemoveLocation(udg_Temp_Pos)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Unit_Distance_Array2[For_West[0]] Less than 200.00
                • Then - Actions
                  • If (Unit_Current_Waypoint[For_West[0]] Greater than 87) then do (Unit - Remove (Triggering unit) from the game) else do (Do nothing)
                  • Set Unit_Current_Waypoint[For_West[0]] = (Unit_Current_Waypoint[For_West[0]] + 8)
                  • -------- Custom script: call RemoveLocation( udg_Unit_Rally_Point[udg_For_West[0]] ) --------
                  • Set Temp_Pos = (Position of Unit_Array[For_West[0]])
                  • Set Unit_Rally_Point[For_West[0]] = Waypoints[Unit_Current_Waypoint[For_West[0]]]
                  • Set Unit_Distance_Array2[For_West[0]] = (Distance between Temp_Pos and Unit_Rally_Point[For_West[0]])
                  • Custom script: call RemoveLocation(udg_Temp_Pos)
                  • Unit - Order Unit_Array[For_West[0]] to Move To Unit_Rally_Point[For_West[0]]
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Unit_Distance_Array[For_West[0]] Equal to Unit_Distance_Array2[For_West[0]]
                    • Then - Actions
                      • Unit - Order Unit_Array[For_West[0]] to Move To Unit_Rally_Point[For_West[0]]
                    • Else - Actions
            • Else - Actions
      • Trigger - Remove (This trigger) from the trigger queue
edit: added hidden tag for a cleaner post
 
Last edited:
Level 2
Joined
Jul 9, 2011
Messages
10
Edit once again: Unt_Array is like a simple index system
Unit_Array is an array with all the units created, when the unit is added to the game it is also added to the Unit_Array. the Unit_Rally_Point is a point array variable with the current destination of that unit, it is first set when the unit is created. units are always on the same position in any array variables used.

  • Events
    • Map initialization
  • Set WavesCooldown[0] = 1.00
  • Set WavesAmmount[0] = 20
  • Set CreepsAmmount[0] = 1
  • Set Creeps[0] = 0. TestUnit
  • Set Point_Center = (Center of (Playable map area))
  • Set Waypoints[4] = (Point_Center offset by (-3750.00, 0.00))
  • Set Spawn_Points[0] = (Point_Center offset by (350.00, 0.00))

  • Trigger Control
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Count non-structure units controlled by Player 12 (Brown) (Exclude incomplete units)) Greater than 0
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Waypoint Move <gen> is queued) Equal to False
            • Then - Actions
              • Trigger - Add Waypoint Move <gen> to the trigger queue (Checking conditions)
            • Else - Actions
        • Else - Actions
  • Waves 0 to 3
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
      • (Count non-structure units controlled by Player 12 (Brown) (Exclude incomplete units)) Less than 1
      • Level Less than or equal to 3
    • Actions
      • Set i_Wave_Creating = 0
      • For each (Integer i_Waves[0]) from 1 to WavesAmmount[Level], do (Actions)
        • Loop - Actions
          • For each (Integer i_Waves[1]) from 1 to CreepsAmmount[Level], do (Actions)
            • Loop - Actions
              • -------- Wave North South --------
              • -------- actualy when Player 3 is in game --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Player 1 (Red) slot status) Equal to Is playing
                • Then - Actions
                  • Unit - Create 1 Creeps[Level] for Player 12 (Brown) at Spawn_Points[1] facing 90.00 degrees
                  • Set Unit_Array[i_Wave_Creating] = (Last created unit)
                  • Set Unit_Rally_Point[i_Wave_Creating] = Waypoints[2]
                  • Set Unit_Current_Waypoint[i_Wave_Creating] = 2
                  • Set i_Wave_Creating = (i_Wave_Creating + 1)
                • Else - Actions
              • -------- Wave North West --------
              • -------- actualy when Player 4 is in game --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Player 1 (Red) slot status) Equal to Is playing
                • Then - Actions
                  • Unit - Create 1 Creeps[Level] for Player 12 (Brown) at Spawn_Points[1] facing 90.00 degrees
                  • Set Unit_Array[i_Wave_Creating] = (Last created unit)
                  • Set Unit_Rally_Point[i_Wave_Creating] = Waypoints[3]
                  • Set Unit_Current_Waypoint[i_Wave_Creating] = 3
                  • Set i_Wave_Creating = (i_Wave_Creating + 1)
                • Else - Actions
              • -------- Wave West South --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Player 1 (Red) slot status) Equal to Is playing
                • Then - Actions
                  • Unit - Create 1 Creeps[Level] for Player 12 (Brown) at Spawn_Points[2] facing 180.00 degrees
                  • Set Unit_Array[i_Wave_Creating] = (Last created unit)
                  • Set Unit_Rally_Point[i_Wave_Creating] = Waypoints[5]
                  • Set Unit_Current_Waypoint[i_Wave_Creating] = 5
                  • Set i_Wave_Creating = (i_Wave_Creating + 1)
                • Else - Actions
              • -------- Wave West North --------
              • -------- actualy when Player 2 is in game --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Player 2 (Blue) slot status) Equal to Is playing
                • Then - Actions
                  • Unit - Create 1 Creeps[Level] for Player 12 (Brown) at Spawn_Points[2] facing 180.00 degrees
                  • Set Unit_Array[i_Wave_Creating] = (Last created unit)
                  • Set Unit_Rally_Point[i_Wave_Creating] = Waypoints[4]
                  • Set Unit_Current_Waypoint[i_Wave_Creating] = 4
                  • Set i_Wave_Creating = (i_Wave_Creating + 1)
                • Else - Actions
          • Wait WavesCooldown[Level] game-time seconds
      • Set Level = (Level + 1)
edit: added hidden tags
 
Last edited:
Level 2
Joined
Jul 9, 2011
Messages
10
hello again, i have been able to improve the trigger!
i disabled the collision of all units on the wave
and i also removed array variables that did not need to be array, like the For_west int array. i changed it to a simple int and made new variables.
now the trigger can control up to 480 units without performance decrease and there are no leaks that i can detect (i made a 100 waves of 320 units and the game closed with no delay)

how do i make the thread [Solved] ?
 
Status
Not open for further replies.
Top