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

[Trigger] Hero Creep Revival

Status
Not open for further replies.
Level 11
Joined
Aug 11, 2009
Messages
594
Hi, I need some help making this trigger revive Heroes instead of creating new units all the time. All creeps are Heroes in my map. The code works without bugs when using custom script but starts to bug out with some creeps not reviving when not using coding. So if someone could make a custom script reviving heroes instead using the values found in this code i would be very thankful!

Here it is:
  • Creep Respawn
    • Events
      • Unit - A unit Dies
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • (Custom value of (Triggering unit)) Greater than 0
          • (Owner of (Triggering unit)) Equal to Neutral Hostile
    • Actions
      • Custom script: local integer i = GetUnitTypeId(GetTriggerUnit())
      • Custom script: local integer ii = GetUnitUserData(GetTriggerUnit())
      • Wait 60.00 game-time seconds
      • Custom script: call SetUnitUserData(CreateUnit(Player(12),i,GetLocationX(udg_Point_CreepRespawn[ii]),GetLocationY(udg_Point_CreepRespawn[ii]),270),ii)
 
Last edited by a moderator:
Level 39
Joined
Feb 27, 2007
Messages
5,010
IIRC there is a hero revive command, and as long as your heroes don't decay instantly you just need to pause them and do something like:

Pause Unit
Save it in local unit u = GetTriggerUnit()
Wait 60 seconds
set udg_HeroToRevive = u
Unpause HeroToRevive
Unit - Revive HeroToRevive
set u = null
 
Level 13
Joined
Mar 24, 2013
Messages
1,105
I think even if it decays it is fine. So long as its not removed from the game you can rez a dead hero at any time.

also you can just do this.

  • Actions
    • Wait 60.00 seconds
    • Hero - Instantly revive (Triggering unit) at whichPoint, Hide revival graphics
 
The "problem" that might occur when using (TriggeringUnit) after 60 seconds with this event is that the unit might get removed/decayed during the duration. So the script you use uses local variables for store required data before the unit is removed.
But as it's explained it is all heroes, it should work fine. And you already have the location provided, so just can use it:

  • Actions
    • Wait 60.00 seconds
    • Hero - Instantly revive (Triggering unit) at Point_CreepRespawn[(Custom value of (Triggering unit))], Hide revival graphics
 
Level 11
Joined
Aug 11, 2009
Messages
594
Some creeps wont revive, the first 2 i kill doesnt revive but the rest does when just using wait and then revive triggering unit.

I get errors when trying the scripts you made pyrogasm so cant test :/

Edit: After further testing it seems they dont revive if i kill them too quickly. But its still a problem.
 
Last edited:
Level 18
Joined
Nov 21, 2012
Messages
835
Hi, I need some help making this trigger revive Heroes instead of creating new units all the time. All creeps are Heroes in my map
You can't. I assume you have more then 7 hostile heroes. 7 is a limit for dead heroes for the same time. You won't be able to revive 8th etc, so your script with creating new ones if good. You may add heroes level, items etc if you use it for hostile heroes.
 
Well howdy doody I forgot that. Would be interesting to know how that native is coded to achieve that functionality and why they chose not to do it with more event responses.
Interestingly there are quite some more working responses, against rumors. This thread is interesting to read: Event Response Myths
 
Level 11
Joined
Aug 11, 2009
Messages
594
ZiBithewand3r3r that explains why some didnt revive when killing them too fast, thx alot. I will try and save levels and items in variables and add them after the new hero is created. If i get any troubles ill be back! Thx :D
 
Level 11
Joined
Aug 11, 2009
Messages
594
So I cant get it to work.. they respawn but always as lvl 1 and no items. Im not good at triggers. Could anyone help me make it work?

