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

Problem reviving mulitple "Triggering Unit"

Status
Not open for further replies.
Level 2
Joined
Mar 17, 2016
Messages
18
[Solved] Problem reviving mulitple Heroes

Hi there!

I'm using an advanced creep revival system originaly created by Tinki3 which works flawlessly.
The system uses a Wait, before reviving "Triggering Unit" which means multiple units may be "dead" (waiting to be revived) at the same time and here comes my problem.

It seems like a maximum of 7 units can be stored and refererred to as a "Triggering Unit" at once.
This results in units not being revived when more than 7 units are "dead" at the same time and when you use a 60 second Wait like I do... alot of units are being forgotten.
Revived unit is always a hero using "Hero - Instantly revive (Triggering Unit)..."

Is there a way to increase this 7 unit cap? If not, is there another efficient way to store and refer to Triggering/Dying unit?

  • Creep Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area) owned by Player 11 (Dark Green)) and do (Actions)
        • Loop - Actions
          • Set CreepInteger = (CreepInteger + 1)
          • Unit - Set the custom value of (Picked unit) to CreepInteger
          • Custom script: set udg_CreepXValue[udg_CreepInteger] = GetUnitX(GetEnumUnit())
          • Custom script: set udg_CreepYValue[udg_CreepInteger] = GetUnitY(GetEnumUnit())
Edit
The problem seems to be the heroes, not that (Triggering Unit) can't store more than 7 units. The problem only occurs when heroes are waiting to become revived.

Solution
The main problem was that only seven heroes could be dead at the same time. When the eighth hero died, the hero that died first was permanently removed from the game. This happened frequently during my "wait"-function. That's why I removed the "wait" and revived the hero instantly at an area outside playable map area. The "wait"-function now occurs when hero is already revived! Simple fix.

  • Basic Creep Revive
    • Events
      • Unit - A unit owned by Player 11 (Dark Green) Dies
    • Conditions
    • Actions
      • Wait 60.00 seconds
      • Set TempPoint = ((Point(0.00, 0.00)) offset by (CreepXValue[(Custom value of (Triggering unit))], CreepYValue[(Custom value of (Triggering unit))]))
      • Hero - Instantly revive (Triggering unit) at TempPoint, Hide revival graphics
      • Custom script: call RemoveLocation (udg_TempPoint)
      • Unit - Set the custom value of (Last created unit) to (Custom value of (Triggering unit))
      • Hero - Set (Last created unit) Hero-level to ((Hero level of (Triggering unit)) + 4), Hide level-up graphics
  • INSTANT Revive
    • Events
      • Unit - A unit owned by Player 11 (Dark Green) Dies
    • Conditions
    • Actions
      • Set TempPoint = (Center of CreepRevivalArea <gen>)
      • Unit - Create 1 (Unit-type of (Triggering unit)) for Player 11 (Dark Green) at TempPoint facing Default building facing degrees
      • Custom script: call RemoveLocation (udg_TempPoint)
      • Unit - Set the custom value of (Last created unit) to (Custom value of (Triggering unit))
      • Hero - Set (Last created unit) Hero-level to ((Hero level of (Triggering unit)) + 4), Hide level-up graphics
This first trigger instantly revives the hero at the region "CreepRevivalArea" which is outside the playable map area.

  • Revival time and Teleportation
    • Events
      • Unit - A unit enters CreepRevivalArea <gen>
    • Conditions
    • Actions
      • Wait 60.00 seconds
      • Set TempPoint = ((Point(0.00, 0.00)) offset by (CreepXValue[(Custom value of (Triggering unit))], CreepYValue[(Custom value of (Triggering unit))]))
      • Unit - Move (Triggering unit) instantly to TempPoint
      • Custom script: call RemoveLocation (udg_TempPoint)
This second trigger waits before moving the hero to it's "Starting Position". The Wait in this trigger is the time the hero is "dead".

In conclusion: By reviving the unit instantly when it is killed, we avoid the problem that Warcraft can only store 7 dead heroes (per player). By reviving it outside the map, we're simulating it being dead.


