TheGoldenStar 2 Posted December 3, 2020 i've been trying to make a small WW2 Mission which seemed fun. I wanted 2 fireteams to suppres the enemies while unloading from their boats, and that works just as fine, i needed to set aswell god mode to the unit cus otherwise enemies will just headshot the shit out of them, so i had this code embedded into the object init of the unit 1 and 2: this addEventHandler ["HandleDamage", {false}]; but then, i didn't want them to be alive for ever so what i did was, place a trigger and whenever a BLUFOR would enter the trigger area, the trigger will activate, the activation code is this one fireteam1 addEventHandler ["HandleDamage", {true}]; fireteam2 addEventHandler ["HandleDamage", {true}]; //since fireteam1 and fireteam2 are the names of the units Tho it just gives me "Generic Error in Expression" i don't really know what am i missing in here, I really need your help. I am aswell posting some screenshots down here so you can get a better understanding of what i am having in my editor. Thanks in advance to everyone! Spoiler Share this post Link to post Share on other sites
Harzach 2507 Posted December 3, 2020 fireteam1 and fireteam2 aren't "units," they are "groups" and must be handled as such: {_x addEventHandler ["HandleDamage", {true}]} forEach fireteam1; {_x addEventHandler ["HandleDamage", {true}]} forEach fireteam2; or { _y = _x; { _x addEventHandler ["HandleDamage", {true}] } forEach units _y; } forEach [fireteam1, fireteam2]; or _ftUnits = units fireteam1 + units fireteam2; { _x addEventHandler ["HandleDamage", {true}] } forEach _ftUnits; ...etc. 4 Share this post Link to post Share on other sites
pierremgi 4743 Posted December 3, 2020 Don't double handleDamage EH for nuts. Basically the event is the same. You just overwrite your previous code by another one. The last code wins but it's not a good habit. Keep on mind the syntax and parameters also. And no, fireTeam1 (2) here is not a unit but a group Name your trigger (trgBeaching or else) { _x addEventHandler ["handleDamage", { params ["_unit", "", "_damage"]; if (triggerActivated trgBeaching) then { _unit removeEventHandler ["handleDamage",_thisEventHandler ]; _damage } else {0} }] } forEach (units fireTeam1 + units fireTeam2); NOTE: The units will start to die under fire when the trigger is activated, no matter their positions. If you want they stay alive until entering the trigger (individually), just replace the condition: triggerActivated trgBeaching by _unit inArea trgBeaching That's all. 4 Share this post Link to post Share on other sites
Harzach 2507 Posted December 3, 2020 Ah, good catch RE: removeEH, @pierremgi 1 Share this post Link to post Share on other sites
TheGoldenStar 2 Posted December 4, 2020 Thanks to everyone for the answers i'll get along testing as soon as i can ❤️ EDIT: @Harzach @pierremgi You guys are the best everything is now working, Thanks for the help :)) { _x addEventHandler ["handleDamage", { params ["_unit", "", "_damage"]; if (triggerActivated trgBeaching) then { _unit removeEventHandler ["handleDamage",_thisEventHandler ]; _damage } else {0} }] } forEach (units fireTeam1 + units fireTeam2); 2 Share this post Link to post Share on other sites