Skip to content

Commit

Permalink
Add custom rearming system for MK20, MG3 and Smoke Launcher (#30)
Browse files Browse the repository at this point in the history
* Move class changes to correct location

* Make MK20 component multifunctional

* Rename function

* WIP

* Add rearm to GM Marder

* Finish config & script part of rearming of marder

* Disable debugging

* Add rearm MG icon

* Change rearm MK seat of GM Marder

* Add rearm smoke icon

* Add smoke packs pictures

* Only use full magazines

* Use Arma description format

* Fix desc

* Fix grammer
  • Loading branch information
Timi007 authored Mar 6, 2022
1 parent d761d0a commit 8e4061e
Show file tree
Hide file tree
Showing 51 changed files with 783 additions and 575 deletions.
33 changes: 24 additions & 9 deletions addons/GM_Marder/CfgVehicles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class CfgVehicles
{
class MainTurret;
};
class AnimationSources;

maximumLoad = 10000;
fuelCapacity = 100;
Expand Down Expand Up @@ -136,21 +137,15 @@ class CfgVehicles
gunnerCompartments= "Compartment3";

weapons[] = {
"gm_20mm_rh202",
"gm_mg3_coax",
QGVAR(20mm_rh202), // Modified reload time for Rearm
QGVAR(mg3_coax), // Modified reload time for Rearm
QGVAR(SmokeLauncher)
};
magazines[] = {
"gm_425Rnd_20x139mm_hei_t_dm81",
"gm_75Rnd_20x139mm_apds_t_dm63",
"gm_500Rnd_762x51mm_b_t_DM21_mg3",
"gm_500Rnd_762x51mm_b_t_DM21_mg3",
"gm_500Rnd_762x51mm_b_t_DM21_mg3",
"gm_500Rnd_762x51mm_b_t_DM21_mg3",
"gm_500Rnd_762x51mm_b_t_DM21_mg3",
"gm_500Rnd_762x51mm_b_t_DM21_mg3",
"gm_500Rnd_762x51mm_b_t_DM21_mg3",
QGVAR(1Rnd_76mm_RP_dm35) // Smoke Mag
QGVAR(1Rnd_76mm_RP_dm35) // Marder A1/2 have 1 rnd 6 smoke granades
};

class Turrets
Expand All @@ -176,5 +171,25 @@ class CfgVehicles
};
};
};

class AnimationSources: AnimationSources
{
// Changes for Rearm (modified 20mm_rh202 and mg3 classes)
class MainTurret_reload_source
{
source = "reload";
weapon = QGVAR(20mm_rh202);
};
class MainTurret_ammorandom_source
{
source = "ammorandom";
weapon = QGVAR(20mm_rh202);
};
class MainTurret_coax_ammorandom_source
{
source = "ammorandom";
weapon = QGVAR(mg3_coax);
};
};
};
};
17 changes: 7 additions & 10 deletions addons/GM_Marder/CfgWeapons.hpp
Original file line number Diff line number Diff line change
@@ -1,39 +1,36 @@
class CfgWeapons
{
class SmokeLauncher;

class GVAR(SmokeLauncher): SmokeLauncher
{
magazines[] += {QGVAR(1Rnd_76mm_RP_dm35)};
showToPlayer = 0;
};


/*
class gm_20mm_rh202_base;
class gm_20mm_rh202: gm_20mm_rh202_base
{
class gm_20mm_rh202_he_muzzle;
class gm_20mm_rh202_ap_muzzle;
};

class gm_20mm_rh202: gm_20mm_rh202_base
class GVAR(20mm_rh202): gm_20mm_rh202
{
autoReload = 1;
magazineReloadTime = 0.1;
class gm_20mm_rh202_he_muzzle: gm_20mm_rh202_he_muzzle
{
autoReload = 1;
magazineReloadTime = 0.1;
};
class gm_20mm_rh202_ap_muzzle: gm_20mm_rh202_ap_muzzle
{
autoReload = 1;
magazineReloadTime = 0.1;
};
};
*/

class gm_mg3_coax;
class GVAR(mg3_coax): gm_mg3_coax
{
magazineReloadTime = 0.1;
};
};
3 changes: 1 addition & 2 deletions addons/GM_Marder/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ PREP(canUnloadMilan);
PREP(closeRamp);
PREP(initActions);
PREP(initMilanActions);
PREP(initRearmMKActions);
PREP(initRearmActions);
PREP(loadMilan);
PREP(openRamp);
PREP(rearmMK);
PREP(removeMilanMagazines);
PREP(unloadMilan);
16 changes: 0 additions & 16 deletions addons/GM_Marder/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -1,17 +1 @@
#include "script_component.hpp"

