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

Question about TempPoint

Status
Not open for further replies.
Level 8
Joined
Jul 17, 2004
Messages
283
If I make a variable for TempPoint at position of unit, can I use this in any trigger if it's an instant trigger, while other units are referencing that variable too at the same time in other triggers?

So, for example:

Set TempPoint = (Position of (Triggering unit))
Unit - Move (Picked unit) instantly to TempPoint

Can I use the TempPoint variable at the same time as other triggers referencing it as long as the triggers are instant without Waits? It wouldn't break, right?
 
Level 8
Joined
Jul 17, 2004
Messages
283
Here are my triggers. What is leaking, and what are the custom scripts for removing what's leaking?

  • Change Job to Knight
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Knight
      • (Owner of (Triggering unit)) Equal to Player 1 (Red)
      • (Triggering unit) Equal to SoldierRED[1]
    • Actions
      • Set TempPoint = (Position of (Triggering unit))
      • Unit - Move (Triggering unit) instantly to (Center of JOBS RED GROUP1 <gen>), facing 270.00 degrees
      • Unit Group - Pick every unit in (Units in JOBS RED GROUP1 <gen> matching ((Unit-type of (Matching unit)) Equal to Squire)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Hero level of (Picked unit)) Equal to 2
            • Then - Actions
              • Unit Group - Pick every unit in (Units in JOBS RED GROUP1 <gen> matching ((Unit-type of (Matching unit)) Equal to Knight)) and do (Actions)
                • Loop - Actions
                  • Unit - Move (Picked unit) instantly to TempPoint, facing 270.00 degrees
                  • Set SoldierRED[1] = (Picked unit)
                  • Selection - Select (Picked unit) for (Owner of (Triggering unit))
                  • Special Effect - Create a special effect attached to the origin of (Picked unit) using Abilities\Spells\Undead\DeathPact\DeathPactTarget.mdl
                  • Special Effect - Destroy (Last created special effect)
            • Else - Actions
              • Unit - Move (Triggering unit) instantly to TempPoint, facing 270.00 degrees
              • Game - Display to (Player group((Owner of (Triggering unit)))) for 0.50 seconds the text: |cffffcc00Job Train...
  • Hire Soldier
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Hire Squire
      • (Owner of (Triggering unit)) Equal to Player 1 (Red)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SoldierRED[1] Equal to No unit
        • Then - Actions
          • Unit Group - Pick every unit in (Units in JOBS RED GROUP1 <gen> matching ((Unit-type of (Matching unit)) Equal to Squire)) and do (Actions)
            • Loop - Actions
              • Unit - Move (Picked unit) instantly to (Position of Soldier_Recruiter), facing 270.00 degrees
              • Set SoldierRED[1] = (Picked unit)
              • Special Effect - Create a special effect at (Position of (Picked unit)) using Objects\Spawnmodels\Other\ToonBoom\ToonBoom.mdl
              • Special Effect - Destroy (Last created special effect)
        • Else - Actions
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
any variable that is a temp variable can be used in any and all triggers that follow the temp variable rules.

u are leaking locations. position of leaks. u have to store it into a temp variable and use the temp variable then use custom script.
  • Custom script: call RemoveLocation( udg_tempPoint)
and u leak unit groups. if u do set tempGroup = units in range or whatever here.
use this.
  • Custom script: call DestroyGroup( udg_tempGroup)
the way u do it setting the unit group inside the unit group action put this line b4 the unit group
  • Custom script: set bj_WantDestroyGroup = true
 
Level 8
Joined
Jul 17, 2004
Messages
283
any variable that is a temp variable can be used in any and all triggers that follow the temp variable rules.

u are leaking locations. position of leaks. u have to store it into a temp variable and use the temp variable then use custom script.
  • Custom script: call RemoveLocation( udg_tempPoint)
and u leak unit groups. if u do set tempGroup = units in range or whatever here.
use this.
  • Custom script: call DestroyGroup( udg_tempGroup)
the way u do it setting the unit group inside the unit group action put this line b4 the unit group
  • Custom script: set bj_WantDestroyGroup = true

Do I need to set the unit group to a variable? Or is there a way to destroy the unit group with LastCreatedUnitGroup or something?

Also, I'm confused with what to do with 'Custom script: set bj_WantDestroyGroup = true'. Do I put that before both of the 2 unit groups?
 

Kusanagi Kuro

Hosted Project: SC
Level 10
Joined
Mar 11, 2012
Messages
708
Also, Player Group creates memory leak. To prevent that, use:
Custom script: call DestroyForce(udg_tempPlayerGroup)
Yes, u need to set the unit group to a variable.
For the second, I'm not sure but might be no.
 
Level 8
Joined
Jul 17, 2004
Messages
283
Can someone insert the custom scripts necessary for removing leaks into the triggers I put in my post? Please? I'll give rep to whoever does.
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
Do I need to set the unit group to a variable? Or is there a way to destroy the unit group with LastCreatedUnitGroup or something?

Also, I'm confused with what to do with 'Custom script: set bj_WantDestroyGroup = true'. Do I put that before both of the 2 unit groups?

this sets the unit group to be destroyed after it is done with the pick all units. this goes right above the 2 units groups and will clean the unit group leaks.
i rather set the unit group to a variable it makes it look neater but its ur choice. both ways end up doing the same thing.
 
