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

problem, please help

Status
Not open for further replies.
Level 2
Joined
Jun 16, 2009
Messages
11
Event-
Time-Every 45 seconds of game time.
Conditions-
Actions-
Unit - Create 4 Footman for Player 10 (Light Blue) at (Center of Lakeshire to Redridge Bluff <gen>) facing Default building facing degrees
Unit Group - Order (Units owned by Player 10 (Light Blue)) to Attack-Move To (Center of Battlefield Redridge Bluff <gen>)


What is wrong here?
 
Level 4
Joined
Aug 9, 2005
Messages
76
  • Untitled Trigger 001
    • Events
      • Time - Every 45.00 seconds of game time
    • Conditions
    • Actions
      • Unit - Create 4 Footman for Player 10 (Light Blue) at (Center of (your region)) facing Default building facing degrees
      • Unit Group - Pick every unit in (Units in (your region)) and do (Actions)
        • Loop - Actions
          • Unit - Order (Picked unit) to Attack-Move To (another region))
 
Level 8
Joined
Aug 4, 2006
Messages
357
This way is better:
  • Untitled Trigger 001
    • Events
      • Time - Every 45.00 seconds of game time
    • Conditions
    • Actions
      • Unit - Create 4 Footman for Player 10 (Light Blue) at (Center of Lakeshire to Redridge Bluff <gen>) facing Default building facing degrees
      • Unit Group - Pick every unit in (Last created unit group) and do (Actions)
        • Loop - Actions
          • Unit - Order (Picked unit) to Attack-Move To (Center of Battlefield Redridge Bluff <gen>)
      • Custom script: call DestroyGroup( bj_lastCreatedGroup )
When you create a bunch of units, it automatically stores them in (Last created unit group). So, we can order all of the units that were just created to do stuff by using this unit group. The custom script destroys (Last created unit group) after we are done using it so that it won't leak. I wouldn't worry too much about leaks for now.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Now we're busy removing leaks, why not remove the location leaks as well? :D

  • Untitled Trigger 001
  • Events
    • Time - Every 45.00 seconds of game time
  • Conditions
  • Actions
    • Set Loc[1] = Center of Lakeshire to Redridge Bluff <gen>
    • Unit - Create 4 Footman for Player 10 (Light Blue) at Loc[1] facing Default building facing degrees
    • Set Loc[1] = Center of Battlefield Redridge Bluff <gen>
    • Set Group = (Units owned by Player 10 (Light Blue))
    • Unit Group - Pick every unit in Group and do (Actions)
      • Loop - Actions
        • Unit - Order (Picked unit) to Attack-Move To Loc[1]
    • Custom script: call DestroyGroup(udg_Group)
    • Custom script: call RemoveLocation(udg_Loc[1])
That should do it...
 
Level 8
Joined
Aug 4, 2006
Messages
357
@ap0calypse: Ha, I completely forgot about the location leaks...
By the way, your trigger does the exact same thing as Nugsofwar's trigger, but removes some leaks. Nugsofwar indicated that his trigger doesn't work right, so yours wouldn't work right either. You also forgot to remove the location leak for (Center of Lakeshire...).

@Nugsofwar: I assume you only want to change the orders of the units you just created. If that is true, use this trigger:
  • Untitled Trigger 001
    • Events
      • Time - Every 45.00 seconds of game time
    • Conditions
    • Actions
      • Set tempPoint = (Center of Lakeshire to Redridge Bluff <gen>)
      • Unit - Create 4 Footman for Player 10 (Light Blue) at tempPoint facing Default building facing degrees
      • Custom script: call RemoveLocation(udg_tempPoint)
      • Set tempPoint = (Center of Battlefield Redridge Bluff <gen>)
      • Unit Group - Pick every unit in (Last created unit group) and do (Actions)
        • Loop - Actions
          • Unit - Order (Picked unit) to Attack-Move To tempPoint
      • Custom script: call RemoveLocation(udg_tempPoint)
      • Custom script: call DestroyGroup(bj_lastCreatedGroup)
