Repair - Add wheel patching (#8835)

* patch wheels on vehicles

* all tire patching working

Co-authored-by: mp-singh <mandeep@mandeepsingh.ca>

* doc

* remove unused string

* Update CfgVehicles.hpp

* use strintable

* setting for where the wheel can be patched

* localize

* Update stringtable.xml

* can't patch a missing tire

* removal > replacement

* Update addons/repair/initSettings.sqf

Co-authored-by: PabstMirror <pabstmirror@gmail.com>

* Apply suggestions from code review

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

* Apply suggestions from code review

Co-authored-by: PabstMirror <pabstmirror@gmail.com>

* Apply suggestions from code review

Co-authored-by: Jouni Järvinen <rautamiekka@users.noreply.github.com>

* patch icon

* use PATCH_WHEEL_STEP_TIME

* fix wheel translation

---------

Co-authored-by: mp-singh <mandeep@mandeepsingh.ca>
Co-authored-by: PabstMirror <pabstmirror@gmail.com>
Co-authored-by: Filip Maciejewski <veteran29@users.noreply.github.com>
Co-authored-by: Jouni Järvinen <rautamiekka@users.noreply.github.com>
This commit is contained in:
BrettMayson 2023-06-28 04:39:08 -06:00 committed by GitHub
parent f434549faf
commit 10c1085aba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 316 additions and 18 deletions

View File

@ -30,6 +30,17 @@ class ACE_Repair {
callbackSuccess = QFUNC(doRemoveWheel);
claimObjects[] = {};
};
class PatchWheel: ReplaceWheel {
displayName = CSTRING(PatchWheel);
displayNameProgress = CSTRING(PatchingWheel);
condition = QFUNC(canPatchWheel);
repairingTime = QFUNC(getPatchWheelTime);
callbackProgress = QFUNC(doPatchWheelProgress);
items = QGVAR(patchWheelRequiredItems);
requiredEngineer = QGVAR(engineerSetting_Wheel);
callbackSuccess = "";
claimObjects[] = {};
};
class MiscRepair: ReplaceWheel {
displayName = CSTRING(Repairing); // let's make empty string an auto generated string
displayNameProgress = CSTRING(RepairingHitPoint);

View File

@ -403,6 +403,19 @@ class CfgVehicles {
};
editorPreview = QPATHTOF(data\preview_wheel.jpg);
class ACE_Actions: ACE_Actions {
class ACE_MainActions: ACE_MainActions {
class GVAR(Patch) {
displayName = CSTRING(PatchWheel);
distance = 4;
condition = QUOTE([ARR_2(_player, _target)] call FUNC(canPatchRemovedWheel));
statement = QUOTE([ARR_2(_player, _target)] call FUNC(patchRemovedWheel));
exceptions[] = {"isNotDragging", "isNotCarrying", "isNotOnLadder", "isNotSwimming", "isNotSitting"};
icon = QPATHTOF(ui\patch_ca.paa);
};
};
};
};
// disable vanilla repair

View File

@ -2,12 +2,15 @@
PREP(addRepairActions);
PREP(addSpareParts);
PREP(canMiscRepair);
PREP(canPatchRemovedWheel);
PREP(canPatchWheel);
PREP(canRemove);
PREP(canRepair);
PREP(canRepairTrack);
PREP(canReplaceTrack);
PREP(canReplaceWheel);
PREP(doFullRepair);
PREP(doPatchWheelProgress);
PREP(doRemoveTrack);
PREP(doRemoveWheel);
PREP(doRepair);
@ -16,6 +19,7 @@ PREP(doReplaceTrack);
PREP(doReplaceWheel);
PREP(getClaimObjects);
PREP(getHitPointString);
PREP(getPatchWheelTime);
PREP(getPostRepairDamage);
PREP(getRepairItems);
PREP(getWheelHitPointsWithSelections);
@ -32,6 +36,7 @@ PREP(moduleAssignRepairVehicle);
PREP(moduleAssignRepairFacility);
PREP(moduleRepairSettings);
PREP(normalizeHitPoints);
PREP(patchRemovedWheel);
PREP(repair);
PREP(repair_failure);
PREP(repair_success);

View File

@ -56,14 +56,6 @@ private _turretPaths = ((fullCrew [_vehicle, "gunner", true]) + (fullCrew [_vehi
TRACE_3("Adding Wheel Actions",_hitpoint,_forEachIndex,_selection);
// An action to remove the wheel is required
private _name = format ["Remove_%1_%2", _forEachIndex, _hitpoint];
private _text = localize LSTRING(RemoveWheel);
private _condition = {[_this select 1, _this select 0, _this select 2 select 0, "RemoveWheel"] call DFUNC(canRepair)};
private _statement = {[_this select 1, _this select 0, _this select 2 select 0, "RemoveWheel"] call DFUNC(repair)};
private _action = [_name, _text, _icon, _statement, _condition, {}, [_hitpoint], _position, 2, nil, FUNC(modifySelectionInteraction)] call EFUNC(interact_menu,createAction);
[_type, 0, [], _action] call EFUNC(interact_menu,addActionToClass);
// An action to replace the wheel is required
_name = format ["Replace_%1_%2", _forEachIndex, _hitpoint];
_text = localize LSTRING(ReplaceWheel);
@ -72,6 +64,28 @@ private _turretPaths = ((fullCrew [_vehicle, "gunner", true]) + (fullCrew [_vehi
_action = [_name, _text, _icon, _statement, _condition, {}, [_hitpoint], _position, 2] call EFUNC(interact_menu,createAction);
[_type, 0, [], _action] call EFUNC(interact_menu,addActionToClass);
// Create a wheel interaction
private _root = format ["Wheel_%1_%2", _forEachIndex, _hitpoint];
private _action = [_root, localize LSTRING(Wheel), ["","#FFFFFF"], {}, {true}, {}, [_hitpoint], _position, 2, nil, LINKFUNC(modifySelectionInteraction)] call EFUNC(interact_menu,createAction);
[_type, 0, [], _action] call EFUNC(interact_menu,addActionToClass);
// An action to remove the wheel is required
private _name = format ["Remove_%1_%2", _forEachIndex, _hitpoint];
private _text = localize LSTRING(RemoveWheel);
private _condition = {[_this select 1, _this select 0, _this select 2 select 0, "RemoveWheel"] call DFUNC(canRepair)};
private _statement = {[_this select 1, _this select 0, _this select 2 select 0, "RemoveWheel"] call DFUNC(repair)};
private _action = [_name, _text, _icon, _statement, _condition, {}, [_hitpoint], _position, 2] call EFUNC(interact_menu,createAction);
[_type, 0, [_root], _action] call EFUNC(interact_menu,addActionToClass);
// An action to patch the wheel is required.
private _name = format ["Patch_%1_%2", _forEachIndex, _hitpoint];
private _patchIcon = QPATHTOF(ui\patch_ca.paa);
private _text = localize LSTRING(PatchWheel);
private _condition = {("vehicle" in GVAR(patchWheelLocation)) && {[_this select 1, _this select 0, _this select 2 select 0, "PatchWheel"] call DFUNC(canRepair)}};
private _statement = {[_this select 1, _this select 0, _this select 2 select 0, "PatchWheel"] call DFUNC(repair)};
private _action = [_name, _text, _patchIcon, _statement, _condition, {}, [_hitpoint], _position, 2] call EFUNC(interact_menu,createAction);
[_type, 0, [_root], _action] call EFUNC(interact_menu,addActionToClass);
_processedSelections pushBack _selection;
} else {
// Empty hitpoints don't contain enough information

View File

@ -0,0 +1,27 @@
#include "script_component.hpp"
/*
* Author: commy2, Brett Mayson
* Check if the unit can patch a wheel not on a vehicle.
*
* Arguments:
* 0: Unit that does the patching <OBJECT>
* 1: Wheel to patch <OBJECT>
*
* Return Value:
* Can patch wheel? <BOOL>
*
* Example:
* [unit, vehicle] call ace_repair_fnc_canPatchRemovedWheel
*
* Public: No
*/
params ["_unit", "_target"];
TRACE_2("params",_unit,_target);
if (GVAR(patchWheelEnabled) == -1) exitWith {false};
if !("ground" in GVAR(patchWheelLocation)) exitWith {false};
if ((GVAR(patchWheelRequiredItems) isEqualTo [ANY_TOOLKIT_FAKECLASS]) && {!([_unit, [GVAR(allToolKits)]] call FUNC(hasItems))}) exitWith {false};
if !([_unit, GVAR(patchWheelEnabled)] call FUNC(isEngineer)) exitWith {false};
(damage _target > GVAR(patchWheelMaximumRepair))

View File

@ -0,0 +1,31 @@
#include "script_component.hpp"
/*
* Author: commy2, Brett Mayson
* Check if the unit can patch given wheel of the vehicle.
*
* Arguments:
* 0: Unit that does the patching <OBJECT>
* 1: Vehicle to patch <OBJECT>
* 2: Selected wheel hitpoint <STRING>
*
* Return Value:
* Can patch wheel? <BOOL>
*
* Example:
* [unit, vehicle, "hitpoint"] call ace_repair_fnc_canPatchWheel
*
* Public: No
*/
params ["_unit", "_target", "_hitPoint"];
TRACE_3("params",_unit,_target,_hitPoint);
if (GVAR(patchWheelEnabled) == -1) exitWith {false};
private _damage = _target getHitPointDamage _hitPoint;
if (_damage == 1) exitWith {false};
if !([_unit, _target, ["isNotDragging", "isNotCarrying", "isNotOnLadder"]] call EFUNC(common,canInteractWith)) exitWith {false};
(_damage > GVAR(patchWheelMaximumRepair))

View File

@ -0,0 +1,35 @@
#include "script_component.hpp"
/*
* Author: commy2, Brett Mayson
* Called by repair action / progress bar. Raise events to set the new hitpoint damage.
*
* Arguments:
* 0: Unit that does the patching <OBJECT>
* 1: Vehicle to patch <OBJECT>
* 2: Selected wheel hitpoint <STRING>
*
* Return Value:
* Should patching continue? <BOOL>
*
* Example:
* [unit, vehicle, "hitpoint"] call ace_repair_fnc_doPatchWheelProgress
*
* Public: No
*/
params ["_args", "_elapsedTime", "_totalTime"];
_args params ["_unit", "_vehicle", "_hitPoint"];
TRACE_3("params",_unit,_vehicle,_hitPoint);
// get current hitpoint damage
private _hitPointDamage = _vehicle getHitPointDamage _hitPoint;
private _iterationsRemaining = ceil ((_hitPointDamage - GVAR(patchWheelMaximumRepair)) / PATCH_WHEEL_STEP_TIME) - 1;
if ((_totalTime - _elapsedTime) > _iterationsRemaining * GVAR(patchWheelTime)) exitWith {true};
_hitPointDamage = (_hitPointDamage - PATCH_WHEEL_STEP_TIME) max GVAR(patchWheelMaximumRepair);
// raise event to set the new hitpoint damage
[QGVAR(setWheelHitPointDamage), [_vehicle, _hitPoint, _hitPointDamage], _vehicle] call CBA_fnc_targetEvent;
(_hitPointDamage > GVAR(patchWheelMaximumRepair))

View File

@ -0,0 +1,25 @@
#include "script_component.hpp"
/*
* Author: Brett Mayson
* Calculate the time to patch the wheel
*
* Arguments:
* 0: Unit that does the patching <OBJECT>
* 1: Vehicle to patch <OBJECT>
* 2: Selected wheel hitpoint <STRING>
*
* Return Value:
* Patching time <NUMBER>
*
* Example:
* [unit, vehicle, "hitpoint"] call ace_repair_fnc_getPatchWheelTime
*
* Public: No
*/
params ["_unit", "_vehicle", "_hitPoint"];
// get current hitpoint damage
private _hitPointDamage = (_vehicle getHitPointDamage _hitPoint) - GVAR(patchWheelMaximumRepair);
ceil (_hitPointDamage / PATCH_WHEEL_STEP_TIME) * GVAR(patchWheelTime)

View File

@ -0,0 +1,39 @@
#include "script_component.hpp"
/*
* Author: Brett Mayson
* Patch a wheel that is not on a vehicle
*
* Arguments:
* 0: Unit that does the patching <OBJECT>
* 1: Wheel to patch <OBJECT>
*
* Return Value:
* None
*
* Example:
* [unit, vehicle] call ace_repair_fnc_patchRemovedWheel
*
* Public: No
*/
params ["_unit", "_target"];
[_unit, "Acts_carFixingWheel"] call EFUNC(common,doAnimation);
private _wheelDamage = (damage _target) - GVAR(patchWheelMaximumRepair);
[ceil (_wheelDamage / 0.05) * GVAR(patchWheelTime), [_target], {}, {}, LLSTRING(PatchingWheel), {
params ["_args"];
_args params ["_target"];
private _damage = damage _target;
private _iterationsRemaining = ceil ((_damage - GVAR(patchWheelMaximumRepair)) / 0.05) - 1;
if ((_totalTime - _elapsedTime) > _iterationsRemaining * GVAR(patchWheelTime)) exitWith {true};
_damage = (_damage - 0.05) max GVAR(patchWheelMaximumRepair);
_target setDamage _damage;
_damage > GVAR(patchWheelMaximumRepair)
}] call ace_common_fnc_progressBar;

View File

@ -25,6 +25,32 @@
{[QGVAR(engineerSetting_wheel), _this] call EFUNC(common,cbaSettings_settingChanged)}
] call CBA_fnc_addSetting;
[
QGVAR(patchWheelEnabled), "LIST",
[LSTRING(patchWheelEnabled_name), LSTRING(patchWheelEnabled_description)],
[localize ELSTRING(OptionsMenu,CategoryLogistics), localize "str_state_repair"],
[[-1,0,1,2],["str_player_none", LSTRING(engineerSetting_anyone), LSTRING(engineerSetting_EngineerOnly), LSTRING(engineerSetting_AdvancedOnly)],1], // default value
true // isGlobal
] call CBA_fnc_addSetting;
[
QGVAR(patchWheelRequiredItems),
"LIST",
[LSTRING(patchWheelRequiredItems_DisplayName), LSTRING(patchWheelRequiredItems_Description)],
[localize ELSTRING(OptionsMenu,CategoryLogistics), localize "str_state_repair"],
[[[], [ANY_TOOLKIT_FAKECLASS]], ["STR_A3_None", "STR_A3_CfgWeapons_Toolkit0"], 1],
true
] call CBA_fnc_addSetting;
[
QGVAR(patchWheelLocation),
"LIST",
[LSTRING(patchWheelLocation_DisplayName), LSTRING(patchWheelLocation_Description)],
[localize ELSTRING(OptionsMenu,CategoryLogistics), localize "str_state_repair"],
[[["ground", "vehicle"], ["vehicle"], ["ground"]], ["str_difficulty_any", LSTRING(patchWheelOnVehicle), LSTRING(patchWheelOnGround)], 0],
true
] call CBA_fnc_addSetting;
[
QGVAR(repairDamageThreshold), "SLIDER",
[LSTRING(repairDamageThreshold_name), LSTRING(repairDamageThreshold_description)],
@ -124,3 +150,22 @@
true, // isGlobal
{[QGVAR(autoShutOffEngineWhenStartingRepair), _this] call EFUNC(common,cbaSettings_settingChanged)}
] call CBA_fnc_addSetting;
[
QGVAR(patchWheelTime),
"SLIDER",
[LSTRING(patchWheelTime_DisplayName), LSTRING(patchWheelTime_Description)],
[localize ELSTRING(OptionsMenu,CategoryLogistics), localize "str_state_repair"],
[0.1, 60, 5, 1],
true
] call CBA_fnc_addSetting;
[
QGVAR(patchWheelMaximumRepair),
"SLIDER",
[LSTRING(patchWheelMaximumRepair_DisplayName), LSTRING(patchWheelMaximumRepair_Description)],
[localize ELSTRING(OptionsMenu,CategoryLogistics), localize "str_state_repair"],
[0, 1, 0.3, 1, true],
true
] call CBA_fnc_addSetting;

View File

@ -21,3 +21,5 @@
#define DAMAGE_COLOR_SCALE ["#FFFFFF", "#FFFF7E", "#FFEC4D", "#FFD52C", "#FCB121", "#FF9916", "#FF7D16", "#FF4400", "#FF0000"]
#define ANY_TOOLKIT_FAKECLASS QGVAR(anyToolKit)
#define PATCH_WHEEL_STEP_TIME 0.05

View File

@ -35,6 +35,11 @@
<Chinese>備用輪胎</Chinese>
<Turkish>Yedek Tekerlek</Turkish>
</Key>
<Key ID="STR_ACE_Repair_Wheel">
<English>Wheel</English>
<German>Rad</German>
<Spanish>Rueda</Spanish>
</Key>
<Key ID="STR_ACE_Repair_ReplaceWheel">
<English>Change Wheel</English>
<German>Reifen wechseln</German>
@ -1206,19 +1211,10 @@
<Turkish>Sadece Gelişmiş Mühendis</Turkish>
</Key>
<Key ID="STR_ACE_Repair_engineerSetting_Wheel_name">
<English>Allow Wheel</English>
<English>Allow Wheel Replacement</English>
<German>Erlaube Radwechsel</German>
<Polish>Wymiana kół</Polish>
<Portuguese>Permite rodas</Portuguese>
<Russian>Разрешить замену колес</Russian>
<Czech>Možnost Výměny Kol</Czech>
<Spanish>Permitir rueda</Spanish>
<Italian>Consenti Ruota</Italian>
<French>Roues autorisées pour</French>
<Japanese>タイヤを許可</Japanese>
<Korean>바퀴 허가</Korean>
<Chinesesimp>允许轮胎</Chinesesimp>
<Chinese>允許輪胎</Chinese>
</Key>
<Key ID="STR_ACE_Repair_engineerSetting_Wheel_description">
<English>Who can remove and replace wheels?</English>
@ -1235,6 +1231,14 @@
<Chinesesimp>谁可维修轮胎?</Chinesesimp>
<Chinese>誰可維修輪胎?</Chinese>
</Key>
<Key ID="STR_ACE_Repair_patchWheelEnabled_name">
<English>Allow Wheel Patching</English>
<German>Erlaube Radflicken</German>
</Key>
<Key ID="STR_ACE_Repair_patchWheelEnabled_description">
<English>Who can patch wheels?</English>
<German>Wer kann Radflicken durchführen?</German>
</Key>
<Key ID="STR_ACE_Repair_engineerSetting_Repair_name">
<English>Allow Repair</English>
<German>Erlaube Reperatur</German>
@ -1885,6 +1889,14 @@
<Chinesesimp>需要特定物品来移除/更换车轮</Chinesesimp>
<Chinese>需要特定物品來移除/更換車輪</Chinese>
</Key>
<Key ID="STR_ACE_Repair_patchWheelRequiredItems_DisplayName">
<English>Wheel Patch Requirements</English>
<German>Bedingungen für die Radflicken</German>
</Key>
<Key ID="STR_ACE_Repair_patchWheelRequiredItems_Description">
<English>Items required to patch a wheel.</English>
<German>Gegenstänge, die zum Reifenflicken benötigt werden.</German>
</Key>
<Key ID="STR_ACE_Repair_MiscRepairRequiredItems_DisplayName">
<English>Misc Repair Requirements</English>
<German>Sonstige Reparaturbedingungen</German>
@ -2050,5 +2062,39 @@
<Spanish>Apagar el motor automáticamente al efectuar una reparación</Spanish>
<Korean>수리 시 엔진을 자동으로 끕니다.</Korean>
</Key>
<Key ID="STR_ACE_Repair_PatchWheel">
<English>Patch Wheel</English>
<German>Radflicken</German>
</Key>
<Key ID="STR_ACE_Repair_PatchingWheel">
<English>Patching Wheel...</English>
<German>Radflicken...</German>
</Key>
<Key ID="STR_ACE_Repair_patchWheelTime_DisplayName">
<English>Patch wheel time</English>
</Key>
<Key ID="STR_ACE_Repair_patchWheelTime_Description">
<English>Time it takes to patch a wheel by 5%.</English>
</Key>
<Key ID="STR_ACE_Repair_patchWheelMaximumRepair_DisplayName">
<English>Patch wheel maximum repair</English>
</Key>
<Key ID="STR_ACE_Repair_patchWheelMaximumRepair_Description">
<English>Maximum level a wheel can be patched.</English>
</Key>
<Key ID="STR_ACE_Repair_patchWheelLocation_DisplayName">
<English>Wheel Patch Location</English>
</Key>
<Key ID="STR_ACE_Repair_patchWheelLocation_Description">
<English>Where the wheel can be patched.</English>
</Key>
<Key ID="STR_ACE_Repair_patchWheelOnGround">
<English>On the ground</English>
<German>Auf dem Boden</German>
</Key>
<Key ID="STR_ACE_Repair_patchWheelOnVehicle">
<English>On a vehicle</English>
<German>An einem Fahrzeug</German>
</Key>
</Package>
</Project>

Binary file not shown.

View File

@ -42,3 +42,8 @@ Adds a more realistic repair system.
- Amount repaired is based on settings and training level
- Using the interaction system select the hitpoint to repair
### 2.3 Patching Wheels
- Ensure the settings allow you to patch the wheel with your current engineer level and equipment
- Interact with the damaged wheel, either on a vehicle or on the ground