Repair - Add enable setting (#8070)

* Add enable setting

* Optimize eden expressions

Co-authored-by: Filip Maciejewski <veteran29@users.noreply.github.com>

* Add debug

* Update addons/repair/functions/fnc_addRepairActions.sqf

Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>

* Fix strange indent

* Optimize bool to number conversion

Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>

* Prevent run before setting is ready

* Move postInit to EH

* remove all transportRepair = 0

* remove requiredAddons

---------

Co-authored-by: Filip Maciejewski <veteran29@users.noreply.github.com>
Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>
Co-authored-by: LinkIsGrim <salluci.lovi@gmail.com>
This commit is contained in:
Dystopian 2023-07-29 07:53:05 +03:00 committed by GitHub
parent 7ef9d19bc5
commit 14e92dfb7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 129 additions and 197 deletions

View File

@ -1,9 +0,0 @@
class CfgActions {
class None;
class Repair: None {
show = 0;
};
class RepairVehicle: None {
show = 0;
};
};

View File

@ -1,7 +1,8 @@
#define VANILLA_ISREPAIRVEHICLE (parseNumber (getRepairCargo _this > 0))
#define GET_NUMBER(config,default) (if (isNumber (config)) then {getNumber (config)} else {default})
#define DEFAULT_ISENGINEER ([ARR_2(0,1)] select (_this getUnitTrait 'engineer'))
#define DEFAULT_ISREPAIRVEHICLE GET_NUMBER(configOf _this >> QQGVAR(canRepair),0)
#define DEFAULT_ISREPAIRVEHICLE GET_NUMBER(configOf _this >> QQGVAR(canRepair),VANILLA_ISREPAIRVEHICLE)
class ctrlToolbox;
@ -69,7 +70,7 @@ class Cfg3DEN {
property = QGVAR(editorLoadedTracks);
control = "Edit";
expression = "_this setVariable ['%s',_value];";
defaultValue = "[0,1] select (_this isKindOf 'Tank')"; // must match pre init script
defaultValue = "parseNumber (_this isKindOf 'Tank')"; // must match post init script
validate = "number";
condition = "objectHasInventoryCargo";
typeName = "NUMBER";
@ -78,7 +79,7 @@ class Cfg3DEN {
displayName = CSTRING(editorLoadedWheels);
tooltip = CSTRING(editorLoadedWheels_tooltip);
property = QGVAR(editorLoadedWheels);
defaultValue = "[0,1] select (_this isKindOf 'Car')"; // must match pre init script
defaultValue = "parseNumber (_this isKindOf 'Car')"; // must match post init script
};
};
};

View File

