phronk 898 Posted October 27, 2016 Quick question: Is it necessary to remove eventHandlers from units that are killed upon death? I'm working on a large insurgency mission which will have quite a bit of AI active at a time, each AI unit with eventHandlers. For example: _badMan addEventHandler["Killed",{(_this select 1)addRating 2000;(_this select 0)removeAllEventHandlers "Killed";}];}; Do the EHs get automatically removed when the units are dead, whether it be a killed EH or not, or do they need to be removed? I'm asking from an optimization standpoint. Would it help memory, for example? Share this post Link to post Share on other sites
killzone_kid 1330 Posted October 27, 2016 If you delete unit, all EHs will be removed with it. If you are not deleting, some of the EH will continue to operate, like for example HandleDamage even if unit is dead. Killed EH will obviously not fire again because unit will be dead. Some event handlers will not fire after unit is dead but will still be checked. So it is better to remove all event handlers on killed event to be sure. Share this post Link to post Share on other sites
cuel 25 Posted October 27, 2016 You could introduce some bugs doing by removing all EHs (e.g mods). I'd suggest just checking if the unit is alive before doing anything. Share this post Link to post Share on other sites
phronk 898 Posted October 27, 2016 So is it plausably more optimized to give all spawned AI a killed EH like this: _badMan addEventHandler["Killed",{(_this select 1)addRating 2000;(_this select 0)removeAllEventHandlers "Killed";(_this select 0)removeAllEventHandlers "AnimChanged";(_this select 0)removeAllEventHandlers "HandleDamage";}];}; 1 Share this post Link to post Share on other sites
killzone_kid 1330 Posted October 27, 2016 So is it plausably more optimized to give all spawned AI a killed EH like this: _badMan addEventHandler["Killed",{ (_this select 1)addRating 2000;(_this select 0)removeAllEventHandlers "Killed";(_this select 0)removeAllEventHandlers "AnimChanged";(_this select 0)removeAllEventHandlers "HandleDamage";}]; }; I would say remove only EHs you added as cuel pointed out, there could be mods using own EHs, but then there could be bad mods that wont do cleanup too. Also https://community.bistudio.com/wiki/addRating has to be executed where killer is local and it most probably will not be where Killed is executed. Share this post Link to post Share on other sites
phronk 898 Posted October 28, 2016 Thanks for the help. Had no idea rating was local... While I'm asking questions, does anyone know how to remoteExec a simple hint parseText format ["I'm here: %1",mapGridPosition player]; command? I'm still new to remoteExec. Share this post Link to post Share on other sites
dachs 14 Posted October 28, 2016 Try this one: format ["I'm here: %1",mapGridPosition player] remoteExec ["hint"]; 1 Share this post Link to post Share on other sites
phronk 898 Posted October 28, 2016 format parseText ["I'm here: %1",mapGridPosition player] remoteExec ["hint"]; ​Also works, thanks a lot fellas! 1 Share this post Link to post Share on other sites