sizraide 4 Posted June 5, 2021 Hello, i'm creating a COOP mission where a player has to infiltrate a base and silently kill all enemies. and i'm creating an eventHandler that creates a trigger at players location when the enemy fires (when enemy detects player) Here is my setup, I have 11 enemies named from first1, first2, first3, first4, etc. In their init field I have Quote 0 = [first1] = execVM "objective1\enemy_detected.sqf"; Then in the enemy_detected.sqf I have Quote private _unit = player; private _unitEnemy = _this select 0; _unitEnemy addEventHandler ["Fired", { sleep 3; //playSound //titleText _tgr = createTrigger ["EmptyDetector", getPosWorld _unit]; _tgr setTriggerArea [15, 15, 15, false, 15]; _tgr setTriggerActivation ["ANYPLAYER", "PRESENT", "false"]; _tgr setTriggerStatements ["this", "activation enableAI "MOVE";", ""]; _tgr attachTo [_unit, [0,0,0]]; }]; sleep 1; _unitEnemy removeEventHandler ["Fired", 0]; Now my issue is when I load into the mission I don't receive any popup screen errors and nothing happens when the enemies start firing. I have an AI (called activation) that is on "disableAI "MOVE";" and will walk into a trigger area that will spawn enemies around the player in a separate script. (Supposed to represent that the enemies shooting attracted more enemies to player location) Also, I have a removeEventHandler to remove the added event as soon as the fired event happens. I'm also curious because I don't have much experience with scripting but would this work with COOP? because I created this script intended to work for COOP. Share this post Link to post Share on other sites
pierremgi 4739 Posted June 5, 2021 you could use trigger(s) with activation type: "detected by" . That's fine and you don't need the AI fires for triggering the code! The disableAi "move" limits drastically the possibility of the AI to fire (enemy must be in front of AI as it can't turn). Try with disableAI "path" instead. Anyway, just for fun: if (isServer) then { this disableAI "move"; this addEventHandler ["fired", { params ["_unit"]; _unit spawn { params ["_unit"]; while {alive _unit} do { sleep 1; if ( allPlayers findIf {_x distance _unit < 15} > -1) then { _unit enableAi "move"; }; }; }; _unit removeEventHandler ["fired",_thisEventHandler]; }]; }; in init field of concerned units. Share this post Link to post Share on other sites
sizraide 4 Posted June 6, 2021 10 hours ago, pierremgi said: you could use trigger(s) with activation type: "detected by" . That's fine and you don't need the AI fires for triggering the code! The disableAi "move" limits drastically the possibility of the AI to fire (enemy must be in front of AI as it can't turn). Try with disableAI "path" instead. Anyway, just for fun: if (isServer) then { this disableAI "move"; this addEventHandler ["fired", { params ["_unit"]; _unit spawn { params ["_unit"]; while {alive _unit} do { sleep 1; if ( allPlayers findIf {_x distance _unit < 15} > -1) then { _unit enableAi "move"; }; }; }; _unit removeEventHandler ["fired",_thisEventHandler]; }]; }; in init field of concerned units. Thanks for responding quick, before I test this I wanna learn how this script works because i'm trying to improve my knowledge in scripting. Would you mind telling me step by step why and what your script does in each line? Share this post Link to post Share on other sites