mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Merge branch 'medical-rewrite' of https://github.com/KoffeinFlummi/ACE3 into medical-rewrite
Conflicts: addons/medical/XEH_preInit.sqf
This commit is contained in:
commit
46cb963630
@ -10,6 +10,7 @@ GVAR(heartBeatSounds_Slow) = ["ACE_heartbeat_slow_1", "ACE_heartbeat_slow_2", "A
|
||||
GVAR(playingHeartBeatSound) = false;
|
||||
|
||||
["Medical_treatmentCompleted", FUNC(onTreatmentCompleted)] call ace_common_fnc_addEventHandler;
|
||||
["medical_propagateWound", FUNC(onPropagateWound)] call ace_common_fnc_addEventHandler;
|
||||
|
||||
// Initialize all effects
|
||||
// @todo: make this a macro?
|
||||
|
@ -42,6 +42,8 @@ PREP(isInMedicalFacility);
|
||||
PREP(isMedic);
|
||||
PREP(isMedicalVehicle);
|
||||
PREP(onMedicationUsage);
|
||||
PREP(onPropagateWound);
|
||||
PREP(onTreatmentCompleted);
|
||||
PREP(parseConfigForInjuries);
|
||||
PREP(playInjuredSound);
|
||||
PREP(reactionToDamage);
|
||||
|
@ -58,19 +58,25 @@ if (_highestPossibleSpot < 0) exitwith {
|
||||
};
|
||||
};
|
||||
_openWounds = _unit getvariable[QGVAR(openWounds), []];
|
||||
_woundID = 1;
|
||||
_amountOf = count _openWounds;
|
||||
if (_amountOf > 0) then { _woundID = (_openWounds select (_amountOf - 1) select 0) + 1; };
|
||||
_woundID = _unit getvariable[QGVAR(lastUniqueWoundID), 1];
|
||||
|
||||
_woundsCreated = [];
|
||||
{
|
||||
if (_x select 0 <= _damage) exitwith {
|
||||
for "_i" from 0 to (1+ floor(random(_x select 1)-1)) /* step +1 */ do {
|
||||
_toAddInjury = _allPossibleInjuries select (floor(random (count _allPossibleInjuries)));
|
||||
// ID, classname, bodypart, percentage treated, bloodloss rate
|
||||
_openWounds pushback [_woundID, _toAddInjury select 0, if (_injuryTypeInfo select 1) then {_bodyPartn} else {floor(random(6))}, 1, _toAddInjury select 2];
|
||||
_injury = [_woundID, _toAddInjury select 0, if (_injuryTypeInfo select 1) then {_bodyPartn} else {floor(random(6))}, 1, _toAddInjury select 2]
|
||||
_openWounds pushback _injury;
|
||||
_woundsCreated pushback _injury;
|
||||
_woundID = _woundID + 1;
|
||||
};
|
||||
};
|
||||
}foreach (_injuryTypeInfo select 0);
|
||||
|
||||
_unit setvariable [GVAR(openWounds), _openWounds, true];
|
||||
_unit setvariable [GVAR(openWounds), _openWounds];
|
||||
_unit setvariable[QGVAR(lastUniqueWoundID), _woundID, true];
|
||||
|
||||
{
|
||||
["medical_propagateWound", [_unit, _x]] call EFUNC(common,globalEvent);
|
||||
}foreach _woundsCreated;
|
||||
|
37
addons/medical/functions/fnc_onPropagateWound.sqf
Normal file
37
addons/medical/functions/fnc_onPropagateWound.sqf
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* Adds a new injury to the wounds collection from remote clients. Is used to split up the large collection of injuries broadcasting across network.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: The remote unit <OBJECT>
|
||||
* 1: injury <ARRAY>
|
||||
*
|
||||
* Return Value:
|
||||
* None <NIL>
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_unit", "_injury", "_openWounds", "_injuryID", "_exists"];
|
||||
_unit = _this select 0;
|
||||
_injury = _this select 1;
|
||||
|
||||
if (!local _unit) then {
|
||||
_openWounds = _unit getvariable[QGVAR(openWounds), []];
|
||||
_injuryID = _injury select 0;
|
||||
|
||||
_exists = false;
|
||||
{
|
||||
if (_x select 0 == _injuryID) exitwith {
|
||||
_exists = true;
|
||||
_openWounds set [_foreachIndex, _injury];
|
||||
};
|
||||
}foreach _openWounds;
|
||||
|
||||
if (!_exists) then {
|
||||
_openWounds pushback _injury;
|
||||
};
|
||||
_unit setvariable [GVAR(openWounds), _openWounds];
|
||||
};
|
@ -69,14 +69,11 @@ if (_effectivenessFound == 0) exitwith {}; // Seems everything is patched up on
|
||||
// Find the impact this bandage has and reduce the amount this injury is present
|
||||
_impact = if ((_mostEffectiveInjury select 3) >= _effectivenessFound) then {_effectivenessFound} else { (_mostEffectiveInjury select 3) };
|
||||
_mostEffectiveInjury set [ 3, ((_mostEffectiveInjury select 3) - _effectivenessFound) max 0];
|
||||
_openWounds set [_mostEffectiveSpot, _mostEffectiveInjury];
|
||||
|
||||
if (_mostEffectiveInjury select 3 == 0) then {
|
||||
_openWounds deleteAt _mostEffectiveSpot;
|
||||
} else {
|
||||
_openWounds set [_mostEffectiveSpot, _mostEffectiveInjury];
|
||||
};
|
||||
_target setvariable [QGVAR(openWounds), _openWounds];
|
||||
|
||||
_target setvariable [QGVAR(openWounds), _openWounds, true];
|
||||
["medical_propagateWound", [_unit, _mostEffectiveInjury]] call EFUNC(common,globalEvent);
|
||||
|
||||
// Handle the reopening of bandaged wounds
|
||||
if (_impact > 0) then {
|
||||
|
Loading…
Reference in New Issue
Block a user