Merge pull request #2164 from GitHawk/rearm

Adding vehicle rearming
This commit is contained in:
Thomas Kooi 2015-11-26 16:15:09 +01:00
commit bba0e999ff
43 changed files with 1835 additions and 18 deletions

View File

@ -26,7 +26,7 @@ class CfgAmmo {
thrustTime = 1.07;
thrust = 530;
fuseDistance = 2;
effectsMissileInit = "MissileDAR1";
effectsMissile = "missile2";
whistleDist = 4;
@ -34,34 +34,34 @@ class CfgAmmo {
// Turn off arma crosshair-guidance
manualControl = 0;
// ACE uses these values
trackOversteer = 1;
trackLead = 0;
// Begin ACE guidance Configs
class ADDON {
enabled = 1;
minDeflection = 0.00025; // Minium flap deflection for guidance
maxDeflection = 0.001; // Maximum flap deflection for guidance
incDeflection = 0.0005; // The incrmeent in which deflection adjusts.
canVanillaLock = 0; // Can this default vanilla lock? Only applicable to non-cadet mode
// Guidance type for munitions
defaultSeekerType = "SALH";
seekerTypes[] = { "SALH", "LIDAR", "SARH", "Optic", "Thermal", "GPS", "SACLOS", "MCLOS" };
seekerTypes[] = { "SALH", "LIDAR", "SARH", "Optic", "Thermal", "GPS", "SACLOS", "MCLOS" };
defaultSeekerLockMode = "LOAL";
seekerLockModes[] = { "LOAL", "LOBL" };
seekerLockModes[] = { "LOAL", "LOBL" };
seekerAngle = 90; // Angle in front of the missile which can be searched
seekerAccuracy = 1; // seeker accuracy multiplier
seekerMinRange = 1;
seekerMaxRange = 2500; // Range from the missile which the seeker can visually search
// Attack profile type selection
defaultAttackProfile = "LIN";
attackProfiles[] = { "LIN", "DIR", "MID", "HI" };
@ -71,10 +71,12 @@ class CfgAmmo {
class ACE_Hydra70_DAGR: M_PG_AT {
displayName = CSTRING(Hydra70_DAGR);
displayNameShort = CSTRING(Hydra70_DAGR_Short);
description = CSTRING(Hydra70_DAGR_Desc);
descriptionShort = CSTRING(Hydra70_DAGR_Desc);
EGVAR(rearm,caliber) = 70;
//Explicity add guidance config
class ADDON: ADDON {};
};
@ -82,14 +84,14 @@ class CfgAmmo {
class ACE_Hellfire_AGM114K: ACE_Hydra70_DAGR {
displayName = CSTRING(Hellfire_AGM114K);
displayNameShort = CSTRING(Hellfire_AGM114K_Short);
description = CSTRING(Hellfire_AGM114K_desc);
descriptionShort = CSTRING(Hellfire_AGM114K_desc);
// @TODO: placeholder model to at least make it look different
model = "\A3\Weapons_F\Ammo\Missile_AT_03_fly_F";
proxyShape = "\A3\Weapons_F\Ammo\Missile_AT_03_F";
hit = 1400;
indirectHit = 71;
indirectHitRange = 4.5;
@ -98,7 +100,7 @@ class CfgAmmo {
//Explicity add guidance config
class ADDON: ADDON {};
};
// Titan
class M_Titan_AT: MissileBase {};

1
addons/rearm/$PBOPREFIX$ Normal file
View File

@ -0,0 +1 @@
z\ace\addons\rearm

View File

@ -0,0 +1,9 @@
class ACE_Settings {
class GVAR(level) {
displayName = CSTRING(RearmSettings_level_DisplayName);
description = CSTRING(RearmSettings_level_Description);
value = 0;
typeName = "SCALAR";
values[] = {CSTRING(RearmSettings_vehicle), CSTRING(RearmSettings_magazine), CSTRING(RearmSettings_caliber)};
};
};

200
addons/rearm/CfgAmmo.hpp Normal file
View File

@ -0,0 +1,200 @@
class CfgAmmo {
class BombCore;
class BombBase : BombCore {
GVAR(caliber) = 250; // Default caliber for bombs
};
class LaserBombCore : BombCore {
GVAR(caliber) = 250; // Default caliber for bombs
};
class MissileCore;
class MissileBase : MissileCore {
GVAR(caliber) = 250; // Default caliber for missiles
};
class Missile_AA_04_F : MissileBase {
GVAR(dummy) = QGVAR(Missile_AA_04_F);
};
class Missile_AA_03_F : Missile_AA_04_F {
GVAR(dummy) = QGVAR(Missile_AA_03_F);
};
class Rocket_04_HE_F : MissileBase {
GVAR(caliber) = 70;
GVAR(dummy) = QGVAR(Rocket_04_HE_F);
};
class Rocket_03_HE_F : Rocket_04_HE_F {
GVAR(dummy) = QGVAR(Rocket_03_HE_F);
};
class Rocket_04_AP_F : Rocket_04_HE_F {
GVAR(dummy) = QGVAR(Rocket_04_AP_F);
};
class Rocket_03_AP_F : Rocket_04_AP_F {
GVAR(dummy) = QGVAR(Rocket_03_AP_F);
};
class M_PG_AT : MissileBase {
GVAR(caliber) = 70;
GVAR(dummy) = QGVAR(M_PG_AT);
};
class Missile_AGM_02_F : MissileBase {
GVAR(dummy) = QGVAR(Missile_AGM_02_F);
};
class Missile_AGM_01_F : Missile_AGM_02_F {
GVAR(dummy) = QGVAR(Missile_AGM_01_F);
};
class RocketCore;
class RocketBase : RocketCore {
GVAR(caliber) = 70; // Default caliber for rockets
};
class R_80mm_HE : RocketBase {
GVAR(caliber) = 80;
GVAR(dummy) = QGVAR(R_80mm_HE);
};
class R_60mm_HE : R_80mm_HE {
GVAR(caliber) = 60;
GVAR(dummy) = QGVAR(R_60mm_HE);
};
class R_Hydra_HE : RocketBase {
GVAR(dummy) = QGVAR(R_Hydra_HE);
};
class BulletBase;
class B_19mm_HE : BulletBase {
GVAR(caliber) = 19;
};
class B_20mm : BulletBase {
GVAR(caliber) = 20;
};
class B_25mm : BulletBase {
GVAR(caliber) = 25;
};
class B_30mm_AP : BulletBase {
GVAR(caliber) = 30;
};
class B_30mm_HE : B_19mm_HE {
GVAR(caliber) = 30;
};
class Gatling_30mm_HE_Plane_CAS_01_F : BulletBase {
GVAR(caliber) = 30;
};
class B_35mm_AA : BulletBase {
GVAR(caliber) = 35;
};
class B_30mm_APFSDS;
class B_40mm_APFSDS : B_30mm_APFSDS {
GVAR(caliber) = 40;
};
class B_40mm_GPR : B_30mm_HE {
GVAR(caliber) = 40;
};
class GrenadeBase;
class G_40mm_HE : GrenadeBase {
GVAR(caliber) = 39;
};
class ShellBase;
class R_230mm_fly : ShellBase {
GVAR(dummy) = QGVAR(R_230mm_fly);
};
class Sh_120mm_APFSDS : Shellbase {
GVAR(caliber) = 120;
};
class Sh_105mm_APFSDS : Sh_120mm_APFSDS {
GVAR(caliber) = 105;
};
class Sh_125mm_APFSDS : Sh_120mm_APFSDS {
GVAR(caliber) = 125;
};
class Sh_120mm_HE : ShellBase {
GVAR(caliber) = 120;
};
class Sh_125mm_HE : Sh_120mm_HE {
GVAR(caliber) = 125;
};
class Sh_125mm_HEAT : Sh_125mm_HE {
GVAR(caliber) = 125;
};
class Sh_105mm_HEAT_MP : Sh_125mm_HEAT {
GVAR(caliber) = 105;
};
class Sh_155mm_AMOS : ShellBase {
GVAR(caliber) = 155;
};
class Sh_82mm_AMOS : Sh_155mm_AMOS {
GVAR(caliber) = 82;
};
class Sh_82mm_AMOS_LG;
class Sh_155mm_AMOS_LG : Sh_82mm_AMOS_LG {
GVAR(caliber) = 155;
};
class ShotDeployBase;
class Smoke_82mm_AMOS_White : ShotDeployBase {
GVAR(caliber) = 82;
};
class FlareCore;
class Flare_82mm_AMOS_White : FlareCore {
GVAR(caliber) = 82;
};
class SmokeLauncherAmmo : BulletBase {
GVAR(caliber) = 250;
};
class CMflareAmmo : BulletBase {
GVAR(caliber) = 39;
};
class SubmunitionBase;
class Sh_82mm_AMOS_guided : SubmunitionBase {
GVAR(caliber) = 82;
};
class Sh_155mm_AMOS_guided : Sh_82mm_AMOS_guided {
GVAR(caliber) = 155;
};
class R_230mm_HE : SubmunitionBase {
GVAR(caliber) = 230;
};
class Mine_155mm_AMOS_range : SubmunitionBase {
GVAR(caliber) = 155;
};
class Cluster_155mm_AMOS : SubmunitionBase {
GVAR(caliber) = 155;
};
class Smoke_120mm_AMOS_White : SubmunitionBase {
GVAR(caliber) = 155;
};
class AT_Mine_155mm_AMOS_range : SubmunitionBase {
GVAR(caliber) = 155;
};
class Bo_Mk82 : BombCore {
GVAR(dummy) = QGVAR(Bo_Mk82);
};
class Bo_GBU12_LGB : LaserBombCore {
GVAR(caliber) = 250; // Default caliber for bombs
GVAR(dummy) = QGVAR(Bo_GBU12_LGB);
};
class Bomb_04_F : LaserBombCore {
GVAR(caliber) = 250; // Default caliber for bombs
GVAR(dummy) = QGVAR(Bomb_04_F);
};
class Bomb_03_F : Bomb_04_F {
GVAR(dummy) = QGVAR(Bomb_03_F);
};
};

View File

@ -0,0 +1,36 @@
class Extended_PreInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preInit));
};
};
class Extended_Init_EventHandlers {
class GVAR(defaultCarriedObject) { // TODO check if we need to add all subclasses
class ADDON {
init = QUOTE(_this call DEFUNC(cargo,initObject));
};
};
};
class Extended_PostInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_postInit));
};
};
class Extended_Respawn_EventHandlers {
class CAManBase {
class ADDON {
respawn = QUOTE(call COMPILE_FILE(XEH_respawn));
};
};
};
class Extended_Killed_EventHandlers {
class CAManBase {
class ADDON {
killed = QUOTE(_this call FUNC(handleKilled));
};
};
};