Level 8
Joined
Jul 17, 2004
Messages
283
Also, Player Group creates memory leak. To prevent that, use:
Custom script: call DestroyForce(udg_tempPlayerGroup)
Yes, u need to set the unit group to a variable.
For the second, I'm not sure but might be no.

Where am I using a Player Group in the triggers I posted? ...

this sets the unit group to be destroyed after it is done with the pick all units. this goes right above the 2 units groups and will clean the unit group leaks.
i rather set the unit group to a variable it makes it look neater but its ur choice. both ways end up doing the same thing.

Making your adjustments to my triggers right now. Thank you for quick replies. Stay with me, I'll reply back once I'm done with the edits.
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
u should be careful about putting a unit group inside a unit group.
say the first group has 10 units and the one inside it has 10 units.
the first one will loop through 1 times ( doing actions to 10 units). the one inside it will loop through 10 times ( doing 10 actions to each unit)

also anything u use twice or more store into a temp variable and use the temp variable.
example: triggering unit should be stored.
u store picked unit in this Set SoldierRED[1] = (Picked unit)
but u never use the variable. u should use the variable in all the actions rather than the picked unit.
this is for speed and efficiency
 
Level 8
Joined
Jul 17, 2004
Messages
283
this sets the unit group to be destroyed after it is done with the pick all units. this goes right above the 2 units groups and will clean the unit group leaks.
i rather set the unit group to a variable it makes it look neater but its ur choice. both ways end up doing the same thing.

What is the custom script for removing leaks for LastCreatedUnitGroup? The one without variable.
 
Level 8
Joined
Jul 17, 2004
Messages
283
Okay, is this correct? Is it leakless now?

Also, I have my reasons for having it set up the way it is.

What do I replace 'LAST CREATED UNIT GROUP?' with?

  • Soldier 1 Knight
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Knight
      • (Owner of (Triggering unit)) Equal to Player 1 (Red)
      • (Triggering unit) Equal to SoldierRED[1]
    • Actions
      • Set TempPoint = (Position of (Triggering unit))
      • Unit - Move (Triggering unit) instantly to (Center of JOBS RED GROUP1 <gen>), facing 270.00 degrees
      • Unit Group - Pick every unit in (Units in JOBS RED GROUP1 <gen> matching ((Unit-type of (Matching unit)) Equal to Squire)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Hero level of (Picked unit)) Equal to 2
            • Then - Actions
              • Custom script: call DestroyGroup( LAST CREATED UNIT GROUP?)
              • Unit Group - Pick every unit in (Units in JOBS RED GROUP1 <gen> matching ((Unit-type of (Matching unit)) Equal to Knight)) and do (Actions)
                • Loop - Actions
                  • Unit - Move (Picked unit) instantly to TempPoint, facing 270.00 degrees
                  • Set SoldierRED[1] = (Picked unit)
                  • Selection - Select (Picked unit) for (Owner of (Triggering unit))
                  • Special Effect - Create a special effect attached to the origin of (Picked unit) using Abilities\Spells\Undead\DeathPact\DeathPactTarget.mdl
                  • Special Effect - Destroy (Last created special effect)
                  • Custom script: call DestroyGroup( LAST CREATED UNIT GROUP?)
            • Else - Actions
              • Unit - Move (Triggering unit) instantly to TempPoint, facing 270.00 degrees
              • Game - Display to (Player group((Owner of (Triggering unit)))) for 0.50 seconds the text: |cffffcc00Job Train...
      • Custom script: call RemoveLocation( udg_TempPoint)
 

Kusanagi Kuro

Hosted Project: SC
Level 10
Joined
Mar 11, 2012
Messages
708
Okay, is this correct? Is it leakless now?

Also, I have my reasons for having it set up the way it is.

What do I replace 'LAST CREATED UNIT GROUP?' with?

  • Soldier 1 Knight
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Knight
      • (Owner of (Triggering unit)) Equal to Player 1 (Red)
      • (Triggering unit) Equal to SoldierRED[1]
    • Actions
      • Set TempPoint = (Position of (Triggering unit))
      • Unit - Move (Triggering unit) instantly to (Center of JOBS RED GROUP1 <gen>), facing 270.00 degrees
      • Unit Group - Pick every unit in (Units in JOBS RED GROUP1 <gen> matching ((Unit-type of (Matching unit)) Equal to Squire)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Hero level of (Picked unit)) Equal to 2
            • Then - Actions
              • Custom script: call DestroyGroup( LAST CREATED UNIT GROUP?)
              • Unit Group - Pick every unit in (Units in JOBS RED GROUP1 <gen> matching ((Unit-type of (Matching unit)) Equal to Knight)) and do (Actions)
                • Loop - Actions
                  • Unit - Move (Picked unit) instantly to TempPoint, facing 270.00 degrees
                  • Set SoldierRED[1] = (Picked unit)
                  • Selection - Select (Picked unit) for (Owner of (Triggering unit))
                  • Special Effect - Create a special effect attached to the origin of (Picked unit) using Abilities\Spells\Undead\DeathPact\DeathPactTarget.mdl
                  • Special Effect - Destroy (Last created special effect)
                  • Custom script: call DestroyGroup( LAST CREATED UNIT GROUP?)
            • Else - Actions
              • Unit - Move (Triggering unit) instantly to TempPoint, facing 270.00 degrees
              • Game - Display to (Player group((Owner of (Triggering unit)))) for 0.50 seconds the text: |cffffcc00Job Train...
      • Custom script: call RemoveLocation( udg_TempPoint)
