How to: Create a Creep Revival System

Tinki3

Special Member
Reaction score
418
Introduction

This tutorial will explain in great detail, how to create a creep revival system. To understand this tutorial properly, you will need some decent knowledge of how to use the World Editor - mainly triggers, and variables.

We will be covering how to revive creeps 1 by 1, some time after their death, at their original starting location.

So if you're having any trouble at all creating a revival system, or if you just want to know how its done, read closely, and open the World Editor; this tutorial will be the perfect guide for you.

The "Revive creeps 1 by 1" trigger has minor leaks.



Let's get started

We will be needing the following variables:

Creep_X - A real type variable, with an array size of 1.
Creep_Y - A real type variable, with an array size of 1.
Integer - An integer type variable.

creepsystemimage1variabgi7.jpg


The best way to initialize our creep's starting locations, is to use a trigger with a Map initialization event, and store their data using the help of our variables that we created earlier. We need to store every creeps starting locations so we know where to revive them when need be. We will be using each creeps X and Y values to accomplish this.

"Creep_X" will store all of our creep's X values and "Creep_Y" will store all of our creep's Y values. X and Y work like locations (Points), except they act more or less like offsets (co-ordinates), which work just fine in a revival system like we are going to produce.

"Integer" does something very important which I will explain soon enough.

So open up the trigger editor, and create a new trigger titled "Creep Revival System Initialization", or whatever, and add in the following:
Code:
Creep Revival System Initialization
    Events
        Map initialization
    Conditions
    Actions
        Unit Group - Pick every unit in (Units in (Playable map area) owned by Neutral Hostile) and do (Actions)
            Loop - Actions
                Set Integer = (Integer + 1)
                Unit - Set the custom value of (Picked unit) to Integer
So what have we done so far? We've picked every unit in the playable map area (the area that is inside the black border around your map), owned by Neutral Hostile (the player that usually owns creeps) and set that player's creep's custom values to that of the integer's value, so specific reference can be made in-future.

Why are we using "Integer" to set our creep's custom values?

Well, you see the "Loop Actions" located directly below our Unit Group function?

That loop will "loop" through every creep/unit Neutral Hostile owns, until it loops through the last one.

Thus, "Integer" will keep adding 1 to its current value through every loop and thus when we set the picked creep's custom values, it'll end up looking like the following set of data, which is just what we need:

1, 2, 3, 4, 5, 6... and it goes on, right up until the last creep's value, which is actually the total amount of creeps that were pre-placed in your map.

Our creep's custom values are also important for referring to specific variable array values.

So now we need to set those X any Y variables, to store each creep's starting locations, using a Custom Script code:
Code:
Creep Revival System Initialization
    Events
        Map initialization
    Conditions
    Actions
        Unit Group - Pick every unit in (Units in (Playable map area) owned by Neutral Hostile) and do (Actions)
            Loop - Actions
                Set Integer = (Integer + 1)
                Unit - Set the custom value of (Picked unit) to Integer
                Custom script:   set udg_Creep_X[udg_Integer] = GetUnitX(GetEnumUnit())
                Custom script:   set udg_Creep_Y[udg_Integer] = GetUnitY(GetEnumUnit())
You see those [ ] marks, with "udg_Integer" between them? They are crucial to each creep's X and Y values.

But how do they work? Well, since they have an array value, those variables have the ability to "duplicate" themselves, enabling us to refer back to each "duplicated" value individually. And, since we are using "Integer" as our array index, we'll end up getting Creep_X[1], Creep_X[2], Creep_Y[1], Creep_Y[2], (etc, etc..), with each value referring to each picked unit as they are picked through the loop in the unit group function.

Note that "GetEnumUnit()", refers to each unit that is picked inside the loop; its just the custom script version for picked unit.

---

Now that we've successfully initialized our creeps, we want to create a trigger that actually revives them.

So what's the best event to use in this case? "Unit - A unit Dies".

This event let's the trigger fire as soon as a unit dies, but, we want to be specific do we not? We need to add in a condition that checks who the dying unit belonged to, and if the dying unit was a "summoned" or not.

Why? Because otherwise the "dying unit" could've belonged to Player Red, who just lost a Footman in battle, or Player Blue, who just sacrificed an Acolyte for a Shade.

And why don't we want the dying unit to be a "summoned"? Simply because a summoned unit isn't a unit that was originally pre-placed on your map, and isn't what we want to revive, is it?