View File

@ -0,0 +1,56 @@
class CfgMagazines {
class CA_Magazine;
class 60Rnd_CMFlareMagazine : CA_Magazine {
displayName = CSTRING(Mag_60Rnd_CMFlareMagazine);
};
class VehicleMagazine;
class SmokeLauncherMag : VehicleMagazine {
displayName = CSTRING(Mag_SmokeLauncherMag);
};
class SmokeLauncherMag_boat : VehicleMagazine {
displayName = CSTRING(Mag_SmokeLauncherMag);
};
class 1000Rnd_Gatling_30mm_Plane_CAS_01_F : VehicleMagazine {
displayName = CSTRING(Mag_1000Rnd_Gatling_30mm_Plane_CAS_01_F);
};
class 500Rnd_Cannon_30mm_Plane_CAS_02_F : 1000Rnd_Gatling_30mm_Plane_CAS_01_F {
displayName = CSTRING(Mag_500Rnd_Cannon_30mm_Plane_CAS_02_F);
};
class 2Rnd_Missile_AA_04_F : VehicleMagazine {
displayName = CSTRING(Mag_2Rnd_Missile_AA_04_F);
};
class 2Rnd_Missile_AA_03_F : 2Rnd_Missile_AA_04_F {
displayName = CSTRING(Mag_2Rnd_Missile_AA_03_F);
};
class 6Rnd_Missile_AGM_02_F : VehicleMagazine {
displayName = CSTRING(Mag_6Rnd_Missile_AGM_02_F);
};
class 4Rnd_Missile_AGM_01_F : 6Rnd_Missile_AGM_02_F {
displayName = CSTRING(Mag_4Rnd_Missile_AGM_01_F);
};
class 7Rnd_Rocket_04_HE_F : VehicleMagazine {
displayName = CSTRING(Mag_7Rnd_Rocket_04_HE_F);
};
class 20Rnd_Rocket_03_HE_F : 7Rnd_Rocket_04_HE_F {
displayName = CSTRING(Mag_20Rnd_Rocket_03_HE_F);
};
class 7Rnd_Rocket_04_AP_F : 7Rnd_Rocket_04_HE_F {
displayName = CSTRING(Mag_7Rnd_Rocket_04_AP_F);
};
class 20Rnd_Rocket_03_AP_F : 7Rnd_Rocket_04_AP_F {
displayName = CSTRING(Mag_20Rnd_Rocket_03_AP_F);
};
class 4Rnd_Bomb_04_F : VehicleMagazine {
displayName = CSTRING(Mag_4Rnd_Bomb_04_F);
};
class 2Rnd_Bomb_03_F : 4Rnd_Bomb_04_F {
displayName = CSTRING(Mag_2Rnd_Bomb_03_F);
};
};

View File

