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

[Trigger] Advanced Respawn System (Creeps)

Status
Not open for further replies.
Level 3
Joined
Dec 31, 2008
Messages
46
This is useful for RPG's for creep respawn.

I know this probably leaks, but at the moment I don't care because I think this may be the only trigger out there like this.

Variables:

i - Integer | Init Value : 0
iMax - Integer | Init Value : Number of enemy units
unitcount - Integer | Init Value : 0
unitRef - Unit Array | Init Value : -None- | Array Size : Number of enemy units
unitRefType - Unit-Type Array | Init Value : -None- | Array Size : Number of enemy units
unitXY - Region Array | Init Value : -None- | Array Size : Number of enemy units


To find the number of enemy units on your map, Place the following trigger in your map.

  • Unit Count
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units owned by Player 10 (Light Blue)) and do (Actions)
        • Loop - Actions
          • Set unitcount = (unitcount + 1)
    • Game - Display to (All players) the text: (String(unitcount))
  • NPC Revive
    • Events
      • Unit - A unit owned by Player 10 (Light Blue) Dies
    • Conditions
    • Actions
      • Wait 60.00 seconds
      • Trigger - Run NPC Revive Repeat <gen> (checking conditions)
  • NPC Revive Repeat
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • unitRef[i] Equal to (Dying unit)
        • Then - Actions
          • Unit - Create 1 unitRefType[i] for Player 10 (Light Blue) at (Center of unitXY[i]) facing Default building facing degrees
          • Set unitRef[i] = (Last created unit)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • i Equal to iMax
            • Then - Actions
              • Set i = 0
            • Else - Actions
              • Set i = (i + 1)
          • Trigger - Run NPC Revive Repeat <gen> (checking conditions)
  • Set Units
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units owned by Player 10 (Light Blue)) and do (Actions)
        • Loop - Actions
          • Set unitRef[i] = (Picked unit)
          • Set unitRefType[i] = (Unit-type of (Picked unit))
          • Set unitXY[i] = (Region centered at (Position of (Picked unit)) with size (1.00, 1.00))
          • Set i = (i + 1)
 
Last edited:
Level 9
Joined
May 22, 2009
Messages
276
won't that first trigger show messages=to the number of units? Even tho this is nicely done, I don't think you had to make it this difficult, this can all be done in one trigger.
+rep for the hard work anyways, I still learned something from reading the triggers
 
Level 3
Joined
Dec 31, 2008
Messages
46
won't that first trigger show messages=to the number of units? Even tho this is nicely done, I don't think you had to make it this difficult, this can all be done in one trigger.
+rep for the hard work anyways, I still learned something from reading the triggers
Yes it will, but it is just there for reference on how many units there are. This trigger is more complicated then a simple when they die respawn, because it respawns them in their Original Location.

-EDIT- Fixed it to only display the number of units instead of 1-amount of units.
 
Level 3
Joined
Dec 31, 2008
Messages
46
The problem is this trigger leaks (bigtime), the UNITXY leaks and u can't fix it

As I am aware, but the unitxy has to remain for the respawn to spawn at their original location, otherwise, if a unit follows another unit into a town, then dies in the town, we do not want to unit to respawn in the town, instead we want them to respawn elsewhere.


Anyone who wants to make this script unleak, be my guest (Not trying to be arrogant about it.)
 
Level 9
Joined
May 22, 2009
Messages
276
I'm not sure if you can unleak it, also if you want to avoid the die in town bug, just make it so when an enemy unit enters the town he's instantly moved to a random point in the fighting area, same for when he dies, random point in fighting area
 
Level 3
Joined
Dec 31, 2008
Messages
46
I'm not sure if you can unleak it, also if you want to avoid the die in town bug, just make it so when an enemy unit enters the town he's instantly moved to a random point in the fighting area, same for when he dies, random point in fighting area

Could work, though for the RPG aspect, it wouldnt work =( None the less, Usually RPG maps that are multiplayer have save/load codes, and it wouldnt cause enough lag in one sitting, would it? (If I fix leaks everywhere except the unitxy?)
 
Status
Not open for further replies.
Top