• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Solved] Unit deleted by system?

Level 3
Joined
May 24, 2024
Messages
33
Hello,I meet a problem about losing some certain units(heroes).I save them in the hashmap when they are trained,and when they are dead,i set a temporary timer,they will rebirth after the timer off.They will show up just several times.
I guess they are cleaned by the system.Is there any we can keep some units in a whole game time?
 

Remixer

Map Reviewer
Level 33
Joined
Feb 19, 2011
Messages
2,112
It's a bit unclear how and what you are trying to achieve. To my understanding, do you want to revive units after X time once they die? To my understanding, the Death and Decay animations take roughly 30~ seconds to complete, after which the game deletes the 'unit'.

If you are dealing with low number of unit types, you can change their Death Duration, which would delay their Raise Corpse delay and thus also Decay duration, preventing the game from deleting the units. You could try to change this value to absurdly high value - such as 100 minutes, depending on your needs.

Alternatively, you could just make the corpses permanent, which I think would achieve the same thing (Leaves a Corpse, Does Not Decay) in Object Editor - similarly to changing the Death Time Delay.

If you need to have ordinary death time and corpses for other reasons, then you'd need to time their death (When HP < 0.405) and start a timer that would revive and hide the unit just before the game deletes them. Then, after any time you could unhide and re-enable the unit.
 
Level 3
Joined
May 24, 2024
Messages
33
Oh sorry friend,i mean,for example, i train a hero and set him to battleground,when he is fall in there,i want him to be born again in a dynamic time (20+5*his level).
My problem is, sometimes he doesn't come back.
I also check the Equilibrium constants as you mentioned above,but i didn't change the three infos (BoneDecay:88,Decay:2,Dissipate:3).
The reason should be what you call the 30-second mechanism,but,when we in a standard melee game,we can get the heroes' rebirth anytime from the altar,why can they stay there for more than 30s?
 