1. Using Local Variables:
  • Basic Creep Revive
  • Events
  • Unit - A unit owned by Player 11 (Dark Green) Dies
  • Conditions
  • Actions
  • Custom script: local unittype array udg_TempUnitType
  • Custom script: local location array udg_TempLocation
  • Custom script: local integer array udg_TempInteger
  • Set TempInteger[0] = (CreepId[(Custom value of (Triggering unit))])
  • Set TempUnitType[0] = (Unit-type of (Triggering unit))
  • Set TempLocation[0] = (CreepLocValue[TempInteger[0]])
  • Set TempInteger[1] = (Hero experience of (Triggering unit))
  • Wait 60.00 game-time seconds
  • Unit - Create 1 TempUnitType[0] for Player 11 (Dark Green) at TempLocation[0] facing Default building facing degrees
  • Hero - Set (Last created unit) experience to TempInteger[1], Hide level-up graphics
  • Set CreepId[(Custom value of (Last created unit))] = (TempInteger[0])
  • Custom script: call RemoveLocation(udg_TempLocation[0])
  • Custom script: set udg_TempLocation[0] = null


2. Making the heroes normal units and then add abilities that add to unit's health, defence, attack speed etc.
For each revive, the abilities would be set to a higher level, making the unit more powerful.
 
Last edited:
It should not be a problem with (Triggering Unit). It should work fine.
What can happen is that the unit gets removed from game after the 60 seconds and so (Triggering Unit) will try to refer to a unit that doesn't exist anymore which can lead to malfunction.

You can print the name of unit before the 60 seconds wait and after, to check it. Use TriggeringUnit as reference.

It can be set somewhere in editor how long unit need to decay, or if they should decay at all.
 
Level 2
Joined
Mar 17, 2016
Messages
18
It should not be a problem with (Triggering Unit). It should work fine.
I'm using heroes and the Hero - Revive (instantly) action and therefore the decay-times doesn't matter.
I've also tried with shorter wait-values (even 5 sec), but whenever more than 7 units die the units that died first are forgotten.
 
Last edited:
Level 2
Joined
Mar 17, 2016
Messages
18
As I stated before. The system works great other than forgetting units. The maximum revived unit is ALWAYS 7 in my case.
I have tried deactivating all other triggers but with no effect.
Food cap is set so that all heroes can respawn.

  • Creep Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area) owned by Player 11 (Dark Green)) and do (Actions)
        • Loop - Actions
          • Set CreepInteger = (CreepInteger + 1)
          • Unit - Set the custom value of (Picked unit) to CreepInteger
          • Custom script: set udg_CreepXValue[udg_CreepInteger] = GetUnitX(GetEnumUnit())
          • Custom script: set udg_CreepYValue[udg_CreepInteger] = GetUnitY(GetEnumUnit())
  • Basic Creeps Revive
    • Events
      • Unit - A unit owned by Player 11 (Dark Green) Dies
    • Conditions
    • Actions
      • Wait 10.00 seconds
      • Hero - Instantly revive (Triggering unit) at ((Point(0.00, 0.00)) offset by (CreepXValue[(Custom value of (Triggering unit))], CreepYValue[(Custom value of (Triggering unit))])), Hide revival graphics
 
Hm.. This seems strange indeed. The code should work not for only a limited amount.
There might be something else, hardcoded, or object editor data maybe that blocks it for heroes.

I try to look for similar problems.. if you have the solution, please post it, too.

Edit:

Okay, so the limit for hero icons on left side also seems to be seven.
Also the very same issues someone had here: http://www.wc3c.net/showthread.php?t=35699
Though, no solution was found.

It seems it's pretty much only hero-related, so I guess it is limiated for each player.
I know you can have more heroes at once, but when more than 7 heroes are dead at same
time, then seems to be a issue. As there is queue or something and someone gets overridden.

I also don't know now how to fix this. :s
 
Last edited:
Level 2
Joined
Mar 17, 2016
Messages
18
Hm.. This seems strange indeed. The code should work not for only a limited amount.
The thread you linked describes the exact same problem as I have. Thank you for your help this far! The problem seems to occur only when reviving Heroes. (Triggering Unit) seems to be able to store many more than 7 units.

