HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Respawning killed units

02-04-2006, 08:02 PM#1
Drek-ker
I'm doing a map for me and my friends and they wanted a trigger that when a unit dies in a region they get respawned in the middle of the same region.Any triggers for that?
02-04-2006, 08:26 PM#2
Thunder_Eye
Trigger:
Respawn
Collapse Events
Unit - A unit Dies
Collapse Conditions
(<Your Region>) contains (Dying unit)) Equal to True
Collapse Actions
Wait 30.00 seconds
Unit - Create 1 (Unit-type of (Dying unit)) for (Owner of (Dying unit)) at (<Your Region>) facing Default building facing degrees
02-04-2006, 09:00 PM#3
johnfn
That wont work 100% of the time. You have to set Dying unit to a variable and then recreate a unit based on that variable for it to work, because otherwise other units can die and then the respawned unit will be the wrong type of unit.
02-05-2006, 12:09 AM#4
iNfraNe
Thats not true. DyingUnit() is a local variable. It is true you should save the unit type tho, cuz the dead unit MIGHT be removed from the game before the 30 sec wait is over.
02-05-2006, 01:00 PM#5
Drek-ker
i'll do a wait for 20 seconds and see if it works and i'll add the variable if it doesnt work it doesnt matter
02-05-2006, 01:11 PM#6
Thunder_Eye
Oh yeah also If you just want it for a specific player youll have to add that to the conditions.

Trigger:
(Owner of (Dying unit)) Equal to <Your Player>

and you might want to change the "Wait 30 seconds" to "Wait game-time 30 seconds"
02-06-2006, 11:02 AM#7
Drek-ker
Thx for replies.
02-06-2006, 12:24 PM#8
Vexorian
DyingUnit is not a local variable it is a thread variable

Still that method is not safe, cause if the unit is exploded and doesn't leave a corpse, The dying unit will be removed - there won't be any unit after 30 seconds. So Unit type of Dying unit will return 0 and create unit will not respawn anything.


Trigger:
Respawn
Collapse Events
Unit - A unit Dies
Collapse Conditions
(<Your Region>) contains (Dying unit)) Equal to True
Collapse Actions
Custom Script: local integer t=GetUnitTypeId(GetTriggerUnit())
Custom Script: local integer p=GetPlayerId(GetOwningPlayer(GetTriggerUnit()))
Wait 30.00 seconds
Custom Script: set udg_Utypev = t
Custom Script: set udg_Pv = Player(p)
Unit - Create 1 (Utypev) for (Pv) at (<Your Region>) facing Default building facing degrees
02-06-2006, 01:13 PM#9
Thunder_Eye
Yeah my trigger was very basic, wasnt really sure how he wanted it.