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

HELP! Recall units system

Status
Not open for further replies.
Level 3
Joined
Feb 12, 2008
Messages
33
Hello fellow members
I need help with my Recall units trigger... In my map there is two phases : Build phase and attack phase. You can only build in build phase. In attack phase the buildings built in build phase [ Will be hidden ] is replaced by a temporary building of same stats. When attack phase is over this temporary building is removed and the original building built in build phase is unhid.
This is my trigger :
This is the first part of the trigger where it replaces the original buildings ( Spirits ) with the temporary ones. The attack phase is started off by typing " start " in this case.
  • Start
    • Events
      • Player - Player 1 (Red) types a chat message containing start as An exact match
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Unit Group - Pick every unit in (Units owned by (Picked player) matching ((Unit-type of (Picked unit)) Equal to |cffccccaaWooden Wall|r [Spirit])) and do (Actions)
            • Loop - Actions
              • Set Point_Temp[4] = (Position of (Picked unit))
              • Unit - Create 1 |cffccccaaWooden Wall|r for (Picked player) at Point_Temp[4] facing Default building facing degrees
              • Custom script: call RemoveLocation(udg_Point_Temp[4])
              • Unit - Hide (Picked unit)
          • Unit Group - Pick every unit in (Units owned by (Picked player) matching ((Unit-type of (Picked unit)) Equal to |cffccccaaReinforced Wooden Wall|r [Spirit])) and do (Actions)
            • Loop - Actions
              • Set Point_Temp[5] = (Position of (Picked unit))
              • Unit - Create 1 |cffccccaaReinforced Wooden Wall|r for (Picked player) at Point_Temp[5] facing Default building facing degrees
              • Custom script: call RemoveLocation(udg_Point_Temp[5])
              • Unit - Hide (Picked unit)
          • Custom script: set bj_wantDestroyGroup = true
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units owned by (Picked player) matching ((Unit-type of (Picked unit)) Equal to |cffccccaaSmall House|r [Spirit])) and do (Actions)
            • Loop - Actions
              • Set Point_Temp[7] = (Position of (Picked unit))
              • Unit - Create 1 |cffccccaaSmall House|r for (Picked player) at Point_Temp[7] facing Default building facing degrees
              • Custom script: call RemoveLocation(udg_Point_Temp[7])
              • Unit - Hide (Picked unit)
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units of type |cffff0000Wait until round ends!|r) and do (Actions)
        • Loop - Actions
          • Unit - Remove (Picked unit) from the game


This is the second part of the trigger, where the temporary building is removed while the " Spirits " are unhid.
  • stop
    • Events
      • Player - Player 1 (Red) types a chat message containing stop as An exact match
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Unit Group - Pick every unit in (Units owned by (Picked player) matching ((Unit-type of (Picked unit)) Equal to |cffccccaaWooden Wall|r)) and do (Actions)
            • Loop - Actions
              • Unit - Remove (Picked unit) from the game
          • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units owned by (Picked player) matching (((Matching unit) is A structure) Equal to True)) and do (Actions)
        • Loop - Actions
          • Unit - Unhide (Picked unit)
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units of type |cffff0000Wait until round ends!|r) and do (Actions)
        • Loop - Actions
          • Unit - Remove (Picked unit) from the game
      • Set Point_Temp[3] = (Center of Region 021 <gen>)
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Unit - Create 1 |cffff0000Wait until round ends!|r for (Picked player) at Point_Temp[3] facing Default building facing degrees
      • Custom script: call RemoveLocation(udg_Point_Temp[3])
This system is similar to in the case of Legion TD where the units are hid before round starts and the units spawn at the same position when the round starts.

Problem: When i tried the trigger out, the spirits will not get replaced and the temporary buildings will not spawn... It's a total failure in other words. Help me out will ya? =)

I thank you from the very bottom of my heart.
 
Level 16
Joined
May 1, 2008
Messages
1,605
Moin moin =)

Easy thing: When you pick up every unit in a unit group, you have to use (matching unit) not (picked unit) when you check the conditions.

So instead of:
  • Unit Group - Pick every unit in (Units owned by (Picked player) matching ((Unit-type of (Picked unit)) Equal to |cffccccaaWooden Wall|r [Spirit])) and do (Actions)
