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

[Solved] [Need Help!] - Creep Respawning System

Status
Not open for further replies.
Level 4
Joined
Oct 23, 2016
Messages
85
Hello!

I'm currently working on a large map with a lot of creeps. I've looked everywhere and allthough I've found plenty of respawning systems, they're either outdated, jass (which I dont understand very well) or just not what i'm looking for.

Anyway, I currently have a gui respawning system which requires me to set a lot of variables maually, which is taking forever with the amount of units I have, so I was wondering if there's anyone out there with a better (working) Idea.

What I need the system to do:

-Detect Units, and save their Types, Position and Rotation.
-Detect when a creep is killed and respawn the same creep type on the same location with the same rotation.

What would be nice extras:

-Configurable respawn timers
-The ability to save a group of creeps together, so they respawn at the same time and only after they've ALL been killed.
-Delaying creep respawns if there's a player owned unit close.

(-I want some creeps to have a chance to spawn a different type of creep after they've been killed, but i dont know how that would be possible to put into a general respawning trigger system... but who knows, there's some awesome Mappers out there :) )
(-Also, I want to make some units patrol after they've spawned. But again, no idea how this would fit in a general grigger system)

I did find something very close to what i'm looking for HERE, but it's vJass and seems to be outdated. If someone could update it or just show me how to get it working on my map, i'd be equally happy!
 
Level 6
Joined
Jun 4, 2017
Messages
172
This is a basic trigger that should be able to do the first 2 points(also the third point too, you just need to change that 30 seconds wait time with whatever time you want).
The variables that you need to make this trigger are 5:
Creep(Unit variable);
I(Integer variable);
J(Integer variable);
Position(Point variable);
Rotation(Real variable).
  • Test
    • Events
      • Unit - A unit owned by Neutral Hostile dies
    • Conditions
    • Actions
      • Set I = (I + 1)
      • Set Creep[I] = (Dying unit)
      • Set Position[I] = (Position of (Dying unit))
      • Set Rotation[I] = (Facing of (Dying unit))
      • Wait 30.00 seconds
      • Set J = (J + 1)
      • Unit - Create 1 (Unit-type of Creep[J]) for Neutral Hostile at Position[J] facing Rotation[J] degrees
      • Custom script: call RemoveLocation(udg_Position[udg_J])
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • I Equal to 8000
        • Then - Actions
          • Set I = 0
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • J Equal to 8000
        • Then - Actions
          • Set J = 0
        • Else - Actions
I didn't test it, so i don't know if it works, but I think it should.
EDIT1:Also, I forgot to say that you will need the Creep, Position and Rotation variables to be big arrays, like 8k. Also, I updated the trigger with the if-else statements so that there is no risk to go over the arrays size. I''ll see if I manage to add the other points that you asked.
 
Last edited:
Level 4
Joined
Oct 23, 2016
Messages
85
It works. Thanks! It's alredy better then what I had.

I'm gonna try to see if I can modify it to include some of the extras (specially the grouped mobs and unit proximity detection).

In the meantime, i'm still open for suggestions that include some of the extras!
 
Level 6
Joined
Jun 4, 2017
Messages
172
This is the version of the triggers that will respawn creeps in their original spawn points.
Variable used:
-Creeps(Unit group variable);
-I(Integer variable);
-J(Integer variable);
-X(Real variable with array of 1);
-Y(Real variable with array of 1);
-Angle(Real variable with array of 1);
-Position(Point variable);
-Creep(Unit variable with array of 1);

  • Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Creeps = (Units owned by Neutral Hostile)
      • Unit Group - Pick every unit in Creeps and do (Actions)
        • Giro - Actions
          • Set I = (I + 1)
          • Unit - Set the custom value of (Picked unit) to I
          • Set Angle[I] = (Facing of (Picked unit))
          • Set Position = (Position of (Picked unit))
          • Set X[I] = (X of Position)
          • Set Y[I] = (Y of Position)
          • Custom script: call RemoveLocation(udg_Position)
      • Set I = 0
      • Set Position = (Center of (Entire map))
  • Test
    • Events
      • Unit - A unit owned by Neutral Hostile dies
    • Conditions
    • Actions
      • Set I = (I + 1)
      • Set Creep[I] = (Dying unit)
      • Wait 30.00 seconds
      • Set J = (J + 1)
      • Unit - Create 1 (Unit-type of Creep[J]) for Neutral Hostile at (Position offset by (X[(Custom value of Creep[J])], Y[(Custom value of Creep[J])])) facing Angle[(Custom value of Creep[J])] degrees
      • Unit - Set the custom value of (Last created unit) to (Custom value of Creep[J])
Hope that helps ;)
 
