• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Solved] Problem with spawn and patrol trigger.

Status
Not open for further replies.
Level 4
Joined
May 14, 2013
Messages
48
  • spawn satr
    • Events
      • Time - Every 20.00 seconds of game time
    • Conditions
      • (Number of units in (Units in forest <gen>)) Less than 5
    • Actions
      • Set temp_point = (Random point in forest <gen>)
      • Unit - Create 1 Footman for Neutral Hostile at temp_point facing Default building facing degrees
      • Custom script: call RemoveLocation (udg_temp_point)
      • Set temp_point = (Random point in forest <gen>)
      • Unit - Order (Last created unit) to Patrol To temp_point
      • Custom script: call RemoveLocation (udg_temp_point)
The purpose of the trigger is to spawn units and make them patrol so they are not just standing still. Problem is they appear to patrol for only 1 round trip then they just stop. Why is this happening is it a bug with patrol or did i do this trigger wrong?
 
Level 25
Joined
May 11, 2007
Messages
4,651
Pretty sure it's because you're using the neutral hostile player.
Creeps has a radius that when they go that far, they return to their spawn position. Either modify it in the misc data tab in the Editor (where you change hero max lvl)
Or use a different player.
 
Level 4
Joined
May 14, 2013
Messages
48
Pretty sure it's because you're using the neutral hostile player.
Creeps has a radius that when they go that far, they return to their spawn position. Either modify it in the misc data tab in the Editor (where you change hero max lvl)
Or use a different player.

Problem appears to be fixed. Thank you.
 
Level 12
Joined
Mar 17, 2007
Messages
412
Problem appears to be fixed. Thank you.

Not fixed

Condition (number of units) leaks because it creates a group & therefor isn't recycled, before you know it you'll comeback asking why your map is lagging.

You're using the same variable (point) twice in 1 trigger action while it's executing this is a bad practice while it causes overwrites. Unless you're using else actions it would be fine since it's searching for a condition.
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
Not fixed
If you want to get real technical, his issue was the unit only stopping one round trip. After following LordDz's suggestion, the problem no longer occured, ergo fixed.

You're using the same variable (point) twice in 1 trigger action while it's executing this is a bad practice while it causes overwrites.
There's nothing wrong with his trigger other than the unit group leak you pointed out. He properly removes the point variable before assigning it to a new location. The only issue he needs to look out for is if he uses the same point variable in a trigger that uses A unit enters Region or A unit Is issued an order targeting a point events.
 
Level 4
Joined
May 14, 2013
Messages
48
  • spawn satr
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • Set integer = (Number of units in (Units in forest <gen> owned by Neutral Hostile))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • integer Less than or equal to 5
        • Then - Actions
          • Set temp_point = (Random point in forest <gen>)
          • Unit - Create 1 Satry for Neutral Hostile at temp_point facing Default building facing degrees
          • Custom script: call RemoveLocation (udg_temp_point)
          • Set temp_point2 = (Random point in forest <gen>)
          • Unit - Order (Last created unit) to Patrol To temp_point2
          • Custom script: call RemoveLocation (udg_temp_point2)
          • Hero - Create (Random level 1 Permanent item-type) and give it to (Last created unit)
        • Else - Actions
Thank you for pointing out the unit group problem i had no idea just requesting a number of units automatically made a unit group. Also I thought using a variable twice was fine granted it cleared first but just to be safe I updated that as well.

Does what i did solve the previous unit group leak?
Do integer variables leak? I am unsure how to remove integer values? is this necessary?

Thank you again for this information
 
Level 4
Joined
May 14, 2013
Messages
48
The "integer" variable leaks because it creates an unit-group to calculate the number of units within that group.
Setting bj_wantDestroyGroup to true will remove the leak after being used.

Is that Jass? if not how do i do that?
if it is Jass is this possible to do in Gui?
 
Level 4
Joined
May 14, 2013
Messages
48
  • spawn satr
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
      • (Number of units in (Units in forest <gen> owned by Neutral Hostile)) Less than or equal to 5
    • Actions
      • set bj_wantDestroyGroup = true
      • Set temp_point = (Random point in forest <gen>)
      • Unit - Create 1 Satry for Neutral Hostile at temp_point facing Default building facing degrees
      • Custom script: call RemoveLocation (udg_temp_point)
      • Set temp_point2 = (Random point in forest <gen>)
      • Unit - Order (Last created unit) to Patrol To temp_point2
      • Custom script: call RemoveLocation (udg_temp_point2)
      • Hero - Create (Random level 1 Permanent item-type) and give it to (Last created unit)
