2015-07-03 21:14:23 +00:00
|
|
|
/*
|
|
|
|
* Author: Glowbal, KoffeinFlummi
|
|
|
|
* Starts the repair process
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: The engineer <OBJECT>
|
|
|
|
* 1: The patient <OBJECT>
|
|
|
|
* 2: SelectionName <STRING>
|
|
|
|
* 3: repair classname <STRING>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* Succesful repair started <BOOL>
|
|
|
|
*
|
|
|
|
* Public: Yes
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-08-09 06:54:44 +00:00
|
|
|
params ["_caller", "_target", "_hitPoint", "_className"];
|
|
|
|
TRACE_4("params",_calller,_target,_hitPoint,_className);
|
|
|
|
|
2015-08-14 20:14:36 +00:00
|
|
|
private["_callbackProgress", "_callerAnim", "_calller", "_condition", "_config", "_consumeItems", "_displayText", "_engineerRequired", "_iconDisplayed", "_items", "_locations", "_repairTime", "_repairTimeConfig", "_return", "_usersOfItems", "_vehicleStateCondition", "_wpn"];
|
2015-07-03 21:14:23 +00:00
|
|
|
|
|
|
|
_config = (ConfigFile >> "ACE_Repair" >> "Actions" >> _className);
|
|
|
|
if !(isClass _config) exitwith {false}; // or go for a default?
|
|
|
|
|
|
|
|
_engineerRequired = if (isNumber (_config >> "requiredEngineer")) then {
|
|
|
|
getNumber (_config >> "requiredEngineer");
|
|
|
|
} else {
|
|
|
|
// Check for required class
|
|
|
|
if (isText (_config >> "requiredEngineer")) exitwith {
|
|
|
|
missionNamespace getvariable [(getText (_config >> "requiredEngineer")), 0];
|
|
|
|
};
|
|
|
|
0;
|
|
|
|
};
|
|
|
|
if !([_caller, _engineerRequired] call FUNC(isEngineer)) exitwith {false};
|
2015-08-09 16:08:53 +00:00
|
|
|
if (isEngineOn _target) exitwith {false};
|
2015-07-03 21:14:23 +00:00
|
|
|
_items = getArray (_config >> "items");
|
|
|
|
if (count _items > 0 && {!([_caller, _items] call FUNC(hasItems))}) exitwith {false};
|
|
|
|
|
|
|
|
_return = true;
|
|
|
|
if (getText (_config >> "condition") != "") then {
|
|
|
|
_condition = getText (_config >> "condition");
|
|
|
|
if (isnil _condition) then {
|
|
|
|
_condition = compile _condition;
|
|
|
|
} else {
|
|
|
|
_condition = missionNamespace getvariable _condition;
|
|
|
|
};
|
|
|
|
if (typeName _condition == "BOOL") then {
|
|
|
|
_return = _condition;
|
|
|
|
} else {
|
|
|
|
_return = [_caller, _target, _hitPoint, _className] call _condition;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
if (!_return) exitwith {false};
|
|
|
|
|
|
|
|
_vehicleStateCondition = if (isText(_config >> "vehicleStateCondition")) then {
|
|
|
|
missionNamespace getvariable [getText(_config >> "vehicleStateCondition"), 0]
|
|
|
|
} else {
|
|
|
|
getNumber(_config >> "vehicleStateCondition")
|
|
|
|
};
|
|
|
|
// if (_vehicleStateCondition == 1 && {!([_target] call FUNC(isInStableCondition))}) exitwith {false};
|
|
|
|
|
|
|
|
_locations = getArray (_config >> "repairLocations");
|
|
|
|
if ("All" in _locations) exitwith {true};
|
|
|
|
|
|
|
|
private ["_repairFacility", "_repairVeh"];
|
|
|
|
_repairFacility = {([_caller] call FUNC(isInRepairFacility)) || ([_target] call FUNC(isInRepairFacility))};
|
|
|
|
_repairVeh = {([_caller] call FUNC(isNearRepairVehicle)) || ([_target] call FUNC(isNearRepairVehicle))};
|
|
|
|
|
|
|
|
{
|
|
|
|
if (_x == "field") exitwith {_return = true;};
|
|
|
|
if (_x == "RepairFacility" && _repairFacility) exitwith {_return = true;};
|
|
|
|
if (_x == "RepairVehicle" && _repairVeh) exitwith {_return = true;};
|
|
|
|
if !(isnil _x) exitwith {
|
|
|
|
private "_val";
|
|
|
|
_val = missionNamespace getvariable _x;
|
|
|
|
if (typeName _val == "SCALAR") then {
|
|
|
|
_return = switch (_val) do {
|
|
|
|
case 0: {true};
|
|
|
|
case 1: _repairVeh;
|
|
|
|
case 2: _repairFacility;
|
2015-08-14 18:49:51 +00:00
|
|
|
case 3: {{call _repairFacility || call _repairVeh}};
|
2015-07-03 21:14:23 +00:00
|
|
|
};
|
|
|
|
_return = call _return;
|
|
|
|
};
|
|
|
|
};
|
2015-08-09 06:54:44 +00:00
|
|
|
} forEach _locations;
|
2015-07-03 21:14:23 +00:00
|
|
|
|
2015-08-09 13:53:52 +00:00
|
|
|
if !(_return && alive _target) exitwith {false};
|
2015-07-03 21:14:23 +00:00
|
|
|
|
|
|
|
_consumeItems = if (isNumber (_config >> "itemConsumed")) then {
|
|
|
|
getNumber (_config >> "itemConsumed");
|
|
|
|
} else {
|
|
|
|
// Check for required class
|
|
|
|
if (isText (_config >> "itemConsumed")) exitwith {
|
|
|
|
missionNamespace getvariable [(getText (_config >> "itemConsumed")), 0];
|
|
|
|
};
|
|
|
|
0;
|
|
|
|
};
|
|
|
|
|
|
|
|
_usersOfItems = [];
|
|
|
|
if (_consumeItems > 0) then {
|
|
|
|
_usersOfItems = ([_caller, _target, _items] call FUNC(useItems)) select 1;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Parse the config for the progress callback
|
|
|
|
_callbackProgress = getText (_config >> "callbackProgress");
|
|
|
|
if (_callbackProgress == "") then {
|
|
|
|
_callbackProgress = "true";
|
|
|
|
};
|
|
|
|
if (isNil _callbackProgress) then {
|
|
|
|
_callbackProgress = compile _callbackProgress;
|
|
|
|
} else {
|
|
|
|
_callbackProgress = missionNamespace getvariable _callbackProgress;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Player Animation
|
|
|
|
_callerAnim = [getText (_config >> "animationCaller"), getText (_config >> "animationCallerProne")] select (stance _caller == "PRONE");
|
|
|
|
_caller setvariable [QGVAR(selectedWeaponOnrepair), currentWeapon _caller];
|
|
|
|
|
|
|
|
// Cannot use secondairy weapon for animation
|
|
|
|
if (currentWeapon _caller == secondaryWeapon _caller) then {
|
|
|
|
_caller selectWeapon (primaryWeapon _caller);
|
|
|
|
};
|
|
|
|
|
|
|
|
_wpn = ["non", "rfl", "pst"] select (1 + ([primaryWeapon _caller, handgunWeapon _caller] find (currentWeapon _caller)));
|
|
|
|
_callerAnim = [_callerAnim, "[wpn]", _wpn] call CBA_fnc_replace;
|
|
|
|
if (vehicle _caller == _caller && {_callerAnim != ""}) then {
|
|
|
|
if (primaryWeapon _caller == "") then {
|
|
|
|
_caller addWeapon "ACE_FakePrimaryWeapon";
|
|
|
|
};
|
|
|
|
if (currentWeapon _caller == "") then {
|
|
|
|
_caller selectWeapon (primaryWeapon _caller); // unit always has a primary weapon here
|
|
|
|
};
|
|
|
|
|
|
|
|
if (stance _caller == "STAND") then {
|
|
|
|
_caller setvariable [QGVAR(repairPrevAnimCaller), "amovpknlmstpsraswrfldnon"];
|
|
|
|
} else {
|
|
|
|
_caller setvariable [QGVAR(repairPrevAnimCaller), animationState _caller];
|
|
|
|
};
|
|
|
|
[_caller, _callerAnim] call EFUNC(common,doAnimation);
|
|
|
|
};
|
|
|
|
|
|
|
|
//Get repair time
|
2015-08-09 13:53:52 +00:00
|
|
|
_repairTime = if (isNumber (_config >> "repairingTime")) then {
|
|
|
|
getNumber (_config >> "repairingTime");
|
2015-07-03 21:14:23 +00:00
|
|
|
} else {
|
2015-08-09 13:53:52 +00:00
|
|
|
if (isText (_config >> "repairingTime")) exitwith {
|
|
|
|
_repairTimeConfig = getText(_config >> "repairingTime");
|
2015-07-03 21:14:23 +00:00
|
|
|
if (isnil _repairTimeConfig) then {
|
|
|
|
_repairTimeConfig = compile _repairTimeConfig;
|
|
|
|
} else {
|
|
|
|
_repairTimeConfig = missionNamespace getvariable _repairTimeConfig;
|
|
|
|
};
|
|
|
|
if (typeName _repairTimeConfig == "SCALAR") exitwith {
|
|
|
|
_repairTimeConfig;
|
|
|
|
};
|
2015-08-14 20:14:36 +00:00
|
|
|
[_caller, _target, _hitPoint, _className] call _repairTimeConfig;
|
2015-07-03 21:14:23 +00:00
|
|
|
};
|
|
|
|
0;
|
|
|
|
};
|
|
|
|
|
2015-08-09 13:53:52 +00:00
|
|
|
private ["_text", "_processText"];
|
|
|
|
_processText = getText (_config >> "displayNameProgress");
|
|
|
|
_text = format ["STR_ACE_Repair_%1", _hitPoint];
|
|
|
|
if (isLocalized _text) then {
|
|
|
|
_text = format [_processText, localize _text];
|
2015-08-14 18:49:51 +00:00
|
|
|
} else {
|
|
|
|
_text = _processText;
|
2015-08-09 13:53:52 +00:00
|
|
|
};
|
|
|
|
|
2015-07-03 21:14:23 +00:00
|
|
|
// Start repair
|
|
|
|
[
|
|
|
|
_repairTime,
|
2015-08-09 13:53:52 +00:00
|
|
|
[_caller, _target, _hitPoint, _className, _items, _usersOfItems],
|
2015-07-03 21:14:23 +00:00
|
|
|
DFUNC(repair_success),
|
|
|
|
DFUNC(repair_failure),
|
2015-08-09 13:53:52 +00:00
|
|
|
_text,
|
2015-07-03 21:14:23 +00:00
|
|
|
_callbackProgress,
|
|
|
|
[]
|
|
|
|
] call EFUNC(common,progressBar);
|
|
|
|
|
|
|
|
// Display Icon
|
|
|
|
_iconDisplayed = getText (_config >> "actionIconPath");
|
|
|
|
if (_iconDisplayed != "") then {
|
|
|
|
[QGVAR(repairActionIcon), true, _iconDisplayed, [1,1,1,1], getNumber(_config >> "actionIconDisplayTime")] call EFUNC(common,displayIcon);
|
|
|
|
};
|
|
|
|
|
|
|
|
// handle display of text/hints
|
|
|
|
_displayText = "";
|
|
|
|
if (_target != _caller) then {
|
|
|
|
_displayText = getText(_config >> "displayTextOther");
|
|
|
|
} else {
|
|
|
|
_displayText = getText(_config >> "displayTextSelf");
|
|
|
|
};
|
|
|
|
|
|
|
|
if (_displayText != "") then {
|
|
|
|
["displayTextStructured", [_caller], [[_displayText, [_caller] call EFUNC(common,getName), [_target] call EFUNC(common,getName)], 1.5, _caller]] call EFUNC(common,targetEvent);
|
|
|
|
};
|
|
|
|
|
|
|
|
true;
|