So create a new trigger titled "Revive Creeps 1 by 1", or whatever, and add in the following:
Code:
Revive Creeps 1 by 1
    Events
        Unit - A unit Dies
    Conditions
        ((Owner of (Triggering unit)) Equal to Neutral Hostile) and (((Triggering unit) is Summoned) Not equal to True)
    Actions
And now we probably would want to add in a wait to our actions, so the dying creep's revival time is delayed, for obvious reasons.

So what do we do now? Yes, we want to revive, or, re-create the dying creep (notice that I use "triggering unit" - DO NOT use "Dying unit" -> it will be overwritten by any other instances of the trigger).

Add the following action in to your trigger, below the wait action:
Code:
Unit - Create 1 [COLOR="Red"](Unit-type of (Triggering unit))[/COLOR] for [COLOR="red"]Neutral Hostile[/COLOR] at [COLOR="red"]((Center of (Entire map))[/COLOR] [COLOR="red"]offset[/COLOR] by [COLOR="red"](Creep_X[(Custom value of (Triggering unit))], Creep_Y[(Custom value of (Triggering unit))]))[/COLOR] facing (Random angle) degrees

You might be wondering "how do I get to the point where I have one massive line of text across my screen"

You will need to note that the unit is created at an offset:

creepsystemimage2step1de9.jpg


It's best to break the whole unit creation action down, if you're unsure:

Unit-type of (Triggering unit) - We want to re-create the type of unit that has died.

Neutral Hostile - We want to re-create the type of unit that has died, for Neutral Hostile, the "creep owner".

at ((Center of (Entire map)) offset by.. - We want to re-create the type of unit that has died, for Neutral Hostile, the "creep owner", at the Center of the Entire map, offset by our creeps original X and Y location, that we first initialized in the initialization trigger. Remember that our Creep's X and Y value is the key to the "offset".

(Creep_X[(Custom value of (Triggering unit))], Creep_Y[(Custom value of (Triggering unit))])) - Our dying creep will be recreated at the coordinates "Creep_X", and "Creep_Y", which are offset from the Centre of the Entire map. We use the Entire map as a centre, simply because it includes areas outside the playable map area - areas that units cannot reach, and since we are using X and Y coordinates, using playable map area would not give us the exact offset point of the creep's original location. Notice that for array index value, we are using the custom value of the triggering unit - this is because the unit's custom value tells the variable what array value needs to be used.

So, is there anything more left to do?

Yes, there is - we need to set the custom value of the "last created unit" to the custom value of the "triggering unit" (the dead creep).

Why? So if that last created unit dies, the "Creep_X" and "Creep_Y" variables know which array values to refer to again.

So add in the following line:
Code:
Unit - Set the custom value of [COLOR="Red"](Last created unit)[/COLOR] to (Custom value of (Triggering unit))

You should have all of the following:
Code:
Revive Creeps 1 by 1
    Events
        Unit - A unit Dies
    Conditions
        ((Owner of (Triggering unit)) Equal to Neutral Hostile) and (((Triggering unit) is Summoned) Not equal to True)
    Actions
        Wait 5.00 game-time seconds
        Unit - Create 1 (Unit-type of (Triggering unit)) for Neutral Hostile at ((Center of (Entire map)) offset by (Creep_X[(Custom value of (Triggering unit))], Creep_Y[(Custom value of (Triggering unit))])) facing (Random angle) degrees
        Unit - Set the custom value of (Last created unit) to (Custom value of (Triggering unit))
[Leak-fix-link for the above trigger]


A quick summary:

> A creep dies, the creep's name is Bobble.

> Bobble has a custom value of 4.

> When Bobble died, a trigger fired.

> The trigger told itself that Bobble wasn't a summoned unit, and that Bobble belonged to Neutral Hostile (Bobble is a creep).

> In no time at all, or, after a few seconds, Bobble was "revived", at the coordinates, "Creep_X[4]", "Creep_Y[4]", which had told the trigger where Bobble's original starting point was.

> The new Bobble also had its custom value set to 4, so that when it dies again, the trigger knows what Creep X & Y array indexes to use.


---

Well, we've hit the end of the road and I hope you learned a thing or 2 :)

If you've got any comments, suggestions, please feel free to share them.

This tutorial also includes a demo map (enjoy, and I hope it helps):
 

Attachments

  • Creep Revival System.w3x
    30.4 KB · Views: 1,921

waaaks!

Zinctified
Reaction score
255
nice tutorial, for GUI triggers Revival System, this is only the time i found GUI revive system, well theres some JASS or custom scripts, but i can understand a lot of that cause im studying JASS already....+rep Tinki3 ^^ hey i cant add..ohh shocks...
 

