mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Trenches - Add modded Entrenching Tools support (#8999)
* Add support for other entrenching tools * Docs * Remove unused variable * Check unit weapons for entrenching tool `weapons` returns weapons in weapon slots and from all containers. * Update addons/trenches/README.md Co-authored-by: Jouni Järvinen <rautamiekka@users.noreply.github.com> * Support for shovel Backpacks * Update XEH_preStart.sqf * Add Arsenal "Entrenching Tool" stat Co-authored-by: Jouni Järvinen <rautamiekka@users.noreply.github.com> Co-authored-by: PabstMirror <pabstmirror@gmail.com>
This commit is contained in:
parent
b97056f527
commit
508e669e05
13
addons/trenches/ACE_Arsenal_Stats.hpp
Normal file
13
addons/trenches/ACE_Arsenal_Stats.hpp
Normal file
@ -0,0 +1,13 @@
|
||||
class EGVAR(arsenal,stats) {
|
||||
class statBase;
|
||||
class GVAR(entrenchingTool): statBase {
|
||||
scope = 2;
|
||||
priority = -1;
|
||||
stats[] = {QGVAR(entrenchingTool)};
|
||||
displayName = CSTRING(EntrenchingToolName);
|
||||
showText = 1;
|
||||
textStatement = QUOTE(localize 'STR_ACE_Common_Yes'); // using localization macros in QUOTE is a PITA
|
||||
condition = QUOTE(getNumber (_this select 1 >> (_this select 0) select 0) > 0);
|
||||
tabs[] = {{0,1,5}, {7}};
|
||||
};
|
||||
};
|
@ -12,5 +12,7 @@ class CfgWeapons {
|
||||
class ItemInfo: CBA_MiscItem_ItemInfo {
|
||||
mass = 10;
|
||||
};
|
||||
|
||||
GVAR(entrenchingTool) = 1;
|
||||
};
|
||||
};
|
||||
|
@ -1,17 +1,7 @@
|
||||
ace_trenches
|
||||
=================
|
||||
|
||||
Adds item 'ACE_entrenchingtool'
|
||||
Provides players with the capability of digging trenches.
|
||||
|
||||
Adds item 'ACE_EntrenchingTool'
|
||||
Adds 2 trenches; Envelope - Small & Envelop - Big
|
||||
|
||||
### Whitelist surfaces for digging
|
||||
Single surfaces can be whitelisted by adding `ACE_canDig = 1` into `CfgSurfaces`.
|
||||
Example:
|
||||
```cpp
|
||||
class CfgSurfaces {
|
||||
class myAwesomeSurface {
|
||||
ACE_canDig = 1;
|
||||
};
|
||||
};
|
||||
```
|
||||
|
||||
|
@ -11,6 +11,7 @@ PREP(handlePlayerChanged);
|
||||
PREP(handlePlayerInventoryChanged);
|
||||
PREP(handleScrollWheel);
|
||||
PREP(handleUnconscious);
|
||||
PREP(hasEntrenchingTool);
|
||||
PREP(placeCancel);
|
||||
PREP(placeConfirm);
|
||||
PREP(placeTrench);
|
||||
|
@ -8,4 +8,6 @@ PREP_RECOMPILE_END;
|
||||
|
||||
#include "initSettings.sqf"
|
||||
|
||||
GVAR(entrenchingTools) = call (uiNamespace getVariable QGVAR(entrenchingTools));
|
||||
|
||||
ADDON = true;
|
||||
|
@ -1,3 +1,9 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
#include "XEH_PREP.hpp"
|
||||
|
||||
private _entrenchingTools = (QUOTE(getNumber (_x >> QQGVAR(entrenchingTool)) > 0) configClasses (configFile >> "CfgWeapons") apply {configName _x});
|
||||
_entrenchingTools append (QUOTE(getNumber (_x >> QQGVAR(entrenchingTool)) > 0) configClasses (configFile >> "CfgVehicles") apply {configName _x});
|
||||
TRACE_1("",_entrenchingTools);
|
||||
|
||||
uiNamespace setVariable [QGVAR(entrenchingTools), compileFinal str _entrenchingTools];
|
||||
|
@ -14,6 +14,7 @@ class CfgPatches {
|
||||
};
|
||||
};
|
||||
|
||||
#include "ACE_Arsenal_Stats.hpp"
|
||||
#include "CfgEventHandlers.hpp"
|
||||
#include "CfgVehicles.hpp"
|
||||
#include "CfgWeapons.hpp"
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
params ["_trench", "_unit"];
|
||||
|
||||
if !("ACE_EntrenchingTool" in (_unit call EFUNC(common,uniqueItems))) exitWith {false};
|
||||
if !(_unit call FUNC(hasEntrenchingTool)) exitWith {false};
|
||||
|
||||
// Prevent camouflage if not fully dug
|
||||
if ((_trench getVariable [QGVAR(progress), 0]) != 1) exitWith {false};
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
params ["_trench", "_unit"];
|
||||
|
||||
if !("ACE_EntrenchingTool" in (_unit call EFUNC(common,uniqueItems))) exitWith {false};
|
||||
if !(_unit call FUNC(hasEntrenchingTool)) exitWith {false};
|
||||
if ((_trench getVariable [QGVAR(progress), 1]) >= 1) exitWith {false};
|
||||
|
||||
// Prevent removing/digging trench by more than one person
|
||||
|
@ -17,6 +17,6 @@
|
||||
|
||||
params ["_unit"];
|
||||
|
||||
if !("ACE_EntrenchingTool" in (_unit call EFUNC(common,uniqueItems))) exitWith {false};
|
||||
if !(_unit call FUNC(hasEntrenchingTool)) exitWith {false};
|
||||
|
||||
_unit call EFUNC(common,canDig)
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
params ["_trench", "_unit"];
|
||||
|
||||
if !("ACE_EntrenchingTool" in (_unit call EFUNC(common,uniqueItems))) exitWith {false};
|
||||
if !(_unit call FUNC(hasEntrenchingTool)) exitWith {false};
|
||||
|
||||
// Prevent removing/digging trench by more than one person
|
||||
if (_trench getVariable [QGVAR(digging), false]) exitWith {false};
|
||||
|
@ -67,7 +67,7 @@ private _fnc_onFailure = {
|
||||
};
|
||||
private _fnc_condition = {
|
||||
(_this select 0) params ["_unit"];
|
||||
"ACE_EntrenchingTool" in (_unit call EFUNC(common,uniqueItems))
|
||||
_unit call FUNC(hasEntrenchingTool)
|
||||
};
|
||||
[(_digTimeLeft + 0.5), [_unit, _trench], _fnc_onFinish, _fnc_onFailure, localize LSTRING(DiggingTrench), _fnc_condition] call EFUNC(common,progressBar);
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
params ["_unit"];
|
||||
|
||||
if (_unit getVariable [QGVAR(isPlacing), false]) then {
|
||||
if !("ACE_EntrenchingTool" in (_unit call EFUNC(common,uniqueItems))) then {
|
||||
if !(_unit call FUNC(hasEntrenchingTool)) then {
|
||||
[_unit] call FUNC(placeCancel);
|
||||
};
|
||||
};
|
||||
|
26
addons/trenches/functions/fnc_hasEntrenchingTool.sqf
Normal file
26
addons/trenches/functions/fnc_hasEntrenchingTool.sqf
Normal file
@ -0,0 +1,26 @@
|
||||
#include "script_component.hpp"
|
||||
/*
|
||||
* Author: veteran29
|
||||
* Checks if unit has entrenching tool.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* Has entrenching tool <BOOL>
|
||||
*
|
||||
* Example:
|
||||
* [bob] call ace_trenches_fnc_hasEntrenchingTool
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
|
||||
params [
|
||||
["_unit", objNull, [objNull]]
|
||||
];
|
||||
|
||||
private _uniqueItems = _unit call EFUNC(common,uniqueItems);
|
||||
_uniqueItems append weapons _unit;
|
||||
_uniqueItems pushBack backpack _unit;
|
||||
|
||||
GVAR(entrenchingTools) findIf {_x in _uniqueItems} != -1 // return
|
@ -66,7 +66,7 @@ private _fnc_onFailure = {
|
||||
};
|
||||
private _fnc_condition = {
|
||||
(_this select 0) params ["_unit"];
|
||||
"ACE_EntrenchingTool" in (_unit call EFUNC(common,uniqueItems))
|
||||
_unit call FUNC(hasEntrenchingTool)
|
||||
};
|
||||
[(_removeTimeLeft + 0.5), [_unit, _trench], _fnc_onFinish, _fnc_onFailure, localize LSTRING(RemovingTrench), _fnc_condition] call EFUNC(common,progressBar);
|
||||
|
||||
|
57
docs/wiki/framework/trenches-framework.md
Normal file
57
docs/wiki/framework/trenches-framework.md
Normal file
@ -0,0 +1,57 @@
|
||||
---
|
||||
layout: wiki
|
||||
title: Trenches Framework
|
||||
description: Explains how to set-up surface whitelisting and entrenching tools.
|
||||
group: framework
|
||||
order: 5
|
||||
parent: wiki
|
||||
mod: ace
|
||||
version:
|
||||
major: 3
|
||||
minor: 5
|
||||
patch: 0
|
||||
---
|
||||
|
||||
## 1. Config Values
|
||||
|
||||
### 1.1 Whitelisting surfaces for digging
|
||||
|
||||
Single surfaces can be whitelisted by adding `ACE_canDig = 1` into `CfgSurfaces`.
|
||||
```cpp
|
||||
class CfgSurfaces {
|
||||
class myAwesomeSurface {
|
||||
ACE_canDig = 1;
|
||||
};
|
||||
};
|
||||
```
|
||||
|
||||
### 1.2 Enabling entrenching tool features on an item or backpack
|
||||
|
||||
```cpp
|
||||
class CfgWeapons { // same config also works on backpacks (CfgVehicles)
|
||||
class yourBaseClass;
|
||||
class yourEntrenchingToolClass: yourBaseClass
|
||||
ace_trenches_entrenchingTool = 1;
|
||||
};
|
||||
};
|
||||
```
|
||||
|
||||
## 2. Scripting
|
||||
|
||||
### 2.1 Checking if unit has entrenching tool
|
||||
|
||||
`ace_trenches_fnc_hasEntrenchingTool`
|
||||
Used to check if unit has any entrenching capable tool.
|
||||
|
||||
```sqf
|
||||
* Checks if unit has entrenching tool.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* Has entrenching tool <BOOL>
|
||||
*
|
||||
* Example:
|
||||
* [bob] call ace_trenches_fnc_hasEntrenchingTool
|
||||
```
|
Loading…
Reference in New Issue
Block a user