hacked approach for repair tracks.

Could probably better go with config entries, but this seems to be a very good value for 90% of the vanilla tracked vehicles. It's also still easily accessible and on an acceptable place for the remaining vehicles.
This commit is contained in:
Glowbal 2015-08-11 21:35:13 +02:00
parent 660f8debf6
commit b45aa51d47
6 changed files with 103 additions and 9 deletions

View File

@ -35,6 +35,12 @@ class ACE_Repair {
requiredEngineer = 0;
callbackSuccess = QUOTE(call FUNC(doRepair));
};
class RepairTrack: MiscRepair {
displayName = CSTRING(Repairing);
displayNameProgress = CSTRING(RepairingHitPoint);
condition = QUOTE(call FUNC(canRepairTrack));
callbackSuccess = QUOTE(call FUNC(doRepairTrack));
};
class RemoveTrack: MiscRepair {
displayName = CSTRING(RemoveTrack);
displayNameProgress = CSTRING(RemovingTrack);

View File

@ -6,11 +6,13 @@ PREP(addRepairActions);
PREP(canRemoveWheel);
PREP(canRemoveTrack);
PREP(canRepair);
PREP(canRepairTrack);
PREP(canReplaceWheel);
PREP(canReplaceTrack);
PREP(doRemoveWheel);
PREP(doRemoveTrack);
PREP(doRepair);
PREP(doRepairTrack);
PREP(doReplaceWheel);
PREP(doReplaceTrack);
PREP(getPostRepairDamage);
@ -22,12 +24,9 @@ PREP(isNearRepairVehicle);
PREP(isRepairVehicle);
PREP(moduleRepairSettings);
PREP(normalizeHitPoints);
//PREP(removeWheel);
PREP(repair);
//PREP(repairVehicle);
PREP(repair_failure);
PREP(repair_success);
//PREP(replaceWheel);
PREP(setDamage);
PREP(setHitPointDamage);
PREP(spawnObject);

View File

@ -2,7 +2,7 @@
class CfgPatches {
class ADDON {
units[] = {"ACE_SpareWheel"};
units[] = {"ACE_Wheel", "ACE_Track"};
weapons[] = {};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_common","ace_interact_menu"};

View File

@ -96,19 +96,28 @@ _wheelHitPointSelections = _wheelHitPointsWithSelections select 1;
_statement = {[_this select 1, _this select 0, _this select 2 select 0, _this select 2 select 1] call DFUNC(repair)};
// impossible to remove tracks
/*if (_x in TRACK_HITPOINTS) then {
//_selection = getText(configFile >> "CfgVehicles" >> _type >> "HitPoints" >> _x >> "name"); // TODO this is a valid selection, it's just on the wrong position.
if (_x in TRACK_HITPOINTS) then {
/*//_selection = getText(configFile >> "CfgVehicles" >> _type >> "HitPoints" >> _x >> "name"); // TODO this is a valid selection, it's just on the wrong position.
private "_action";
_action = [_name, localize LSTRING(RemoveTrack), _icon, _statement, _condition, {}, [_x, "RemoveTrack"], _selection, 4] call EFUNC(interact_menu,createAction);
[_type, 0, ["ACE_MainActions", QGVAR(Repair)], _action] call EFUNC(interact_menu,addActionToClass);
_action = [_name, localize LSTRING(ReplaceTrack), _icon, _statement, _condition, {}, [_x, "ReplaceTrack"], _selection, 4] call EFUNC(interact_menu,createAction);
[_type, 0, ["ACE_MainActions", QGVAR(Repair)], _action] call EFUNC(interact_menu,addActionToClass);
} else {*/
[_type, 0, ["ACE_MainActions", QGVAR(Repair)], _action] call EFUNC(interact_menu,addActionToClass);*/
if (_x == "HitLTrack") then {
_selection = [-1.75, 0, -1.75];
} else {
_selection = [1.75, 0, -1.75];
};
private "_action";
_action = [_name, _text, _icon, _statement, _condition, {}, [_x, "RepairTrack"], _selection, 4] call EFUNC(interact_menu,createAction);
[_type, 0, [], _action] call EFUNC(interact_menu,addActionToClass);
} else {
private "_action";
_action = [_name, _text, _icon, _statement, _condition, {}, [_x, "MiscRepair"], _selection, 4] call EFUNC(interact_menu,createAction);
[_type, 0, ["ACE_MainActions", QGVAR(Repair)], _action] call EFUNC(interact_menu,addActionToClass);
//};
};
};
} forEach _hitPoints;

View File

@ -0,0 +1,37 @@
/*
* Author: commy2
* Check if the unit can replace given wheel of the vehicle.
*
* Arguments:
* 0: Unit that does the repairing (Object)
* 1: vehicle to repair (Object)
* 2: Selected hitpoint (String)
*
* Return Value:
* NONE
*/
#include "script_component.hpp"
params ["_unit", "_target", "_hitPoint", ["_wheel",false]];
TRACE_4("params",_unit,_target,_hitPoint,_wheel);
// TODO [_unit, _wheel] call EFUNC(common,claim); on start of action
if (typeName _wheel == "OBJECT") then {
// not near interpret as objNull
if !(_wheel in nearestObjects [_unit, ["ACE_Track"], 5]) then {
_wheel = objNull;
};
} else {
_wheel = objNull;
{
if ([_unit, _x, ["isNotDragging", "isNotCarrying"]] call EFUNC(common,canInteractWith)) exitWith {
_wheel = _x;
};
} forEach nearestObjects [_unit, ["ACE_Track"], 5];
};
if (isNull _wheel || damage _wheel >= 1) exitWith {false};
alive _target && {_target getHitPointDamage _hitPoint > 0}

View File

@ -0,0 +1,43 @@
/*
* Author: commy2
* Called by repair action / progress bar. Raise events to set the new hitpoint damage.
*
* Arguments:
* 0: Stuff from progress bar. <ARRAY>
*
* Return Value:
* NONE
*/
#include "script_component.hpp"
params ["_unit", "_vehicle", "_hitPoint", "_classname"];
TRACE_4("params",_unit,_vehicle,_hitPoint,_classname);
// TODO [_unit, _wheel] call EFUNC(common,claim); on start of action
_wheel = objNull;
{
if ([_unit, _x, ["isNotDragging", "isNotCarrying"]] call EFUNC(common,canInteractWith)) exitWith {
_wheel = _x;
};
} forEach nearestObjects [_unit, ["ACE_Track"], 5];
if (isNull _wheel) exitwith {};
// get current hitpoint damage
private "_hitPointDamage";
_hitPointDamage = _vehicle getHitPointDamage _hitPoint;
_newDamage = (1 - (damage _wheel)) / 4; // require 4 tracks to fully replace one side
// can't replace a destroyed wheel
if ((damage _wheel) >= 1) exitWith {};
// don't die by spawning / moving the wheel
_hitPointDamage = (_hitPointDamage - _newDamage) min 0;
deleteVehicle _wheel;
// raise event to set the new hitpoint damage
["setWheelHitPointDamage", _vehicle, [_vehicle, _hitPoint, _hitPointDamage]] call EFUNC(common,targetEvent);
// display text message if enabled
if (GVAR(DisplayTextOnRepair)) then {
[LSTRING(ReplacedTrack)] call EFUNC(common,displayTextStructured);
};