Too many Unit Group leaks. First is this:
  • Unit Group - Pick every unit in (Units in JOBS RED GROUP1 <gen> matching ((Unit-type of (Matching unit)) Equal to Squire)) and do (Actions)
Units in JOBS RED GROUP 1 <gen> should be placed into a variable. Then when u done, u can clear it.
Second:
  • Unit - Move (Triggering unit) instantly to (Center of JOBS RED GROUP1 <gen>), facing 270.00 degrees
Center of JOBS RED GROUP1 <gen> is a point => create leaks if u dont clean it => shoudl store in the variable.
Third:
  • Unit Group - Pick every unit in (Units in JOBS RED GROUP1 <gen> matching ((Unit-type of (Matching unit)) Equal to Knight)) and do (Actions)
Just like the first leak.
Wait for some minutes. I'll update a fixed trigger for u.
  • Soldier 1 Knight
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Knight
      • (Owner of (Triggering unit)) Equal to Player 1 (Red)
      • (Triggering unit) Equal to SoldierRED[1]
    • Actions
      • Set TempPoint = (Position of (Triggering unit))
      • Set TempPoint2 = (Center of JOBS RED GROUP1 <gen>)
      • Set TempGroup1 = (Units in JOBS RED GROUP1 <gen> matching ((Unit-type of (Matching unit)) Equal to Squire)))
      • Unit - Move (Triggering unit) instantly to TempPoint2, facing 270.00 degrees
      • Unit Group - Pick every unit in TempGroup1 and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Hero level of (Picked unit)) Equal to 2
            • Then - Actions
              • Set TempGroup2 = (Units in JOBS RED GROUP1 <gen> matching ((Unit-type of (Matching unit)) Equal to Knight))
              • Unit Group - Pick every unit in TempGroup2 and do (Actions)
                • Loop - Actions
                  • Unit - Move (Picked unit) instantly to TempPoint, facing 270.00 degrees
                  • Set SoldierRED[1] = (Picked unit)
                  • Selection - Select (Picked unit) for (Owner of (Triggering unit))
                  • Special Effect - Create a special effect attached to the origin of (Picked unit) using Abilities\Spells\Undead\DeathPact\DeathPactTarget.mdl
                  • Special Effect - Destroy (Last created special effect)
                  • Custom script: call DestroyGroup(udg_TempGroup2)
            • Else - Actions
              • Unit - Move (Triggering unit) instantly to TempPoint, facing 270.00 degrees
              • Set TempPlayerGroup = (Player group((Owner of (Triggering unit)))
              • Game - Display to TempPlayerGroup for 0.50 seconds the text: |cffffcc00Job Train...
      • Custom script: call RemoveLocation( udg_TempPoint)
      • Custom script: call RemoveLocation( udg_TempPoint2)
      • Custom script: call DestroyGroup(udg_TempGroup1)
      • Custom script: call DestroyForce(udg_TempPlayerGroup)
Done.
 
Level 8
Joined
Jul 17, 2004
Messages
283
Updated. Is my trigger leakless now?

  • Soldier 1 Knight
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Knight
      • (Owner of (Triggering unit)) Equal to Player 1 (Red)
      • (Triggering unit) Equal to SoldierRED[1]
    • Actions
      • Set TempPoint[1] = (Position of (Triggering unit))
      • Set TempPoint[2] = (Center of JOBS RED GROUP1 <gen>)
      • Set TempUnitGroup[1] = (Units in JOBS RED GROUP1 <gen> matching ((Unit-type of (Matching unit)) Equal to Squire))
      • Unit - Move (Triggering unit) instantly to TempPoint[2], facing 270.00 degrees
      • Unit Group - Pick every unit in TempUnitGroup[1] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Hero level of (Picked unit)) Equal to 2
            • Then - Actions
              • Set TempUnitGroup[2] = (Units in JOBS RED GROUP1 <gen> matching ((Unit-type of (Matching unit)) Equal to Knight))
              • Unit Group - Pick every unit in TempUnitGroup[2] and do (Actions)
                • Loop - Actions
                  • Unit - Move (Picked unit) instantly to TempPoint[1], facing 270.00 degrees
                  • Set SoldierRED[1] = (Picked unit)
                  • Selection - Select (Picked unit) for (Owner of (Triggering unit))
                  • Special Effect - Create a special effect attached to the origin of (Picked unit) using Abilities\Spells\Undead\DeathPact\DeathPactTarget.mdl
                  • Special Effect - Destroy (Last created special effect)
                  • Custom script: call DestroyGroup(udg_TempGroup[2])
            • Else - Actions
              • Unit - Move (Triggering unit) instantly to TempPoint[1], facing 270.00 degrees
              • Set TempPlayerGroup = (Player group((Owner of (Triggering unit))))
              • Game - Display to TempPlayerGroup for 0.50 seconds the text: |cffffcc00Job Train...
      • Custom script: call RemoveLocation( udg_TempPoint[1])
      • Custom script: call RemoveLocation( udg_TempPoint[2])
      • Custom script: call DestroyGroup(udg_TempGroup[1])
      • Custom script: call DestroyForce(udg_TempPlayerGroup)
 