Edit: Here is Init triggers
Code:
Creep Respawn Init
    Events
        Map initialization
    Conditions
    Actions
        Unit Group - Pick every unit in (Units in (Playable map area) owned by Neutral Hostile) and do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        And - All (Conditions) are true
                            Conditions
                                ((Picked unit) is A Hero) Equal to True
                                ((Picked unit) is An Ancient) Equal to False
                    Then - Actions
                        Set Integer_Creep = (Integer_Creep + 1)
                        Unit - Set the custom value of (Picked unit) to Integer_Creep
                        Set Point_Creep[Integer_Creep] = (Position of (Picked unit))
                        Set Integer_CreepLevel[(Custom value of (Picked unit))] = (Hero level of (Picked unit))
                        Set Item_CreepSlot1[(Custom value of (Picked unit))] = (Item-type of (Item carried by (Picked unit) in slot 1))
                        Set Item_CreepSlot2[(Custom value of (Picked unit))] = (Item-type of (Item carried by (Picked unit) in slot 2))
                        Set Item_CreepSlot3[(Custom value of (Picked unit))] = (Item-type of (Item carried by (Picked unit) in slot 3))
                        Set Item_CreepSlot4[(Custom value of (Picked unit))] = (Item-type of (Item carried by (Picked unit) in slot 4))
                        Set Item_CreepSlot5[(Custom value of (Picked unit))] = (Item-type of (Item carried by (Picked unit) in slot 5))
                        Set Item_CreepSlot6[(Custom value of (Picked unit))] = (Item-type of (Item carried by (Picked unit) in slot 6))
                        Hero - Disable experience gain for (Picked unit)
                    Else - Actions

And here is execution of respawn:
Code:
Creep Respawn
    Events
        Unit - A unit Dies
    Conditions
        And - All (Conditions) are true
            Conditions
                (Custom value of (Triggering unit)) Greater than 0
                (Owner of (Triggering unit)) Equal to Neutral Hostile
    Actions
        Custom script:   local integer i = GetUnitTypeId(GetTriggerUnit())
        Custom script:   local integer ii = GetUnitUserData(GetTriggerUnit())
        Wait 30.00 game-time seconds
        Custom script:   call SetUnitUserData(CreateUnit(Player(12),i,GetLocationX(udg_Point_Creep[ii]),GetLocationY(udg_Point_Creep[ii]),270),ii)
        Hero - Set (Last created unit) Hero-level to Integer_CreepLevel[(Custom value of (Triggering unit))], Hide level-up graphics
        Hero - Create Item_CreepSlot1[(Custom value of (Triggering unit))] and give it to (Last created unit)
        Hero - Create Item_CreepSlot2[(Custom value of (Triggering unit))] and give it to (Last created unit)
        Hero - Create Item_CreepSlot3[(Custom value of (Triggering unit))] and give it to (Last created unit)
        Hero - Create Item_CreepSlot4[(Custom value of (Triggering unit))] and give it to (Last created unit)
        Hero - Create Item_CreepSlot5[(Custom value of (Triggering unit))] and give it to (Last created unit)
        Hero - Create Item_CreepSlot6[(Custom value of (Triggering unit))] and give it to (Last created unit)
        Hero - Disable experience gain for (Last created unit)
 
Last edited:
Level 39
Joined
Feb 27, 2007
Messages
5,010
Because you're making new ones, not reviving them. Change this line:
Custom script: call SetUnitUserData(CreateUnit(Player(12),i,GetLocationX(udg_Point_Creep[ii]),GetLocationY(udg_Point_Creep[ii]),270),ii)
to
Hero - Revive (Triggering unit) at Point_Creep[Custom value of (triggering unit)]
 
Level 11
Joined
Aug 11, 2009
Messages
594
Because you're making new ones, not reviving them. Change this line:
Custom script: call SetUnitUserData(CreateUnit(Player(12),i,GetLocationX(udg_Point_Creep[ii]),GetLocationY(udg_Point_Creep[ii]),270),ii)

to
Hero - Revive (Triggering unit) at Point_Creep[Custom value of (triggering unit)]

Get error: Expected a code statement
 
Level 11
Joined
Aug 11, 2009
Messages
594
Not a custom script. Literally a Hero action. From the GUI trigger editor's actions list.

