Moved replace and repair wheel actions into the repair action framework

This commit is contained in:
Glowbal 2015-08-09 15:53:52 +02:00
parent ec97cd2edd
commit 9adbb07367
13 changed files with 59 additions and 113 deletions

View File

@ -9,10 +9,10 @@ class ACE_Repair {
repairingTime = 5;
repairingTimeSelfCoef = 1;
items[] = {};
condition = "";
condition = QUOTE(call FUNC(canReplaceWheel));
itemConsumed = 0;
callbackSuccess = QUOTE(DFUNC(repairBasic_bandage));
callbackSuccess = QUOTE(call FUNC(doReplaceWheel));
callbackFailure = "";
callbackProgress = "";
@ -23,7 +23,10 @@ class ACE_Repair {
litter[] = {};
};
class RemoveWheel: ReplaceWheel {
displayName = CSTRING(RemoveWheel);
displayNameProgress = CSTRING(RemovingWheel);
condition = QUOTE(call FUNC(canRemoveWheel));
callbackSuccess = QUOTE(call FUNC(doRemoveWheel));
};
class RepairEngine {
@ -32,8 +35,10 @@ class ACE_Repair {
};
class MiscRepair: ReplaceWheel {
displayName = ""; // let's make empty string an auto generated string
displayNameProgress = CSTRING(Repairing);
displayName = CSTRING(Repairing); // let's make empty string an auto generated string
displayNameProgress = CSTRING(RepairingHitPoint);
condition = "";
callbackSuccess = QUOTE(call FUNC(doRepair));
};
};
};

View File

@ -18,12 +18,12 @@ PREP(isNearRepairVehicle);
PREP(isRepairVehicle);
PREP(moduleRepairSettings);
PREP(normalizeHitPoints);
PREP(removeWheel);
//PREP(removeWheel);
PREP(repair);
PREP(repairVehicle);
//PREP(repairVehicle);
PREP(repair_failure);
PREP(repair_success);
PREP(replaceWheel);
//PREP(replaceWheel);
PREP(setDamage);
PREP(setHitPointDamage);
PREP(spawnObject);

View File

@ -51,8 +51,8 @@ _wheelHitPointSelections = _wheelHitPointsWithSelections select 1;
_name = format ["Remove_%1", _x];
_text = localize "STR_ACE_Repair_RemoveWheel";
_condition = {[_this select 1, _this select 0, _this select 2 select 0] call DFUNC(canRemoveWheel)};
_statement = {[_this select 1, _this select 0, _this select 2 select 0] call DFUNC(removeWheel)};
_condition = {[_this select 1, _this select 0, _this select 2 select 0, "RemoveWheel"] call DFUNC(canRepair)};
_statement = {[_this select 1, _this select 0, _this select 2 select 0, "RemoveWheel"] call DFUNC(repair)};
private "_action";
_action = [_name, _text, _icon, _statement, _condition, {}, [_x], _selection, 2] call EFUNC(interact_menu,createAction);
@ -62,8 +62,8 @@ _wheelHitPointSelections = _wheelHitPointsWithSelections select 1;
_name = format ["Replace_%1", _x];
_text = localize LSTRING(ReplaceWheel);
_condition = {[_this select 1, _this select 0, _this select 2 select 0] call DFUNC(canReplaceWheel)};
_statement = {[_this select 1, _this select 0, _this select 2 select 0] call DFUNC(replaceWheel)};
_condition = {[_this select 1, _this select 0, _this select 2 select 0, "ReplaceWheel"] call DFUNC(canRepair)};
_statement = {[_this select 1, _this select 0, _this select 2 select 0, "ReplaceWheel"] call DFUNC(repair)};
_action = [_name, _text, _icon, _statement, _condition, {}, [_x], _selection, 2] call EFUNC(interact_menu,createAction);
[_type, 0, [], _action] call EFUNC(interact_menu,addActionToClass);
@ -92,11 +92,11 @@ _wheelHitPointSelections = _wheelHitPointsWithSelections select 1;
_icon = "";
_selection = "";
_condition = {[_this select 1, _this select 0, _this select 2 select 0] call DFUNC(canRepair)};
_statement = {[_this select 1, _this select 0, _this select 2 select 0] call DFUNC(repairVehicle)};
_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(repairVehicle)};
private "_action";
_action = [_name, _text, _icon, _statement, _condition, {}, [_x], _selection, 4] call EFUNC(interact_menu,createAction);
_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);
};

