Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- 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};
- };
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement