Bon 12 Posted June 22, 2010 Hi guys. When a unit dies and respawns, it respawns into another entity. Retrieving this new entity if its the player is of course no problem, since the variable "player" always points to this unit. But how to retrieve the new entity if a playable AI is moved into it? A previously assigned variable (e.g. _unit) is not valid anymore after the AI dies, the statement "alive _unit" would never become true. What I am doing atm is storing the name of the AI unit (as this name never change) into "_name", checking for the statement {name _x == _name} count allUnits > 0 to become true. Now I am concerned about this checking to be too resources-hungry (especially when the allUnits array is very huge) and wonder if there's a more elegant way that I just can't find out on my own. Any suggestions? Share this post Link to post Share on other sites
Big Dawg KS 5 Posted June 22, 2010 (edited) IIRC their vehicleVarName stays the same when they respawn. Ex: _unit setVehicleVarName "Joe"; Now he will always be referenced by Joe, no matter how many times he respawns. waitUntil{!alive Joe}; hint "Joe is dead"; waitUntil{alive Joe}; Joe sideChat "I'm alive!"; Edited June 22, 2010 by Big Dawg KS Share this post Link to post Share on other sites
Bon 12 Posted June 22, 2010 Thanks for the response, but that apparently does not work. It works when you assign the vehicle varname in the editor. Using setvehiclevarname ( ---- btw it must look like this ;) ---- _varname = "Joe"; _unit setVehicleVarName _varname; _unit call compile format["%1=_this",_varname]; ) the varname content does not change automatically after respawn - its also stated in the wiki: setVehicleVarName I could improve the checking a little bit by using playableUnits instead of allUnits (as only playableUnits respawn) and the implicit assumption that in gerenal playableUnits is smaller than allUnits, but I don't think that's enough regarding to my concerns... Share this post Link to post Share on other sites
Big Dawg KS 5 Posted June 22, 2010 I see. My comref must be wrong (not surprising though). Share this post Link to post Share on other sites