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

Revive a hero via Item

Status
Not open for further replies.
Level 5
Joined
Jun 16, 2009
Messages
49
Greetings,

I have a castle defense map, where heroes that die are respawned after hero level + 30 seconds, and I'm trying to make an item that revives a random hero that are currently dead. I tried using hashtables, but chose to use unit arrays instead. Here is what I got so far:

Turn On: this is where I set a boolean to make the system know someone has the item and therefore turning all other triggers on.
  • Eye of Horus Activate
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Eye of Horus
    • Actions
      • Set Eye_Boolean = True
      • Trigger - Turn on Eye of Horus Array <gen>

If someone drops the item or sells it, turns all other triggers off:
  • Eye of Horus Lose
    • Events
      • Unit - A unit Loses an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Eye of Horus
    • Actions
      • Set Eye_Boolean = False
      • Trigger - Turn off Eye of Horus Array <gen>

Here I define which and whom hero dies and store them:
  • Eye of Horus Array
    • Events
      • Unit - A unit Dies
    • Conditions
      • Eye_Boolean Equal to True
      • ((Dying unit) is A Hero) Equal to True
      • ((Owner of (Dying unit)) Equal to Player 1 (Red)) or (((Owner of (Dying unit)) Equal to Player 2 (Blue)) or (((Owner of (Dying unit)) Equal to Player 3 (Teal)) or (((Owner of (Dying unit)) Equal to Player 4 (Purple)) or ((Owner of (Dying unit)) Equal to Player 6 (Orange)))))
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Dying unit)) Equal to Player 1 (Red)
        • Then - Actions
          • Set Revival_Boolean[1] = True
          • Set Revival_Array[1] = (Dying unit)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Dying unit)) Equal to Player 2 (Blue)
            • Then - Actions
              • Set Revival_Boolean[2] = True
              • Set Revival_Array[2] = (Dying unit)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Owner of (Dying unit)) Equal to Player 3 (Teal)
                • Then - Actions
                  • Set Revival_Boolean[3] = True
                  • Set Revival_Array[3] = (Dying unit)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Owner of (Dying unit)) Equal to Player 4 (Purple)
                    • Then - Actions
                      • Set Revival_Boolean[4] = True
                      • Set Revival_Array[4] = (Dying unit)
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Owner of (Dying unit)) Equal to Player 6 (Orange)
                        • Then - Actions
                          • Set Revival_Boolean[5] = True
                          • Set Revival_Array[5] = (Dying unit)
                        • Else - Actions

I'm almost sure that these ones are correct, unless someone tells me it isn't. But this one I feel like there is something missing:

  • Eye of Horus Use
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Eye of Horus
    • Actions
      • Game - Display to (All players) for 10.00 seconds the text: ((|cffffcc00 + ((Proper name of (Triggering unit)) + |r)) + has used the |c006969FFEye of Horus|r!)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random integer number between 1 and 5) Equal to 1
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Revival_Boolean[1] Equal to True
            • Then - Actions
              • Hero - Instantly revive Revival_Array[1] at Pos[150], Show revival graphics
            • Else - Actions
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Random integer number between 1 and 5) Equal to 2
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Revival_Boolean[2] Equal to True
                • Then - Actions
                  • Hero - Instantly revive Revival_Array[2] at Pos[150], Show revival graphics
                • Else - Actions
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Random integer number between 1 and 5) Equal to 3
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Revival_Boolean[3] Equal to True
                    • Then - Actions
                      • Hero - Instantly revive Revival_Array[3] at Pos[150], Show revival graphics
                    • Else - Actions
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Random integer number between 1 and 5) Equal to 4
                    • Then - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • Revival_Boolean[4] Equal to True
                        • Then - Actions
                          • Hero - Instantly revive Revival_Array[4] at Pos[150], Show revival graphics
                        • Else - Actions
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Random integer number between 1 and 5) Equal to 5
                        • Then - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • Revival_Boolean[5] Equal to True
                            • Then - Actions
                              • Hero - Instantly revive Revival_Array[5] at Pos[150], Show revival graphics
                            • Else - Actions
                        • Else - Actions

Or if someone would have a hashtable solution, I'm open to suggetions. Any help would be much appreciated still.
 
Level 5
Joined
Jun 16, 2009
Messages
49
Just when the hero die add him to a unit group and when you use the item do the action "Revive (Random Unit of that group)" and remove him of that group.

PD: You should use "Or Multiple conditions"

:con:
I mean, you get too complicated, you don't need all that.

I realise that now, I feel really dumb. I managed to get it working, with your help ofc.

  • Eye of Horus Activate
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to |cffffd700Eye of Horus|r
    • Actions
      • Trigger - Turn on Eye of Horus Set <gen>
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Unit Group - Add (Picked unit) to Revival_Group)
      • Set Revival_Group = (Last created unit group)
      • Unit Group - Remove all units of Revival_Group from Revival_Group
  • Eye of Horus Lose
    • Events
      • Unit - A unit Loses an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to |cffffd700Eye of Horus|r
    • Actions
      • Unit Group - Remove all units of Revival_Group from Revival_Group
      • Trigger - Turn off Eye of Horus Set <gen>
  • Eye of Horus Set
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Dying unit) is A Hero) Equal to True
      • ((Owner of (Dying unit)) Equal to Player 1 (Red)) or (((Owner of (Dying unit)) Equal to Player 2 (Blue)) or (((Owner of (Dying unit)) Equal to Player 3 (Teal)) or (((Owner of (Dying unit)) Equal to Player 4 (Purple)) or ((Owner of (Dying unit)) Equal to Player 6 (Orange)))))
    • Actions
      • Unit Group - Add (Dying unit) to Revival_Group
  • Eye of Horus Use
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Eye of Horus
    • Actions
      • Set Spell_Variation_Unit = (Random unit from Revival_Group)
      • Game - Display to (All players) for 10.00 seconds the text: ((|cffffcc00 + ((Proper name of (Triggering unit)) + |r)) + has used the |c006969FFEye of Horus|r!)
      • Hero - Instantly revive Spell_Variation_Unit at Pos[150], Show revival graphics
      • Camera - Pan camera for (Owner of Spell_Variation_Unit) to Pos[150] over 1.00 seconds
      • Unit Group - Remove Spell_Variation_Unit from Revival_Group
 
Level 24
Joined
Jun 26, 2020
Messages
1,852
And one more thing, Why is necesary add the units that have that item to a unit group? Because its only necesary that they have the item and you aren't use that information.

And just in case, the second trigger has an error: If one unit drop the item, all the units in that group are removed.
 
Status
Not open for further replies.
Top