you must use:
  • Unit Group - Pick every unit in (Units owned by (Picked player) matching ((Unit-type of (MATCHING UNIT)) Equal to |cffccccaaWooden Wall|r [Spirit])) and do (Actions)
see the difference? - Good

Also you have to use the custom script
  • Custom script: set bj_wantDestroyGroup = true
only in front of ANY unit group picking!

Greetings
~The Bomb King > Dr. Boom
 
Level 3
Joined
Feb 12, 2008
Messages
33
Still need help!

Start Trigger
  • Start
    • Events
      • Player - Player 1 (Red) types a chat message containing start as An exact match
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units owned by (Picked player) matching ((Unit-type of (Matching unit)) Equal to |cffccccaaWooden Wall|r [Spirit])) and do (Actions)
            • Loop - Actions
              • Set Point_Temp[4] = (Position of (Picked unit))
              • Unit - Create 1 |cffccccaaWooden Wall|r for (Picked player) at Point_Temp[4] facing Default building facing degrees
              • Custom script: call RemoveLocation(udg_Point_Temp[4])
              • Unit - Hide (Picked unit)
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units owned by (Picked player) matching ((Unit-type of (Matching unit)) Equal to |cffccccaaReinforced Wooden Wall|r [Spirit])) and do (Actions)
            • Loop - Actions
              • Set Point_Temp[5] = (Position of (Picked unit))
              • Unit - Create 1 |cffccccaaReinforced Wooden Wall|r for (Picked player) at Point_Temp[5] facing Default building facing degrees
              • Custom script: call RemoveLocation(udg_Point_Temp[5])
              • Unit - Hide (Picked unit)
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units owned by (Picked player) matching ((Unit-type of (Matching unit)) Equal to |cffccccaaSmall House|r [Spirit])) and do (Actions)
            • Loop - Actions
              • Set Point_Temp[7] = (Position of (Picked unit))
              • Unit - Create 1 |cffccccaaSmall House|r for (Picked player) at Point_Temp[7] facing Default building facing degrees
              • Custom script: call RemoveLocation(udg_Point_Temp[7])
              • Unit - Hide (Picked unit)
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units owned by (Picked player) matching ((Unit-type of (Matching unit)) Equal to |cffccccaaTwo-storey House|r [Spirit])) and do (Actions)
            • Loop - Actions
              • Set Point_Temp[8] = (Position of (Picked unit))
              • Unit - Create 1 |cffccccaaTwo-storey House|r for (Picked player) at Point_Temp[8] facing Default building facing degrees
              • Custom script: call RemoveLocation(udg_Point_Temp[8])
              • Unit - Hide (Picked unit)
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units owned by (Picked player) matching ((Unit-type of (Matching unit)) Equal to |cffccccaaThree-storey House|r [Spirit])) and do (Actions)
            • Loop - Actions
              • Set Point_Temp[9] = (Position of (Picked unit))
              • Unit - Create 1 |cffccccaaThree-storey House|r for (Picked player) at Point_Temp[8] facing Default building facing degrees
              • Custom script: call RemoveLocation(udg_Point_Temp[9])
              • Unit - Hide (Picked unit)
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units of type |cffff0000Wait until round ends!|r) and do (Actions)
        • Loop - Actions
          • Unit - Remove (Picked unit) from the game
Stop Trigger
  • stop
    • Events
      • Player - Player 1 (Red) types a chat message containing stop as An exact match
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units owned by (Picked player) matching ((Unit-type of (Matching unit)) Equal to |cffccccaaWooden Wall|r)) and do (Actions)
            • Loop - Actions
              • Unit - Remove (Picked unit) from the game
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units owned by (Picked player) matching ((Unit-type of (Matching unit)) Equal to |cffccccaaReinforced Wooden Wall|r)) and do (Actions)
            • Loop - Actions
              • Unit - Remove (Picked unit) from the game
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units owned by (Picked player) matching ((Unit-type of (Matching unit)) Equal to |cffccccaaThree-storey House|r)) and do (Actions)
            • Loop - Actions
              • Unit - Remove (Picked unit) from the game
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units owned by (Picked player) matching ((Unit-type of (Matching unit)) Equal to |cffccccaaSmall House|r)) and do (Actions)
            • Loop - Actions
              • Unit - Remove (Picked unit) from the game
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units owned by (Picked player) matching ((Unit-type of (Matching unit)) Equal to |cffccccaaTwo-storey House|r)) and do (Actions)
            • Loop - Actions
              • Unit - Remove (Picked unit) from the game
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units owned by (Picked player) matching (((Matching unit) is A structure) Equal to True)) and do (Actions)
            • Loop - Actions
              • Unit - Unhide (Picked unit)
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units of type |cffff0000Wait until round ends!|r) and do (Actions)
        • Loop - Actions
          • Unit - Remove (Picked unit) from the game
      • Set Point_Temp[3] = (Center of Region 021 <gen>)
      • Custom script: set bj_wantDestroyGroup = true
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Unit - Create 1 |cffff0000Wait until round ends!|r for (Picked player) at Point_Temp[3] facing Default building facing degrees
      • Custom script: call RemoveLocation(udg_Point_Temp[3])
