• 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.

[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,219
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,219
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.
 
Too bad I am too lazy to create a variable when doing stuff quickly.

That was so the Topic owner didn't make the mistake lol. I know you don't use that. Just thought I should mention it since you didn't. Also you can make it easy when you paste your triggers here use find and replace to change it to a tempInteger.
 
Status
Not open for further replies.
Top