Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repair - Add enable setting #8070

Merged
merged 13 commits into from
Jul 29, 2023
9 changes: 0 additions & 9 deletions addons/repair/CfgActions.hpp

This file was deleted.

7 changes: 4 additions & 3 deletions addons/repair/CfgEden.hpp
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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";
Expand All @@ -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
};
};
};
Expand Down
68 changes: 0 additions & 68 deletions addons/repair/CfgVehicles.hpp
Dystopian marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -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"}; \
Expand Down Expand Up @@ -403,39 +399,10 @@ class CfgVehicles {
editorPreview = QPATHTOF(data\preview_wheel.jpg);
};

// 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 Helicopter_Base_H;
class Heli_Transport_04_base_F: Helicopter_Base_H {
GVAR(hitpointGroups)[] = { {"HitEngine", {"HitEngine1", "HitEngine2"}} };
};
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 {
Expand All @@ -448,41 +415,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;
};
Expand All @@ -502,10 +438,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}} };
Expand Down
63 changes: 61 additions & 2 deletions addons/repair/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "script_component.hpp"

if !GVAR(enabled) exitWith {};
Dystopian marked this conversation as resolved.
Show resolved Hide resolved

[QGVAR(setVehicleDamage), {_this call FUNC(setDamage)}] call CBA_fnc_addEventHandler;
[QGVAR(setVehicleHitPointDamage), {_this call FUNC(setHitPointDamage)}] call CBA_fnc_addEventHandler;

// wheels
[QGVAR(setWheelHitPointDamage), {
params ["_object", "_hitPoint", "_damage"];
private _damageDisabled = !isDamageAllowed _object;
Expand All @@ -18,3 +18,62 @@
_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;
};
} forEach allMissionObjects "Static";

["All", "InitPost", {
params ["_vehicle"];
if (local _vehicle && {getRepairCargo _vehicle > 0}) then {
_vehicle setRepairCargo 0;
};
}, true, ["Man"], true] call CBA_fnc_addClassEventHandler;

["CAManBase", "InitPost", {
params ["_unit"];
if (local _unit && {_unit getUnitTrait "engineer"}) then {
_unit setUnitTrait ["engineer", false];
if (-1 isEqualTo (_unit getVariable ["ACE_IsEngineer", -1])) then {
Dystopian marked this conversation as resolved.
Show resolved Hide resolved
Dystopian marked this conversation as resolved.
Show resolved Hide resolved
_unit setVariable ["ACE_IsEngineer", true, true];
};
};
}, true, [], true] call CBA_fnc_addClassEventHandler;


["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 = [0, 1] select (_vehicle isKindOf "Tank"); // must match eden attribute default
Dystopian marked this conversation as resolved.
Show resolved Hide resolved
};
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
Dystopian marked this conversation as resolved.
Show resolved Hide resolved
};
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;
};
33 changes: 0 additions & 33 deletions addons/repair/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,4 @@ PREP_RECOMPILE_END;

#include "initSettings.sqf"

["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;
1 change: 0 additions & 1 deletion addons/repair/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion addons/repair/functions/fnc_addRepairActions.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* Public: No
*/

if (!hasInterface) exitWith {};
if (!hasInterface || !GVAR(enabled)) exitWith {};
Dystopian marked this conversation as resolved.
Show resolved Hide resolved

params ["_vehicle"];
private _type = typeOf _vehicle;
Expand Down
2 changes: 1 addition & 1 deletion addons/repair/functions/fnc_getPostRepairDamage.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* 0: Unit that does the repairing <OBJECT>
*
* Return Value:
* 0: Rpair Damage Threshold <NUMBER>
* 0: Repair Damage Threshold <NUMBER>
*
* Example:
* [unit] call ace_repair_fnc_getPostRepairDamage
Expand Down
9 changes: 7 additions & 2 deletions addons/repair/functions/fnc_isInRepairFacility.sqf
Dystopian marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Is inside a repair facility <BOOL>
*
* Example:
* [unit] call ace_repair_fnc_isInRepairFacility
* player call ace_repair_fnc_isInRepairFacility
*
* Public: Yes
*/
Expand All @@ -22,8 +22,13 @@ private _position = getPosASL _object;
private _isInBuilding = false;

private _checkObject = {
private _config = configOf _x;
private _canRepair = getNumber (_config >> QGVAR(canRepair));
if (_canRepair == 0) then {
_canRepair = getNumber (_config >> "transportRepair");
};
if (
_x getVariable ["ACE_isRepairFacility", getNumber (configOf _x >> QGVAR(canRepair))] > 0
_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}
) exitWith {
Expand Down
9 changes: 7 additions & 2 deletions addons/repair/functions/fnc_isRepairVehicle.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Is engineering vehicle <BOOL>
*
* Example:
* [vehicle] call ace_repair_fnc_isRepairVehicle
* cursorObject call ace_repair_fnc_isRepairVehicle
*
* Public: Yes
*/
Expand All @@ -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
Loading