• 🏆 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 any unit in the position they died ?

Level 5
Joined
May 8, 2020
Messages
78
How to revive them right where they died after about period of 30 seconds once and keep repeating forever
In addition, I also want to revive the Hero based on their level, which will count towards the time they revive
For example: level 25 x 2 = 50 seconds of respawn
 
Level 25
Joined
Sep 26, 2009
Messages
2,381
Ad reviving non-hero units

The below could work:
  • Dies
    • Events
      • Unit - A unit owned by Neutral Hostile Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to False
      • ((Triggering unit) is A structure) Equal to False
      • ((Triggering unit) is Mechanical) Equal to False
    • Actions
      • Custom script: local integer ut = GetUnitTypeId(GetTriggerUnit())
      • Custom script: local location p = GetUnitLoc(GetTriggerUnit())
      • Wait 10.00 seconds
      • Custom script: set udg_ut = ut
      • Custom script: set udg_p1 = p
      • -------- ------------------------------ --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Triggering unit) Equal to No unit
        • Then - Actions
          • -------- Remains of unit that died no longer exist after the wait period, so nothing to respawn --------
        • Else - Actions
          • Unit - Remove (Triggering unit) from the game
          • Unit - Create 1 ut for (Triggering player) at p1 facing Default building facing degrees
      • -------- ------------------------------ --------
      • Custom script: call RemoveLocation(p)
      • Custom script: set p = null
It requires you to create two variables:
  • p1 (point)
  • ut (unit-type)
if you choose different variable names, you will need to update the two custom scripts after the 'Wait' action, so that the script matches:
  • Custom script: set udg_<your_variable_name> = ut
  • Custom script: set udg_<your_variable_name> = p
  • --
  • // e.g. if instead of 'ut' I named it MyUnitType and instread of 'p1' I named it MyLocation
  • --
  • Custom script: set udg_MyUnitType = ut
  • Custom script: set udg_MyLocation = p
The script revives a non-hero, non-structure, non-mechanical neutral hostile unit after 10 seconds at the location of its death.
If there is no corpse after the wait period, then no unit will be revived (to prevent respawning unit that was reanimated via Raise Dead, etc.)

Ad reviving heroes
Depends on how you revive your heroes, how many heroes per player you have, how many player you can have, etc.
If you want to revive them via triggers, then I would propose using timers, since you can display to player a timer window with the remaining time in the timer.

The basic idea would be to store the hero in some unit variable and start the timer, e.g.:
  • Set VariableSet HeroToRevive = (Triggering unit)
  • Countdown Timer - Start HeroReviveTimer as a One-shot timer that will expire in (Real((2 x (Hero level of HeroToRevive)))) seconds
Then you would need another trigger that reacts to when the timer expires and revive the hero in it:
  • Revive
    • Events
      • Time - HeroReviveTimer expires
    • Conditions
    • Actions
      • Hero - Instantly revive HeroToRevive at (Center of (Playable map area)), Hide revival graphics
Note that the above example will work only for a single hero in the entire map at a time.
 
Top