Merge pull request #220 from KoffeinFlummi/medical-jip-fixes

Medical jip fixes
This commit is contained in:
Glowbal 2015-03-22 22:36:26 +01:00
commit 0233b923f5
8 changed files with 48 additions and 30 deletions

View File

@ -7,7 +7,6 @@ class CfgVehicles {
}; };
}; };
class ACE_Module; class ACE_Module;
// TODO localization for all the modules // TODO localization for all the modules
class ACE_moduleMedicalSettings: ACE_Module { class ACE_moduleMedicalSettings: ACE_Module {
scope = 2; scope = 2;

View File

@ -2,7 +2,6 @@
#include "script_component.hpp" #include "script_component.hpp"
if (!hasInterface) exitwith{};
GVAR(enabledFor) = 1; // TODO remove this once we implement settings. Just here to get the vitals working. GVAR(enabledFor) = 1; // TODO remove this once we implement settings. Just here to get the vitals working.
GVAR(heartBeatSounds_Fast) = ["ACE_heartbeat_fast_1", "ACE_heartbeat_fast_2", "ACE_heartbeat_fast_3"]; GVAR(heartBeatSounds_Fast) = ["ACE_heartbeat_fast_1", "ACE_heartbeat_fast_2", "ACE_heartbeat_fast_3"];
@ -219,24 +218,14 @@ if (isNil QGVAR(level)) then {
// broadcast injuries to JIP clients in a MP session // broadcast injuries to JIP clients in a MP session
if (isMultiplayer) then { if (isMultiplayer) then {
[QGVAR(onPlayerConnected), "onPlayerConnected", { // We are only pulling the wounds for the units in the player group. Anything else will come when the unit interacts with them.
if (GVAR(level) >= 2) then { if (hasInterface) then {
if (isNil QGVAR(InjuredCollection)) then {
GVAR(InjuredCollection) = [];
};
{ {
_unit = _x; [_x, player] call FUNC(requestWoundSync);
_openWounds = _unit getvariable [QGVAR(openWounds), []]; }foreach units group player;
{
["medical_propagateWound", [_id], [_unit, _x]] call EFUNC(common,targetEvent);
}foreach _openWounds;
}foreach GVAR(InjuredCollection);
}; };
}, []] call BIS_fnc_addStackedEventHandler;
}; };
[ [
{(((_this select 0) getvariable [QGVAR(bloodVolume), 0]) < 65)}, {(((_this select 0) getvariable [QGVAR(bloodVolume), 0]) < 65)},
{(((_this select 0) getvariable [QGVAR(pain), 0]) > 0.9)}, {(((_this select 0) getvariable [QGVAR(pain), 0]) > 0.9)},

View File

@ -89,6 +89,7 @@ PREP(moduleAssignMedicRoles);
PREP(moduleAssignMedicalVehicle); PREP(moduleAssignMedicalVehicle);
PREP(moduleAssignMedicalFacility); PREP(moduleAssignMedicalFacility);
PREP(moduleTreatmentConfiguration); PREP(moduleTreatmentConfiguration);
PREP(requestWoundSync);
GVAR(injuredUnitCollection) = []; GVAR(injuredUnitCollection) = [];
call FUNC(parseConfigForInjuries); call FUNC(parseConfigForInjuries);

View File

@ -18,22 +18,21 @@ _unit = _this select 0;
_force = if (count _this > 1) then {_this select 1} else {false}; _force = if (count _this > 1) then {_this select 1} else {false};
if ([_unit] call FUNC(hasMedicalEnabled) || _force) then { if ([_unit] call FUNC(hasMedicalEnabled) || _force) then {
if ((_unit getvariable[QGVAR(addedToUnitLoop),false] || !alive _unit) && !_force) exitwith{};
if !(local _unit) exitwith { if !(local _unit) exitwith {
[[_unit, _force], QUOTE(DFUNC(addToInjuredCollection)), _unit] call EFUNC(common,execRemoteFnc); /* TODO Replace by event system */ [[_unit, _force], QUOTE(DFUNC(addToInjuredCollection)), _unit] call EFUNC(common,execRemoteFnc); /* TODO Replace by event system */
}; };
if ((_unit getvariable[QGVAR(addedToUnitLoop),false] || !alive _unit) && !_force) exitwith{};
_unit setvariable [QGVAR(addedToUnitLoop), true, true]; _unit setvariable [QGVAR(addedToUnitLoop), true, true];
if (isNil QGVAR(InjuredCollection)) then { diag_log format["[MEDICAL] Added a unit to loop: %1", _unit];
GVAR(InjuredCollection) = [];
};
GVAR(InjuredCollection) pushback _unit;
[{ [{
private "_unit"; private "_unit";
_unit = (_this select 0) select 0; _unit = (_this select 0) select 0;
if (!alive _unit || !local _unit) then { if (!alive _unit || !local _unit) then {
[_this select 1] call CBA_fnc_removePerFrameHandler; [_this select 1] call CBA_fnc_removePerFrameHandler;
diag_log format["[MEDICAL] Removed a unit from loop: %1", _unit];
if (!local _unit) then { if (!local _unit) then {
if (GVAR(level) >= 2) then { if (GVAR(level) >= 2) then {
_unit setvariable [QGVAR(heartRate), _unit getvariable [QGVAR(heartRate), 0], true]; _unit setvariable [QGVAR(heartRate), _unit getvariable [QGVAR(heartRate), 0], true];
@ -41,7 +40,6 @@ if ([_unit] call FUNC(hasMedicalEnabled) || _force) then {
}; };
_unit setvariable [QGVAR(bloodVolume), _unit getvariable [QGVAR(bloodVolume), 0], true]; _unit setvariable [QGVAR(bloodVolume), _unit getvariable [QGVAR(bloodVolume), 0], true];
}; };
GVAR(InjuredCollection) = GVAR(InjuredCollection) - [_unit];
} else { } else {
[_unit] call FUNC(handleUnitVitals); [_unit] call FUNC(handleUnitVitals);

View File

@ -21,6 +21,8 @@ GVAR(currentSelectedSelectionN) = if (count _this > 2) then {_this select 2} els
GVAR(displayPatientInformationTarget) = if (_show) then {_target} else {ObjNull}; GVAR(displayPatientInformationTarget) = if (_show) then {_target} else {ObjNull};
[_target, ACE_player] call FUNC(requestWoundSync);
if (_show) then { if (_show) then {
("ACE_MedicalRscDisplayInformation" call BIS_fnc_rscLayer) cutRsc [QGVAR(DisplayInformation),"PLAIN"]; ("ACE_MedicalRscDisplayInformation" call BIS_fnc_rscLayer) cutRsc [QGVAR(DisplayInformation),"PLAIN"];

View File

@ -22,4 +22,9 @@ if (GVAR(level) >= 2) then {
_unit setvariable [QGVAR(heartRate), 0]; _unit setvariable [QGVAR(heartRate), 0];
_unit setvariable [QGVAR(bloodPressure), [0, 0]]; _unit setvariable [QGVAR(bloodPressure), [0, 0]];
_unit setvariable [QGVAR(airwayStatus), 0]; _unit setvariable [QGVAR(airwayStatus), 0];
_openWounds = _unit getvariable [QGVAR(openWounds), []];
{
["medical_propagateWound", [_unit, _x]] call EFUNC(common,globalEvent);
}foreach _openWounds;
}; };

View File

@ -19,8 +19,8 @@ _unit = _this select 0;
_lastId = _this select 1; _lastId = _this select 1;
_originOfrequest = _this select 2; _originOfrequest = _this select 2;
_openWounds = _unit getvariable [QGVAR(openWounds), []]; if (local _unit) then {
if (count _openWounds > _lastId) then { _openWounds = _unit getvariable [QGVAR(openWounds), []];
{ {
["medical_propagateWound", [_originOfrequest], [_unit, _x]] call EFUNC(common,targetEvent); ["medical_propagateWound", [_originOfrequest], [_unit, _x]] call EFUNC(common,targetEvent);
}foreach _openWounds; }foreach _openWounds;

View File

@ -0,0 +1,24 @@
/*
* Author: Glowbal
* Ask for the latest wound information.
*
* Arguments:
* 0: The target <OBJECT>
* 1: object belonging to the caller <OBJECT>
*
* ReturnValue:
* <NIL>
*
* Public: Yes
*/
#include "script_component.hpp"
private [ "_target", "_caller", "_openWounds","_lastId"];
_target = _this select 0;
_caller = _this select 1;
if (local _target || GVAR(level) < 2) exitwith {}; // if the target is local, we already got the most update to date information
if (_target getvariable [QGVAR(isWoundSynced), false]) exitwith {};
_target setvariable [QGVAR(isWoundSynced), true];
["medical_woundUpdateRequest", [_target], [_target, _lastId, _caller]] call EFUNC(common,targetEvent);