Level 8
Joined
Jul 17, 2004
Messages
283
I've updated the trigger. U can have a look. :D
Maker: Doesnt Player Group leave memory leaks?

Just to make sure, this is good now. Right?

Also, do special effects cause leaks? Do I just use the Destroy Special Effect function to get rid of its leak?

  • Soldier 1 Knight
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Knight
      • (Owner of (Triggering unit)) Equal to Player 1 (Red)
      • (Triggering unit) Equal to SoldierRED[1]
    • Actions
      • Set TempPoint[1] = (Position of (Triggering unit))
      • Set TempPoint[2] = (Center of JOBS RED GROUP1 <gen>)
      • Set TempUnitGroup[1] = (Units in JOBS RED GROUP1 <gen> matching ((Unit-type of (Matching unit)) Equal to Squire))
      • Unit - Move (Triggering unit) instantly to TempPoint[2], facing 270.00 degrees
      • Unit Group - Pick every unit in TempUnitGroup[1] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Hero level of (Picked unit)) Equal to 2
            • Then - Actions
              • Set TempUnitGroup[2] = (Units in JOBS RED GROUP1 <gen> matching ((Unit-type of (Matching unit)) Equal to Knight))
              • Unit Group - Pick every unit in TempUnitGroup[2] and do (Actions)
                • Loop - Actions
                  • Unit - Move (Picked unit) instantly to TempPoint[1], facing 270.00 degrees
                  • Set SoldierRED[1] = (Picked unit)
                  • Selection - Select (Picked unit) for (Owner of (Triggering unit))
                  • Special Effect - Create a special effect attached to the origin of (Picked unit) using Abilities\Spells\Undead\DeathPact\DeathPactTarget.mdl
                  • Special Effect - Destroy (Last created special effect)
                  • Custom script: call DestroyGroup(udg_TempUnitGroup[2])
            • Else - Actions
              • Unit - Move (Triggering unit) instantly to TempPoint[1], facing 270.00 degrees
              • Set TempPlayerGroup = (Player group((Owner of (Triggering unit))))
              • Game - Display to TempPlayerGroup for 0.50 seconds the text: |cffffcc00Job Train...
      • Custom script: call RemoveLocation( udg_TempPoint[1])
      • Custom script: call RemoveLocation( udg_TempPoint[2])
      • Custom script: call DestroyGroup(udg_TempUnitGroup[1])
      • Custom script: call DestroyForce(udg_TempPlayerGroup)
 
Level 8
Joined
Jul 17, 2004
Messages
283
triggering unit should be stored in a temp variable and used. and picked unit should be stored into a temp variable and used.
u should also stay away from arrays with temp variables as arrays r slightly slower.

deathismyfriend, why pick picked unit and triggering unit in their own variables? What's the point of that? Those don't leak, do they? Or just because it will speed things up? But why does that even matter? It's fast enough, isn't it?
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
its for speed and efficiency.
everything is fast yes but everything should be as fast as possible.
if u code inefficiently it can lead to lag in game.
wc3 only runs one trigger at a time so if u slow down the triggers they will eventually become slow enough that it will lag.
u clean leaks because they can cause lag so y not make the rest of ur trigger efficient.
ive seen to many good games that lag or crash after an hr because of inefficient coding.

storing them into variables also makes it easier to edit later if u ever need to.

check out my tutorial things a guier should know. i explain more in there y its important to code efficiently.

also y code inefficiently when u know how to do it efficiently ?
 
Level 8
Joined
Jul 17, 2004
Messages
283
its for speed and efficiency.
everything is fast yes but everything should be as fast as possible.
if u code inefficiently it can lead to lag in game.
wc3 only runs one trigger at a time so if u slow down the triggers they will eventually become slow enough that it will lag.
u clean leaks because they can cause lag so y not make the rest of ur trigger efficient.
ive seen to many good games that lag or crash after an hr because of inefficient coding.

storing them into variables also makes it easier to edit later if u ever need to.

check out my tutorial things a guier should know. i explain more in there y its important to code efficiently.

also y code inefficiently when u know how to do it efficiently ?

Is this up to standards now?

