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

[Solved] Hero Respawn

Status
Not open for further replies.
Level 3
Joined
Nov 18, 2015
Messages
41
  • HR Death
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Triggering unit) Equal to p_hero[(Player number of (Owner of (Triggering unit)))]
    • Actions
      • Set tempP = (Owner of (Triggering unit))
      • Set tempLoc = (Position of (Triggering unit))
      • Sound - Play GraveYardWhat1 <gen> at 100.00% volume, located at tempLoc with Z offset 0.00
      • Sound - Play TempleOfTheDamnedWhat <gen> at 75.00% volume, located at tempLoc with Z offset 0.00
      • Game - Display to (All players) for 6.00 seconds the text: ((Name of tempP) + 's hero has fallen to the darkness.)
      • Custom script: set udg_hr_timer = CreateTimer()
      • Custom script: set udg_hr_handleId = GetHandleId(udg_hr_timer)
      • Countdown Timer - Start hr_timer as a One-shot timer that will expire in 5.00 seconds
      • Countdown Timer - Create a timer window for (Last started timer) with title Hero revival in:
      • Countdown Timer - Hide (Last created timer window)
      • Countdown Timer - Show (Last created timer window) for tempP
      • Trigger - Add to HR Revive <gen> the event (Time - hr_timer expires)
      • Hashtable - Save Handle Of(Triggering unit) as 0 of hr_handleId in hr_hashtable
      • Hashtable - Save Handle Of(Last created timer window) as 1 of hr_handleId in hr_hashtable
      • Custom script: call RemoveLocation(udg_tempLoc)
  • HR Revive
    • Events
    • Conditions
    • Actions
      • Set hr_timer = (Expiring timer)
      • Custom script: set udg_hr_handleId = GetHandleId(udg_hr_timer)
      • Game - Display to (Player group(tempP)) for 6.00 seconds the text: (String(hr_handleId))
      • Set hr_hero = (Load 0 of hr_handleId in hr_hashtable)
      • Game - Display to (Player group(tempP)) for 6.00 seconds the text: (Proper name of hr_hero)
      • Set tempP = (Owner of hr_hero)
      • Game - Display to (Player group(tempP)) for 6.00 seconds the text: (Name of tempP)
      • Set tempInt = (Player number of tempP)
      • Game - Display to (Player group(tempP)) for 6.00 seconds the text: (String(tempInt))
      • Camera - Pan camera for tempP to hr_reviveLoc[tempInt] over 0.00 seconds
      • Set tempLoc = hr_reviveLoc[tempInt]
      • Game - Display to (Player group(tempP)) for 6.00 seconds the text: ((String((X of tempLoc))) + (, + (String((Y of tempLoc)))))
      • Hero - Instantly revive hr_hero at tempLoc, Hide revival graphics
      • Camera - Pan camera for tempP to tempLoc over 0.00 seconds
      • Selection - Select hr_hero for tempP
      • Countdown Timer - Destroy (Load 1 of hr_handleId in hr_hashtable)
      • Custom script: call RemoveLocation(udg_tempLoc)
      • Custom script: call DestroyTimer(udg_hr_timer)
      • Hashtable - Clear all child hashtables of child hr_handleId in hr_hashtable
This is what I'm using for my hero respawn. I added in the game messages in the revival trigger for debugging. Every time the location will return 0.0~, 0.0~ and the hero won't respawn because there is no location to spawn at.

This is the trigger I use to set the location.
  • HS Select
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Ability being cast) Equal to Hero Select
    • Actions
      • Set tempP = (Owner of (Casting unit))
      • Player Group - Add tempP to tempPGroup
      • Set tempInt = (Player number of tempP)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of hs_targetHero[tempInt]) Equal to Azura
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Name of tempP) Not equal to kkFire
            • Then - Actions
              • Game - Display to tempPGroup for 3.50 seconds the text: This hero is reserv...
              • Player Group - Pick every player in tempPGroup and do (Player Group - Remove (Picked player) from tempPGroup)
              • Skip remaining actions
            • Else - Actions
        • Else - Actions
      • Set hr_reviveLoc[tempInt] = (Random point in hr rev1 <gen>)
      • Set tempLoc = hr_reviveLoc[tempInt]
      • Unit - Create 1 (Unit-type of hs_targetHero[tempInt]) for tempP at tempLoc facing 270.00 degrees
      • Set p_hero[tempInt] = (Last created unit)
      • Selection - Select p_hero[tempInt] for tempP
      • Cinematic - Clear the screen of text messages for tempPGroup
      • Game - Display to tempPGroup for 12.00 seconds the text: You've chosen your ...
      • Custom script: call RemoveLocation(udg_tempLoc)
      • Set tempLoc = (Position of p_hero[tempInt])
      • Camera - Pan camera for tempP to tempLoc over 0.00 seconds
      • Special Effect - Create a special effect attached to the origin of p_hero[tempInt] using Abilities\Spells\Other\Awaken\Awaken.mdl
      • Special Effect - Destroy (Last created special effect)
      • Unit - Remove (Casting unit) from the game
      • For each (Integer tempInt) from 1 to 8, do (Actions)
        • Loop - Actions
          • Unit - Deny shared vision of hs_hero[(tempInt - 1)] to tempP
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • tempP Not equal to (Player(tempInt))
            • Then - Actions
              • Player - Make tempP treat (Player(tempInt)) as an Ally with shared vision
            • Else - Actions
      • Unit - Deny shared vision of Azura 0009 <gen> to tempP
      • Custom script: call RemoveLocation(udg_tempLoc)
      • Player Group - Remove tempP from tempPGroup
I don't understand why my revive location is nulled out. I tried deleting the variable and saving to see where it was used in custom scripts & in triggers and these are the only locations it's used.
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
  • Set tempLoc = hr_reviveLoc[tempInt]
  • Custom script: call RemoveLocation(udg_tempLoc)
^ Removing tempLoc will also remove hr_reviveLoc[]. You can just do this instead:

  • Set hr_reviveLoc[tempInt] = (Random point in hr rev1 <gen>)
  • Set tempLoc = hr_reviveLoc[tempInt] --- DELETE THIS LINE ---
  • Unit - Create 1 (Unit-type of hs_targetHero[tempInt]) for tempP at hr_reviveLoc[tempInt] facing 270.00 degrees
I honestly don't see the reasoning behind using tempLoc to create the unit when you can just reference hr_reviveLoc[] directly.
 
Level 3
Joined
Nov 18, 2015
Messages
41
I did it merely for convenience, to avoid having to put in the array all of 3 times. Pure laziness that's all.
However, I'm confused why removing tempLoc would remove what it's set to as well. Maybe I'm just overthinking it, but if you...

As I was typing this I pictured the same scenario with a unit, and I can see why now. Thank you very much.
 
Status
Not open for further replies.
Top