Cleaned, improved, fixed, changed - entire rearm

This commit is contained in:
jonpas 2015-08-18 02:32:10 +02:00
parent 0fcf692d36
commit c8c6488125
25 changed files with 457 additions and 508 deletions

View File

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

View File

@ -1,5 +1,5 @@
class CfgAmmo {
class BombCore;
class BombBase : BombCore {
GVAR(caliber) = 250; // Default caliber for bombs
@ -17,7 +17,7 @@ class CfgAmmo {
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);
@ -60,170 +60,170 @@ class CfgAmmo {
class R_Hydra_HE : RocketBase {
GVAR(dummy) = QGVAR(R_Hydra_HE);
};
class BulletBase;
class B_19mm_HE : BulletBase {
GVAR(caliber) = 19;
GVAR(caliber) = 19;
};
class B_20mm : BulletBase {
GVAR(caliber) = 20;
GVAR(caliber) = 20;
};
class B_25mm : BulletBase {
GVAR(caliber) = 25;
GVAR(caliber) = 25;
};
class B_30mm_AP : BulletBase {
GVAR(caliber) = 30;
GVAR(caliber) = 30;
};
class B_30mm_HE : B_19mm_HE {
GVAR(caliber) = 30;
GVAR(caliber) = 30;
};
class Gatling_30mm_HE_Plane_CAS_01_F : BulletBase {
GVAR(caliber) = 30;
GVAR(caliber) = 30;
};
class B_35mm_AA : BulletBase {
GVAR(caliber) = 35;
GVAR(caliber) = 35;
};
class B_30mm_APFSDS;
class B_40mm_APFSDS : B_30mm_APFSDS {
GVAR(caliber) = 40;
GVAR(caliber) = 40;
};
class B_40mm_GPR : B_30mm_HE {
GVAR(caliber) = 40;
GVAR(caliber) = 40;
};
class GrenadeBase;
class G_40mm_HE : GrenadeBase {
GVAR(caliber) = 40;
GVAR(caliber) = 40;
};
class RDS_B_127x107_Ball : BulletBase {
GVAR(caliber) = 12.7;
GVAR(caliber) = 12.7;
};
class ShellBase;
class R_230mm_fly : ShellBase {
GVAR(dummy) = QGVAR(R_230mm_fly);
};
class Sh_120mm_APFSDS : Shellbase {
GVAR(caliber) = 120;
GVAR(caliber) = 120;
};
class Sh_105mm_APFSDS : Sh_120mm_APFSDS {
GVAR(caliber) = 105;
GVAR(caliber) = 105;
};
class Sh_125mm_APFSDS : Sh_120mm_APFSDS {
GVAR(caliber) = 125;
GVAR(caliber) = 125;
};
class Sh_120mm_HE : ShellBase {
GVAR(caliber) = 120;
GVAR(caliber) = 120;
};
class Sh_125mm_HE : Sh_120mm_HE {
GVAR(caliber) = 125;
GVAR(caliber) = 125;
};
class Sh_125mm_HEAT : Sh_125mm_HE {
GVAR(caliber) = 125;
GVAR(caliber) = 125;
};
class Sh_105mm_HEAT_MP : Sh_125mm_HEAT {
GVAR(caliber) = 105;
GVAR(caliber) = 105;
};
class Sh_155mm_AMOS : ShellBase {
GVAR(caliber) = 155;
GVAR(caliber) = 155;
};
class Sh_82mm_AMOS : Sh_155mm_AMOS {
GVAR(caliber) = 82;
GVAR(caliber) = 82;
};
class RDS_Sh_122_HE : Sh_155mm_AMOS {
GVAR(caliber) = 122;
GVAR(caliber) = 122;
};
class RDS_Sh_105_HE : Sh_155mm_AMOS {
GVAR(caliber) = 105;
GVAR(caliber) = 105;
};
class Sh_82mm_AMOS_LG;
class Sh_155mm_AMOS_LG : Sh_82mm_AMOS_LG {
GVAR(caliber) = 155;
GVAR(caliber) = 155;
};
class RDS_Sh_122_LASER : Sh_155mm_AMOS_LG {
GVAR(caliber) = 122;
GVAR(caliber) = 122;
};
class RDS_Sh_105_LASER : Sh_155mm_AMOS_LG {
GVAR(caliber) = 105;
GVAR(caliber) = 105;
};
class ShotDeployBase;
class Smoke_82mm_AMOS_White : ShotDeployBase {
GVAR(caliber) = 82;
GVAR(caliber) = 82;
};
class FlareCore;
class Flare_82mm_AMOS_White : FlareCore {
GVAR(caliber) = 82;
GVAR(caliber) = 82;
};
class SmokeLauncherAmmo : BulletBase {
GVAR(caliber) = 250;
GVAR(caliber) = 250;
};
class CMflareAmmo : BulletBase {
GVAR(caliber) = 40;
};
class SubmunitionBase;
class Sh_82mm_AMOS_guided : SubmunitionBase {
GVAR(caliber) = 82;
GVAR(caliber) = 82;
};
class Sh_155mm_AMOS_guided : Sh_82mm_AMOS_guided {
GVAR(caliber) = 155;
GVAR(caliber) = 155;
};
class R_230mm_HE : SubmunitionBase {
GVAR(caliber) = 230;
GVAR(caliber) = 230;
};
class rhs_ammo_127x108mm_x5 : SubmunitionBase {
GVAR(caliber) = 12.7;
GVAR(caliber) = 12.7;
};
class Mine_155mm_AMOS_range : SubmunitionBase {
GVAR(caliber) = 155;
GVAR(caliber) = 155;
};
class Cluster_155mm_AMOS : SubmunitionBase {
GVAR(caliber) = 155;
GVAR(caliber) = 155;
};
class Smoke_120mm_AMOS_White : SubmunitionBase {
GVAR(caliber) = 155;
GVAR(caliber) = 155;
};
class AT_Mine_155mm_AMOS_range : SubmunitionBase {
GVAR(caliber) = 155;
GVAR(caliber) = 155;
};
class rhs_ammo_rpgShell_base : ShellBase {
GVAR(caliber) = 70;
GVAR(caliber) = 70;
};
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);
};
// F18 Mod
class js_a_fa18_wing_tank : LaserBombCore {
GVAR(caliber) = 250; // Default caliber for bombs
@ -232,7 +232,7 @@ class CfgAmmo {
class js_a_fa18x_GBU39_SDB : js_a_fa18x_MK82 {
GVAR(caliber) = 250; // Default caliber for bombs
};
class js_a_fa18_GBU12_LGB : LaserBombCore {};
class js_a_fa18_GBU38_JDAM : js_a_fa18_GBU12_LGB {
GVAR(caliber) = 250; // Default caliber for bombs

View File

@ -16,4 +16,12 @@ class Extended_Respawn_EventHandlers {
respawn = QUOTE(call COMPILE_FILE(XEH_respawn));
};
};
};
};
class Extended_Killed_EventHandlers {
class CAManBase {
class ADDON {
killed = QUOTE(_this call FUNC(handleKilled));
};
};
};

View File

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

View File

@ -1,13 +1,8 @@
#define REARM_ACTION_DISTANCE 4.5
#define MACRO_REARM_ACTIONS \
class ACE_Actions { \
class ACE_MainActions { \
displayName = ECSTRING(interaction,MainAction); \
selection = ""; \
distance = 10; \
condition = "true"; \
class GVAR(rearm) { \
displayName = CSTRING(rearm); \
class GVAR(Rearm) { \
displayName = CSTRING(Rearm); \
distance = REARM_ACTION_DISTANCE; \
condition = QUOTE([ARR_2(_player,_target)] call FUNC(canRearm)); \
statement = QUOTE([ARR_2(_player,_target)] call FUNC(rearm)); \
@ -15,23 +10,23 @@
icon = PATHTOF(ui\icon_rearm_interact.paa); \
}; \
}; \
};
};
#define MACRO_REARM_PICKUPAMMO \
class ACE_Actions : ACE_Actions { \
class ACE_MainActions : ACE_MainActions { \
class GVAR(pickUpAmmo) { \
displayName = CSTRING(pickUpAmmo); \
class GVAR(PickUpAmmo) { \
displayName = CSTRING(PickUpAmmo); \
distance = REARM_ACTION_DISTANCE; \
condition = QUOTE([ARR_2(_player,_target)] call FUNC(canPickUpAmmo)); \
insertChildren = QUOTE([ARR_1(_target)] call DFUNC(addRearmActions)); \
insertChildren = QUOTE([_target] call FUNC(addRearmActions)); \
exceptions[] = {"isNotInside"}; \
icon = PATHTOF(ui\icon_rearm_interact.paa); \
}; \
}; \
};
#define DUMMY_PROPERTIES \
#define MACRO_DUMMY_PROPERTIES \
displayName = QGVAR(dummy_obj); \
scope = 2; \
scopeCurator = 2;
@ -43,7 +38,7 @@ class CfgVehicles {
displayName = CSTRING(RearmSettings_Module_DisplayName);
icon = QUOTE(PATHTOF(ui\icon_module_rearm.paa));
category = "ACE";
function = QUOTE(DFUNC(moduleRearmSettings));
function = QFUNC(moduleRearmSettings);
functionPriority = 1;
isGlobal = 0;
isTriggerActivated = 0;
@ -70,6 +65,9 @@ class CfgVehicles {
};
};
};
class ModuleDescription {
description = CSTRING(RearmSettings_Module_Description);
};
};
class LandVehicle;
@ -80,7 +78,7 @@ class CfgVehicles {
class Tank : LandVehicle {
MACRO_REARM_ACTIONS
};
class StaticWeapon : LandVehicle {
MACRO_REARM_ACTIONS
};
@ -99,125 +97,110 @@ class CfgVehicles {
MACRO_REARM_ACTIONS
};
// Ammo Vehicles (with full inheritance for granted ACE_Actions)
class Car_F : Car {};
class Truck_F : Car_F {};
class Truck_01_base_F: Truck_F {};
class Truck_02_base_F : Truck_F {};
class Truck_03_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 I_Truck_02_ammo_F : Truck_02_base_F {
transportAmmo = 0;
MACRO_REARM_PICKUPAMMO
};
class B_Truck_01_ammo_F : B_Truck_01_mover_F {
transportAmmo = 0;
MACRO_REARM_PICKUPAMMO
};
class O_Truck_02_Ammo_F : Truck_02_base_F {
transportAmmo = 0;
MACRO_REARM_PICKUPAMMO
};
class O_Truck_03_ammo_F : Truck_03_base_F {
transportAmmo = 0;
MACRO_REARM_PICKUPAMMO
};
// Dummy vehicles
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_PICKUPAMMO
};
class O_Truck_02_Ammo_F : Truck_02_Ammo_base_F {
transportAmmo = 0;
MACRO_REARM_PICKUPAMMO
};
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_PICKUPAMMO
};
// Dummy Vehicles
class ThingX;
class GVAR(Bo_GBU12_LGB) : ThingX {
DUMMY_PROPERTIES
MACRO_DUMMY_PROPERTIES
model = "\A3\Weapons_F\Ammo\Bomb_01_F.p3d";
};
class GVAR(Bo_Mk82) : ThingX {
DUMMY_PROPERTIES
MACRO_DUMMY_PROPERTIES
model = "\A3\Weapons_F\Ammo\Bomb_02_F";
};
class GVAR(Bomb_04_F) : ThingX {
DUMMY_PROPERTIES
MACRO_DUMMY_PROPERTIES
model = "\A3\Weapons_F_EPC\Ammo\Bomb_04_F.p3d";
};
class GVAR(Bomb_03_F) : ThingX {
DUMMY_PROPERTIES
MACRO_DUMMY_PROPERTIES
model = "\A3\Weapons_F_EPC\Ammo\Bomb_03_F.p3d";
};
class GVAR(Missile_AA_04_F) : ThingX {
DUMMY_PROPERTIES
MACRO_DUMMY_PROPERTIES
model = "\A3\Weapons_F_EPC\Ammo\Missile_AA_04_F.p3d";
};
class GVAR(Missile_AA_03_F) : ThingX {
DUMMY_PROPERTIES
MACRO_DUMMY_PROPERTIES
model = "\A3\Weapons_F_EPC\Ammo\Missile_AA_03_F.p3d";
};
class GVAR(Missile_AGM_02_F) : ThingX {
DUMMY_PROPERTIES
MACRO_DUMMY_PROPERTIES
model = "\A3\Weapons_F_EPC\Ammo\Missile_AGM_02_F.p3d";
};
class GVAR(Missile_AGM_01_F) : ThingX {
DUMMY_PROPERTIES
MACRO_DUMMY_PROPERTIES
model = "\A3\Weapons_F_EPC\Ammo\Missile_AGM_01_F.p3d";
};
class GVAR(R_230mm_fly) : ThingX {
DUMMY_PROPERTIES
MACRO_DUMMY_PROPERTIES
model = "\A3\Weapons_F\Ammo\Missile_AT_02_F";
};
class GVAR(R_230mm_HE) : ThingX {
DUMMY_PROPERTIES
MACRO_DUMMY_PROPERTIES
model = "\A3\Weapons_F\Ammo\Missile_AT_02_F";
};
class GVAR(M_PG_AT) : ThingX {
DUMMY_PROPERTIES
MACRO_DUMMY_PROPERTIES
model = "\A3\Weapons_F\Ammo\Rocket_01_F";
};
class GVAR(Rocket_04_HE_F) : ThingX {
DUMMY_PROPERTIES
MACRO_DUMMY_PROPERTIES
model = "\A3\Weapons_F_EPC\Ammo\Rocket_04_HE_F.p3d";
};
class GVAR(Rocket_03_HE_F) : ThingX {
DUMMY_PROPERTIES
MACRO_DUMMY_PROPERTIES
model = "\A3\Weapons_F_EPC\Ammo\Rocket_03_HE_F.p3d";
};
class GVAR(Rocket_04_AP_F) : ThingX {
DUMMY_PROPERTIES
MACRO_DUMMY_PROPERTIES
model = "\A3\Weapons_F_EPC\Ammo\Rocket_04_AP_F.p3d";
};
class GVAR(Rocket_03_AP_F) : ThingX {
DUMMY_PROPERTIES
MACRO_DUMMY_PROPERTIES
model = "\A3\Weapons_F_EPC\Ammo\Rocket_03_AP_F.p3d";
};
// Using wrong model
class GVAR(R_80mm_HE) : ThingX {
DUMMY_PROPERTIES
MACRO_DUMMY_PROPERTIES
model = "\A3\Weapons_F_EPC\Ammo\Rocket_03_HE_F.p3d";
};
class GVAR(R_60mm_HE) : ThingX {
DUMMY_PROPERTIES
MACRO_DUMMY_PROPERTIES
model = "\A3\Weapons_F_EPC\Ammo\Rocket_03_HE_F.p3d";
};
class GVAR(R_Hydra_HE) : ThingX {
DUMMY_PROPERTIES
MACRO_DUMMY_PROPERTIES
model = "\A3\Weapons_F_EPC\Ammo\Rocket_03_HE_F.p3d";
};
};

