How would one go about making a trigger where if a unit dies it will respawn 30 seconds later at a given point? I don't know how to identify which player the unit belonged to and how to respawn it for that specific player.
I've tried the general wait 30 seconds and then create.. but for some reason if i put any sort of wait command before the create an error occurs saying the point is out of bounds or something.... but if i just make it instantly recreate it works.
I've also tried using a timer and making it run after last started timer ended... still same thing happened.
Also how do I work with leaderboards? i jsut need a simple one that keeps track of scores on each team.
Needless to say, these aren't word for word, but you'll hopefully get the idea.
EVENTS
-Any unit dies
LOCAL VARIABLES
CONDITIONS
ACTIONS
-Wait 30 seconds
-Create 1 (Unit type of (Dying unit)) at (Location of (Dying Unit)) for Player (Owner of (Dying unit)) facing Default build angle
I don't have my SC2 editor open, but that's how you would do it in WC3.
Events:
Unit - Any Unit dies
Conditions:
Owner of Triggering Player != 0
Owner of Triggering Player != 15
Actions:
General - Wait 1.0 Game Time seconds
Unit - Create 1 Unit type of Triggering Player for player Triggering Player at Start Area
With the wait action my unit never revives, if I remove the wait action my unit revives instantly.
Looking at several other forums in researching this seem the Wait action screws up the triggering unit/player target.
I suppose will need to make a trigger per player slot to work around this.
Okay so now how do i make it so if the unit who died belonged to someone in team 1 (player group) itll respawn in one spot... and if its team 2 then itll respawn in another spot.
As for your respawn timer... This is just an idea but what if you try:
Make a unit group (global variable) and in the death detection trigger add the unit that died to unit group. Also, add a custom value to the unit (Set Unit Custom Value) of 30.
Then you have another trigger which fires once per second, and it goes through the whole unit group and removes 1 from the custom value for each unit. If the value is then 0 for a unit, respawn unit and remove it from the unit group.
It's not a bug, it's the fact that you are waiting which causes a race condition. i.e EventUnit returns null. So storing a thread local copy of the owner/unit type is the way to go.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
How would one go about making a trigger where if a unit dies it will respawn 30 seconds later at a given point? I don't know how to identify which player the unit belonged to and how to respawn it for that specific player.
I've tried the general wait 30 seconds and then create.. but for some reason if i put any sort of wait command before the create an error occurs saying the point is out of bounds or something.... but if i just make it instantly recreate it works.
I've also tried using a timer and making it run after last started timer ended... still same thing happened.
Also how do I work with leaderboards? i jsut need a simple one that keeps track of scores on each team.
Needless to say, these aren't word for word, but you'll hopefully get the idea.
EVENTS -Any unit dies LOCAL VARIABLES CONDITIONS ACTIONS -Wait 30 seconds -Create 1 (Unit type of (Dying unit)) at (Location of (Dying Unit)) for Player (Owner of (Dying unit)) facing Default build angle
I don't have my SC2 editor open, but that's how you would do it in WC3.
Seems to be a bug in the Wait action
Events:
Unit - Any Unit dies
Conditions:
Owner of Triggering Player != 0
Owner of Triggering Player != 15
Actions:
General - Wait 1.0 Game Time seconds
Unit - Create 1 Unit type of Triggering Player for player Triggering Player at Start Area
With the wait action my unit never revives, if I remove the wait action my unit revives instantly.
so it IS a bug... but then how do people put in timed respawns like in SotIS and stuff?
Looking at several other forums in researching this seem the Wait action screws up the triggering unit/player target.
I suppose will need to make a trigger per player slot to work around this.
Okay so now how do i make it so if the unit who died belonged to someone in team 1 (player group) itll respawn in one spot... and if its team 2 then itll respawn in another spot.
Try something like this?
Variable
Team 1 = No Player Group
Team 2 = No Player Group
Event - Initialization
Actions:
Player Group - Add player 1 to Team 1
Player Group - Add player 2 to Team 2
ect...
Event - Any unit dies
Condition - Triggering player is in Team 1 == true
Action - Create unit of type triggering unit at center of region Team 1
but how do i do that kind of condition?? TT
As for your respawn timer... This is just an idea but what if you try:
Make a unit group (global variable) and in the death detection trigger add the unit that died to unit group. Also, add a custom value to the unit (Set Unit Custom Value) of 30. Then you have another trigger which fires once per second, and it goes through the whole unit group and removes 1 from the custom value for each unit. If the value is then 0 for a unit, respawn unit and remove it from the unit group.
Event - Unit Dies
Variable - player (int) - Integer = Owner of Unit (Trigger Unit)
Variable - unit (Unit) = Trigger Unit
Action - Wait
Action - Unit - Create 1 Unit type of unit for player player at Start Area
----------Might work
It's not a bug, it's the fact that you are waiting which causes a race condition. i.e EventUnit returns null. So storing a thread local copy of the owner/unit type is the way to go.