// Server only EH
[QGVAR(rearmMK20), {
if (!isServer) exitWith {};

params ["_vehicle", "_turretPath"];

private _turretOwnerID = _vehicle turretOwner _turretPath;
if (_turretOwnerID isEqualTo 0) then {
[QGVAR(setTurretMagazineAmmo), _this, [_vehicle]] call CBA_fnc_targetEvent;
} else {
[QGVAR(setTurretMagazineAmmo), _this, _turretOwnerID] call CBA_fnc_ownerEvent;
};
}] call CBA_fnc_addEventHandler;

[QGVAR(setTurretMagazineAmmo), {_this call ace_rearm_fnc_setTurretMagazineAmmo}] call CBA_fnc_addEventHandler;
2 changes: 1 addition & 1 deletion addons/GM_Marder/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,5 @@ if (hasInterface) then {
["gm_marder1_base", "InitPost", {
_this call FUNC(initActions);
_this call FUNC(initMilanActions);
_this call FUNC(initRearmMKActions);
_this call FUNC(initRearmActions);
}, nil, nil, true] call CBA_fnc_addClassEventHandler;
5 changes: 2 additions & 3 deletions addons/GM_Marder/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ class CfgPatches {
"PzGrenBtl402_Main",
"PzGrenBtl402_ACRE",
"PzGrenBtl402_SmokeLauncher",
"PzGrenBtl402_MK20",
"PzGrenBtl402_Rearm",
"PzGrenBtl402_GM_Milan",
"gm_vehicles_land_tracked_marder1",
"Redd_Bags",
"ace_rearm"
"Redd_Bags"
};
author = ECSTRING(Main, authors);
authors[] = {"Timi007", "Lemonberries", "Mishkar"};
Expand Down
154 changes: 154 additions & 0 deletions addons/GM_Marder/functions/fnc_initRearmActions.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
#include "script_component.hpp"
/**
* Author: Mishkar, Timi007
*
* Description:
* Initializes rearm MK actions.
*
* Parameter(s):
* 0: OBJECT - Vehicle (Marder).
*
* Returns:
* Nothing.
*
* Example:
* _this call PzGrenBtl402_GM_Marder_fnc_initRearmActions
*
*/

#define HOLD_TIME 5
#define REARM_DURATION 15

params ["_vehicle"];

if (!hasInterface) exitWith {};

private _rearmMKShowCondition = "_this isEqualTo (fullCrew [_target, 'turret', true] select 2 select 0) && {!isTurnedOut _this} && {isNull gunner _target}";
private _rearmMKProgressCondition = "_caller isEqualTo (fullCrew [_target, 'turret', true] select 2 select 0) && {!isTurnedOut _caller} && {isNull gunner _target}";

// MK HE laden
private _rearmHeIcon = QPATHTOEF(Rearm,data\ui\holdaction_rearm_mk20_he.paa);
private _heMagazineName = [QEGVAR(Rearm,mk20_he_ammo)] call EFUNC(Rearm,getMagazineName);
[
_vehicle,
format [LELSTRING(Rearm,rearm), _heMagazineName],
_rearmHeIcon,
_rearmHeIcon,
_rearmMKShowCondition,
_rearmMKProgressCondition,
{},
{},
{
params ["_vehicle"];
[_vehicle, [0], "gm_425Rnd_20x139mm_hei_t_dm81", [QEGVAR(Rearm,mk20_he_ammo)], REARM_DURATION] call EFUNC(Rearm,rearm);
},
{},
[],
HOLD_TIME,
nil,
false,
false,
false
] call BIS_fnc_holdActionAdd;

// MK AP laden
private _rearmApIcon = QPATHTOEF(Rearm,data\ui\holdaction_rearm_mk20_ap.paa);
private _apMagazineName = [QEGVAR(Rearm,mk20_ap_ammo)] call EFUNC(Rearm,getMagazineName);
[
_vehicle,
format [LELSTRING(Rearm,rearm), _apMagazineName],
_rearmApIcon,
_rearmApIcon,
_rearmMKShowCondition,
_rearmMKProgressCondition,
{},
{},
{
params ["_vehicle"];
[_vehicle, [0], "gm_75Rnd_20x139mm_apds_t_dm63", [QEGVAR(Rearm,mk20_ap_ammo)], REARM_DURATION] call EFUNC(Rearm,rearm);
},
{},
[],
HOLD_TIME,
nil,
false,
false,
false
] call BIS_fnc_holdActionAdd;

// Nebeltöpfe auffüllen
private _rearmSmokeIcon = QPATHTOEF(Rearm,data\ui\holdaction_rearm_smoke.paa);
private _smokeMagazineName = [QEGVAR(Rearm,smoke_6grenade_ammo)] call EFUNC(Rearm,getMagazineName);
[
_vehicle,
format [LELSTRING(Rearm,rearm), _smokeMagazineName],
_rearmSmokeIcon,
_rearmSmokeIcon,
QUOTE([ARR_4(_target, _this, 'mainturret_coax', 2)] call EFUNC(Rearm,canRearmFromOutside)),
QUOTE([ARR_4(_target, _caller, 'mainturret_coax', 2)] call EFUNC(Rearm,canRearmFromOutside)),
{},
{},
{
params ["_vehicle"];
[_vehicle, [0], QGVAR(1Rnd_76mm_RP_dm35), [QEGVAR(Rearm,smoke_6grenade_ammo)], REARM_DURATION] call EFUNC(Rearm,rearm);
},
{},
[],
HOLD_TIME,
nil,
false,
false,
false
] call BIS_fnc_holdActionAdd;

// MG laden
private _rearmMGIcon = QPATHTOEF(Rearm,data\ui\holdaction_rearm_mg.paa);
private _mgMagazineName = getText (configFile >> "CfgWeapons" >> QGVAR(mg3_coax) >> "displayName");
// List of all mags which can be used to rearm the turret MG3
// Sorted decending to rearm with the bigger mags first
private _mg3CompatibleMags = [
"hlc_250Rnd_762x51_B_MG3",
"hlc_250Rnd_762x51_M_MG3",
"hlc_250Rnd_762x51_mdim_MG3",
"hlc_250Rnd_762x51_Barrier_MG3",
"hlc_250Rnd_762x51_T_MG3",

"gm_120Rnd_762x51mm_B_T_DM21_mg3_grn",
"gm_120Rnd_762x51mm_B_T_DM21A1_mg3_grn",
"gm_120Rnd_762x51mm_B_T_DM21A2_mg3_grn",

"hlc_100Rnd_762x51_B_MG3",
"hlc_100Rnd_762x51_M_MG3",
"hlc_100Rnd_762x51_mdim_MG3",
"hlc_100Rnd_762x51_Barrier_MG3",
"hlc_100Rnd_762x51_T_MG3",

"hlc_50Rnd_762x51_B_MG3",
"hlc_50Rnd_762x51_M_MG3",
"hlc_50Rnd_762x51_mdim_MG3",
"hlc_50Rnd_762x51_Barrier_MG3",
"hlc_50Rnd_762x51_T_MG3"
];
[
_vehicle,
format [LELSTRING(Rearm,rearm), _mgMagazineName],
_rearmMGIcon,
_rearmMGIcon,
QUOTE([ARR_4(_target, _this, 'mainturret_coax', 2)] call EFUNC(Rearm,canRearmFromOutside)),
QUOTE([ARR_4(_target, _caller, 'mainturret_coax', 2)] call EFUNC(Rearm,canRearmFromOutside)),
{},
{},
{
params ["_vehicle", "", "", "_args"];
_args params ["_mg3CompatibleMags"];

[_vehicle, [0], "gm_500Rnd_762x51mm_b_t_DM21_mg3", _mg3CompatibleMags, REARM_DURATION] call EFUNC(Rearm,rearm);
},
{},
[_mg3CompatibleMags],
HOLD_TIME,
nil,
false,
false,
false
] call BIS_fnc_holdActionAdd;
71 changes: 0 additions & 71 deletions addons/GM_Marder/functions/fnc_initRearmMKActions.sqf

This file was deleted.

Loading

0 comments on commit 8e4061e

Please sign in to comment.