Level 3
Joined
May 24, 2024
Messages
33
how many heroes per player do you use? I believe someone mentioned in some other thread if you have too many heroes, then the game removes dead heroes and they can no longer be resurrected.
So if you have too many heroes, perhaps try to resurrect them immediately on death and just hide them.
Actually,no more than 4 (all players' heroes added up )have been trained in testing so far.I guess Remixer is right.I got a situation(when using cache to save and get) like your idea, but i stopped the test when the third Uther was created.
 
Level 3
Joined
May 24, 2024
Messages
33
It's a bit unclear how and what you are trying to achieve. To my understanding, do you want to revive units after X time once they die? To my understanding, the Death and Decay animations take roughly 30~ seconds to complete, after which the game deletes the 'unit'.

If you are dealing with low number of unit types, you can change their Death Duration, which would delay their Raise Corpse delay and thus also Decay duration, preventing the game from deleting the units. You could try to change this value to absurdly high value - such as 100 minutes, depending on your needs.

Alternatively, you could just make the corpses permanent, which I think would achieve the same thing (Leaves a Corpse, Does Not Decay) in Object Editor - similarly to changing the Death Time Delay.

If you need to have ordinary death time and corpses for other reasons, then you'd need to time their death (When HP < 0.405) and start a timer that would revive and hide the unit just before the game deletes them. Then, after any time you could unhide and re-enable the unit.
It's weird that the hero wasn't deleted by system after 30 seconds when he was dead.I even waited 2 minutes and the debug still showed his name.
I tested the way to hide it before,but still failed.I checked all triggers, finding nothing related to deleting heroes.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,877
I don't think heroes ever get removed from the game, but there is some revive limitations related to too many heroes, but I believe that's per player and you need to exceed ~7.

Anyway, it sounds like you've made a mistake in your revival system. Here's a very basic version that should always work:

REQUIRED:
vJASS:
library ReviveDeadHeroes initializer Init

    globals
        private hashtable Hash
    endglobals

    private function ReviveDeadHeroCallback takes nothing returns nothing
        local timer t = GetExpiredTimer()
        local integer id = GetHandleId(t)
        set udg_Dead_Hero = LoadUnitHandle(Hash, id, 0)
        set udg_Dead_Revive_Point = LoadLocationHandle(Hash, id, 1)
        call ReviveHeroLoc(udg_Dead_Hero, udg_Dead_Revive_Point, false)
        call TriggerExecute(gg_trg_Dead_Hero_Revives)
        call RemoveLocation(udg_Dead_Revive_Point)
        call DestroyTimer(t)
        set t = null
    endfunction

    function ReviveDeadHero takes nothing returns nothing
        local timer t = CreateTimer()
        local integer id = GetHandleId(t)
        call SaveUnitHandle(Hash, id, 0, udg_Dead_Hero)
        call SaveLocationHandle(Hash, id, 1, udg_Dead_Revive_Point)
        call TimerStart(t, udg_Dead_Revive_Duration, false, function ReviveDeadHeroCallback)
        set t = null
    endfunction

    private function Init takes nothing returns nothing
        set Hash = InitHashtable()
    endfunction

endlibrary
  • Dead Hero Revives
    • Events
    • Conditions
    • Actions
      • -------- This trigger runs when a hero is revived by the system. --------
      • -------- Dead_Hero = Revived hero. --------
      • -------- Dead_Revive_Point = Position of newly revived hero. --------
1717088350879.png

Variables and Triggers needs to use these exact names!

Then to use the system:
  • Demo
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
      • ((Triggering unit) is an illusion) Equal to False
    • Actions
      • -------- Set the Dead_ variables and call the ReviveDeadHero() function: --------
      • Set VariableSet Dead_Hero = (Triggering unit)
      • Set VariableSet Dead_Revive_Duration = (3.00 + (1.00 x (Real((Hero level of Dead_Hero)))))
      • Set VariableSet Dead_Revive_Point = ((Owner of Dead_Hero) start location)
      • Custom script: call ReviveDeadHero()
 

Attachments

  • Revive Dead Hero 1.w3m
    20.7 KB · Views: 4
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,287
There is a limit to how many dead heroes a single player can have. After that limited has been reached, any further hero deaths cause the most recent to die heroes to be removed from the game, permanently. This was likely done to prevent unit leaks in the case of campaigns or custom maps spamming dozens of heroes at a player.

To work around this, simply revive the heroes immediately upon death. Then hide the now living heroes somewhere such as a corner of the map. Then when it comes time to actually revive the hero you move it to the revive point and unhide it. This keeps the dead hero stack empty, reducing the chance of a hero getting removed by it.
 
Level 3
Joined
May 24, 2024
Messages
33
There is a limit to how many dead heroes a single player can have. After that limited has been reached, any further hero deaths cause the most recent to die heroes to be removed from the game, permanently. This was likely done to prevent unit leaks in the case of campaigns or custom maps spamming dozens of heroes at a player.

To work around this, simply revive the heroes immediately upon death. Then hide the now living heroes somewhere such as a corner of the map. Then when it comes time to actually revive the hero you move it to the revive point and unhide it. This keeps the dead hero stack empty, reducing the chance of a hero getting removed by it.
Hi friend,i did make the reviving trigger before as your idea.One of the feedback i received is, the hero was revived and suddenly disappeared.Finally i delete the trigger sadly.I just revive a hero(which is kept by local variables,and has only a profilephoto) for a player not many.
 
Level 3
Joined
May 24, 2024
Messages
33
I don't think heroes ever get removed from the game, but there is some revive limitations related to too many heroes, but I believe that's per player and you need to exceed ~7.

Anyway, it sounds like you've made a mistake in your revival system. Here's a very basic version that should always work:

REQUIRED:
vJASS:
library ReviveDeadHeroes initializer Init

    globals
        private hashtable Hash
    endglobals

    private function ReviveDeadHeroCallback takes nothing returns nothing
        local timer t = GetExpiredTimer()
        local integer id = GetHandleId(t)
        set udg_Dead_Hero = LoadUnitHandle(Hash, id, 0)
        set udg_Dead_Revive_Point = LoadLocationHandle(Hash, id, 1)
        call ReviveHeroLoc(udg_Dead_Hero, udg_Dead_Revive_Point, false)
        call TriggerExecute(gg_trg_Dead_Hero_Revives)
        call RemoveLocation(udg_Dead_Revive_Point)
        call DestroyTimer(t)
        set t = null
    endfunction

    function ReviveDeadHero takes nothing returns nothing
        local timer t = CreateTimer()
        local integer id = GetHandleId(t)
        call SaveUnitHandle(Hash, id, 0, udg_Dead_Hero)
        call SaveLocationHandle(Hash, id, 1, udg_Dead_Revive_Point)
        call TimerStart(t, udg_Dead_Revive_Duration, false, function ReviveDeadHeroCallback)
        set t = null
    endfunction

    private function Init takes nothing returns nothing
        set Hash = InitHashtable()
    endfunction

endlibrary
  • Dead Hero Revives
    • Events
    • Conditions
    • Actions
      • -------- This trigger runs when a hero is revived by the system. --------
      • -------- Dead_Hero = Revived hero. --------
      • -------- Dead_Revive_Point = Position of newly revived hero. --------
View attachment 474806
Variables and Triggers needs to use these exact names!

Then to use the system:
  • Demo
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
      • ((Triggering unit) is an illusion) Equal to False
    • Actions
      • -------- Set the Dead_ variables and call the ReviveDeadHero() function: --------
      • Set VariableSet Dead_Hero = (Triggering unit)
      • Set VariableSet Dead_Revive_Duration = (3.00 + (1.00 x (Real((Hero level of Dead_Hero)))))
      • Set VariableSet Dead_Revive_Point = ((Owner of Dead_Hero) start location)
      • Custom script: call ReviveDeadHero()
Much appreciate you pro.I will test it and get feedback for you.
 
Level 3
Joined
May 24, 2024
Messages
33
I don't think heroes ever get removed from the game, but there is some revive limitations related to too many heroes, but I believe that's per player and you need to exceed ~7.

Anyway, it sounds like you've made a mistake in your revival system. Here's a very basic version that should always work:

REQUIRED:
vJASS:
library ReviveDeadHeroes initializer Init

    globals
        private hashtable Hash
    endglobals

    private function ReviveDeadHeroCallback takes nothing returns nothing
        local timer t = GetExpiredTimer()
        local integer id = GetHandleId(t)
        set udg_Dead_Hero = LoadUnitHandle(Hash, id, 0)
        set udg_Dead_Revive_Point = LoadLocationHandle(Hash, id, 1)
        call ReviveHeroLoc(udg_Dead_Hero, udg_Dead_Revive_Point, false)
        call TriggerExecute(gg_trg_Dead_Hero_Revives)
        call RemoveLocation(udg_Dead_Revive_Point)
        call DestroyTimer(t)
        set t = null
    endfunction

    function ReviveDeadHero takes nothing returns nothing
        local timer t = CreateTimer()
        local integer id = GetHandleId(t)
        call SaveUnitHandle(Hash, id, 0, udg_Dead_Hero)
        call SaveLocationHandle(Hash, id, 1, udg_Dead_Revive_Point)
        call TimerStart(t, udg_Dead_Revive_Duration, false, function ReviveDeadHeroCallback)
        set t = null
    endfunction

    private function Init takes nothing returns nothing
        set Hash = InitHashtable()
    endfunction

endlibrary
  • Dead Hero Revives
    • Events
    • Conditions
    • Actions
      • -------- This trigger runs when a hero is revived by the system. --------
      • -------- Dead_Hero = Revived hero. --------
      • -------- Dead_Revive_Point = Position of newly revived hero. --------
View attachment 474806
Variables and Triggers needs to use these exact names!

Then to use the system:
  • Demo
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
      • ((Triggering unit) is an illusion) Equal to False
    • Actions
      • -------- Set the Dead_ variables and call the ReviveDeadHero() function: --------
      • Set VariableSet Dead_Hero = (Triggering unit)
      • Set VariableSet Dead_Revive_Duration = (3.00 + (1.00 x (Real((Hero level of Dead_Hero)))))
      • Set VariableSet Dead_Revive_Point = ((Owner of Dead_Hero) start location)
      • Custom script: call ReviveDeadHero()
Nothing wrong has happened so far,Thank you friend.I used to believe that variables saving the dead heroes will be replaced by new dead heroes.I wish no new problems of this come later.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,877
Nothing wrong has happened so far,Thank you friend.I used to believe that variables saving the dead heroes will be replaced by new dead heroes.I wish no new problems of this come later.
The variables in my setup aren't keeping track of the hero over time, they're set the moment that the hero dies and the moment that the hero revives. The issue is when you set those variables expecting them to have those same values X seconds later.
 
Last edited:
Level 3
Joined
May 24, 2024
Messages
33
The variables aren't keeping track of the hero over time, they're set the moment that the hero dies and the moment that the hero revives. The issue is when you set those variables expecting them to have those same values X seconds later.
Yeah pro,I just realized the problem is the variables lose their values when waiting.The heroes actually are not being cleaned by system.(i check the video,the player still remains the photo of it) You're really perceptive. Besides that,i get the feedback saying the hero owed by player could revive at first several times,when the game came to be stuck,they didn't appear anymore.i wonder that local variables like triggering unit may have a limited size,the excess will replace the previous ones.All right,just using the global variables like yours is ok.
 
Top