client/addons/medical/functions/fnc_onRespawn.sqf
Jacob Schmidt d474b3676a
All checks were successful
Build / Build (push) Successful in 28s
Refactor: Standardize function descriptions and variable handling
This commit refactors several client-side functions to improve code consistency and readability.

- Standardizes function descriptions by removing redundant "Function: forge_client..." prefixes and "[Description]" sections, focusing on concise descriptions of the function's purpose.
- Updates variable handling in arsenal functions to use GVAR and EGVARS for default values, improving consistency and reducing code duplication.
- Removes the bank init function as it is no longer needed.
- Adds a done variable to the preinit file.
2025-05-25 11:30:26 -05:00

52 lines
1.5 KiB
Plaintext

#include "..\script_component.hpp"
/*
* Author: IDSolutions
* Handles the unit's respawn
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Corpse <OBJECT>
*
* Return Value:
* None
*
* Example:
* [player, bodyBag] call forge_client_medical_fnc_onRespawn;
*
* Public: Yes
*/
params ["_unit", "_corpse"];
private _newBank = 0;
private _newCash = 0;
private _bank = GETVAR(_unit,FORGE_Bank,0);
private _cash = GETVAR(_unit,FORGE_Cash,0);
private _funds = companyFunds;
private _deductible = "INS_DEDUCT" call BFUNC(getParamValue);
private _medicalCost = "MED_COST" call BFUNC(getParamValue);
private _totalCost = (_medicalCost - _deductible);
private _loadout = [[], [], [], ["U_BG_Guerrilla_6_1", []], [], [], "", "", [], ["", "", "", "", "", ""]];
private _stretcher = (GVAR(occupancyTriggers) select { !(GETVAR(_x,isOccupied,false)) }) param [0, objNull];
private _stretcherPos = (getPosATL _stretcher) vectorAdd [0.05, -0.125, 0.45];
private _stretcherDir = getDir _stretcher;
deleteVehicle _corpse;
if (_cash >= _totalCost or _bank >= _totalCost) exitWith {
[_unit, _totalCost] call FUNC(deductMedicalCost);
_unit setUnitLoadout _loadout;
};
["Medical Alert: Funds unavailable for treatment. Respawn temporarily suspended.", "warning", 5] call EFUNC(misc,notify);
_unit setUnitLoadout _loadout;
_unit setPosATL _stretcherPos;
_unit setDir _stretcherDir;
[_unit, "Acts_LyingWounded_loop"] remoteExec ["switchMove"];
["Initialize", [_unit, [], false, true, true, true, true, true, false, false]] call BFUNC(EGSpectator);
[_unit, _totalCost] spawn FUNC(heartBeat);