Alright I got this time right? No leaks?
 
Last edited:
Level 4
Joined
May 14, 2013
Messages
48
Why did you moved the condition to the "Main Conditions"? The bj_wantDestroyGroup is set to be defined before the condition happens to remove the leak after the condition is used.

  • spawn satr
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Set integer = (Number of units in (Units in forest <gen> owned by Neutral Hostile))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • integer Less than or equal to 5
        • Then - Actions
          • Set temp_point = (Random point in forest <gen>)
          • Unit - Create 1 Satry for Neutral Hostile at temp_point facing Default building facing degrees
          • Custom script: call RemoveLocation (udg_temp_point)
          • Set temp_point2 = (Random point in forest <gen>)
          • Unit - Order (Last created unit) to Patrol To temp_point2
          • Custom script: call RemoveLocation (udg_temp_point2)
          • Hero - Create (Random level 1 Permanent item-type) and give it to (Last created unit)
        • Else - Actions
so like this?
 
Level 14
Joined
Nov 30, 2013
Messages
926
  • spawn satr
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Set integer = (Number of units in (Units in forest <gen> owned by Neutral Hostile))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • integer Less than or equal to 5
        • Then - Actions
          • Set temp_point = (Random point in forest <gen>)
          • Unit - Create 1 Satry for Neutral Hostile at temp_point facing Default building facing degrees
          • Custom script: call RemoveLocation (udg_temp_point)
          • Set temp_point2 = (Random point in forest <gen>)
          • Unit - Order (Last created unit) to Patrol To temp_point2
          • Custom script: call RemoveLocation (udg_temp_point2)
          • Hero - Create (Random level 1 Permanent item-type) and give it to (Last created unit)
        • Else - Actions
so like this?
Yes. Now there's no leaks in the trigger.
 
Level 4
Joined
May 14, 2013
Messages
48
  • spawn satr Copy
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in (Units in forest <gen> owned by Neutral Hostile)) Less than or equal to 5
        • Then - Actions
          • Set temp_point = (Random point in forest <gen>)
          • Unit - Create 1 Satry for Neutral Hostile at temp_point facing Default building facing degrees
          • Custom script: call RemoveLocation (udg_temp_point)
          • Set temp_point2 = (Random point in forest <gen>)
          • Unit - Order (Last created unit) to Patrol To temp_point2
          • Custom script: call RemoveLocation (udg_temp_point2)
          • Hero - Create (Random level 1 Permanent item-type) and give it to (Last created unit)
        • Else - Actions
just so i understand the set bj_wantDestroyGroup = true correctly.

does this also work or does the set bj_wantDestroyGroup = true need to be on the same line or can be anywhere in the trigger as long as its before the group needed to be destroyed.
 
Level 14
Joined
Nov 30, 2013
Messages
926
  • spawn satr Copy
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in (Units in forest <gen> owned by Neutral Hostile)) Less than or equal to 5
        • Then - Actions
          • Set temp_point = (Random point in forest <gen>)
          • Unit - Create 1 Satry for Neutral Hostile at temp_point facing Default building facing degrees
          • Custom script: call RemoveLocation (udg_temp_point)
          • Set temp_point2 = (Random point in forest <gen>)
          • Unit - Order (Last created unit) to Patrol To temp_point2
          • Custom script: call RemoveLocation (udg_temp_point2)
          • Hero - Create (Random level 1 Permanent item-type) and give it to (Last created unit)
        • Else - Actions
just so i understand the set bj_wantDestroyGroup = true correctly.

does this also work or does the set bj_wantDestroyGroup = true need to be on the same line or can be anywhere in the trigger as long as its before the group needed to be destroyed.
That can work as well. Since bj_wantDestroyGroup is a global variable, it can be anywhere and it can able to destroy unit-groups as long as its value is "true".
After the unit-group with the bj_wantDestroyGroup's value is true, that group will be destroyed but the bj_wantDestroyGroup will set to false so you need to set it true again if you have multiple unit-groups in the same trigger.
 
Status
Not open for further replies.
Top