The system works perfectly for the wooden wall for both triggers, but the rest doesn't work! Help!
The brigther coloured block is the reinforced wooden wall while the darker one is wooden wall. When i type start, the reinforced wooden wall did not get replaced while the wooden wall did. I know this as i didn't get deselected when i type start.
http://img267.imageshack.us/img267/7585

When i type stop, the reinforced wooden wall disappears while the wooden wall is replaced back to the spirit version..
htthttp://img684.imageshack.us/img684/9822/retryw.jpg

When i try " start " again, the wooden wall work perfectly with the sytem but the reinforced wooden wall is nowhere to be seen again.
http://img684.imageshack.us/img684/9822/retryw.jpg

Help me please.. i will deeply appreciate any help =D:goblin_yeah:
 
Level 14
Joined
Nov 18, 2007
Messages
1,084
I'm not sure what your problem is but you could simplify your trigger to avoid duplication by using arrays and a loop. (They're arrays of Unit-type)
  • MapInit
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Building[0] = Wooden Wall
      • Set Building[1] = Reinforced Wooden Wall
      • Set Building[2] = Small House
      • Set Building[3] = Two-Story House
      • Set Building[4] = Three-Story House
      • Set BuildingSpirit[0] = Wooden Wall (Spirit)
      • Set BuildingSpirit[1] = Reinforced Wooden Wall (Spirit)
      • Set BuildingSpirit[2] = Small House (Spirit)
      • Set BuildingSpirit[3] = Two-Story House (Spirit)
      • Set BuildingSpirit[4] = Three-Story House (Spirit)
In the Start trigger, it would look something like this:
  • Start
    • Events
      • Player - Player 1 (Red) types a chat message containing start as An exact match
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • For each (Integer A) from 0 to 4, do (Actions)
            • Loop - Actions
              • Custom script: set bj_wantDestroyGroup = true
              • Unit Group - Pick every unit in (Units owned by Player 1 (Red) matching ((Unit-type of (Matching unit)) Equal to BuildingSpirit[(Integer A)])) and do (Actions)
                • Loop - Actions
                  • Set TempLoc = (Position of (Picked unit))
                  • Unit - Hide (Picked unit)
                  • Unit - Create 1 Building[(Integer A)] for (Picked player) at TempLoc facing Default building facing degrees
                  • Custom script: call RemoveLocation(udg_TempLoc)
You should do this similarly with the Stop trigger.

Also you don't use Custom script: set bj_wantDestroyGroup = true for player forces. (In your Stop trigger)
You don't need a location array since you're not using them simultaneously.
 
Level 3
Joined
Feb 12, 2008
Messages
33
+ Rep for making life simpler for me by simplifying my trigger.. But the trigger currently works for only Wooden wall , Three Storey House and Small house.. The rest just disappears when i type stop, even if they are intact.

Current Triggers :
Start
  • Start
    • Events
      • Player - Player 1 (Red) types a chat message containing start as An exact match
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Custom script: set bj_wantDestroyGroup = true
          • For each (Integer A) from 1 to 5, do (Actions)
            • Loop - Actions
              • Unit Group - Pick every unit in (Units owned by (Picked player) matching ((Unit-type of (Matching unit)) Equal to SpiritBuilding[(Integer A)])) and do (Actions)
                • Loop - Actions
                  • Set Point_Temp = (Position of (Picked unit))
                  • Unit - Hide (Picked unit)
                  • Unit - Create 1 Building[(Integer A)] for (Picked player) at Point_Temp facing Default building facing degrees
                  • Custom script: call RemoveLocation(udg_Point_Temp)
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units of type |cffff0000Wait until round ends!|r) and do (Actions)
        • Loop - Actions
          • Unit - Remove (Picked unit) from the game
