• 🏆 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] Unable to transfer units loaded in a hashtable to another player.

Status
Not open for further replies.
Level 19
Joined
Jul 14, 2011
Messages
875
Well, I have this trigger that should transfer a certain unit along with its corresponding handle in the hashtable but it doesnt do so : it doesnt work after transferred the first time but when I transfer it back it works normaly. My only guess is the unit in the hashtable isnt being transfererd at all.

  • DropOffBuild
    • Events
      • Unit - A unit Finishes construction
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Owner of (Triggering unit)) Equal to Player 1 (Red)
          • (Owner of (Triggering unit)) Equal to Player 6 (Orange)
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Triggering unit)) Equal to Great Hall
          • (Unit-type of (Triggering unit)) Equal to War Mill
    • Actions
      • Set TempPoint = (Position of (Triggering unit))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Triggering unit)) Equal to Great Hall
        • Then - Actions
          • Unit - Create 1 Dummy [Lumber & Gold] for Neutral Passive at TempPoint facing Default building facing degrees
        • Else - Actions
          • Unit - Create 1 Dummy [Lumber] for Neutral Passive at TempPoint facing Default building facing degrees
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 1 (Red)
        • Then - Actions
          • Unit - Change ownership of (Last created unit) to Player 6 (Orange) and Change color
        • Else - Actions
          • Unit - Change ownership of (Last created unit) to Player 1 (Red) and Change color
      • Set x = (X of TempPoint)
      • Set y = (Y of TempPoint)
      • Unit - Turn collision for (Last created unit) Off
      • Custom script: call SetUnitX(GetLastCreatedUnit(), udg_x)
      • Custom script: call SetUnitY(GetLastCreatedUnit(), udg_y)
      • Set TempUGroup = (Units in (Playable map area) matching ((Matching unit) Equal to (Triggering unit)))
      • Unit Group - Pick every unit in TempUGroup and do (Actions)
        • Loop - Actions
          • Hashtable - Save Handle Of(Last created unit) as 0 of (Key (Picked unit)) in (Last created hashtable)
      • Custom script: call DestroyGroup (udg_TempUGroup)
      • Custom script: call RemoveLocation (udg_TempPoint)
      • Unit Group - Add (Triggering unit) to ResourceDropBuildings
  • Then - Actions
    • Selection - Remove (Picked unit) from selection for Player1
    • Cinematic - Ping minimap for (All players) at (Position of (Picked unit)) for 3.00 seconds
    • Set ExchangeSuccess = True
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • ((Picked unit) is in ResourceDropBuildings) Equal to True
      • Then - Actions
        • Unit - Change ownership of (Load 0 of (Key (Picked unit)) in RecDropOffHastable) to Player2 and Change color
        • Set TempUnit = (Load 0 of (Key (Picked unit)) in RecDropOffHastable)
        • Set TempPoint = (Position of (Picked unit))
        • Set x = (X of TempPoint)
        • Set y = (Y of TempPoint)
        • Custom script: call SetUnitX(udg_TempUnit, udg_x)
        • Custom script: call SetUnitY(udg_TempUnit, udg_y)
      • Else - Actions
    • Unit - Change ownership of (Picked unit) to Player2 and Change color
    • Unit Group - Remove (Picked unit) from TempUGroup
    • Unit Group - Remove (Picked unit) from ExchangeSelection1
    • Unit Group - Remove (Picked unit) from ExchangeSelection2
 
  • Set TempUGroup = (Units in (Playable map area) matching ((Matching unit) Equal to (Triggering unit)))
  • Unit Group - Pick every unit in TempUGroup and do (Actions)
    • Loop - Actions
      • Hashtable - Save Handle Of(Last created unit) as 0 of (Key (Picked unit)) in (Last created hashtable)
This makes no sense.
a) No need to enumerate to find a reference of a unit that you already have (which is Last created unit)
b) No need to store it to itself, unless you planned to store last created unit to the triggering unit.
c) (Last created hashtable) -> define it. Have you created any?

Not that this matters, but what is the event of the second trigger?
Why do you keep referring to (Picked unit) when you are not within a unit group enumeration block?
 