It should work perfectly and should not leak. You need to create a point variable called "tempPoint".
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
@ap0calypse: Ha, I completely forgot about the location leaks...
By the way, your trigger does the exact same thing as Nugsofwar's trigger, but removes some leaks. Nugsofwar indicated that his trigger doesn't work right, so yours wouldn't work right either. You also forgot to remove the location leak for (Center of Lakeshire...).

@Nugsofwar: I assume you only want to change the orders of the units you just created. If that is true, use this trigger:
  • Untitled Trigger 001
    • Events
      • Time - Every 45.00 seconds of game time
    • Conditions
    • Actions
      • Set tempPoint = (Center of Lakeshire to Redridge Bluff <gen>)
      • Unit - Create 4 Footman for Player 10 (Light Blue) at tempPoint facing Default building facing degrees
      • Custom script: call RemoveLocation(udg_tempPoint)
      • Set tempPoint = (Center of Battlefield Redridge Bluff <gen>)
      • Unit Group - Pick every unit in (Last created unit group) and do (Actions)
        • Loop - Actions
          • Unit - Order (Picked unit) to Attack-Move To tempPoint
      • Custom script: call RemoveLocation(udg_tempPoint)
      • Custom script: call DestroyGroup(bj_lastCreatedGroup)
It should work perfectly and should not leak. You need to create a point variable called "tempPoint".

I didn't use the exact same trigger: I have changed the unit group, since "pick every unit in (last created unit group)" would seriously bug.
And I did fix all location leaks, according to me... I might be wrong though, but if you can point out my mistake... :s (no, I didn't edit my post -.-).
 
Level 8
Joined
Aug 4, 2006
Messages
357
I didn't use the exact same trigger: I have changed the unit group, since "pick every unit in (last created unit group)" would seriously bug.
I meant you're doing the same thing as the original poster, but you're also removing leaks. The original poster did pick every unit owned by player 10, and so are you.
Uh I don't think "pick every unit in (last created unit group)" would bug. "Create 4 footmen for Player..." is this BJ function:
JASS:
function CreateNUnitsAtLoc takes integer count, integer unitId, player whichPlayer, location loc, real face returns group
    call GroupClear(bj_lastCreatedGroup)
    loop
        set count = count - 1
        exitwhen count < 0
        call CreateUnitAtLocSaveLast(whichPlayer, unitId, loc, face)
        call GroupAddUnit(bj_lastCreatedGroup, bj_lastCreatedUnit)
    endloop
    return bj_lastCreatedGroup
endfunction
As you can see, it automatically puts the created units in "bj_lastCreatedGroup" which == "(last created unit group)". I realize that it is a global variable, but since there are no waits between "Create 4 Footmen..." and "Unit Group - pick every unit...", it is not possible for the group to get set to something else between those two functions.

ap0calypse said:
And I did fix all location leaks, according to me... I might be wrong though, but if you can point out my mistake... :s (no, I didn't edit my post -.-).
Lol, okay. I'll show you where you leak:
  • Set Loc[1] = Center of Lakeshire to Redridge Bluff <gen>
  • Unit - Create 4 Footman for Player 10 (Light Blue) at Loc[1] facing Default building facing degrees
  • Set Loc[1] = Center of Battlefield Redridge Bluff <gen>
Do you see the leak? Remember that location variables are pointers to actual locations. Let me tell you what is going on behind the scenes.
First line: you create a location at the center of lakeshire to redridge bluff. You set Loc[1] to point at this location.
Second line: you create four units at the location that Loc[1] is pointing to.
Third line: you create a location at the center of battlefield redridge bluff. You set Loc[1] to point at this location. The problem is that the original location (Center of Lakeshire to Redridge Bluff <gen>) still exists but no longer has any variables pointing to it, so it leaks.

Solution:
  • Set Loc[1] = Center of Lakeshire to Redridge Bluff <gen>
  • Unit - Create 4 Footman for Player 10 (Light Blue) at Loc[1] facing Default building facing degrees
  • Custom script: call RemoveLocation(udg_Loc[1])
  • Set Loc[1] = Center of Battlefield Redridge Bluff <gen>
Now you destroy the old location before resetting the variable so the old location doesn't leak. :D
 
Status
Not open for further replies.
Top