Skip to content

Commit 098419a

Browse files
Rearm - Add pylon position check (#11333)
* add rearm at pylon * add rearm dummies for a3 pylon ammo * docs * Update addons/rearm/functions/fnc_pickUpAmmo.sqf Co-authored-by: PabstMirror <pabstmirror@gmail.com> * Update addons/rearm/functions/fnc_pickUpAmmo.sqf Co-authored-by: PabstMirror <pabstmirror@gmail.com> --------- Co-authored-by: PabstMirror <pabstmirror@gmail.com>
1 parent 04437a3 commit 098419a

7 files changed

Lines changed: 187 additions & 2 deletions

File tree

addons/rearm/CfgAmmo.hpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,30 @@ class CfgAmmo {
1515
class Missile_AA_03_F: Missile_AA_04_F {
1616
GVAR(dummy) = QGVAR(Missile_AA_03_F);
1717
};
18+
class M_Air_AA: MissileBase {
19+
GVAR(dummy) = QGVAR(M_Air_AA);
20+
};
21+
class M_Titan_AA;
22+
class M_Zephyr: M_Titan_AA {
23+
GVAR(dummy) = QGVAR(M_Zephyr);
24+
};
25+
class ammo_Missile_MediumRangeAABase;
26+
class ammo_Missile_AMRAAM_C: ammo_Missile_MediumRangeAABase {
27+
GVAR(dummy) = QGVAR(ammo_Missile_AMRAAM_C);
28+
};
29+
class ammo_Missile_AMRAAM_D: ammo_Missile_MediumRangeAABase {
30+
GVAR(dummy) = QGVAR(ammo_Missile_AMRAAM_D);
31+
};
32+
class ammo_Missile_AA_R77: ammo_Missile_MediumRangeAABase {
33+
GVAR(dummy) = QGVAR(ammo_Missile_AA_R77);
34+
};
35+
class ammo_Missile_ShortRangeAABase;
36+
class ammo_Missile_BIM9X: ammo_Missile_ShortRangeAABase {
37+
GVAR(dummy) = QGVAR(ammo_Missile_BIM9X);
38+
};
39+
class ammo_Missile_AA_R73: ammo_Missile_ShortRangeAABase {
40+
GVAR(dummy) = QGVAR(ammo_Missile_AA_R73);
41+
};
1842

1943
class Rocket_04_HE_F: MissileBase {
2044
GVAR(caliber) = 70;
@@ -33,12 +57,26 @@ class CfgAmmo {
3357
GVAR(caliber) = 70;
3458
GVAR(dummy) = QGVAR(M_PG_AT);
3559
};
60+
class M_Scalpel_AT: MissileBase {
61+
GVAR(dummy) = QGVAR(M_Scalpel_AT);
62+
};
3663
class Missile_AGM_02_F: MissileBase {
3764
GVAR(dummy) = QGVAR(Missile_AGM_02_F);
3865
};
3966
class Missile_AGM_01_F: Missile_AGM_02_F {
4067
GVAR(dummy) = QGVAR(Missile_AGM_01_F);
4168
};
69+
class ammo_Missile_AntiRadiationBase;
70+
class ammo_Missile_HARM: ammo_Missile_AntiRadiationBase {
71+
GVAR(dummy) = QGVAR(ammo_Missile_HARM);
72+
};
73+
class ammo_Missile_KH58: ammo_Missile_AntiRadiationBase {
74+
GVAR(dummy) = QGVAR(ammo_Missile_KH58);
75+
};
76+
class ammo_Bomb_SmallDiameterBase;
77+
class ammo_Bomb_SDB: ammo_Bomb_SmallDiameterBase {
78+
GVAR(dummy) = QGVAR(ammo_Bomb_SDB);
79+
};
4280

4381
class RocketCore;
4482
class RocketBase: RocketCore {
@@ -181,6 +219,12 @@ class CfgAmmo {
181219
class Bo_Mk82: BombCore {
182220
GVAR(dummy) = QGVAR(Bo_Mk82);
183221
};
222+
class BombDemine_01_Ammo_F: BombCore {
223+
GVAR(dummy) = QGVAR(BombDemine_01_Ammo_F);
224+
};
225+
class BombDemine_01_DummyAmmo_F: BombDemine_01_Ammo_F {
226+
GVAR(dummy) = QGVAR(BombDemine_01_DummyAmmo_F);
227+
};
184228

185229
class Bo_GBU12_LGB: ammo_Bomb_LaserGuidedBase {
186230
GVAR(caliber) = 250; // Default caliber for bombs

addons/rearm/CfgVehicles.hpp

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,12 @@ class CfgVehicles {
178178
class GVAR(Bo_Mk82): GVAR(defaultCarriedObject) {
179179
model = "\A3\Weapons_F\Ammo\Bomb_02_F";
180180
};
181+
class GVAR(BombDemine_01_Ammo_F): GVAR(defaultCarriedObject) {
182+
model = "\a3\Weapons_F_Orange\Ammo\BombDemine_01_F";
183+
};
184+
class GVAR(BombDemine_01_DummyAmmo_F): GVAR(defaultCarriedObject) {
185+
model = "\a3\Weapons_F_Orange\Ammo\BombDemine_01_Dummy_F";
186+
};
181187
class GVAR(Bomb_04_F): GVAR(defaultCarriedObject) {
182188
model = "\A3\Weapons_F_EPC\Ammo\Bomb_04_F.p3d";
183189
};
@@ -190,12 +196,45 @@ class CfgVehicles {
190196
class GVAR(Missile_AA_03_F): GVAR(defaultCarriedObject) {
191197
model = "\A3\Weapons_F_EPC\Ammo\Missile_AA_03_F.p3d";
192198
};
199+
class GVAR(M_Air_AA): GVAR(defaultCarriedObject) {
200+
model = "\A3\Weapons_F_EPC\Ammo\M_Air_AA.p3d";
201+
};
202+
class GVAR(M_Zephyr): GVAR(defaultCarriedObject) {
203+
model = "\A3\Weapons_F\Ammo\Missile_AA_02_F.p3d";
204+
};
205+
class GVAR(ammo_Missile_AMRAAM_C): GVAR(defaultCarriedObject) {
206+
model = "\A3\Weapons_F_Jets\Ammo\Missile_AA_10_F";
207+
};
208+
class GVAR(ammo_Missile_AMRAAM_D): GVAR(defaultCarriedObject) {
209+
model = "\A3\Weapons_F_Jets\Ammo\Missile_AA_06_F";
210+
};
211+
class GVAR(ammo_Missile_AA_R77): GVAR(defaultCarriedObject) {
212+
model = "\A3\Weapons_F_Jets\Ammo\Missile_AA_05_F";
213+
};
214+
class GVAR(ammo_Missile_BIM9X): GVAR(defaultCarriedObject) {
215+
model = "\A3\Weapons_F_Jets\Ammo\Missile_AA_08_F";
216+
};
217+
class GVAR(ammo_Missile_AA_R73): GVAR(defaultCarriedObject) {
218+
model = "\A3\Weapons_F_Jets\Ammo\Missile_AA_07_F";
219+
};
220+
class GVAR(M_Scalpel_AT): GVAR(defaultCarriedObject) {
221+
model = "\A3\Weapons_F\Ammo\Missile_AT_03_F";
222+
};
193223
class GVAR(Missile_AGM_02_F): GVAR(defaultCarriedObject) {
194-
model = "\A3\Weapons_F_EPC\Ammo\Missile_AGM_02_F.p3d";
224+
model = "\A3\Weapons_F\Ammo\Missile_AT_02_F";
195225
};
196226
class GVAR(Missile_AGM_01_F): GVAR(defaultCarriedObject) {
197227
model = "\A3\Weapons_F_EPC\Ammo\Missile_AGM_01_F.p3d";
198228
};
229+
class GVAR(ammo_Missile_HARM): GVAR(defaultCarriedObject) {
230+
model = "\A3\Weapons_F_Sams\Ammo\Missile_AR_01_F.p3d";
231+
};
232+
class GVAR(ammo_Missile_KH58): GVAR(defaultCarriedObject) {
233+
model = "\A3\Weapons_F_Sams\Ammo\Missile_AR_02_F.p3d";
234+
};
235+
class GVAR(ammo_Bomb_SDB): GVAR(defaultCarriedObject) {
236+
model = "\A3\Weapons_F_Sams\Ammo\Bomb_05_F.p3d";
237+
};
199238
class GVAR(R_230mm_fly): GVAR(defaultCarriedObject) {
200239
model = "\A3\Weapons_F\Ammo\Missile_AT_02_F";
201240
};

addons/rearm/functions/fnc_pickUpAmmo.sqf

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,22 @@ private _nearUnits = _unit nearObjects ["CAManBase", 100];
2828
[QGVAR(makeDummyEH), [_dummy, [[-1,0,0],[0,0,1]]], _nearUnits] call CBA_fnc_targetEvent;
2929

3030
_unit setVariable [QGVAR(dummy), _dummy];
31+
32+
if (GVAR(usePylonPosition) && {GVAR(level) > 0} && {typeOf _attachedDummy isNotEqualTo QGVAR(defaultCarriedObject)}) then {
33+
private _action = [
34+
QGVAR(flipAmmo),
35+
localize "STR_3DEN_Display3DEN_ControlsHint_Rotate",
36+
"a3\ui_f_curator\Data\CfgWrapperUI\Cursors\curatorRotate_ca.paa",
37+
{
38+
params ["_dummy", "_unit"];
39+
_dummy setVectorDirAndUp [
40+
(_unit vectorWorldToModelVisual vectorDir _dummy) vectorMultiply -1,
41+
[0,0,1]
42+
];
43+
}, {
44+
params ["_dummy", "_unit"];
45+
_dummy == _unit getVariable [QGVAR(dummy), objNull]
46+
}
47+
] call EFUNC(interact_menu,createAction);
48+
[_dummy , 0, [], _action] call EFUNC(interact_menu,addActionToObject);
49+
};

addons/rearm/functions/fnc_rearm.sqf

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,60 @@ private _needRearmMagsOfClass = _needRearmMags select {(_x select 0) isEqualTo _
3434
if (_needRearmMagsOfClass isEqualTo []) exitWith {ERROR_2("Could not find turret for %1 in %2",_magazineClass,typeOf _target);};
3535

3636
private _currentRearmableMag = _needRearmMagsOfClass select 0;
37-
_currentRearmableMag params ["", "_turretPath", "", "_pylon", "", "_magazineCount"];
37+
_currentRearmableMag params ["", "_turretPath", "_isPylon", "_pylon", "", "_magazineCount"];
38+
39+
// If mag is pylon, pylon position enabled, level is not Entire Vehicle, munition model is not default box
40+
private _isMisaligned = false;
41+
if (_isPylon && {GVAR(usePylonPosition)} && {GVAR(level) > 0} && {typeOf _attachedDummy isNotEqualTo QGVAR(defaultCarriedObject)}) then {
42+
_isMisaligned = true;
43+
private _pylonDistance = GVAR(distance);
44+
private _pylonPos = [0, 0, 0];
45+
private _pylonDir = [0, 0, 0];
46+
47+
// Check if there are multiple rearmable pylons of the same magazine class, and if so, find the closest one to the munition
48+
private _multipleRearmablePylons = _needRearmMagsOfClass param [1, []] param [2, false];
49+
{
50+
private _xNeedRearmMagsOfClass = _x;
51+
private _xMagIndex = _forEachIndex;
52+
_x params ["", "", "_xMagIsPylon", "_xMagPylonIndex"];
53+
if !_xMagIsPylon then {continue;};
54+
55+
{
56+
_x params ["_xPylonIndex", "", "", "", "", "", "_xPylonPosInfo", "_xPylonObj"];
57+
if (_xPylonIndex != _xMagPylonIndex) then {continue;};
58+
_xPylonPosInfo params ["_xPylonPos", "_xPylonDir"];
59+
private _xPylonPosATL = _target modelToWorldVisual _xPylonPos;
60+
61+
private _xDistance = _xPylonPosATL distance _attachedDummy;
62+
if (_xDistance < _pylonDistance) then {
63+
_pylonDistance = _xDistance;
64+
_currentRearmableMag = _needRearmMagsOfClass select _xMagIndex;
65+
_pylonPos = _xPylonPosATL;
66+
_pylonDir = _target vectorModelToWorldVisual _xPylonDir;
67+
};
68+
} forEach getAllPylonsInfo _target;
69+
} forEach ([[_currentRearmableMag], _needRearmMagsOfClass] select _multipleRearmablePylons);
70+
71+
// Exit if munition is too far from pylon
72+
#define MUNITION_DISTANCE 2
73+
if (_pylonDistance > MUNITION_DISTANCE) exitWith {
74+
[[LSTRING(Hint_MunitionDistance), _pylonDistance toFixed 1]] call EFUNC(common,displayTextStructured);
75+
};
76+
77+
// Exit if munition is not aligned with pylon
78+
#define MUNITION_ANGLE 5
79+
private _pylonAngle = abs (180 - acos (_pylonDir vectorDotProduct (vectorNormalized vectorDir _attachedDummy)));
80+
if (_pylonAngle > MUNITION_ANGLE) exitWith {
81+
//hint format ["Munition not aligned with pylon. Angle: %1",_pylonAngle];
82+
[[LSTRING(Hint_MunitionAngle), round _pylonAngle]] call EFUNC(common,displayTextStructured);
83+
};
84+
85+
_isMisaligned = false;
86+
hint ""; //
87+
};
88+
if (_isMisaligned) exitWith {};
89+
90+
_currentRearmableMag params ["", "_turretPath", "_isPylon", "_pylon", "", "_magazineCount"];
3891

3992
private _magazineDisplayName = _magazineClass call FUNC(getMagazineName);
4093

addons/rearm/initSettings.inc.sqf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,13 @@ private _category = [ELSTRING(main,Category_Logistics), LLSTRING(DisplayName)];
3333
[10, 50, 20, 0],
3434
true // isGlobal
3535
] call CBA_fnc_addSetting;
36+
37+
[
38+
QGVAR(usePylonPosition), "CHECKBOX",
39+
[LSTRING(RearmSettings_usePylonPosition_DisplayName), LSTRING(RearmSettings_usePylonPosition_Description)],
40+
_category,
41+
false,
42+
true,
43+
{[QGVAR(usePylonPosition), _this] call EFUNC(common,cbaSettings_settingChanged)},
44+
false // Needs mission restart
45+
] call CBA_fnc_addSetting;

addons/rearm/stringtable.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@
6565
<Chinesesimp>已经没有剩余的弹药了。</Chinesesimp>
6666
<Ukrainian>Запас боєкомплекту порожній</Ukrainian>
6767
</Key>
68+
<Key ID="STR_ACE_Rearm_Hint_MunitionDistance">
69+
<English>Munition is too far from pylon. Distance: %1 m</English>
70+
</Key>
71+
<Key ID="STR_ACE_Rearm_Hint_MunitionAngle">
72+
<English>Munition is not aligned with pylon. Angle: %1</English>
73+
</Key>
6874
<Key ID="STR_ACE_Rearm_Hint_RearmedTriple">
6975
<English>Rearmed %1 rounds of %2 on %3</English>
7076
<Czech>Přezbrojeno % nábojů z %2 u %3</Czech>
@@ -641,6 +647,12 @@
641647
<Chinesesimp>无限弹药</Chinesesimp>
642648
<Ukrainian>Необмежений боєзапас</Ukrainian>
643649
</Key>
650+
<Key ID="STR_ACE_Rearm_RearmSettings_usePylonPosition_Description">
651+
<English>When rearming a pylon, the munition must be held aligned at the pylon. Only applies if Rearm Amount is not Entire Vehicle.</English>
652+
</Key>
653+
<Key ID="STR_ACE_Rearm_RearmSettings_usePylonPosition_DisplayName">
654+
<English>Use Pylon Position</English>
655+
</Key>
644656
<Key ID="STR_ACE_Rearm_RearmSettings_vehicle">
645657
<English>Entire Vehicle</English>
646658
<Czech>Celé vozidlo</Czech>

docs/wiki/feature/rearm.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ To fully rearm 2000 rounds of 7.62mm machine gun, you need five ammo boxes.
6464
- Can check what magazines are loaded on supply vehicle
6565

6666

67+
## 2.3 Use Pylon Position (`ace_rearm_usePylonPosition`)
68+
Rearming a pylon magazine requires the player to position ammo object (missile or bomb) nearby and aligned with the correct pylon on the vehicle. This requirement takes effect if all of these conditions are met:
69+
- This setting Use Pylon Position is enabled
70+
- The setting Rearm Amount set to `Entire Magazine` or `Amount based on caliber`, not `Entire vehicle`
71+
- The magazine being rearmed is a pylon magazine
72+
- The ammobox is a munition model, not the default ammobox
73+
74+
6775
## 3. FAQ
6876

6977
### Can I drop the ammo box?

0 commit comments

Comments
 (0)