Level 19
Joined
Jul 14, 2011
Messages
875
  • Exchange Unit
    • Events
      • Player - Player 1 (Red) types a chat message containing -exchange as A substring
      • Player - Player 6 (Orange) types a chat message containing -exchange as A substring
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Triggering player) Equal to Player1
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Exchanging1 Equal to True
            • Then - Actions
              • Skip remaining actions
            • Else - Actions
              • Set Exchanging1 = True
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Exchanging2 Equal to True
            • Then - Actions
              • Skip remaining actions
            • Else - Actions
              • Set Exchanging2 = True
      • Set ExchangeFail1 = False
      • Set ExchangeFail2 = False
      • Set ExchangeFail3 = False
      • Set ExchangeSuccess = False
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Triggering player) Equal to Player1
        • Then - Actions
          • Set TempUGroup = ExchangeSelection1
          • Set TempPGroup = (Player group(Player1))
          • Set TempPGroup2 = (Player group(Player2))
          • Set TempPlayer = Player1
          • Set Exchanging1 = False
        • Else - Actions
          • Set TempUGroup = ExchangeSelection2
          • Set TempPGroup = (Player group(Player2))
          • Set TempPGroup2 = (Player group(Player1))
          • Set TempPlayer = Player2
          • Set Exchanging2 = False
      • Set TempBoolean = False
      • Unit Group - Pick every unit in TempUGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Picked unit)) Equal to (Triggering player)
            • Then - Actions
              • Set TempBoolean = True
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TempBoolean Equal to True
        • Then - Actions
          • Unit Group - Pick every unit in TempUGroup and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Owner of (Picked unit)) Equal to (Triggering player)
                • Then - Actions
                  • Set tempugroup = (Units in (Playable map area) matching (((Matching unit) is loaded into (Picked unit)) Equal to True))
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Unit-type of (Picked unit)) Not equal to Altar of Storms
                      • ((Picked unit) is A Hero) Equal to False
                      • ((Picked unit) is A town-hall-type unit) Equal to False
                      • ((Picked unit) is A peon-type unit) Equal to False
                      • ((Picked unit) is Summoned) Equal to False
                      • (Number of units in tempugroup) Equal to 0
                    • Then - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Triggering player) Equal to Player1
                        • Then - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • Or - Any (Conditions) are true
                                • Conditions
                                  • And - All (Conditions) are true
                                    • Conditions
                                      • (Supply used by (Picked unit)) Greater than 0
                                      • ((Supply used by (Picked unit)) + (Player2 Food used)) Less than or equal to (Player2 Food cap)
                                  • And - All (Conditions) are true
                                    • Conditions
                                      • (Supply provided by (Picked unit)) Greater than 0
                                      • ((Player1 Food cap) - (Supply provided by (Picked unit))) Greater than or equal to (Player1 Food used)
                                  • And - All (Conditions) are true
                                    • Conditions
                                      • (Supply used by (Picked unit)) Equal to 0
                                      • (Supply provided by (Picked unit)) Equal to 0
                            • Then - Actions
                              • Selection - Remove (Picked unit) from selection for Player1
                              • Cinematic - Ping minimap for (All players) at (Position of (Picked unit)) for 3.00 seconds
                              • Set ExchangeSuccess = True
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • ((Picked unit) is in ResourceDropBuildings) Equal to True
                                • Then - Actions
                                  • Unit - Change ownership of (Load 0 of (Key (Picked unit)) in RecDropOffHastable) to Player2 and Change color
                                  • Set TempUnit = (Load 0 of (Key (Picked unit)) in RecDropOffHastable)
                                  • Set TempPoint = (Position of (Picked unit))
                                  • Set x = (X of TempPoint)
                                  • Set y = (Y of TempPoint)
                                  • Custom script: call SetUnitX(udg_TempUnit, udg_x)
                                  • Custom script: call SetUnitY(udg_TempUnit, udg_y)
                                • Else - Actions
                              • Unit - Change ownership of (Picked unit) to Player2 and Change color
                              • Unit Group - Remove (Picked unit) from TempUGroup
                              • Unit Group - Remove (Picked unit) from ExchangeSelection1
                              • Unit Group - Remove (Picked unit) from ExchangeSelection2
                            • Else - Actions
                              • Set ExchangeFail2 = True
                        • Else - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • Or - Any (Conditions) are true
                                • Conditions
                                  • And - All (Conditions) are true
                                    • Conditions
                                      • (Supply used by (Picked unit)) Greater than 0
                                      • ((Supply used by (Picked unit)) + (Player1 Food used)) Less than or equal to (Player1 Food cap)
                                  • And - All (Conditions) are true
                                    • Conditions
                                      • (Supply provided by (Picked unit)) Greater than 0
                                      • ((Player2 Food cap) - (Supply provided by (Picked unit))) Greater than or equal to (Player2 Food used)
                                  • And - All (Conditions) are true
                                    • Conditions
                                      • (Supply used by (Picked unit)) Equal to 0
                                      • (Supply provided by (Picked unit)) Equal to 0
                            • Then - Actions
                              • Selection - Remove (Picked unit) from selection for Player2
                              • Cinematic - Ping minimap for (All players) at (Position of (Picked unit)) for 3.00 seconds
                              • Set ExchangeSuccess = True
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • ((Picked unit) is in ResourceDropBuildings) Equal to True
                                • Then - Actions
                                  • Unit - Change ownership of (Load 0 of (Key (Picked unit)) in RecDropOffHastable) to Player1 and Change color
                                  • Set TempUnit = (Load 0 of (Key (Picked unit)) in RecDropOffHastable)
                                  • Set TempPoint = (Position of (Picked unit))
                                  • Set x = (X of TempPoint)
                                  • Set y = (Y of TempPoint)
                                  • Custom script: call SetUnitX(udg_TempUnit, udg_x)
                                  • Custom script: call SetUnitY(udg_TempUnit, udg_y)
                                • Else - Actions
                              • Unit - Change ownership of (Picked unit) to Player1 and Change color
                              • Unit Group - Remove (Picked unit) from TempUGroup
                              • Unit Group - Remove (Picked unit) from ExchangeSelection1
                              • Unit Group - Remove (Picked unit) from ExchangeSelection2
                            • Else - Actions
                              • Set ExchangeFail2 = True
                    • Else - Actions
                      • Set ExchangeFail1 = True
                  • Custom script: call DestroyGroup (udg_tempugroup)
                • Else - Actions
                  • Unit Group - Remove (Picked unit) from TempUGroup
        • Else - Actions
          • Set ExchangeFail3 = True
      • -------- - --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ExchangeSuccess Equal to True
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ExchangeFail3 Equal to True
            • Then - Actions
              • Sound - Play Rescue <gen>
              • Game - Display to (All players) the text:
              • Game - Display to TempPGroup for 5.00 seconds the text: |cffcc6600ALLIES|r ...
              • Game - Display to TempPGroup2 for 5.00 seconds the text: |cffcc6600ALLIES|r ...
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ExchangeFail1 Equal to True
                • Then - Actions
                  • Sound - Play Rescue <gen>
                  • Game - Display to (All players) the text:
                  • Game - Display to TempPGroup for 5.00 seconds the text: |cffcc6600ALLIES|r ...
                  • Game - Display to TempPGroup2 for 5.00 seconds the text: |cffcc6600ALLIES|r ...
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ExchangeFail2 Equal to True
                    • Then - Actions
                      • Sound - Play Rescue <gen>
                      • Game - Display to (All players) the text:
                      • Game - Display to TempPGroup for 5.00 seconds the text: |cffcc6600ALLIES|r ...
                      • Game - Display to TempPGroup2 for 5.00 seconds the text: |cffcc6600ALLIES|r ...
                    • Else - Actions
                      • Sound - Play Rescue <gen>
                      • Game - Display to (All players) the text:
                      • Game - Display to TempPGroup for 5.00 seconds the text: |cffcc6600ALLIES|r ...
                      • Game - Display to TempPGroup2 for 5.00 seconds the text: |cffcc6600ALLIES|r ...
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ExchangeFail3 Equal to True
            • Then - Actions
              • Custom script: if GetLocalPlayer() == udg_TempPlayer then
              • Sound - Play Error <gen>
              • Custom script: endif
              • Game - Display to TempPGroup the text:
              • Game - Display to TempPGroup for 5.00 seconds the text: |cffcc6600ALLIES|r ...
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ExchangeFail1 Equal to True
                • Then - Actions
                  • Custom script: if GetLocalPlayer() == udg_TempPlayer then
                  • Sound - Play Error <gen>
                  • Custom script: endif
                  • Game - Display to TempPGroup the text:
                  • Game - Display to TempPGroup for 5.00 seconds the text: |cffcc6600ALLIES|r ...
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ExchangeFail2 Equal to True
                    • Then - Actions
                      • Custom script: if GetLocalPlayer() == udg_TempPlayer then
                      • Sound - Play Error <gen>
                      • Custom script: endif
                      • Game - Display to TempPGroup the text:
                      • Game - Display to TempPGroup for 5.00 seconds the text: |cffcc6600ALLIES|r ...
                    • Else - Actions
                      • Custom script: if GetLocalPlayer() == udg_TempPlayer then
                      • Sound - Play Error <gen>
                      • Custom script: endif
                      • Game - Display to TempPGroup the text:
                      • Game - Display to TempPGroup for 5.00 seconds the text: |cffcc6600ALLIES|r ...
