2015-02-20 21:04:01 +00:00
|
|
|
/*
|
2015-02-21 20:09:57 +00:00
|
|
|
* Author: Glowbal, KoffeinFlummi
|
2015-02-20 21:04:01 +00:00
|
|
|
* Starts the treatment process
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: The medic <OBJECT>
|
|
|
|
* 1: The patient <OBJECT>
|
2015-02-21 20:09:57 +00:00
|
|
|
* 2: SelectionName <STRING>
|
|
|
|
* 3: Treatment classname <STRING>
|
2015-02-20 21:04:01 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
2015-02-21 20:09:57 +00:00
|
|
|
* Succesful treatment started <BOOL>
|
2015-02-20 21:04:01 +00:00
|
|
|
*
|
|
|
|
* Public: Yes
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-02-21 20:09:57 +00:00
|
|
|
private ["_caller", "_target", "_selectionName", "_className", "_config", "_availableLevels", "_medicRequired", "_items", "_locations", "_return", "_callbackSuccess", "_callbackFailure", "_onProgress", "_treatmentTime", "_callerAnim", "_patietAnim"];
|
|
|
|
_caller = _this select 0;
|
|
|
|
_target = _this select 1;
|
|
|
|
_selectionName = _this select 2;
|
|
|
|
_className = _this select 3;
|
2015-02-20 21:04:01 +00:00
|
|
|
|
2015-02-21 23:24:50 +00:00
|
|
|
_config = (ConfigFile >> "ACE_Medical_Treatments" >> "Basic" >> _className);
|
|
|
|
if (GVAR(level)>=1) then {
|
|
|
|
_config = (ConfigFile >> "ACE_Medical_Treatments" >> "Advanced" >> _className);
|
|
|
|
};
|
2015-02-21 20:09:57 +00:00
|
|
|
if !(isClass _config) exitwith {false};
|
2015-02-20 21:04:01 +00:00
|
|
|
|
2015-02-21 20:09:57 +00:00
|
|
|
_availableLevels = getArray (_config >> "availableLevels");
|
|
|
|
if !(GVAR(level) in _availableLevels) exitwith {false};
|
2015-02-20 21:04:01 +00:00
|
|
|
|
2015-02-21 20:09:57 +00:00
|
|
|
_medicRequired = getNumber (_config >> "requiredMedic");
|
|
|
|
if !([_caller, _medicRequired] call FUNC(isMedic) || [_target, _medicRequired] call FUNC(isMedic)) exitwith {false};
|
2015-02-20 21:04:01 +00:00
|
|
|
|
2015-02-21 20:09:57 +00:00
|
|
|
_items = getArray (_config >> "items");
|
|
|
|
if (count _items > 0 && {!([_caller, _target, _items] call FUNC(hasItems))}) exitwith {false};
|
2015-02-20 21:04:01 +00:00
|
|
|
|
2015-02-21 20:09:57 +00:00
|
|
|
_locations = getArray (_config >> "treatmentLocations");
|
|
|
|
|
|
|
|
_return = false;
|
2015-02-21 23:47:14 +00:00
|
|
|
if ("All" in _locations) then {
|
|
|
|
_return = true;
|
|
|
|
} else {
|
|
|
|
{
|
|
|
|
if (_x == "field") exitwith {_return = true;};
|
|
|
|
if (_x == "MedicalFacility" && {([_caller] call FUNC(isInMedicalFacility)) || ([_target] call FUNC(isInMedicalFacility))}) exitwith {_return = true;};
|
|
|
|
if (_x == "MedicalVehicle" && {([vehicle _caller] call FUNC(isMedicalVehicle)) || ([vehicle _target] call FUNC(isMedicalVehicle))}) exitwith {_return = true;};
|
|
|
|
}foreach _locations;
|
|
|
|
};
|
2015-02-21 20:09:57 +00:00
|
|
|
if !(_return) exitwith {false};
|
|
|
|
|
2015-02-21 23:47:14 +00:00
|
|
|
|
2015-02-21 20:09:57 +00:00
|
|
|
// Parse the config for the success callback
|
|
|
|
_callbackSuccess = getText (_config >> "callbackSuccess");
|
|
|
|
if (isNil _callbackSuccess) then {
|
|
|
|
_callbackSuccess = compile _callbackSuccess;
|
|
|
|
} else {
|
|
|
|
_callbackSuccess = missionNamespace getvariable _callbackSuccess;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Parse the config for the failure callback
|
|
|
|
_callbackFailure = getText (_config >> "callbackFailure");
|
|
|
|
if (isNil _callbackFailure) then {
|
|
|
|
_callbackFailure = compile _callbackFailure;
|
|
|
|
} else {
|
|
|
|
_callbackFailure = missionNamespace getvariable _callbackFailure;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Parse the config for the onProgress callback
|
|
|
|
_onProgress = getText (_config >> "onProgress");
|
|
|
|
if (isNil _onProgress) then {
|
|
|
|
_onProgress = compile _onProgress;
|
|
|
|
} else {
|
|
|
|
_onProgress = missionNamespace getvariable _onProgress;
|
|
|
|
};
|
|
|
|
|
|
|
|
_treatmentTime = getNumber (_config >> "treatmentTime");
|
|
|
|
[_treatmentTime, [_caller, _target, _selectionName, _className, _items], _callbackSuccess, _callbackFailure, (localize ""), _onProgress] call EFUNC(common,progressBar);
|
|
|
|
|
|
|
|
_callerAnim = getText (_config >> "animationCaller");
|
|
|
|
_patietAnim = getText (_confg >> "animationPatient");
|
|
|
|
|
|
|
|
if (_caller != _target && {vehicle _target == _target} && {_patietAnim != ""}) then {
|
2015-02-21 20:28:59 +00:00
|
|
|
[_target, _patietAnim] call EFUNC(common,doAnimation);
|
2015-02-21 20:09:57 +00:00
|
|
|
};
|
|
|
|
if (vehicle _caller == _caller && {_callerAnim != ""}) then {
|
2015-02-21 22:14:21 +00:00
|
|
|
if (primaryWeapon _caller == "") then {
|
|
|
|
_caller addWeapon "ACE_FakePrimaryWeapon";
|
|
|
|
};
|
|
|
|
_caller selectWeapon (primaryWeapon _caller);
|
|
|
|
_caller setvariable [QGVAR(treatmentPrevAnimCaller), animationState _target];
|
2015-02-21 20:28:59 +00:00
|
|
|
[_caller, _callerAnim] call EFUNC(common,doAnimation);
|
2015-02-21 20:09:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
true;
|