Also, there are no leaks with the special effect are there? 'Destroy SFX' gets rid of the leak, right?

  • Soldier 1 Knight
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Knight
      • (Owner of (Triggering unit)) Equal to Player 1 (Red)
      • (Triggering unit) Equal to SoldierRED[1]
    • Actions
      • Set TempPoint1 = (Position of (Triggering unit))
      • Set TempPoint2 = (Center of JOBS RED GROUP1 <gen>)
      • Set TempUnitGroup1 = (Units in JOBS RED GROUP1 <gen> matching ((Unit-type of (Matching unit)) Equal to Squire))
      • Set TempUnit1 = (Triggering unit)
      • Unit - Move TempUnit1 instantly to TempPoint2, facing 270.00 degrees
      • Unit Group - Pick every unit in TempUnitGroup1 and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Hero level of (Picked unit)) Equal to 2
            • Then - Actions
              • Set TempUnitGroup2 = (Units in JOBS RED GROUP1 <gen> matching ((Unit-type of (Matching unit)) Equal to Knight))
              • Unit Group - Pick every unit in TempUnitGroup2 and do (Actions)
                • Loop - Actions
                  • Set TempUnit2 = (Picked unit)
                  • Unit - Move TempUnit2 instantly to TempPoint1, facing 270.00 degrees
                  • Set SoldierRED[1] = (Picked unit)
                  • Selection - Select TempUnit2 for (Owner of TempUnit1)
                  • Special Effect - Create a special effect attached to the origin of TempUnit2 using Abilities\Spells\Undead\DeathPact\DeathPactTarget.mdl
                  • Special Effect - Destroy (Last created special effect)
                  • Custom script: call DestroyGroup(udg_TempUnitGroup2)
            • Else - Actions
              • Unit - Move TempUnit1 instantly to TempPoint1, facing 270.00 degrees
              • Set TempPlayerGroup = (Player group((Owner of (Triggering unit))))
              • Game - Display to TempPlayerGroup for 0.50 seconds the text: |cffffcc00Job Train...
      • Custom script: call RemoveLocation( udg_TempPoint1)
      • Custom script: call RemoveLocation( udg_TempPoint2)
      • Custom script: call DestroyGroup(udg_TempUnitGroup1)
      • Custom script: call DestroyForce(udg_TempPlayerGroup)
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
dont destroy the group in the group loop. destroy it after.
since u set picked unit to soldierRed[1] just use that rather than another variable.

set this Set TempUnit1 = (Triggering unit)
above this
Set TempPoint1 = (Position of (Triggering unit))
and use it in the tempPoint1

use the variable down here also
Set TempPlayerGroup = (Player group((Owner of (Triggering unit))))
 
Level 8
Joined
Jul 17, 2004
Messages
283
The reason why I am destroying it inside it is because if you notice, that's a nested unit group inside another. And some times that nested one won't follow through if it doesn't meet Conditions. So if I were to put that Custom Script after, I may be destroying a unit group that isn't there. Should I still move it out like you suggested?

And, I did use that variable. 'Set TempPlayerGroup = (Player group((Owner of (Triggering unit))))'

It's being used in the Game - Display message function below it. So am I good there?

dont destroy the group in the group loop. destroy it after.
since u set picked unit to soldierRed[1] just use that rather than another variable.

set this Set TempUnit1 = (Triggering unit)
above this
Set TempPoint1 = (Position of (Triggering unit))
and use it in the tempPoint1

use the variable down here also
Set TempPlayerGroup = (Player group((Owner of (Triggering unit))))
 

Kusanagi Kuro

Hosted Project: SC
Level 10
Joined
Mar 11, 2012
Messages
708
What he mentioned is this:
  • Soldier 1 Knight
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Knight
      • (Owner of (Triggering unit)) Equal to Player 1 (Red)
      • (Triggering unit) Equal to SoldierRED[1]
    • Actions
      • Set TempPoint1 = (Position of (Triggering unit))
      • Set TempPoint2 = (Center of JOBS RED GROUP1 <gen>)
      • Set TempUnitGroup1 = (Units in JOBS RED GROUP1 <gen> matching ((Unit-type of (Matching unit)) Equal to Squire))
      • Set TempUnit1 = (Triggering unit)
      • Unit - Move TempUnit1 instantly to TempPoint2, facing 270.00 degrees
      • Unit Group - Pick every unit in TempUnitGroup1 and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Hero level of (Picked unit)) Equal to 2
            • Then - Actions
              • Set TempUnitGroup2 = (Units in JOBS RED GROUP1 <gen> matching ((Unit-type of (Matching unit)) Equal to Knight))
              • Unit Group - Pick every unit in TempUnitGroup2 and do (Actions)
                • Loop - Actions
                  • Set TempUnit2 = (Picked unit)
                  • Unit - Move TempUnit2 instantly to TempPoint1, facing 270.00 degrees
                  • Set SoldierRED[1] = (Picked unit)
                  • Selection - Select TempUnit2 for (Owner of TempUnit1)
                  • Special Effect - Create a special effect attached to the origin of TempUnit2 using Abilities\Spells\Undead\DeathPact\DeathPactTarget.mdl
                  • Special Effect - Destroy (Last created special effect)
              • Custom script: call DestroyGroup(udg_TempUnitGroup2)
            • Else - Actions
              • Unit - Move TempUnit1 instantly to TempPoint1, facing 270.00 degrees
              • Set TempPlayerGroup = (Player group((Owner of (Triggering unit))))
              • Game - Display to TempPlayerGroup for 0.50 seconds the text: |cffffcc00Job Train...
      • Custom script: call RemoveLocation( udg_TempPoint1)
      • Custom script: call RemoveLocation( udg_TempPoint2)
      • Custom script: call DestroyGroup(udg_TempUnitGroup1)
      • Custom script: call DestroyForce(udg_TempPlayerGroup)
 

Kusanagi Kuro

Hosted Project: SC
Level 10
Joined
Mar 11, 2012
Messages
708
Look a little bit carefully man ==. I place the custom script out of the unit group ==. I dont know his intension when he places the unit group inside another so i didnt do anything with it.
 
