JR Nova 24 Posted April 13, 2019 Hello I am trying to create an alert level system where if the player kills a civilian, then AAF units are spawned that hunt the player down, and if the player kills an AAF unit, even more AAF come for the player and eventually a heli comes and engages the player. I need it to be MP compatible and have different alert levels for each player though and not a universal level. What I have tried so far is creating a script and spawning units whenever a civ or AAF unit is killed. civKilled.sqf Spoiler _civkilled = addMissionEventHandler [ "EntityKilled", { params[ "_killed", "_killer", "_instigator", "_pos", "_police" ]; if ( (_instigator isEqualTo player) && (side group _killed isEqualTo civilian) ) then { _instigator setCaptive false; _pos = [ _killer, [50,150]] call SHK_pos; _police = [_pos, resistance, 1 + (random 2)] call bis_fnc_spawngroup; _stalking = [_police, group _instigator,nil,10,{_instigator distance _police < 300},"mkrStation"] spawn BIS_fnc_stalk; }; }]; _copkilled = addMissionEventHandler [ "EntityKilled", { params[ "_killed", "_killer", "_instigator", "_pos", "_police" ]; if ( (_instigator isEqualTo player) && (side group _killed isEqualTo resistance) ) then { _instigator setCaptive false; _pos = [ _killer, [50,150]] call SHK_pos; _police = [_pos, resistance, 3 + (random 3)] call bis_fnc_spawngroup; _stalking = [_police, group _instigator,nil,10,{_instigator distance _police < 300},"mkrStation"] spawn BIS_fnc_stalk; }; }]; This script works, but it gets out of hand pretty quickly when you start killing AAF units, so I was trying to make an alert level type system where if you kill a civ, that gives you one point, and killing an AAF unit gives you 3 points. I'm trying to have AAF spawn 1-3 units when you have less than 3 points, 3-6 units when you have 3-10 points, and spawn more units plus a vehicle over that then eventually a heli that hunts you as well. Since I want each player to have their own alert level, I thought maybe putting the script in the initPlayerLocal would do the trick but units aren't even spawning when I put the script in there so I really have no idea where to go from here. initPlayerLocal.sqf Spoiler _alertLevel = 0; //killed EventHandlers _civkilled = addMissionEventHandler [ "EntityKilled", { params[ "_killed", "_killer", "_instigator", "_pos", "_police" ]; if ( (_instigator isEqualTo player) && (side group _killed isEqualTo civilian) ) then { _alertLevel = _alertLevel + 1 }; }]; _copkilled = addMissionEventHandler [ "EntityKilled", { params[ "_killed", "_killer", "_instigator", "_pos", "_police" ]; if ( (_instigator isEqualTo player) && (side group _killed isEqualTo resistance) ) then { _alertLevel = _alertLevel + 3 }; }]; //Spawn units and Stalk if ((_alertLevel > 0) && (_alertLevel <= 2)) then { player setCaptive false; _pos = [player, [50,150]] call SHK_pos; _police = [_pos, resistance, 1 + (random 2)] call bis_fnc_spawngroup; _stalking = [_police, group player,nil,10,{player distance _police < 300},"mkrStation"] spawn BIS_fnc_stalk; }; if ((_alertLevel > 2) && (_alertLevel <= 5)) then { player setCaptive false; _pos = [player, [50,150]] call SHK_pos; _police = [_pos, resistance, 1 + (random 2)] call bis_fnc_spawngroup; _stalking = [_police, group player,nil,10,{player distance _police < 300},"mkrStation"] spawn BIS_fnc_stalk; }; Any ideas on how I can get this to work? Share this post Link to post Share on other sites
JR Nova 24 Posted April 14, 2019 I got it to work, I took everything out of initPlayerLocal and in civKilled.sqf changed the code to if ( (_instigator isEqualTo player) && (side group _killed isEqualTo civilian) ) then { _instigator execVM "killed.sqf" }; }]; then in killed.sqf alertLevel = alertLevel + 1; wanted = true; player setCaptive false; if ((alertLevel > 0) && (alertLevel <= 2) && (!dispatched1)) then { dispatched1 = true; _pos = [player, [50,150]] call SHK_pos; _police = [_pos, resistance, 1 + (random 2)] call bis_fnc_spawngroup; _stalking = [_police, group player,nil,10,{player distance _police < 300},"mkrStation"] spawn BIS_fnc_stalk; waitUntil { (count units _police) < 1 }; dispatched1 = false; }; if ((alertLevel > 2) && (alertLevel <= 5) && (!dispatched2)) then { dispatched2 = true; _pos = [player, [50,150]] call SHK_pos; _police = [_pos, resistance, 1 + (random 2)] call bis_fnc_spawngroup; _stalking = [_police, group player,nil,10,{player distance _police < 300},"mkrStation"] spawn BIS_fnc_stalk; waitUntil { (count units _police) < 1 }; dispatched2 = false; }; 2 Share this post Link to post Share on other sites
snakeplissken 96 Posted April 14, 2019 GTA? rs Where are these scripts placed and called? Share this post Link to post Share on other sites
JR Nova 24 Posted April 14, 2019 Not exactly GTA but something similar lol 😉 I actually changed the way I set it up and now its a few more files, for now I have them all in the mission folder. init.sqf Spoiler if (local player) then { player setCaptive true; player addMPEventhandler ["MPRespawn", {player setCaptive true;}]; }; alertLevel = 0; wanted = false; dispatched1 = false; dispatched2 = false; dispatched3 = false; dispatched4 = false; dispatched5 = false; nul = [] execVM "killed.sqf"; killed.sqf Spoiler _pedkilled = addMissionEventHandler [ "EntityKilled", { params[ "_killed", "_killer", "_instigator" ]; if ( (_instigator == player) && (side group _killed == civilian) ) then { _instigator execVM "civKilled.sqf" }; if ( (_instigator == player) && (side group _killed == resistance) ) then { _instigator execVM "copKilled.sqf" }; }]; civKilled.sqf Spoiler alertLevel = alertLevel + 1; wanted = true; player setCaptive false; player execVM "wanted.sqf"; copKilled.sqf Spoiler alertLevel = alertLevel + 3; wanted = true; player setCaptive false; player execVM "wanted.sqf"; wanted.sqf Spoiler //wanted Level 1 / 1-3 units responding if ((alertLevel > 0) && (alertLevel <= 2) && !dispatched1) then { private ["_pos", "_police", "_stalking"]; dispatched1 = true; hint format ["Police Units Dispatched. Alert Level 1", alertLevel]; _pos = [player, [100,150]] call SHK_pos; _police = [_pos, resistance, 1 + (random 2)] call bis_fnc_spawngroup; _stalking = [_police, group player,nil,10,{player distance _police < 300},"mkrStation"] spawn BIS_fnc_stalk; waitUntil { (count units _police) < 1 }; //hint "Dispatched Units are Dead."; dispatched1 = false; }; //wanted Level 2 / 3-6 units responding if ((alertLevel > 2) && (alertLevel <= 6) && !dispatched2) then { private ["_pos", "_police", "_stalking"]; dispatched2 = true; hint format ["Police Units Dispatched. Alert Level 2", alertLevel]; _pos = [player, [100,150]] call SHK_pos; _police = [_pos, resistance, 3 + (random 3)] call bis_fnc_spawngroup; _stalking = [_police, group player,nil,10,{player distance _police < 400},"mkrStation"] spawn BIS_fnc_stalk; waitUntil { (count units _police) < 1 }; //hint "Dispatched Units are Dead."; dispatched2 = false; }; //wanted Level 3 / 5-10 units and a strider responding if ((alertLevel > 6) && (alertLevel <= 10) && !dispatched3) then { private ["_pos", "_pos2", "_police", "_policeMRAP", "_stalking"]; dispatched3 = true; hint format ["Police Units Dispatched. Alert Level 3", alertLevel]; _pos = [player, [100,150]] call SHK_pos; _pos2 = [player, [300,500]] call SHK_pos; _police = [_pos, resistance, 5 + (random 5)] call bis_fnc_spawngroup; _policeMRAP = [_pos2, 180, "I_MRAP_03_hmg_F", _police] call bis_fnc_spawnvehicle; _stalking = [_police, group player,nil,10,{player distance _police < 500},"mkrStation"] spawn BIS_fnc_stalk; waitUntil { (count units _police) < 1 }; //hint "Dispatched Units are Dead."; dispatched3 = false; }; //wanted level 4 / 8-16 units, one helo with marksmen, and a strider responding if ((alertLevel > 10) && (alertLevel <= 20) && !dispatched4) then { private ["_pos", "_pos2", "_pos3", "_police", "_policeMRAP", "_policeHeli", "_unit1", "_unit2", "_stalking"]; dispatched4 = true; hint format ["Police Units Dispatched. Alert Level 4", alertLevel]; _pos = [player, [100,150]] call SHK_pos; _pos2 = [player, [300,500]] call SHK_pos; _pos3 = [player, [900,1200]] call SHK_pos; _police = [_pos, resistance, 8 + (random 8)] call bis_fnc_spawngroup; _policeMRAP = [_pos2, 180, "I_MRAP_03_hmg_F", _police] call bis_fnc_spawnvehicle; _policeHeli = [_pos3, 180, "I_Heli_light_03_F", _police] call bis_fnc_spawnvehicle; (_policeHeli select 0) setVehicleAmmo 0; _unit1 = _police createUnit ["I_Soldier_M_F", _pos3, [], 0, "NONE"]; _unit2 = _police createUnit ["I_Soldier_M_F", _pos3, [], 0, "NONE"]; _unit1 moveInCargo (_policeHeli select 0); _unit2 moveInCargo (_policeHeli select 0); _stalking = [_police, group player,nil,10,{player distance _police < 1000},"mkrStation"] spawn BIS_fnc_stalk; waitUntil { (count units _police) < 1 }; //hint "Dispatched Units are Dead."; dispatched4 = false; }; Share this post Link to post Share on other sites