Ah ok, my mistake. But the problem still remains with reviving as stated by ZiBitheWand3r3r that only 7 Heroes can revive at the same time so it wont work when i have a world filled with Hero creeps :(
 
Level 39
Joined
Feb 27, 2007
Messages
5,010
You can instantly revive them but then hide (and pause? not sure) them until you want a respawn. They'll still show on the minimap I think though because they're revived instantly.
  • Unit - Pause (Triggering unit)
  • Unit - Hide (triggering unit)
  • Unit - Revive (triggering unit)
  • Wait - 60.00 seconds
  • Unit - Unhide (triggering unit)
  • Unit - Unpause (triggering unit)
  • Unit - Play (triggering unit)'s birth animation //not sure of the exact command, maybe try "revive" too idk.
 
Level 18
Joined
Nov 21, 2012
Messages
835
  • init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units owned by Neutral Hostile matching ((((Matching unit) is A Hero) Equal to True) and (((Matching unit) is An Ancient) Equal to False))) and do (Actions)
        • Loop - Actions
          • Set TempUnit = (Picked unit)
          • Set IntegerCreep = (IntegerCreep + 1)
          • Unit - Set the custom value of TempUnit to IntegerCreep
          • Set CreepType[IntegerCreep] = (Unit-type of TempUnit)
          • Set PointCreep[IntegerCreep] = (Position of TempUnit)
          • Set CreepLevel[IntegerCreep] = (Hero level of TempUnit)
          • Set ItemTypeCreep1[IntegerCreep] = (Item-type of (Item carried by TempUnit in slot 1))
          • -------- also for other slots... --------
          • Hero - Disable experience gain for TempUnit
  • dies
    • Events
      • Unit - A unit owned by Neutral Hostile Dies
    • Conditions
      • (Custom value of (Triggering unit)) Greater than 0
    • Actions
      • Custom script: local integer id = GetUnitUserData(GetTriggerUnit())
      • Wait 10.00 seconds
      • Custom script: set udg_TempInteger = id
      • Unit - Create 1 CreepType[TempInteger] for Neutral Hostile at PointCreep[TempInteger] facing Default building facing degrees
      • Unit - Set the custom value of (Last created unit) to TempInteger
      • Hero - Set (Last created unit) Hero-level to CreepLevel[TempInteger], Hide level-up graphics
      • Hero - Create ItemTypeCreep1[TempInteger] and give it to (Last created unit)
      • -------- also for other slots... --------
      • Hero - Disable experience gain for (Last created unit)
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,197
I can confirm, only 7 dead heroes can exist at a time. After 7 heroes die, the longest dead heroes (or maybe internal ordering?) are removed from the game (permanently destroyed). They need to reach a certain level of decaying for removal to occur so killing 30 heroes and instantly reviving them is not a problem.

As Pyrogasm suggested above, the solution is to instantly revive, hide and pause the creep hero. When it respawns unhide and unpause the creep hero. To avoid mini-map icon one can temporarily move the unit to a corner of the map out of the way, with it being moved back in place when respawn occurs.
 
Level 11
Joined
Aug 11, 2009
Messages
594
You can instantly revive them but then hide (and pause? not sure) them until you want a respawn. They'll still show on the minimap I think though because they're revived instantly.
  • Unit - Pause (Triggering unit)
  • Unit - Hide (triggering unit)
  • Unit - Revive (triggering unit)
  • Wait - 60.00 seconds
  • Unit - Unhide (triggering unit)
  • Unit - Unpause (triggering unit)
  • Unit - Play (triggering unit)'s birth animation //not sure of the exact command, maybe try "revive" too idk.

I can confirm, only 7 dead heroes can exist at a time. After 7 heroes die, the longest dead heroes (or maybe internal ordering?) are removed from the game (permanently destroyed). They need to reach a certain level of decaying for removal to occur so killing 30 heroes and instantly reviving them is not a problem.

As Pyrogasm suggested above, the solution is to instantly revive, hide and pause the creep hero. When it respawns unhide and unpause the creep hero. To avoid mini-map icon one can temporarily move the unit to a corner of the map out of the way, with it being moved back in place when respawn occurs.

That was actually pretty smart, thx a lot, will try that! :)

Thx also ZiBitheWand3r3r for code but I also had extra problems with hero abilities not being relearned when creating new Heroes every time, would be a lot of extra coding to check for every different ability and level of ability they have so will try the above first :)
 
Level 18
Joined
Oct 17, 2012
Messages
820
I can confirm, only 7 dead heroes can exist at a time. After 7 heroes die, the longest dead heroes (or maybe internal ordering?) are removed from the game (permanently destroyed). They need to reach a certain level of decaying for removal to occur so killing 30 heroes and instantly reviving them is not a problem.

As Pyrogasm suggested above, the solution is to instantly revive, hide and pause the creep hero. When it respawns unhide and unpause the creep hero. To avoid mini-map icon one can temporarily move the unit to a corner of the map out of the way, with it being moved back in place when respawn occurs.
Is that 7 heroes total or 7 heroes per player?
 
Status
Not open for further replies.
Top