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

[Spell] Creep respawn

Status
Not open for further replies.
Level 8
Joined
Nov 9, 2011
Messages
326
So i got this open world kinda rpg map im working on i need this one thing and i need to know the best way to do it.

So there are camps of creeps that u kill for gold lvl up blabla...

Now i need each camp to respawn right after 1 min when all creeps of that camp are dead.
What is the best and easiest way to do that.
 
Level 7
Joined
Mar 6, 2014
Messages
203
So i got this open world kinda rpg map im working on i need this one thing and i need to know the best way to do it.

So there are camps of creeps that u kill for gold lvl up blabla...

Now i need each camp to respawn right after 1 min when all creeps of that camp are dead.
What is the best and easiest way to do that.

the easiest is something like this.
  • Event: time every 60 seconds
  • condition: number of unit in camp(region) less than or equal to ( how many creeps in camp)
  • Action: Create creeps
 
Level 8
Joined
Nov 9, 2011
Messages
326
the easiest is something like this.
  • Event: time every 60 seconds
  • condition: number of unit in camp(region) less than or equal to ( how many creeps in camp)
  • Action: Create creeps

yea but i need it to be at the same time all 3 creeps in camp(example) and i would need to store them all and their positions and all screw it i guess they wont respawn :D
anyways thanks for the reply
 
You can use an unit indexer, or hashtable.

When the game starts or a "reviveable unit" enters the world, store the x/y -coordinates as reals in x[index] and y[index] (reals), or hashtable. (Hashtable -> Use HanldeId of unit as parent key.)

When the unit dies, you just wait the needed duration and then create a new unit with same type at x/y, which you can read out of x/y[unit-index], or of hashtable with HandleId again.

Or you browse though hive/google, and you for sure will find a finished respawn system somewhere.
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
I'd try something like this.
(triggers are not tested)
  • init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Unit Group - Add Footman 0000 <gen> to creep_camps[1]
      • Set total_camps = 1
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • Set temp = (temp + 1)
          • Unit - Set the custom value of (Picked unit) to temp
          • Set respawn_loc[temp] = (Position of (Picked unit))
  • enter
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • Set temp = (temp + 1)
      • Unit - Set the custom value of (Triggering unit) to temp
      • Set respawn_loc[temp] = (Position of (Triggering unit))
  • respawn
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • For each (Integer A) from 1 to total_camps, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Triggering unit) is in creep_camps[(Integer A)]) Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (All units of creep_camps[(Integer A)] are dead) Equal to True
                • Then - Actions
                  • Unit Group - Pick every unit in creep_camps[(Integer A)] and do (Actions)
                    • Loop - Actions
                      • Custom script: local unit udg_u = GetEnumUnit()
                      • Wait 60.00 seconds
                      • Unit - Create 1 (Unit-type of u) for (Owner of u) at respawn_loc[(Custom value of u)] facing Default building facing degrees
                • Else - Actions
            • Else - Actions
 
If a unit indexer will ever be used, the system will mixup custom values, Chaosy.

And you always loop through all indices, if a unit dies. That can be avoided.

That all units of a "camp" must be dead might be a feature, but it's not what was asked for.

Both If-conditions might be combined in the loop.

Local units should be nulled. :p
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
Integer A / B should never be used. Make your own custom integer and use that for your looping instead. This is more efficient and faster than integer A / B.

Too bad I am too lazy to create a variable when doing stuff quickly.

OT:

I just noticed the trigger shown is buggy to say the least it spawns one unit at a time. The wait action should be moved slightly, but not a big deal.
 
Status
Not open for further replies.
Top