View File

@ -1,27 +1,3 @@
#include "script_component.hpp"
["medical_onUnconscious", {
if (local (_this select 0)) then {
private ["_unit", "_dummy"];
_unit = _this select 0;
if (_this select 1) then {
_dummy = _unit getVariable [QGVAR(dummy), objNull];
if !(isNull _dummy) then {
detach _dummy;
deleteVehicle _dummy; // TODO remove when moved to CfgVehicles
};
_unit setVariable [QGVAR(dummy), nil];
};
};
}] call EFUNC(common,addEventHandler);
["medical_onSetDead", {
if (local (_this select 0)) then {
private ["_unit"];
_unit = _this select 0;
if (_this select 1) then {
_unit setVariable [QGVAR(selectedWeaponOnRearm), nil];
_unit setVariable [QGVAR(carriedMagazine), nil];
};
};
}] call EFUNC(common,addEventHandler);
["medical_onUnconscious", {_this call FUNC(handleOnUnconscious)}] call EFUNC(common,addEventHandler);

View File

@ -3,16 +3,19 @@
ADDON = false;
PREP(addRearmActions);
PREP(canRearm);
PREP(canPickupAmmo);
PREP(canRearm);
PREP(getMaxMagazines);
PREP(getNeedRearmMagazines);
PREP(handleKilled);
PREP(handleUnconscious);
PREP(moduleRearmSettings);
PREP(pickUpAmmo);
PREP(pickUpSuccess);
PREP(rearm);
PREP(rearmEntireVehicle);
PREP(rearmEntireVehicleSuccess);
PREP(rearmSuccess);
PREP(moduleRearmSettings);
PREP(turn);
ADDON = true;