Level 4
Joined
Oct 23, 2016
Messages
85
This is the version of the triggers that will respawn creeps in their original spawn points.
Variable used:
-Creeps(Unit group variable);
-I(Integer variable);
-J(Integer variable);
-X(Real variable with array of 1);
-Y(Real variable with array of 1);
-Angle(Real variable with array of 1);
-Position(Point variable);
-Creep(Unit variable with array of 1);

  • Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Creeps = (Units owned by Neutral Hostile)
      • Unit Group - Pick every unit in Creeps and do (Actions)
        • Giro - Actions
          • Set I = (I + 1)
          • Unit - Set the custom value of (Picked unit) to I
          • Set Angle[I] = (Facing of (Picked unit))
          • Set Position = (Position of (Picked unit))
          • Set X[I] = (X of Position)
          • Set Y[I] = (Y of Position)
          • Custom script: call RemoveLocation(udg_Position)
      • Set I = 0
      • Set Position = (Center of (Entire map))
  • Test
    • Events
      • Unit - A unit owned by Neutral Hostile dies
    • Conditions
    • Actions
      • Set I = (I + 1)
      • Set Creep[I] = (Dying unit)
      • Wait 30.00 seconds
      • Set J = (J + 1)
      • Unit - Create 1 (Unit-type of Creep[J]) for Neutral Hostile at (Position offset by (X[(Custom value of Creep[J])], Y[(Custom value of Creep[J])])) facing Angle[(Custom value of Creep[J])] degrees
      • Unit - Set the custom value of (Last created unit) to (Custom value of Creep[J])
Hope that helps ;)

My bad, should have been more clear :p

The units seem to be spawned at the edge of the map. I triple checked if I copied the triggers correctly but i think I did. Wouldn't "(X[(Custom value of Creep[J])], Y[(Custom value of Creep[J])]))" be the same value twice? so always offset by the same X as Y from the center of the map?


[Edit 1]: My 0/0 Coordinates are not the middle of my map. That might also be causing trouble.

[Edit 2]: Yep. Changed "Set Position = (Point(0.00,0.00))" . Working fine now! Ty!
 
Last edited:
Level 6
Joined
Jun 4, 2017
Messages
172
The units seem to be spawned at the edge of the map. I triple checked if I copied the triggers correctly but i think I did. Wouldn't "(X[(Custom value of Creep[J])], Y[(Custom value of Creep[J])]))" be the same value twice? so always offset by the same X as Y from the center of the map?
The triggers work very well in my tests.
"(X[(Custom value of Creep[J])], Y[(Custom value of Creep[J])]))" be the same value twice? so always offset by the same X as Y from the center of the map?
X and Y aren't the same, they are the coordinates of every neutral hostile units in the map, when you have to set them there is a function for the X called "X of point" and another for the Y called "Y of point" and they are completely different(at least, most of the time).
 
Level 4
Joined
Oct 23, 2016
Messages
85
The respawning is working fine now. I Still can't find a way to add any of the extras though.

