Heatseeker 0 Posted September 8, 2006 Condition (?): (! (alive unit) && (captive unit)) Doesnt seem to work together.. i have a unit that is setcaptive true in his init field, after he reaches a waypoint he is setcaptive false.. I want an objective to fail only if the unit is killed while being captive (not alive and captive), after he is setcaptive false nothing should happen.. But it doesnt work! I cant use those 2 conditions together. Im thinking that after he dies his captive status changes to false.. I could use a diferent way but now i just want to know... . Share this post Link to post Share on other sites
Rommel 2 Posted September 9, 2006 why do brackets? shouldnt it be this: !alive unit && captive unit Share this post Link to post Share on other sites
SevenBEF 0 Posted September 9, 2006 /post edited after correction/ ye it seems that when he dies after 0.5 second captive status is gone. this works though; put in the init field of that guy: this addEventHandler ["Killed",{if (captive (_this select 0)) then {hint "you failed"}}] edit: change the part after "then" to however you want it to react; maybe have a (end)trigger that checks for a condition for example condition: fail1 and you could make it like this: this addEventHandler ["Killed",{if (captive (_this select 0)) then {fail1 = true}}] Share this post Link to post Share on other sites
Heatseeker 0 Posted September 9, 2006 Thanks sevenBEF, if the guy dies his captive status automaticaly changes to false. Like: A guy setcaptive true and a trigger that activates if he is not captive (condition), you kill him it activates so you dont need to check if he's alive, seems strange and not very practical . Share this post Link to post Share on other sites
ProfTournesol 956 Posted September 9, 2006 <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">[/Killed Triggered when the unit is killed. Local. Passed array: [unit, killer] unit: Object - Object the event handler is assigned to killer: Object - Object that killed the unit So it should be : <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this addEventHandler ["Killed",{if (captive (_this select 0)) then {fail1 = true}}] _this select 1 would check the killer and not the killed. Share this post Link to post Share on other sites
SevenBEF 0 Posted September 9, 2006 So it should be :<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this addEventHandler ["Killed",{if (captive (_this select 0)) then {fail1 = true}}] _this select 1 would check the killer and not the killed. Ooops ehm like often just awaken when I wrote that post Thx for the correction indeed EDIT: Arf this doesn't work Share this post Link to post Share on other sites
Heatseeker 0 Posted September 9, 2006 And can the eventhandler be split and used has a trigger condition (without needing the variable?) Like this? Condition: unitname addEventHandler ["Killed",if (captive (_this select 0))] On activation: hint "oh no! the captive is dead!" The syntax is problably all wrong . But the eventhandler is still an if/then statement, yes? . Edit: EDIT: Arf this doesn't work No it doesnt, problably for the same reason alive doesnt, i will have to change it wich is a pitty but not a big problem, thanks guys . Share this post Link to post Share on other sites
SevenBEF 0 Posted September 9, 2006 Ok tested thisone before posting: Have a trigger set to true on the map with: activation: cap1 = false When setting the unit captive, in its condition add: unit setcaptive true; cap1 = true; same for setting to false: unit setcaptive false; cap1 = false; in the unit's initfield: this addEventHandler ["Killed",{if (cap1) then {hint "you failed"}}] this seems to work Share this post Link to post Share on other sites
Heatseeker 0 Posted September 9, 2006 The variable way is the way . Should i also declare those variables in the init file? edit: How about spliting the eventhandler in a trigger? . edit2: If it works using the variable workaround it should also work without the event handler? !alive && cap1 ?? If not im confused and out for a coffee . Share this post Link to post Share on other sites
SevenBEF 0 Posted September 9, 2006 The variable way is the way . Should i also declare those variables in the init file? edit: How about spliting the eventhandler in a trigger? . edit2: If it works using the variable workaround it should also work without the event handler? !alive && cap1 ?? If not im confused and out for a coffee . Perhaps; Seems that first solutions didn't work since the check on the captive status is slower than the status "captive" to be gone when the unit dies. So if the check takes time, so does assigning the variable. that's how I came to it. Guess a trigger would also do, but I don't see why you wouldn't use the EH since you can launch any script or whatever you want from the "then {.....} I'm sure there are some real pro's (that didn't reply yet) here who would recommend you to use the EH I think Share this post Link to post Share on other sites
Metal Heart 0 Posted September 9, 2006 You don't need any variables or even the captive condition, just have: 1. a trigger that fails the objective when the unit is not alive 2. on the waypoint that has setcaptive false, deletevehicle said trigger Share this post Link to post Share on other sites
Heatseeker 0 Posted September 9, 2006 Actually i dont even need the captive status has a condition (its only there to prevent friendly a.i. from failing the obj .), its all working fine, just wanted to know a workaround for the not alive/captive situation since it might come in handy. Thanks . Share this post Link to post Share on other sites