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-05-27 11:51:15 +00:00
|
|
|
private ["_caller", "_target", "_selectionName", "_className", "_config", "_medicRequired", "_items", "_locations", "_return", "_callbackProgress", "_treatmentTime", "_callerAnim", "_patientAnim", "_iconDisplayed", "_return", "_usersOfItems", "_consumeItems", "_condition", "_displayText", "_wpn", "_treatmentTimeConfig"];
|
2015-02-21 20:09:57 +00:00
|
|
|
_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-04-04 19:52:00 +00:00
|
|
|
// If the cursorMenu is open, the loading bar will fail. If we execute the function one frame later, it will work fine
|
|
|
|
if (uiNamespace getVariable [QEGVAR(interact_menu,cursorMenuOpened),false]) exitwith {
|
|
|
|
[{
|
|
|
|
_this call FUNC(treatment);
|
|
|
|
}, _this, 0, 0] call EFUNC(common,waitAndExecute);
|
|
|
|
};
|
|
|
|
|
2015-02-28 19:46:36 +00:00
|
|
|
if !(_target isKindOf "CAManBase") exitWith {false};
|
|
|
|
|
|
|
|
_config = (configFile >> "ACE_Medical_Actions" >> "Basic" >> _className);
|
2015-03-06 21:54:44 +00:00
|
|
|
if (GVAR(level) >= 2) then {
|
2015-02-28 19:46:36 +00:00
|
|
|
_config = (configFile >> "ACE_Medical_Actions" >> "Advanced" >> _className);
|
2015-02-21 23:24:50 +00:00
|
|
|
};
|
2015-02-21 20:09:57 +00:00
|
|
|
if !(isClass _config) exitwith {false};
|
2015-02-20 21:04:01 +00:00
|
|
|
|
2015-04-04 19:20:24 +00:00
|
|
|
_medicRequired = if (isNumber (_config >> "requiredMedic")) then {
|
|
|
|
getNumber (_config >> "requiredMedic");
|
|
|
|
} else {
|
|
|
|
// Check for required class
|
|
|
|
if (isText (_config >> "requiredMedic")) exitwith {
|
|
|
|
missionNamespace getvariable [(getText (_config >> "requiredMedic")), 0];
|
|
|
|
};
|
|
|
|
0;
|
|
|
|
};
|
|
|
|
|
2015-03-09 20:05:01 +00:00
|
|
|
if !([_caller, _medicRequired] call FUNC(isMedic)) exitwith {false};
|
2015-02-20 21:04:01 +00:00
|
|
|
|
2015-02-28 19:46:36 +00:00
|
|
|
// Check item
|
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-28 19:46:36 +00:00
|
|
|
// Check allowed locations
|
2015-02-21 20:09:57 +00:00
|
|
|
_locations = getArray (_config >> "treatmentLocations");
|
2015-03-09 20:05:01 +00:00
|
|
|
|
2015-03-09 20:42:09 +00:00
|
|
|
_return = true;
|
|
|
|
if (isText (_config >> "Condition")) then {
|
|
|
|
_condition = getText(_config >> "condition");
|
2015-03-09 20:05:01 +00:00
|
|
|
if (_condition != "") then {
|
|
|
|
if (isnil _condition) then {
|
|
|
|
_condition = compile _condition;
|
|
|
|
} else {
|
|
|
|
_condition = missionNamespace getvariable _condition;
|
|
|
|
};
|
|
|
|
if (typeName _condition == "BOOL") then {
|
|
|
|
_return = _condition;
|
|
|
|
} else {
|
|
|
|
_return = [_caller, _target, _selectionName, _className] call _condition;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2015-03-09 20:42:09 +00:00
|
|
|
if (!_return) exitwith {false};
|
|
|
|
|
|
|
|
if ("All" in _locations) then {
|
|
|
|
_return = true;
|
|
|
|
} else {
|
2015-04-06 12:32:37 +00:00
|
|
|
private [ "_medFacility", "_medVeh"];
|
|
|
|
_medFacility = {([_caller] call FUNC(isInMedicalFacility)) || ([_target] call FUNC(isInMedicalFacility))};
|
|
|
|
_medVeh = {([_caller] call FUNC(isInMedicalVehicle)) || ([_target] call FUNC(isInMedicalVehicle))};
|
|
|
|
|
2015-03-09 20:42:09 +00:00
|
|
|
{
|
|
|
|
if (_x == "field") exitwith {_return = true;};
|
2015-04-06 12:32:37 +00:00
|
|
|
if (_x == "MedicalFacility" && _medFacility) exitwith {_return = true;};
|
|
|
|
if (_x == "MedicalVehicle" && _medVeh) exitwith {_return = true;};
|
2015-04-06 12:11:10 +00:00
|
|
|
if !(isnil _x) exitwith {
|
|
|
|
private "_val";
|
|
|
|
_val = missionNamespace getvariable _x;
|
|
|
|
if (typeName _val == "SCALAR") then {
|
2015-04-06 12:32:37 +00:00
|
|
|
_return = switch (_val) do {
|
2015-04-06 12:11:10 +00:00
|
|
|
case 0: {true};
|
2015-04-06 12:32:37 +00:00
|
|
|
case 1: _medVeh;
|
|
|
|
case 2: _medFacility;
|
|
|
|
case 3: {call _medFacility || call _medVeh};
|
2015-04-06 12:11:10 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2015-03-09 20:42:09 +00:00
|
|
|
}foreach _locations;
|
|
|
|
};
|
2015-03-09 20:05:01 +00:00
|
|
|
|
2015-02-21 20:09:57 +00:00
|
|
|
if !(_return) exitwith {false};
|
|
|
|
|
2015-04-03 20:40:36 +00:00
|
|
|
_usersOfItems = [];
|
2015-04-04 19:20:24 +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;
|
|
|
|
};
|
|
|
|
if (_consumeItems > 0) then {
|
2015-04-03 20:40:36 +00:00
|
|
|
_usersOfItems = ([_caller, _target, _items] call FUNC(useItems)) select 1;
|
|
|
|
};
|
2015-03-09 20:05:01 +00:00
|
|
|
|
2015-02-24 21:09:31 +00:00
|
|
|
// Parse the config for the progress callback
|
2015-02-22 16:45:46 +00:00
|
|
|
_callbackProgress = getText (_config >> "callbackProgress");
|
2015-02-28 21:10:20 +00:00
|
|
|
if (_callbackProgress == "") then {
|
|
|
|
_callbackProgress = "true";
|
|
|
|
};
|
2015-02-22 16:45:46 +00:00
|
|
|
if (isNil _callbackProgress) then {
|
2015-02-28 14:23:12 +00:00
|
|
|
_callbackProgress = compile _callbackProgress;
|
2015-02-21 20:09:57 +00:00
|
|
|
} else {
|
2015-02-28 14:23:12 +00:00
|
|
|
_callbackProgress = missionNamespace getvariable _callbackProgress;
|
2015-02-21 20:09:57 +00:00
|
|
|
};
|
|
|
|
|
2015-02-28 19:46:36 +00:00
|
|
|
// Patient Animation
|
2015-04-04 15:33:20 +00:00
|
|
|
_patientAnim = getText (_config >> "animationPatient");
|
2015-04-17 18:51:57 +00:00
|
|
|
if (_target getvariable ["ACE_isUnconscious", false] && GVAR(allowUnconsciousAnimationOnTreatment)) then {
|
2015-04-04 16:08:41 +00:00
|
|
|
if !(animationState _target in (getArray (_config >> "animationPatientUnconsciousExcludeOn"))) then {
|
|
|
|
_patientAnim = getText (_config >> "animationPatientUnconscious");
|
|
|
|
};
|
2015-04-04 15:33:20 +00:00
|
|
|
};
|
|
|
|
|
2015-02-28 19:46:36 +00:00
|
|
|
if (_caller != _target && {vehicle _target == _target} && {_patientAnim != ""}) then {
|
2015-04-04 16:08:41 +00:00
|
|
|
if (_target getvariable ["ACE_isUnconscious", false]) then {
|
|
|
|
[_target, _patientAnim, 2, true] call EFUNC(common,doAnimation);
|
|
|
|
} else {
|
|
|
|
[_target, _patientAnim, 1, true] call EFUNC(common,doAnimation);
|
|
|
|
};
|
2015-02-28 19:46:36 +00:00
|
|
|
};
|
2015-02-21 20:09:57 +00:00
|
|
|
|
2015-02-28 19:46:36 +00:00
|
|
|
// Player Animation
|
2015-02-28 14:10:58 +00:00
|
|
|
_callerAnim = [getText (_config >> "animationCaller"), getText (_config >> "animationCallerProne")] select (stance _caller == "PRONE");
|
|
|
|
if (_caller == _target) then {
|
2015-02-28 14:23:12 +00:00
|
|
|
_callerAnim = [getText (_config >> "animationCallerSelf"), getText (_config >> "animationCallerSelfProne")] select (stance _caller == "PRONE");
|
2015-02-28 14:10:58 +00:00
|
|
|
};
|
2015-04-02 20:58:00 +00:00
|
|
|
|
2015-04-17 19:07:09 +00:00
|
|
|
_caller setvariable [QGVAR(selectedWeaponOnTreatment), currentWeapon _caller];
|
|
|
|
|
2015-04-02 20:58:00 +00:00
|
|
|
// Cannot use secondairy weapon for animation
|
|
|
|
if (currentWeapon _caller == secondaryWeapon _caller) then {
|
|
|
|
_caller selectWeapon (primaryWeapon _caller);
|
|
|
|
};
|
|
|
|
|
2015-02-28 14:10:58 +00:00
|
|
|
_wpn = ["non", "rfl", "pst"] select (["", primaryWeapon _caller, handgunWeapon _caller] find (currentWeapon _caller));
|
|
|
|
_callerAnim = [_callerAnim, "[wpn]", _wpn] call CBA_fnc_replace;
|
2015-02-21 20:09:57 +00:00
|
|
|
if (vehicle _caller == _caller && {_callerAnim != ""}) then {
|
2015-02-28 14:23:12 +00:00
|
|
|
if (primaryWeapon _caller == "") then {
|
|
|
|
_caller addWeapon "ACE_FakePrimaryWeapon";
|
|
|
|
};
|
2015-04-04 18:49:30 +00:00
|
|
|
if (currentWeapon _caller == "") then {
|
|
|
|
_caller selectWeapon (primaryWeapon _caller); // unit always has a primary weapon here
|
|
|
|
};
|
|
|
|
|
2015-04-04 18:21:52 +00:00
|
|
|
if (stance _caller == "STAND") then {
|
|
|
|
_caller setvariable [QGVAR(treatmentPrevAnimCaller), "amovpknlmstpsraswrfldnon"];
|
|
|
|
} else {
|
|
|
|
_caller setvariable [QGVAR(treatmentPrevAnimCaller), animationState _caller];
|
|
|
|
};
|
2015-02-28 14:23:12 +00:00
|
|
|
[_caller, _callerAnim] call EFUNC(common,doAnimation);
|
2015-02-21 20:09:57 +00:00
|
|
|
};
|
|
|
|
|
2015-05-26 22:45:22 +00:00
|
|
|
//Get treatment time
|
|
|
|
if (isNumber (_config >> "treatmentTime")) then {
|
|
|
|
_treatmentTime = getNumber (_config >> "treatmentTime");
|
|
|
|
} else {
|
|
|
|
if (isText (_config >> "treatmentTime")) then {
|
|
|
|
_treatmentTimeConfig = getText(_config >> "treatmentTime");
|
|
|
|
if (isnil _treatmentTimeConfig) then {
|
|
|
|
_treatmentTimeConfig = compile _treatmentTimeConfig;
|
|
|
|
} else {
|
|
|
|
_treatmentTimeConfig = missionNamespace getvariable _treatmentTimeConfig;
|
|
|
|
};
|
|
|
|
if (typeName _treatmentTimeConfig == "SCALAR") then {
|
|
|
|
_treatmentTime = _treatmentTimeConfig;
|
|
|
|
} else {
|
|
|
|
_treatmentTime = [_caller, _target, _selectionName, _className] call _treatmentTimeConfig;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2015-02-28 21:10:20 +00:00
|
|
|
// Start treatment
|
|
|
|
[
|
|
|
|
_treatmentTime,
|
2015-04-03 20:40:36 +00:00
|
|
|
[_caller, _target, _selectionName, _className, _items, _usersOfItems],
|
2015-02-28 21:10:20 +00:00
|
|
|
DFUNC(treatment_success),
|
|
|
|
DFUNC(treatment_failure),
|
|
|
|
getText (_config >> "displayNameProgress"),
|
2015-04-04 20:48:52 +00:00
|
|
|
_callbackProgress,
|
|
|
|
["isnotinside"]
|
2015-02-28 21:10:20 +00:00
|
|
|
] call EFUNC(common,progressBar);
|
|
|
|
|
2015-02-28 19:46:36 +00:00
|
|
|
// Display Icon
|
2015-02-23 17:19:35 +00:00
|
|
|
_iconDisplayed = getText (_config >> "actionIconPath");
|
|
|
|
if (_iconDisplayed != "") then {
|
2015-02-28 19:46:36 +00:00
|
|
|
[QGVAR(treatmentActionIcon), true, _iconDisplayed, [1,1,1,1], getNumber(_config >> "actionIconDisplayTime")] call EFUNC(common,displayIcon);
|
2015-02-23 17:19:35 +00:00
|
|
|
};
|
|
|
|
|
2015-02-28 14:46:37 +00:00
|
|
|
// handle display of text/hints
|
|
|
|
_displayText = "";
|
|
|
|
if (_target != _caller) then {
|
|
|
|
_displayText = getText(_config >> "displayTextOther");
|
|
|
|
} else {
|
|
|
|
_displayText = getText(_config >> "displayTextSelf");
|
|
|
|
};
|
|
|
|
|
|
|
|
if (_displayText != "") then {
|
2015-02-28 17:59:37 +00:00
|
|
|
["displayTextStructured", [_caller], [[_displayText, [_caller] call EFUNC(common,getName), [_target] call EFUNC(common,getName)], 1.5, _caller]] call EFUNC(common,targetEvent);
|
2015-02-28 14:46:37 +00:00
|
|
|
};
|
|
|
|
|
2015-02-21 20:09:57 +00:00
|
|
|
true;
|