@ -0,0 +1,246 @@
#define MACRO_REARM_ACTIONS \
class ACE_Actions { \
class ACE_MainActions { \
class GVAR(Rearm) { \
displayName = CSTRING(Rearm); \
distance = REARM_ACTION_DISTANCE; \
condition = QUOTE(_this call FUNC(canRearm)); \
statement = QUOTE(_player call FUNC(rearm)); \
exceptions[] = {"isNotInside"}; \
icon = PATHTOF(ui\icon_rearm_interact.paa); \
}; \
}; \
};
#define MACRO_REARM_TRUCK_ACTIONS \
class ACE_Actions : ACE_Actions { \
class ACE_MainActions : ACE_MainActions { \
class GVAR(TakeAmmo) { \
displayName = CSTRING(TakeAmmo); \
distance = REARM_ACTION_DISTANCE; \
condition = QUOTE(_this call FUNC(canTakeAmmo)); \
insertChildren = QUOTE(_target call FUNC(addRearmActions)); \
exceptions[] = {"isNotInside"}; \
showDisabled = 0; \
priority = 2; \
icon = PATHTOF(ui\icon_rearm_interact.paa); \
}; \
class GVAR(StoreAmmo) { \
displayName = CSTRING(StoreAmmo); \
distance = REARM_ACTION_DISTANCE; \
condition = QUOTE(_this call FUNC(canStoreAmmo)); \
statement = QUOTE(_this call FUNC(storeAmmo)); \
exceptions[] = {"isNotInside"}; \
icon = PATHTOF(ui\icon_rearm_interact.paa); \
}; \
}; \
};
class CfgVehicles {
class ACE_Module;
class ACE_moduleRearmSettings : ACE_Module {
scope = 2;
displayName = CSTRING(RearmSettings_Module_DisplayName);
icon = QUOTE(PATHTOF(ui\icon_module_rearm.paa));
category = "ACE_Logistics";
function = QFUNC(moduleRearmSettings);
functionPriority = 1;
isGlobal = 0;
isTriggerActivated = 0;
author = ECSTRING(common,ACETeam);
class Arguments {
class level {
displayName = CSTRING(RearmSettings_level_DisplayName);
description = CSTRING(RearmSettings_level_Description);
typeName = "NUMBER";
class values {
class vehicle {
name = CSTRING(RearmSettings_vehicle);
value = 0;
};
class magazine {
name = CSTRING(RearmSettings_magazine);
value = 1;
};
class caliber {
name = CSTRING(RearmSettings_caliber);
value = 2;
default = 1;
};
};
};
};
class ModuleDescription {
description = CSTRING(RearmSettings_Module_Description);
};
};
class LandVehicle;
class Car : LandVehicle {
MACRO_REARM_ACTIONS
};
class Tank : LandVehicle {
MACRO_REARM_ACTIONS
};
class StaticWeapon : LandVehicle {
MACRO_REARM_ACTIONS
};
class Air;
class Helicopter : Air {
MACRO_REARM_ACTIONS
};
class Plane : Air {
MACRO_REARM_ACTIONS
};
class Ship;
class Ship_F : Ship {
MACRO_REARM_ACTIONS
};
// Ammo Vehicles (with full inheritance for granted ACE_Actions)
class Car_F : Car {};
class Truck_F : Car_F {};
class Truck_03_base_F : Truck_F {};
class O_Truck_03_ammo_F : Truck_03_base_F {
transportAmmo = 0;
MACRO_REARM_TRUCK_ACTIONS
};
class Truck_02_base_F : Truck_F {};
class Truck_02_Ammo_base_F : Truck_02_base_F {};
class I_Truck_02_ammo_F : Truck_02_Ammo_base_F {
transportAmmo = 0;
MACRO_REARM_TRUCK_ACTIONS
};
class O_Truck_02_Ammo_F : Truck_02_Ammo_base_F {
transportAmmo = 0;
MACRO_REARM_TRUCK_ACTIONS
};
class Truck_01_base_F : Truck_F {};
class B_Truck_01_transport_F : Truck_01_base_F {};
class B_Truck_01_mover_F : B_Truck_01_transport_F {};
class B_Truck_01_ammo_F : B_Truck_01_mover_F {
transportAmmo = 0;
MACRO_REARM_TRUCK_ACTIONS
};
class Helicopter_Base_F : Helicopter {};
class Helicopter_Base_H : Helicopter_Base_F {};
class Heli_Transport_04_base_F : Helicopter_Base_H {};
class O_Heli_Transport_04_ammo_F : Heli_Transport_04_base_F {
transportAmmo = 0;
MACRO_REARM_TRUCK_ACTIONS
};
class Land_Pod_Heli_Transport_04_base_F : StaticWeapon {};
class Land_Pod_Heli_Transport_04_ammo_F : Land_Pod_Heli_Transport_04_base_F {
XEH_ENABLED;
transportAmmo = 0;
MACRO_REARM_TRUCK_ACTIONS
};
class ReammoBox_F;
class Slingload_01_Base_F : ReammoBox_F {
class ACE_Actions {
class ACE_MainActions {
displayName = ECSTRING(interaction,MainAction);
selection = "";
distance = 10;
condition = "true";
};
};
};
class B_Slingload_01_Ammo_F : Slingload_01_Base_F {
XEH_ENABLED;
transportAmmo = 0;
MACRO_REARM_TRUCK_ACTIONS
};
// Dummy Vehicles
class ThingX;
class GVAR(defaultCarriedObject) : ThingX {
XEH_ENABLED;
displayName = QGVAR(dummy_obj);
scope = 2;
scopeCurator = 2;
model = "\A3\Weapons_F\AmmoBoxes\AmmoBox_F.p3d";
EGVAR(cargo,size) = 1;
class ACE_Actions {
class ACE_MainActions {
displayName = CSTRING(PickUpAmmo);
distance = REARM_ACTION_DISTANCE;
condition = QUOTE(_this call FUNC(canTakeAmmo));
statement = QUOTE(_this call FUNC(grabAmmo));
exceptions[] = {"isNotInside"};
showDisabled = 0;
priority = 2;
icon = PATHTOF(ui\icon_rearm_interact.paa);
};
};
};
class GVAR(Bo_GBU12_LGB) : GVAR(defaultCarriedObject) {
model = "\A3\Weapons_F\Ammo\Bomb_01_F.p3d";
};
class GVAR(Bo_Mk82) : GVAR(defaultCarriedObject) {
model = "\A3\Weapons_F\Ammo\Bomb_02_F";
};
class GVAR(Bomb_04_F) : GVAR(defaultCarriedObject) {
model = "\A3\Weapons_F_EPC\Ammo\Bomb_04_F.p3d";
};
class GVAR(Bomb_03_F) : GVAR(defaultCarriedObject) {
model = "\A3\Weapons_F_EPC\Ammo\Bomb_03_F.p3d";
};
class GVAR(Missile_AA_04_F) : GVAR(defaultCarriedObject) {
model = "\A3\Weapons_F_EPC\Ammo\Missile_AA_04_F.p3d";
};
class GVAR(Missile_AA_03_F) : GVAR(defaultCarriedObject) {
model = "\A3\Weapons_F_EPC\Ammo\Missile_AA_03_F.p3d";
};
class GVAR(Missile_AGM_02_F) : GVAR(defaultCarriedObject) {
model = "\A3\Weapons_F_EPC\Ammo\Missile_AGM_02_F.p3d";
};
class GVAR(Missile_AGM_01_F) : GVAR(defaultCarriedObject) {
model = "\A3\Weapons_F_EPC\Ammo\Missile_AGM_01_F.p3d";
};
class GVAR(R_230mm_fly) : GVAR(defaultCarriedObject) {
model = "\A3\Weapons_F\Ammo\Missile_AT_02_F";
};
class GVAR(R_230mm_HE) : GVAR(defaultCarriedObject) {
model = "\A3\Weapons_F\Ammo\Missile_AT_02_F";
};
class GVAR(M_PG_AT) : GVAR(defaultCarriedObject) {
model = "\A3\Weapons_F\Ammo\Rocket_01_F";
};
class GVAR(Rocket_04_HE_F) : GVAR(defaultCarriedObject) {
model = "\A3\Weapons_F_EPC\Ammo\Rocket_04_HE_F.p3d";
};
class GVAR(Rocket_03_HE_F) : GVAR(defaultCarriedObject) {
model = "\A3\Weapons_F_EPC\Ammo\Rocket_03_HE_F.p3d";
};
class GVAR(Rocket_04_AP_F) : GVAR(defaultCarriedObject) {
model = "\A3\Weapons_F_EPC\Ammo\Rocket_04_AP_F.p3d";
};
class GVAR(Rocket_03_AP_F) : GVAR(defaultCarriedObject) {
model = "\A3\Weapons_F_EPC\Ammo\Rocket_03_AP_F.p3d";
};
// Using wrong model
class GVAR(R_80mm_HE) : GVAR(defaultCarriedObject) {
model = "\A3\Weapons_F_EPC\Ammo\Rocket_03_HE_F.p3d";
};
class GVAR(R_60mm_HE) : GVAR(defaultCarriedObject) {
model = "\A3\Weapons_F_EPC\Ammo\Rocket_03_HE_F.p3d";
};
class GVAR(R_Hydra_HE) : GVAR(defaultCarriedObject) {
model = "\A3\Weapons_F_EPC\Ammo\Rocket_03_HE_F.p3d";
};
};

11
addons/rearm/README.md Normal file
View File