Also, yes, there is a hashtable created, I guess I forgot to change that but its the only hastable in the game and it doesnt work even with pre-set hastable loads, which have the hashtable variable set right.

  • Set TempPoint = (Position of Great Hall 0290 <gen>)
  • Unit - Create 1 Dummy [Lumber & Gold] for Player 1 (Red) at TempPoint facing Default building facing degrees
  • Set x = (X of TempPoint)
  • Set y = (Y of TempPoint)
  • Unit - Turn collision for (Last created unit) Off
  • Custom script: call SetUnitX(GetLastCreatedUnit(), udg_x)
  • Custom script: call SetUnitY(GetLastCreatedUnit(), udg_y)
  • Set TempUGroup = (Units in (Playable map area) matching ((Matching unit) Equal to Great Hall 0290 <gen>))
  • Unit Group - Pick every unit in TempUGroup and do (Actions)
    • Loop - Actions
      • Hashtable - Save Handle Of(Last created unit) as 0 of (Key (Picked unit)) in RecDropOffHastable
  • Custom script: call DestroyGroup (udg_TempUGroup)
  • Custom script: call RemoveLocation (udg_TempPoint)
  • Unit Group - Add Great Hall 0290 <gen> to ResourceDropBuildings
 
First of all, optimize your trigger. You have two if then else statements and both of them have the same condition(s) (if Triggering player is equal to Player1). Merge these together.