View File

@ -7,13 +7,14 @@ class CfgPatches {
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_interaction"};
author[] = {"GitHawk"};
authorUrl = "";
authorUrl = "https://ace3mod.com";
VERSION_CONFIG;
};
};
#include "ACE_Settings.hpp"
#include "CfgEventHandlers.hpp"
#include "CfgVehicles.hpp"
#include "CfgMagazines.hpp"
#include "CfgAmmo.hpp"
#include "ACE_Settings.hpp"
#include "CfgMagazines.hpp"
#include "CfgVehicles.hpp"

View File

@ -1,7 +1,6 @@
/*
* Author: GitHawk
* Show the resupplyable ammunition of all surrounding vehicles.
* Called from "insertChildren" on interact_menu
*
* Argument:
* 0: Target <OBJECT>
@ -16,11 +15,11 @@
*/
#include "script_component.hpp"
private ["_vehicleActions", "_actions", "_action", "_vehicles", "_vehicle", "_needToAdd", "_magazineHelper", "_turretPath", "_magazines", "_magazine", "_icon"];
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}; // Logistics needs at least 2 vehicles
if (count _vehicles < 2) exitWith {false}; // Rearming needs at least 2 vehicles
_vehicleActions = [];
{
@ -37,32 +36,32 @@ _vehicleActions = [];
_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(pickUpAmmo)},
{true},
{},
_action = [_magazine,
getText(configFile >> "CfgMagazines" >> _magazine >> "displayName"),
getText(configFile >> "CfgMagazines" >> _magazine >> "picture"),
{_this call FUNC(pickUpAmmo)},
{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(pickUpAmmo)},
{true},
{},
_action = [_magazine,
getText(configFile >> "CfgMagazines" >> _magazine >> "displayName"),
getText(configFile >> "CfgMagazines" >> _magazine >> "picture"),
{_this call FUNC(pickUpAmmo)},
{true},
{},
[_magazine, _vehicle]] call EFUNC(interact_menu,createAction);
_actions pushBack [_action, [], _target];
_magazineHelper pushBack _magazine;
_needToAdd = true;
};
};
} foreach _magazines;
} foreach [[0], [-1], [0,0], [0,1], [1], [2]];
} forEach _magazines;
} forEach REARM_TURRET_PATHS;
};
if (_needToAdd) then {
_icon = getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "Icon");
@ -70,26 +69,25 @@ _vehicleActions = [];
_icon = "";
};
if (GVAR(level) == 0) then {
_action = [_vehicle,
getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName"),
_icon,
{_this call FUNC(rearmEntireVehicle)},
{true},
{},
_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},
{},
_action = [_vehicle,
getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName"),
_icon,
{},
{true},
{},
[]] call EFUNC(interact_menu,createAction);
_vehicleActions pushBack [_action, _actions, _target];
};
};
} foreach _vehicles;
} forEach _vehicles;
_vehicleActions