@ -0,0 +1,11 @@
ace_rearm
===============
The Rearm module introduces ability to rearm vehicles on different realistic levels.
## Maintainers
The people responsible for merging changes to this component or answering potential questions.
- [GitHawk] (https://github.com/GitHawk)
- [Jonpas] (https://github.com/jonpas)

View File

@ -0,0 +1,4 @@
#include "script_component.hpp"
["medical_onUnconscious", {_this call FUNC(handleOnUnconscious)}] call EFUNC(common,addEventHandler);
["playerVehicleChanged", {params ["_unit"]; [_unit] call FUNC(dropAmmo)}] call EFUNC(common,addEventHandler);

View File

@ -0,0 +1,30 @@
#include "script_component.hpp"
ADDON = false;
PREP(addRearmActions);
PREP(canRearm);
PREP(canStoreAmmo);
PREP(canTakeAmmo);
PREP(createDummy);
PREP(dropAmmo);
PREP(getConfigMagazines);
PREP(getMaxMagazines);
PREP(getNeedRearmMagazines);
PREP(grabAmmo);
PREP(handleKilled);
PREP(handleUnconscious);
PREP(makeDummy);
PREP(moduleRearmSettings);
PREP(pickUpAmmo);
PREP(rearm);
PREP(rearmEntireVehicle);
PREP(rearmEntireVehicleSuccess);
PREP(rearmEntireVehicleSuccessLocal);
PREP(rearmSuccess);
PREP(rearmSuccessLocal);
PREP(storeAmmo);
PREP(takeAmmo);
PREP(takeSuccess);
ADDON = true;

View File

@ -0,0 +1,16 @@
#include "script_component.hpp"
private ["_unit"];
_unit = _this select 0;
if !(local _unit) exitWith {};
_unit setVariable [QGVAR(selectedWeaponOnRearm), nil];
_unit setVariable [QGVAR(carriedMagazine), nil];
_dummy = _unit getVariable [QGVAR(dummy), objNull];
if !(isNull _dummy) then {
detach _dummy;
deleteVehicle _dummy;
};
_unit setVariable [QGVAR(dummy), nil];

20
addons/rearm/config.cpp Normal file
View File

@ -0,0 +1,20 @@
#include "script_component.hpp"
class CfgPatches {
class ADDON {
units[] = {};
weapons[] = {};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_interaction"};
author[] = {"GitHawk", "Jonpas"};
authorUrl = "https://ace3mod.com";
VERSION_CONFIG;
};
};
#include "ACE_Settings.hpp"
#include "CfgEventHandlers.hpp"
#include "CfgAmmo.hpp"
#include "CfgMagazines.hpp"
#include "CfgVehicles.hpp"

View File

@ -0,0 +1,98 @@
/*
* Author: GitHawk
* Show the resupplyable ammunition of all surrounding vehicles.
*
* Argument:
* 0: Target <OBJECT>
*
* Return value:
* ChildActions <ARRAY>
*
* Example:
* [tank] call ace_rearm_fnc_addRearmActions
*
* Public: No
*/
#include "script_component.hpp"
private ["_vehicleActions", "_actions", "_action", "_vehicles", "_vehicle", "_needToAdd", "_magazineHelper", "_turretPath", "_magazines", "_magazine", "_icon", "_cnt"];
params ["_target"];
_vehicles = nearestObjects [_target, ["AllVehicles"], 20];
if (count _vehicles < 2) exitWith {false}; // Rearming needs at least 2 vehicles
_vehicleActions = [];
{
_actions = [];
_vehicle = _x;
_needToAdd = false;
_action = [];
if !((_vehicle == _target) || (_vehicle isKindOf "CAManBase")) then {
_magazineHelper = [];
{
_turretPath = _x;
_magazines = [];
if (_turretPath isEqualTo [-1]) then {
_magazines = [_vehicle, _turretPath] call FUNC(getConfigMagazines);
} else {
_magazines = _vehicle magazinesTurret _turretPath;
};
{
_magazine = _x;
_cnt = { _x == _magazine } count (_vehicle magazinesTurret _turretPath);
if ((_cnt < ([_vehicle, _turretPath, _magazine] call FUNC(getMaxMagazines))) && !(_magazine in _magazineHelper)) then {
_action = [_magazine,
getText(configFile >> "CfgMagazines" >> _magazine >> "displayName"),
getText(configFile >> "CfgMagazines" >> _magazine >> "picture"),
{_this call FUNC(takeAmmo)},
{true},
{},
[_magazine, _vehicle]] call EFUNC(interact_menu,createAction);
_actions pushBack [_action, [], _target];
_magazineHelper pushBack _magazine;
_needToAdd = true;
} else {
if (((_vehicle magazineTurretAmmo [_magazine, _turretPath]) < getNumber (configFile >> "CfgMagazines" >> _magazine >> "count")) && !(_magazine in _magazineHelper)) then {
_action = [_magazine,
getText(configFile >> "CfgMagazines" >> _magazine >> "displayName"),
getText(configFile >> "CfgMagazines" >> _magazine >> "picture"),
{_this call FUNC(takeAmmo)},
{true},
{},
[_magazine, _vehicle]] call EFUNC(interact_menu,createAction);
_actions pushBack [_action, [], _target];
_magazineHelper pushBack _magazine;
_needToAdd = true;
};
};
} forEach _magazines;
} forEach REARM_TURRET_PATHS;
};
if (_needToAdd && !(_vehicle getVariable [QGVAR(disabled), false])) then {
_icon = getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "Icon");
if !((_icon select [0, 1]) == "\") then {
_icon = "";
};
if (GVAR(level) == 0) then {
_action = [_vehicle,
getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName"),
_icon,
{_this call FUNC(rearmEntireVehicle)},
{true},
{},
_vehicle] call EFUNC(interact_menu,createAction);
_vehicleActions pushBack [_action, [], _target];
} else {
_action = [_vehicle,
getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName"),
_icon,
{},
{true},
{},
[]] call EFUNC(interact_menu,createAction);
_vehicleActions pushBack [_action, _actions, _target];
};
};
} forEach _vehicles;
_vehicleActions

View File

@ -0,0 +1,29 @@
/*
* Author: GitHawk, Jonpas
* Check if a unit can rearm.
*
* Arguments:
* 0: Target <OBJECT>
* 1: Unit <OBJECT>
*
* Return Value:
* Can Rearm <BOOL>
*
* Example:
* [player, tank] call ace_rearm_fnc_canRearm
*
* Public: No
*/
#include "script_component.hpp"
private ["_dummy","_magazineClass"];
params ["_target", "_unit"];
if (GVAR(level) == 0 || {isNull _unit} || {!(_unit isKindOf "CAManBase")} || {!local _unit} || {_target distance _unit > REARM_ACTION_DISTANCE} || {_target getVariable [QGVAR(disabled), false]}) exitWith {false};
_dummy = _unit getVariable [QGVAR(dummy), objNull];
if (isNull _dummy) exitwith {false};
_magazineClass = _dummy getVariable QGVAR(magazineClass);
if (isNil "_magazineClass") exitWith {false};
([_target, _magazineClass] call FUNC(getNeedRearmMagazines)) select 0

View File

@ -0,0 +1,25 @@
/*
* Author: GitHawk
* Check if a unit can store ammo in an ammo truck.
*
* Arguments:
* 0: Target <OBJECT>
* 1: Unit <OBJECT>
*
* Return Value:
* Can Store Ammo <BOOL>
*
* Example:
* [player, tank] call ace_rearm_fnc_canStoreAmmo
*
* Public: No
*/
#include "script_component.hpp"
params ["_target", "_unit"];
!(isNull _unit ||
{!(_unit isKindOf "CAManBase")} ||
{!local _unit} ||
{(_target distance _unit) > REARM_ACTION_DISTANCE} ||
{isNull (_unit getVariable [QGVAR(dummy), objNull])})

View File

@ -0,0 +1,25 @@
/*
* Author: GitHawk
* Check if a unit can pick up ammo.
*
* Arguments:
* 0: Target <OBJECT>
* 1: Unit <OBJECT>
*
* Return Value:
* Can Pick Up Ammo <BOOL>
*
* Example:
* [player, tank] call ace_rearm_fnc_canTakeAmmo
*
* Public: No
*/
#include "script_component.hpp"
params ["_target", "_unit"];
!(isNull _unit ||
{!(_unit isKindOf "CAManBase")} ||
{!local _unit} ||
{(_target distance _unit) > REARM_ACTION_DISTANCE} ||
{!isNull (_unit getVariable [QGVAR(dummy), objNull])})

View File

@ -0,0 +1,33 @@
/*
* Author: GitHawk
* Creates a carryable ammunition dummy object.
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Magazine Classname <STRING>
*
* Return Value:
* Created Dummy <OBJECT>
*
* Example:
* ["500Rnd_127x99_mag_Tracer_Red"] call ace_rearm_fnc_createDummy
*
* Public: No
*/
#include "script_component.hpp"
private ["_ammo", "_dummyName", "_dummy"];
params ["_unit", "_magazineClass"];
_ammo = getText (configFile >> "CfgMagazines" >> _magazineClass >> "ammo");
_dummyName = getText (configFile >> "CfgAmmo" >> _ammo >> QGVAR(dummy));
_dummy = objNull;
if !(_dummyName == "") then {
_dummy = _dummyName createVehicle (position _unit);
} else {
_dummy = QGVAR(defaultCarriedObject) createVehicle (position _unit);
};
_dummy allowDamage false;
_dummy setVariable [QGVAR(magazineClass), _magazineClass, true];
_dummy

View File

@ -0,0 +1,43 @@
/*
* Author: GitHawk
* Drops a magazine, optionally deletes it and optionally unholsters the wepaon.
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Delete dummy object <BOOL> (optional)
* 2: Unholster Weapon <BOOL> (optional)
*
* Return Value:
* None
*
* Example:
* [player, true, true] call ace_rearm_fnc_dropAmmo
*
* Public: No
*/
#include "script_component.hpp"
private ["_dummy", "_actionID"];
params ["_unit", ["_delete", false], ["_unholster", true]];
_dummy = _unit getVariable [QGVAR(dummy), objNull];
if !(isNull _dummy) then {
detach _dummy;
if (_delete) then {
deleteVehicle _dummy;
} else {
_dummy setVelocity [0,0,-0.1];
};
_unit setVariable [QGVAR(dummy), objNull];
//_unit setVariable [QEGVAR(dragging,isCarrying), false, true]; // breaks things, since it hides interact menu on _target
};
_actionID = _unit getVariable [QGVAR(ReleaseActionID), -1];
if (_actionID != -1) then {
_unit removeAction _actionID;
_unit setVariable [QGVAR(ReleaseActionID), nil];
};
[_unit, QGVAR(vehRearm), false] call EFUNC(common,setForceWalkStatus);
if (_unholster) then {
REARM_UNHOLSTER_WEAPON
};

View File

@ -0,0 +1,53 @@
/*
* Author: GitHawk, Jonpas
* Returns all magazines a turret can hold according to config.
*
* Arguments:
* 0: Target <OBJECT>
* 1: Turret Path <ARRAY>
*
* Return Value:
* Magazine classes in TurretPath <ARRAY>
*
* Example:
* [vehicle, [0]] call ace_rearm_fnc_getConfigMagazines
*
* Public: No
*/
#include "script_component.hpp"
params ["_target", "_turretPath"];
if (isNull _target) exitWith {[]};
_cfg = configFile >> "CfgVehicles" >> (typeOf _target) >> "Turrets";
if (count _turretPath == 1) then {
_turretPath params ["_subPath"];
if (_subPath == -1) exitWith {
_cfg = configFile >> "CfgVehicles" >> (typeOf _target);
};
if (count _cfg > _subPath) then {
_cfg = _cfg select _subPath;
} else {
_cfg = nil;
};
} else {
_turretPath params ["", "_subPath"];
if (count _cfg > 0) then {
_cfg = (_cfg select 0) >> "Turrets";
if (count _cfg > _subPath) then {
_cfg = _cfg select _subPath;
} else {
_cfg = nil;
};
} else {
_cfg = nil;
};
};
if !(isClass _cfg) exitWith {[]};
getArray (_cfg >> "magazines")

View File

@ -0,0 +1,26 @@
/*
* Author: GitHawk, Jonpas
* Calculates the maximum number of magazines a turret can hold according to config.
*
* Arguments:
* 0: Target <OBJECT>
* 1: Turret Path <ARRAY>
* 2: Magazine Classname <STRING>
*
* Return Value:
* Number of magazines on the turret path <NUMBER>
*
* Example:
* [vehicle, [0], "500Rnd_127x99_mag_Tracer_Red"] call ace_rearm_fnc_getMaxMagazines
*
* Public: No
*/
#include "script_component.hpp"
private ["_count", "_cfg"];
params ["_target", "_turretPath", "_magazineClass"];
if (isNull _target) exitWith {0};
_count = {_x == _magazineClass} count ([_target, _turretPath] call FUNC(getConfigMagazines));
_count

View File

@ -0,0 +1,49 @@
/*
* Author: GitHawk, Jonpas
* Get rearm return value.
*
* Arguments:
* 0: Target <OBJECT>
* 1: Magazine Classname <STRING>
*
* Return Value:
* Return Value <ARRAY>
* 0: Can Rearm <BOOL>
* 1: TurretPath <ARRAY>
* 2: Magazine Classname <STRING>
*
* Example:
* [tank, "mag"] call ace_rearm_fnc_getNeedRearmMagazines
*
* Public: No
*/
#include "script_component.hpp"
private ["_return", "_magazines", "_cnt"];
params ["_target", "_magazineClass"];
_return = [false, [], 0];
{
_magazines = [];
if (_x isEqualTo [-1]) then {
_magazines = [_target, _x] call FUNC(getConfigMagazines);
} else {
_magazines = _target magazinesTurret _x;
};
if (_magazineClass in _magazines) then {
_cnt = {_x == _magazineClass} count (_target magazinesTurret _x);
if ((_target magazineTurretAmmo [_magazineClass, _x]) < getNumber (configFile >> "CfgMagazines" >> _magazineClass >> "count")) exitWith {
_return = [true, _x, _cnt];
};
if (_cnt < ([_target, _x, _magazineClass] call FUNC(getMaxMagazines))) exitWith {
_return = [true, _x, _cnt];
};
};
if (_return select 0) exitWith {};
} forEach REARM_TURRET_PATHS;
_return

View File

@ -0,0 +1,53 @@
/*
* Author: GitHawk
* Grabs an dummy ammo.
*
* Arguments:
* 0: Ammo Dummy <OBJECT>
* 1: Unit <OBJECT>
*
* Return Value:
* None
*
* Example:
* [dummy, player] call ace_rearm_fnc_grabAmmo
*
* Public: No
*/
#include "script_component.hpp"
params ["_dummy", "_unit"];
REARM_HOLSTER_WEAPON
[_unit, QGVAR(vehRearm), true] call EFUNC(common,setForceWalkStatus);
[
5,
[_dummy, _unit],
{
private ["_actionID"];
params ["_args"];
_args params ["_dummy", "_unit"];
[_dummy, _unit] call FUNC(pickUpAmmo);
_actionID = _unit getVariable [QGVAR(ReleaseActionID), -1];
if (_actionID != -1) then {
_unit removeAction _actionID;
};
_actionID = _unit addAction [
format ["<t color='#FF0000'>%1</t>", localize ELSTRING(dragging,Drop)],
'(_this select 0) call FUNC(dropAmmo)',
nil,
20,
false,
true,
"",
'!isNull (_target getVariable [QGVAR(dummy), objNull])'
];
_unit setVariable [QGVAR(ReleaseActionID), _actionID];
},
"",
localize LSTRING(GrabAction),
{true},
["isnotinside"]
] call EFUNC(common,progressBar);

View File

@ -0,0 +1,23 @@
/*
* Author: GitHawk, Jonpas
* Handles medical on set dead event.
*
* Arguments:
* 0: Unit <OBJECT>
*
* Return Value:
* None
*
* Example:
* [unit] call ace_rearm_fnc_handleKilled
*
* Public: No
*/
#include "script_component.hpp"
params ["_unit"];
if (!local _unit) exitWith {};
_unit setVariable [QGVAR(selectedWeaponOnRearm), nil];
[_unit, false, false] call FUNC(dropAmmo);

View File

@ -0,0 +1,23 @@
/*
* Author: GitHawk, Jonpas
* Handles medical on unconscious event.
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Is Unconscious <BOOL>
*
* Return Value:
* None
*
* Example:
* [unit] call ace_rearm_fnc_handleUnconscious
*
* Public: No
*/
#include "script_component.hpp"
params ["_unit", "_isUnconscious"];
if (!local _unit || {!_isUnconscious}) exitWith {};
[_unit, false, false] call FUNC(dropAmmo);

View File

@ -0,0 +1,23 @@
/*
* Author: GitHawk
* Make a dummy object by disabling collision and turning it.
*
* Arguments:
* 0: Object <OBJECT>
* 1: Vector dirAndUp <ARRAY>
*
* Return Value:
* None
*
* Example:
* [dummy, [[1,0,0],[0,0,1]]] call ace_rearm_fnc_makeDummy
*
* Public: No
*/
#include "script_component.hpp"
params ["_obj", "_dirAndUp"];
_obj setVectorDirAndUp _dirAndUp;
_obj allowDamage false;
player disableCollisionWith _obj;

View File

@ -0,0 +1,26 @@
/*
* Author: GitHawk
* Module for adjusting the refuel settings.
*
* Arguments:
* 0: The module logic <OBJECT>
* 1: Synchronized units <ARRAY>
* 2: Activated <BOOL>
*
* Return Value:
* None
*
* Example;
* function = "ace_rearm_fnc_moduleRearmSettings"
*
* Public: No
*/
#include "script_component.hpp"
params ["_logic", "", "_activated"];
if (!_activated) exitWith {};
[_logic, QGVAR(level), "level"] call EFUNC(common,readSettingFromModule);
diag_log text format ["[ACE]: Rearm Module Initialized on level: %1", GVAR(level)];

View File

@ -0,0 +1,31 @@
/*
* Author: GitHawk
* Starts progress bar for picking up a specific kind of magazine from the ground.
*
* Arguments:
* 0: Ammo Dummy <OBJECT>
* 1: Unit <OBJECT>
*
* Return Value:
* None
*
* Example:
* [target, player] call ace_rearm_fnc_pickUpAmmo
*
* Public: No
*/
#include "script_component.hpp"
private ["_magazineClass"];
params ["_target", "_unit"];
_dummy = _unit getVariable [QGVAR(dummy), objNull];
if !(isNull _dummy) exitWith {};
//_target attachTo [_unit, [0,0.7,0], "pelvis"];
_target attachTo [_unit, [0,1,0], "pelvis"];
{
[[_target, [[-1,0,0],[0,0,1]]], QFUNC(makeDummy), _x] call EFUNC(common,execRemoteFnc);
} count (position _unit nearObjects ["CAManBase", 100]);
_unit setVariable [QGVAR(dummy), _target];
//_unit setVariable [QEGVAR(dragging,isCarrying), true, true]; // breaks things, since it hides interact menu on _target

View File

@ -0,0 +1,75 @@
/*
* Author: GitHawk
* Starts progress bar for rearming a vehicle.
*
* Arguments:
* 0: Unit <OBJECT>
*
* Return Value:
* None
*
* Example:
* [player] call ace_rearm_fnc_rearm
*
* Public: No
*/
#include "script_component.hpp"
private ["_magazineClass", "_ammo", "_tmpCal", "_cal", "_idx", "_needRearmMags", "_magazineDisplayName"];
params ["_unit"];
_dummy = _unit getVariable [QGVAR(dummy), objNull];
if (isNull _dummy) exitwith {false};
_magazineClass = _dummy getVariable QGVAR(magazineClass);
if (isNil "_magazineClass") exitWith {false};
_ammo = getText (configFile >> "CfgMagazines" >> _magazineClass >> "ammo");
_tmpCal = getNumber (configFile >> "CfgAmmo" >> _ammo >> "ace_caliber");
_cal = 8;
if (_tmpCal > 0) then {
_cal = _tmpCal;
} else {
_tmpCal = getNumber (configFile >> "CfgAmmo" >> _ammo >> QGVAR(caliber));
if (_tmpCal > 0) then {
_cal = _tmpCal;
} else {
diag_log format ["[ACE] ERROR: Undefined Ammo [%1 : %2]", _ammo, inheritsFrom (configFile >> "CfgAmmo" >> _ammo)];
if (_ammo isKindOf "BulletBase") then {
_cal = 8;
} else {
_cal = 100;
};
};
};
_cal = round _cal;
_idx = REARM_CALIBERS find _cal;
if (_idx == -1) then {
_idx = 2;
};
// Get magazines that can be rearmed
_needRearmMags = [_target, _magazineClass] call FUNC(getNeedRearmMagazines);
_needRearmMags params ["_needRearm", "_turretPath", "_cnt"];
// Exit if no magazines need rearming
if (!_needRearm) exitWith {
diag_log format ["[ACE] ERROR: Could not find turret for %1 in %2", _magazineClass, typeOf _target];
};
//hint format ["Magazine: %1\nAmmo: %2\nCaliber: %3\nIndex: %4\nTurretPath: %5\nREARM_DURATION_REARM: %6\nCount: %7", _magazine, _ammo, _cal, _idx, _turretPath, (REARM_DURATION_REARM select _idx), (REARM_COUNT select _idx)];
_magazineDisplayName = getText(configFile >> "CfgMagazines" >> _magazineClass >> "displayName");
if (_magazineDisplayName == "") then {
_magazineDisplayName = _magazineClass;
diag_log format ["[ACE] ERROR: Magazine is missing display name [%1]", _magazineClass];
};
[
(REARM_DURATION_REARM select _idx),
[_target, _unit, _turretPath, _cnt, _magazineClass, (REARM_COUNT select _idx)],
FUNC(rearmSuccess),
"",
format [localize LSTRING(RearmAction), getText(configFile >> "CfgVehicles" >> (typeOf _target) >> "displayName"), _magazineDisplayName],
{true},
["isnotinside"]
] call EFUNC(common,progressBar);

View File

@ -0,0 +1,30 @@
/*
* Author: GitHawk
* Starts progress bar for rearming an entire vehicle.
*
* Arguments:
* 0: Ammo Truck <OBJECT>
* 1: Unit <OBJECT>
* 2: Vehicle to be armed <OBJECT>
*
* Return Value:
* None
*
* Example:
* [ammo_truck, player, tank] call ace_rearm_fnc_rearmEntireVehicle
*
* Public: No
*/
#include "script_component.hpp"
params ["_target", "_unit", "_vehicle"]; // _target is for future possible finite ammo, _unit placeholder
[
10,
_vehicle,
FUNC(rearmEntireVehicleSuccess),
"",
format [localize LSTRING(BasicRearmAction), getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName")],
{true},
["isnotinside"]
] call EFUNC(common,progressBar);

View File

@ -0,0 +1,33 @@
/*
* Author: GitHawk
* Rearm an entire vehicle.
*
* Arguments:
* 0: Vehicle <OBJECT>
*
* Return Value:
* None
*
* Example:
* [tank] call ace_rearm_fnc_rearmEntireVehicleSuccess
*
* Public: No
*/
#include "script_component.hpp"
private ["_turretPath", "_magazines", "_magazine", "_currentMagazines", "_maxMagazines", "_maxRounds", "_currentRounds"];
params ["_vehicle"];
if (isServer) then {
{
_turretOwnerID = _vehicle turretOwner _x;
if (_turretOwnerID == 0) then {
[[_vehicle, _x], QFUNC(rearmEntireVehicleSuccessLocal), _target] call EFUNC(common,execRemoteFnc);
} else {
EGVAR(common,remoteFnc) = [[_vehicle, _x], QFUNC(rearmEntireVehicleSuccessLocal), 0];
_turretOwnerID publicVariableClient QEGVAR(common,remoteFnc);
};
} count REARM_TURRET_PATHS;
} else {
[_this, QFUNC(rearmEntireVehicleSuccess), 1] call EFUNC(common,execRemoteFnc);
};

View File

@ -0,0 +1,48 @@
/*
* Author: GitHawk
* Rearm an entire turret locally.
*
* Arguments:
* 0: Vehicle <OBJECT>
*
* Return Value:
* None
*
* Example:
* [tank, [0]] call ace_rearm_fnc_rearmEntireVehicleSuccessLocal
*
* Public: No
*/
#include "script_component.hpp"
private ["_magazines", "_magazine", "_currentMagazines", "_maxMagazines", "_maxRounds", "_currentRounds"];
params ["_vehicle", "_turretPath"];
_magazines = [];
if (_turretPath isEqualTo [-1]) then {
_magazines = [_vehicle, _turretPath] call FUNC(getConfigMagazines);
} else {
_magazines = _vehicle magazinesTurret _turretPath;
};
{
_magazine = _x;
_currentMagazines = { _x == _magazine } count (_vehicle magazinesTurret _turretPath);
_maxMagazines = [_vehicle, _turretPath, _magazine] call FUNC(getMaxMagazines);
_maxRounds = getNumber (configFile >> "CfgMagazines" >> _magazine >> "count");
_currentRounds = _vehicle magazineTurretAmmo [_magazine, _turretPath];
TRACE_7("Rearmed Turret",_vehicle,_turretPath,_currentMagazines,_maxMagazines,_currentRounds,_maxRounds,_magazine);
if (_turretPath isEqualTo [-1] && _currentMagazines == 0) then {
// On driver, the empty magazine is still there, but is not returned by magazinesTurret
_currentMagazines = _currentMagazines + 1;
};
if (_currentMagazines < _maxMagazines) then {
_vehicle setMagazineTurretAmmo [_magazine, _maxRounds, _turretPath];
for "_idx" from 1 to (_maxMagazines - _currentMagazines) do {
_vehicle addMagazineTurret [_magazine, _turretPath];
};
} else {
_vehicle setMagazineTurretAmmo [_magazine, _maxRounds, _turretPath];
};
} foreach _magazines;

View File

@ -0,0 +1,44 @@
/*
* Author: GitHawk
* Rearms a vehicle.
*
* Arguments:
* 0: Params <ARRAY>
* 0: Target <OBJECT>
* 1: Unit <OBJECT>
* 2: Turret Path <ARRAY>
* 3: Number of magazines <NUMBER>
* 4: Magazine Classname <STRING>
* 5: Number of rounds <NUMBER>
*
* Return Value:
* None
*
* Example:
* [[vehicle, player, [-1], 2, "5000Rnd_762x51_Belt", 500]] call ace_rearm_fnc_rearmSuccess
*
* Public: No
*/
#include "script_component.hpp"
private ["_dummy", "_weaponSelect", "_turretOwnerID"];
params ["_args"];
_args params ["_target", "_unit", "_turretPath", "_numMagazines", "_magazineClass", "_numRounds"];
//hint format ["Target: %1\nTurretPath: %2\nNumMagazines: %3\nMagazine: %4\nNumRounds: %5", _target, _turretPath, _numMagazines, _magazineClass, _numRounds];
if (local _unit) then {
[_unit, true, true] call FUNC(dropAmmo);
};
if (isServer) then {
_turretOwnerID = _target turretOwner _turretPath;
if (_turretOwnerID == 0) then {
[_this, QFUNC(rearmSuccessLocal), _target] call EFUNC(common,execRemoteFnc);
} else {
EGVAR(common,remoteFnc) = [_this, QFUNC(rearmSuccessLocal), 0];
_turretOwnerID publicVariableClient QEGVAR(common,remoteFnc);
};
} else {
[_this, QFUNC(rearmSuccess), 1] call EFUNC(common,execRemoteFnc);
};

View File

@ -0,0 +1,82 @@
/*
* Author: GitHawk
* Rearms a vehicle on the turret owner.
*
* Arguments:
* 0: Params <ARRAY>
* 0: Target <OBJECT>
* 1: Unit <OBJECT>
* 2: Turret Path <ARRAY>
* 3: Number of magazines <NUMBER>
* 4: Magazine Classname <STRING>
* 5: Number of rounds <NUMBER>
*
* Return Value:
* None
*
* Example:
* [[vehicle, player, [-1], 2, "5000Rnd_762x51_Belt", 500]] call ace_rearm_fnc_rearmSuccess
*
* Public: No
*/
#include "script_component.hpp"
private ["_rounds", "_currentRounds", "_maxMagazines", "_dummy", "_weaponSelect"];
params ["_args"];
_args params ["_target", "_unit", "_turretPath", "_numMagazines", "_magazineClass", "_numRounds"];
//hint format ["Target: %1\nTurretPath: %2\nNumMagazines: %3\nMagazine: %4\nNumRounds: %5\nUnit: %6", _target, _turretPath, _numMagazines, _magazineClass, _numRounds, _unit];
_rounds = getNumber (configFile >> "CfgMagazines" >> _magazineClass >> "count");
_currentRounds = 0;
_maxMagazines = [_target, _turretPath, _magazineClass] call FUNC(getMaxMagazines);
if (_maxMagazines == 1) then {
if (GVAR(level) == 1) then {
// Fill magazine completely
_target setMagazineTurretAmmo [_magazineClass, _rounds, _turretPath];
["displayTextStructured", [_unit], [[LSTRING(Hint_RearmedTriple), _rounds,
getText(configFile >> "CfgMagazines" >> _magazineClass >> "displayName"),
getText(configFile >> "CfgVehicles" >> (typeOf _target) >> "displayName")], 3, _unit]] call EFUNC(common,targetEvent);
} else {
// Fill only at most _numRounds
_target setMagazineTurretAmmo [_magazineClass, ((_target magazineTurretAmmo [_magazineClass, _turretPath]) + _numRounds) min _rounds, _turretPath];
["displayTextStructured", [_unit], [[LSTRING(Hint_RearmedTriple), _numRounds,
getText(configFile >> "CfgMagazines" >> _magazineClass >> "displayName"),
getText(configFile >> "CfgVehicles" >> (typeOf _target) >> "displayName")], 3, _unit]] call EFUNC(common,targetEvent);
};
} else {
for "_idx" from 1 to _maxMagazines do {
_currentRounds = _target magazineTurretAmmo [_magazineClass, _turretPath];
if (_currentRounds > 0) exitWith {
if (GVAR(level) == 2) then {
//hint format ["Target: %1\nTurretPath: %2\nNumMagazines: %3\nMaxMagazines %4\nMagazine: %5\nNumRounds: %6\nMagazine: %7", _target, _turretPath, _numMagazines, _maxMagazines, _currentRounds, _numRounds, _magazineClass];
// Fill only at most _numRounds
if ((_currentRounds + _numRounds) > _rounds) then {
_target setMagazineTurretAmmo [_magazineClass, _rounds, _turretPath];
if (_numMagazines < _maxMagazines) then {
_target addMagazineTurret [_magazineClass, _turretPath];
_target setMagazineTurretAmmo [_magazineClass, _currentRounds + _numRounds - _rounds, _turretPath];
};
} else {
_target setMagazineTurretAmmo [_magazineClass, _currentRounds + _numRounds, _turretPath];
};
["displayTextStructured", [_unit], [[LSTRING(Hint_RearmedTriple), _numRounds,
getText(configFile >> "CfgMagazines" >> _magazineClass >> "displayName"),
getText(configFile >> "CfgVehicles" >> (typeOf _target) >> "displayName")], 3, _unit]] call EFUNC(common,targetEvent);
} else {
// Fill current magazine completely and fill next magazine partially
_target setMagazineTurretAmmo [_magazineClass, _rounds, _turretPath];
if (_numMagazines < _maxMagazines) then {
_target addMagazineTurret [_magazineClass, _turretPath];
_target setMagazineTurretAmmo [_magazineClass, _currentRounds, _turretPath];
};
["displayTextStructured", [_unit], [[LSTRING(Hint_RearmedTriple), _rounds,
getText(configFile >> "CfgMagazines" >> _magazineClass >> "displayName"),
getText(configFile >> "CfgVehicles" >> (typeOf _target) >> "displayName")], 3, _unit]] call EFUNC(common,targetEvent);
};
};
_target removeMagazineTurret [_magazineClass, _turretPath];
_numMagazines = _numMagazines - 1;
};
};

View File

@ -0,0 +1,34 @@
/*
* Author: GitHawk
* Stores ammo in an ammo truck.
*
* Arguments:
* 0: Target <OBJECT>
* 1: Unit <OBJECT>
*
* Return Value:
* None
*
* Example:
* [player, dummy] call ace_rearm_fnc_storeAmmo
*
* Public: No
*/
#include "script_component.hpp"
private "_dummy";
params ["_target", "_unit"];
_dummy = _unit getVariable [QGVAR(dummy), objNull];
if (isNull _dummy) exitwith {};
[
5,
_unit,
{params ["_unit"]; [_unit, true, true] call FUNC(dropAmmo)},
"",
format [localize LSTRING(StoreAmmoAction), getText(configFile >> "CfgMagazines" >> (_dummy getVariable QGVAR(magazineClass)) >> "displayName"), getText(configFile >> "CfgVehicles" >> (typeOf _target) >> "displayName")],
{true},
["isnotinside"]
] call EFUNC(common,progressBar);

View File

@ -0,0 +1,61 @@
/*
* Author: GitHawk
* Starts progress bar for picking up a specific kind of magazine from an ammo truck.
*
* Arguments:
* 0: Ammo Truck <OBJECT>
* 1: Unit <OBJECT>
* 2: Params <ARRAY>
* 0: Magazine Classname <STRING>
* 1: Vehicle to be armed <OBJECT>
*
* Return Value:
* None
*
* Example:
* [ammo_truck, player, ["500Rnd_127x99_mag_Tracer_Red", tank]] call ace_rearm_fnc_takeAmmo
*
* Public: No
*/
#include "script_component.hpp"
private ["_ammo", "_tmpCal", "_cal", "_idx"];
params ["_target", "_unit", "_args"];
_args params ["_magazineClass", "_vehicle"];
_ammo = getText (configFile >> "CfgMagazines" >> _magazineClass >> "ammo");
_tmpCal = getNumber (configFile >> "CfgAmmo" >> _ammo >> "ace_caliber");
_cal = 8;
if (_tmpCal > 0) then {
_cal = _tmpCal;
} else {
_tmpCal = getNumber (configFile >> "CfgAmmo" >> _ammo >> QGVAR(caliber));
if (_tmpCal > 0) then {
_cal = _tmpCal;
} else {
diag_log format ["[ACE] ERROR: Undefined Ammo [%1 : %2]", _ammo, inheritsFrom (configFile >> "CfgAmmo" >> _ammo)];
if (_ammo isKindOf "BulletBase") then {
_cal = 8;
} else {
_cal = 100;
};
};
};
_cal = round _cal;
_idx = REARM_CALIBERS find _cal;
if (_idx == -1 ) then {
_idx = 2;
};
REARM_HOLSTER_WEAPON
[
(REARM_DURATION_TAKE select _idx),
[_unit, _magazineClass, _target],
FUNC(takeSuccess),
"",
format [localize LSTRING(TakeAction), getText(configFile >> "CfgMagazines" >> _magazineClass >> "displayName"), getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName")],
{true},
["isnotinside"]
] call EFUNC(common,progressBar);

View File

@ -0,0 +1,39 @@
/*
* Author: GitHawk
* Takes a magazine from an ammo truck.
*
* Arguments:
* 0: Params <ARRAY>
* 0: Unit <OBJECT>
* 1: Magazine Classname <STRING>
* 2: Ammo Truck <OBJECT>
*
* Return Value:
* None
*
* Example:
* [[player, "500Rnd_127x99_mag_Tracer_Red"]] call ace_rearm_fnc_takeSuccess
*
* Public: No
*/
#include "script_component.hpp"
private ["_ammo", "_dummyName", "_dummy", "_actionID"];
params ["_args"];
_args params ["_unit", "_magazineClass", "_target"]; // _target is for future possible finite ammo
[_unit, QGVAR(vehRearm), true] call EFUNC(common,setForceWalkStatus);
_dummy = [_unit, _magazineClass] call FUNC(createDummy);
[_dummy, _unit] call FUNC(pickUpAmmo);
_actionID = _unit addAction [
format ["<t color='#FF0000'>%1</t>", localize ELSTRING(dragging,Drop)],
'(_this select 0) call FUNC(dropAmmo)',
nil,
20,
false,
true,
"",
'!isNull (_target getVariable [QGVAR(dummy), objNull])'
];
_unit setVariable [QGVAR(ReleaseActionID), _actionID];

View File

@ -0,0 +1 @@
#include "\z\ace\addons\rearm\script_component.hpp"

View File

@ -0,0 +1,31 @@
#define COMPONENT rearm
#include "\z\ace\addons\main\script_mod.hpp"
#ifdef DEBUG_ENABLED_REARM
#define DEBUG_MODE_FULL
#endif
#ifdef DEBUG_SETTINGS_REARM
#define DEBUG_SETTINGS DEBUG_SETTINGS_REARM
#endif
#include "\z\ace\addons\main\script_macros.hpp"
#define REARM_ACTION_DISTANCE 7
#define REARM_TURRET_PATHS [[-1], [0], [0,0], [0,1], [1], [2], [0,2]]
#define REARM_CALIBERS [ 6, 7, 8, 13, 19, 20, 25, 30, 35, 39, 40, 60, 70, 80, 82, 100, 105, 120, 122, 125, 155, 230, 250]
#define REARM_DURATION_TAKE [ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 3, 3, 3, 3, 3, 4, 5, 5, 5, 5, 13, 10]
#define REARM_DURATION_REARM [ 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 7, 7, 7, 7, 7, 8, 10, 10, 10, 10, 27, 20]
#define REARM_COUNT [500, 500, 400, 100, 50, 50, 40, 25, 34, 24, 10, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1]
#define REARM_HOLSTER_WEAPON \
_unit setVariable [QGVAR(selectedWeaponOnRearm), currentWeapon _unit]; \
_unit action ["SwitchWeapon", _unit, _unit, 99];
#define REARM_UNHOLSTER_WEAPON \
_weaponSelect = _unit getVariable QGVAR(selectedWeaponOnRearm); \
_unit selectWeapon _weaponSelect; \
_unit setVariable [QGVAR(selectedWeaponOnRefuel), nil];

View File

@ -0,0 +1,144 @@
<?xml version="1.0" encoding="utf-8"?>
<Project name="ACE">
<Package name="Rearm">
<Key ID="STR_ACE_Rearm_RearmSettings_Module_DisplayName">
<English>Rearm Settings</English>
<German>Aufmunitioniereinstellungen</German>
</Key>
<Key ID="STR_ACE_Rearm_RearmSettings_Module_Description">
<English>This module allows you to tweak repair system settings.</English>
</Key>
<Key ID="STR_ACE_Rearm_RearmSettings_level_DisplayName">
<English>Rearm Amount</English>
<German>Aufmunitioniermenge</German>
</Key>
<Key ID="STR_ACE_Rearm_RearmSettings_level_Description">
<English>How fast should a vehicle be rearmed?</English>
<German>Wie schnell soll ein Fahrzeug aufmunitioniert werden?</German>
</Key>
<Key ID="STR_ACE_Rearm_RearmSettings_vehicle">
<English>Entire Vehicle</English>
<German>Gesamtes Fahrzeug</German>
</Key>
<Key ID="STR_ACE_Rearm_RearmSettings_magazine">
<English>Entire Magazine</English>
<German>Gesamtes Magazin</German>
</Key>
<Key ID="STR_ACE_Rearm_RearmSettings_caliber">
<English>Amount based on caliber</English>
<German>Kaliberbasierte Anzahl</German>
</Key>
<Key ID="STR_ACE_Rearm_Rearm">
<English>Rearm</English>
<German>Aufmunitionieren</German>
</Key>
<Key ID="STR_ACE_Rearm_RearmAction">
<English>Rearming %1 with %2 ...</English>
<German>Munitioniere %1 auf mit %2 ...</German>
</Key>
<Key ID="STR_ACE_Rearm_BasicRearmAction">
<English>Rearming %1 ...</English>
<German>Munitioniere %1 auf ...</German>
</Key>
<Key ID="STR_ACE_Rearm_TakeAction">
<English>Taking %1 for %2 ...</English>
<German>Nehme %1 für %2 ...</German>
</Key>
<Key ID="STR_ACE_Rearm_TakeAmmo">
<English>Take ammo</English>
<German>Munition nehmen</German>
</Key>
<Key ID="STR_ACE_Rearm_PickUpAmmo">
<English>Pick up ammo</English>
<German>Munition aufnehmen</German>
</Key>
<Key ID="STR_ACE_Rearm_StoreAmmo">
<English>Store ammo</English>
<German>Munition verstauen</German>
</Key>
<Key ID="STR_ACE_Rearm_StoreAmmoAction">
<English>Storing %1 in %2 ...</English>
<German>Verstaue %1 in %2 ...</German>
</Key>
<Key ID="STR_ACE_Rearm_GrabAction">
<English>Picking up ammo ...</English>
<German>Nehme Munition ...</German>
</Key>
<Key ID="STR_ACE_Rearm_Hint_RearmedTriple">
<English>Rearmed %1 rounds of %2 on %3</English>
<German>%1 Schuss %2 an %3 aufmunitioniert</German>
</Key>
<Key ID="STR_ACE_Rearm_Mag_SmokeLauncherMag">
<Original>Smoke Screen</Original>
<English>Smoke Screen</English>
<Czech>Kouřová clona</Czech>
<French>Écran de fumée</French>
<German>Rauchwand</German>
<Italian>Cortina fumogena</Italian>
<Polish>Zasłona dymna</Polish>
<Portuguese>Cortina de fumaça</Portuguese>
<Russian>Дым. завеса</Russian>
<Spanish>Pantalla de humo</Spanish>
</Key>
<Key ID="STR_ACE_Rearm_Mag_60Rnd_CMFlareMagazine">
<Original>Flares</Original>
<English>Flares</English>
<Czech>Světlice</Czech>
<French>Fusées</French>
<German>Leuchtkörper</German>
<Italian>Razzi luminosi</Italian>
<Polish>Flary</Polish>
<Portuguese>Sinalizadores</Portuguese>
<Russian>ЛТЦ</Russian>
<Spanish>Bengalas</Spanish>
</Key>
<Key ID="STR_ACE_Rearm_Mag_1000Rnd_Gatling_30mm_Plane_CAS_01_F">
<English>30mm HEI</English>
<German>30mm HEI</German>
</Key>
<Key ID="STR_ACE_Rearm_Mag_500Rnd_Cannon_30mm_Plane_CAS_02_F">
<English>30mm HEI-T</English>
<German>30mm HEI-T</German>
</Key>
<Key ID="STR_ACE_Rearm_Mag_2Rnd_Missile_AA_04_F">
<English>AIM-9 Sidewinder</English>
<German>AIM-9 Sidewinder</German>
</Key>
<Key ID="STR_ACE_Rearm_Mag_2Rnd_Missile_AA_03_F">
<English>Wympel R-73</English>
<German>Wympel R-73</German>
</Key>
<Key ID="STR_ACE_Rearm_Mag_6Rnd_Missile_AGM_02_F">
<English>AGM-65 Maverick</English>
<German>AGM-65 Maverick</German>
</Key>
<Key ID="STR_ACE_Rearm_Mag_4Rnd_Missile_AGM_01_F">
<English>Kh-25MTP</English>
<German>Kh-25MTP</German>
</Key>
<Key ID="STR_ACE_Rearm_Mag_7Rnd_Rocket_04_HE_F">
<English>Hydra 70 HE</English>
<German>Hydra 70 HE</German>
</Key>
<Key ID="STR_ACE_Rearm_Mag_20Rnd_Rocket_03_HE_F">
<English>S-8 HE</English>
<German>S-8 HE</German>
</Key>
<Key ID="STR_ACE_Rearm_Mag_7Rnd_Rocket_04_AP_F">
<English>Hydra 70 AP</English>
<German>Hydra 70 AP</German>
</Key>
<Key ID="STR_ACE_Rearm_Mag_20Rnd_Rocket_03_AP_F">
<English>S-8 AP</English>
<German>S-8 AP</German>
</Key>
<Key ID="STR_ACE_Rearm_Mag_4Rnd_Bomb_04_F">
<English>GBU-12</English>
<German>GBU-12</German>
</Key>
<Key ID="STR_ACE_Rearm_Mag_2Rnd_Bomb_03_F">
<English>FAB-250M-54</English>
<German>FAB-250M-54</German>
</Key>
</Package>
</Project>

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@ -122,4 +122,8 @@ class CfgAmmo
ACE_muzzleVelocities[]={298, 330, 350};
ACE_barrelLengths[]={96.52, 127.0, 228.6};
};
};
class SubmunitionBase;
class rhs_ammo_127x108mm_x5: SubmunitionBase {
ACE_rearm_caliber=13;
}
};