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

Specific Unit Removal Issue & Life/Mana Issue

Status
Not open for further replies.
Level 4
Joined
Aug 9, 2012
Messages
84
I am having troubles in my map to where when a player leaves the game the specific unit-type units they owned are not removed from the entire map. These units are placed mines (and Shade wards that can be bought from the shop). Since my game has a REMATCH system it's absolutely a must the remaining units be removed. They also need to be removed when a player goes into 'Observe Mode', allowing players to observe other players. You can immediately see after the first 'Action' line where I am trying to do this in the triggers below.

The second issue I am having is when a player does the command -repick (whenever they want) I cannot get the newly trained unit to have the old unit's Life and Mana

Note: I had someone help me on this some time ago, but due to being busy they weren't able to help me furthermore.


Here are my Observe Mode triggers:

  • Observing Players
    • Events
      • Player - Player 1 (Red) types a chat message containing -Observe as A substring
      • Player - Player 2 (Blue) types a chat message containing -Observe as A substring
      • Player - Player 3 (Teal) types a chat message containing -Observe as A substring
      • Player - Player 4 (Purple) types a chat message containing -Observe as A substring
      • Player - Player 5 (Yellow) types a chat message containing -Observe as A substring
      • Player - Player 6 (Orange) types a chat message containing -Observe as A substring
      • Player - Player 7 (Green) types a chat message containing -Observe as A substring
      • Player - Player 8 (Pink) types a chat message containing -Observe as A substring
      • Player - Player 9 (Gray) types a chat message containing -Observe as A substring
      • Player - Player 10 (Light Blue) types a chat message containing -Observe as A substring
    • Conditions
      • (String((Entered chat string)) as Lower case) Equal to -observe
      • Observer[(Player number of (Triggering player))] Equal to False
    • Actions
      • Set Observer[(Player number of (Triggering player))] = True
      • Set Temp_UnitGroup = (Units owned by (Triggering player) of type Spy Unit)
      • Set Temp_UnitGroup2 = (Units owned by (Triggering player) of type Explosive Mine)
      • Unit Group - Pick every unit in Temp_UnitGroup and do (Actions)
        • Loop - Actions
          • Unit - Remove (Picked unit) from the game
      • Custom script: call DestroyGroup(udg_Temp_UnitGroup)
      • Unit Group - Pick every unit in Temp_UnitGroup2 and do (Actions)
        • Loop - Actions
          • Unit - Remove (Picked unit) from the game
      • Custom script: call DestroyGroup(udg_Temp_UnitGroup2)
      • Game - Display to (All players) the text: ((Color[(Player number of (Triggering player))] + (Name of (Triggering player))) + |r chose to be an Observer!)
      • Game - Display to (All players) the text:
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • GameMode_5v5 Equal to True
        • Then - Actions
          • For each (Integer A) from 1 to 10, do (Actions)
            • Loop - Actions
          • Multiboard - Set the icon for Multiboard_5v5 item in column 2, row Multiboard_Spots[(Player number of (Triggering player))] to ReplaceableTextures\CommandButtons\PASScout.blp
          • Multiboard - Set the icon for Multiboard_5v5 item in column 3, row Multiboard_Spots[(Player number of (Triggering player))] to ReplaceableTextures\CommandButtons\PASScout.blp
          • Multiboard - Set the text for Multiboard_5v5 item in column 1, row Multiboard_Spots[(Player number of (Triggering player))] to (Color[(Player number of (Triggering player))] + Observer|r)
          • Multiboard - Set the text for Multiboard_5v5 item in column 2, row Multiboard_Spots[(Player number of (Triggering player))] to <Empty String>
          • Multiboard - Set the text for Multiboard_5v5 item in column 3, row Multiboard_Spots[(Player number of (Triggering player))] to <Empty String>
        • Else - Actions
          • Multiboard - Set the icon for Multiboard_FFA item in column 2, row ((Player number of (Triggering player)) + 1) to ReplaceableTextures\CommandButtons\PASScout.blp
          • Multiboard - Set the icon for Multiboard_FFA item in column 3, row ((Player number of (Triggering player)) + 1) to ReplaceableTextures\CommandButtons\PASScout.blp
          • Multiboard - Set the icon for Multiboard_FFA item in column 4, row ((Player number of (Triggering player)) + 1) to ReplaceableTextures\CommandButtons\PASScout.blp
          • Multiboard - Set the text for Multiboard_FFA item in column 1, row ((Player number of (Triggering player)) + 1) to (Color[(Player number of (Triggering player))] + Observer|r)
          • Multiboard - Set the text for Multiboard_FFA item in column 2, row ((Player number of (Triggering player)) + 1) to <Empty String>
          • Multiboard - Set the text for Multiboard_FFA item in column 3, row ((Player number of (Triggering player)) + 1) to <Empty String>
          • Multiboard - Set the text for Multiboard_FFA item in column 4, row ((Player number of (Triggering player)) + 1) to <Empty String>
      • Unit - Remove Hero[(Player number of (Triggering player))] from the game
      • Unit - Create 1 Observer for (Triggering player) at (Center of (Playable map area)) facing Default building facing degrees
      • Player - Set (Triggering player) Current gold to 0
      • Player - Set (Triggering player) Current lumber to 0
      • Camera - Pan camera for (Triggering player) to (Position of (Triggering unit)) over 0.00 seconds
      • Visibility - Create an initially Enabled visibility modifier for (Triggering player) emitting Visibility across (Entire map)

