HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Creep Respawn Trigger

01-28-2006, 04:37 AM#1
TheBlackMage01
Alrighty, I've made this trigger, which I expect to be called quite often in my map. The problem is, I cant quite get it to recreate the units. I am thinking the breakdown is between the If - Then - Else I have.

Ideas?

Trigger:
DeathRespawn
Collapse Events
Unit - A unit Dies
Collapse Conditions
(Owner of (Dying unit)) Equal to Neutral Hostile
Collapse Actions
Custom script: local unit udg_u = GetDyingUnit()
Custom script: local location udg_loc = GetUnitLoc(GetDyingUnit())
Custom script: local effect udg_effect = null
Custom script: call PolledWait(60)
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Number of units in (Units within 512.00 of loc matching ((((Owner of (Matching unit)) controller) Equal to User) and (((Matching unit) is A structure) Equal to True)))) Equal to 0
Collapse Then - Actions
Unit - Create 1 (Unit-type of u) for Neutral Hostile at (loc offset by (0.00, 0.00)) facing Default building facing (270.0) degrees
Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Human\MassTeleport\MassTeleportTarget.mdl
Special Effect - Destroy effect
Collapse Else - Actions
Do nothing
Custom script: call RemoveLocation(udg_loc)
Custom script: set udg_u = null
Custom script: set udg_loc = null
Custom script: set udg_effect = null
01-28-2006, 06:48 AM#2
Naakaloh
I believe your problem is here:

Trigger:
Actions
Custom script: local unit udg_u = GetDyingUnit()
Custom script: local location udg_loc = GetUnitLoc(GetDyingUnit())
Custom script: local effect udg_effect = null

and here:

Trigger:
Then - Actions
Unit - Create 1 (Unit-type of u) for Neutral Hostile at (loc offset by (0.00, 0.00)) facing Default building facing (270.0) degrees

The variable you're referring to when creating the unit is the global variable that you've created using the variable editor, but the declarations you used at the beginning of the actions don't modify the reference of the global variable.

You could modify the names of the local variables you're using and change the function that creates the unit to custom script, or more simply just set the global variables to the appropriate values and destroy/remove the locations/units.

Trigger:
DeathRespawn
Collapse Events
Unit - A unit Dies
Collapse Conditions
(Owner of (Dying unit)) Equal to Neutral Hostile
Collapse Actions
Set u = Dying Unit
Set loc = Position of Dying Unit
Custom script: call PolledWait(60)
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Number of units in (Units within 512.00 of loc matching ((((Owner of (Matching unit)) controller) Equal to User) and (((Matching unit) is A structure) Equal to True)))) Equal to 0
Collapse Then - Actions
Unit - Create 1 (Unit-type of u) for Neutral Hostile at (loc offset by (0.00, 0.00)) facing Default building facing (270.0) degrees
Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Human\MassTeleport\MassTeleportTarget.mdl
Set effect = Last Created Special Effect
Special Effect - Destroy effect
Collapse Else - Actions
Do nothing
Custom script: call RemoveLocation(udg_loc)
Custom script: call RemoveUnit(udg_u)

As a general rule: "udg" should only precede actual global variables. Also, since the global variables will be reused, you don't need to set them to 'null' when you finish using them.

I believe something like that should work without any problems.
01-28-2006, 12:37 PM#3
johnfn
Let me point you to my resources section, since I have a creep respawn trigger there :D

Anyways, Naakaloh, wouldn't this
Trigger:
Unit - Create 1 (Unit-type of u) for Neutral Hostile at (loc offset by (0.00, 0.00)) facing Default building facing (270.0) degrees
Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Human\MassTeleport\MassTeleportTarget.mdl
Set effect = Last Created Special Effect
Special Effect - Destroy effect
instantly create and destroy the special effect?

Also, another problem with your respawn trigger is that they respawn where they died. So if a creep chased a hero across the map, that's where he'd respawn. In general the way I averted this was to save the locations of all the creeps to an array, and then just find the array number that I needed and then respawn the creep there.
01-28-2006, 03:13 PM#4
TheBlackMage01
Thanks john, just one more thing. :)

Collapse JASS:
    call TriggerSleepAction( 5.00 ) // This wait could be as long as you want it to be before the creeps respawn.
I've changed the wait time to 60 seconds, but I need to add a condition to all of this. If, after 60 seconds, there are any player-owned buildings within 512.00 of the unit's location, simply dont spawn it. (Or even better, send it back into the loop where it waits until there is nothing)
01-28-2006, 04:17 PM#5
Naakaloh
Quote:
Anyways, Naakaloh, wouldn't this

Trigger:
Unit - Create 1 (Unit-type of u) for Neutral Hostile at (loc offset by (0.00, 0.00)) facing Default building facing (270.0) degrees
Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Human\MassTeleport\MassTeleportTarget.mdl
Set effect = Last Created Special Effect
Special Effect - Destroy effect

instantly create and destroy the special effect?

It might, but unless I'm mistaken, an effect will play it's animation once completely before being destroyed.

Also about looping the trigger, I'm not entirely sure, but I believe all you have to do is put the action that's something like "Trigger - Run this trigger", after the else instead of "Do nothing." Although that does seem strange to me, unless you're expecting the buildings to be destroyed or removed frequently.
01-31-2006, 08:06 AM#6
Pheonix-IV
A special effect with only one animation will play that animation once on birth and once on death, also at any time when it does an action like 'attack' a special effect with a death animation will play that the instant it is destroyed.