View File

@ -15,6 +15,4 @@
params ["_unit", "_target", "_hitPoint"];
TRACE_3("params",_unit,_target,_hitPoint);
if !([_unit, _target, []] call EFUNC(common,canInteractWith)) exitWith {false};
alive _target && {_target getHitPointDamage _hitPoint < 1}

View File

@ -52,6 +52,7 @@ if (getText (_config >> "condition") != "") then {
_return = [_caller, _target, _hitPoint, _className] call _condition;
};
};
if (!_return) exitwith {false};
_vehicleStateCondition = if (isText(_config >> "vehicleStateCondition")) then {
@ -87,4 +88,4 @@ _repairVeh = {([_caller] call FUNC(isNearRepairVehicle)) || ([_target] call FUNC
};
} forEach _locations;
_return && alive _target && {(_target getHitPointDamage _hitPoint) > ([_target] call FUNC(getPostRepairDamage))}
_return && alive _target // && {(_target getHitPointDamage _hitPoint) > ([_target] call FUNC(getPostRepairDamage))}

View File

@ -14,10 +14,12 @@
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 !([_unit, _target, _hitpoint, "ReplaceWheel"] call FUNC(canRepair)) exitwith {false};
if !([_unit, _target, []] call EFUNC(common,canInteractWith)) exitWith {false};
//if !([_unit, _target, []] call EFUNC(common,canInteractWith)) exitWith {false};
if !([_unit, GVAR(engineerSetting_Wheel)] call FUNC(isEngineer)) exitWith {false};
//if !([_unit, GVAR(engineerSetting_Wheel)] call FUNC(isEngineer)) exitWith {false};
// check for a near wheel
if (typeName _wheel == "OBJECT") then {
@ -38,3 +40,4 @@ if (typeName _wheel == "OBJECT") then {
if (isNull _wheel) exitWith {false};
alive _target && {_target getHitPointDamage _hitPoint >= 1}

View File

@ -13,7 +13,7 @@
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;

View File

@ -10,8 +10,21 @@
*/
#include "script_component.hpp"
params ["_unit", "_vehicle", "_hitPoint", "_wheel"];
TRACE_4("params",_unit,_vehicle,_hitPoint,_wheel);
params ["_unit", "_vehicle", "_hitPoint", "_classname"];
TRACE_4("params",_unit,_vehicle,_hitPoint,_classname);
// TODO [_unit, _wheel] call EFUNC(common,claim); on start of action
systemChat format["Calling doReplaceWheel with: %1", _This];
diag_log format["Calling doReplaceWheel with: %1", _This];
_wheel = objNull;
{
if ([_unit, _x, ["isNotDragging", "isNotCarrying"]] call EFUNC(common,canInteractWith)) exitWith {
_wheel = _x;
};
} forEach nearestObjects [_unit, ["ACE_Wheel"], 5];
if (isNull _wheel) exitwith {};
// get current hitpoint damage
private "_hitPointDamage";

View File

@ -18,8 +18,6 @@ TRACE_2("params",_unit,_engineerN);
private ["_class"];
_class = _unit getVariable [QGVAR(engineerClass),
getNumber (configFile >> "CfgVehicles" >> typeOf _unit >> "engineer")
];
_class = _unit getVariable [QGVAR(engineerClass), getNumber (configFile >> "CfgVehicles" >> typeOf _unit >> "engineer")];
_class >= (_engineerN min GVAR(engineerSetting_Repair))
_class >= (_engineerN min GVAR(engineerSetting_Repair));

View File

@ -1,32 +0,0 @@
/*
* Author: commy2
*
* Start a remove wheel action and open progress bar.
*
* 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 ["_caller", "_vehicle", "_hitPoint"];
TRACE_3("params",_caller,_vehicle,_hitPoint);
// exit if not a valid hitpoint
if !(_hitPoint in ([_vehicle] call EFUNC(common,getHitPoints))) exitWith {};
// calculate time to fully repair the hitpoint
private "_time";
_time = 10;
// open the loading bar
[_time, [_caller, _vehicle, _hitPoint], {(_this select 0) call DFUNC(doRemoveWheel)}, {[localize "STR_ACE_Common_ActionAborted"] call EFUNC(common,displayTextStructured);}, localize "STR_ACE_Repair_RemovingWheel", {(_this select 0) call DFUNC(canRemoveWheel)}, []] call EFUNC(common,progressBar);
// do animation
[_caller] call EFUNC(common,goKneeling);
// @todo play sound

View File

@ -87,7 +87,7 @@ _repairVeh = {([_caller] call FUNC(isNearRepairVehicle)) || ([_target] call FUNC
};
} forEach _locations;
if !(_return && alive _target && {_target getHitPointDamage _hitPoint > ([_unit] call FUNC(getPostRepairDamage))}) exitwith {false};
if !(_return && alive _target) exitwith {false};
_consumeItems = if (isNumber (_config >> "itemConsumed")) then {
getNumber (_config >> "itemConsumed");
@ -144,11 +144,11 @@ if (vehicle _caller == _caller && {_callerAnim != ""}) then {
};
//Get repair time
_repairTime = if (isNumber (_config >> "repairTime")) then {
getNumber (_config >> "repairTime");
_repairTime = if (isNumber (_config >> "repairingTime")) then {
getNumber (_config >> "repairingTime");
} else {
if (isText (_config >> "repairTime")) exitwith {
_repairTimeConfig = getText(_config >> "repairTime");
if (isText (_config >> "repairingTime")) exitwith {
_repairTimeConfig = getText(_config >> "repairingTime");
if (isnil _repairTimeConfig) then {
_repairTimeConfig = compile _repairTimeConfig;
} else {
@ -162,13 +162,20 @@ _repairTime = if (isNumber (_config >> "repairTime")) then {
0;
};
private ["_text", "_processText"];
_processText = getText (_config >> "displayNameProgress");
_text = format ["STR_ACE_Repair_%1", _hitPoint];
if (isLocalized _text) then {
_text = format [_processText, localize _text];
};
// Start repair
[
_repairTime,
[_caller, _target, _selectionName, _className, _items, _usersOfItems],
[_caller, _target, _hitPoint, _className, _items, _usersOfItems],
DFUNC(repair_success),
DFUNC(repair_failure),
getText (_config >> "displayNameProgress"),
_text,
_callbackProgress,
[]
] call EFUNC(common,progressBar);

View File

@ -47,7 +47,6 @@ if (isNil _callback) then {
} else {
_callback = missionNamespace getvariable _callback;
};
_args call _callback;
// _args call FUNC(createLitter);

View File

@ -1,46 +0,0 @@
/*
* Author: commy2
*
* Start a replace wheel action and open progress bar.
*
* 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", "_vehicle", "_hitPoint"];
TRACE_3("params",_unit,_vehicle,_hitPoint);
// exit if not a valid hitpoint
if !(_hitPoint in ([_vehicle] call EFUNC(common,getHitPoints))) exitWith {};
// get nearest wheel
private "_wheel";
_wheel = objNull;
{
if ([_unit, _x, ["isNotDragging", "isNotCarrying"]] call EFUNC(common,canInteractWith)) exitWith {
_wheel = _x;
};
} forEach nearestObjects [_unit, ["ACE_Wheel"], 5];
if (isNull _wheel) exitWith {};
[_unit, _wheel] call EFUNC(common,claim);
// calculate time to fully repair the hitpoint
private "_time";
_time = 10;
// open the loading bar
[_time, [_unit, _vehicle, _hitPoint, _wheel], {(_this select 0) call DFUNC(doReplaceWheel)}, {[objNull, _this select 0 select 3] call DEFUNC(common,claim); [localize ELSTRING(common,ActionAborted)] call EFUNC(common,displayTextStructured);}, localize LSTRING(ReplacingWheel), {(_this select 0) call DFUNC(canReplaceWheel)}, []] call EFUNC(common,progressBar);
// do animation
[_unit] call EFUNC(common,goKneeling);
// @todo play sound