Here are my Leaving Players triggers:

  • Leavers
    • Events
      • Player - Player 1 (Red) leaves the game
      • Player - Player 2 (Blue) leaves the game
      • Player - Player 3 (Teal) leaves the game
      • Player - Player 4 (Purple) leaves the game
      • Player - Player 5 (Yellow) leaves the game
      • Player - Player 6 (Orange) leaves the game
      • Player - Player 7 (Green) leaves the game
      • Player - Player 8 (Pink) leaves the game
      • Player - Player 9 (Gray) leaves the game
      • Player - Player 10 (Light Blue) leaves the game
    • Conditions
    • Actions
      • Set Temp_UnitGroup = (Units owned by (Triggering player) of type Spy Unit)
      • Set Temp_UnitGroup2 = (Units owned by (Triggering player) of type Explosive Mine)
      • Unit Group - Pick every unit in Temp_UnitGroup and do (Actions)
        • Loop - Actions
          • Unit - Remove (Picked unit) from the game
      • Custom script: call DestroyGroup(udg_Temp_UnitGroup)
      • Unit Group - Pick every unit in Temp_UnitGroup2 and do (Actions)
        • Loop - Actions
          • Unit - Remove (Picked unit) from the game
      • Custom script: call DestroyGroup(udg_Temp_UnitGroup2)
      • Game - Display to (All players) the text: ((Color[(Player number of (Triggering player))] + (Name of (Triggering player))) + |r has left the game!)
      • Game - Display to (All players) the text:
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering player) is in Force1) Equal to True
        • Then - Actions
          • Player Group - Remove (Triggering player) from Force1
        • Else - Actions
          • Player Group - Remove (Triggering player) from Force2
      • Unit - Remove Hero[(Player number of (Triggering player))] from the game
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • GameMode_5v5 Equal to True
        • Then - Actions
          • Multiboard - Set the icon for Multiboard_5v5 item in column 1, row Multiboard_Spots[(Player number of (Triggering player))] to UI\Minimap\MinimapIconCreepLoc.blp
          • Multiboard - Set the display style for Multiboard_5v5 item in column 1, row Multiboard_Spots[(Player number of (Triggering player))] to Show text and Show icons
          • Multiboard - Set the text for Multiboard_5v5 item in column 2, row Multiboard_Spots[(Player number of (Triggering player))] to |cffA1A1A1Left|r
          • Multiboard - Set the display style for Multiboard_5v5 item in column 2, row Multiboard_Spots[(Player number of (Triggering player))] to Show text and Hide icons
          • Multiboard - Set the text for Multiboard_5v5 item in column 3, row Multiboard_Spots[(Player number of (Triggering player))] to |cffA1A1A1Left|r
          • Multiboard - Set the display style for Multiboard_5v5 item in column 3, row Multiboard_Spots[(Player number of (Triggering player))] to Show text and Hide icons
        • Else - Actions
          • For each (Integer A) from 2 to (Player_Count + 2), do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Leaver[(Integer A)] Equal to (Triggering player)
                • Then - Actions
                  • Multiboard - Set the display style for Multiboard_FFA item in column 1, row (Integer A) to Hide text and Hide icons
                  • Multiboard - Set the display style for Multiboard_FFA item in column 2, row (Integer A) to Hide text and Hide icons
                  • Multiboard - Set the display style for Multiboard_FFA item in column 3, row (Integer A) to Hide text and Hide icons
                  • Multiboard - Set the display style for Multiboard_FFA item in column 4, row (Integer A) to Hide text and Hide icons
                • Else - Actions
