-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into feature/clear-empty…
…-vehicles-on-spawn
- Loading branch information
Showing
30 changed files
with
475 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
z\afsk\addons\vehicles |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class Extended_PreStart_EventHandlers { | ||
class ADDON { | ||
init = QUOTE(call COMPILE_FILE(XEH_preStart)); | ||
}; | ||
}; | ||
class Extended_PreInit_EventHandlers { | ||
class ADDON { | ||
init = QUOTE(call COMPILE_FILE(XEH_preInit)); | ||
}; | ||
}; | ||
class Extended_PostInit_EventHandlers { | ||
class ADDON { | ||
init = QUOTE(call COMPILE_FILE(XEH_postInit)); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class CfgSounds | ||
{ | ||
class CarAlarm | ||
{ | ||
name = "CarAlarm"; | ||
sound[] = {QPATHTOF(assets\sounds\Caralarm.ogg), "db+10", 1.0}; | ||
titles[] = {}; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
PREP(carAlarm); | ||
PREP(carAlarmLoop); | ||
PREP(createVehicle); | ||
PREP(disableCarAlarm); | ||
PREP(initCarAlarm); | ||
PREP(initVehicles); | ||
PREP(setVehicleRandomTexture); | ||
PREP(vehicleStolenMsg); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include "script_component.hpp" | ||
|
||
if (isServer) then { | ||
|
||
[QGVAR(carAlarm), FUNC(carAlarm)] call CBA_fnc_addEventHandler; | ||
[QGVAR(disableCarAlarm), FUNC(disableCarAlarm)] call CBA_fnc_addEventHandler; | ||
}; | ||
|
||
if (hasInterface) then { | ||
[QGVAR(carAlarm), FUNC(carAlarm)] call CBA_fnc_addEventHandler; | ||
|
||
[QGVAR(alarmOff), { | ||
params ["_vehicle"]; | ||
|
||
[QEGVAR(common,showSideChatMsg), [WEST, [_vehicle] call FUNC(vehicleStolenMsg)]] call CBA_fnc_localEvent; | ||
[_vehicle, true, GVAR(alarmDuration)] call FUNC(carAlarmLoop); | ||
}] call CBA_fnc_addEventHandler; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include "script_component.hpp" | ||
ADDON = false; | ||
#include "XEH_PREP.hpp" | ||
|
||
#include "initSettings.sqf" | ||
|
||
// We need some improvements in determining civilian vehicles limit | ||
GVAR(emptyVehiclesLimit) = 500; | ||
|
||
if (isServer) then { | ||
call FUNC(initVehicles); | ||
}; | ||
|
||
ADDON = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#include "script_component.hpp" | ||
#include "XEH_PREP.hpp" |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include "script_component.hpp" | ||
|
||
class CfgPatches { | ||
class ADDON { | ||
name = COMPONENT_NAME; | ||
units[] = {}; | ||
weapons[] = {}; | ||
requiredVersion = REQUIRED_VERSION; | ||
requiredAddons[] = { | ||
"afsk_common" | ||
}; | ||
author = "ArmaForces"; | ||
VERSION_CONFIG; | ||
}; | ||
}; | ||
|
||
#include "CfgEventHandlers.hpp" | ||
#include "CfgSounds.hpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#include "script_component.hpp" | ||
/* | ||
* Author: 3Mydlo3 | ||
* Function triggers car alarm on given vehicle. | ||
* | ||
* Arguments: | ||
* 0: Vehicle which has alarm going off <OBJECT> | ||
* | ||
* Return Value: | ||
* True if alarm has gone off <BOOL> | ||
* | ||
* Example: | ||
* None | ||
* | ||
* Public: No | ||
*/ | ||
|
||
params ["_vehicle"]; | ||
|
||
// Prevent triggering when triggered already | ||
if (_vehicle getVariable [QGVAR(alarmOn), false]) exitWith { false }; | ||
|
||
// Prevent triggering multiple times or if unarmed | ||
if (!GVAR(alarmAlwaysArmed) && { | ||
(_vehicle getVariable [QGVAR(hasGoneOff), false] || { | ||
!(_vehicle getVariable [QGVAR(alarmArmed), false])} | ||
) | ||
}) exitWith { false }; | ||
|
||
// Random chance that alarm will go off | ||
if (_vehicle getVariable [QGVAR(offChance), 1] < random 1) exitWith { | ||
if (GVAR(alarmDisarmIfFailed)) then { | ||
_vehicle setVariable [QGVAR(alarmArmed), false]; | ||
}; | ||
|
||
false | ||
}; | ||
|
||
_vehicle setVariable [QGVAR(alarmOn), true]; | ||
_vehicle setVariable [QGVAR(hasGoneOff), true]; | ||
|
||
[QGVAR(alarmOff), [_vehicle]] call CBA_fnc_globalEvent; | ||
|
||
true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#include "script_component.hpp" | ||
/* | ||
* Author: 3Mydlo3 | ||
* Function triggers car alarm on given vehicle. | ||
* | ||
* Arguments: | ||
* 0: Vehicle which has alarm turned on <OBJECT> | ||
* | ||
* Return Value: | ||
* None | ||
* | ||
* Example: | ||
* None | ||
* | ||
* Public: No | ||
*/ | ||
|
||
#define ALARM_INTERVAL 0.5 | ||
#define ALARM_LENGTH 10 | ||
#define MAX_DISTANCE GVAR(alarmAudibleDistance) | ||
#define DEFAULT_PITCH 1 | ||
#define SOUND_WITHOUT_MUFFLING 2 | ||
|
||
params ["_vehicle", "_lightsOn", "_remainingDuration", ["_currentSoundDuration", 999]]; | ||
|
||
_vehicle setPilotLight _lightsOn; | ||
if (_currentSoundDuration > ALARM_LENGTH) then { | ||
_vehicle say3D ["CarAlarm", MAX_DISTANCE, DEFAULT_PITCH, SOUND_WITHOUT_MUFFLING]; | ||
_currentSoundDuration = ALARM_INTERVAL; | ||
} else { | ||
_currentSoundDuration = _currentSoundDuration + ALARM_INTERVAL; | ||
}; | ||
|
||
_remainingDuration = _remainingDuration - 1; | ||
|
||
// player sideChat format ["Remaining alarm: %1", _remainingDuration]; | ||
|
||
if (_remainingDuration < 1 || {!alive _vehicle}) exitWith { | ||
// player sideChat "Ending alarm"; | ||
_vehicle setVariable [QGVAR(alarmOn), false, true]; | ||
_vehicle setPilotLight false; | ||
}; | ||
|
||
[FUNC(carAlarmLoop), [_vehicle, !_lightsOn, _remainingDuration, _currentSoundDuration], ALARM_INTERVAL] call CBA_fnc_waitAndExecute; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include "script_component.hpp" | ||
/* | ||
* Author: 3Mydlo3 | ||
* Function disables car alarm on given vehicle. | ||
* | ||
* Arguments: | ||
* 0: Vehicle which has alarm armed <OBJECT> | ||
* | ||
* Return Value: | ||
* True if alarm is disabled <BOOL> | ||
* | ||
* Example: | ||
* None | ||
* | ||
* Public: No | ||
*/ | ||
|
||
params ["_vehicle"]; | ||
|
||
if (!isServer) exitWith { | ||
[QGVAR(disableCarAlarm), [_vehicle]] call CBA_fnc_serverEvent; | ||
false | ||
}; | ||
|
||
_vehicle setVariable [QGVAR(alarmArmed), false]; | ||
|
||
// Remove EH so it doesn't fire unnecessarily | ||
private _ehId = _vehicle getVariable [QGVAR(GetInEHID), -1]; | ||
_vehicle removeEventHandler ["GetIn", _ehId]; | ||
|
||
INFO_1("Disabled alarm in vehicle %1",_vehicle); | ||
|
||
true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include "script_component.hpp" | ||
/* | ||
* Author: 3Mydlo3 | ||
* Function initializes car alarm on given vehicle. | ||
* | ||
* Arguments: | ||
* 0: Vehicle which has alarm armed <OBJECT> | ||
* 1: Chance that the alarm will indeed go off <NUMBER> | ||
* | ||
* Return Value: | ||
* True if alarm has been armed <BOOL> | ||
* | ||
* Example: | ||
* None | ||
* | ||
* Public: No | ||
*/ | ||
|
||
params ["_vehicle", ["_offChance", 1]]; | ||
|
||
if (_vehicle getVariable [QGVAR(alarmArmed), false]) exitWith { false }; | ||
|
||
_vehicle setVariable [QGVAR(alarmArmed), true]; | ||
_vehicle setVariable [QGVAR(offChance), _offChance]; | ||
|
||
// Alarm should go off at most once, init a flag to keep that in mind | ||
_vehicle setVariable [QGVAR(hasGoneOff), false]; | ||
|
||
private _ehId = _vehicle addEventHandler ["GetIn", { | ||
params ["_vehicle", "_role", "_unit", "_turret"]; | ||
if (side _unit isEqualTo CIVILIAN) exitWith {}; | ||
|
||
[QGVAR(carAlarm), [_vehicle]] call CBA_fnc_serverEvent; | ||
}]; | ||
|
||
_vehicle setVariable [QGVAR(GetInEHID), _ehId]; | ||
|
||
true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.