Level 8
Joined
Jul 17, 2004
Messages
283
I'm having an issue. For some reason the first unit group if/then/else is being bypassed on the first run of the trigger. Then it works after.

  • Soldier 1 Knight
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Knight
      • (Owner of (Triggering unit)) Equal to Player 1 (Red)
      • (Triggering unit) Equal to SoldierRED[1]
    • Actions
      • Set TempUnit1 = (Triggering unit)
      • Set TempPoint1 = (Position of TempUnit1)
      • Set TempPoint2 = (Center of JOBS RED GROUP1 <gen>)
      • Set TempUnitGroup1 = (Units in JOBS RED GROUP1 <gen> matching ((Unit-type of (Matching unit)) Equal to Squire))
      • Unit - Move TempUnit1 instantly to TempPoint2, facing 270.00 degrees
      • Unit Group - Pick every unit in TempUnitGroup1 and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Hero level of (Picked unit)) Less than 2
            • Then - Actions
              • Unit - Move TempUnit1 instantly to TempPoint1, facing 270.00 degrees
              • Set TempPlayerGroup = (Player group((Owner of TempUnit1)))
              • Game - Display to TempPlayerGroup for 0.50 seconds the text: |cffffcc00Job Train...
              • Skip remaining actions
            • Else - Actions
      • Set TempUnitGroup2 = (Units in JOBS RED GROUP1 <gen> matching ((Unit-type of (Matching unit)) Equal to Knight))
      • Unit Group - Pick every unit in TempUnitGroup2 and do (Actions)
        • Loop - Actions
          • Set TempUnit2 = (Picked unit)
          • Unit - Move TempUnit2 instantly to TempPoint1, facing 270.00 degrees
          • Set SoldierRED[1] = (Picked unit)
          • Selection - Select TempUnit2 for (Owner of TempUnit1)
          • Special Effect - Create a special effect attached to the origin of TempUnit2 using Abilities\Spells\Undead\DeathPact\DeathPactTarget.mdl
          • Special Effect - Destroy (Last created special effect)
      • Custom script: call RemoveLocation( udg_TempPoint1)
      • Custom script: call RemoveLocation( udg_TempPoint2)
      • Custom script: call DestroyGroup(udg_TempUnitGroup1)
      • Custom script: call DestroyGroup(udg_TempUnitGroup2)
      • Custom script: call DestroyForce(udg_TempPlayerGroup)
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
wat do u mean by bypassed ? how r u determining this ?

also change this
  • Set TempUnit2 = (Picked unit)
  • Unit - Move TempUnit2 instantly to TempPoint1, facing 270.00 degrees
  • Set SoldierRED[1] = (Picked unit)
  • Selection - Select TempUnit2 for (Owner of TempUnit1)
to this
  • Set SoldierRED[1] = (Picked unit)
  • Unit - Move SoldierRED[1] instantly to TempPoint1, facing 270.00 degrees
  • Selection - Select SoldierRED[1] for (Owner of TempUnit1)
 
Level 8
Joined
Jul 17, 2004
Messages
283
wat do u mean by bypassed ? how r u determining this ?

also change this
  • Set TempUnit2 = (Picked unit)
  • Unit - Move TempUnit2 instantly to TempPoint1, facing 270.00 degrees
  • Set SoldierRED[1] = (Picked unit)
  • Selection - Select TempUnit2 for (Owner of TempUnit1)
to this
  • Set SoldierRED[1] = (Picked unit)
  • Unit - Move SoldierRED[1] instantly to TempPoint1, facing 270.00 degrees
  • Selection - Select SoldierRED[1] for (Owner of TempUnit1)

deathismyfriend, I have to leave that variable alone. Because I need to copy and paste this for other players, and all for different job classes. It would be way too tedious to have to change that variable for each player. Just ignore that.

It's bypassing, meaning, it's ignoring the hero level requirement, and changing the unit's Job. It shouldn't be doing that. It didn't do that before.
 
Level 8
Joined
Jul 17, 2004
Messages
283
I found the issue.

For some reason it won't work with this var:
Set TempUnitGroup1 = (Units in JOBS RED GROUP1 <gen> matching ((Unit-type of (Matching unit)) Equal to Squire))

If I just add all that into the Unit Group instead of using a Var, it works. With the var, it does not. What gives?

EDIT: OH, HAHA. USER ERROR ON MY END. The unit isn't inside the region yet! I put 'Set TempUnitGroup1 = (Units in JOBS RED GROUP1 <gen> matching ((Unit-type of (Matching unit)) Equal to Squire))' below 'Unit - Move TempUnit1 instantly to TempPoint2, facing 270.00 degrees', now it works fine.

Sec, I'm going to post my trigger for final checkings. Sec.
 