And here are my two triggers regarding the Life/Mana transfer issue to newly trained units when a player does the -repick command. The reason I need it this way is because my game's a shooter (no heals in it, once damaged you're damaged) players don't abuse the -repick command for automatic full life/full mana. Mind you, players are be able to -repick whenever they want in the game. With that in mind, according to what the person said that was helping me before is the new unit's life needs to be reset to ZERO, otherwise, the unit will kill itself if the -repick command is used more than once. I don't know exactly why that is and don't get what he meant by that but I thought I would mention it anyway.


  • Hero Repicking
    • Events
      • Player - Player 1 (Red) types a chat message containing -Repick as An exact match
      • Player - Player 2 (Blue) types a chat message containing -Repick as An exact match
      • Player - Player 3 (Teal) types a chat message containing -Repick as An exact match
      • Player - Player 4 (Purple) types a chat message containing -Repick as An exact match
      • Player - Player 5 (Yellow) types a chat message containing -Repick as An exact match
      • Player - Player 6 (Orange) types a chat message containing -Repick as An exact match
      • Player - Player 7 (Green) types a chat message containing -Repick as An exact match
      • Player - Player 8 (Pink) types a chat message containing -Repick as An exact match
      • Player - Player 9 (Gray) types a chat message containing -Repick as An exact match
      • Player - Player 10 (Light Blue) types a chat message containing -Repick as An exact match
    • Conditions
      • ((Triggering player) Current lumber) Equal to 0
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (String((Entered chat string)) as Lower case) Equal to -repick
        • Then - Actions
          • Camera - Pan camera for (Triggering player) to ((Triggering player) start location) over 0.00 seconds
          • Player - Make (Unit-type of Hero[(Player number of (Triggering player))]) Available for training/construction by (Triggering player)
          • Player - Add 1 to (Triggering player) Current lumber
          • Unit - Remove Hero[(Player number of (Triggering player))] from the game
          • Game - Display to (All players) the text: (((Color[(Player number of (Triggering player))] + (Name of (Triggering player))) + |r has repicked! |cffffcc00(|ror not if an Observer|cffffcc00)|r) + <Empty String>)
          • Game - Display to (All players) the text:
          • Set Items1_TempStore[(Player number of (Triggering player))] = (Item-type of (Item carried by Hero[(Player number of (Triggering player))] in slot 1))
          • Set Items2_TempStore[(Player number of (Triggering player))] = (Item-type of (Item carried by Hero[(Player number of (Triggering player))] in slot 2))
          • Set Items3_TempStore[(Player number of (Triggering player))] = (Item-type of (Item carried by Hero[(Player number of (Triggering player))] in slot 3))
          • Set Items4_TempStore[(Player number of (Triggering player))] = (Item-type of (Item carried by Hero[(Player number of (Triggering player))] in slot 4))
          • Set Items5_TempStore[(Player number of (Triggering player))] = (Item-type of (Item carried by Hero[(Player number of (Triggering player))] in slot 5))
          • Set Items6_TempStore[(Player number of (Triggering player))] = (Item-type of (Item carried by Hero[(Player number of (Triggering player))] in slot 6))
          • Set ItemCharges_1[(Player number of (Triggering player))] = (Charges remaining in (Item carried by Hero[(Player number of (Triggering player))] in slot 1))
          • Set ItemCharges_2[(Player number of (Triggering player))] = (Charges remaining in (Item carried by Hero[(Player number of (Triggering player))] in slot 2))
          • Set ItemCharges_3[(Player number of (Triggering player))] = (Charges remaining in (Item carried by Hero[(Player number of (Triggering player))] in slot 3))
          • Set ItemCharges_4[(Player number of (Triggering player))] = (Charges remaining in (Item carried by Hero[(Player number of (Triggering player))] in slot 4))
          • Set ItemCharges_5[(Player number of (Triggering player))] = (Charges remaining in (Item carried by Hero[(Player number of (Triggering player))] in slot 5))
          • Set ItemCharges_6[(Player number of (Triggering player))] = (Charges remaining in (Item carried by Hero[(Player number of (Triggering player))] in slot 6))
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Observer[(Player number of (Triggering player))] Equal to True
        • Then - Actions
          • Player - Set (Triggering player) Current gold to 0
          • Player - Set (Triggering player) Current lumber to 0
        • Else - Actions
  • Hero Training
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • ((Trained unit) is A Hero) Equal to True
    • Actions
      • Set Hero[(Player number of (Owner of (Trained unit)))] = (Trained unit)
      • Player - Make (Unit-type of (Trained unit)) Unavailable for training/construction by (Owner of (Trained unit))
      • Hero - Set (Trained unit) Hero-level to HeroLevel[(Player number of (Owner of (Trained unit)))], Show level-up graphics
      • Unit - Remove Place Explosive Mine from (Trained unit)
      • Unit - Add |cffffcc00Anti Mine Placement Abuse|r to (Trained unit)
      • Hero - Create Items1_TempStore[(Player number of (Triggering player))] and give it to (Trained unit)
      • Hero - Create Items2_TempStore[(Player number of (Triggering player))] and give it to (Trained unit)
      • Hero - Create Items3_TempStore[(Player number of (Triggering player))] and give it to (Trained unit)
      • Hero - Create Items4_TempStore[(Player number of (Triggering player))] and give it to (Trained unit)
      • Hero - Create Items5_TempStore[(Player number of (Triggering player))] and give it to (Trained unit)
      • Hero - Create Items6_TempStore[(Player number of (Triggering player))] and give it to (Trained unit)
      • Item - Set charges remaining in (Item carried by Hero[(Player number of (Triggering player))] in slot 1) to ItemCharges_1[(Player number of (Triggering player))]
      • Item - Set charges remaining in (Item carried by Hero[(Player number of (Triggering player))] in slot 2) to ItemCharges_2[(Player number of (Triggering player))]
      • Item - Set charges remaining in (Item carried by Hero[(Player number of (Triggering player))] in slot 3) to ItemCharges_3[(Player number of (Triggering player))]
      • Item - Set charges remaining in (Item carried by Hero[(Player number of (Triggering player))] in slot 4) to ItemCharges_4[(Player number of (Triggering player))]
      • Item - Set charges remaining in (Item carried by Hero[(Player number of (Triggering player))] in slot 5) to ItemCharges_5[(Player number of (Triggering player))]
      • Item - Set charges remaining in (Item carried by Hero[(Player number of (Triggering player))] in slot 6) to ItemCharges_6[(Player number of (Triggering player))]
      • Item - Set charges remaining in (Item carried by Hero[(Player number of (Triggering player))] in slot 6) to ItemCharges_6[(Player number of (Triggering player))]
      • Wait 120.00 seconds
      • Unit - Remove |cffffcc00Anti Mine Placement Abuse|r from (Trained unit)
      • Unit - Add Place Explosive Mine to (Trained unit)
NOTE: The 'Hero Repicking' trigger is where things are stored via items and item charges. Therefore, this is where the old unit's life has to be stored, and in the training trigger, the new unit's life and mana is to be set to the old unit's life and mana. That's really all I know regarding this issue, but not how to go about doing it.

If anyone can show me how it's supposed to look that would be cool. Keep it GUI though. I have zilch for knowledge regarding vJASS or C++



In advance, I appreciate anyone who comes forward to help.
Siryan
 
Last edited by a moderator:
Level 26
Joined
Aug 18, 2009
Messages
4,097
Do not see why the removal should not work. The general idea to see why some code refuses to cooperate though is to install debug messages, check which parts are executed and what values are passed to functions/actions.

To store the life of a hero, you can save it in a real variable and ask for it via the function Unit - Property or if you want relative life, there is Unit - Percentage Life or similar. The action Unit - Set Life (To Value) and Unit - Set Life (To Percentage) allow you to apply the value to the new hero. No, resetting the life to zero is what would kill the unit.

Also, in your Hero Repicking trigger, do not destroy the hero before you have read out its information. Your item request lines are currently after the removal.
 
Status
Not open for further replies.
Top