Do your units have to be heroes or do you only use it to revive them?
Unfortunately yes, since the dying unit should gain levels to become more powerfull as it respawn.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
You dont really have to revive it.
If you can just take the experience from the "hero" when he dies and apply that to a new "hero" instead of reviving the old one, you can then have technically infinite units.

The only problem is, you need a slightly more advanced system of doing the creep respawning.
 
Level 2
Joined
Mar 17, 2016
Messages
18
You dont really have to revive it.
If you can just take the experience from the "hero" when he dies and apply that to a new "hero"...
Smart! The only problem with that is that you still have to reference to (Triggering Unit) when you create a new one and that doesn't work either... still max 7 revived.

  • Basic Creep Revive
    • Events
      • Unit - A unit owned by Player 11 (Dark Green) Dies
    • Conditions
    • Actions
      • Set CreepRevivalLevelStore[(Custom value of (Triggering unit))] = (Hero level of (Triggering unit))
      • Wait 10.00 seconds
      • Unit - Create 1 (Unit-type of (Triggering unit)) for Player 11 (Dark Green) at ((Point(0.00, 0.00)) offset by (CreepXValue[(Custom value of (Triggering unit))], CreepYValue[(Custom value of (Triggering unit))])) facing Default building facing degrees
      • Unit - Set the custom value of (Last created unit) to (Custom value of (Triggering unit))
      • Hero - Set (Last created unit) Hero-level to (CreepRevivalLevelStore[(Custom value of (Last created unit))] + 4), Hide level-up graphics
I tried it with normal units as well and they respawn as wanted...
 
Level 2
Joined
Mar 17, 2016
Messages
18
The unit type needs to be saved before the wait and read out after the wait.
I tried that too but it seems like that isn't the problem.
The problem seems to be that (Triggering Unit) only can remember 7 specific Hero-references. That's why it doesn't matter if I reference to Unit-type and Level of (Triggering Unit) since I'm still referencing to properties of (Triggering Unit).

Ill be going home soon... will take a look at my respawn system tonight...
Please do so! I also begin to understand that I might have to consider work-arounds.
Either de-hero the units and settle with them not becoming stronger
or
Reducing the amount of heroes and have shorter revival-times so that the risk of 7 heroes being dead at the same is reduced...

But I'm hoping you can bring me something better!
 
Level 12
Joined
Jan 2, 2016
Messages
973
The problem seems to be that (Triggering Unit) only can remember 7 specific Hero-references. That's why it doesn't matter if I reference to Unit-type and Level of (Triggering Unit) since I'm still referencing to properties of (Triggering Unit).

If that really was the case - then it wouldn't have been working for unlimited amount of units.
It's more likely that the problem lies in the "revive hero" function OR the way the game handles more than 7 heroes, owned by the same player at the same time.
 
Level 2
Joined
Mar 17, 2016
Messages
18
It's more likely that the problem lies in the "revive hero" function OR the way the game handles more than 7 heroes, owned by the same player at the same time.
Please view previous replies. It is not the "revive hero" function.
I believe your second option is the accurate one and I'm hoping to work around it.

I think you misunderstood me on de-hero the units.
Oh, okay. That's much better!
Are there any tutorials out there on how to de-hero units? Could you link it or explain to me?
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
As I mentioned before, de-hero units is really hard to make.
And I have failed to do so many times.
It is a last resort if everything else fails.

Well... I created a creep behavior system for my maps, cause I want them to only start their respawn timer once all creeps in one camp are killed, and I want them to regenerate health when they are not in combat, and I want them to return to their starting positions when they are not in combat, and I want them to... a hell of a lot more than that.

In that system, heroes do work, so it is definately not impossible to do so.
I can give you the system but you probably dont wan 90% of its features, so that would only be a step back.

What you can try is to make a local variable in a custom script and use that one instead of triggering unit.
Then you can at least be sure it is not triggering unit that fails.

  • Actions:
    • Custom Script: local unit udg_Unit
    • Variable - Set Unit = (Triggering unit)
    • ... << do all other stuff
    • Variable - Set Unit = (No unit)
 