Level 8
Joined
Jul 17, 2004
Messages
283
Okay, aside from what you mentioned about the SoldierRED variable, is this okay now?

  • Soldier 1 Knight
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Knight
      • (Owner of (Triggering unit)) Equal to Player 1 (Red)
      • (Triggering unit) Equal to SoldierRED[1]
    • Actions
      • Set TempUnit1 = (Triggering unit)
      • Set TempPoint1 = (Position of TempUnit1)
      • Set TempPoint2 = (Center of JOBS RED GROUP1 <gen>)
      • Unit - Move TempUnit1 instantly to TempPoint2, facing 270.00 degrees
      • Set TempUnitGroup1 = (Units in JOBS RED GROUP1 <gen> matching ((Unit-type of (Matching unit)) Equal to Squire))
      • Unit Group - Pick every unit in TempUnitGroup1 and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Hero level of (Picked unit)) Greater than or equal to 2
            • Then - Actions
              • Set TempUnitGroup2 = (Units in JOBS RED GROUP1 <gen> matching ((Unit-type of (Matching unit)) Equal to Knight))
              • Unit Group - Pick every unit in TempUnitGroup2 and do (Actions)
                • Loop - Actions
                  • Set TempUnit2 = (Picked unit)
                  • Unit - Move TempUnit2 instantly to TempPoint1, facing 270.00 degrees
                  • Set SoldierRED[1] = (Picked unit)
                  • Selection - Select TempUnit2 for (Owner of TempUnit1)
                  • Special Effect - Create a special effect attached to the origin of TempUnit2 using Abilities\Spells\Undead\DeathPact\DeathPactTarget.mdl
                  • Special Effect - Destroy (Last created special effect)
            • Else - Actions
              • Unit - Move TempUnit1 instantly to TempPoint1, facing 270.00 degrees
              • Set TempPlayerGroup = (Player group((Owner of TempUnit1)))
              • Game - Display to TempPlayerGroup for 0.50 seconds the text: |cffffcc00Job Train...
      • Custom script: call RemoveLocation( udg_TempPoint1)
      • Custom script: call RemoveLocation( udg_TempPoint2)
      • Custom script: call DestroyGroup(udg_TempUnitGroup1)
      • Custom script: call DestroyGroup(udg_TempUnitGroup2)
      • Custom script: call DestroyForce(udg_TempPlayerGroup)
 
Level 8
Joined
Jul 17, 2004
Messages
283
deathismyfriend, the reason why is because. If they aren't nested, I'd have to do "Skip Remaining Actions" somewhere. That wouldn't be good, cause then the custom scripts for removing leaks will get skipped. PLUS I will be adding more hero level requirement conditions (more nested unit groups) for other Job classes, and the Player Group message needs to stay in one line. And for that to be possible, I need an Else inside an If/Then/Else, nested in other unit groups.

And, I actually did go with your method for the SoldierRED var. I realized it really isn't all that tedious to change for every player.

How is the trigger now?

  • Soldier 1 Knight
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Knight
      • (Owner of (Triggering unit)) Equal to Player 1 (Red)
      • (Triggering unit) Equal to SoldierRED[1]
    • Actions
      • Set TempUnit = (Triggering unit)
      • Set TempPoint = (Position of TempUnit)
      • Set TempPoint2 = (Center of JOBS RED GROUP1 <gen>)
      • Unit - Move TempUnit instantly to TempPoint2, facing 270.00 degrees
      • Set TempUnitGroup = (Units in JOBS RED GROUP1 <gen> matching ((Unit-type of (Matching unit)) Equal to Squire))
      • Unit Group - Pick every unit in TempUnitGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Hero level of (Picked unit)) Greater than or equal to 2
            • Then - Actions
              • Set TempUnitGroup2 = (Units in JOBS RED GROUP1 <gen> matching ((Unit-type of (Matching unit)) Equal to Knight))
              • Unit Group - Pick every unit in TempUnitGroup2 and do (Actions)
                • Loop - Actions
                  • Set SoldierRED[1] = (Picked unit)
                  • Unit - Move SoldierRED[1] instantly to TempPoint, facing 270.00 degrees
                  • Selection - Select SoldierRED[1] for (Owner of TempUnit)
                  • Special Effect - Create a special effect attached to the origin of SoldierRED[1] using Abilities\Spells\Undead\DeathPact\DeathPactTarget.mdl
                  • Special Effect - Destroy (Last created special effect)
            • Else - Actions
              • Unit - Move TempUnit instantly to TempPoint, facing 270.00 degrees
              • Set TempPlayerGroup = (Player group((Owner of TempUnit)))
              • Game - Display to TempPlayerGroup for 0.50 seconds the text: |cffffcc00Job Train...
      • Custom script: call RemoveLocation( udg_TempPoint)
      • Custom script: call RemoveLocation( udg_TempPoint2)
      • Custom script: call DestroyGroup(udg_TempUnitGroup)
      • Custom script: call DestroyGroup(udg_TempUnitGroup2)
      • Custom script: call DestroyForce(udg_TempPlayerGroup)
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
The DestroyForce should be after the Game - Display...

it skips every action after the skip remaining actions function call. it basically ends the trigger.

It ends the function, not necessarily the trigger.

For example unit group enumerations are done in a separate function.

This will display the "Finish" text:

  • Untitled Trigger 103
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Picked unit)) Equal to Footman
            • Then - Actions
              • Game - Display to Player Group - Player 1 (Red) for 3.00 seconds the text: Footman
              • Skip remaining actions
            • Else - Actions
      • Game - Display to Player Group - Player 1 (Red) for 3.00 seconds the text: Finish

In fact, that does not even break the unit group loop, every unit in the map will be looped even if there is a footman in there.
 
