ACE3/addons/medical_treatment/functions/fnc_treatment_success.sqf
2016-09-30 12:18:59 +02:00

75 lines
2.2 KiB
Plaintext

/*
* Author: KoffeinFlummi, Glowbal
* Callback when the treatment is completed
*
* Arguments:
* 0: The medic <OBJECT>
* 1: The patient <OBJECT>
* 2: SelectionName <STRING>
* 3: Treatment classname <STRING>
* 4: Items available <ARRAY<STRING>>
*
* Return Value:
* None
*
* Public: No
*/
#include "script_component.hpp"
params ["_args"];
_args params ["_caller", "_target", "_selectionName", "_className", "_items", "_usersOfItems"];
// switch to end anim immediately
private _endInAnim = _caller getVariable QGVAR(endInAnim);
if (!isNil "_endInAnim") then {
if (animationState _caller != _endInAnim) then {
[_caller, _endInAnim, 2] call EFUNC(common,doAnimation);
};
_caller setVariable [QGVAR(endInAnim), nil];
TRACE_1("abort",_endInAnim);
};
// reset sped up animations
[QEGVAR(common,setAnimSpeedCoef), [_caller, 1]] call CBA_fnc_globalEvent;
// Record specific callback
private _config = configFile >> QGVAR(Actions) >> CUR_LEVEL >> _className;
private _callback = getText (_config >> "callbackSuccess");
if (isNil _callback) then {
_callback = compile _callback;
} else {
_callback = missionNamespace getVariable _callback;
};
if !(_callback isEqualType {}) then {
_callback = {TRACE_1("callback was NOT code",_callback)};
};
//Get current blood loose on limb (for "bloody" litter)
private _bloodLossOnSelection = 0;
private _partNumber = ([_selectionName] call EFUNC(medical,selectionNameToNumber)) max 0;
// 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);
_args call _callback;
_args pushBack _bloodLossOnSelection;
_args call FUNC(litterCreate);
//If we're not already tracking vitals, start:
if (!(_target getVariable [QGVAR(addedToUnitLoop),false])) then {
[_target] call FUNC(addVitalLoop);
};
["ace_treatmentSucceded", [_caller, _target, _selectionName, _className]] call CBA_fnc_localEvent;