Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSW/Mk6 Mortar - Make Mk6 Mortar Ammo Handling override CSW's #9238

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions addons/csw/functions/fnc_initVehicle.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ if (hasInterface && {!(_typeOf in GVAR(initializedStaticTypes))}) then {
private _ammoActionPath = [];
private _magazineLocation = getText (_configOf >> QUOTE(ADDON) >> "magazineLocation");
private _condition = { //IGNORE_PRIVATE_WARNING ["_target", "_player"];
// If magazine handling is enabled or weapon assembly/disassembly is enabled we enable ammo handling
if ((GVAR(ammoHandling) == 0) && {!([false, true, true, GVAR(defaultAssemblyMode)] select (_target getVariable [QGVAR(assemblyMode), 3]))}) exitWith { false };
// If magazine handling and weapon assembly/disassembly are enabled we enable ammo handling
if ((GVAR(ammoHandling) == 0) || {!([false, true, true, GVAR(defaultAssemblyMode)] select (_target getVariable [QGVAR(assemblyMode), 3]))}) exitWith { false };
johnb432 marked this conversation as resolved.
Show resolved Hide resolved
[_player, _target, ["isNotSwimming", "isNotSitting"]] call EFUNC(common,canInteractWith)
};
private _childrenCode = {
Expand All @@ -93,7 +93,11 @@ if (hasInterface && {!(_typeOf in GVAR(initializedStaticTypes))}) then {
_ammoActionPath = [_typeOf, 0, ["ACE_MainActions"], _ammoAction] call EFUNC(interact_menu,addActionToClass);
};

if (["ace_reload"] call EFUNC(common,isModLoaded)) then {
if (
["ace_reload"] call EFUNC(common,isModLoaded) &&
{GVAR(ammoHandling) isNotEqualTo 0} &&
{([false, true, true, GVAR(defaultAssemblyMode)] select (_vehicle getVariable [QGVAR(assemblyMode), 3]))}
) then {
// move reload's check ammo action to the ammo handling point (remove and re-add)
[_typeOf, 0, ["ACE_MainActions", QEGVAR(reload,CheckAmmo)]] call EFUNC(interact_menu,removeActionFromClass);
private _checkAmmoAction = [QGVAR(checkAmmo), LELSTRING(reload,checkAmmo), "", EFUNC(reload,checkAmmo), EFUNC(reload,canCheckAmmo)] call EFUNC(interact_menu,createAction);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

params ["_vehicle", "_assemblyMode", "_emptyWeapon"];
TRACE_3("staticWeaponInit_unloadExtraMags",_vehicle,_assemblyMode,_emptyWeapon);
if (!_assemblyMode) exitWith {};
if !(_assemblyMode && {GVAR(ammoHandling) > 0}) exitWith {};

private _desiredAmmo = getNumber (configOf _vehicle >> QUOTE(ADDON) >> "desiredAmmo");
private _storeExtraMagazines = GVAR(handleExtraMagazines);
Expand Down
43 changes: 17 additions & 26 deletions addons/csw/stringtable.xml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you split off the changes not related to this specific PR into a separate one?

Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@
<Korean>고급 조립</Korean>
</Key>
<Key ID="STR_ACE_CSW_defaultAssemblyMode_description">
<English>Use ACE for Assemble/Disassemble of supported static weapons. Loaded ammo is reduced to a single magazine.</English>
<English>Use ACE to Assemble/Disassemble supported static weapons.</English>
<German>Benutze ACE um unterstützte statische Waffen zu montieren/demontieren. Geladene Munition ist auf ein einzelnes Magazin reduziert.</German>
<Portuguese>Usar o ACE para Montar/Desmontar armas estáticas suportadas. Munição carregada é reduzida para um único carregador.</Portuguese>
<Portuguese>Usar o ACE para Montar/Desmontar armas estáticas suportadas.</Portuguese>
<French>Utilise ACE pour l'assemblage/le désassemblage des armes statiques supportées.\nLes munitions chargées sont réduites à un seul chargeur.</French>
<Japanese>対応している設置型火器に ACE の設置と解体を使用します。装填済みの弾倉は1つの弾倉のみに減少します。</Japanese>
<Chinese>使用ACE來組裝/拆解固定型武器。上膛的限制為單個彈匣。</Chinese>
Expand All @@ -144,9 +144,9 @@
<Korean>ACE의 조립/분해 기능을 사용하여 공용화기를 다룹니다. 장전된 탄은 한 탄창으로 제한됩니다.</Korean>
</Key>
<Key ID="STR_ACE_CSW_handleExtraMagazines_displayName">
<English>Save Extra Ammo</English>
<English>Store Extra Ammo</English>
<German>Spare extra Munition</German>
<Portuguese>Economizar munição extra</Portuguese>
<Portuguese>Guardar munição extra</Portuguese>
<French>Conserver le surplus de munitions</French>
<Japanese>追加の弾薬を保持</Japanese>
<Chinese>保存額外彈藥</Chinese>
Expand All @@ -159,18 +159,18 @@
<Korean>남은 탄약 저장</Korean>
</Key>
<Key ID="STR_ACE_CSW_handleExtraMagazines_description">
<English>Store extra magazines next to static weapon</English>
<German>Lager extra Magazine neben der statischen Waffe</German>
<Portuguese>Carregar munições extras próximo à arma estática</Portuguese>
<English>Store extra magazines next to the static weapon.</English>
<German>Lager extra Magazine neben der statischen Waffe.</German>
<Portuguese>Guardar munição extra próximo à arma estática.</Portuguese>
<French>Range les chargeurs en surplus auprès de l'arme statique.</French>
<Japanese>追加の弾倉を固定火器の横に保管します。</Japanese>
<Chinese>在固定型武器旁存放額外彈匣</Chinese>
<Chinesesimp>在固定式武器旁边存放额外的弹匣</Chinesesimp>
<Italian>Conserva i caricatori extra accanto all'arma statica</Italian>
<Italian>Conserva i caricatori extra accanto all'arma statica.</Italian>
<Czech>Ukládat munici navíc vedle statické zbraně.</Czech>
<Polish>Dodatkowe magazynki przechowuj obok broni statycznej</Polish>
<Spanish>Almacenar cargadores extra junto al arma estática</Spanish>
<Russian>Хранить дополнительные магазины рядом со статическим оружием</Russian>
<Polish>Dodatkowe magazynki przechowuj obok broni statycznej.</Polish>
<Spanish>Almacenar cargadores extra junto al arma estática.</Spanish>
<Russian>Хранить дополнительные магазины рядом со статическим оружием.</Russian>
<Korean>공용화기 옆에 남은 탄들을 저장합니다.</Korean>
</Key>
<Key ID="STR_ACE_CSW_handleExtraMagazinesType_displayName">
Expand All @@ -187,17 +187,8 @@
<Portuguese>Armazenamento de Munição</Portuguese>
</Key>
<Key ID="STR_ACE_CSW_handleExtraMagazinesType_description">
<English>Determines whether extra magazines are stored on the ground or inside an ammo box</English>
<German>Legt fest, ob zusätzliche Magazine auf dem Boden oder in einer Munitionskiste aufbewahrt werden</German>
<Italian>Determina se ulteriori caricatori verranno stoccati sul suolo o in una cassa di munizioni.</Italian>
<Korean>여분의 탄약을 지면 또는 탄약 상자에 넣을 지 결정합니다.</Korean>
<Polish>Decyduje, czy dodatkowe magazynki przechowywane są na ziemi, czy w skrzynce z amunicją.</Polish>
<Japanese>追加の弾倉を地面に直接配置するか、弾薬箱内に保管するかを設定します。</Japanese>
<Chinesesimp>设置多余的弹夹是存放在地面上还是弹药箱内</Chinesesimp>
<Russian>Определяет будут ли дополнительные магазины лежать на земле или внутри хранилища</Russian>
<Spanish>Determina si los cargadores extra son almacenados en el suelo o en una caja de munición</Spanish>
<French>Détermine si les chargeurs supplémentaires sont stockés par terre ou dans une caisse de munitions.</French>
<Portuguese>Determina se munições extras são armazenadas no chão ou dentro de uma caixa de munição</Portuguese>
<English>Determines whether extra magazines are stored on the ground or inside an ammo box, if the static weapon doesn't have a defined container.</English>
johnb432 marked this conversation as resolved.
Show resolved Hide resolved
<Portuguese>Determina se a munição extra é guardada no chão ou dentro de uma caixa de munição, se a arma estática não tiver um recipiente definido.</Portuguese>
</Key>
<Key ID="STR_ACE_CSW_handleExtraMagazinesType_weaponHolder">
<English>Ground</English>
Expand Down Expand Up @@ -226,9 +217,9 @@
<Portuguese>Caixa de Munição</Portuguese>
</Key>
<Key ID="STR_ACE_CSW_ammoHandling_displayName">
<English>Ammo handling</English>
<English>Ammo Handling</English>
<German>Munitionsmanagement</German>
<Portuguese>Manipulação de Munições</Portuguese>
<Portuguese>Manipulação de Munição</Portuguese>
<French>Manipulation des munitions</French>
<Japanese>弾薬の処理</Japanese>
<Chinese>彈藥處理</Chinese>
Expand All @@ -241,9 +232,9 @@
<Korean>탄약 취급</Korean>
</Key>
<Key ID="STR_ACE_CSW_ammoHandling_description">
<English>Allow loading and unloading magazines</English>
<English>Allow loading and unloading magazines. Loaded ammo is reduced to a single magazine for static weapons using Advanced Assembly.</English>
<German>Erlaubt es Magazine zu- und entladen.</German>
<Portuguese>Permite carregamento e descarregamento de munições</Portuguese>
<Portuguese>Permite carregar e descarregar munição. Munição carregada é reduzida para um único carregador em armas estáticas usando Montagem Avançada.</Portuguese>
<French>Définit qui peut charger et décharger les chargeurs.</French>
<Japanese>弾薬の装填と除去を許可します。</Japanese>
<Chinese>允許裝填或卸載彈匣</Chinese>
Expand Down
2 changes: 1 addition & 1 deletion addons/mk6mortar/CfgVehicles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class CfgVehicles {
};
class Mortar_01_base_F: StaticMortar {
class ace_csw {
proxyWeapon = QFUNC(csw_getProxyWeapon);
proxyWeapon = "ACE_mortar_82mm";
LinkIsGrim marked this conversation as resolved.
Show resolved Hide resolved
magazineLocation = "_target selectionPosition 'usti hlavne'";
};
class Turrets: Turrets {
Expand Down
1 change: 0 additions & 1 deletion addons/mk6mortar/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

PREP(csw_getProxyWeapon);
PREP(handleFired);
PREP(handlePlayerVehicleChanged);
PREP(moduleInit);
Expand Down
9 changes: 9 additions & 0 deletions addons/mk6mortar/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,13 @@ PREP_RECOMPILE_END;

#include "initSettings.inc.sqf"

// Override CSW's ammo handling with Mk6 setting for non-advanced assembly mortars
["Mortar_01_base_F", "Init", {
params ["_mortar"];
if (GVAR(useAmmoHandling)) exitWith {};
if ((_mortar getVariable [QEGVAR(csw,assemblyMode), 3]) isEqualTo 3) then {
_mortar setVariable [QEGVAR(csw,assemblyMode), 0];
};
}] call CBA_fnc_addClassEventHandler;

ADDON = true;
68 changes: 0 additions & 68 deletions addons/mk6mortar/functions/fnc_csw_getProxyWeapon.sqf

This file was deleted.

2 changes: 1 addition & 1 deletion addons/mk6mortar/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@
<Czech>Používat ruční manipulaci s municí</Czech>
</Key>
<Key ID="STR_ACE_Mk6Mortar_useAmmoHandling_Description">
<English>Removes mortar magazines, requiring individual rounds to be loaded by the gunner or loader. Does not affect AI mortars.</English>
<English>Removes mortar magazines, requiring individual rounds to be loaded by the gunner or loader. Does not affect AI mortars. Requires CSW Ammo Handling.</English>
<German>Enfernt das Magzin des Mörsers. Es ist nun erforderlich, die einzelnen Patronen manuell zu laden. Dies beeinflusst nicht die KI-Truppen.</German>
<Spanish>Elimina los cargadores del mortero, requiriendo al artillero o cargador la carga manual de cada rondas. No afecta morteros controlados por IA.</Spanish>
<Polish>Usuwa magazynki moździerza, wymagając ładowania pojedynczych pocisków przez strzelca lub ładowniczego. Nie dotyczy moździerzy AI.</Polish>
Expand Down
17 changes: 13 additions & 4 deletions docs/wiki/framework/crew-served-weapons-framework.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ class ACE_CSW_Groups {
class prefix_100rnd_hmg_csw_mag { // Same name as the carryable magazine
prefix_100rnd_hmg_mag = 1; // Vehicle magazine that will be loaded when loading this magazine
};

// Using an existing CSW magazine
class ace_csw_100Rnd_127x99_mag {
banana_dummy_ammo = 1;
};

/*
Carryable magazines already defined by ACE:
- ace_csw_100Rnd_127x99_mag
Expand All @@ -134,12 +134,12 @@ class CfgVehicles {
class StaticMGWeapon;
class prefix_hmg: StaticMGWeapon {
class ACE_CSW {
enabled = 1; // Enables ACE CSW for this weapon
enabled = 1; // Enables ACE CSW for this weapon
proxyWeapon = "prefix_hmg_weapon_proxy"; // The proxy weapon created above
magazineLocation = "_target selectionPosition 'magazine'"; // Ammo handling interaction point location
disassembleWeapon = "prefix_hmg_carry"; // Carryable weapon created above
disassembleTurret = "ace_csw_m3Tripod"; // Which static tripod will appear when weapon is disassembled
ammoLoadTime = 7; // How long it takes in seconds to load ammo into the weapon
ammoLoadTime = 7; // How long it takes in seconds to load ammo into the weapon
ammoUnloadTime = 5; // How long it takes in seconds to unload ammo from the weapon
desiredAmmo = 100; // When the weapon is reloaded it will try and reload to this ammo capacity
// Optional callback function for when the CSW gets disassembled, called with [tripod, staticWeapon]
Expand All @@ -149,6 +149,15 @@ class CfgVehicles {
};
```

### 1.5 Disabling CSW for a single weapon

The entirety of CSW's systems can be disabled by setting the `ace_csw_assemblyMode` variable to `0` on init.

```sqf
myCustomStaticWeapon = createVehicle ["B_Mortar_01_F", [0, 0, 0]];
myCustomStaticWeapon setVariable ["ace_csw_assemblyMode", 0, true]; // disable CSW
```

## 2. Making a new Tripod

If none of the existing ACE tripods fit your weapon, you can create your own. Creating a tripod is similar to creating a crew served weapon and consists of two parts:
Expand Down