ACE3/addons/medical/functions/fnc_treatment_failure.sqf

76 lines
2.7 KiB
Plaintext
Raw Normal View History

/*
2015-02-28 19:46:36 +00:00
* Author: KoffeinFlummi, Glowbal
* Callback when the treatment fails
*
* Arguments:
* 0: The medic <OBJECT>
* 1: The patient <OBJECT>
* 2: SelectionName <STRING>
* 3: Treatment classname <STRING>
* 4: Items available <ARRAY<STRING>>
*
* Return Value:
2015-08-22 17:47:23 +00:00
* None
*
2015-02-28 19:46:36 +00:00
* Public: No
*/
#include "script_component.hpp"
2015-08-22 17:47:23 +00:00
private ["_config", "_callback", "_weaponSelect", "_lastAnim"];
params ["_args"];
_args params ["_caller", "_target", "_selectionName", "_className", "_items", "_usersOfItems"];
if (primaryWeapon _caller == "ACE_FakePrimaryWeapon") then {
_caller removeWeapon "ACE_FakePrimaryWeapon";
};
if (vehicle _caller == _caller) then {
_lastAnim = _caller getvariable [QGVAR(treatmentPrevAnimCaller), ""];
//Don't play another medic animation (when player is rapidily treating)
TRACE_2("Reseting to old animation", animationState player, _lastAnim);
2015-08-23 12:13:55 +00:00
switch (toLower _lastAnim) do {
case "ainvpknlmstpslaywrfldnon_medic": {_lastAnim = "AmovPknlMstpSrasWrflDnon"};
case "ainvppnemstpslaywrfldnon_medic": {_lastAnim = "AmovPpneMstpSrasWrflDnon"};
case "ainvpknlmstpslaywnondnon_medic": {_lastAnim = "AmovPknlMstpSnonWnonDnon"};
case "ainvppnemstpslaywpstdnon_medic": {_lastAnim = "AinvPpneMstpSlayWpstDnon"};
case "ainvpknlmstpslaywpstdnon_medic": {_lastAnim = "AmovPknlMstpSrasWpstDnon"};
};
[_caller, _lastAnim, 2] call EFUNC(common,doAnimation);
};
_caller setvariable [QGVAR(treatmentPrevAnimCaller), nil];
2015-02-28 19:46:36 +00:00
_weaponSelect = (_caller getvariable [QGVAR(selectedWeaponOnTreatment), []]);
2015-08-04 02:49:16 +00:00
if ((_weaponSelect params [["_previousWeapon", ""]]) && {(_previousWeapon != "") && {_previousWeapon in (weapons _caller)}}) then {
for "_index" from 0 to 99 do {
_caller action ["SwitchWeapon", _caller, _caller, _index];
//Just check weapon, muzzle and mode (ignore ammo in case they were reloading)
2015-08-04 02:49:16 +00:00
if (((weaponState _caller) select [0,3]) isEqualTo (_weaponSelect select [0,3])) exitWith {TRACE_1("Restoring", (weaponState _caller));};
if ((weaponState _caller) isEqualTo ["","","","",0]) exitWith {ERROR("weaponState not found");};
};
2015-04-17 19:07:09 +00:00
} else {
2015-04-20 20:08:31 +00:00
_caller action ["SwitchWeapon", _caller, _caller, 99];
2015-04-17 19:07:09 +00:00
};
{
2015-08-22 17:47:23 +00:00
_x params ["_unit", "_item"];
_unit addItem _item;
2015-11-30 16:23:48 +00:00
} forEach _usersOfItems;
2015-02-28 19:46:36 +00:00
// Record specific callback
_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);
};
_callback = getText (_config >> "callbackFailure");
2015-08-22 17:47:23 +00:00
_callback = if (isNil _callback) then {
compile _callback
} else {
2015-08-22 17:47:23 +00:00
missionNamespace getvariable _callback
};
2015-02-28 19:46:36 +00:00
_args call _callback;
// _args call FUNC(createLitter);