Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add: Player can use horn, beacons and siren to stop civilian mouvements #1235

Merged
merged 13 commits into from
Nov 14, 2021
6 changes: 5 additions & 1 deletion =BTC=co@30_Hearts_and_Minds.Altis/core/def/mission.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,12 @@ btc_type_ieds_ace = ["IEDLandBig_F", "IEDLandSmall_F"];
btc_ied_deleteOn = -1;

//Int
btc_int_radius_orders = 25;
btc_int_ordersRadius = 25;
btc_int_search_intel_time = 4;
btc_int_sirenRadius = 35;
btc_int_beaconRadius = 15;
btc_int_hornRadius = 20;
btc_int_hornDelay = time;

//Info
btc_info_intel_chance = _info_chance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Returns:

Examples:
(begin example)
[btc_create_object_point] call btc_arsenal_fnc_garage;
[btc_create_object_point] spawn btc_arsenal_fnc_garage;
(end)

Author:
Expand Down
3 changes: 3 additions & 0 deletions =BTC=co@30_Hearts_and_Minds.Altis/core/fnc/compile.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,9 @@ if (!isDedicated) then {
btc_int_fnc_shortcuts = compileScript ["core\fnc\int\shortcuts.sqf"];
btc_int_fnc_terminal = compileScript ["core\fnc\int\terminal.sqf"];
btc_int_fnc_foodGive = compileScript ["core\fnc\int\foodGive.sqf"];
btc_int_fnc_ordersLoop = compileScript ["core\fnc\int\ordersLoop.sqf"];
btc_int_fnc_checkSirenBeacons = compileScript ["core\fnc\int\checkSirenBeacons.sqf"];
btc_int_fnc_horn = compileScript ["core\fnc\int\horn.sqf"];

//INFO
btc_info_fnc_ask = compileScript ["core\fnc\info\ask.sqf"];
Expand Down
16 changes: 15 additions & 1 deletion =BTC=co@30_Hearts_and_Minds.Altis/core/fnc/eh/player.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,21 @@ if (btc_p_respawn_location >= 4) then {
["ace_killed", {
params ["_unit"];
if (_unit isNotEqualTo player) exitWith {};
private _group = group player;
private _group = group player;
[_group, leader _group] call BIS_fnc_addRespawnPosition;
}] call CBA_fnc_addEventHandler;
};

["btc_inGameUISetEventHandler", {
params ["_target", "", "", "", "_text"];
[_target, _text, ["siren_Start", "siren_stop"], "btc_int_sirenStart"] call btc_int_fnc_checkSirenBeacons;
}] call CBA_fnc_addEventHandler;
["btc_inGameUISetEventHandler", {
params ["_target", "", "", "", "_text"];
[_target, _text, ["beacons_start", "beacons_stop"], "btc_int_beaconsStart"] call btc_int_fnc_checkSirenBeacons;
}] call CBA_fnc_addEventHandler;
inGameUISetEventHandler ["Action", '["btc_inGameUISetEventHandler", _this] call CBA_fnc_localEvent; false'];

[{!isNull (findDisplay 46)}, {
(findDisplay 46) displayAddEventHandler ["MouseButtonDown", btc_int_fnc_horn];
}] call CBA_fnc_waitUntilAndExecute;
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

/* ----------------------------------------------------------------------------
Function: btc_int_fnc_checkSirenBeacons

Description:
Check if player turn ON siren or beacons.

Parameters:
_veh - Vehicle. [Object]
_text - Text displayed. [String]
_typesConfig - Type of config to check. [Array]
_typeVariable - Variable name. [String]

Returns:

Examples:
(begin example)
[cursorObject, configOf _veh >> "UserActions" >> siren_Start >> "displayName", ["siren_Start", "siren_stop"] , "btc_int_sirenStart"] call btc_int_fnc_checkSirenBeacons;
(end)

Author:
Vdauphin

---------------------------------------------------------------------------- */

params [
"_veh",
"_text",
"_typesConfig",
"_typeVariable"
];
_typesConfig params ["_start", "_stop"];

private _userActions = configOf _veh >> "UserActions";
if (
getText (_userActions >> _start >> "displayName") isEqualTo _text
) exitWith {
_veh call btc_int_fnc_ordersLoop;
_veh setVariable [_typeVariable, true, true];
};
if (
getText (_userActions >> _stop >> "displayName") isEqualTo _text
) exitWith {
_veh setVariable [_typeVariable, false, true];
};
46 changes: 46 additions & 0 deletions =BTC=co@30_Hearts_and_Minds.Altis/core/fnc/int/horn.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

/* ----------------------------------------------------------------------------
Function: btc_int_fnc_horn

Description:
Execute STOP order if player use horn.

Parameters:

Returns:

Examples:
(begin example)
[] call btc_int_fnc_horn;
(end)

Author:
Vdauphin

---------------------------------------------------------------------------- */

private _veh = vehicle player;
if (
_veh isEqualTo player ||
{visibleMap} ||
{driver _veh isNotEqualTo player} ||
{time < btc_int_hornDelay + 1}
) exitWith {};

params ["_displayOrControl", "_button"];
if (_button isNotEqualTo 0) exitWith {};

private _weapon = currentWeapon _veh;
if (
_weapon isNotEqualTo "" &&
{!(_weapon isKindOf ["CarHorn", configFile >> "CfgWeapons"])}
) exitWith {};

[
1,
objNull,
btc_int_hornRadius,
_veh
] call btc_int_fnc_orders;

btc_int_hornDelay = time;
17 changes: 10 additions & 7 deletions =BTC=co@30_Hearts_and_Minds.Altis/core/fnc/int/orders.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,19 @@ Author:

params [
["_order", 0, [0]],
["_unit", objNull, [objNull]]
["_unit", objNull, [objNull]],
["_radius", btc_int_ordersRadius, [0]],
["_vehicle", player, [objNull]]
];

private _gesture = ["", "gestureFreeze", "gestureCover", "gestureGo", "gestureGo"] select _order;

player playActionNow _gesture;
if (_vehicle isEqualTo player) then {
private _gesture = ["", "gestureFreeze", "gestureCover", "gestureGo", "gestureGo"] select _order;
_vehicle playActionNow _gesture;
};

private _pos = getPos player;
private _dir = getDir player;
private _units = (_pos nearEntities [["Car", "Civilian_F"] + btc_civ_type_units, btc_int_radius_orders]) apply {driver _x};
private _pos = getPos _vehicle;
private _dir = getDir _vehicle;
private _units = (_pos nearEntities [["Car", "Civilian_F"] + btc_civ_type_units, _radius]) apply {driver _x};

if (_units isEqualTo []) exitWith {true};

Expand Down
51 changes: 51 additions & 0 deletions =BTC=co@30_Hearts_and_Minds.Altis/core/fnc/int/ordersLoop.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

/* ----------------------------------------------------------------------------
Function: btc_int_fnc_ordersLoop

Description:
Execute in loop STOP order.

Parameters:
_veh - Vehicle. [Object]

Returns:

Examples:
(begin example)
cursorObject call btc_int_fnc_ordersLoop;
(end)

Author:
Vdauphin

---------------------------------------------------------------------------- */

params [
"_veh"
];

if (
_veh getVariable ["btc_int_sirenStart", false] ||
_veh getVariable ["btc_int_beaconsStart", false]
) exitWith {};

[{
params ["_arguments", "_idPFH"];
_arguments params ["_veh"];

private _sirenStart = _veh getVariable ["btc_int_sirenStart", false];
private _beaconsStart = _veh getVariable ["btc_int_beaconsStart", false];
if (
!_sirenStart &&
!_beaconsStart
) exitWith {
[_idPFH] call CBA_fnc_removePerFrameHandler;
};

[
1,
objNull,
([0, btc_int_sirenRadius] select _sirenStart) + ([0, btc_int_beaconRadius] select _beaconsStart),
_veh
] call btc_int_fnc_orders;
}, 0.5, _veh] call CBA_fnc_addPerFrameHandler;
Loading