mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Attempt at repairing tracks. Improved repair wheel actions
This commit is contained in:
parent
872d026cd0
commit
ed6a53a402
@ -24,13 +24,13 @@ class ACE_Settings {
|
||||
displayName = CSTRING(repairDamageThreshold_name);
|
||||
description = CSTRING(repairDamageThreshold_description);
|
||||
typeName = "SCALAR";
|
||||
value = 0.3;
|
||||
value = 0.6;
|
||||
};
|
||||
class GVAR(repairDamageThreshold_Engineer) {
|
||||
displayName = CSTRING(repairDamageThreshold_Engineer_name);
|
||||
description = CSTRING(repairDamageThreshold_Engineer_description);
|
||||
typeName = "SCALAR";
|
||||
value = 0;
|
||||
value = 0.4;
|
||||
};
|
||||
class GVAR(consumeItem_ToolKit) {
|
||||
displayName = CSTRING(consumeItem_ToolKit_name);
|
||||
|
@ -5,7 +5,7 @@ class ACE_Repair {
|
||||
displayNameProgress = CSTRING(ReplacingWheel);
|
||||
|
||||
locations[] = {"All"};
|
||||
requiredEngineer = 0;
|
||||
requiredEngineer = QGVAR(engineerSetting_Wheel);
|
||||
repairingTime = 5;
|
||||
repairingTimeSelfCoef = 1;
|
||||
items[] = {"ToolKit"};
|
||||
@ -27,18 +27,25 @@ class ACE_Repair {
|
||||
displayNameProgress = CSTRING(RemovingWheel);
|
||||
condition = QUOTE(call FUNC(canRemoveWheel));
|
||||
callbackSuccess = QUOTE(call FUNC(doRemoveWheel));
|
||||
};
|
||||
class RepairEngine {
|
||||
|
||||
};
|
||||
class Tracks: ReplaceWheel {
|
||||
|
||||
};
|
||||
class MiscRepair: ReplaceWheel {
|
||||
displayName = CSTRING(Repairing); // let's make empty string an auto generated string
|
||||
displayNameProgress = CSTRING(RepairingHitPoint);
|
||||
condition = "";
|
||||
condition = QUOTE((_target getHitPointDamage _hitPoint) > ([_caller] call FUNC(getPostRepairDamage)));
|
||||
requiredEngineer = 0;
|
||||
callbackSuccess = QUOTE(call FUNC(doRepair));
|
||||
};
|
||||
class RemoveTrack: MiscRepair {
|
||||
displayName = CSTRING(RemoveTrack);
|
||||
displayNameProgress = CSTRING(RemovingTrack);
|
||||
condition = QUOTE(call FUNC(canRemoveTrack));
|
||||
callbackSuccess = QUOTE(call FUNC(doRemoveTrack));
|
||||
};
|
||||
class ReplaceTrack: RemoveTrack {
|
||||
displayName = CSTRING(ReplaceTrack);
|
||||
displayNameProgress = CSTRING(ReplacingTrack);
|
||||
condition = QUOTE(call FUNC(canReplaceTrack));
|
||||
callbackSuccess = QUOTE(call FUNC(doReplaceTrack));
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -53,13 +53,13 @@ class CfgVehicles {
|
||||
displayName = CSTRING(repairDamageThreshold_name);
|
||||
description = CSTRING(repairDamageThreshold_description);
|
||||
typeName = "NUMBER";
|
||||
defaultValue = 0.3;
|
||||
defaultValue = 0.6;
|
||||
};
|
||||
class repairDamageThreshold_Engineer {
|
||||
displayName = CSTRING(repairDamageThreshold_Engineer_name);
|
||||
description = CSTRING(repairDamageThreshold_Engineer_description);
|
||||
typeName = "NUMBER";
|
||||
defaultValue = 0;
|
||||
defaultValue = 0.4;
|
||||
};
|
||||
class consumeItem_ToolKit {
|
||||
displayName = CSTRING(consumeItem_ToolKit_name);
|
||||
|
@ -4,11 +4,15 @@ ADDON = false;
|
||||
|
||||
PREP(addRepairActions);
|
||||
PREP(canRemoveWheel);
|
||||
PREP(canRemoveTrack);
|
||||
PREP(canRepair);
|
||||
PREP(canReplaceWheel);
|
||||
PREP(canReplaceTrack);
|
||||
PREP(doRemoveWheel);
|
||||
PREP(doRemoveTrack);
|
||||
PREP(doRepair);
|
||||
PREP(doReplaceWheel);
|
||||
PREP(doReplaceTrack);
|
||||
PREP(getPostRepairDamage);
|
||||
PREP(getWheelHitPointsWithSelections);
|
||||
PREP(hasItems);
|
||||
|
@ -95,19 +95,20 @@ _wheelHitPointSelections = _wheelHitPointsWithSelections select 1;
|
||||
_condition = {[_this select 1, _this select 0, _this select 2 select 0, _this select 2 select 1] call DFUNC(canRepair)};
|
||||
_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");
|
||||
diag_log format["Selection exists: %1", !(isNil {_vehicle getHit _selection})];
|
||||
//_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, _text, _icon, _statement, _condition, {}, [_x, "MiscRepair"], _selection, 4] call EFUNC(interact_menu,createAction);
|
||||
[_type, 0, [], _action] call EFUNC(interact_menu,addActionToClass);
|
||||
_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 {*/
|
||||
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);
|
||||
//};
|
||||
//diag_log format["Adding repair action for: %1 - %2", _type, _x];
|
||||
};
|
||||
} forEach _hitPoints;
|
||||
|
||||
|
18
addons/repair/functions/fnc_canRemoveTrack.sqf
Normal file
18
addons/repair/functions/fnc_canRemoveTrack.sqf
Normal file
@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
* Check if the unit can remove 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"];
|
||||
TRACE_3("params",_unit,_target,_hitPoint);
|
||||
|
||||
alive _target && {_target getHitPointDamage _hitPoint < 1}
|
@ -15,4 +15,4 @@
|
||||
params ["_unit", "_target", "_hitPoint"];
|
||||
TRACE_3("params",_unit,_target,_hitPoint);
|
||||
|
||||
alive _target && {_target getHitPointDamage _hitPoint < 1}
|
||||
alive _target && {_target getHitPointDamage _hitPoint > 0} && {_target getHitPointDamage _hitPoint < 1}
|
||||
|
@ -23,6 +23,7 @@ private ["_config", "_engineerRequired", "_items", "_locations", "_return", "_co
|
||||
|
||||
_config = (ConfigFile >> "ACE_Repair" >> "Actions" >> _className);
|
||||
if !(isClass _config) exitwith {false}; // or go for a default?
|
||||
if(isEngineOn _target) exitwith {false};
|
||||
|
||||
_engineerRequired = if (isNumber (_config >> "requiredEngineer")) then {
|
||||
getNumber (_config >> "requiredEngineer");
|
||||
@ -88,4 +89,4 @@ _repairVeh = {([_caller] call FUNC(isNearRepairVehicle)) || ([_target] call FUNC
|
||||
};
|
||||
} forEach _locations;
|
||||
|
||||
_return && alive _target // && {(_target getHitPointDamage _hitPoint) > ([_target] call FUNC(getPostRepairDamage))}
|
||||
_return && alive _target;
|
||||
|
37
addons/repair/functions/fnc_canReplaceTrack.sqf
Normal file
37
addons/repair/functions/fnc_canReplaceTrack.sqf
Normal 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) exitWith {false};
|
||||
|
||||
alive _target && {_target getHitPointDamage _hitPoint >= 1}
|
||||
|
38
addons/repair/functions/fnc_doRemoveTrack.sqf
Normal file
38
addons/repair/functions/fnc_doRemoveTrack.sqf
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Called by repair action / progress bar. Raise events to set the new hitpoint damage.
|
||||
*
|
||||
* Arguments:
|
||||
* Stuff from progress bar.
|
||||
*
|
||||
* Return Value:
|
||||
* NONE
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit", "_vehicle", "_hitPoint"];
|
||||
TRACE_3("params",_unit,_vehicle,_hitPoint);
|
||||
// TODO [_unit, _wheel] call EFUNC(common,claim); on start of action
|
||||
// get current hitpoint damage
|
||||
private "_hitPointDamage";
|
||||
_hitPointDamage = _vehicle getHitPointDamage _hitPoint;
|
||||
|
||||
// can't remove destroyed or already removed wheel
|
||||
if (_hitPointDamage >= 1) exitWith {};
|
||||
|
||||
// don't die by spawning / moving the wheel
|
||||
["fixCollision", _unit] call EFUNC(common,localEvent);
|
||||
|
||||
// spawn wheel
|
||||
private "_wheel";
|
||||
_wheel = ["ACE_Track", getPosASL _unit] call FUNC(spawnObject);
|
||||
_wheel setdamage _hitPointDamage;
|
||||
|
||||
// raise event to set the new hitpoint damage
|
||||
["setWheelHitPointDamage", _vehicle, [_vehicle, _hitPoint, 1]] call EFUNC(common,targetEvent);
|
||||
|
||||
// display text message if enabled
|
||||
if (GVAR(DisplayTextOnRepair)) then {
|
||||
[localize LSTRING(RemovedTrack)] call EFUNC(common,displayTextStructured);
|
||||
};
|
47
addons/repair/functions/fnc_doReplaceTrack.sqf
Normal file
47
addons/repair/functions/fnc_doReplaceTrack.sqf
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
// can't replace not destroyed wheel
|
||||
if (_hitPointDamage < 1) exitWith {};
|
||||
|
||||
// don't die by spawning / moving the wheel
|
||||
_hitPointDamage = damage _wheel;
|
||||
|
||||
// can't replace a destroyed wheel
|
||||
if (_hitPointDamage >= 1) exitWith {};
|
||||
|
||||
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);
|
||||
};
|
@ -4,6 +4,9 @@
|
||||
params ["_unit"];
|
||||
TRACE_1("params",_unit);
|
||||
// TODO when near repair station, full repair?
|
||||
|
||||
if (([_caller] call FUNC(isInRepairFacility) || {[_caller] call FUNC(isNearRepairVehicle)})) exitwith {0};
|
||||
|
||||
if ([_unit, GVAR(engineerSetting_Repair) + 1] call FUNC(isEngineer)) exitWith {GVAR(repairDamageThreshold_Engineer)};
|
||||
if ([_unit, GVAR(engineerSetting_Repair)] call FUNC(isEngineer)) exitWith {GVAR(repairDamageThreshold)};
|
||||
0.3;
|
||||
|
@ -17,4 +17,4 @@ TRACE_1("params",_vehicle);
|
||||
|
||||
if (_vehicle isKindOf "CAManBase") exitwith {false};
|
||||
|
||||
((_vehicle getVariable [QGVAR(engineerClass), getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> "engineer")]) > 0);
|
||||
((_vehicle getVariable [QGVAR(engineerClass), getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> QGVAR(canRepair))]) > 0);
|
||||
|
@ -34,7 +34,7 @@ _engineerRequired = if (isNumber (_config >> "requiredEngineer")) then {
|
||||
0;
|
||||
};
|
||||
if !([_caller, _engineerRequired] call FUNC(isEngineer)) exitwith {false};
|
||||
|
||||
if (isEngineOn _target) exitwith {false};
|
||||
_items = getArray (_config >> "items");
|
||||
if (count _items > 0 && {!([_caller, _items] call FUNC(hasItems))}) exitwith {false};
|
||||
|
||||
|
@ -66,6 +66,24 @@
|
||||
<English>Wheel removed</English>
|
||||
<German>Reifen entfernt</German>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Repair_ReplaceTrack">
|
||||
<English>Change Track</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Repair_ReplacingTrack">
|
||||
<English>Replacing Track ...</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Repair_ReplacedTrack">
|
||||
<English>Track replaced</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Repair_RemoveTrack">
|
||||
<English>Remove Track</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Repair_RemovingTrack">
|
||||
<English>Removing Track ...</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Repair_RemovedTrack">
|
||||
<English>Track removed</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Repair_RepairHitpoint">
|
||||
<English>Repair %1</English>
|
||||
<German>Reparieren %1</German>
|
||||
|
Loading…
Reference in New Issue
Block a user