Secondly, when you want to refer to a player, don't create a player group. Simply refer to that player through Player actions. Consequently, the same thing applies to your unit group creation. There's absolutely no need for this "Set TempUGroup = (Units in (Playable map area) matching ((Matching unit) Equal to Great Hall 0290 <gen>))".

Just do this instead:
  • Set UnitTemp = Great Hall 0290 <gen>
  • Custom script: call SaveUnitHandle (udg_RecDropOffHashtable, GetHandleId(udg_UnitTemp), 0, bj_lastCreatedUnit)
Use variables for Picked unit and Key(Picked unit) [the second should be a handle-type variable].

"ExchangeSuccess Equal to True" -> In any case you will play Rescue <gen> music. So, delete it from every instance of the "Then" branch and move it in the beginning of the main "Then" branch.
Same goes for Error <gen> when "ExchangeFail3 (is) Equal to True" and "Cinematic - Ping minimap for (All players) at (Position of (Picked unit)) for 3.00 seconds" (which also leaks by the way).

Your code is very repetitive and hard to read. Please, optimize it first and then I will take a further look. I'm surprised that it actually works prior to the hashtable storing.
 
Level 19
Joined
Jul 14, 2011
Messages
875
Ok, so I redid the trigger

  • Exchange Unit
    • Events
      • Player - Player 1 (Red) types a chat message containing -exchange as A substring
      • Player - Player 6 (Orange) types a chat message containing -exchange as A substring
    • Conditions
    • Actions
      • Set ExchangeFail = False
      • Set ExchangeSuccess = False
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Triggering player) Equal to Player 1 (Red)
        • Then - Actions
          • Set TempPlayer = Player 6 (Orange)
          • Set TempUGroup = ExchangeSelection1
        • Else - Actions
          • Set TempPlayer = Player 1 (Red)
          • Set TempUGroup = ExchangeSelection2
      • Unit Group - Pick every unit in TempUGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Picked unit)) Equal to (Triggering player)
              • (Unit-type of (Picked unit)) Not equal to Altar of Storms
              • ((Picked unit) is A Hero) Equal to False
              • ((Picked unit) is A town-hall-type unit) Equal to False
              • ((Picked unit) is A peon-type unit) Equal to False
              • ((Picked unit) is Summoned) Equal to False
              • Or - Any (Conditions) are true
                • Conditions
                  • And - All (Conditions) are true
                    • Conditions
                      • (Supply used by (Picked unit)) Greater than 0
                      • ((Supply used by (Picked unit)) + (TempPlayer Food used)) Less than or equal to (TempPlayer Food cap)
                  • And - All (Conditions) are true
                    • Conditions
                      • (Supply used by (Picked unit)) Equal to 0
                      • (Supply provided by (Picked unit)) Equal to 0
            • Then - Actions
              • Set ExchangeSuccess = True
              • Unit - Change ownership of (Picked unit) to TempPlayer and Change color
              • Selection - Remove (Picked unit) from selection for (Triggering player)
              • Set TempPoint = (Position of (Picked unit))
              • Cinematic - Ping minimap for (All players) at TempPoint for 3.00 seconds
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) is in ResourceDropBuildings) Equal to True
                • Then - Actions
                  • Unit - Change ownership of (Load 0 of (Key (Picked unit)) in RecDropOffHashtable) to TempPlayer and Change color
                  • Set TempUnit = (Load 0 of (Key (Picked unit)) in RecDropOffHashtable)
                  • Set x = (X of TempPoint)
                  • Set y = (Y of TempPoint)
                  • Custom script: call SetUnitX(udg_TempUnit, udg_x)
                  • Custom script: call SetUnitY(udg_TempUnit, udg_y)
                • Else - Actions
              • Custom script: call RemoveLocation (udg_TempPoint)
            • Else - Actions
              • Set ExchangeFail = True
      • Custom script: call DestroyGroup (udg_TempUGroup)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ExchangeSuccess Equal to True
        • Then - Actions
          • Sound - Play Rescue <gen>
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ExchangeFail Equal to True
            • Then - Actions
              • Game - Display to (Player group((Triggering player))) the text: |cffcc6600ALLIES|r ...
              • Game - Display to (Player group(TempPlayer)) the text: |cffcc6600ALLIES|r ...
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ExchangeTip Equal to False
                • Then - Actions
                  • Set ExchangeTip = True
                  • Game - Display to (All players) the text: |cffffcc00TIP|r - Y...
                • Else - Actions
            • Else - Actions
              • Game - Display to (Player group((Triggering player))) the text: |cffcc6600ALLIES|r ...
              • Game - Display to (Player group(TempPlayer)) the text: |cffcc6600ALLIES|r ...
        • Else - Actions
          • Sound - Play Error <gen>
          • Game - Display to (Player group((Triggering player))) the text: |cffcc6600ALLIES|r ...
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ExchangeTip Equal to False
            • Then - Actions
              • Set ExchangeTip = True
              • Game - Display to (All players) the text: |cffffcc00TIP|r - Y...
            • Else - Actions