View File

@ -1,13 +1,13 @@
/*
* Author: GitHawk
* Check if a unit can pick up ammo
* Check if a unit can pick up ammo.
*
* Arguments:
* 0: The Player <OBJECT>
* 1: The Target <OBJECT>
* 0: Unit <OBJECT>
* 1: Target <OBJECT>
*
* Return Value:
* Can rearm
* Can Pick Up Ammo <BOOL>
*
* Example:
* [player, tank] call ace_rearm_fnc_canPickUpAmmo
@ -18,4 +18,4 @@
params ["_unit", "_target"];
!(isNull _unit || {!(_unit isKindOf "CAManBase")} || {!local _unit} || { (_target distance _unit) > 7})
!(isNull _unit || {!(_unit isKindOf "CAManBase")} || {!local _unit} || {(_target distance _unit) > REARM_ACTION_DISTANCE})

View File

@ -1,13 +1,13 @@
/*
* Author: GitHawk
* Check if a unit can rearm
* Author: GitHawk, Jonpas
* Check if a unit can rearm.
*
* Arguments:
* 0: The unit <OBJECT>
* 1: The target <OBJECT>
* 0: Unit <OBJECT>
* 1: Target <OBJECT>
*
* Return Value:
* Can rearm <BOOL>
* Can Rearm <BOOL>
*
* Example:
* [player, tank] call ace_rearm_fnc_canRearm
@ -16,64 +16,12 @@
*/
#include "script_component.hpp"
private ["_magazine", "_return", "_magazines", "_path", "_cnt"];
params ["_unit", "_vehicle"];
private ["_magazineClass", "_magazines", "_turretPath"];
params ["_unit", "_target"];
#define GETRETURNVALUE \
if ((_vehicle magazineTurretAmmo [_magazine, _path]) < getNumber (configFile >> "CfgMagazines" >> _magazine >> "count")) then { \
_return = true; \
} else { \
_cnt = { _x == _magazine } count _magazines; \
if (_cnt < ([_vehicle, _path, _magazine] call FUNC(getMaxMagazines))) then { \
_return = true; \
}; \
};
if (GVAR(level) == 0 || {isNull _unit} || {!(_unit isKindOf "CAManBase")} || {!local _unit} || {_target distance _unit > REARM_ACTION_DISTANCE}) exitWith {false};
if (isNull _unit || {!(_unit isKindOf "CAManBase")} || {!local _unit} || { (_vehicle distance _unit) > 7} || {GVAR(level) == 0}) exitWith {false};
_magazineClass = _unit getVariable QGVAR(carriedMagazine);
if (isNil "_magazineClass") exitWith {false};
_magazine = _unit getVariable QGVAR(carriedMagazine);
if (isNil "_magazine") exitWith {false};
_return = false;
_magazines = _vehicle magazinesTurret [-1];
if (_magazine in _magazines) then {
_path = [-1];
GETRETURNVALUE
};
if (!_return) then {
_magazines = _vehicle magazinesTurret [0];
if (_magazine in _magazines) then {
_path = [0];
GETRETURNVALUE
};
};
if (!_return) then {
_magazines = _vehicle magazinesTurret [0,0];
if (_magazine in _magazines) then {
_path = [0,0];
GETRETURNVALUE
};
};
if (!_return) then {
_magazines = _vehicle magazinesTurret [0,1];
if (_magazine in _magazines) then {
_path = [0,1];
GETRETURNVALUE
};
};
if (!_return) then {
_magazines = _vehicle magazinesTurret [1];
if (_magazine in _magazines) then {
_path = [1];
GETRETURNVALUE
};
};
if (!_return) then {
_magazines = _vehicle magazinesTurret [2];
if (_magazine in _magazines) then {
_path = [2];
GETRETURNVALUE
};
};
_return
([_target, _magazines, _magazineClass] call FUNC(getNeedRearmMagazines)) select 0

View File

