mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Initial code
This commit is contained in:
parent
1a2b99c76c
commit
0c4924259d
1
addons/rearm/$PBOPREFIX$
Normal file
1
addons/rearm/$PBOPREFIX$
Normal file
@ -0,0 +1 @@
|
||||
z\ace\addons\rearm
|
9
addons/rearm/ACE_Settings.hpp
Normal file
9
addons/rearm/ACE_Settings.hpp
Normal file
@ -0,0 +1,9 @@
|
||||
class ACE_Settings {
|
||||
class GVAR(level) {
|
||||
displayName = LSTRING(RearmSettings_level_DisplayName);
|
||||
description = LSTRING(RearmSettings_level_Description);
|
||||
value = 1;
|
||||
typeName = "SCALAR";
|
||||
values[] = {LSTRING(RearmSettings_vehicle), LSTRING(RearmSettings_magazine), LSTRING(RearmSettings_caliber)};
|
||||
};
|
||||
};
|
196
addons/rearm/CfgAmmo.hpp
Normal file
196
addons/rearm/CfgAmmo.hpp
Normal file
@ -0,0 +1,196 @@
|
||||
class CfgAmmo {
|
||||
|
||||
class BombCore;
|
||||
class BombBase : BombCore {
|
||||
ace_logistics_caliber = 250; // Default caliber for bombs
|
||||
};
|
||||
class LaserBombCore : BombCore {
|
||||
ace_logistics_caliber = 250; // Default caliber for bombs
|
||||
};
|
||||
class MissileCore;
|
||||
class MissileBase : MissileCore {
|
||||
ace_logistics_caliber = 250; // Default caliber for missiles
|
||||
};
|
||||
class Rocket_04_HE_F : MissileBase {
|
||||
ace_logistics_caliber = 70;
|
||||
};
|
||||
class M_PG_AT : MissileBase {
|
||||
ace_logistics_caliber = 100;
|
||||
};
|
||||
class ACE_Hydra70_DAGR : M_PG_AT {
|
||||
ace_logistics_caliber = 70;
|
||||
};
|
||||
|
||||
class RocketCore;
|
||||
class RocketBase : RocketCore {
|
||||
ace_logistics_caliber = 70; // Default caliber for rockets
|
||||
};
|
||||
class R_80mm_HE : RocketBase {
|
||||
ace_logistics_caliber = 80;
|
||||
};
|
||||
class R_60mm_HE : R_80mm_HE {
|
||||
ace_logistics_caliber = 60;
|
||||
};
|
||||
|
||||
class BulletBase;
|
||||
|
||||
class B_19mm_HE : BulletBase {
|
||||
ace_logistics_caliber = 19;
|
||||
};
|
||||
|
||||
class B_20mm : BulletBase {
|
||||
ace_logistics_caliber = 20;
|
||||
};
|
||||
|
||||
class B_25mm : BulletBase {
|
||||
ace_logistics_caliber = 25;
|
||||
};
|
||||
|
||||
class B_30mm_AP : BulletBase {
|
||||
ace_logistics_caliber = 30;
|
||||
};
|
||||
class B_30mm_HE : B_19mm_HE {
|
||||
ace_logistics_caliber = 30;
|
||||
};
|
||||
class Gatling_30mm_HE_Plane_CAS_01_F : BulletBase {
|
||||
ace_logistics_caliber = 30;
|
||||
};
|
||||
|
||||
class B_35mm_AA : BulletBase {
|
||||
ace_logistics_caliber = 35;
|
||||
};
|
||||
|
||||
class B_30mm_APFSDS;
|
||||
class B_40mm_APFSDS : B_30mm_APFSDS {
|
||||
ace_logistics_caliber = 40;
|
||||
};
|
||||
|
||||
class B_40mm_GPR : B_30mm_HE {
|
||||
ace_logistics_caliber = 40;
|
||||
};
|
||||
|
||||
class GrenadeBase;
|
||||
class G_40mm_HE : GrenadeBase {
|
||||
ace_logistics_caliber = 40;
|
||||
};
|
||||
|
||||
class RDS_B_127x107_Ball : BulletBase {
|
||||
ace_logistics_caliber = 12.7;
|
||||
};
|
||||
|
||||
class ShellBase;
|
||||
class Sh_120mm_APFSDS : Shellbase {
|
||||
ace_logistics_caliber = 120;
|
||||
};
|
||||
class Sh_105mm_APFSDS : Sh_120mm_APFSDS {
|
||||
ace_logistics_caliber = 105;
|
||||
};
|
||||
class Sh_125mm_APFSDS : Sh_120mm_APFSDS {
|
||||
ace_logistics_caliber = 125;
|
||||
};
|
||||
|
||||
class Sh_120mm_HE : ShellBase {
|
||||
ace_logistics_caliber = 120;
|
||||
};
|
||||
class Sh_125mm_HE : Sh_120mm_HE {
|
||||
ace_logistics_caliber = 125;
|
||||
};
|
||||
class Sh_125mm_HEAT : Sh_125mm_HE {
|
||||
ace_logistics_caliber = 125;
|
||||
};
|
||||
class Sh_105mm_HEAT_MP : Sh_125mm_HEAT {
|
||||
ace_logistics_caliber = 105;
|
||||
};
|
||||
|
||||
class Sh_155mm_AMOS : ShellBase {
|
||||
ace_logistics_caliber = 155;
|
||||
};
|
||||
class Sh_82mm_AMOS : Sh_155mm_AMOS {
|
||||
ace_logistics_caliber = 82;
|
||||
};
|
||||
class RDS_Sh_122_HE : Sh_155mm_AMOS {
|
||||
ace_logistics_caliber = 122;
|
||||
};
|
||||
class RDS_Sh_105_HE : Sh_155mm_AMOS {
|
||||
ace_logistics_caliber = 105;
|
||||
};
|
||||
|
||||
class Sh_82mm_AMOS_LG;
|
||||
class Sh_155mm_AMOS_LG : Sh_82mm_AMOS_LG {
|
||||
ace_logistics_caliber = 155;
|
||||
};
|
||||
class RDS_Sh_122_LASER : Sh_155mm_AMOS_LG {
|
||||
ace_logistics_caliber = 122;
|
||||
};
|
||||
class RDS_Sh_105_LASER : Sh_155mm_AMOS_LG {
|
||||
ace_logistics_caliber = 105;
|
||||
};
|
||||
|
||||
class ShotDeployBase;
|
||||
class Smoke_82mm_AMOS_White : ShotDeployBase {
|
||||
ace_logistics_caliber = 82;
|
||||
};
|
||||
|
||||
class FlareCore;
|
||||
class Flare_82mm_AMOS_White : FlareCore {
|
||||
ace_logistics_caliber = 82;
|
||||
};
|
||||
|
||||
class SmokeLauncherAmmo : BulletBase {
|
||||
ace_logistics_caliber = 250;
|
||||
};
|
||||
|
||||
class CMflareAmmo : BulletBase {
|
||||
ace_logistics_caliber = 40;
|
||||
};
|
||||
|
||||
class SubmunitionBase;
|
||||
class Sh_82mm_AMOS_guided : SubmunitionBase {
|
||||
ace_logistics_caliber = 82;
|
||||
};
|
||||
class Sh_155mm_AMOS_guided : Sh_82mm_AMOS_guided {
|
||||
ace_logistics_caliber = 155;
|
||||
};
|
||||
class R_230mm_HE : SubmunitionBase {
|
||||
ace_logistics_caliber = 230;
|
||||
};
|
||||
class rhs_ammo_127x108mm_x5 : SubmunitionBase {
|
||||
ace_logistics_caliber = 12.7;
|
||||
};
|
||||
class Mine_155mm_AMOS_range : SubmunitionBase {
|
||||
ace_logistics_caliber = 155;
|
||||
};
|
||||
class Cluster_155mm_AMOS : SubmunitionBase {
|
||||
ace_logistics_caliber = 155;
|
||||
};
|
||||
class Smoke_120mm_AMOS_White : SubmunitionBase {
|
||||
ace_logistics_caliber = 155;
|
||||
};
|
||||
class AT_Mine_155mm_AMOS_range : SubmunitionBase {
|
||||
ace_logistics_caliber = 155;
|
||||
};
|
||||
|
||||
class rhs_ammo_rpgShell_base : ShellBase {
|
||||
ace_logistics_caliber = 70;
|
||||
};
|
||||
|
||||
class Bomb_04_F : LaserBombCore {
|
||||
ace_logistics_caliber = 250; // Default caliber for bombs
|
||||
};
|
||||
class Bo_GBU12_LGB : LaserBombCore {
|
||||
ace_logistics_caliber = 250; // Default caliber for bombs
|
||||
};
|
||||
class js_a_fa18_wing_tank : LaserBombCore {
|
||||
ace_logistics_caliber = 250; // Default caliber for bombs
|
||||
};
|
||||
|
||||
class js_a_fa18x_MK82 : BombCore {};
|
||||
class js_a_fa18x_GBU39_SDB : js_a_fa18x_MK82 {
|
||||
ace_logistics_caliber = 250; // Default caliber for bombs
|
||||
};
|
||||
|
||||
class js_a_fa18_GBU12_LGB : LaserBombCore {};
|
||||
class js_a_fa18_GBU38_JDAM : js_a_fa18_GBU12_LGB {
|
||||
ace_logistics_caliber = 250; // Default caliber for bombs
|
||||
};
|
||||
};
|
5
addons/rearm/CfgEventHandlers.hpp
Normal file
5
addons/rearm/CfgEventHandlers.hpp
Normal file
@ -0,0 +1,5 @@
|
||||
class Extended_PreInit_EventHandlers {
|
||||
class ADDON {
|
||||
init = QUOTE(call COMPILE_FILE(XEH_preInit));
|
||||
};
|
||||
};
|
125
addons/rearm/CfgVehicles.hpp
Normal file
125
addons/rearm/CfgVehicles.hpp
Normal file
@ -0,0 +1,125 @@
|
||||
#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); \
|
||||
distance = REARM_ACTION_DISTANCE; \
|
||||
condition = QUOTE([ARR_2(_player,_target)] call FUNC(canRearm)); \
|
||||
statement = QUOTE([ARR_2(_player,_target)] call FUNC(rearm)); \
|
||||
exceptions[] = {"isNotInside"}; \
|
||||
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); \
|
||||
distance = REARM_ACTION_DISTANCE; \
|
||||
condition = QUOTE([ARR_2(_player,_target)] call FUNC(canPickUpAmmo)); \
|
||||
insertChildren = QUOTE([ARR_1(_target)] call DFUNC(addRearmActions)); \
|
||||
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";
|
||||
function = QUOTE(DFUNC(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 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
|
||||
};
|
||||
|
||||
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
|
||||
};
|
||||
};
|
15
addons/rearm/XEH_preInit.sqf
Normal file
15
addons/rearm/XEH_preInit.sqf
Normal file
@ -0,0 +1,15 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
ADDON = false;
|
||||
|
||||
PREP(addRearmActions);
|
||||
PREP(canRearm);
|
||||
PREP(canPickupAmmo);
|
||||
PREP(getMaxMagazines);
|
||||
PREP(pickUpAmmo);
|
||||
PREP(pickUpSuccess);
|
||||
PREP(rearm);
|
||||
PREP(rearmSuccess);
|
||||
PREP(moduleRearmSettings);
|
||||
|
||||
ADDON = true;
|
18
addons/rearm/config.cpp
Normal file
18
addons/rearm/config.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
class CfgPatches {
|
||||
class ADDON {
|
||||
units[] = {};
|
||||
weapons[] = {};
|
||||
requiredVersion = REQUIRED_VERSION;
|
||||
requiredAddons[] = {"ace_interaction"};
|
||||
author[] = {"GitHawk"};
|
||||
authorUrl = "";
|
||||
VERSION_CONFIG;
|
||||
};
|
||||
};
|
||||
|
||||
#include "CfgEventHandlers.hpp"
|
||||
#include "CfgVehicles.hpp"
|
||||
#include "CfgAmmo.hpp"
|
||||
#include "ACE_Settings.hpp"
|
65
addons/rearm/functions/fnc_addRearmActions.sqf
Normal file
65
addons/rearm/functions/fnc_addRearmActions.sqf
Normal file
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Author: GitHawk
|
||||
* Show the resupplyable ammunition of all surrounding vehicles.
|
||||
* Called from "insertChildren" on interact_menu
|
||||
*
|
||||
* 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"];
|
||||
params ["_target"];
|
||||
|
||||
_vehicles = nearestObjects [_target, ["AllVehicles"], 20];
|
||||
if (count _vehicles < 2) exitWith {false}; // Logistics needs at least 2 vehicles
|
||||
|
||||
_vehicleActions = [];
|
||||
{
|
||||
_actions = [];
|
||||
_vehicle = _x;
|
||||
_needToAdd = false;
|
||||
_action = [];
|
||||
if !(_vehicle == _target) then {
|
||||
_magazineHelper = [];
|
||||
{
|
||||
_turretPath = _x;
|
||||
_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(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}, {}, [_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]];
|
||||
};
|
||||
if (_needToAdd) then {
|
||||
_icon = getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "Icon");
|
||||
if !((_icon select [0, 1]) == "\") then {
|
||||
_icon = "";
|
||||
};
|
||||
_action = [_vehicle, getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName"), _icon, "", {true}, {}, []] call EFUNC(interact_menu,createAction);
|
||||
_vehicleActions pushBack [_action, _actions, _target];
|
||||
};
|
||||
} foreach _vehicles;
|
||||
|
||||
_vehicleActions
|
21
addons/rearm/functions/fnc_canPickUpAmmo.sqf
Normal file
21
addons/rearm/functions/fnc_canPickUpAmmo.sqf
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Author: GitHawk
|
||||
* Check if a unit can pick up ammo
|
||||
*
|
||||
* Arguments:
|
||||
* 0: The Player <OBJECT>
|
||||
* 1: The Target <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* Can rearm
|
||||
*
|
||||
* Example:
|
||||
* [tank] call ace_rearm_fnc_canPickUpAmmo
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit", "_target"];
|
||||
|
||||
!(isNull ace_player || {!(ace_player isKindOf "CAManBase")} || {!local ace_player} || { (_target distance ace_player) > 7})
|
81
addons/rearm/functions/fnc_canRearm.sqf
Normal file
81
addons/rearm/functions/fnc_canRearm.sqf
Normal file
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Author: GitHawk
|
||||
* Check if a unit can rearm
|
||||
*
|
||||
* Arguments:
|
||||
* 0: The unit <OBJECT>
|
||||
* 1: The target <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* Can rearm <BOOL>
|
||||
*
|
||||
* Example:
|
||||
* [player, tank] call ace_rearm_fnc_canRearm
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_vehicles", "_magazine", "_magazines", "_path", "_return", "_cnt"];
|
||||
params ["_unit", "_vehicle"];
|
||||
|
||||
#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 (isNull _unit || {!(_unit isKindOf "CAManBase")} || {!local _unit} || { (_vehicle distance _unit) > 7}) exitWith {false};
|
||||
|
||||
_magazine = _unit getVariable QGVAR(carriedMagazine);
|
||||
if (isNil "_magazine") exitWith {false};
|
||||
|
||||
// TODO move into loop
|
||||
|
||||
_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
|
87
addons/rearm/functions/fnc_getMaxMagazines.sqf
Normal file
87
addons/rearm/functions/fnc_getMaxMagazines.sqf
Normal file
@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Author: GitHawk
|
||||
* 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>
|
||||
*
|
||||
* 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", "_magazine"];
|
||||
|
||||
if (isNull _target) exitWith {0};
|
||||
_count = 0;
|
||||
|
||||
// TODO replace by loop or method of interpreting _turretPath
|
||||
|
||||
_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 {
|
||||
_cfg = configFile >> "CfgVehicles" >> (typeOf _target);
|
||||
};
|
||||
};
|
||||
|
||||
if !(isClass _cfg) exitWith {0};
|
||||
|
||||
_count = {_x == _magazine} count getArray (_cfg >> "magazines");
|
||||
_count
|
22
addons/rearm/functions/fnc_moduleRearmSettings.sqf
Normal file
22
addons/rearm/functions/fnc_moduleRearmSettings.sqf
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Author: GitHawk
|
||||
* Module for adjusting the refuel settings
|
||||
*
|
||||
* Arguments:
|
||||
* 0: The module logic <LOGIC>
|
||||
* 1: units <ARRAY>
|
||||
* 2: activated <BOOL>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_logic", "_units", "_activated"];
|
||||
|
||||
if !(_activated) exitWith {};
|
||||
|
||||
[_logic, QGVAR(level), "level"] call EFUNC(common,readSettingFromModule);
|
58
addons/rearm/functions/fnc_pickUpAmmo.sqf
Normal file
58
addons/rearm/functions/fnc_pickUpAmmo.sqf
Normal file
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Author: GitHawk
|
||||
* Picks 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>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [ammo_truck, player, ["500Rnd_127x99_mag_Tracer_Red", tank]] call ace_rearm_fnc_pickUpAmmo
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_ammo", "_tmpCal", "_cal"];
|
||||
params ["_target","_unit","_args"];
|
||||
_args params ["_magazine", "_vehicle"];
|
||||
|
||||
_ammo = getText (configFile >> "CfgMagazines" >> _magazine >> "ammo");
|
||||
_tmpCal = getNumber (configFile >> "CfgAmmo" >> _ammo >> "ace_caliber");
|
||||
_cal = 8;
|
||||
if (_tmpCal > 0) then {
|
||||
_cal = _tmpCal;
|
||||
} else {
|
||||
_tmpCal = getNumber (configFile >> "CfgAmmo" >> _ammo >> "ace_logistics_caliber");
|
||||
if (_tmpCal > 0) then {
|
||||
_cal = _tmpCal;
|
||||
} else {
|
||||
diag_log format ["ACE_Logistics: Undefined Ammo [%1 : %2]", _ammo, inheritsFrom (configFile >> "CfgAmmo" >> _ammo)];
|
||||
if (_ammo isKindOf "BulletBase") then {
|
||||
_cal = 8;
|
||||
} else {
|
||||
_cal = 100;
|
||||
};
|
||||
};
|
||||
};
|
||||
_cal = round _cal;
|
||||
_idx = CALIBERS find _cal;
|
||||
if (_idx == -1 ) then {
|
||||
_idx = 2;
|
||||
};
|
||||
|
||||
[
|
||||
(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);
|
23
addons/rearm/functions/fnc_pickUpSuccess.sqf
Normal file
23
addons/rearm/functions/fnc_pickUpSuccess.sqf
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Author: GitHawk
|
||||
* Picks up a magazine
|
||||
*
|
||||
* Arguments:
|
||||
* 0: The Params <ARRAY>
|
||||
* 0,0: The Unit <OBJECT>
|
||||
* 0,1: The Magazine <STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [[player, "500Rnd_127x99_mag_Tracer_Red"]] call ace_rearm_fnc_pickUpSuccess
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_args"];
|
||||
_args params ["_unit", "_magazine"];
|
||||
|
||||
_unit setVariable [QGVAR(carriedMagazine), _magazine]; // TODO replace by item
|
115
addons/rearm/functions/fnc_rearm.sqf
Normal file
115
addons/rearm/functions/fnc_rearm.sqf
Normal file
@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Author: GitHawk
|
||||
* Rearms a vehicle
|
||||
*
|
||||
* Arguments:
|
||||
* 0: The vehicle <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [player, vehicle] call ace_rearm_fnc_rearm
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#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", "_cnt","_return"];
|
||||
params ["_unit", "_vehicle"];
|
||||
|
||||
_magazine = _unit getVariable QGVAR(carriedMagazine);
|
||||
if (isNil "_magazine") exitWith {false};
|
||||
|
||||
_ammo = getText (configFile >> "CfgMagazines" >> _magazine >> "ammo");
|
||||
_tmpCal = getNumber (configFile >> "CfgAmmo" >> _ammo >> "ace_caliber");
|
||||
_cal = 8;
|
||||
if (_tmpCal > 0) then {
|
||||
_cal = _tmpCal;
|
||||
} else {
|
||||
_tmpCal = getNumber (configFile >> "CfgAmmo" >> _ammo >> "ace_logistics_caliber");
|
||||
if (_tmpCal > 0) then {
|
||||
_cal = _tmpCal;
|
||||
} else {
|
||||
diag_log format ["ACE_Rearm: Undefined Ammo [%1 : %2]", _ammo, inheritsFrom (configFile >> "CfgAmmo" >> _ammo)];
|
||||
if (_ammo isKindOf "BulletBase") then {
|
||||
_cal = 8;
|
||||
} else {
|
||||
_cal = 100;
|
||||
};
|
||||
};
|
||||
};
|
||||
_cal = round _cal;
|
||||
_idx = 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)];
|
||||
};
|
||||
};
|
||||
|
||||
//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)];
|
||||
|
||||
[
|
||||
(DURATION_REARM select _idx),
|
||||
[_target, _unit, _turretPath, _cnt, _magazine, (COUNT select _idx)],
|
||||
FUNC(rearmSuccess),
|
||||
"",
|
||||
format [localize LSTRING(RearmAction), getText(configFile >> "CfgVehicles" >> (typeOf _target) >> "displayName"), getText(configFile >> "CfgMagazines" >> _magazine >> "displayName")],
|
||||
{true},
|
||||
["isnotinside"]
|
||||
] call EFUNC(common,progressBar);
|
58
addons/rearm/functions/fnc_rearmSuccess.sqf
Normal file
58
addons/rearm/functions/fnc_rearmSuccess.sqf
Normal file
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Author: GitHawk
|
||||
* 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>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [vehicle] call ace_rearm_fnc_rearmSuccess
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_rounds", "_currentRounds", "_maxMagazines"];
|
||||
params ["_args"];
|
||||
_args params ["_target", "_caller", "_turretPath", "_numMagazines", "_magazine", "_numRounds"];
|
||||
|
||||
//hint format ["Target: %1\nTurretPath: %2\nNumMagazines: %3\nMagazine: %4\nNumRounds: %5", _target, _turretPath, _numMagazines, _magazine, _numRounds];
|
||||
|
||||
if !(local _target) exitWith {
|
||||
[_this, QUOTE(DFUNC(rearmSuccess)), _target] call EFUNC(common,execRemoteFnc);
|
||||
};
|
||||
|
||||
_rounds = getNumber (configFile >> "CfgMagazines" >> _magazine >> "count");
|
||||
_currentRounds = 0;
|
||||
|
||||
_maxMagazines = [_target, _turretPath, _magazine] call FUNC(getMaxMagazines);
|
||||
if (_maxMagazines == 1) then {
|
||||
_target setMagazineTurretAmmo [_magazine, ((_target magazineTurretAmmo [_magazine, _turretPath]) + _numRounds) min _rounds, _turretPath];
|
||||
ace_player setVariable [QGVAR(carriedMagazine), nil]; // TODO replace by item
|
||||
} else {
|
||||
for "_idx" from 1 to _maxMagazines do {
|
||||
_currentRounds = _target magazineTurretAmmo [_magazine, _turretPath];
|
||||
if (_currentRounds > 0) exitWith {
|
||||
if ((_currentRounds + _numRounds) > _rounds) then {
|
||||
_target setMagazineTurretAmmo [_magazine, _rounds, _turretPath];
|
||||
if (_numMagazines < _maxMagazines) then {
|
||||
_target addMagazineTurret [_magazine, _turretPath];
|
||||
_target setMagazineTurretAmmo [_magazine, _currentRounds + _numRounds - _rounds, _turretPath];
|
||||
};
|
||||
} else {
|
||||
_target setMagazineTurretAmmo [_magazine, _currentRounds + _numRounds, _turretPath];
|
||||
};
|
||||
ace_player setVariable [QGVAR(carriedMagazine), nil]; // TODO replace by item
|
||||
};
|
||||
_target removeMagazineTurret [_magazine, _turretPath];
|
||||
};
|
||||
};
|
6
addons/rearm/functions/script_component.hpp
Normal file
6
addons/rearm/functions/script_component.hpp
Normal file
@ -0,0 +1,6 @@
|
||||
#include "\z\ace\addons\rearm\script_component.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]
|
4
addons/rearm/script_component.hpp
Normal file
4
addons/rearm/script_component.hpp
Normal file
@ -0,0 +1,4 @@
|
||||
#define COMPONENT rearm
|
||||
#include "\z\ace\addons\main\script_mod.hpp"
|
||||
|
||||
#include "\z\ace\addons\main\script_macros.hpp"
|
45
addons/rearm/stringtable.xml
Normal file
45
addons/rearm/stringtable.xml
Normal file
@ -0,0 +1,45 @@
|
||||
<?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_speed_DisplayName">
|
||||
<English>Rearm speed</English>
|
||||
<German>Aufmunitioniergeschwindigkeit</German>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Rearm_RearmSettings_speed_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_PickUpAction">
|
||||
<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>
|
||||
<German>Munition nehmen</German>
|
||||
</Key>
|
||||
</Package>
|
||||
</Project>
|
BIN
addons/rearm/ui/icon_module_rearm.paa
Normal file
BIN
addons/rearm/ui/icon_module_rearm.paa
Normal file
Binary file not shown.
BIN
addons/rearm/ui/icon_rearm_interact.paa
Normal file
BIN
addons/rearm/ui/icon_rearm_interact.paa
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user