mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
safemode: port
This commit is contained in:
parent
7c41eb04e9
commit
9247bb3411
1
addons/safemode/$PBOPREFIX$
Normal file
1
addons/safemode/$PBOPREFIX$
Normal file
@ -0,0 +1 @@
|
||||
z\ace\addons\safemode
|
12
addons/safemode/CfgEventHandlers.hpp
Normal file
12
addons/safemode/CfgEventHandlers.hpp
Normal file
@ -0,0 +1,12 @@
|
||||
|
||||
class Extended_PreInit_EventHandlers {
|
||||
class ADDON {
|
||||
init = QUOTE(call COMPILE_FILE(XEH_preInit) );
|
||||
};
|
||||
};
|
||||
|
||||
class Extended_PostInit_EventHandlers {
|
||||
class ADDON {
|
||||
clientInit = QUOTE( call COMPILE_FILE(XEH_postInit) );
|
||||
};
|
||||
};
|
5
addons/safemode/XEH_postInit.sqf
Normal file
5
addons/safemode/XEH_postInit.sqf
Normal file
@ -0,0 +1,5 @@
|
||||
|
||||
// by commy2
|
||||
|
||||
//["Soldier", {_player = ACE_player; if (currentWeapon _player in (_player getVariable [QGVAR(safedWeapons), []])) then {[false] call FUNC(setSafeModeVisual)}] call EFUNC(common,addInfoDisplayEventHandler);
|
||||
//@todo addEventHandler infoDisplayChanged with select 1 == "Soldier"
|
7
addons/safemode/XEH_preInit.sqf
Normal file
7
addons/safemode/XEH_preInit.sqf
Normal file
@ -0,0 +1,7 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
PREP(firstMode);
|
||||
PREP(lockSafety);
|
||||
PREP(playChangeFiremodeSound);
|
||||
PREP(setSafeModeVisual);
|
||||
PREP(unlockSafety);
|
@ -1,5 +0,0 @@
|
||||
|
||||
// by commy2
|
||||
|
||||
//["Soldier", {_player = AGM_player; if (currentWeapon _player in (_player getVariable ["AGM_SafeMode_safedWeapons", []])) then {[false] call AGM_SafeMode_setSafeModeVisual}] call AGM_Core_fnc_addInfoDisplayEventHandler;
|
||||
//@todo addEventHandler infoDisplayChanged with select 1 == "Soldier"
|
@ -1,46 +1,28 @@
|
||||
// PATCH CONFIG
|
||||
#include "script_component.hpp"
|
||||
|
||||
class CfgPatches {
|
||||
class AGM_SafeMode {
|
||||
units[] = {};
|
||||
weapons[] = {};
|
||||
requiredVersion = 0.60;
|
||||
requiredAddons[] = {AGM_Core};
|
||||
version = "0.95";
|
||||
versionStr = "0.95";
|
||||
versionAr[] = {0,95,0};
|
||||
author[] = {"commy2"};
|
||||
authorUrl = "https://github.com/commy2/";
|
||||
};
|
||||
};
|
||||
|
||||
class CfgFunctions {
|
||||
class AGM_SafeMode {
|
||||
class AGM_SafeMode {
|
||||
file = "AGM_SafeMode\functions";
|
||||
class firstMode;
|
||||
class lockSafety;
|
||||
class playChangeFiremodeSound;
|
||||
class setSafeModeVisual;
|
||||
class unlockSafety;
|
||||
class ADDON {
|
||||
units[] = {};
|
||||
weapons[] = {};
|
||||
requiredVersion = REQUIRED_VERSION;
|
||||
requiredAddons[] = {"ace_common"};
|
||||
author[] = {"commy2"};
|
||||
authorUrl = "https://github.com/commy2/";
|
||||
VERSION_CONFIG;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
class Extended_PostInit_EventHandlers {
|
||||
class AGM_SafeMode {
|
||||
clientInit = "call compile preprocessFileLineNumbers '\AGM_SafeMode\clientInit.sqf';";
|
||||
};
|
||||
};
|
||||
#include "CfgEventHandlers.hpp"
|
||||
|
||||
class AGM_Core_Default_Keys {
|
||||
class safeWeapon {
|
||||
displayName = "$STR_AGM_SafeMode_SafeMode";
|
||||
condition = "[_player] call AGM_Core_fnc_canUseWeapon";
|
||||
statement = "[_player, currentWeapon _player, currentMuzzle _player] call AGM_SafeMode_fnc_lockSafety";
|
||||
exceptions[] = {"AGM_Interaction_isNotEscorting"};
|
||||
key = 41;
|
||||
shift = 0;
|
||||
control = 1;
|
||||
alt = 0;
|
||||
};
|
||||
class ACE_Default_Keys {
|
||||
class safeWeapon {
|
||||
displayName = "$STR_ACE_SafeMode_SafeMode";
|
||||
condition = QUOTE([_player] call EFUNC(common,canUseWeapon));
|
||||
statement = QUOTE([ARR_3(_player, currentWeapon _player, currentMuzzle _player)] call FUNC(lockSafety));
|
||||
exceptions[] = {"ACE_interaction_isNotEscorting"};
|
||||
key = 41;
|
||||
shift = 0;
|
||||
control = 1;
|
||||
alt = 0;
|
||||
};
|
||||
};
|
||||
|
@ -1,65 +0,0 @@
|
||||
// by commy2
|
||||
|
||||
private ["_unit", "_weapon", "_muzzle", "_safedWeapons"];
|
||||
|
||||
_unit = _this select 0;
|
||||
_weapon = _this select 1;
|
||||
_muzzle = _this select 2;
|
||||
|
||||
// don't immediately switch back
|
||||
if (inputAction "nextWeapon" > 0) exitWith {};
|
||||
|
||||
_safedWeapons = _unit getVariable ["AGM_SafeMode_safedWeapons", []];
|
||||
|
||||
if (_weapon in _safedWeapons) exitWith {
|
||||
_this call AGM_SafeMode_fnc_unlockSafety;
|
||||
};
|
||||
|
||||
_safedWeapons pushBack _weapon;
|
||||
|
||||
_unit setVariable ["AGM_SafeMode_safedWeapons", _safedWeapons];
|
||||
|
||||
if (_unit getVariable ["AGM_SafeWeapon_actionID", -1] == -1) then {
|
||||
private ["_condition", "_statement", "_id"];
|
||||
|
||||
_condition = {
|
||||
if (
|
||||
[_this select 1] call AGM_Core_fnc_canUseWeapon
|
||||
&& {
|
||||
if (currentMuzzle (_this select 1) in ((_this select 1) getVariable ["AGM_SafeMode_safedWeapons", []])) then {
|
||||
if (inputAction "nextWeapon" > 0) exitWith {
|
||||
[_this select 1, currentWeapon (_this select 1), currentMuzzle (_this select 1)] call AGM_SafeMode_fnc_unlockSafety;
|
||||
false
|
||||
};
|
||||
true
|
||||
} else {false}
|
||||
}
|
||||
) then {
|
||||
// player hud
|
||||
[false] call AGM_SafeMode_fnc_setSafeModeVisual;
|
||||
true
|
||||
} else {
|
||||
// player hud
|
||||
[true] call AGM_SafeMode_fnc_setSafeModeVisual;
|
||||
false
|
||||
}
|
||||
};
|
||||
|
||||
_statement = {
|
||||
[_this select 1, currentWeapon (_this select 1), currentMuzzle (_this select 1)] call AGM_SafeMode_fnc_unlockSafety;
|
||||
};
|
||||
|
||||
//_id = [_unit, format ["<t color=""#FFFF00"" >%1</t>", localize "STR_AGM_SafeMode_TakeOffSafety"], "DefaultAction", _condition, {}, {true}, _statement, 10] call AGM_Core_fnc_addActionMenuEventHandler;
|
||||
_id = [_unit, "DefaultAction", _condition, {}] call AGM_Core_fnc_addActionEventHandler;
|
||||
|
||||
_unit setVariable ["AGM_SafeWeapon_actionID", _id];
|
||||
};
|
||||
|
||||
_unit selectWeapon _muzzle;//_weapon
|
||||
|
||||
// play fire mode selector sound
|
||||
[_unit, _weapon, _muzzle] call AGM_SafeMode_fnc_playChangeFiremodeSound;
|
||||
|
||||
private "_picture";
|
||||
_picture = getText (configFile >> "CfgWeapons" >> _weapon >> "picture");
|
||||
[localize "STR_AGM_SafeMode_PutOnSafety", _picture] call AGM_Core_fnc_displayTextPicture;
|
@ -1,9 +1,9 @@
|
||||
// by commy2
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_weapon", "_mode"];
|
||||
|
||||
_weapon = _this select 0;
|
||||
EXPLODE_1_PVT(_this,_weapon);
|
||||
|
||||
private ["_mode"];
|
||||
_mode = getArray (configFile >> "CfgWeapons" >> _weapon >> "modes") select 0;
|
||||
|
||||
[_mode, _weapon] select (_mode == "this")
|
63
addons/safemode/functions/fnc_lockSafety.sqf
Normal file
63
addons/safemode/functions/fnc_lockSafety.sqf
Normal file
@ -0,0 +1,63 @@
|
||||
// by commy2
|
||||
#include "script_component.hpp"
|
||||
|
||||
EXPLODE_3_PVT(_this,_unit,_weapon,_muzzle);
|
||||
|
||||
// don't immediately switch back
|
||||
if (inputAction "nextWeapon" > 0) exitWith {};
|
||||
|
||||
private ["_safedWeapons"];
|
||||
_safedWeapons = _unit getVariable [QGVAR(safedWeapons), []];
|
||||
|
||||
if (_weapon in _safedWeapons) exitWith {
|
||||
_this call FUNC(unlockSafety);
|
||||
};
|
||||
|
||||
_safedWeapons pushBack _weapon;
|
||||
|
||||
_unit setVariable [QGVAR(safedWeapons), _safedWeapons];
|
||||
|
||||
if (_unit getVariable [QGVAR(actionID), -1] == -1) then {
|
||||
private ["_condition", "_statement", "_id"];
|
||||
|
||||
_condition = {
|
||||
if (
|
||||
[_this select 1] call EFUNC(common,canUseWeapon)
|
||||
&& {
|
||||
if (currentMuzzle (_this select 1) in ((_this select 1) getVariable [QGVAR(safedWeapons), []])) then {
|
||||
if (inputAction "nextWeapon" > 0) exitWith {
|
||||
[_this select 1, currentWeapon (_this select 1), currentMuzzle (_this select 1)] call FUNC(unlockSafety);
|
||||
false
|
||||
};
|
||||
true
|
||||
} else {false}
|
||||
}
|
||||
) then {
|
||||
// player hud
|
||||
[false] call FUNC(setSafeModeVisual);
|
||||
true
|
||||
} else {
|
||||
// player hud
|
||||
[true] call FUNC(setSafeModeVisual);
|
||||
false
|
||||
}
|
||||
};
|
||||
|
||||
_statement = {
|
||||
[_this select 1, currentWeapon (_this select 1), currentMuzzle (_this select 1)] call FUNC(unlockSafety);
|
||||
};
|
||||
|
||||
//_id = [_unit, format ["<t color=""#FFFF00"" >%1</t>", localize "STR_ACE_SafeMode_TakeOffSafety"], "DefaultAction", _condition, {}, {true}, _statement, 10] call EFUNC(common,addActionMenuEventHandler);
|
||||
_id = [_unit, "DefaultAction", _condition, {}] call EFUNC(common,addActionEventHandler);
|
||||
|
||||
_unit setVariable [QGVAR(actionID), _id];
|
||||
};
|
||||
|
||||
_unit selectWeapon _muzzle;//_weapon
|
||||
|
||||
// play fire mode selector sound
|
||||
[_unit, _weapon, _muzzle] call FUNC(playChangeFiremodeSound);
|
||||
|
||||
private "_picture";
|
||||
_picture = getText (configFile >> "CfgWeapons" >> _weapon >> "picture");
|
||||
[localize "STR_ACE_SafeMode_PutOnSafety", _picture] call EFUNC(common,displayTextPicture);
|
@ -1,14 +1,13 @@
|
||||
// by commy2
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_unit", "_weapon", "_sound"];
|
||||
|
||||
_unit = _this select 0;
|
||||
_weapon = _this select 1;
|
||||
EXPLODE_2_PVT(_this,_unit,_weapon);
|
||||
|
||||
private ["_sound"];
|
||||
_sound = getArray (configFile >> "CfgWeapons" >> _weapon >> "changeFiremodeSound");
|
||||
|
||||
if (count _sound == 0) exitWith {
|
||||
playSound "AGM_Sound_Click";
|
||||
playSound "ACE_Sound_Click";
|
||||
};
|
||||
|
||||
// add file extension
|
||||
@ -27,7 +26,6 @@ if (count _sound < 3) then {_sound pushBack 1};
|
||||
if (count _sound < 4) then {_sound pushBack 0};
|
||||
|
||||
private "_position";
|
||||
|
||||
_position = _unit modelToWorld (_unit selectionPosition "RightHand");
|
||||
_position set [2, (_position select 2) + ((getPosASLW _unit select 2) - (getPosATL _unit select 2) max 0)];
|
||||
|
@ -1,11 +1,12 @@
|
||||
// by commy2
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_show", "_control"];
|
||||
|
||||
_show = _this select 0;
|
||||
EXPLODE_1_PVT(_this,_show);
|
||||
|
||||
disableSerialization;
|
||||
_control = (uiNamespace getVariable ["AGM_dlgSoldier", displayNull]) displayCtrl 187;
|
||||
|
||||
private ["_control"];
|
||||
_control = (uiNamespace getVariable ["ACE_dlgSoldier", displayNull]) displayCtrl 187;
|
||||
|
||||
if (isNull _control) exitWith {};
|
||||
|
@ -1,25 +1,23 @@
|
||||
// by commy2
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_unit", "_weapon", "_muzzle", "_safedWeapons"];
|
||||
EXPLODE_3_PVT(_this,_unit,_weapon,_muzzle);
|
||||
|
||||
_unit = _this select 0;
|
||||
_weapon = _this select 1;
|
||||
_muzzle = _this select 2;
|
||||
|
||||
_safedWeapons = _unit getVariable ["AGM_SafeMode_safedWeapons", []];
|
||||
private ["_safedWeapons"];
|
||||
_safedWeapons = _unit getVariable [QGVAR(safedWeapons), []];
|
||||
|
||||
if (_weapon in _safedWeapons) then {
|
||||
_safedWeapons = _safedWeapons - [_weapon];
|
||||
|
||||
_unit setVariable ["AGM_SafeMode_safedWeapons", _safedWeapons];
|
||||
_unit setVariable [QGVAR(safedWeapons), _safedWeapons];
|
||||
|
||||
if (count _safedWeapons == 0) then {
|
||||
private "_id";
|
||||
_id = _unit getVariable ["AGM_SafeWeapon_actionID", -1];
|
||||
_id = _unit getVariable [QGVAR(actionID), -1];
|
||||
|
||||
//[_unit, "DefaultAction", _id] call AGM_Core_fnc_removeActionMenuEventHandler;
|
||||
[_unit, "DefaultAction", _id] call AGM_Core_fnc_removeActionEventHandler;
|
||||
_unit setVariable ["AGM_SafeWeapon_actionID", -1];
|
||||
//[_unit, "DefaultAction", _id] call EFUNC(common,removeActionMenuEventHandler);
|
||||
[_unit, "DefaultAction", _id] call EFUNC(common,removeActionEventHandler);
|
||||
_unit setVariable [QGVAR(actionID), -1];
|
||||
};
|
||||
};
|
||||
|
||||
@ -53,12 +51,12 @@ if (inputAction "nextWeapon" > 0) then {
|
||||
};
|
||||
} else {
|
||||
// play fire mode selector sound
|
||||
[_unit, _weapon, _muzzle] call AGM_SafeMode_fnc_playChangeFiremodeSound;
|
||||
[_unit, _weapon, _muzzle] call FUNC(playChangeFiremodeSound);
|
||||
};
|
||||
|
||||
// player hud
|
||||
[true] call AGM_SafeMode_fnc_setSafeModeVisual;
|
||||
[true] call FUNC(setSafeModeVisual);
|
||||
|
||||
private "_picture";
|
||||
_picture = getText (configFile >> "CfgWeapons" >> _weapon >> "picture");
|
||||
[localize "STR_AGM_SafeMode_TookOffSafety", _picture] call AGM_Core_fnc_displayTextPicture;
|
||||
[localize "STR_ACE_SafeMode_TookOffSafety", _picture] call EFUNC(common,displayTextPicture);
|
1
addons/safemode/functions/script_component.hpp
Normal file
1
addons/safemode/functions/script_component.hpp
Normal file
@ -0,0 +1 @@
|
||||
#include "\z\ace\addons\safemode\script_component.hpp"
|
12
addons/safemode/script_component.hpp
Normal file
12
addons/safemode/script_component.hpp
Normal file
@ -0,0 +1,12 @@
|
||||
#define COMPONENT safemode
|
||||
#include "\z\ace\Addons\main\script_mod.hpp"
|
||||
|
||||
#ifdef DEBUG_ENABLED_SAFEMODE
|
||||
#define DEBUG_MODE_FULL
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_SETTINGS_SAFEMODE
|
||||
#define DEBUG_SETTINGS DEBUG_SETTINGS_SAFEMODE
|
||||
#endif
|
||||
|
||||
#include "\z\ace\Addons\main\script_macros.hpp"
|
@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Edited with tabler - 2014-12-20 -->
|
||||
<Project name="AGM">
|
||||
<Project name="ACE">
|
||||
<Package name="SafeMode">
|
||||
<Key ID="STR_AGM_SafeMode_SafeMode">
|
||||
<Key ID="STR_ACE_SafeMode_SafeMode">
|
||||
<English>Safe Mode</English>
|
||||
<German>Waffe sichern</German>
|
||||
<Spanish>Seguro puesto</Spanish>
|
||||
@ -11,7 +11,7 @@
|
||||
<Hungarian>Veszélytelenités</Hungarian>
|
||||
<Russian>Предохранитель</Russian>
|
||||
</Key>
|
||||
<Key ID="STR_AGM_SafeMode_TakeOffSafety">
|
||||
<Key ID="STR_ACE_SafeMode_TakeOffSafety">
|
||||
<English>Take off Safety</English>
|
||||
<German>Waffe entsichern</German>
|
||||
<Spanish>Quitar seguro</Spanish>
|
||||
@ -20,7 +20,7 @@
|
||||
<Hungarian>Veszélyesités</Hungarian>
|
||||
<Russian>Снять с предохранителя</Russian>
|
||||
</Key>
|
||||
<Key ID="STR_AGM_SafeMode_PutOnSafety">
|
||||
<Key ID="STR_ACE_SafeMode_PutOnSafety">
|
||||
<English>Put on Safety</English>
|
||||
<German>Waffe gesichert</German>
|
||||
<Spanish>Poner seguro</Spanish>
|
||||
@ -29,7 +29,7 @@
|
||||
<Hungarian>Veszélytelenitve</Hungarian>
|
||||
<Russian>Поставить на предохранитель</Russian>
|
||||
</Key>
|
||||
<Key ID="STR_AGM_SafeMode_TookOffSafety">
|
||||
<Key ID="STR_ACE_SafeMode_TookOffSafety">
|
||||
<English>Took off Safety</English>
|
||||
<German>Waffe entsichert</German>
|
||||
<Spanish>Seguro quitado</Spanish>
|
||||
|
Loading…
Reference in New Issue
Block a user