But even if It's too complicated or not possible to add them, I still have the most important aspects of the system that I needed. It will save me lots of hours of tedious work.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
RG00 there are the following problems with your triggers...
  • Wait (TriggerSleepAction) is not an accurate game time delay. Depending on game speed and network latency the time might be considerably more or less than 30 game seconds. The wait also does not factor in pauses, eg by command or lag, so one could abuse such to get faster game time respawn.
  • If the creep is removed before the wait expires, eg due to being exploded or decaying, then the unit will resolve to null so the unit type will be 0 and no unit will respawn.
  • No idea what you are doing with your indexing logic but it will break after ~8,192 (or ~32,768) units are respawned.
  • It uses unit custom values. This might conflict with other usage of custom values such as unit indexers.
  • Map initialization actions leak a unit group.
Seeing how this is such a common problem there is bound to be dozens of ready to use solutions available online. I have personally made such a system at least twice before.
 
Level 11
Joined
May 16, 2016
Messages
730
What I need the system to do:

-Detect Units, and save their Types, Position and Rotation.
-Detect when a creep is killed and respawn the same creep type on the same location with the same rotation.
What would be nice extras:

-Configurable respawn timers
-The ability to save a group of creeps together, so they respawn at the same time and only after they've ALL been killed.
-Delaying creep respawns if there's a player owned unit close.
Done
(-I want some creeps to have a chance to spawn a different type of creep after they've been killed, but i dont know how that would be possible to put into a general respawning trigger system... but who knows, there's some awesome Mappers out there :) )
(-Also, I want to make some units patrol after they've spawned. But again, no idea how this would fit in a general grigger system)
Done
Don't follow examples with wait triggers. They don't count Raise Dead, Animate Dead or Dark Ranger ultimate ability. Better listen professionals (Standing a proud pose)

P.S. Patrol can't be set for Neutral Hostile Creep, because in the wc3 system creates additional AI Neutral that doesn't let to use patrol long. The example is set for the player 12 brown.
 

Attachments

  • RESPAWN.w3x
    31.5 KB · Views: 216
Level 4
Joined
Oct 23, 2016
Messages
85
Done
Don't follow examples with wait triggers. They don't count Raise Dead, Animate Dead or Dark Ranger ultimate ability. Better listen professionals (Standing a proud pose)

P.S. Patrol can't be set for Neutral Hostile Creep, because in the wc3 system creates additional AI Neutral that doesn't let to use patrol long. The example is set for the player 12 brown.

Ah, hi Fruit Forest! Your Triggers are like alien technology to me: They do awesome stuff way beyond my state of knowledge but i need a team of researchers to figure out how to use it right xD

Guess i'll get to it then.

[Edit]: could you maybe give me a quick explanation of what you did there axactly? Where do I specify the Regions for the Creep camps?

PS: Brown being the Creeps is not an option. I need the Unit name to show on mouseover. I'll just keep the patrols short enough so the Creeps dont reset or figure out something else.
 
Last edited:
Level 11
Joined
May 16, 2016
Messages
730
Ah, hi Fruit Forest! Your Triggers are like alien technology to me: They do awesome stuff way beyond my state of knowledge but i need a team of researchers to figure out how to use it right xD

Guess i'll get to it then.
You may ask if you get questions. The system is "alien one" only at first look. Really it is simple.
PS: Brown being the Creeps is not an option. I need the Unit name to show on mouseover. I'll just keep the patrols short enough so the Creeps dont reset or figure out something else.
The system can fit with Neutral creeps, just change the Creep_player in the RUN triggers. But patrols, unfortunetaly, won't work with it (if only you try to disable netural creep AI somehow but in this case creeps won't use skills.)
 
Level 4
Joined
Oct 23, 2016
Messages
85
But patrols, unfortunetaly, won't work with it
Do patrols not work at all? Or do you mean the problem that they reset if they walk too far from their guard spot? Could I maybe just use "move to" actions and short distances from the initial standing spot? (and a trigger that fires when a destiny region is entered by the creep, which sends the creep back)