undeadorcjerk

The Ulitimate TheHelper.net Lurker
Reaction score
223
Good job on the tut. My rpg went out hte window along with the rest of my stuff when my computer crashed so i probably wont be getting around to using this, but other people certainly have been asking for this.
 

Oninuva

You can change this now in User CP.
Reaction score
221
Made one of these a while back. But this has better trigger explanations.
 

Hero

─║╣ero─
Reaction score
250
Hey mind if i Mention yo in my tutorial?
I made a tutoral on this in JASS.
 

MaaxeEvid

New Member
Reaction score
8
nice, last week im trying to develop this, i do, but many people cant ^^ i will + rep, but i dont have more to give :(
 
M

MikeTheGuy

Guest
If the air unit was owned by Neutral Hostile and was not summoned, then it fits the conditions and it would have been revived. Somebody correct me if I'm wrong, but as far as I know you don't need to specify wether or not it was an air unit.

Anyway, great tutorial, once I get finished laying out all the heroes for my map, I'll probably be using this. I never knew you could do it like this. +rep Tinki3
 

Prometheus

Everything is mutable; nothing is sacred
Reaction score
589
JASS:
function Trig_Unit_Revive_Conditions takes nothing returns boolean
    return (IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) == false) and (IsUnitType(GetTriggerUnit(), UNIT_TYPE_STRUCTURE) == false)
endfunction

function Trig_Unit_Revive_Actions takes nothing returns nothing
	local integer idu = GetUnitTypeId(GetTriggerUnit())
	local real rezx = GetUnitX(GetTriggerUnit())
	local real rezy = GetUnitY(GetTriggerUnit())
	local real face = GetUnitFacing(GetTriggerUnit())
	call CreateUnit(GetOwningPlayer(GetTriggerUnit()), idu, rezx, rezy, face)
endfunction

//===========================================================================
function InitTrig_Unit_Revive takes nothing returns nothing
    set gg_trg_Unit_Revive = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Unit_Revive, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_Unit_Revive, Condition( function Trig_Unit_Revive_Conditions ) )
    call TriggerAddAction( gg_trg_Unit_Revive, function Trig_Unit_Revive_Actions )
endfunction


Isn't this a lot easier, maybe not the summoned unit thing but it revives the creeps just fine. Though it doesn't revive at their starting location.
Just stick this in your map and your good to go.
 

Prometheus

Everything is mutable; nothing is sacred
Reaction score
589
Just re-read this.
If you only gave the global an array of one, why can you use it so many more times?
Also, I would think to use Point(X, Y) instead of an offset.
 
0

026sasuke026

Guest
Wow Awesome

:)

What can I say it's all there is......


Good Job..........
 
A

AK-47Pirates

Guest
I used this and its great, before I had it just: a unit dies - replace dead one with a new one at last ones corpse, which alows for leading them to fountain and going afk then come back with tons of xp, TY

Question:

I have a hero with Cannibalism, When he eats the corpses, the don't respawn, because it gets rid of the corpse, and they stay dead. How can i fix this, (So creeps respawn even w/o corpse) ??
 

Tinki3

Special Member
Reaction score
418
>How can i fix this

Hmm.
You'd have to get a bit tricky here.

You could "fake" the cannibalism by just having you click on the corpse, and having the hero play the animation, but just don't have the corpse eaten by the hero.

What I mean by this, is that you'd have to trigger the healing process for the caster. Is that possible for you?
 

Icyculyr

I'm a Mac
Reaction score
68
Does this not leak?

Code:
Unit - Create 1 (Unit-type of (Triggering unit)) for Neutral Hostile at ((Center of (Entire map)) offset by (Creep_X[(Custom value of (Triggering unit))], Creep_Y[(Custom value of (Triggering unit))])) facing (Random angle) degree


Unit - Create 1 (Unit-Type of (Triggering unit)) for Neutral Hostile at (Center of (Entire map)).

That creates 1 leak, you should edit your post :p

Cheers
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1
  • The Helper The Helper:
    The recipe today is Sloppy Joe Casserole - one of my faves LOL https://www.thehelper.net/threads/sloppy-joe-casserole-with-manwich.193585/
  • The Helper The Helper:
    Decided to put up a healthier type recipe to mix it up - Honey Garlic Shrimp Stir-Fry https://www.thehelper.net/threads/recipe-honey-garlic-shrimp-stir-fry.193595/

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top