Its conditions are the same, except that I removed one of the And conditions, which was in an Or condition.
The only thing that it exchanges is the War Mill, I assume its because its in RecourceDropBuildings group, but it doesnt do theat with the unit saved in the hashtable. Actually the hashtable unit either gets transferred to the wrong player somehow or dissappears.
Also, does this :

  • Game - Display to (Player group(TempPlayer)) the text: |cffcc6600ALLIES|r ...
cause a leak?
 
  • Unit - Change ownership of (Load 0 of (Key (Picked unit)) in RecDropOffHashtable) to TempPlayer and Change color
  • Set TempUnit = (Load 0 of (Key (Picked unit)) in RecDropOffHashtable)
Move Set TempUnit action on top of Change ownership one and use "TempUnit" as a reference in the ownership change action.

Player group(TempPlayer) -> yes, that leaks, as you create a new force.

I don't get why "ExchangeFail Equal to True" is checked within the "ExchangeSuccess" block. Shouldn't this already be part of the "Else" branch of the former? I may miss the point of what you want to achieve here, given that I cannot see the messages you are trying to display to the player.

You have 3 "Player Group(Triggering player)" which could be replaced with the "Player Group(TempPlayer)", which should also be replaced with a player group variable.

You say it doesn't exchange the loaded unit. Show me how you save it (with your new trigger) and confirm whether by exchange you actually mean transfer ownership.

Also, tell me what ExchangeSelection1 and ExchangeSelection2 unit groups contain and where you have defined them.
 
Level 19
Joined
Jul 14, 2011
Messages
875
I don't get why "ExchangeFail Equal to True" is checked within the "ExchangeSuccess" block. Shouldn't this already be part of the "Else" branch of the former? I may miss the point of what you want to achieve here, given that I cannot see the messages you are trying to display to the player.

If it has ExchangeFail and ExchangeSuccess are both true then it will display to the player that exchanges that not all units were exchanged, if only ExchangeSuccess is true then it will tell him that ALL units were sent correctly.

Also, tell me what ExchangeSelection1 and ExchangeSelection2 unit groups contain and where you have defined them.

