mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Add Weapon Attachments interaction (#7706)
* Add Weapon Attachments interaction * Apply recommended changes * Format addPEH Co-authored-by: mharis001 <34453221+mharis001@users.noreply.github.com> * Remove toLower * Update required CBA version * Rename category to Accessories * Change setting var name * Add setting description * Fix notification size * Optimize with new commands Co-authored-by: mharis001 <34453221+mharis001@users.noreply.github.com>
This commit is contained in:
parent
c60e4111d8
commit
69c3d2bb65
@ -47,7 +47,7 @@ private _isChemlight = _attachedObject isKindOf "Chemlight_base";
|
||||
|
||||
// Exit if can't add the item
|
||||
if (!([_unit, _itemName] call CBA_fnc_canAddItem) && {!_isChemlight}) exitWith {
|
||||
[localize LSTRING(Inventory_Full)] call EFUNC(common,displayTextStructured);
|
||||
[LELSTRING(common,Inventory_Full)] call EFUNC(common,displayTextStructured);
|
||||
};
|
||||
|
||||
// Add item to inventory (unless it's a chemlight)
|
||||
|
@ -154,23 +154,6 @@
|
||||
<Chinesesimp>已取下萤光棒</Chinesesimp>
|
||||
<Turkish>Işık Çubuğu Söküldü</Turkish>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Attach_Inventory_Full">
|
||||
<English>No inventory space</English>
|
||||
<German>Kein Platz im Inventar</German>
|
||||
<Spanish>Sin espacio en inventario</Spanish>
|
||||
<Polish>Brak miejsca w ekwipunku</Polish>
|
||||
<French>Pas de place dans l'inventaire</French>
|
||||
<Czech>Nedostatek místa v inventáři</Czech>
|
||||
<Portuguese>Sem espaço no inventário</Portuguese>
|
||||
<Italian>Non hai più spazio</Italian>
|
||||
<Hungarian>Nincs több hely</Hungarian>
|
||||
<Russian>В инвентаре нет места</Russian>
|
||||
<Japanese>インベントリに空きがない</Japanese>
|
||||
<Korean>넣을 공간이 없음</Korean>
|
||||
<Chinese>無可用空間</Chinese>
|
||||
<Chinesesimp>无可用空间</Chinesesimp>
|
||||
<Turkish>Envanter de alan yok</Turkish>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Attach_IrStrobe_Name">
|
||||
<English>IR Strobe</English>
|
||||
<German>IR-Stroboskop</German>
|
||||
|
@ -49,23 +49,6 @@
|
||||
<Spanish>%1<br/>Preparado</Spanish>
|
||||
<Turkish>%1<br/> Hazırlandı</Turkish>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Chemlights_Inventory_Full">
|
||||
<English>No inventory space</English>
|
||||
<German>Kein Platz im Inventar</German>
|
||||
<Spanish>Sin espacio en inventario</Spanish>
|
||||
<Polish>Brak miejsca w ekwipunku</Polish>
|
||||
<French>Pas de place dans l'inventaire</French>
|
||||
<Czech>Nedostatek místa v inventáři</Czech>
|
||||
<Portuguese>Sem espaço no inventário</Portuguese>
|
||||
<Italian>Nessuno spazio nell'inventario</Italian>
|
||||
<Hungarian>Nincs több hely</Hungarian>
|
||||
<Russian>В инвентаре нет места</Russian>
|
||||
<Japanese>インベントリに空きがありません</Japanese>
|
||||
<Korean>소지품 공간이 없음</Korean>
|
||||
<Chinese>已無存放空間</Chinese>
|
||||
<Chinesesimp>已无存放空间</Chinesesimp>
|
||||
<Turkish>Envanter de alan yok</Turkish>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Chemlights_Box_DisplayName">
|
||||
<English>[ACE] Chemlights</English>
|
||||
<Japanese>[ACE] ケミライト</Japanese>
|
||||
|
@ -110,7 +110,6 @@ private _settings = configProperties [configFile >> "ACE_Settings", "(isClass _x
|
||||
|
||||
private _gvarName = _varName select [_addonSearchCount];
|
||||
|
||||
_output pushBack "";
|
||||
_output pushBack format ["["];
|
||||
_output pushBack format [" QGVAR(%1), ""%2"",", _gvarName, _cbaSettingType];
|
||||
_output pushBack format [" [LSTRING(), LSTRING()], // %1, %2", _localizedName, _localizedDescription]; //IGNORE_STRING_WARNING(str_ace_common_);
|
||||
@ -124,6 +123,7 @@ private _settings = configProperties [configFile >> "ACE_Settings", "(isClass _x
|
||||
};
|
||||
_output pushBack format [" %1 // Needs mission restart", _warnIfChangedMidMission];
|
||||
_output pushBack "] call CBA_fnc_addSetting;";
|
||||
_output pushBack "";
|
||||
} forEach _settings;
|
||||
|
||||
copyToClipboard (_output joinString endl);
|
||||
|
@ -1296,6 +1296,23 @@
|
||||
<Chinesesimp>没有空间可卸载</Chinesesimp>
|
||||
<Korean>언로드 할 공간이 없습니다.</Korean>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Common_Inventory_Full">
|
||||
<English>No inventory space</English>
|
||||
<German>Kein Platz im Inventar</German>
|
||||
<Spanish>Sin espacio en inventario</Spanish>
|
||||
<Polish>Brak miejsca w ekwipunku</Polish>
|
||||
<French>Pas de place dans l'inventaire</French>
|
||||
<Czech>Nedostatek místa v inventáři</Czech>
|
||||
<Portuguese>Sem espaço no inventário</Portuguese>
|
||||
<Italian>Non hai più spazio</Italian>
|
||||
<Hungarian>Nincs több hely</Hungarian>
|
||||
<Russian>В инвентаре нет места</Russian>
|
||||
<Japanese>インベントリに空きがない</Japanese>
|
||||
<Korean>넣을 공간이 없음</Korean>
|
||||
<Chinese>無可用空間</Chinese>
|
||||
<Chinesesimp>无可用空间</Chinesesimp>
|
||||
<Turkish>Envanter de alan yok</Turkish>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Common_KeybindToggle">
|
||||
<English>Toggle</English>
|
||||
<Polish>переключить</Polish>
|
||||
|
@ -21,7 +21,7 @@ params ["_player", ["_displayHint", false, [false]]];
|
||||
if (!GVAR(EnableCombatDeafness)) exitWith {};
|
||||
|
||||
if !([_player, "ACE_EarPlugs"] call CBA_fnc_canAddItem) exitWith { // inventory full
|
||||
[localize LSTRING(Inventory_Full)] call EFUNC(common,displayTextStructured);
|
||||
[LELSTRING(common,Inventory_Full)] call EFUNC(common,displayTextStructured);
|
||||
};
|
||||
|
||||
// Plugs already in and removing them.
|
||||
|
@ -119,23 +119,6 @@
|
||||
<Chinese>你沒有耳塞</Chinese>
|
||||
<Turkish>Kulak Tıkacın Yok</Turkish>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Hearing_Inventory_Full">
|
||||
<English>No inventory space</English>
|
||||
<German>Kein Platz im Inventar</German>
|
||||
<Spanish>Sin espacio en el inventario</Spanish>
|
||||
<Polish>Brak miejsca w ekwipunku</Polish>
|
||||
<French>Il n'y a plus de place dans l'inventaire.</French>
|
||||
<Czech>Není místo v inventáři</Czech>
|
||||
<Italian>Non hai abbastanza spazio</Italian>
|
||||
<Portuguese>Não há espaço no inventário</Portuguese>
|
||||
<Hungarian>Nincs több hely</Hungarian>
|
||||
<Russian>Нет места в инвентаре</Russian>
|
||||
<Japanese>インベントリに空きがありません</Japanese>
|
||||
<Korean>넣을 공간이 없습니다</Korean>
|
||||
<Chinesesimp>无可用空间</Chinesesimp>
|
||||
<Chinese>無可用空間</Chinese>
|
||||
<Turkish>Envanterin de alan yok</Turkish>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Hearing_DisableEarRinging_DisplayName">
|
||||
<English>Disable ear ringing</English>
|
||||
<French>Désactiver les bourdonnements</French>
|
||||
|
@ -1,24 +1,12 @@
|
||||
|
||||
class ACE_Settings {
|
||||
class GVAR(enableTeamManagement) {
|
||||
category = CSTRING(DisplayName);
|
||||
displayName = CSTRING(EnableTeamManagement_DisplayName);
|
||||
description = CSTRING(EnableTeamManagement_Description);
|
||||
value = 1;
|
||||
typeName = "BOOL";
|
||||
movedToSQF = 1;
|
||||
};
|
||||
class GVAR(enableMagazinePassing) {
|
||||
category = CSTRING(DisplayName);
|
||||
value = 1;
|
||||
typeName = "BOOL";
|
||||
isClientSettable = 1;
|
||||
displayName = CSTRING(PassMagazineSetting);
|
||||
movedToSQF = 1;
|
||||
};
|
||||
class GVAR(disableNegativeRating) {
|
||||
category = CSTRING(DisplayName);
|
||||
displayName = CSTRING(DisableNegativeRating_DisplayName);
|
||||
description = CSTRING(DisableNegativeRating_Description);
|
||||
value = 0;
|
||||
typeName = "BOOL";
|
||||
movedToSQF = 1;
|
||||
};
|
||||
};
|
||||
|
@ -312,6 +312,14 @@ class CfgVehicles {
|
||||
statement = "";
|
||||
showDisabled = 1;
|
||||
icon = ""; // @todo
|
||||
|
||||
class GVAR(weaponAttachments) {
|
||||
displayName = "$STR_A3_CfgEditorSubcategories_EdSubcat_SideSlot0";
|
||||
condition = QGVAR(enableWeaponAttachments);
|
||||
exceptions[] = {"isNotInside", "isNotSwimming", "isNotSitting"};
|
||||
insertChildren = QUOTE(call DFUNC(getWeaponAttachmentsActions));
|
||||
modifierFunction = QUOTE(_this select 3 set [ARR_2(2, getText (configFile >> 'CfgWeapons' >> currentWeapon (_this select 0) >> 'picture'))];);
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -33,6 +33,10 @@ PREP(pardon);
|
||||
PREP(canPullOutBody);
|
||||
PREP(pullOutBody);
|
||||
|
||||
// Weapon Attachments
|
||||
PREP(getWeaponAttachmentsActions);
|
||||
PREP(switchWeaponAttachment);
|
||||
|
||||
// interaction with doors
|
||||
PREP(getDoor);
|
||||
PREP(getGlassDoor);
|
||||
|
@ -135,3 +135,9 @@ GVAR(isOpeningDoor) = false;
|
||||
}];
|
||||
};
|
||||
}] call CBA_fnc_addEventHandler;
|
||||
|
||||
{
|
||||
[_x, {
|
||||
[QGVAR(clearWeaponAttachmentsActionsCache)] call CBA_fnc_localEvent;
|
||||
}] call CBA_fnc_addPlayerEventHandler;
|
||||
} forEach ["loadout", "weapon"];
|
||||
|
@ -6,6 +6,8 @@ PREP_RECOMPILE_START;
|
||||
#include "XEH_PREP.hpp"
|
||||
PREP_RECOMPILE_END;
|
||||
|
||||
#include "initSettings.sqf"
|
||||
|
||||
DFUNC(repair_Statement) = { // moved from config because of build problems
|
||||
TRACE_1("repair_Statement",_this);
|
||||
{
|
||||
|
@ -0,0 +1,68 @@
|
||||
#include "script_component.hpp"
|
||||
/*
|
||||
* Author: mharis001, Dystopian
|
||||
* Returns children actions for weapon attachment switching.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* Actions <ARRAY>
|
||||
*
|
||||
* Example:
|
||||
* player call ace_interaction_fnc_getWeaponAttachmentsActions
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
params ["_unit"];
|
||||
|
||||
[_unit, {
|
||||
params ["_unit"];
|
||||
|
||||
private _currentWeapon = currentWeapon _unit;
|
||||
if (_currentWeapon isEqualTo "") exitWith {[]};
|
||||
private _weaponItems = _unit weaponAccessories _currentWeapon;
|
||||
private _cfgWeapons = configFile >> "CfgWeapons";
|
||||
private _actions = [];
|
||||
|
||||
// "attach" actions
|
||||
private _items = _unit call EFUNC(common,uniqueItems);
|
||||
private _compatibleItems = _currentWeapon call CBA_fnc_compatibleItems;
|
||||
{
|
||||
private _config = _cfgWeapons >> _x;
|
||||
private _name = format [LLSTRING(weaponAttachmentsAttach), getText (_config >> "displayName")];
|
||||
private _picture = getText (_config >> "picture");
|
||||
private _type = getNumber (_config >> "itemInfo" >> "type");
|
||||
private _oldAttachment = _weaponItems select ([TYPE_MUZZLE, TYPE_FLASHLIGHT, TYPE_OPTICS, TYPE_BIPOD] find _type);
|
||||
|
||||
private _action = [
|
||||
_x, _name, _picture,
|
||||
LINKFUNC(switchWeaponAttachment),
|
||||
{true},
|
||||
{},
|
||||
[_currentWeapon, _x, _oldAttachment]
|
||||
] call EFUNC(interact_menu,createAction);
|
||||
_actions pushBack [_action, [], _unit];
|
||||
} forEach ((_items arrayIntersect _compatibleItems) - _weaponItems);
|
||||
|
||||
// "detach" actions
|
||||
{
|
||||
if (_x isEqualTo "") then {continue};
|
||||
|
||||
private _config = _cfgWeapons >> _x;
|
||||
private _name = format [LLSTRING(weaponAttachmentsDetach), getText (_config >> "displayName")];
|
||||
private _picture = getText (_config >> "picture");
|
||||
|
||||
private _action = [
|
||||
_x, _name, _picture,
|
||||
LINKFUNC(switchWeaponAttachment),
|
||||
{true},
|
||||
{},
|
||||
[_currentWeapon, "", _x]
|
||||
] call EFUNC(interact_menu,createAction);
|
||||
_actions pushBack [_action, [], _unit];
|
||||
} forEach _weaponItems;
|
||||
|
||||
_actions
|
||||
}, _unit, QGVAR(weaponAttachmentsActions), 5, QGVAR(clearWeaponAttachmentsActionsCache)] call EFUNC(common,cachedCall);
|
59
addons/interaction/functions/fnc_switchWeaponAttachment.sqf
Normal file
59
addons/interaction/functions/fnc_switchWeaponAttachment.sqf
Normal file
@ -0,0 +1,59 @@
|
||||
#include "script_component.hpp"
|
||||
/*
|
||||
* Author: mharis001, Dystopian
|
||||
* Switches weapon attachment.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Target <OBJECT>
|
||||
* 1: Player (not used) <OBJECT>
|
||||
* 2: Action params <ARRAY>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [player, player, [currentWeapon player, "acc_flashlight", ""]] call ace_interaction_fnc_switchWeaponAttachment
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
params ["_unit", "", "_actionParams"];
|
||||
_actionParams params ["_weapon", "_newAttachment", "_oldAttachment"];
|
||||
TRACE_3("Switching attachment",_weapon,_newAttachment,_oldAttachment);
|
||||
|
||||
[_unit, "Gear"] call EFUNC(common,doGesture);
|
||||
|
||||
private _addNew = _newAttachment isNotEqualTo "";
|
||||
private _removeOld = _oldAttachment isNotEqualTo "";
|
||||
|
||||
if (_addNew) then {
|
||||
_unit removeItem _newAttachment;
|
||||
};
|
||||
|
||||
if (_removeOld && {!([_unit, _oldAttachment] call CBA_fnc_canAddItem)}) exitWith {
|
||||
LOG("no space");
|
||||
[LELSTRING(common,Inventory_Full)] call EFUNC(common,displayTextStructured);
|
||||
if (_addNew) then {
|
||||
_unit addItem _newAttachment;
|
||||
};
|
||||
};
|
||||
|
||||
if (_removeOld) then {
|
||||
[{
|
||||
params ["_unit", "_weapon", "_oldAttachment"];
|
||||
switch (_weapon) do {
|
||||
case (primaryWeapon _unit): {_unit removePrimaryWeaponItem _oldAttachment;};
|
||||
case (handgunWeapon _unit): {_unit removeHandgunItem _oldAttachment;};
|
||||
default {_unit removeSecondaryWeaponItem _oldAttachment;};
|
||||
};
|
||||
_unit addItem _oldAttachment;
|
||||
}, [_unit, _weapon, _oldAttachment], 0.3] call CBA_fnc_waitAndExecute;
|
||||
};
|
||||
|
||||
if (!_addNew) exitWith {};
|
||||
|
||||
[{
|
||||
params ["_unit", "_weapon", "_newAttachment"];
|
||||
_unit addWeaponItem [_weapon, _newAttachment];
|
||||
[[getText (configFile >> "CfgWeapons" >> _newAttachment >> "picture"), 4], true] call CBA_fnc_notify;
|
||||
}, [_unit, _weapon, _newAttachment], 1] call CBA_fnc_waitAndExecute;
|
31
addons/interaction/initSettings.sqf
Normal file
31
addons/interaction/initSettings.sqf
Normal file
@ -0,0 +1,31 @@
|
||||
[
|
||||
QGVAR(enableTeamManagement), "CHECKBOX",
|
||||
[LSTRING(EnableTeamManagement_DisplayName), LSTRING(EnableTeamManagement_Description)],
|
||||
format ["ACE %1", LLSTRING(DisplayName)],
|
||||
true,
|
||||
true
|
||||
] call CBA_fnc_addSetting;
|
||||
|
||||
[
|
||||
QGVAR(enableMagazinePassing), "CHECKBOX",
|
||||
LSTRING(PassMagazineSetting),
|
||||
format ["ACE %1", LLSTRING(DisplayName)],
|
||||
true
|
||||
] call CBA_fnc_addSetting;
|
||||
|
||||
[
|
||||
QGVAR(disableNegativeRating), "CHECKBOX",
|
||||
[LSTRING(DisableNegativeRating_DisplayName), LSTRING(DisableNegativeRating_Description)],
|
||||
format ["ACE %1", LLSTRING(DisplayName)],
|
||||
false,
|
||||
true,
|
||||
{[QGVAR(disableNegativeRating), _this] call EFUNC(common,cbaSettings_settingChanged)},
|
||||
true
|
||||
] call CBA_fnc_addSetting;
|
||||
|
||||
[
|
||||
QGVAR(enableWeaponAttachments), "CHECKBOX",
|
||||
["str_a3_cfgeditorcategories_edcat_weaponattachments0", LSTRING(weaponAttachments_Description)],
|
||||
format ["ACE %1", LLSTRING(DisplayName)],
|
||||
true
|
||||
] call CBA_fnc_addSetting;
|
@ -1203,5 +1203,17 @@
|
||||
<Spanish>Romper parabrisas</Spanish>
|
||||
<Turkish>Ön camı parçala</Turkish>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Interaction_weaponAttachmentsAttach">
|
||||
<English>Attach %1</English>
|
||||
<Russian>Установить %1</Russian>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Interaction_weaponAttachmentsDetach">
|
||||
<English>Detach %1</English>
|
||||
<Russian>Снять %1</Russian>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Interaction_weaponAttachments_Description">
|
||||
<English>Enables attach/detach weapon attachment actions for current weapon.</English>
|
||||
<Russian>Включает действия Установить/Снять для приспособлений текущего оружия.</Russian>
|
||||
</Key>
|
||||
</Package>
|
||||
</Project>
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
// MINIMAL required version for the Mod. Components can specify others..
|
||||
#define REQUIRED_VERSION 2.02
|
||||
#define REQUIRED_CBA_VERSION {3,15,0}
|
||||
#define REQUIRED_CBA_VERSION {3,15,2}
|
||||
|
||||
#ifdef COMPONENT_BEAUTIFIED
|
||||
#define COMPONENT_NAME QUOTE(ACE3 - COMPONENT_BEAUTIFIED)
|
||||
|
Loading…
Reference in New Issue
Block a user