Split up the openWounds through the ACE event system

Based upon the suggestions from Jaynus
This commit is contained in:
Glowbal 2015-02-28 20:48:34 +01:00
parent d293008586
commit 18998bb619
4 changed files with 51 additions and 11 deletions

View File

@ -57,6 +57,7 @@ PREP(actionCheckResponse);
PREP(actionRemoveTourniquet);
PREP(onTreatmentCompleted);
PREP(onMedicationUsage);
PREP(onPropagateWound);
PREP(reactionToDamage);
PREP(useItem);
PREP(useItems);

View File

@ -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;

View File

@ -0,0 +1,36 @@
/*
* 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"
_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];
};

View File

@ -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 {