mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Use CBA Accessory Functions for Laser mode switching (#4855)
* Use CBA Accessory Functions for Laser mode switching * Use CBA ACC EH to prevent switching to unusable lzr (#4860) * Use CBA ACC EH to prevent switching to unusable lzr * Re-call CBA_accessory_fnc_switchAttachment * Require CBA 3.2.0
This commit is contained in:
parent
fc245d9fb5
commit
bc70571765
@ -1,4 +1,3 @@
|
||||
|
||||
class Extended_PreStart_EventHandlers {
|
||||
class ADDON {
|
||||
init = QUOTE(call COMPILE_FILE(XEH_preStart));
|
||||
|
@ -9,16 +9,18 @@ class CfgWeapons {
|
||||
class InventoryFlashLightItem_Base_F;
|
||||
|
||||
class acc_pointer_IR: ItemCore {
|
||||
ACE_nextModeClass = "ACE_acc_pointer_red";
|
||||
ACE_modeDescription = CSTRING(IRLaser);
|
||||
MRT_SwitchItemNextClass = "ACE_acc_pointer_red";
|
||||
MRT_SwitchItemPrevClass = "ACE_acc_pointer_red";
|
||||
MRT_switchItemHintText = CSTRING(IRLaser);
|
||||
|
||||
displayName = CSTRING(red);
|
||||
descriptionUse = CSTRING(useLaser);
|
||||
};
|
||||
|
||||
class ACE_acc_pointer_red: ItemCore {
|
||||
ACE_nextModeClass = "acc_pointer_IR";
|
||||
ACE_modeDescription = CSTRING(Laser);
|
||||
MRT_SwitchItemNextClass = "acc_pointer_IR";
|
||||
MRT_SwitchItemPrevClass = "acc_pointer_IR";
|
||||
MRT_switchItemHintText = CSTRING(Laser);
|
||||
|
||||
ACE_laserpointer = 1;
|
||||
|
||||
@ -68,8 +70,9 @@ class CfgWeapons {
|
||||
};
|
||||
|
||||
class ACE_acc_pointer_green_IR: acc_pointer_IR {
|
||||
ACE_nextModeClass = "ACE_acc_pointer_green";
|
||||
ACE_modeDescription = CSTRING(IRLaser);
|
||||
MRT_SwitchItemNextClass = "ACE_acc_pointer_green";
|
||||
MRT_SwitchItemPrevClass = "ACE_acc_pointer_green";
|
||||
MRT_switchItemHintText = CSTRING(IRLaser);
|
||||
|
||||
author = ECSTRING(common,ACETeam);
|
||||
_generalMacro = "ACE_acc_pointer_green";
|
||||
@ -78,8 +81,9 @@ class CfgWeapons {
|
||||
};
|
||||
|
||||
class ACE_acc_pointer_green: ACE_acc_pointer_red {
|
||||
ACE_nextModeClass = "ACE_acc_pointer_green_IR";
|
||||
ACE_modeDescription = CSTRING(Laser);
|
||||
MRT_SwitchItemNextClass = "ACE_acc_pointer_green_IR";
|
||||
MRT_SwitchItemPrevClass = "ACE_acc_pointer_green_IR";
|
||||
MRT_switchItemHintText = CSTRING(Laser);
|
||||
|
||||
ACE_laserpointer = 2;
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
|
||||
PREP(drawLaserpoint);
|
||||
PREP(getNearUnits);
|
||||
PREP(onDraw);
|
||||
PREP(switchLaserLightMode);
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
// fixes laser when being captured. Needed, because the selectionPosition of the right hand is used
|
||||
[QEGVAR(captives,setHandcuffed), {if (_this select 1) then {(_this select 0) action ["ace_gunLightOff", _this select 0]};}] call CBA_fnc_addEventHandler;
|
||||
[QEGVAR(captives,setHandcuffed), {if (_this select 1) then {(_this select 0) action ["GunLightOff", _this select 0]};}] call CBA_fnc_addEventHandler;
|
||||
|
||||
if (!hasInterface) exitWith {};
|
||||
|
||||
@ -12,11 +12,18 @@ GVAR(laserClassesCache) = [] call CBA_fnc_createNamespace;
|
||||
GVAR(redLaserUnits) = [];
|
||||
GVAR(greenLaserUnits) = [];
|
||||
|
||||
#include "initKeybinds.sqf"
|
||||
|
||||
["ace_settingsInitialized", {
|
||||
// if not enabled, dont't add draw eventhandler or PFEH (for performance)
|
||||
if !(GVAR(enabled)) exitWith {};
|
||||
// If not enabled, dont't add draw eventhandler or PFEH (for performance)
|
||||
if (!GVAR(enabled)) exitWith {
|
||||
["CBA_attachmentSwitched", {
|
||||
params ["_unit", "_prevItem", "_newItem", "_currWeaponType"];
|
||||
TRACE_4("CBA_attachmentSwitched eh",_unit,_prevItem,_newItem,_currWeaponType);
|
||||
if ((getNumber (configFile >> "CfgWeapons" >> _newItem >> "ACE_laserpointer")) > 0) then {
|
||||
TRACE_1("removing ACE_laserpointer",getNumber (configFile >> "CfgWeapons" >> _newItem >> "ACE_laserpointer"));
|
||||
[1, "prev"] call CBA_accessory_fnc_switchAttachment;
|
||||
};
|
||||
}] call CBA_fnc_addEventHandler;
|
||||
};
|
||||
|
||||
[{
|
||||
private _oldNearUnits = GVAR(nearUnits);
|
||||
|
@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Author: Commy2
|
||||
* Switch between laser modes.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
* 1: Weapon <STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit", "_weapon"];
|
||||
|
||||
private _pointer = (_unit weaponAccessories _weapon) select 1;
|
||||
|
||||
if (_pointer == "") exitWith {};
|
||||
|
||||
private _config = configFile >> "CfgWeapons" >> _pointer;
|
||||
|
||||
private _nextPointer = getText (_config >> "ACE_nextModeClass");
|
||||
|
||||
if (_nextPointer == "") exitWith {};
|
||||
|
||||
//If system disabled, don't switch to a laser:
|
||||
private _nextPointerIsLaser = getNumber (configFile >> "CfgWeapons" >> _nextPointer >> "ACE_laserpointer");
|
||||
if ((!GVAR(enabled)) && {_nextPointerIsLaser == 1}) exitWith {};
|
||||
|
||||
// disable inheritance for this entry, because addons claim this as a base class for convenience
|
||||
if !((_config >> "ACE_nextModeClass") in configProperties [_config, "true", false]) exitWith {};
|
||||
|
||||
_unit addWeaponItem [_weapon, _nextPointer];
|
||||
|
||||
private _error = false;
|
||||
|
||||
if ((_unit weaponAccessories _weapon) select 1 != _nextPointer) then {
|
||||
ERROR("NextPointer not compatible");
|
||||
_unit addWeaponItem [_weapon, _pointer];
|
||||
_error = true;
|
||||
};
|
||||
|
||||
if (!_error) then {
|
||||
private _description = getText (configFile >> "CfgWeapons" >> _nextPointer >> "ACE_modeDescription");
|
||||
private _picture = getText (configFile >> "CfgWeapons" >> _nextPointer >> "picture");
|
||||
|
||||
[_description, _picture] call EFUNC(common,displayTextPicture);
|
||||
} else {
|
||||
ERROR_3("Failed to add %1 to %2 - reverting to %3",_nextPointer,_weapon,_pointer);
|
||||
};
|
||||
|
||||
playSound "ACE_Sound_Click";
|
@ -1,13 +0,0 @@
|
||||
// by commy2
|
||||
|
||||
["ACE3 Weapons", QGVAR(switchLaserLightMode), localize LSTRING(switchLaserLight),
|
||||
{
|
||||
// Conditions: canInteract
|
||||
if !([ACE_player, objNull, ["isNotInside", "isNotSitting"]] call EFUNC(common,canInteractWith)) exitWith {false};
|
||||
// Conditions: specific
|
||||
if !([ACE_player] call CBA_fnc_canUseWeapon) exitWith {false};
|
||||
|
||||
[ACE_player, currentWeapon ACE_player] call FUNC(switchLaserLightMode);
|
||||
true
|
||||
},
|
||||
{false}, [38, [false, true, false]], false] call CBA_fnc_addKeybind;
|
@ -10,7 +10,7 @@
|
||||
|
||||
// MINIMAL required version for the Mod. Components can specify others..
|
||||
#define REQUIRED_VERSION 1.64
|
||||
#define REQUIRED_CBA_VERSION {3,1,2}
|
||||
#define REQUIRED_CBA_VERSION {3,2,0}
|
||||
|
||||
#ifdef COMPONENT_BEAUTIFIED
|
||||
#define COMPONENT_NAME QUOTE(ACE3 - COMPONENT_BEAUTIFIED)
|
||||
|
Loading…
Reference in New Issue
Block a user