Stop
  • Stop
    • Events
      • Player - Player 1 (Red) types a chat message containing stop as An exact match
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • For each (Integer B) from 1 to 5, do (Actions)
            • Loop - Actions
              • Unit Group - Pick every unit in (Units owned by (Picked player) matching ((Unit-type of (Matching unit)) Equal to Building[(Integer B)])) and do (Actions)
                • Loop - Actions
                  • Unit - Remove (Picked unit) from the game
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units owned by (Picked player) matching (((Matching unit) is A structure) Equal to True)) and do (Actions)
            • Loop - Actions
              • Unit - Unhide (Picked unit)
      • Unit Group - Pick every unit in (Units of type |cffff0000Wait until round ends!|r) and do (Actions)
        • Loop - Actions
          • Unit - Remove (Picked unit) from the game
      • Set PointVariables[1] = (Center of Region 021 <gen>)
      • Custom script: set bj_wantDestroyGroup = true
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Unit - Create 1 |cffff0000Wait until round ends!|r for (Picked player) at PointVariables[1] facing Default building facing degrees
      • Custom script: call RemoveLocation(udg_PointVariables[3])
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Why don't you loop through the whole array, you just loop from 1 to 5?



Look where the Custom script: set bj_wantDestroyGroup = true is supposed to be:
  • Start
    • Events
      • Player - Player 1 (Red) types a chat message containing start as An exact match
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • For each (Integer A) from 1 to 5, do (Actions)
            • Loop - Actions
              • Custom script: set bj_wantDestroyGroup = true
              • Unit Group - Pick every unit in (Units owned by (Picked player) matching ((Unit-type of (Matching unit)) Equal to SpiritBuilding[(Integer A)])) and do (Actions)
                • Loop - Actions
                  • Set Point_Temp = (Position of (Picked unit))
                  • Unit - Hide (Picked unit)
                  • Unit - Create 1 Building[(Integer A)] for (Picked player) at Point_Temp facing Default building facing degrees
                  • Custom script: call RemoveLocation(udg_Point_Temp)
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units of type |cffff0000Wait until round ends!|r) and do (Actions)
        • Loop - Actions
          • Unit - Remove (Picked unit) from the game
A few changes here, the second unit group pick was in wrong position, it wasn't in the loop.
  • Stop
    • Events
      • Player - Player 1 (Red) types a chat message containing stop as An exact match
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • For each (Integer B) from 1 to 5, do (Actions)
            • Loop - Actions
              • Custom script: set bj_wantDestroyGroup = true
              • Unit Group - Pick every unit in (Units owned by (Picked player) matching ((Unit-type of (Matching unit)) Equal to Building[(Integer B)])) and do (Actions)
                • Loop - Actions
                  • Unit - Remove (Picked unit) from the game
              • Custom script: set bj_wantDestroyGroup = true
              • Unit Group - Pick every unit in (Units owned by (Picked player) matching (((Matching unit) is A structure) Equal to True)) and do (Actions)
                • Loop - Actions
                  • Unit - Unhide (Picked unit)
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units of type |cffff0000Wait until round ends!|r) and do (Actions)
        • Loop - Actions
          • Unit - Remove (Picked unit) from the game
      • Set PointVariables[1] = (Center of Region 021 <gen>)
      • Custom script: set bj_wantDestroyGroup = true
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Unit - Create 1 |cffff0000Wait until round ends!|r for (Picked player) at PointVariables[1] facing Default building facing degrees
      • Custom script: call RemoveLocation(udg_PointVariables[1])
 
Level 3
Joined
Feb 12, 2008
Messages
33
I current only have Buildings and SpiritBuildings 1 to 5 ...
After your edit the system still doesn't work T_T... It still only works for the wooden wall small house and three storey house only... I don't understand =(
+ Rep anyway for helping =D
 
Level 3
Joined
Feb 12, 2008
Messages
33
o shi... Nevermind i just realise i made the stupidiest mistake ever... I thought that the problem comes from the trigger and overlooked the object editor .. i made the spirit upgrade to the non-spirit building ... IM SOO FOOLISH T_T .. Thanks for your help by the way! =D
 
Status
Not open for further replies.
Top