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

Replacing the died unit every time when it dies !

Status
Not open for further replies.
Level 6
Joined
Sep 24, 2015
Messages
174
hi,

How to make a unit "respawn" or "recreate the same unit" every time when this unit dies... i did that trigger :

  • Gold supplier repop
    • Evénements
      • Unité - Gold supplier - smallest (1 gold) 0016 <gen> Meurt
    • Conditions
    • Actions
      • Partie - Display to (All players) the text: The smallest gold s...
      • Unité - Create 1 Gold supplier - smallest (1 gold) for Neutre Hostile at (Center of smallest gold supp <gen>) facing Orientation bâtiment par défaut degrees
It recreate a unit in the region but it does it only 1 time and i really dont know how to recreate it everytime it dies...please...somebody saaaaaaaaaaave me (smallville theme) xD
 
Level 6
Joined
Feb 6, 2015
Messages
266
You could do it without triggers, just add to the unit "Resurrect" spell and lower its cooldown.
 
Level 1
Joined
Jan 24, 2014
Messages
6
2 popural Russian Tag maps do contain arenas with respawning creeps. They use Hydra ability: configure it so it spawns 1 (insert creep unit-type).
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,197
One simple approach for a timed respawn system using TriggerSleepAction (not that accurate, recommend some leak fixed version of PolledWait instead for sufficient accuracy) is to assign all creeps a creep spawn structure (unique index in parallel arrays). Such assignment can be done by a unit indexer (easy, GUI friendly) or Hashtable with Handle parent and key child (remember to remove mappings to prevent a leak). When the unit dies you lookup its spawn index (custom value if unit indexer is used, hashtable lookup otherwise) and save it in a local variable (Custom Text/JASS only feature). You then wait the desired respawn time before using the data from the creep spawn structure to create a new creep at the appropriate location. If using the hashtable remember to add a new mapping for it so it can be respawned again.
 
Level 28
Joined
Mar 25, 2008
Messages
2,955
( 1.) Make a region where the creep should respawn )
2.) Set a point variable to whatever position in that region (random maybe?)
3.) Use as Event: Unit - A unit (owned by player x?) dies
4.) Check for the dying unit via unit-type comparison
5.) Create 1 unit of the same unit type at the point you specified
6.) Do a leak cleanup

The reason why your trigger doesn't work multiple times is because you set the event so it will only affect Gold supplier - smallest (1 gold) 0016 and only once because the unit is removed after dying. You'll need to check for the unit type dying and perform the actions after that.
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
( 1.) Make a region where the creep should respawn )
2.) Set a point variable to whatever position in that region (random maybe?)
3.) Use as Event: Unit - A unit (owned by player x?) dies
4.) Check for the dying unit via unit-type comparison
5.) Create 1 unit of the same unit type at the point you specified
6.) Do a leak cleanup

The reason why your trigger doesn't work multiple times is because you set the event so it will only affect Gold supplier - smallest (1 gold) 0016 and only once because the unit is removed after dying. You'll need to check for the unit type dying and perform the actions after that.


Works but there are flaws.

1. Not dynamic, all units will respawn at the same location.
2. There is an event for ANY unit dies, it's better.
3. The unit is respawned instantly, but he requested a delay
 
Status
Not open for further replies.
Top