Auss 208 Posted July 9, 2010 I have a script which spawns a unit _northgroup1 = [getMarkerPos "northspawn1", east, ["TK_INS_Warlord_EP1"]] call BIS_fnc_spawnGroup;_northgroup1 setCombatMode "RED"; _northgroup1 setBehaviour "aware"; _northgroup1 setSpeedMode "normal"; The problem I have is that I cant seem to work out how to detect when he is dead so it will trigger an objective. It works fine when I place a unit and call it northgroup1 and then put "not alive northgroup1" in a trigger. Any ideas? Share this post Link to post Share on other sites
pwnstar23 10 Posted July 9, 2010 (edited) if (!alive _northgroup1) then {}; Edited July 9, 2010 by pwnstar23 Share this post Link to post Share on other sites
Auss 208 Posted July 9, 2010 Thanks Pwnstar but that doesnt allow me to put it in a trigger. Share this post Link to post Share on other sites
MulleDK19 21 Posted July 9, 2010 Thanks Pwnstar but that doesnt allow me to put it in a trigger. Remove the _ before the name Share this post Link to post Share on other sites
Auss 208 Posted July 9, 2010 Remove the _ before the name Just tried that also with the same result. It still doesnt seem to detect that units dead when I shoot it. Share this post Link to post Share on other sites
HeliJunkie 11 Posted July 9, 2010 Remove the _ before the name Did you only remove the "_" form your statement in the trigger or also in your scripts ?They must match, and they should both be without undescore. Explanation: The Underscore declares the variable as local (or private). So "_northgroup1" is only "seen" by the script. If the script ends, all variables with "_" are destroyed and it is not possible to reference to it from the trigger. That's the reason why you can use "_northgroup1" in a triggerstatement (throws an error message). It can't use local (or private) variables. And if you type "northgroup1" in your triggerstatement its valid, but it doesn't reference to "_northgroup1"! So if you want to use a variable in a script also outside the script, you have to make it global (without "_"). Hope this will help you. And "not alive northgroup1" is for me the right statement for a trigger activation statement for your purpose. Share this post Link to post Share on other sites
Auss 208 Posted July 9, 2010 Did you only remove the "_" form your statement in the trigger or also in your scripts ?They must match, and they should both be without undescore. Thanks for the exlination HeliJUnkie,I was reading about local variables etc and thought this may have been an issue so I've removed the _ its now northgroup1. I then added a trigger and on condition: not alive northgroup1. and on activation hint "northgroup1 is dead" The unit spawns fine and starts running to a waypoint, when I kill him I dont get the hint still. Is it becasue the trigger has fired before the script has run? therefore trigger doesnt see Northgroup1 so does nothing? Share this post Link to post Share on other sites
MulleDK19 21 Posted July 9, 2010 Thanks for the exlination HeliJUnkie,I was reading about local variables etc and thought this may have been an issue so I've removed the _ its now northgroup1. I then added a trigger and on condition: not alive northgroup1. and on activation hint "northgroup1 is dead" The unit spawns fine and starts running to a waypoint, when I kill him I dont get the hint still. Is it becasue the trigger has fired before the script has run? therefore trigger doesnt see Northgroup1 so does nothing? _northgroup1 = [getMarkerPos "northspawn1", east, ["TK_INS_Warlord_EP1"]] call BIS_fnc_spawnGroup; _northgroup1 setCombatMode "RED"; _northgroup1 setBehaviour "aware"; _northgroup1 setSpeedMode "normal"; Just took a look at your code. This seems to create a group called northgroup1, and not a unit, right? I don't know that particular function (BIS_fnc_spawnGroup), but it looks to me as it spawns a group with as many units as you parse in parameter number 3 (In this case, only 1 unit will be in the group, TK_INS_Warlord_EP1). So, in this case, I would suppose that you need to do this in your trigger instead: !alive ((units northgroup1) select 0) This checks if the first unit in the northgroup1 group is dead. Trying to use alive on a group should throw an error though, but if you haven't made the game show script errors, then you won't see it... Try the above code, and report back. (Remember to not use the _ in the northgroup1 name anywhere) Share this post Link to post Share on other sites
Auss 208 Posted July 9, 2010 Thanks MulleDK19 !alive ((units northgroup1) select 0) Thats getting there, it now triggers the hint however as you mentioned it only works on the leader and noone else in the group. ---------- Post added at 05:31 PM ---------- Previous post was at 04:27 PM ---------- ({alive _x} count units northgroup1) < 1 This is what solved my problem. :) Share this post Link to post Share on other sites
cobra4v320 27 Posted July 29, 2010 (edited) Why are you using the BIS_fnc_spawnGroup on a single unit anyway? Try using this to spawn your unit _dude = _northgroup1 createUnit ["TK_INS_Warlord_EP",getMarkerPos "northspawn1", [], 0, "NONE"]; To check and see if all of your groups units are dead use this {alive _x} count units _northgroup1 == 0 Just change the 0 to a 1 if you want the trigger to go off if only one unit is alive and so on. Edited July 29, 2010 by cobra4v320 Share this post Link to post Share on other sites
RazorX 10 Posted July 29, 2010 (edited) I would rather use event handlers rather than triggers to check if single units (not groups) are dead. using event handlers is easier and much more beneficial, you just have to learn them Edited July 29, 2010 by RazorX Share this post Link to post Share on other sites