Where do I specify the regions for creep camps in the trigger? [Edit 1] Do I copy the INDIVIDUL AREAGROUP for every camp?

[Edit 2] Is it possible to spawn the group 10 secs after the unis have left the spawn area, istead of just delaying it by 10 sec?

I'd rather not tinker with your trigger. I'm gonna break something ^^
 
Last edited:
Level 11
Joined
May 16, 2016
Messages
730
Where do I specify the regions for creep camps in the trigger?
Trigger RUN INDIVIDUAL AREAGROUP. there are 2 examples for area01 with player 12 and for area02 with player 12 too. In the area01 group also added two trolls that aren't in the region - so they also in the group but outside the area.
Do patrols not work at all? Or do you mean the problem that they reset if they walk too far from their guard spot? Could I maybe just use "move to" actions and short distances from the initial standing spot? (and a trigger that fires when a destiny region is entered by the creep, which sends the creep back)
I never do experiments with neutral hostile creeps.
 
Level 4
Joined
Oct 23, 2016
Messages
85
I think I understand most of the trigger now. So for more creep camps I just copy the actions in the RUN INDIVIDUAL AREA trigger.

I'm gonna give it a try and see if everything works.
[Edit 2] Is it possible to spawn the group 10 secs after the unis have left the spawn area, istead of just delaying it by 10 sec?

Could you maybe take a look into this? If this also works, that'll be all I need :)
 
Level 4
Joined
Oct 23, 2016
Messages
85
Aah then it alredy works that way. Awesome!

Sorry for taking so long to understand, this is beyond my skill :D

Ran it on my map. Everything seems to be working fine!

Yet again Fruit Forest saves my day! If not for you, I would probably still be stuck with making my Immolation spell :D
 
Level 18
Joined
Mar 16, 2008
Messages
721
I need a 5 min respawn for my Kings and Knights game mode map and this trigger doesn't work. As Dr Super Good pointed out above ^
workaround = changing decay time of either the bones or flesh of the unit to 1 sec longer than the trigger. So I did a 5 min (300 sec) wait and made the decay time of bones 5 min 1 sec (301 sec) and the trigger seems to be working at 300 sec wait time.

Edit: does anyone think all the bones could cause lag?
 
Level 3
Joined
Jan 24, 2014
Messages
24
This is the version of the triggers that will respawn creeps in their original spawn points.
Variable used:
-Creeps(Unit group variable);
-I(Integer variable);
-J(Integer variable);
-X(Real variable with array of 1);
-Y(Real variable with array of 1);
-Angle(Real variable with array of 1);
-Position(Point variable);
-Creep(Unit variable with array of 1);

  • Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Creeps = (Units owned by Neutral Hostile)
      • Unit Group - Pick every unit in Creeps and do (Actions)
        • Giro - Actions
          • Set I = (I + 1)
          • Unit - Set the custom value of (Picked unit) to I
          • Set Angle[I] = (Facing of (Picked unit))
          • Set Position = (Position of (Picked unit))
          • Set X[I] = (X of Position)
          • Set Y[I] = (Y of Position)
          • Custom script: call RemoveLocation(udg_Position)
      • Set I = 0
      • Set Position = (Center of (Entire map))
  • Test
    • Events
      • Unit - A unit owned by Neutral Hostile dies
    • Conditions
    • Actions
      • Set I = (I + 1)
      • Set Creep[I] = (Dying unit)
      • Wait 30.00 seconds
      • Set J = (J + 1)
      • Unit - Create 1 (Unit-type of Creep[J]) for Neutral Hostile at (Position offset by (X[(Custom value of Creep[J])], Y[(Custom value of Creep[J])])) facing Angle[(Custom value of Creep[J])] degrees
      • Unit - Set the custom value of (Last created unit) to (Custom value of Creep[J])
Hope that helps ;)

Tested and working on a map I am currently creating.

Thanks!
 
Status
Not open for further replies.
Top