• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Trigger] Hero Revival System Needs Help

Status
Not open for further replies.
Level 12
Joined
Jun 28, 2008
Messages
688
I have set up a hero revival system that will revive a dying hero (their level) seconds later. The variable "Hunter" (unit variable) has an array of 5 (as there is only 5 heros on the map) and is set accordingly at map initialization.

I have 15 regions on the map that act as respawn points, and are set to the region variable with an array of 15 "RezLoc" at map initialization.

This is the activating trigger:

  • HeroRez
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Set DeadHero = (Triggering unit)
      • For each (Integer A) from 1 to 5, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of DeadHero) Equal to (Player((Integer A)))
            • Then - Actions
              • Set RezPoint = (Center of RezLoc[(Random integer number between 1 and 15)])
              • Wait (Real((Hero level of DeadHero))) seconds
              • Hero - Instantly revive Hunter[(Integer A)] at RezPoint, Hide revival graphics
              • Custom script: call RemoveLocation(udg_RezPoint)
            • Else - Actions
              • Do nothing
My problem is that if two heros die within the alotted time of eachother, one of them will not respawn. I've actually never used the Loop Integer A action, so my problem probably lies there. Help would be greatly appreciated.
 
Level 4
Joined
Sep 24, 2004
Messages
49
It's because the "DeadHero" Variable is a global
When you set it to something - it gets over written
DeadHero = Hero[1]
then.. Hero[3] dies before Hero[1] is revived
DeadHero = Hero[3]; and NOT Hero[1]


Try -

  • HeroRez
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Custom script: local unit DeadHero = GetTriggerUnit()
      • Custom script: local location RezPoint = udg_RezLoc[GetRandomInt(1, 15)]
      • Wait (Real((Hero level of (Triggering unit)))) seconds
      • Custom script: call ReviveHeroLoc( DeadHero, RezPoint, false )
      • Custom script: call RemoveLocation(RezPoint)
Don't hold me to it - haven't tested that: but in theory - Should Work
 
Last edited:
Level 9
Joined
May 27, 2006
Messages
498
  • Rez
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Wait (Real((Hero level of (Triggering unit)))) seconds
      • Set TempPoint = (Center of RezRect[(Random integer number between 1 and 15)])
      • Hero - Instantly revive (Triggering unit) at TempPoint, Hide revival graphics
      • Custom script: call RemoveLocation(udg_TempPoint)
Is enough. And yes, it does work for all units.
 

Attachments

  • TriggeringUnitMUITest.w3x
    21.8 KB · Views: 47
Level 4
Joined
Sep 24, 2004
Messages
49
  • Rez
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Wait (Real((Hero level of (Triggering unit)))) seconds
      • Set TempPoint = (Center of RezRect[(Random integer number between 1 and 15)])
      • Hero - Instantly revive (Triggering unit) at TempPoint, Hide revival graphics
      • Custom script: call RemoveLocation(udg_TempPoint)
Is enough.
Lol. I always thought that you can't use "Trigger Unit" and Event Responses after waits - but: I guess you can; Dunno where I picked that up from....
 
Status
Not open for further replies.
Top