They were something I was testing, I guess I didnt re-copy the trigger after I changed it, oops. Oh, while I'm talking about mistakes... the reason it wasnt exchanging properly was because I had set the wrong player where is exchanges the Hashtable unit.

The problem now is that it doesnt check the units correctly; as if the conditions change every time I exchange something. Sometimes it exchanges it normally, sometimes it says that some of the units werent exchanged and other times it doesnt at all. And the only unit selected was a Grunt.

  • Exchange Unit
    • Events
      • Player - Player 1 (Red) types a chat message containing -exchange as A substring
      • Player - Player 6 (Orange) types a chat message containing -exchange as A substring
    • Conditions
    • Actions
      • Set ExchangeFail = False
      • Set ExchangeSuccess = False
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Triggering player) Equal to Player 1 (Red)
        • Then - Actions
          • Set TempPlayer = Player 6 (Orange)
        • Else - Actions
          • Set TempPlayer = Player 1 (Red)
      • Set TempUGroup = (Units currently selected by (Triggering player))
      • Set TempPGroup = (Player group((Triggering player)))
      • Set TempPGroup2 = (Player group(TempPlayer))
      • Unit Group - Pick every unit in TempUGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Picked unit)) Equal to (Triggering player)
              • (Unit-type of (Picked unit)) Not equal to Altar of Storms
              • ((Picked unit) is A Hero) Equal to False
              • ((Picked unit) is A town-hall-type unit) Equal to False
              • ((Picked unit) is A peon-type unit) Equal to False
              • ((Picked unit) is Summoned) Equal to False
              • Or - Any (Conditions) are true
                • Conditions
                  • And - All (Conditions) are true
                    • Conditions
                      • (Supply used by (Picked unit)) Greater than 0
                      • ((Supply used by (Picked unit)) + (TempPlayer Food used)) Less than or equal to (TempPlayer Food cap)
                  • And - All (Conditions) are true
                    • Conditions
                      • (Supply used by (Picked unit)) Equal to 0
                      • (Supply provided by (Picked unit)) Equal to 0
            • Then - Actions
              • Set ExchangeSuccess = True
              • Unit Group - Remove (Picked unit) from TempUGroup
              • Unit - Change ownership of (Picked unit) to TempPlayer and Change color
              • Selection - Remove (Picked unit) from selection for (Triggering player)
              • Set TempPoint = (Position of (Picked unit))
              • Cinematic - Ping minimap for (All players) at TempPoint for 3.00 seconds
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) is in ResourceDropBuildings) Equal to True
                • Then - Actions
                  • Set TempUnit = (Load 0 of (Key (Picked unit)) in RecDropOffHashtable)
                  • Unit - Change ownership of TempUnit to (Triggering player) and Change color
                  • Unit - Turn collision for TempUnit Off
                  • Set x = (X of TempPoint)
                  • Set y = (Y of TempPoint)
                  • Custom script: call SetUnitX(udg_TempUnit, udg_x)
                  • Custom script: call SetUnitY(udg_TempUnit, udg_y)
                • Else - Actions
              • Custom script: call RemoveLocation (udg_TempPoint)
            • Else - Actions
              • Set ExchangeFail = True
      • Custom script: call DestroyGroup (udg_TempUGroup)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ExchangeSuccess Equal to True
        • Then - Actions
          • Sound - Play Rescue <gen>
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ExchangeFail Equal to True
            • Then - Actions
              • Game - Display to TempPGroup the text: |cffcc6600ALLIES|r ...
              • Game - Display to TempPGroup2 the text: |cffcc6600ALLIES|r ...
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ExchangeTip Equal to False
                • Then - Actions
                  • Set ExchangeTip = True
                  • Game - Display to (All players) the text: |cffffcc00TIP|r - Y...
                • Else - Actions
            • Else - Actions
              • Game - Display to TempPGroup the text: |cffcc6600ALLIES|r ...
              • Game - Display to TempPGroup2 the text: |cffcc6600ALLIES|r ...
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • LocalPlayer Equal to (Triggering player)
            • Then - Actions
              • Sound - Play Error <gen>
            • Else - Actions
          • Game - Display to TempPGroup the text: |cffcc6600ALLIES|r ...
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ExchangeTip Equal to False
            • Then - Actions
              • Set ExchangeTip = True
              • Game - Display to (All players) the text: |cffffcc00TIP|r - Y...
            • Else - Actions
      • Custom script: call DestroyForce (udg_TempPGroup)
      • Custom script: call DestroyForce (udg_TempPGroup2)
 
Status
Not open for further replies.
Top