@ -3,10 +3,6 @@
class ACE_MainActions { \
class GVAR(Repair) { \
displayName = CSTRING(Repair); \
condition = "true"; \
statement = ""; \
runOnHover = 1; \
showDisabled = 0; \
icon = "\A3\ui_f\data\igui\cfg\actions\repair_ca.paa"; \
distance = 4; \
exceptions[] = {"isNotSwimming", "isNotOnLadder"}; \
@ -418,37 +414,6 @@ class CfgVehicles {
};
};
// disable vanilla repair
// "getNumber (_x >> ""transportRepair"") > 0" configClasses (configFile >> "CfgVehicles")
class ReammoBox_F;
class Land_RepairDepot_01_base_F: ReammoBox_F { // TanksDLC - Repair Depo Thing
GVAR(canRepair) = 1;
transportRepair = 0;
};
class Van_02_base_F;
class Van_02_service_base_F: Van_02_base_F { // OrangeDLC
GVAR(canRepair) = 1;
transportRepair = 0;
};
class Slingload_01_Base_F;
class B_Slingload_01_Repair_F: Slingload_01_Base_F {
GVAR(canRepair) = 1;
transportRepair = 0;
};
class Heli_Transport_04_base_F;
class O_Heli_Transport_04_repair_F: Heli_Transport_04_base_F {
GVAR(canRepair) = 1;
transportRepair = 0;
};
class Pod_Heli_Transport_04_base_F;
class Land_Pod_Heli_Transport_04_repair_F: Pod_Heli_Transport_04_base_F {
GVAR(canRepair) = 1;
transportRepair = 0;
};
class Heli_Transport_02_base_F;
class I_Heli_Transport_02_F: Heli_Transport_02_base_F {
GVAR(hitpointPositions)[] = {{"HitVRotor", {-1,-9.4,1.8}}, {"HitHRotor", {0,1.8,1.3}}};
@ -460,41 +425,10 @@ class CfgVehicles {
};
class B_APC_Tracked_01_base_F;
class B_APC_Tracked_01_CRV_F: B_APC_Tracked_01_base_F {
GVAR(canRepair) = 1;
transportRepair = 0;
};
class B_APC_Tracked_01_AA_F: B_APC_Tracked_01_base_F {
GVAR(hitpointPositions)[] = {{"HitTurret", {0,-2,0}}};
};
class Offroad_01_base_F;
class Offroad_01_repair_base_F: Offroad_01_base_F {
GVAR(canRepair) = 1;
transportRepair = 0;
};
class B_Truck_01_mover_F;
class B_Truck_01_Repair_F: B_Truck_01_mover_F {
GVAR(canRepair) = 1;
transportRepair = 0;
};
class B_Truck_01_fuel_F: B_Truck_01_mover_F { // the fuel hemet apparently can repair. GJ BI
transportRepair = 0;
};
class Truck_02_base_F;
class Truck_02_box_base_F: Truck_02_base_F {
GVAR(canRepair) = 1;
transportRepair = 0;
};
class Truck_02_medical_base_F: Truck_02_box_base_F {
GVAR(canRepair) = 0;
};
class Car_F: Car {
class HitPoints;
};
@ -514,10 +448,6 @@ class CfgVehicles {
};
};
};
class O_Truck_03_repair_F: Truck_03_base_F {
GVAR(canRepair) = 1;
transportRepair = 0;
};
class Quadbike_01_base_F: Car_F {
GVAR(hitpointPositions)[] = { {"HitEngine", {0, 0.5, -0.7}}, {"HitFuel", {0, 0, -0.5}} };

View File

@ -1,20 +1,86 @@
#include "script_component.hpp"
[QGVAR(setVehicleDamage), {_this call FUNC(setDamage)}] call CBA_fnc_addEventHandler;
[QGVAR(setVehicleHitPointDamage), {_this call FUNC(setHitPointDamage)}] call CBA_fnc_addEventHandler;
["CBA_settingsInitialized", {
// wheels
[QGVAR(setWheelHitPointDamage), {
params ["_object", "_hitPoint", "_damage"];
private _damageDisabled = !isDamageAllowed _object;
if !GVAR(enabled) exitWith {};
if (_damageDisabled) then {
_object allowDamage true;
[QGVAR(setVehicleDamage), {_this call FUNC(setDamage)}] call CBA_fnc_addEventHandler;
[QGVAR(setVehicleHitPointDamage), {_this call FUNC(setHitPointDamage)}] call CBA_fnc_addEventHandler;
[QGVAR(setWheelHitPointDamage), {
params ["_object", "_hitPoint", "_damage"];
private _damageDisabled = !isDamageAllowed _object;
if (_damageDisabled) then {
_object allowDamage true;
};
_object setHitPointDamage [_hitPoint, _damage];
if (_damageDisabled) then {
_object allowDamage false;
};
}] call CBA_fnc_addEventHandler;
// placed in editor static objects don't trigger init
{
if (local _x && {getRepairCargo _x > 0}) then {
_x setRepairCargo 0;
TRACE_3("setRepairCargo static",_x,typeOf _x,getRepairCargo _x);
};
} forEach allMissionObjects "Static";
["All", "InitPost", {
params ["_vehicle"];
if !(local _vehicle && {getRepairCargo _vehicle > 0}) exitWith {};
_vehicle setRepairCargo 0;
TRACE_3("setRepairCargo vehicle",_vehicle,typeOf _vehicle,getRepairCargo _vehicle);
}, true, ["Man"], true] call CBA_fnc_addClassEventHandler;
["CAManBase", "InitPost", {
params ["_unit"];
if !(local _unit && {_unit getUnitTrait "engineer"}) exitWith {};
_unit setUnitTrait ["engineer", false];
if (_unit getVariable ["ACE_IsEngineer", -1] isEqualTo -1) then {
_unit setVariable ["ACE_IsEngineer", true, true];
};
TRACE_3("setUnitTrait",_unit,typeOf _unit,_unit getUnitTrait "engineer");
}, true, [], true] call CBA_fnc_addClassEventHandler;
GVAR(allToolKits) = call (uiNamespace getVariable QGVAR(allToolKits));
["ACE_RepairItem_Base", "killed", {
params ["_object"];
[{deleteVehicle _this}, _object, 5] call CBA_fnc_waitAndExecute;
}, true, [], true] call CBA_fnc_addClassEventHandler;
// load tracks and wheels
if (isServer) then {
private _fnc_addSpareItems = {
if (!GVAR(addSpareParts)) exitWith {};
params ["_vehicle"];
private _spareTracks = _vehicle getVariable QGVAR(editorLoadedTracks);
if (isNil "_spareTracks") then {
_spareTracks = parseNumber (_vehicle isKindOf "Tank"); // must match eden attribute default
};
if (_spareTracks > 0) then {
[_vehicle, _spareTracks, "ACE_Track"] call FUNC(addSpareParts);
};
private _spareWheels = _vehicle getVariable QGVAR(editorLoadedWheels);
if (isNil "_spareWheels") then {
_spareWheels = parseNumber (_vehicle isKindOf "Car"); // must match eden attribute default
};
if (_spareWheels > 0) then {
[_vehicle, _spareWheels, "ACE_Wheel"] call FUNC(addSpareParts);
};
};
["Tank", "initPost", _fnc_addSpareItems, true, [], true] call CBA_fnc_addClassEventHandler;
["Car", "initPost", _fnc_addSpareItems, true, [], true] call CBA_fnc_addClassEventHandler;
};
_object setHitPointDamage [_hitPoint, _damage];
if (_damageDisabled) then {
_object allowDamage false;
};
}] call CBA_fnc_addEventHandler;

View File

@ -8,39 +8,4 @@ PREP_RECOMPILE_END;
#include "initSettings.sqf"
GVAR(allToolKits) = call (uiNamespace getVariable QGVAR(allToolKits));
["ACE_RepairItem_Base", "killed", {
params ["_object"];
[{deleteVehicle _this}, _object, 5] call CBA_fnc_waitAndExecute;
}] call CBA_fnc_addClassEventHandler;
// load tracks and wheels
if (isServer) then {
private _fnc_addSpareItems = {
if (!GVAR(addSpareParts)) exitWith {};
params ["_vehicle"];
private _spareTracks = _vehicle getVariable QGVAR(editorLoadedTracks);
if (isNil "_spareTracks") then {
_spareTracks = [0, 1] select (_vehicle isKindOf "Tank"); // must match eden attribute default
};
if (_spareTracks > 0) then {
[_vehicle, _spareTracks, "ACE_Track"] call FUNC(addSpareParts);
};
private _spareWheels = _vehicle getVariable QGVAR(editorLoadedWheels);
if (isNil "_spareWheels") then {
_spareWheels = [0, 1] select (_vehicle isKindOf "Car"); // must match eden attribute default
};
if (_spareWheels > 0) then {
[_vehicle, _spareWheels, "ACE_Wheel"] call FUNC(addSpareParts);
};
};
["Tank", "initPost", _fnc_addSpareItems] call CBA_fnc_addClassEventHandler;
["Car", "initPost", _fnc_addSpareItems] call CBA_fnc_addClassEventHandler;
};
ADDON = true;

View File

@ -16,7 +16,6 @@ class CfgPatches {
#include "ACE_Repair.hpp"
#include "ACE_Settings.hpp"
#include "CfgActions.hpp"
#include "CfgEden.hpp"
#include "CfgEventHandlers.hpp"
#include "CfgMoves.hpp"

View File

@ -15,7 +15,11 @@
* Public: No
*/
if (!hasInterface) exitWith {};
if !(EGVAR(common,settingsInitFinished)) exitWith {
EGVAR(common,runAtSettingsInitialized) pushBack [FUNC(addRepairActions), _this];
};
if !(hasInterface && {GVAR(enabled)}) exitWith {};
params ["_vehicle"];
private _type = typeOf _vehicle;

View File

@ -10,20 +10,32 @@
* Is inside a repair facility <BOOL>
*
* Example:
* [unit] call ace_repair_fnc_isInRepairFacility
* player call ace_repair_fnc_isInRepairFacility
*
* Public: Yes
*/
#define CHECK_OBJECTS(var) ((var) findIf {(_x getVariable ["ACE_isRepairFacility", getNumber (configOf _x >> QGVAR(canRepair))] > 0) && {!(_x isKindOf "AllVehicles")} && {alive _x}} != -1)
#define CHECK_OBJECTS(var) ((var) findIf _checkObject != -1)
params [["_object", objNull, [objNull]]];
TRACE_1("params",_object);
params [["_unit", objNull, [objNull]]];
TRACE_1("params",_unit);
private _checkObject = {
private _config = configOf _x;
private _canRepair = getNumber (_config >> QGVAR(canRepair));
if (_canRepair == 0) then {
_canRepair = getNumber (_config >> "transportRepair");
};
private _fnc_check = {
private _position = _object modelToWorldVisual [0, 0, eyePos _object select 2];
CHECK_OBJECTS(lineIntersectsWith [ARR_3(_position, _position vectorAdd [ARR_3(0, 0, 10)], _object)]) || {CHECK_OBJECTS(_object nearObjects 7.5)}
_x getVariable ["ACE_isRepairFacility", _canRepair > 0] in [1, true] // can be integer or boolean
&& {!(_x isKindOf "AllVehicles")} // check if it's not repair vehicle
&& {alive _x}
};
[[], _fnc_check, _object, QGVAR(inRepairFacilityCache), IN_REPAIR_FACILITY_CACHE_EXPIRY] call EFUNC(common,cachedCall);
private _fnc_check = {
private _position = _unit modelToWorldVisual [0, 0, eyePos _unit select 2];
CHECK_OBJECTS(lineIntersectsWith [ARR_3(_position, _position vectorAdd [ARR_3(0, 0, 10)], _unit)])
|| {CHECK_OBJECTS(_unit nearObjects 7.5)}
};
[[], _fnc_check, _unit, QGVAR(inRepairFacilityCache), IN_REPAIR_FACILITY_CACHE_EXPIRY] call EFUNC(common,cachedCall);

View File

@ -10,7 +10,7 @@
* Is engineering vehicle <BOOL>
*
* Example:
* [vehicle] call ace_repair_fnc_isRepairVehicle
* cursorObject call ace_repair_fnc_isRepairVehicle
*
* Public: Yes
*/
@ -20,6 +20,11 @@ TRACE_1("params",_vehicle);
if (_vehicle isKindOf "CAManBase") exitWith {false};
private _config = configOf _vehicle;
private _canRepair = getNumber (_config >> QGVAR(canRepair));
if (_canRepair == 0) then {
_canRepair = getNumber (_config >> "transportRepair");
};
// Value can be integer or boolean
private _value = _vehicle getVariable ["ACE_isRepairVehicle", getNumber (configOf _vehicle >> QGVAR(canRepair))];
private _value = _vehicle getVariable ["ACE_isRepairVehicle", _canRepair > 0];
_value in [1, true] // return

View File

@ -1,5 +1,15 @@
private _category = format ["ACE %1", LLSTRING(Repair)];
[
QGVAR(enabled), "CHECKBOX",
ELSTRING(common,Enabled),
_category,
true,
true,
{[QGVAR(enabled), _this] call EFUNC(common,cbaSettings_settingChanged)},
true
] call CBA_fnc_addSetting;
[
QGVAR(displayTextOnRepair), "CHECKBOX",
[LSTRING(SettingDisplayTextName), LSTRING(SettingDisplayTextDesc)],

View File

@ -173,11 +173,6 @@ class CfgVehicles {
EGVAR(medical,medicClass) = 1;
};
class gm_ural4320_repair_base: gm_ural4320_base {
transportRepair = 0;
EGVAR(repair,canRepair) = 1;
};
// WEST
@ -222,12 +217,6 @@ class CfgVehicles {
EGVAR(refuel,fuelCapacity) = 390;
};
class gm_fuchsa0_base;
class gm_fuchsa0_engineer_base: gm_fuchsa0_base {
transportRepair = 0;
EGVAR(repair,canRepair) = 1;
};
class gm_luchs_base: gm_wheeled_APC_base {
EGVAR(refuel,fuelCapacity) = 500;
EGVAR(cookoff,cookoffSelections)[] = {"mainturret_hatch", "commanderturret_hatch"};
@ -315,11 +304,6 @@ class CfgVehicles {
};
class gm_m113a1dk_base;
class gm_m113a1dk_engineer_base: gm_m113a1dk_base {
transportRepair = 0;
EGVAR(repair,canRepair) = 1;
};
class gm_m113a1dk_medic_base: gm_m113a1dk_base {
EGVAR(medical,medicClass) = 1;
};

View File

@ -6,7 +6,7 @@ class CfgPatches {
units[] = {};
weapons[] = {};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_csw", "ace_explosives", "ace_refuel", "ace_repair", "gm_core"};
requiredAddons[] = {"ace_csw", "ace_explosives", "ace_refuel", "gm_core"};
author = ECSTRING(common,ACETeam);
authors[] = {"sancron", "nomisum"};
url = ECSTRING(main,URL);

View File

@ -156,10 +156,6 @@ class CfgVehicles {
EGVAR(refuel,hooks)[] = {{-0.05,-3.6,-0.45}};
EGVAR(refuel,fuelCargo) = 10000;
};
class RHS_Ural_Repair_MSV_01: RHS_Ural_Support_MSV_Base_01 {
transportRepair = 0;
EGVAR(repair,canRepair) = 1;
};
class RHS_Ural_Ammo_Base: RHS_Ural_Base {
EGVAR(rearm,defaultSupply) = 1200;
};
@ -175,12 +171,7 @@ class CfgVehicles {
EGVAR(refuel,fuelCapacity) = 210;
};
class rhs_gaz66_vmf: rhs_truck {};
class rhs_gaz66_repair_base: rhs_gaz66_vmf {
transportRepair = 0;
EGVAR(repair,canRepair) = 1;
};
class rhs_gaz66_vmf;
class rhs_gaz66_ammo_base: rhs_gaz66_vmf {
EGVAR(rearm,defaultSupply) = 1200;
};

View File

@ -7,7 +7,7 @@ class CfgPatches {
units[] = {};
weapons[] = {QGVAR(2b14_carry), QGVAR(nsv_carry), QGVAR(kord_carry), QGVAR(ags30_carry), QGVAR(spg9_carry), QGVAR(spg9m_carry), QGVAR(metis_carry), QGVAR(kornet_carry)};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_explosives", "ace_csw", "ace_refuel", "ace_repair", "rhs_main_loadorder"};
requiredAddons[] = {"ace_explosives", "ace_csw", "ace_refuel", "rhs_main_loadorder"};
author = ECSTRING(common,ACETeam);
authors[] = {"Ruthberg", "GitHawk", "BaerMitUmlaut", "commy2", "Skengman2"};
url = ECSTRING(main,URL);

View File

@ -202,8 +202,6 @@ class CfgVehicles {
transportFuel = 0;
EGVAR(refuel,hooks)[] = {{1.1,0.9,-1.2}};
EGVAR(refuel,fuelCargo) = 900; // 45 jerrycans
transportRepair = 0;
EGVAR(repair,canRepair) = 1;
};
class rhsusf_HEMTT_A4_base: Truck_01_base_F {};
@ -234,21 +232,6 @@ class CfgVehicles {
EGVAR(refuel,fuelCargo) = 10000;
};
class rhsusf_M977A4_REPAIR_usarmy_wd: rhsusf_M977A4_usarmy_wd {
transportRepair = 0;
EGVAR(repair,canRepair) = 1;
};
class rhsusf_M977A4_REPAIR_BKIT_usarmy_wd: rhsusf_M977A4_BKIT_usarmy_wd {
transportRepair = 0;
EGVAR(repair,canRepair) = 1;
};
class rhsusf_M977A4_REPAIR_BKIT_M2_usarmy_wd: rhsusf_M977A4_BKIT_M2_usarmy_wd {
transportRepair = 0;
EGVAR(repair,canRepair) = 1;
};
class APC_Tracked_02_base_F: Tank_F {};
class rhsusf_m113tank_base: APC_Tracked_02_base_F {
EGVAR(map,vehicleLightColor)[] = {0,1,0,0.1};

View File

@ -7,7 +7,7 @@ class CfgPatches {
units[] = {};
weapons[] = {QGVAR(m252_carry), QGVAR(m2_carry), QGVAR(mk19_carry), QGVAR(tow_carry)};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_explosives", "ace_javelin", "ace_refuel", "ace_repair", "ace_csw", "rhsusf_main_loadorder"};
requiredAddons[] = {"ace_explosives", "ace_javelin", "ace_refuel", "ace_csw", "rhsusf_main_loadorder"};
author = ECSTRING(common,ACETeam);
authors[] = {"Ruthberg", "GitHawk", "BaerMitUmlaut", "Fyuran"};
url = ECSTRING(main,URL);

View File

@ -9,11 +9,6 @@ class vn_wheeled_m54_fuel_base: vn_wheeled_m54_cab_base {
EGVAR(refuel,hooks)[] = {{-1.15, -2.3, 0.28}};
EGVAR(refuel,fuelCargo) = 4542;
};
class vn_wheeled_m54_03_base;
class vn_wheeled_m54_repair_base: vn_wheeled_m54_03_base {
transportRepair = 0;
EGVAR(repair,canRepair) = 1;
};
class vn_wheeled_m54_01_base;
class vn_wheeled_m54_ammo_base: vn_wheeled_m54_01_base {
EGVAR(rearm,defaultSupply) = 1200;
@ -34,10 +29,6 @@ class vn_wheeled_z157_fuel_base: vn_wheeled_z157_base {
EGVAR(refuel,hooks)[] = {{-1.36, -3.575, -0.4}};
EGVAR(refuel,fuelCargo) = 4000;
};
class vn_wheeled_z157_repair_base: vn_wheeled_z157_base {
transportRepair = 0;
EGVAR(repair,canRepair) = 1;
};
class vn_wheeled_z157_01_base;
class vn_wheeled_z157_ammo_base: vn_wheeled_z157_01_base {
EGVAR(rearm,defaultSupply) = 1200;