2015-02-21 22:14:21 +00:00
|
|
|
/*
|
2015-02-28 19:46:36 +00:00
|
|
|
* Author: KoffeinFlummi, Glowbal
|
2015-02-21 22:14:21 +00:00
|
|
|
* Callback when the treatment is completed
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: The medic <OBJECT>
|
|
|
|
* 1: The patient <OBJECT>
|
|
|
|
* 2: SelectionName <STRING>
|
|
|
|
* 3: Treatment classname <STRING>
|
2015-02-28 21:10:20 +00:00
|
|
|
* 4: Items available <ARRAY<STRING>>
|
2015-02-21 22:14:21 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
2015-08-22 17:47:23 +00:00
|
|
|
* None
|
2015-02-21 22:14:21 +00:00
|
|
|
*
|
2017-06-08 13:31:51 +00:00
|
|
|
* Example:
|
|
|
|
* [bob, kevin, "selectionname", "classname", ["bandage"]] call ACE_medical_fnc_treatment_success
|
|
|
|
*
|
2015-02-28 19:46:36 +00:00
|
|
|
* Public: No
|
2015-02-21 22:14:21 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-08-22 17:47:23 +00:00
|
|
|
params ["_args"];
|
2015-09-17 10:23:56 +00:00
|
|
|
_args params ["_caller", "_target", "_selectionName", "_className", "_items", "_usersOfItems"];
|
2015-02-21 22:14:21 +00:00
|
|
|
|
|
|
|
if (primaryWeapon _caller == "ACE_FakePrimaryWeapon") then {
|
|
|
|
_caller removeWeapon "ACE_FakePrimaryWeapon";
|
|
|
|
};
|
2017-10-01 18:38:11 +00:00
|
|
|
if (vehicle _caller == _caller && {!(_caller call EFUNC(common,isSwimming))}) then {
|
2016-06-13 12:27:43 +00:00
|
|
|
private _lastAnim = _caller getVariable [QGVAR(treatmentPrevAnimCaller), ""];
|
2015-07-23 07:43:19 +00:00
|
|
|
//Don't play another medic animation (when player is rapidily treating)
|
|
|
|
TRACE_2("Reseting to old animation", animationState player, _lastAnim);
|
2015-09-17 10:23:56 +00:00
|
|
|
switch (toLower _lastAnim) do {
|
2015-08-23 12:13:55 +00:00
|
|
|
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"};
|
2015-07-23 07:43:19 +00:00
|
|
|
};
|
2015-09-05 09:04:11 +00:00
|
|
|
[_caller, _lastAnim, 2] call EFUNC(common,doAnimation);
|
2015-04-05 11:03:09 +00:00
|
|
|
};
|
2015-11-30 16:27:09 +00:00
|
|
|
_caller setVariable [QGVAR(treatmentPrevAnimCaller), nil];
|
2015-02-28 19:46:36 +00:00
|
|
|
|
2016-06-13 12:27:43 +00:00
|
|
|
private _weaponSelect = (_caller getVariable [QGVAR(selectedWeaponOnTreatment), []]);
|
2015-08-04 02:49:16 +00:00
|
|
|
if ((_weaponSelect params [["_previousWeapon", ""]]) && {(_previousWeapon != "") && {_previousWeapon in (weapons _caller)}}) then {
|
2017-05-12 18:12:39 +00:00
|
|
|
for "_index" from 0 to 299 do {
|
2015-08-04 00:57:49 +00:00
|
|
|
_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));};
|
2015-08-04 00:57:49 +00:00
|
|
|
if ((weaponState _caller) isEqualTo ["","","","",0]) exitWith {ERROR("weaponState not found");};
|
|
|
|
};
|
2015-04-17 19:07:09 +00:00
|
|
|
} else {
|
2017-05-12 18:12:39 +00:00
|
|
|
_caller action ["SwitchWeapon", _caller, _caller, 299];
|
2015-04-17 19:07:09 +00:00
|
|
|
};
|
|
|
|
|
2015-02-28 19:46:36 +00:00
|
|
|
// Record specific callback
|
2016-06-13 12:27:43 +00:00
|
|
|
private _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);
|
|
|
|
};
|
|
|
|
|
2016-06-13 12:27:43 +00:00
|
|
|
private _callback = getText (_config >> "callbackSuccess");
|
2015-02-28 21:10:20 +00:00
|
|
|
if (isNil _callback) then {
|
|
|
|
_callback = compile _callback;
|
|
|
|
} else {
|
2015-11-30 16:27:09 +00:00
|
|
|
_callback = missionNamespace getVariable _callback;
|
2015-02-28 21:10:20 +00:00
|
|
|
};
|
2016-02-21 17:34:25 +00:00
|
|
|
if (!(_callback isEqualType {})) then {_callback = {TRACE_1("callback was NOT code",_callback)};};
|
2015-02-28 19:46:36 +00:00
|
|
|
|
2015-12-11 04:58:44 +00:00
|
|
|
//Get current blood loose on limb (for "bloody" litter)
|
|
|
|
private _bloodLossOnSelection = 0;
|
|
|
|
private _partNumber = ([_selectionName] call FUNC(selectionNameToNumber)) max 0;
|
2016-06-13 10:18:56 +00:00
|
|
|
|
|
|
|
// Add all bleeding from wounds on selection
|
|
|
|
private _openWounds = _target getvariable [QGVAR(openWounds), []];
|
|
|
|
{
|
|
|
|
_x params ["", "", "_selectionX", "_amountOf", "_percentageOpen"];
|
|
|
|
if (_selectionX == _partNumber) then {
|
|
|
|
_bloodLossOnSelection = _bloodLossOnSelection + (_amountOf * _percentageOpen);
|
|
|
|
};
|
|
|
|
} forEach _openWounds;
|
|
|
|
TRACE_1("advanced",_bloodLossOnSelection);
|
2015-05-03 22:20:28 +00:00
|
|
|
|
2015-08-05 22:32:00 +00:00
|
|
|
_args call _callback;
|
2015-12-11 04:58:44 +00:00
|
|
|
_args pushBack _bloodLossOnSelection;
|
2015-05-03 22:20:28 +00:00
|
|
|
_args call FUNC(createLitter);
|
2015-05-15 03:18:53 +00:00
|
|
|
|
|
|
|
//If we're not already tracking vitals, start:
|
2015-11-30 16:27:09 +00:00
|
|
|
if (!(_target getVariable [QGVAR(addedToUnitLoop),false])) then {
|
2016-02-28 23:12:56 +00:00
|
|
|
[_target] call FUNC(addVitalLoop);
|
2015-05-15 03:18:53 +00:00
|
|
|
};
|
2015-08-06 21:50:44 +00:00
|
|
|
|
2016-06-24 13:45:13 +00:00
|
|
|
["ace_treatmentSucceded", [_caller, _target, _selectionName, _className]] call CBA_fnc_localEvent;
|