ACE3/addons/repair/functions/fnc_canReplaceWheel.sqf

49 lines
1.4 KiB
Plaintext
Raw Normal View History

2015-03-28 10:08:17 +00:00
/*
* 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>
* 3: Wheel <OBJECT>/<BOOL> (default: false)
2015-03-28 10:08:17 +00:00
*
* Return Value:
* None
*
* Example:
* [unit, vehicle, "hitpoint"] call ace_repair_fnc_canReplaceWheel
*
* Public: No
2015-03-28 10:08:17 +00:00
*/
#include "script_component.hpp"
params ["_unit", "_target", "_hitPoint", ["_wheel", false]];
2015-08-09 06:54:44 +00:00
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};
2015-03-28 10:08:17 +00:00
//if !([_unit, _target, []] call EFUNC(common,canInteractWith)) exitWith {false};
2015-03-28 10:08:17 +00:00
//if !([_unit, GVAR(engineerSetting_Wheel)] call FUNC(isEngineer)) exitWith {false};
2015-04-22 19:01:22 +00:00
2015-03-29 09:01:23 +00:00
// check for a near wheel
2015-04-22 19:31:42 +00:00
if (typeName _wheel == "OBJECT") then {
// not near interpret as objNull
if !(_wheel in nearestObjects [_unit, ["ACE_Wheel"], 5]) then {
_wheel = objNull;
2015-03-29 09:01:23 +00:00
};
2015-04-22 19:31:42 +00:00
} else {
_wheel = objNull;
{
2015-08-31 19:22:22 +00:00
if ([_unit, _x, ["isNotDragging", "isNotCarrying", "isNotOnLadder"]] call EFUNC(common,canInteractWith)) exitWith {
2015-04-22 19:31:42 +00:00
_wheel = _x;
};
} forEach nearestObjects [_unit, ["ACE_Wheel"], 5];
};
2015-03-29 09:01:23 +00:00
if (isNull _wheel) exitWith {false};
2015-03-28 10:08:17 +00:00
alive _target && {_target getHitPointDamage _hitPoint >= 1}