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 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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_staticWeaponInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,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 };
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure about this,
before even if ammoHandling was off you could still always load a "CSW" static weapon

e.g. if you assemble a csw from 2 carried weapons then it would still be loadable
because otherwise you just have a empty weapon that you can't do anything with

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll figure something out. Though you might agree that ammo handling still being possible despite the setting is confusing.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah I'd probably say it's mission-maker error
but docs also say

### 3.3 ammoHandling

- Whether or not you want to handle ammo using the CSW way. Does nothing if using defaultAssemblyMode
- Default: On

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IMO it shouldn't even be an option. This feature makes no sense without ammo handling.

[_player, _target, ["isNotSwimming", "isNotSitting"]] call EFUNC(common,canInteractWith)
};
private _childenCode = {
Expand All @@ -88,7 +88,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 (_staticWeapon 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), localize ELSTRING(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 @@ -18,7 +18,7 @@

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

private _desiredAmmo = getNumber (configOf _staticWeapon >> QUOTE(ADDON) >> "desiredAmmo");
private _storeExtraMagazines = GVAR(handleExtraMagazines);
Expand Down
37 changes: 20 additions & 17 deletions addons/csw/stringtable.xml
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>対応している設置型火器に ACE3 の設置と解体を使用します。装填済みの弾倉は 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>Conservare i caricatori extra accanto all'arma statica</Italian>
<Italian>Conservare 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 @@ -184,8 +184,9 @@
<Spanish>Almacenamiento de munición</Spanish>
</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>
<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>
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know what the standard is across ACE, but I think that if you change the english meaning you should clear out all the other untranslated ones. @jonpas comments?

Copy link
Member

Choose a reason for hiding this comment

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

Correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can invalidate the old strings but in #9240 we opted to not do so because it was a minor change not being worth getting rid of translations. I figured this was about the same level of change.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is commenting on new functionality, not elaborating on existing. That is my basis for the purge

<German>Legt fest, ob zusätzliche Magazine auf dem Boden oder in einer Munitionskiste aufbewahrt werden.</German>
<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>
<Korean>여분의 탄약을 지면 또는 탄약 상자에 넣을지 결정합니다.</Korean>
<Polish>Decyduje, czy dodatkowe magazynki przechowywane są na ziemi, czy w skrzynce z amunicją.</Polish>
<Japanese>追加のマガジンを地面に設置するか、弾薬箱の中に保管するかを決定します</Japanese>
Expand All @@ -196,6 +197,7 @@
<Key ID="STR_ACE_CSW_handleExtraMagazinesType_weaponHolder">
<English>Ground</English>
<German>Boden</German>
<Portuguese>Chão</Portuguese>
<Korean>지면</Korean>
<Polish>Ziemia</Polish>
<Japanese>地面</Japanese>
Expand All @@ -206,6 +208,7 @@
<Key ID="STR_ACE_CSW_handleExtraMagazinesType_ammoBox">
<English>Ammo Box</English>
<German>Munitionskiste</German>
<Portuguese>Caixa de munição</Portuguese>
<Korean>탄약 상자</Korean>
<Polish>Skrzynka amunicyjna</Polish>
<Japanese>弾薬箱</Japanese>
Expand All @@ -214,9 +217,9 @@
<Spanish>Caja de munición</Spanish>
</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 @@ -229,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.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