Level 8
Joined
Jul 17, 2004
Messages
283
The DestroyForce should be after the Game - Display...



It ends the function, not necessarily the trigger.

For example unit group enumerations are done in a separate function.

This will display the "Finish" text:

  • Untitled Trigger 103
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Picked unit)) Equal to Footman
            • Then - Actions
              • Game - Display to Player Group - Player 1 (Red) for 3.00 seconds the text: Footman
              • Skip remaining actions
            • Else - Actions
      • Game - Display to Player Group - Player 1 (Red) for 3.00 seconds the text: Finish

In fact, that does not even break the unit group loop, every unit in the map will be looped even if there is a footman in there.




Maker, so it should be like this?



  • Soldier 1 Knight
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Knight
      • (Owner of (Triggering unit)) Equal to Player 1 (Red)
      • (Triggering unit) Equal to SoldierRED[1]
    • Actions
      • Set TempUnit = (Triggering unit)
      • Set TempPoint = (Position of TempUnit)
      • Set TempPoint2 = (Center of JOBS RED GROUP1 <gen>)
      • Unit - Move TempUnit instantly to TempPoint2, facing 270.00 degrees
      • Set TempUnitGroup = (Units in JOBS RED GROUP1 <gen> matching ((Unit-type of (Matching unit)) Equal to Squire))
      • Unit Group - Pick every unit in TempUnitGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Hero level of (Picked unit)) Greater than or equal to 2
            • Then - Actions
              • Set TempUnitGroup2 = (Units in JOBS RED GROUP1 <gen> matching ((Unit-type of (Matching unit)) Equal to Knight))
              • Unit Group - Pick every unit in TempUnitGroup2 and do (Actions)
                • Loop - Actions
                  • Set SoldierRED[1] = (Picked unit)
                  • Unit - Move SoldierRED[1] instantly to TempPoint, facing 270.00 degrees
                  • Selection - Select SoldierRED[1] for (Owner of TempUnit)
                  • Special Effect - Create a special effect attached to the origin of SoldierRED[1] using Abilities\Spells\Undead\DeathPact\DeathPactTarget.mdl
                  • Special Effect - Destroy (Last created special effect)
            • Else - Actions
              • Unit - Move TempUnit instantly to TempPoint, facing 270.00 degrees
              • Set TempPlayerGroup = (Player group((Owner of TempUnit)))
              • Game - Display to TempPlayerGroup for 0.50 seconds the text: |cffffcc00Job Train...
              • Custom script: call DestroyForce(udg_TempPlayerGroup)
      • Custom script: call RemoveLocation( udg_TempPoint)
      • Custom script: call RemoveLocation( udg_TempPoint2)
      • Custom script: call DestroyGroup(udg_TempUnitGroup)
      • Custom script: call DestroyGroup(udg_TempUnitGroup2)
 
Level 8
Joined
Jul 17, 2004
Messages
283
Okay, how is this now? Is the trigger perfect now, Maker?

  • Soldier 1 Knight
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Knight
      • (Owner of (Triggering unit)) Equal to Player 1 (Red)
      • (Triggering unit) Equal to SoldierRED[1]
    • Actions
      • Set TempUnit = (Triggering unit)
      • Set TempPoint = (Position of TempUnit)
      • Set TempPoint2 = (Center of JOBS RED GROUP1 <gen>)
      • Unit - Move TempUnit instantly to TempPoint2, facing 270.00 degrees
      • Custom script: call RemoveLocation( udg_TempPoint2)
      • Set TempUnitGroup = (Units in JOBS RED GROUP1 <gen> matching ((Unit-type of (Matching unit)) Equal to Squire))
      • Unit Group - Pick every unit in TempUnitGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Hero level of (Picked unit)) Greater than or equal to 2
            • Then - Actions
              • Set TempUnitGroup2 = (Units in JOBS RED GROUP1 <gen> matching ((Unit-type of (Matching unit)) Equal to Knight))
              • Unit Group - Pick every unit in TempUnitGroup2 and do (Actions)
                • Loop - Actions
                  • Set SoldierRED[1] = (Picked unit)
                  • Unit - Set life of SoldierRED[1] to (Life of TempUnit)
                  • Unit - Set mana of SoldierRED[1] to (Mana of TempUnit)
                  • Unit - Move SoldierRED[1] instantly to TempPoint, facing 270.00 degrees
                  • Selection - Select SoldierRED[1] for (Owner of TempUnit)
                  • Special Effect - Create a special effect attached to the origin of SoldierRED[1] using Abilities\Spells\Undead\DeathPact\DeathPactTarget.mdl
                  • Special Effect - Destroy (Last created special effect)
              • Custom script: call DestroyGroup(udg_TempUnitGroup2)
            • Else - Actions
              • Unit - Move TempUnit instantly to TempPoint, facing 270.00 degrees
              • Set TempPlayerGroup = (Player group((Owner of TempUnit)))
              • Game - Display to TempPlayerGroup for 0.50 seconds the text: |cffffcc00Job Train...
              • Custom script: call DestroyForce(udg_TempPlayerGroup)
      • Custom script: call RemoveLocation( udg_TempPoint)
      • Custom script: call DestroyGroup(udg_TempUnitGroup)
 
Status
Not open for further replies.
Top