Magirot 14 Posted September 26, 2015 (edited) There are probably hundreds of mission specific systems people have created, but I haven't seen any posted on these forums.So here's a really simple one I've been using. All it does is check if the player equips a weapon, compares this to when hostile sides have last spotted the unit, and then adjusts with setCaptive. It also has various settings for setting up restricted areas, disallowing faction vehicles, and not allowing driving off the road. See the settings. The script runs locally. /* Script for crudely simulating guerilla type missions. Author: Magirot Installation: 1. Save the script into your mission folder (as followCaptive.sqf, for example) 2. Take a look at the settings (at least the first one, fc_hostile_sides) 3. The player unit should be blufor/opfor/independent. You could, for example, group a civilian player to a higher-ranking AI unit, and then set this combatant side AI's probability of presence slider to zero. 4. Execute the script for the players you want it to apply, for example in initPlayerLocal.sqf: [] execVM "followCaptive.sqf"; */ /////////////////////////////////////////////////////////////////////////////////// // Settings /////////////////////////////////////////////////////////////////////////////////// // Which sides monitor players. Separated by comma // Example: // fc_hostile_sides = [opfor, independent]; fc_hostile_sides = [opfor]; // How well the enemy has to "know" a player unit before it's counted as spotted. Value between 0.00 and 4.00 // More info at the end of the page: https://community.bistudio.com/wiki/knowsAbout fc_count_as_spotted = 2.4; // After knowsAbout has fallen below fc_count_as_spotted value, how many seconds until the unarmed player is counted as friendly fc_forget_time = 60; // Names of "restricted area" triggers where spotted players become hostile even if they're unarmed. // The trigger settings should be "Anybody Present" and "Repeatedly" // Example: // fc_restricted_areas = [restrictedTrigger1, restrictedTrigger2]; fc_restricted_areas = []; // Names of "restricted vehicles" which instantly make you hostile if you're in them. // Example: // fc_restricted_vehicles = [armedOffroad1, strider1]; fc_restricted_vehicles = []; // Does getting in a vehicle other than a civilian vehicle automatically make the player hostile? fc_restrict_faction_vehicles = FALSE; // Allow driving off road. If disabled, getting spotted while not driving on a road will make you hostile. // Note that only roads shown on the textureless map count as roads, bridges have small sections which don't count as roads, and simply parking off the road can become dangerous. fc_allow_driving_off_road = TRUE; // Triggers where you can drive off-road, to be used if fc_allow_driving_off_road is FALSE. Useful for cities/bridges. // The trigger settings should be "Anybody Present" and "Repeatedly" // Example: // fc_safe_driving_areas = [safeArea1, safeArea2]; fc_safe_driving_areas = []; // Messages fc_msg_notice_restricted_area = "It feels like you've gained unwanted attention."; fc_msg_weapon_equipped = "You're making yourself a hostile!"; fc_msg_hostile_timeout = "You should be fine now."; /////////////////////////////////////////////////////////////////////////////////// // Settings end /////////////////////////////////////////////////////////////////////////////////// // no need to execute for a dedicated server if (isDedicated) exitWith {}; // Declare some variables for monitoring captive state fc_noticed_time = 0 - fc_forget_time; fc_getting_timed = FALSE; // Function for checking if the player's vehicle isn't a civilian vehicle fc_check_is_faction_vehicle = { // declare private variables private ["_isFactionVehicle", "_vehicle"]; _isFactionVehicle = FALSE; _vehicle = _this select 0; // only check if faction vehicles are restricted if (fc_restrict_faction_vehicles) then { // only check if player is in a vehicle if (_vehicle != player) then { // check the vehicle faction from config entry corresponding to the classname if (getText (configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "faction") != "CIV_F") exitWith { _isFactionVehicle = TRUE; }; }; }; _isFactionVehicle }; // function that removes captive status and then follows when to give it back again fc_handle_captive = { // declare private variable private "_msg"; // _msg defines which info message to show _msg = [_this, 0, ""] call BIS_fnc_param; // only set up a timer if there's none already if (!fc_getting_timed) then { fc_getting_timed = TRUE; player setCaptive FALSE; hint _msg; [] spawn { // wait until enough time has passed and the player has gotten rid of anything branding them waitUntil { sleep 1; ((fc_noticed_time + fc_forget_time) < time && primaryWeapon player == "" && secondaryWeapon player == "" && handgunWeapon player == "" && !(vehicle player in fc_restricted_vehicles) && !([vehicle player] call fc_check_is_faction_vehicle) ) }; fc_getting_timed = FALSE; player setCaptive TRUE; hint fc_msg_hostile_timeout; }; }; }; // functions defined // Just in case the script was executed somewhere where player is still null waitUntil {player == player}; // set player as captive from the onset player setCaptive TRUE; // first loop monitoring when enemy side(s) notice(s) the player [] spawn { while {TRUE} do { { // forEach block start if (_x knowsAbout vehicle player >= fc_count_as_spotted) then { fc_noticed_time = time; if (!fc_allow_driving_off_road) then { if (vehicle player != player) then { if (!isOnRoad getPos vehicle player) then { private "_fc_inSafeZone"; _fc_inSafeZone = FALSE; { if (vehicle player in list _x) then { _fc_inSafeZone = TRUE }; } forEach fc_safe_driving_areas; if (!(_fc_inSafeZone) && captive player) then { [fc_msg_notice_restricted_area] spawn fc_handle_captive; }; }; }; }; if (count fc_restricted_areas > 0) then { private "_fc_inRestricted"; _fc_inRestricted = FALSE; { if (vehicle player in list _x) then { _fc_inRestricted = TRUE }; } forEach fc_restricted_areas; if (_fc_inRestricted && captive player) then { [fc_msg_notice_restricted_area] spawn fc_handle_captive; }; }; }; } forEach fc_hostile_sides; sleep 3; }; }; // second loop for monitoring when the player equips a weapon or gets in the wrong vehicle [] spawn { while {TRUE} do { waitUntil { sleep 2; primaryWeapon player != "" || secondaryWeapon player != "" || handgunWeapon player != "" || vehicle player in fc_restricted_vehicles || [vehicle player] call fc_check_is_faction_vehicle }; [fc_msg_weapon_equipped] spawn fc_handle_captive; waitUntil {sleep 2; captive player}; }; }; pastebin for an easier paste. Please share your own similar systems, suggestions of improvements to the above, or anything relevant I've missed on these forums! Edit: Switched tab indentation to four spaces so all them ifs don't take quite so much space horizontally. Edited October 1, 2015 by Magirot 3 Share this post Link to post Share on other sites
seba1976 98 Posted September 26, 2015 Thank you very much. I was looking for something like this. Share this post Link to post Share on other sites
Magirot 14 Posted October 1, 2015 Just realised I had made a really dumb mistake while cleaning it up, and the "if dedicated server, exit" check was the wrong way around. D: It's fixed now, sorry. I really should've ran a test after any edits. Share this post Link to post Share on other sites
spyderblack723 407 Posted October 2, 2015 Good work! The customizable solution that you've provided should help a lot of people. For my suggestions, Maybe use BIS_fnc_inTriggerArea (BIS_fnc_inArea? I forgot the eact name) to allow for markers to dictate restricted zones as opposed to just triggers (BIS_fnc_inTriggerArea works with markers as well). Some mods that add civilian cars might use a different faction other than "CIV_F", maybe allow for inputting custom array of civilian factions or perform a check for each faction that belongs to the civilian side (side = 3 in config I think?), maybe something along the lines of If (faction vehicle player in [_civFactionList]) then {_civilianVehicle = true}; Share this post Link to post Share on other sites
ThreeProphets 10 Posted January 2, 2017 Can you make it so placing explosives increases your knowsAbout? It's too easy to just walk around with your weapon away and blow things up with IEDs. I also need an exempted weapons array so I can use a standalone flashlight without getting shot at. Share this post Link to post Share on other sites
stormoffires 3 Posted January 3, 2017 awesome script! is there anyway i can make this a toggle ability, rather then always running? Also display a message if you try to enter undercover while on cooldown? Share this post Link to post Share on other sites
stormoffires 3 Posted January 3, 2017 On 10/1/2015 at 8:31 PM, spyderblack723 said: Some mods that add civilian cars might use a different faction other than "CIV_F", maybe allow for inputting custom array of civilian factions or perform a check for each faction that belongs to the civilian side (side = 3 in config I think?), maybe something along the lines of If (faction vehicle player in [_civFactionList]) then {_civilianVehicle = true}; I am working on a mission that has a hand full of vehicles in the independent column that i want to allow use without being flagged, probably 4 or 5 trucks, how would i rewrite the script to allow the specific trucks over a list of faction trucks? Spoiler // Vehicles listed below will not flag you as hostile _allowedtrucks = I_C_Offroad_02_unarmed_f // Function for checking if the player's vehicle isn't a civilian vehicle fc_check_is_faction_vehicle = { // declare private variables private ["_isFactionVehicle", "_vehicle"]; _isFactionVehicle = FALSE; _vehicle = _this select 0; // only check if faction vehicles are restricted if (fc_restrict_faction_vehicles) then { // only check if player is in a vehicle if (_vehicle != player) then { // check the vehicle faction from config entry corresponding to the classname If (faction vehicle player in [_allowedtrucks]) then {_civilianVehicle = true} exitWith { _isFactionVehicle = TRUE; }; }; }; _isFactionVehicle }; do i have this write to allow for use in 1 specific truck? Share this post Link to post Share on other sites
ThreeProphets 10 Posted January 3, 2017 29 minutes ago, stormoffires said: I am working on a mission that has a hand full of vehicles in the independent column that i want to allow use without being flagged, probably 4 or 5 trucks, how would i rewrite the script to allow the specific trucks over a list of faction trucks? Reveal hidden contents // Vehicles listed below will not flag you as hostile _allowedtrucks = I_C_Offroad_02_unarmed_f // Function for checking if the player's vehicle isn't a civilian vehicle fc_check_is_faction_vehicle = { // declare private variables private ["_isFactionVehicle", "_vehicle"]; _isFactionVehicle = FALSE; _vehicle = _this select 0; // only check if faction vehicles are restricted if (fc_restrict_faction_vehicles) then { // only check if player is in a vehicle if (_vehicle != player) then { // check the vehicle faction from config entry corresponding to the classname If (faction vehicle player in [_allowedtrucks]) then {_civilianVehicle = true} exitWith { _isFactionVehicle = TRUE; }; }; }; _isFactionVehicle }; do i have this write to allow for use in 1 specific truck? I'm no scripter, but you can look for their faction in the config browser and add it to or replace the CivF exemption. Be warned that this will make it so all vehicles from that faction are exempted, so if it's AAF, you will be able to drive every AAF vehicle without being noticed. Share this post Link to post Share on other sites
stormoffires 3 Posted January 3, 2017 Thanks ThreeProphets, im not really looking for a whole faction set up, but only a couple of trucks.. also this script does not seem to reset when no longer spotted or after leaving a restricted area with no weapon in hand. Share this post Link to post Share on other sites
ThreeProphets 10 Posted January 3, 2017 57 minutes ago, stormoffires said: Thanks ThreeProphets, im not really looking for a whole faction set up, but only a couple of trucks.. also this script does not seem to reset when no longer spotted or after leaving a restricted area with no weapon in hand. Yeah, the way it's written right now doesn't really support that. Look to see if there are civilian versions of the trucks you want. There's a timer for the reset in the settings. It takes 60 seconds by default. Share this post Link to post Share on other sites
stormoffires 3 Posted January 3, 2017 5 minutes ago, ThreeProphets said: There's a timer for the reset in the settings. It takes 60 seconds by default. no it doesnt...thats my issue, i have change the stat to 10 to speed up the process, but i have a feeling KnowAbout has its own timer so i you have to get your knowAbout below 2.4. also does not seem to reset after leaving a restricted area. Share this post Link to post Share on other sites
ThreeProphets 10 Posted January 3, 2017 14 hours ago, stormoffires said: no it doesnt...thats my issue, i have change the stat to 10 to speed up the process, but i have a feeling KnowAbout has its own timer so i you have to get your knowAbout below 2.4. also does not seem to reset after leaving a restricted area. I think that's right. knowsAbout is a funky variable. I have the script set so it has to be all the way at 4.0 to simulate reaction time, and even then it's really fast. That probably also helps the timeout. Share this post Link to post Share on other sites