mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Merge pull request #2187 from jonpas/trackToTrackedVehicles
Added Spare Parts module handling
This commit is contained in:
commit
a4b4c5d2a3
@ -61,4 +61,11 @@ class ACE_Settings {
|
||||
values[] = {CSTRING(engineerSetting_anyone), CSTRING(engineerSetting_EngineerOnly), CSTRING(engineerSetting_RepairSpecialistOnly)};
|
||||
category = ECSTRING(OptionsMenu,CategoryLogistics);
|
||||
};
|
||||
class GVAR(addSpareParts) {
|
||||
displayName = CSTRING(addSpareParts_name);
|
||||
description = CSTRING(addSpareParts_description);
|
||||
typeName = "BOOL";
|
||||
value = 1;
|
||||
category = ECSTRING(OptionsMenu,CategoryLogistics);
|
||||
};
|
||||
};
|
||||
|
@ -13,31 +13,31 @@ class Extended_PostInit_EventHandlers {
|
||||
class Extended_Init_EventHandlers {
|
||||
class Car {
|
||||
class ADDON {
|
||||
init = QUOTE(_this call DFUNC(addRepairActions));
|
||||
init = QUOTE(_this call DFUNC(addRepairActions); _this call DFUNC(addSpareParts));
|
||||
};
|
||||
};
|
||||
|
||||
class Tank {
|
||||
class ADDON {
|
||||
init = QUOTE(_this call DFUNC(addRepairActions));
|
||||
init = QUOTE(_this call DFUNC(addRepairActions); _this call DFUNC(addSpareParts));
|
||||
};
|
||||
};
|
||||
|
||||
class Helicopter {
|
||||
class ADDON {
|
||||
init = QUOTE(_this call DFUNC(addRepairActions));
|
||||
init = QUOTE(_this call DFUNC(addRepairActions); _this call DFUNC(addSpareParts));
|
||||
};
|
||||
};
|
||||
|
||||
class Plane {
|
||||
class ADDON {
|
||||
init = QUOTE(_this call DFUNC(addRepairActions));
|
||||
init = QUOTE(_this call DFUNC(addRepairActions); _this call DFUNC(addSpareParts));
|
||||
};
|
||||
};
|
||||
|
||||
class Ship_F {
|
||||
class ADDON {
|
||||
init = QUOTE(_this call DFUNC(addRepairActions));
|
||||
init = QUOTE(_this call DFUNC(addRepairActions); _this call DFUNC(addSpareParts));
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -91,6 +91,12 @@ class CfgVehicles {
|
||||
class Special { name = CSTRING(engineerSetting_RepairSpecialistOnly); value = 2; default = 1;};
|
||||
};
|
||||
};
|
||||
class addSpareParts {
|
||||
displayName = CSTRING(addSpareParts_name);
|
||||
description = CSTRING(addSpareParts_description);
|
||||
typeName = "BOOL";
|
||||
defaultValue = 1;
|
||||
};
|
||||
};
|
||||
class ModuleDescription {
|
||||
description = CSTRING(moduleDescription);
|
||||
@ -215,19 +221,57 @@ class CfgVehicles {
|
||||
sync[] = {};
|
||||
};
|
||||
};
|
||||
class ACE_moduleAddSpareParts: Module_F {
|
||||
scope = 2;
|
||||
displayName = CSTRING(AddSpareParts_Module_DisplayName);
|
||||
icon = QUOTE(PATHTOF(ui\Icon_Module_Repair_ca.paa));
|
||||
category = "ACE_Logistics";
|
||||
function = QFUNC(moduleAddSpareParts);
|
||||
functionPriority = 10;
|
||||
isGlobal = 0;
|
||||
isTriggerActivated = 0;
|
||||
isDisposable = 0;
|
||||
author = ECSTRING(common,ACETeam);
|
||||
class Arguments {
|
||||
class List {
|
||||
displayName = CSTRING(AddSpareParts_List_DisplayName);
|
||||
description = CSTRING(AddSpareParts_List_Description);
|
||||
defaultValue = "";
|
||||
typeName = "STRING";
|
||||
};
|
||||
class Part {
|
||||
displayName = CSTRING(AddSpareParts_Part_DisplayName);
|
||||
description = CSTRING(AddSpareParts_Part_Description);
|
||||
typeName = "STRING";
|
||||
class values {
|
||||
class Wheel {
|
||||
name = CSTRING(SpareWheel);
|
||||
value = "ACE_Wheel";
|
||||
default = 1;
|
||||
};
|
||||
class Track {
|
||||
name = CSTRING(SpareTrack);
|
||||
value = "ACE_Track";
|
||||
};
|
||||
};
|
||||
};
|
||||
class Amount {
|
||||
displayName = CSTRING(AddSpareParts_Amount_DisplayName);
|
||||
description = CSTRING(AddSpareParts_Amount_Description);
|
||||
typeName = "NUMBER";
|
||||
defaultValue = 1;
|
||||
};
|
||||
};
|
||||
class ModuleDescription {
|
||||
description = CSTRING(AddSpareParts_Module_Description);
|
||||
sync[] = {};
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
class LandVehicle;
|
||||
class Car: LandVehicle {
|
||||
MACRO_REPAIRVEHICLE
|
||||
class ACE_Cargo {
|
||||
class Cargo {
|
||||
class ACE_Wheel {
|
||||
type = "ACE_Wheel";
|
||||
amount = 1;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
class Tank: LandVehicle {
|
||||
|
@ -5,3 +5,20 @@
|
||||
|
||||
// wheels
|
||||
["setWheelHitPointDamage", {(_this select 0) setHitPointDamage [_this select 1, _this select 2]}] call EFUNC(common,addEventHandler);
|
||||
|
||||
if (isServer) then {
|
||||
["SettingsInitialized", {
|
||||
GVAR(settingInitted) = true; // Stop collecting in FUNC(addSpareParts)
|
||||
|
||||
// Exit if adding spare parts disabled and clean collection
|
||||
if (!GVAR(addSpareParts)) exitWith {GVAR(addSparePartsCollection) = nil};
|
||||
|
||||
// Add spare parts to vehicles in collection
|
||||
{
|
||||
[_x] call FUNC(addSpareParts);
|
||||
} forEach GVAR(addSparePartsCollection);
|
||||
|
||||
// Clean collection
|
||||
GVAR(addSparePartsCollection) = nil;
|
||||
}] call EFUNC(common,addEventHandler);
|
||||
};
|
||||
|
@ -3,6 +3,7 @@
|
||||
ADDON = false;
|
||||
|
||||
PREP(addRepairActions);
|
||||
PREP(addSpareParts);
|
||||
PREP(canMiscRepair);
|
||||
PREP(canRemove);
|
||||
PREP(canRepair);
|
||||
@ -24,6 +25,7 @@ PREP(isEngineer);
|
||||
PREP(isInRepairFacility);
|
||||
PREP(isNearRepairVehicle);
|
||||
PREP(isRepairVehicle);
|
||||
PREP(moduleAddSpareParts);
|
||||
PREP(moduleAssignEngineer);
|
||||
PREP(moduleAssignRepairVehicle);
|
||||
PREP(moduleAssignRepairFacility);
|
||||
@ -38,4 +40,6 @@ PREP(spawnObject);
|
||||
PREP(useItem);
|
||||
PREP(useItems);
|
||||
|
||||
GVAR(addSparePartsCollection) = [];
|
||||
|
||||
ADDON = true;
|
||||
|
47
addons/repair/functions/fnc_addSpareParts.sqf
Normal file
47
addons/repair/functions/fnc_addSpareParts.sqf
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Author: Jonpas
|
||||
* Adds spare parts to the vehicle. Before SettingsInitialized only collect for later execution.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Vehicle <OBJECT>
|
||||
* 1: Amount <NUMBER> (default: 1)
|
||||
* 2: Spare Part Classname <STRING> (default: "")
|
||||
* 3: Force (add even if setting is disabled) <BOOL> (default: false)
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [vehicle] call ace_repair_fnc_addSpareParts
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_part"];
|
||||
params ["_vehicle", ["_amount", 1], ["_part", ""], ["_force", false]];
|
||||
TRACE_2("params",_vehicle,_amount);
|
||||
|
||||
// Exit if ace_cargo is not loaded
|
||||
if !(["ace_cargo"] call EFUNC(common,isModLoaded)) exitWith {};
|
||||
|
||||
// Collect until SettingsInitialized
|
||||
if (isNil QGVAR(settingInitted)) exitWith {
|
||||
if !(_vehicle in GVAR(addSparePartsCollection)) then {
|
||||
GVAR(addSparePartsCollection) pushBack _vehicle;
|
||||
};
|
||||
};
|
||||
|
||||
// Exit if not forced and add spare parts is disabled (after settings initted to make sure it really is)
|
||||
if (!_force && !GVAR(addSpareParts)) exitWith {};
|
||||
|
||||
// Select appropriate part
|
||||
if (_part == "") then {
|
||||
if (_vehicle isKindOf "Car") then { _part = "ACE_Wheel" };
|
||||
if (_vehicle isKindOf "Tank") then { _part = "ACE_Track" };
|
||||
};
|
||||
// Exit if no appropriate part
|
||||
if (_part == "") exitWith {};
|
||||
|
||||
// Load
|
||||
["AddCargoByClass", [_part, _vehicle, _amount]] call EFUNC(common,localEvent);
|
61
addons/repair/functions/fnc_moduleAddSpareParts.sqf
Normal file
61
addons/repair/functions/fnc_moduleAddSpareParts.sqf
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Author: Jonpas
|
||||
* Adds spare parts to a vehicle.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: The module logic <OBJECT>
|
||||
* 1: Synchronized units <ARRAY>
|
||||
* 2: Activated <BOOL>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* function = "ace_repair_fnc_moduleAssignRepairVehicle"
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#define DEBUG_MODE_FULL
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_logic"];
|
||||
|
||||
if (!isNull _logic) then {
|
||||
private ["_list", "_part", "_amount", "_nilCheckPassedList"];
|
||||
// Module settings
|
||||
_list = _logic getVariable ["List", ""];
|
||||
_part = _logic getVariable ["Part", 0];
|
||||
_amount = _logic getVariable ["Amount", 1];
|
||||
|
||||
// Parse list
|
||||
_nilCheckPassedList = "";
|
||||
{
|
||||
_x = [_x] call EFUNC(common,stringRemoveWhiteSpace);
|
||||
if !(isnil _x) then {
|
||||
if (_nilCheckPassedList == "") then {
|
||||
_nilCheckPassedList = _x;
|
||||
} else {
|
||||
_nilCheckPassedList = _nilCheckPassedList + "," + _x;
|
||||
};
|
||||
};
|
||||
} forEach ([_list, ","] call BIS_fnc_splitString);
|
||||
_list = "[" + _nilCheckPassedList + "]";
|
||||
_list = [] call compile _list;
|
||||
|
||||
// Add synchronized objects to list
|
||||
{
|
||||
_list pushBack _x;
|
||||
} forEach (synchronizedObjects _logic);
|
||||
|
||||
if (_list isEqualTo []) exitWith {};
|
||||
|
||||
TRACE_3("module info parsed",_list,_part,_amount);
|
||||
// Add spare parts
|
||||
{
|
||||
if (!isNil "_x" && {typeName _x == typeName objNull}) then {
|
||||
[_x, _amount, _part, true] call FUNC(addSpareParts);
|
||||
};
|
||||
} forEach _list;
|
||||
};
|
||||
|
||||
true
|
@ -31,4 +31,6 @@ if (!isServer) exitWith {};
|
||||
[_logic, QGVAR(fullRepairLocation), "fullRepairLocation"] call EFUNC(common,readSettingFromModule);
|
||||
[_logic, QGVAR(engineerSetting_fullRepair), "engineerSetting_fullRepair"] call EFUNC(common,readSettingFromModule);
|
||||
|
||||
[_logic, QGVAR(addSpareParts), "addSpareParts"] call EFUNC(common,readSettingFromModule);
|
||||
|
||||
diag_log text "[ACE]: Repair Module Initialized.";
|
||||
|
@ -118,6 +118,12 @@
|
||||
<English>Who can perform a full repair on a vehicle?</English>
|
||||
<Polish>Kto może przeprowadzić pełną naprawę pojazdu?</Polish>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Repair_addSpareParts_name">
|
||||
<English>Add Spare Parts</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Repair_addSpareParts_description">
|
||||
<English>Add spare parts to vehicles (requires Cargo component)?</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Repair_Repair">
|
||||
<English>Repair >></English>
|
||||
<German>Reparieren >></German>
|
||||
@ -656,5 +662,30 @@
|
||||
<English>Assign one or multiple objects as a repair Facility</English>
|
||||
<Polish>Przydziel klasę budynku naprawczego do jednego lub kilku budynków.</Polish>
|
||||
</Key>
|
||||
|
||||
<Key ID="STR_ACE_Repair_AddSpareParts_Module_DisplayName">
|
||||
<English>Add Spare Parts</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Repair_AddSpareParts_Module_Description">
|
||||
<English>Add spare parts to one or multiple objects</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Repair_AddSpareParts_List_DisplayName">
|
||||
<English>List</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Repair_AddSpareParts_List_Description">
|
||||
<English>List of objects that will get spare parts added, separated by commas.</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Repair_AddSpareParts_Part_DisplayName">
|
||||
<English>Part</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Repair_AddSpareParts_Part_Description">
|
||||
<English>Spare part.</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Repair_AddSpareParts_Amount_DisplayName">
|
||||
<English>Amount</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Repair_AddSpareParts_Amount_Description">
|
||||
<English>Number of selected spare parts.</English>
|
||||
</Key>
|
||||
</Package>
|
||||
</Project>
|
||||
|
Loading…
Reference in New Issue
Block a user