@ -1,11 +1,11 @@
/*
* Author: GitHawk
* Calculates the maximum number of magazines a turret can hold according to config
* Author: GitHawk, Jonpas
* Calculates the maximum number of magazines a turret can hold according to config.
*
* Arguments:
* 0: The Unit <OBJECT>
* 1: The Turretpath <ARRAY>
* 2: The Magazine <STRING>
* 0: Target <OBJECT>
* 1: Turret Path <ARRAY>
* 2: Magazine Classname <STRING>
*
* Return Value:
* Number of magazines on the turret path <NUMBER>
@ -21,67 +21,36 @@ private ["_count", "_cfg"];
params ["_target", "_turretPath", "_magazine"];
if (isNull _target) exitWith {0};
_count = 0;
// TODO replace by loop or method of interpreting _turretPath
_cfg = configFile >> "CfgVehicles" >> (typeOf _target) >> "Turrets";
_cfg = configFile;
switch (_turretPath) do {
case [0] : {
_cfg = configFile >> "CfgVehicles" >> (typeOf _target) >> "Turrets";
if (count _cfg > 0) then {
_cfg = _cfg select 0;
} else {
_cfg = configFile >> "CfgVehicles" >> (typeOf _target);
};
};
case [1] : {
_cfg = configFile >> "CfgVehicles" >> (typeOf _target) >> "Turrets";
if (count _cfg > 0) then {
_cfg = _cfg select 1;
} else {
_cfg = configFile >> "CfgVehicles" >> (typeOf _target);
};
};
case [2] : {
_cfg = configFile >> "CfgVehicles" >> (typeOf _target) >> "Turrets";
if (count _cfg > 0) then {
_cfg = _cfg select 2;
} else {
_cfg = configFile >> "CfgVehicles" >> (typeOf _target);
};
};
case [0,0] : {
_cfg = configFile >> "CfgVehicles" >> (typeOf _target) >> "Turrets";
if (count _cfg > 0) then {
_cfg = (_cfg select 0) >> "Turrets";
if (count _cfg > 0) then {
_cfg = _cfg select 0;
} else {
_cfg = configFile >> "CfgVehicles" >> (typeOf _target);
};
} else {
_cfg = configFile >> "CfgVehicles" >> (typeOf _target);
};
};
case [0,1] : {
if (count _cfg > 0) then {
_cfg = (_cfg select 0) >> "Turrets";
if (count _cfg > 0) then {
_cfg = _cfg select 1;
} else {
_cfg = configFile >> "CfgVehicles" >> (typeOf _target);
};
} else {
_cfg = configFile >> "CfgVehicles" >> (typeOf _target);
};
};
default {
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 {0};
_count = {_x == _magazine} count getArray (_cfg >> "magazines");
_count
_count

View File

@ -0,0 +1,43 @@
/*
* Author: GitHawk, Jonpas
* Get rearm return value.
*
* Arguments:
* 0: Target <OBJECT>
* 1: Magazines <ARRAY>
* 2: Magazine Classname <STRING>
* 3: Turret Path <ARRAY>
*
* Return Value:
* Return Value <BOOL>
*
* Example:
* [tank, ["mag1", "mag2"], "mag", [0]] call ace_rearm_fnc_getNeedRearmMagazines
*
* Public: No
*/
#include "script_component.hpp"
private ["_return", "_cnt"];
params ["_target", "_magazines", "_magazineClass"];
_return = [false];
{
_magazines = _target magazinesTurret _x;
if (_magazineClass in _magazines) then {
_cnt = {_x == _magazineClass} count _magazines;
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,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 setVariable [QGVAR(carriedMagazine), nil];

View File

@ -0,0 +1,31 @@
/*
* 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 {};
private "_dummy";
_dummy = _unit getVariable [QGVAR(dummy), objNull];
if (!isNull _dummy) then {
detach _dummy;
deleteVehicle _dummy; // TODO remove when moved to CfgVehicles
};
_unit setVariable [QGVAR(dummy), nil];

View File

@ -1,22 +1,26 @@
/*
* Author: GitHawk
* Module for adjusting the refuel settings
* Module for adjusting the refuel settings.
*
* Arguments:
* 0: The module logic <LOGIC>
* 1: units <ARRAY>
* 2: activated <BOOL>
* 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", "_units", "_activated"];
params ["_logic", "", "_activated"];
if !(_activated) exitWith {};
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

@ -1,13 +1,13 @@
/*
* Author: GitHawk
* Picks up a specific kind of magazine from an ammo truck
* Starts progress bar for picking up a specific kind of magazine from an ammo truck.
*
* Arguments:
* 0: The Ammo Truck <OBJECT>
* 1: The Player <OBJECT>
* 2: The Params <ARRAY>
* 2,0: The Magazine <STRING>
* 2,1: The Vehicle to be armed <OBJECT>
* 0: Ammo Truck <OBJECT>
* 1: Unit <OBJECT>
* 2: Params <ARRAY>
* 0: Magazine <STRING>
* 1: Vehicle to be armed <OBJECT>
*
* Return Value:
* None
@ -19,8 +19,9 @@
*/
#include "script_component.hpp"
private ["_ammo", "_tmpCal", "_cal"];
params ["_target","_unit","_args"];
private ["_ammo", "_tmpCal", "_cal", "_idx"];
params ["_target", "_unit", "_args"]; // _target is for future possible finite ammo
_args params ["_magazine", "_vehicle"];
_ammo = getText (configFile >> "CfgMagazines" >> _magazine >> "ammo");
@ -42,7 +43,7 @@ if (_tmpCal > 0) then {
};
};
_cal = round _cal;
_idx = CALIBERS find _cal;
_idx = REARM_CALIBERS find _cal;
if (_idx == -1 ) then {
_idx = 2;
};
@ -51,11 +52,11 @@ _unit setVariable [QGVAR(selectedWeaponOnRearm), currentWeapon _unit];
_unit action ["SwitchWeapon", _unit, _unit, 99];
[
(DURATION_PICKUP select _idx),
(REARM_DURATION_PICKUP select _idx),
[_unit, _magazine],
FUNC(pickUpSuccess),
"",
format [localize LSTRING(PickUpAction), getText(configFile >> "CfgMagazines" >> _magazine >> "displayName"), getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName")],
{true},
["isnotinside"]
] call EFUNC(common,progressBar);
] call EFUNC(common,progressBar);

View File

@ -1,11 +1,11 @@
/*
* Author: GitHawk
* Picks up a magazine
* Picks up a magazine.
*
* Arguments:
* 0: The Params <ARRAY>
* 0,0: The Unit <OBJECT>
* 0,1: The Magazine <STRING>
* 0: Params <ARRAY>
* 0: Unit <OBJECT>
* 1: Magazine <STRING>
*
* Return Value:
* None
@ -17,7 +17,7 @@
*/
#include "script_component.hpp"
private ["_dummy"];
private ["_dummy", "_ammo"];
params ["_args"];
_args params ["_unit", "_magazine"];
@ -30,6 +30,7 @@ if !(isNull _dummy) then {
deleteVehicle _dummy;
_unit setVariable [QGVAR(dummy), objNull];
};
_ammo = getText (configFile >> "CfgMagazines" >> _magazine >> "ammo");
_dummy = getText (configFile >> "CfgAmmo" >> _ammo >> QGVAR(dummy));
if !(_dummy == "") then {
@ -38,4 +39,4 @@ if !(_dummy == "") then {
[[_dummy, [[-1,0,0],[0,0,1]]], QUOTE(DFUNC(turn)), 2] call EFUNC(common,execRemoteFnc);
_dummy allowDamage false;
_unit setVariable [QGVAR(dummy), _dummy];
};
};

View File

@ -1,9 +1,10 @@
/*
* Author: GitHawk
* Rearms a vehicle
* Starts progress bar for rearming a vehicle.
*
* Arguments:
* 0: The vehicle <OBJECT>
* 0: Unit <OBJECT>
* 1: Vehicle <OBJECT>
*
* Return Value:
* None
@ -15,25 +16,13 @@
*/
#include "script_component.hpp"
#define GETRETURNVALUE \
_cnt = { _x == _magazine } count _magazines; \
if ((_target magazineTurretAmmo [_magazine, _path]) < getNumber (configFile >> "CfgMagazines" >> _magazine >> "count")) then { \
_turretPath = _path; \
_return = true; \
} else { \
if (_cnt < ([_target, _path, _magazine] call FUNC(getMaxMagazines))) then { \
_turretPath = _path; \
_return = true; \
}; \
};
private ["_ammo", "_tmpCal", "_cal", "_idx", "_return", "_cnt", "_magazineDisplayName"];
private ["_magazineClass", "_ammo", "_tmpCal", "_cal", "_idx", "_needRearmMags", "_magazineDisplayName"];
params ["_unit", "_vehicle"];
_magazine = _unit getVariable QGVAR(carriedMagazine);
if (isNil "_magazine") exitWith {false};
_magazineClass = _unit getVariable QGVAR(carriedMagazine);
if (isNil "_magazineClass") exitWith {false};
_ammo = getText (configFile >> "CfgMagazines" >> _magazine >> "ammo");
_ammo = getText (configFile >> "CfgMagazines" >> _magazineClass >> "ammo");
_tmpCal = getNumber (configFile >> "CfgAmmo" >> _ammo >> "ace_caliber");
_cal = 8;
if (_tmpCal > 0) then {
@ -43,7 +32,7 @@ if (_tmpCal > 0) then {
if (_tmpCal > 0) then {
_cal = _tmpCal;
} else {
diag_log format ["ACE_Rearm: Undefined Ammo [%1 : %2]", _ammo, inheritsFrom (configFile >> "CfgAmmo" >> _ammo)];
diag_log format ["[ACE] ERROR: Undefined Ammo [%1 : %2]", _ammo, inheritsFrom (configFile >> "CfgAmmo" >> _ammo)];
if (_ammo isKindOf "BulletBase") then {
_cal = 8;
} else {
@ -52,70 +41,34 @@ if (_tmpCal > 0) then {
};
};
_cal = round _cal;
_idx = CALIBERS find _cal;
if (_idx == -1 ) then {
_idx = REARM_CALIBERS find _cal;
if (_idx == -1) then {
_idx = 2;
};
_return = false;
_turretPath = [0]; _cnt = 0;
_magazines = _target magazinesTurret [-1];
if (_magazine in _magazines) then {
_path = [-1];
GETRETURNVALUE
};
if (!_return) then {
_magazines = _target magazinesTurret [0];
if (_magazine in _magazines) then {
_path = [0];
GETRETURNVALUE
};
};
if (!_return) then {
_magazines = _target magazinesTurret [0,0];
if (_magazine in _magazines) then {
_path = [0,0];
GETRETURNVALUE
};
};
if (!_return) then {
_magazines = _target magazinesTurret [0,1];
if (_magazine in _magazines) then {
_path = [0,1];
GETRETURNVALUE
};
};
if (!_return) then {
_magazines = _target magazinesTurret [1];
if (_magazine in _magazines) then {
_path = [1];
GETRETURNVALUE
};
};
if (!_return) then {
_magazines = _target magazinesTurret [2];
if (_magazine in _magazines) then {
_path = [2];
GETRETURNVALUE
} else {
diag_log format ["ACE_Rearm: Could not find turret for %1 in %2", _magazine, typeOf _target];
};
// Get magazines that can be rearmed
_needRearmMags = [_target, _magazines, _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\nDURATION_REARM: %6\nCount: %7", _magazine, _ammo, _cal, _idx, _turretPath, (DURATION_REARM select _idx), (COUNT select _idx)];
//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" >> _magazine >> "displayName");
_magazineDisplayName = getText(configFile >> "CfgMagazines" >> _magazineClass >> "displayName");
if (_magazineDisplayName == "") then {
_magazineDisplayName = _magazine;
diag_log format ["ACE_Rearm: Magazine is missing display name [%1]", _magazine];
_magazineDisplayName = _magazineClass;
diag_log format ["[ACE] ERROR: Magazine is missing display name [%1]", _magazineClass];
};
[
(DURATION_REARM select _idx),
[_target, _unit, _turretPath, _cnt, _magazine, (COUNT select _idx)],
(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);
] call EFUNC(common,progressBar);

View File

@ -1,11 +1,11 @@
/*
* Author: GitHawk
* Rearms an entire vehicle
* Starts progress bar for rearming an entire vehicle.
*
* Arguments:
* 0: The Ammo Truck <OBJECT>
* 1: The Player <OBJECT>
* 2: The Vehicle to be armed <OBJECT>
* 0: Ammo Truck <OBJECT>
* 1: Unit <OBJECT>
* 2: Vehicle to be armed <OBJECT>
*
* Return Value:
* None
@ -18,7 +18,7 @@
#include "script_component.hpp"
private ["_ammo", "_tmpCal", "_cal"];
params ["_target","_unit","_vehicle"];
params ["_target", "_unit", "_vehicle"];
[
10,
@ -28,4 +28,4 @@ params ["_target","_unit","_vehicle"];
format [localize LSTRING(BasicRearmAction), getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName")],
{true},
["isnotinside"]
] call EFUNC(common,progressBar);
] call EFUNC(common,progressBar);

View File

@ -1,9 +1,9 @@
/*
* Author: GitHawk
* Rearm an entire vehicle
* Rearm an entire vehicle.
*
* Arguments:
* 0: The Vehicle <OBJECT>
* 0: Vehicle <OBJECT>
*
* Return Value:
* None
@ -15,11 +15,11 @@
*/
#include "script_component.hpp"
private ["_turretPath", "_magazines", "_magazine", "_currentMagazines", "_maxMagazines", "_rounds"];
private ["_turretPath", "_magazines", "_magazine", "_currentMagazines", "_maxMagazines", "_maxRounds", "_currentRounds"];
params ["_vehicle"];
if !(local _vehicle) exitWith {
[_this, QUOTE(DFUNC(rearmEntireVehicleSuccess)), _vehicle] call EFUNC(common,execRemoteFnc);
[_this, QFUNC(rearmEntireVehicleSuccess), _vehicle] call EFUNC(common,execRemoteFnc);
};
{
@ -31,7 +31,7 @@ if !(local _vehicle) exitWith {
_maxMagazines = [_vehicle, _turretPath, _magazine] call FUNC(getMaxMagazines);
_maxRounds = getNumber (configFile >> "CfgMagazines" >> _magazine >> "count");
_currentRounds = _vehicle magazineTurretAmmo [_magazine, _turretPath];
//diag_log format ["Target: %1\nTurretPath: %2\nNumMagazines: %3\nMaxMagazines %4\nNumRounds: %5\nMaxRounds: %6\nMagazine: %7", _vehicle, _turretPath, _currentMagazines, _maxMagazines, _currentRounds, _maxRounds, _magazine];
if (_currentMagazines < _maxMagazines) then {
_vehicle setMagazineTurretAmmo [_magazine, _maxRounds, _turretPath];
@ -46,4 +46,4 @@ if !(local _vehicle) exitWith {
};
};
} foreach _magazines;
} foreach [[-1], [0], [0,0], [0,1], [1], [2]];
} foreach REARM_TURRET_PATHS;

View File

@ -1,31 +1,31 @@
/*
* Author: GitHawk
* Rearms a vehicle
* Rearms a vehicle.
*
* Arguments:
* 0: The Params <ARRAY>
* 0,1: The Target <OBJECT>
* 0,2: The Caller <OBJECT>
* 0,3: The Turretpath <ARRAY>
* 0,4: The Number of magazines <NUMBER>
* 0,5: The Magazine <STRING>
* 0,6: The Number of rounds <NUMBER>
* 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] call ace_rearm_fnc_rearmSuccess
* [[vehicle, player, [0], 5, "calcium", 500]] call ace_rearm_fnc_rearmSuccess
*
* Public: No
*/
#include "script_component.hpp"
private ["_rounds", "_currentRounds", "_maxMagazines", "_dummy"];
private ["_rounds", "_currentRounds", "_maxMagazines", "_dummy", "_weaponSelect"];
params ["_args"];
_args params ["_target", "_unit", "_turretPath", "_numMagazines", "_magazine", "_numRounds"];
_args params ["_target", "_unit", "_turretPath", "_numMagazines", "_magazineClass", "_numRounds"];
//hint format ["Target: %1\nTurretPath: %2\nNumMagazines: %3\nMagazine: %4\nNumRounds: %5", _target, _turretPath, _numMagazines, _magazine, _numRounds];
//hint format ["Target: %1\nTurretPath: %2\nNumMagazines: %3\nMagazine: %4\nNumRounds: %5", _target, _turretPath, _numMagazines, _magazineClass, _numRounds];
if (local _unit) then {
[_unit, QGVAR(vehRearm), false] call EFUNC(common,setForceWalkStatus);
@ -44,50 +44,50 @@ if !(local _target) exitWith {
[_this, QUOTE(DFUNC(rearmSuccess)), _target] call EFUNC(common,execRemoteFnc);
};
_rounds = getNumber (configFile >> "CfgMagazines" >> _magazine >> "count");
_rounds = getNumber (configFile >> "CfgMagazines" >> _magazineClass >> "count");
_currentRounds = 0;
_maxMagazines = [_target, _turretPath, _magazine] call FUNC(getMaxMagazines);
_maxMagazines = [_target, _turretPath, _magazineClass] call FUNC(getMaxMagazines);
if (_maxMagazines == 1) then {
if (GVAR(level) == 1) then {
// Fill magazine completely
_target setMagazineTurretAmmo [_magazine, _rounds, _turretPath];
_target setMagazineTurretAmmo [_magazineClass, _rounds, _turretPath];
} else {
// Fill only at most _numRounds
_target setMagazineTurretAmmo [_magazine, ((_target magazineTurretAmmo [_magazine, _turretPath]) + _numRounds) min _rounds, _turretPath];
_target setMagazineTurretAmmo [_magazineClass, ((_target magazineTurretAmmo [_magazineClass, _turretPath]) + _numRounds) min _rounds, _turretPath];
};
[[LSTRING(Hint_RearmedTriple), _numRounds,
getText(configFile >> "CfgMagazines" >> _magazine >> "displayName"),
getText(configFile >> "CfgMagazines" >> _magazineClass >> "displayName"),
getText(configFile >> "CfgVehicles" >> (typeOf _target) >> "displayName")], 3, _unit] call EFUNC(common,displayTextStructured);
} else {
for "_idx" from 1 to _maxMagazines do {
_currentRounds = _target magazineTurretAmmo [_magazine, _turretPath];
_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, _magazine];
//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 [_magazine, _rounds, _turretPath];
_target setMagazineTurretAmmo [_magazineClass, _rounds, _turretPath];
if (_numMagazines < _maxMagazines) then {
_target addMagazineTurret [_magazine, _turretPath];
_target setMagazineTurretAmmo [_magazine, _currentRounds + _numRounds - _rounds, _turretPath];
_target addMagazineTurret [_magazineClass, _turretPath];
_target setMagazineTurretAmmo [_magazineClass, _currentRounds + _numRounds - _rounds, _turretPath];
};
} else {
_target setMagazineTurretAmmo [_magazine, _currentRounds + _numRounds, _turretPath];
_target setMagazineTurretAmmo [_magazineClass, _currentRounds + _numRounds, _turretPath];
};
} else {
// Fill current magazine completely and fill next magazine partially
_target setMagazineTurretAmmo [_magazine, _rounds, _turretPath];
_target setMagazineTurretAmmo [_magazineClass, _rounds, _turretPath];
if (_numMagazines < _maxMagazines) then {
_target addMagazineTurret [_magazine, _turretPath];
_target setMagazineTurretAmmo [_magazine, _currentRounds, _turretPath];
_target addMagazineTurret [_magazineClass, _turretPath];
_target setMagazineTurretAmmo [_magazineClass, _currentRounds, _turretPath];
};
};
[[LSTRING(Hint_RearmedTriple), _rounds,
getText(configFile >> "CfgMagazines" >> _magazine >> "displayName"),
getText(configFile >> "CfgMagazines" >> _magazineClass >> "displayName"),
getText(configFile >> "CfgVehicles" >> (typeOf _target) >> "displayName")], 3, _unit] call EFUNC(common,displayTextStructured);
};
_target removeMagazineTurret [_magazine, _turretPath];
_target removeMagazineTurret [_magazineClass, _turretPath];
_numMagazines = _numMagazines - 1;
};
};
};

View File

@ -1,16 +1,16 @@
/*
* Author: GitHawk
* Turns an object
* Turns an object.
*
* Arguments:
* 0: The Player <OBJECT>
* 1: The dirAndUp vector <ARRAY>
* 0: Object <OBJECT>
* 1: Vector dirAndUp <ARRAY>
*
* Return Value:
* None
*
* Example:
* [_dummy, [[1,0,0],[0,0,1]]] call ace_rearm_fnc_turn
* [dummy, [[1,0,0],[0,0,1]]] call ace_rearm_fnc_turn
*
* Public: No
*/

View File

@ -11,7 +11,11 @@
#include "\z\ace\addons\main\script_macros.hpp"
#define CALIBERS [ 6, 7, 8, 13, 19, 20, 25, 30, 35, 40, 60, 70, 80, 82, 100, 105, 120, 122, 125, 155, 230, 250]
#define DURATION_PICKUP [ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 3, 3, 3, 3, 3, 4, 5, 5, 5, 5, 13, 10]
#define DURATION_REARM [ 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 7, 7, 7, 7, 7, 8, 10, 10, 10, 10, 27, 20]
#define COUNT [500, 500, 400, 100, 50, 50, 40, 25, 34, 10, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1]
#define REARM_ACTION_DISTANCE 7
#define REARM_TURRET_PATHS [[-1], [0], [0,0], [0,1], [1], [2]]
#define REARM_CALIBERS [ 6, 7, 8, 13, 19, 20, 25, 30, 35, 40, 60, 70, 80, 82, 100, 105, 120, 122, 125, 155, 230, 250]
#define REARM_DURATION_PICKUP [ 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, 7, 7, 7, 7, 7, 8, 10, 10, 10, 10, 27, 20]
#define REARM_COUNT [500, 500, 400, 100, 50, 50, 40, 25, 34, 10, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1]

View File

@ -1,12 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<?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>
<English>Rearm Amount</English>
<German>Aufmunitioniermenge</German>
</Key>
<Key ID="STR_ACE_Rearm_RearmSettings_level_Description">
@ -14,7 +17,7 @@
<German>Wie schnell soll ein Fahrzeug aufmunitioniert werden?</German>
</Key>
<Key ID="STR_ACE_Rearm_RearmSettings_vehicle">
<English>Entire vehicle</English>
<English>Entire Vehicle</English>
<German>Gesamtes Fahrzeug</German>
</Key>
<Key ID="STR_ACE_Rearm_RearmSettings_magazine">
@ -30,16 +33,16 @@
<German>Aufmunitionieren</German>
</Key>
<Key ID="STR_ACE_Rearm_RearmAction">
<English>Rearming %1 with %2</English>
<German>Munitioniere %1 auf mit %2</German>
<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>
<English>Rearming %1 ...</English>
<German>Munitioniere %1 auf ...</German>
</Key>
<Key ID="STR_ACE_Rearm_PickUpAction">
<English>Taking %1 for %2</English>
<German>Nehme %1 für %2</German>
<English>Taking %1 for %2 ...</English>
<German>Nehme %1 für %2 ...</German>
</Key>
<Key ID="STR_ACE_Rearm_PickUpAmmo">
<English>Pick up ammo</English>
@ -49,7 +52,7 @@
<English>Rearmed %1 rounds of %2 on %3</English>
<German>%1 Schuss %2 an %3 aufmunitioniert</German>
</Key>
<Key ID="STR_ACE_Rearm_SmokeLauncherMag">
<Key ID="STR_ACE_Rearm_Mag_SmokeLauncherMag">
<Original>Smoke Screen</Original>
<English>Smoke Screen</English>
<Czech>Kouřová clona</Czech>
@ -61,7 +64,7 @@
<Russian>Дым. завеса</Russian>
<Spanish>Pantalla de humo</Spanish>
</Key>
<Key ID="STR_ACE_Rearm_60Rnd_CMFlareMagazine">
<Key ID="STR_ACE_Rearm_Mag_60Rnd_CMFlareMagazine">
<Original>Flares</Original>
<English>Flares</English>
<Czech>Světlice</Czech>
@ -73,51 +76,51 @@
<Russian>ЛТЦ</Russian>
<Spanish>Bengalas</Spanish>
</Key>
<Key ID="STR_ACE_Rearm_1000Rnd_Gatling_30mm_Plane_CAS_01_F">
<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_500Rnd_Cannon_30mm_Plane_CAS_02_F">
<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_2Rnd_Missile_AA_04_F">
<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_2Rnd_Missile_AA_03_F">
<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_6Rnd_Missile_AGM_02_F">
<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_4Rnd_Missile_AGM_01_F">
<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_7Rnd_Rocket_04_HE_F">
<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_20Rnd_Rocket_03_HE_F">
<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_7Rnd_Rocket_04_AP_F">
<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_20Rnd_Rocket_03_AP_F">
<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_4Rnd_Bomb_04_F">
<Key ID="STR_ACE_Rearm_Mag_4Rnd_Bomb_04_F">
<English>GBU-12</English>
<German>GBU-12</German>
</Key>
<Key ID="STR_ACE_Rearm_2Rnd_Bomb_03_F">
<Key ID="STR_ACE_Rearm_Mag_2Rnd_Bomb_03_F">
<English>FAB-250M-54</English>
<German>FAB-250M-54</German>
</Key>