Level 18
Joined
Nov 21, 2012
Messages
835
indeed, strange problem,
I can confirm that only 7 heroes are remembered,
If we got 7 dead heroes and then if 8th hero dies then first from those 7 is removed. I mean this one who died as first in that 7 group is completely removed from the game. It happends in moment when 8th hero becomes revivable. I tryed this

  • Untitled Trigger 005
    • Events
      • Player - Player 1 (Red) types a chat message containing pal as An exact match
    • Conditions
    • Actions
      • Game - Display to (All players) the text: (try to revieve hero + (Name of Hero[1]))
      • Game - Display to (All players) the text: (try to revieve hero + (Name of Paladin 0001 <gen>))
      • Hero - Instantly revive Hero[1] at Point[1], Show revival graphics
      • Hero - Instantly revive Paladin 0001 <gen> at Point[1], Show revival graphics
none works, game prints no-name for paladin hero,
unit variable Hero[1] is also null.
 
Level 2
Joined
Mar 17, 2016
Messages
18
Instead of remembering the hero, remember the data you need...

I tried that using global Array-variables but i still needed to reference to Triggering unit through them...
Can Local Variables store more than one value at the same time?
What I mean is: Can
JASS:
local unittype udg_UnitType
remember several Unit-types at once? That would solve my problem.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
No you do NOT want to have the reference to the original unit.
You will create a new unit and give it the same xp.

The local variables store one thing, but because they are bound to the function call, the call of the same function with different input will cause it to have other data than the other function calls.

... technically yes they can store multiple values
 
Level 2
Joined
Mar 17, 2016
Messages
18
... technically yes they can store multiple values
I can see how that can help me. However, I came up with a simple way of doing it without using own-created local variables! It may not be the best when using an advanced revival system but it's definately enough for me and it revies the creeps perfectly. Se the original post for my solution!

Also, if I can figure out how to do it, I will +rep you Wietlol and IcemanBo for wholehartedly trying to help me out!
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
That solution is pretty horrible because
1. TempPoint can be overwritten and
2. The second trigger will also run for all other units that enter that area.

Simply use the method that I told a few posts back.
Remember the data you need and create a new unit.
 
Level 2
Joined
Mar 17, 2016
Messages
18
That solution is pretty horrible because
1. TempPoint can be overwritten and
2. The second trigger will also run for all other units that enter that area.

1. TempPoint isn't overwritten. Also, the custom value of the unit survives the whole process meaning that I can reference to it's coordinates anytime.
2. The area is outside the map meaning no other units will enter it.

I chose this method because I'm not comfortable with JASS and own-made local variables! You could always post your solution in grater detail, and I'll put it as an alternative solution.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
"TempPoint isn't overwritten"
TempPoint is a temporary variable it seems to me, so anything that can run between those triggers that uses it will overwrite the variable.

Also, using the custom value of a unit is quite forbidden in uploaded resources.
I dont know where you have your creep respawn system from but you should use a unit indexer and create an array to store the CreepInteger in.

On top of that, a location with offset is pretty useless, not to mention that you create a location that you do not remove.

In any case:
  • Basic Creep Revive
    • Events
      • Unit - A unit owned by Player 11 (Dark Green) Dies
    • Conditions
    • Actions
      • Custom script: local unittype array udg_TempUnitType
      • Custom script: local location array udg_TempLocation
      • Custom script: local integer array udg_TempInteger
      • Set TempInteger[0] = (CreepId[(Custom value of (Triggering unit))])
      • Set TempUnitType[0] = (Unit-type of (Triggering unit))
      • Set TempLocation[0] = (CreepLocValue[TempInteger[0]])
      • Set TempInteger[1] = (Hero experience of (Triggering unit))
      • Wait 60.00 game-time seconds
      • Unit - Create 1 TempUnitType[0] for Player 11 (Dark Green) at TempLocation[0] facing Default building facing degrees
      • Hero - Set (Last created unit) experience to TempInteger[1], Hide level-up graphics
      • Set CreepId[(Custom value of (Last created unit))] = (TempInteger[0])
      • Custom script: call RemoveLocation(udg_TempLocation[0])
      • Custom script: set udg_TempLocation[0] = null
 
Status
Not open for further replies.
Top