Merge branch 'simpleDiagnosis' into streamlinedBasicDiagnosis

This commit is contained in:
esteldunedain 2015-04-20 10:24:59 -03:00
commit 7953919b89
32 changed files with 306 additions and 143 deletions

View File

@ -27,7 +27,7 @@ if ((local _unit) && {!([_unit] call EFUNC(common,isPlayer))}) then {
_unit disableConversation true;
} else {
//Sanity check to make sure we don't enable unconsious AI
if (_unit getVariable ["ace_isunconscious", false]) exitWith {ERROR("Enabling AI for unconsious unit");};
if (_unit getVariable ["ace_isunconscious", false] && alive _unit) exitWith {ERROR("Enabling AI for unconsious unit");};
_unit enableAI "MOVE";
_unit enableAI "TARGET";
_unit enableAI "AUTOTARGET";

View File

@ -9,8 +9,6 @@ _isUnconscious = _this select 1;
private "_player";
_player = ACE_player;
if ((_unit getHitPointDamage "HitLeftLeg") + (_unit getHitPointDamage "HitRightLeg") > 0.4) exitwith {};
if (_player getVariable [QGVAR(isDragging), false]) then {
private "_draggedObject";
@ -22,9 +20,9 @@ if (_player getVariable [QGVAR(isDragging), false]) then {
};
// handle waking up dragged unit
if (_unit == _draggedObject) then {
[_player, _draggedObject] call FUNC(dropObject);
};
//if (_unit == _draggedObject) then {
// [_player, _draggedObject] call FUNC(dropObject);
//};
};
@ -39,8 +37,8 @@ if (_player getVariable [QGVAR(isCarrying), false]) then {
};
// handle waking up dragged unit
if (_unit == _carriedObject) then {
[_player, _carriedObject] call FUNC(dropObject_carry);
};
//if (_unit == _carriedObject) then {
// [_player, _carriedObject] call FUNC(dropObject_carry);
//};
};

View File

@ -4,6 +4,7 @@ class ACE_Head {
runOnHover = 1;
statement = QUOTE([ARR_3(_target, true, 0)] call DFUNC(displayPatientInformation));
modifierFunction = QUOTE([ARR_4(_target,_player,0,_this select 3)] call FUNC(modifyMedicalAction));
condition = "true";
EXCEPTIONS
icon = PATHTOF(UI\icons\medical_cross.paa);
distance = MEDICAL_ACTION_DISTANCE;
@ -70,12 +71,19 @@ class ACE_Head {
statement = QUOTE([ARR_4(_player, _target, 'head', 'CheckResponse')] call DFUNC(treatment));
EXCEPTIONS
};
class Diagnose: CheckPulse {
displayName = "Diagnose";
condition = QUOTE([ARR_4(_player, _target, 'head', 'Diagnose')] call DFUNC(canTreatCached));
statement = QUOTE([ARR_4(_player, _target, 'head', 'Diagnose')] call DFUNC(treatment));
EXCEPTIONS
};
};
class ACE_Torso {
displayName = "$STR_ACE_Interaction_Torso";
runOnHover = 1;
statement = QUOTE([ARR_3(_target, true, 1)] call DFUNC(displayPatientInformation));
modifierFunction = QUOTE([ARR_4(_target,_player,1,_this select 3)] call FUNC(modifyMedicalAction));
condition = "true";
EXCEPTIONS
icon = PATHTOF(UI\icons\medical_cross.paa);
distance = MEDICAL_ACTION_DISTANCE;
@ -176,6 +184,7 @@ class ACE_ArmLeft {
runOnHover = 1;
statement = QUOTE([ARR_3(_target, true, 2)] call DFUNC(displayPatientInformation));
modifierFunction = QUOTE([ARR_4(_target,_player,2,_this select 3)] call FUNC(modifyMedicalAction));
condition = "true";
EXCEPTIONS
icon = PATHTOF(UI\icons\medical_cross.paa);
distance = MEDICAL_ACTION_DISTANCE;
@ -333,6 +342,7 @@ class ACE_ArmRight {
runOnHover = 1;
statement = QUOTE([ARR_3(_target, true, 3)] call DFUNC(displayPatientInformation));
modifierFunction = QUOTE([ARR_4(_target,_player,3,_this select 3)] call FUNC(modifyMedicalAction));
condition = "true";
EXCEPTIONS
icon = PATHTOF(UI\icons\medical_cross.paa);
distance = MEDICAL_ACTION_DISTANCE;
@ -427,8 +437,8 @@ class ACE_ArmRight {
};
class PlasmaIV: BloodIV {
displayName = "$STR_ACE_MEDICAL_ACTIONS_Plasma4_1000";
condition = QUOTE([ARR_4(_player, _target, 'hand_r', 'BloodIV')] call DFUNC(canTreatCached));
statement = QUOTE([ARR_4(_player, _target, 'hand_r', 'BloodIV')] call DFUNC(treatment));
condition = QUOTE([ARR_4(_player, _target, 'hand_r', 'PlasmaIV')] call DFUNC(canTreatCached));
statement = QUOTE([ARR_4(_player, _target, 'hand_r', 'PlasmaIV')] call DFUNC(treatment));
EXCEPTIONS
};
class PlasmaIV_500: PlasmaIV {
@ -487,6 +497,7 @@ class ACE_LegLeft {
runOnHover = 1;
statement = QUOTE([ARR_3(_target, true, 4)] call DFUNC(displayPatientInformation));
modifierFunction = QUOTE([ARR_4(_target,_player,4,_this select 3)] call FUNC(modifyMedicalAction));
condition = "true";
EXCEPTIONS
icon = PATHTOF(UI\icons\medical_cross.paa);
distance = MEDICAL_ACTION_DISTANCE;
@ -583,8 +594,8 @@ class ACE_LegLeft {
};
class PlasmaIV: BloodIV {
displayName = "$STR_ACE_MEDICAL_ACTIONS_Plasma4_1000";
condition = QUOTE([ARR_4(_player, _target, 'leg_l', 'BloodIV')] call DFUNC(canTreatCached));
statement = QUOTE([ARR_4(_player, _target, 'leg_l', 'BloodIV')] call DFUNC(treatment));
condition = QUOTE([ARR_4(_player, _target, 'leg_l', 'PlasmaIV')] call DFUNC(canTreatCached));
statement = QUOTE([ARR_4(_player, _target, 'leg_l', 'PlasmaIV')] call DFUNC(treatment));
EXCEPTIONS
};
class PlasmaIV_500: PlasmaIV {
@ -629,6 +640,7 @@ class ACE_LegRight {
runOnHover = 1;
statement = QUOTE([ARR_3(_target, true, 5)] call DFUNC(displayPatientInformation));
modifierFunction = QUOTE([ARR_4(_target,_player,5,_this select 3)] call FUNC(modifyMedicalAction));
condition = "true";
EXCEPTIONS
icon = PATHTOF(UI\icons\medical_cross.paa);
distance = MEDICAL_ACTION_DISTANCE;
@ -724,8 +736,8 @@ class ACE_LegRight {
};
class PlasmaIV: BloodIV {
displayName = "$STR_ACE_MEDICAL_ACTIONS_Plasma4_1000";
condition = QUOTE([ARR_4(_player, _target, 'leg_r', 'BloodIV')] call DFUNC(canTreatCached));
statement = QUOTE([ARR_4(_player, _target, 'leg_r', 'BloodIV')] call DFUNC(treatment));
condition = QUOTE([ARR_4(_player, _target, 'leg_r', 'PlasmaIV')] call DFUNC(canTreatCached));
statement = QUOTE([ARR_4(_player, _target, 'leg_r', 'PlasmaIV')] call DFUNC(treatment));
EXCEPTIONS
};
class PlasmaIV_500: PlasmaIV {

View File

@ -4,6 +4,7 @@ class Medical {
hotkey = "M";
exceptions[] = {"isNotInside"};
statement = QUOTE([ARR_3(_target, true, 0)] call DFUNC(displayPatientInformation));
condition = "true";
icon = PATHTOF(UI\icons\medical_cross.paa);
class ACE_Head {
@ -12,6 +13,7 @@ class Medical {
exceptions[] = {"isNotInside"};
statement = QUOTE([ARR_3(_target, true, 0)] call DFUNC(displayPatientInformation));
modifierFunction = QUOTE([ARR_4(_target,_player,0,_this select 3)] call FUNC(modifyMedicalAction));
condition = "true";
runOnHover = 1;
class Bandage {
@ -149,6 +151,7 @@ class Medical {
exceptions[] = {"isNotInside"};
statement = QUOTE([ARR_3(_target, true, 2)] call DFUNC(displayPatientInformation));
modifierFunction = QUOTE([ARR_4(_target,_player,2,_this select 3)] call FUNC(modifyMedicalAction));
condition = "true";
icon = PATHTOF(UI\icons\medical_cross.paa);
class Bandage {
@ -250,6 +253,7 @@ class Medical {
exceptions[] = {"isNotInside"};
statement = QUOTE([ARR_3(_target, true, 3)] call DFUNC(displayPatientInformation));
modifierFunction = QUOTE([ARR_4(_target,_player,3,_this select 3)] call FUNC(modifyMedicalAction));
condition = "true";
icon = PATHTOF(UI\icons\medical_cross.paa);
class Bandage {
@ -347,6 +351,7 @@ class Medical {
exceptions[] = {"isNotInside"};
statement = QUOTE([ARR_3(_target, true, 4)] call DFUNC(displayPatientInformation));
modifierFunction = QUOTE([ARR_4(_target,_player,4,_this select 3)] call FUNC(modifyMedicalAction));
condition = "true";
icon = PATHTOF(UI\icons\medical_cross.paa);
class Bandage {
@ -433,6 +438,7 @@ class Medical {
exceptions[] = {"isNotInside"};
statement = QUOTE([ARR_3(_target, true, 5)] call DFUNC(displayPatientInformation));
modifierFunction = QUOTE([ARR_4(_target,_player,5,_this select 3)] call FUNC(modifyMedicalAction));
condition = "true";
icon = PATHTOF(UI\icons\medical_cross.paa);
class Bandage {

View File

@ -71,14 +71,14 @@ class ACE_Medical_Actions {
itemConsumed = 1;
litter[] = {};
};
class CheckPulse: Bandage {
displayName = "";
displayNameProgress = "";
class Diagnose: Bandage {
displayName = "Diagnose";
displayNameProgress = "Diagnosing...";
treatmentLocations[] = {"All"};
requiredMedic = 0;
treatmentTime = 2;
treatmentTime = 1;
items[] = {};
callbackSuccess = QUOTE(DFUNC(actionCheckPulse));
callbackSuccess = QUOTE(DFUNC(actionDiagnose));
callbackFailure = "";
callbackProgress = "";
animationPatient = "";
@ -86,12 +86,6 @@ class ACE_Medical_Actions {
itemConsumed = 0;
litter[] = {};
};
class CheckBloodPressure: CheckPulse {
callbackSuccess = QUOTE(DFUNC(actionCheckBloodPressure));
};
class CheckResponse: CheckPulse {
callbackSuccess = QUOTE(DFUNC(actionCheckResponse));
};
};
class Advanced {

View File

@ -135,4 +135,8 @@ class ACE_Settings {
values[] = {"$STR_ACE_Medical_painEffect_Flash", "$STR_ACE_Medical_painEffect_Chroma"};
isClientSettable = 1;
};
class GVAR(allowUnconsciousAnimationOnTreatment) {
typeName = "BOOL";
value = 0;
};
};

View File

@ -4,7 +4,4 @@ private ["_unit"];
_unit = _this select 0;
_unit addEventHandler ["HandleDamage", {_this call FUNC(handleDamage)}];
if (local _unit) then {
[_unit] call FUNC(init);
};
[_unit] call FUNC(init);

View File

@ -241,7 +241,7 @@ if (USE_WOUND_EVENT_SYNC) then {
// We are only pulling the wounds for the units in the player group. Anything else will come when the unit interacts with them.
{
[_x, _newPlayer] call FUNC(requestWoundSync);
}foreach units group player;
}foreach units group _newPlayer;
};
}] call EFUNC(common,addEventhandler);
};

View File

@ -7,6 +7,8 @@ PREP(actionCheckBloodPressureLocal);
PREP(actionCheckPulse);
PREP(actionCheckPulseLocal);
PREP(actionCheckResponse);
PREP(actionDiagnose);
PREP(actionDiagnoseLocal);
PREP(actionPlaceInBodyBag);
PREP(actionRemoveTourniquet);
PREP(actionLoadUnit);
@ -97,6 +99,7 @@ PREP(moduleAssignMedicalFacility);
PREP(moduleTreatmentConfiguration);
PREP(copyDeadBody);
PREP(requestWoundSync);
PREP(unconsciousPFH);
// Networked litter
PREP(createLitter);

View File

@ -6,8 +6,7 @@ _unit = _this select 0;
if !(local _unit) exitWith {};
diag_log "running respawn";
[_unit] call FUNC(init);
[_unit, true] call FUNC(init);
//Reset captive status for respawning unit
if (!(_unit getVariable ["ACE_isUnconscious", false])) then {

View File

@ -0,0 +1,20 @@
/*
* Author: Glowbal
* Action for diagnosing in basic medical
*
* Arguments:
* 0: The medic <OBJECT>
* 1: The patient <OBJECT>
*
* Return Value:
* NONE
*
* Public: No
*/
#include "script_component.hpp"
private ["_caller","_target","_title","_content"];
_caller = _this select 0;
_target = _this select 1;
[[_caller, _target], QUOTE(DFUNC(actionDiagnoseLocal)), _target] call EFUNC(common,execRemoteFnc); /* TODO Replace by event system */

View File

@ -0,0 +1,40 @@
/*
* Author: Glowbal
* Local callback for checking the pulse of a patient
*
* Arguments:
* 0: The medic <OBJECT>
* 1: The patient <OBJECT>
*
* Return Value:
* NONE
*
* Public: No
*/
#include "script_component.hpp"
_caller = _this select 0;
_unit = _this select 1;
_genericMessages = ["Patient %1<br/>is %2.<br/>%3.<br/>%4"];
_genericMessages pushBack ([_unit] call EFUNC(common,getName));
if (alive _unit) then {
_genericMessages pushback "alive";
} else {
_genericMessages pushback "dead";
};
if (_target getvariable[QGVAR(hasLostBlood), false]) then {
_genericMessages pushback "He's lost some blood";
} else {
_genericMessages pushback "He hasn't lost blood";
};
if (_target getvariable[QGVAR(hasPain), false]) then {
_genericMessages pushback "He is in pain";
} else {
_genericMessages pushback "He is not in pain";
};
diag_log _genericMessages;
["displayTextStructured", [_caller], [format _genericMessages, 3.0, _caller]] call EFUNC(common,targetEvent);

View File

@ -19,4 +19,4 @@
#define MAX_DURATION_CACHE 2
// parameters, function, namespace, uid
[_this, DFUNC(canTreat), _this select 0, format[QGVAR(canTreat_%1_%2), _this select 2, _this select 3], MAX_DURATION_CACHE, "clearConditionCaches"] call EFUNC(common,cachedCall);
[_this, DFUNC(canTreat), _this select 1, format[QGVAR(canTreat_%1_%2), _this select 2, _this select 3], MAX_DURATION_CACHE, "clearConditionCaches"] call EFUNC(common,cachedCall);

View File

@ -21,10 +21,10 @@ if ((vehicle _unit != _unit) && {!alive (vehicle _unit)}) exitwith { true };
// Find the correct Damage threshold for unit.
_damageThreshold = [1,1,1];
if (isPlayer _unit) then {
//_damageThreshold =_unit getvariable[QGVAR(unitDamageThreshold), [GVAR(damageThreshold_Players), GVAR(damageThreshold_Players), GVAR(damageThreshold_Players) * 1.7]];
if ([_unit] call EFUNC(common,IsPlayer)) then {
_damageThreshold =_unit getvariable[QGVAR(unitDamageThreshold), [GVAR(playerDamageThreshold), GVAR(playerDamageThreshold), GVAR(playerDamageThreshold) * 1.7]];
} else {
//_damageThreshold =_unit getvariable[QGVAR(unitDamageThreshold), [GVAR(damageThreshold_AI), GVAR(damageThreshold_AI), GVAR(damageThreshold_AI) * 1.7]];
_damageThreshold =_unit getvariable[QGVAR(unitDamageThreshold), [GVAR(AIDamageThreshold), GVAR(AIDamageThreshold), GVAR(AIDamageThreshold) * 1.7]];
};
_damageBodyPart = ((_unit getvariable [QGVAR(bodyPartStatus),[0, 0, 0, 0, 0, 0]]) select _part) + _withDamage;

View File

@ -59,20 +59,30 @@ if (isClass (_config >> _className)) then {
_bandagedWounds = _target getvariable [QGVAR(bandagedWounds), []];
_exist = false;
_injuryId = _injury select 0;
_bandagedInjury = [];
{
if ((_x select 0) == _injuryId) exitwith {
_exist = true;
_existingInjury = _x;
_existingInjury set [3, (_existingInjury select 3) + _impact];
_bandagedWounds set [_foreachIndex, _existingInjury];
_bandagedInjury = _existingInjury;
};
}foreach _bandagedWounds;
if !(_exist) then {
// [ID, classID, bodypart, percentage treated, bloodloss rate]
_bandagedWounds pushback [_injuryId, _injury select 1, _injury select 2, _impact, _injury select 4];
_bandagedInjury = [_injuryId, _injury select 1, _injury select 2, _impact, _injury select 4];
_bandagedWounds pushback _bandagedInjury;
};
_target setvariable [QGVAR(bandagedWounds), _bandagedWounds, !USE_WOUND_EVENT_SYNC];
if (USE_WOUND_EVENT_SYNC) then {
// sync _bandagedInjury
};
_target setvariable [QGVAR(bandagedWounds), _bandagedWounds, true];
// Check if we are ever going to reopen this
if (random(1) <= _reopeningChance) then {
@ -109,7 +119,7 @@ if (random(1) <= _reopeningChance) then {
}foreach _bandagedWounds;
if (_exist) then {
_target setvariable [QGVAR(bandagedWounds), _bandagedWounds, true];
_target setvariable [QGVAR(bandagedWounds), _bandagedWounds, !USE_WOUND_EVENT_SYNC];
};
};
// Otherwise something went wrong, we we don't reopen them..

View File

@ -57,6 +57,12 @@ if (GVAR(level) >= 2) then {
_minLethalDamage = GVAR(minLethalDamages) select _typeIndex;
};
if (vehicle _unit != _unit && {!(vehicle _unit isKindOf "StaticWeapon")} && {isNull _source} && {_projectile == ""} && {_selection == ""}) then {
if (GVAR(enableVehicleCrashes)) then {
_selection = GVAR(SELECTIONS) select (floor(random(count GVAR(SELECTIONS))));
};
};
if ((_minLethalDamage <= _newDamage) && {[_unit, [_selection] call FUNC(selectionNameToNumber), _newDamage] call FUNC(determineIfFatal)} && {_selection in ["", "head", "body"]}) then {
if ([_unit] call FUNC(setDead)) then {
_damageReturn = 1;

View File

@ -33,10 +33,12 @@ if (isNull _sourceOfDamage && {_typeOfProjectile == ""} && {vehicle _unit == _un
};
_typeOfDamage = [_typeOfProjectile] call FUNC(getTypeOfDamage);
_part = [_selectionName] call FUNC(selectionNameToNumber);
if (_part < 0) exitwith {};
_hitPoints = ["HitHead", "HitBody", "HitLeftArm", "HitRightArm", "HitLeftLeg", "HitRightLeg"];
// Sorting out the damage
_damageBodyParts = _unit getvariable [QGVAR(bodyPartStatus), [0,0,0,0,0,0]];
_damageBodyParts set [_part, (_damageBodyParts select _part) + _newDamage];
_unit setvariable [QGVAR(bodyPartStatus), _damageBodyParts, true];

View File

@ -63,6 +63,12 @@ if (_selectionName in GVAR(SELECTIONS)) then {
_newDamage = _damage - (_unit getHitPointDamage (GVAR(HITPOINTS) select (GVAR(SELECTIONS) find _selectionName)));
};
if ([_unit] call EFUNC(common,isPlayer)) then {
_newDamage = _newDamage / (GVAR(playerDamageThreshold) max 0.01);
} else {
_newDamage = _newDamage / (GVAR(AIDamageThreshold) max 0.01);
};
_damage = _damage - _newDamage;

View File

@ -38,7 +38,7 @@ if (_selectionName in _hitSelections) then {
// Check for vehicle crash
if (vehicle _unit != _unit && {!(vehicle _unit isKindOf "StaticWeapon")} && {isNull _source} && {_projectile == ""} && {_selectionName == ""}) then {
if (missionNamespace getvariable [QGVAR(allowVehicleCrashDamage), true]) then {
if (GVAR(enableVehicleCrashes)) then {
_selectionName = _hitSelections select (floor(random(count _hitSelections)));
_projectile = "vehiclecrash";
};

View File

@ -133,7 +133,6 @@ if (count _woundsCreated > 0) then {
};
if (USE_WOUND_EVENT_SYNC) then {
// TODO Should this be done in a single broadcast?
// Broadcast the new injuries across the net in parts. One broadcast per injury. Prevents having to broadcast one massive array of injuries.
{
["medical_propagateWound", [_unit, _x]] call EFUNC(common,globalEvent);

View File

@ -22,4 +22,14 @@ if (_local) then {
if (_unit getvariable[QGVAR(addedToUnitLoop),false]) then {
[_unit, true] call FUNC(addToInjuredCollection);
};
if ((_unit getvariable ["ACE_isUnconscious",false]) && {count (_unit getvariable [QGVAR(unconsciousArguments), []]) >= 7}) then {
private "_arguments";
_arguments = (_unit getvariable [QGVAR(unconsciousArguments), []]);
_arguments set [ 3, time];
[DFUNC(unconsciousPFH), 0.1, _arguments ] call CBA_fnc_addPerFrameHandler;
_unit setvariable [QGVAR(unconsciousArguments), nil, true];
};
};

View File

@ -94,7 +94,7 @@ if (GVAR(level) >= 2) then {
if ([_unit] call EFUNC(common,isAwake)) then {
if (_bloodVolume < 60) then {
if (random(1) > 0.9) then {
[_unit] call FUNC(setUnconscious);
[_unit, true, 15 + random(20)] call FUNC(setUnconscious);
};
};
};
@ -136,7 +136,7 @@ if (GVAR(level) >= 2) then {
if (!(_unit getvariable [QGVAR(inCardiacArrest),false])) then {
if (_heartRate < 10 || _bloodPressureH < 30 || _bloodVolume < 20) then {
[_unit] call FUNC(setUnconscious); // safety check to ensure unconsciousness for units if they are not dead already.
[_unit, true, 10+ random(20)] call FUNC(setUnconscious); // safety check to ensure unconsciousness for units if they are not dead already.
};
if (_bloodPressureH > 260) then {

View File

@ -13,21 +13,25 @@
#include "script_component.hpp"
private ["_unit", "_allUsedMedication", "_logs"];
private ["_unit", "_allUsedMedication", "_logs", "_forceNew"];
_unit = _this select 0;
_forceNew = if (count _this > 1) then {_this select 1} else {false};
_unit setVariable [QGVAR(pain), 0, true];
_unit setVariable [QGVAR(morphine), 0, true];
_unit setVariable [QGVAR(bloodVolume), 100, true];
if (!(isnil {_unit getvariable QGVAR(triageLevel)}) && !_forceNew) exitwith {};
_unit setVariable [QGVAR(pain), 0];
_unit setVariable [QGVAR(morphine), 0];
_unit setVariable [QGVAR(bloodVolume), 100];
// tourniquets
_unit setvariable [QGVAR(tourniquets), [0,0,0,0,0,0], true];
_unit setvariable [QGVAR(tourniquets), [0,0,0,0,0,0]];
// wounds and injuries
_unit setvariable [QGVAR(openWounds), [], true];
_unit setvariable [QGVAR(bandagedWounds), [], true];
_unit setVariable [QGVAR(internalWounds), [], true];
_unit setvariable [QGVAR(openWounds), []];
_unit setvariable [QGVAR(bandagedWounds), []];
_unit setVariable [QGVAR(internalWounds), []];
_unit setvariable [QGVAR(lastUniqueWoundID), 1];
// vitals
_unit setVariable [QGVAR(heartRate), 80];
@ -39,8 +43,8 @@ _unit setVariable [QGVAR(peripheralResistance), 100];
_unit setVariable [QGVAR(fractures), []];
// triage card and logs
_unit setvariable [QGVAR(triageLevel), 0, true];
_unit setvariable [QGVAR(triageCard), [], true];
_unit setvariable [QGVAR(triageLevel), 0];
_unit setvariable [QGVAR(triageCard), []];
// IVs
_unit setVariable [QGVAR(salineIVVolume), 0];
@ -48,21 +52,21 @@ _unit setVariable [QGVAR(plasmaIVVolume), 0];
_unit setVariable [QGVAR(bloodIVVolume), 0];
// damage storage
_unit setvariable [QGVAR(bodyPartStatus), [0,0,0,0,0,0], true];
_unit setvariable [QGVAR(bodyPartStatus), [0,0,0,0,0,0]];
// airway
_unit setvariable [QGVAR(airwayStatus), 100, true];
_unit setVariable [QGVAR(airwayOccluded), false, true];
_unit setvariable [QGVAR(airwayCollapsed), false, true];
_unit setvariable [QGVAR(airwayStatus), 100];
_unit setVariable [QGVAR(airwayOccluded), false];
_unit setvariable [QGVAR(airwayCollapsed), false];
// generic medical admin
_unit setvariable [QGVAR(addedToUnitLoop), false, true];
_unit setvariable [QGVAR(inCardiacArrest), false, true];
_unit setVariable ["ACE_isUnconscious", false, true];
_unit setvariable [QGVAR(hasLostBlood), false, true];
_unit setvariable [QGVAR(isBleeding), false, true];
_unit setvariable [QGVAR(hasPain), false, true];
_unit setvariable [QGVAR(amountOfReviveLives), GVAR(amountOfReviveLives), true];
_unit setvariable [QGVAR(addedToUnitLoop), false];
_unit setvariable [QGVAR(inCardiacArrest), false];
_unit setVariable ["ACE_isUnconscious", false];
_unit setvariable [QGVAR(hasLostBlood), false];
_unit setvariable [QGVAR(isBleeding), false];
_unit setvariable [QGVAR(hasPain), false];
_unit setvariable [QGVAR(amountOfReviveLives), GVAR(amountOfReviveLives)];
// medication
_allUsedMedication = _unit getVariable [QGVAR(allUsedMedication), []];
@ -73,9 +77,9 @@ _unit setVariable [QGVAR(allUsedMedication), []];
_logs = _unit getvariable [QGVAR(allLogs), []];
{
_unit setvariable [_x, nil, true];
_unit setvariable [_x, nil];
} foreach _logs;
_unit setvariable [QGVAR(allLogs), [], true];
_unit setvariable [QGVAR(allLogs), []];
// items
[{

View File

@ -1,11 +1,10 @@
/*
* Author: Glowbal
* Enabled the vitals loop for a unit.
* Handles an wound update request.
*
* Arguments:
* 0: The Unit <OBJECT>
* 1: the last known ID <NUMBER>
* 2: Origin object <OBJECT>
* 1: Origin object <OBJECT>
*
* ReturnValue:
* <NIL>
@ -14,12 +13,11 @@
*/
#include "script_component.hpp"
private ["_unit", "_lastId", "_openWounds"];
private ["_unit", "_openWounds"];
_unit = _this select 0;
_lastId = _this select 1;
_originOfrequest = _this select 2;
_originOfrequest = _this select 1;
if (local _unit) then {
if (local _unit && !(local _originOfrequest)) then {
_openWounds = _unit getvariable [QGVAR(openWounds), []];
{
["medical_propagateWound", [_originOfrequest], [_unit, _x]] call EFUNC(common,targetEvent);

View File

@ -14,11 +14,11 @@
#include "script_component.hpp"
private [ "_target", "_caller", "_openWounds","_lastId"];
private [ "_target", "_caller", "_openWounds"];
_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);
["medical_woundUpdateRequest", [_target], [_target, _caller]] call EFUNC(common,targetEvent);

View File

@ -23,7 +23,7 @@ _set = if (count _this > 1) then {_this select 1} else {true};
_minWaitingTime = if (count _this > 2) then {_this select 2} else {DEFAULT_DELAY};
if !(_set) exitwith {
_unit setvariable ["ACE_isUnconscious", false,true];
_unit setvariable ["ACE_isUnconscious", false, true];
};
if !(!(isNull _unit) && {(_unit isKindOf "CaManBase") && ([_unit] call EFUNC(common,isAwake))}) exitwith{};
@ -40,6 +40,11 @@ if (_unit == ACE_player) then {
closeDialog 0;
};
// if we have unconsciousness for AI disabled, we will kill the unit instead
if (!([_unit] call EFUNC(common,IsPlayer)) && (GVAR(enableUnsconsiousnessAI) == 0 || (GVAR(enableUnsconsiousnessAI) == 2 && random(1) <= 0.5))) exitwith {
[_unit, true] call FUNC(setDead); // force, to avoid getting into a loop in case revive is enabled.
};
// If a unit has the launcher out, it will sometimes start selecting the primairy weapon while unconscious,
// therefor we force it to select the primairy weapon before going unconscious
if ((vehicle _unit) isKindOf "StaticWeapon") then {
@ -75,66 +80,6 @@ _unit setUnitPos "DOWN";
_startingTime = time;
[{
private ["_unit", "_vehicleOfUnit","_minWaitingTime", "_oldAnimation", "_captiveSwitch", "_hasMovedOut"];
_args = _this select 0;
_unit = _args select 0;
_oldAnimation = _args select 1;
_originalPos = _args select 2;
_startingTime = _args select 3;
_minWaitingTime = _args select 4;
_hasMovedOut = _args select 5;
if (!alive _unit) exitwith {
[(_this select 1)] call cba_fnc_removePerFrameHandler;
};
// In case the unit is no longer in an unconscious state, we are going to check if we can already reset the animation
if !(_unit getvariable ["ACE_isUnconscious",false]) exitwith {
// TODO, handle this with carry instead, so we can remove the PFH here.
// Wait until the unit isn't being carried anymore, so we won't end up with wierd animations
if !(([_unit] call FUNC(isBeingCarried)) || ([_unit] call FUNC(isBeingDragged))) then {
if (vehicle _unit == _unit) then {
if (animationState _unit == "AinjPpneMstpSnonWrflDnon") then {
[_unit,"AinjPpneMstpSnonWrflDnon_rolltofront", 2] call EFUNC(common,doAnimation);
[_unit,"amovppnemstpsnonwnondnon", 1] call EFUNC(common,doAnimation);
} else {
[_unit,"amovppnemstpsnonwnondnon", 2] call EFUNC(common,doAnimation);
};
} else {
// Switch to the units original animation, assuming
// TODO: what if the unit switched vehicle?
[_unit, _oldAnimation, 2] call EFUNC(common,doAnimation);
};
// EXIT PFH
[(_this select 1)] call cba_fnc_removePerFrameHandler;
};
if (!_hasMovedOut) then {
// Reset the unit back to the previous captive state.
[_unit, QGVAR(unconscious), false] call EFUNC(common,setCaptivityStatus);
// Swhich the unit back to its original group
//Unconscious units shouldn't be put in another group #527:
// [_unit, false, "ACE_isUnconscious", side group _unit] call EFUNC(common,switchToGroupSide);
[_unit, false] call EFUNC(common,disableAI);
_unit setUnitPos _originalPos; // This is not position but stance (DOWN, MIDDLE, UP)
_unit setUnconscious false;
["medical_onUnconscious", [_unit, false]] call EFUNC(common,globalEvent);
// ensure this statement runs only once
_args set [5, true];
};
};
// Ensure we are waiting at least a minimum period before checking if we can wake up the unit again, allows for temp knock outs
if ((time - _startingTime) >= _minWaitingTime) exitwith {
if (!([_unit] call FUNC(getUnconsciousCondition))) then {
_unit setvariable ["ACE_isUnconscious", false, true];
};
};
}, 0.1, [_unit,_animState, _originalPos, _startingTime, _minWaitingTime, false] ] call CBA_fnc_addPerFrameHandler;
[DFUNC(unconsciousPFH), 0.1, [_unit,_animState, _originalPos, _startingTime, _minWaitingTime, false, vehicle _unit isKindOf "ParachuteBase"] ] call CBA_fnc_addPerFrameHandler;
["medical_onUnconscious", [_unit, true]] call EFUNC(common,globalEvent);

View File

@ -129,7 +129,7 @@ if (isNil _callbackProgress) then {
// Patient Animation
_patientAnim = getText (_config >> "animationPatient");
if (_target getvariable ["ACE_isUnconscious", false]) then {
if (_target getvariable ["ACE_isUnconscious", false] && GVAR(allowUnconsciousAnimationOnTreatment)) then {
if !(animationState _target in (getArray (_config >> "animationPatientUnconsciousExcludeOn"))) then {
_patientAnim = getText (_config >> "animationPatientUnconscious");
};
@ -149,6 +149,8 @@ if (_caller == _target) then {
_callerAnim = [getText (_config >> "animationCallerSelf"), getText (_config >> "animationCallerSelfProne")] select (stance _caller == "PRONE");
};
_caller setvariable [QGVAR(selectedWeaponOnTreatment), currentWeapon _caller];
// Cannot use secondairy weapon for animation
if (currentWeapon _caller == secondaryWeapon _caller) then {
_caller selectWeapon (primaryWeapon _caller);

View File

@ -92,7 +92,8 @@ if (USE_WOUND_EVENT_SYNC) then {
};
// Handle the reopening of bandaged wounds
if (_impact > 0 && {GVAR(enableAdvancedWounds)}) then {
[_target, _impact, _part, _mostEffectiveSpot, _mostEffectiveInjury, _bandage] call FUNC(handleBandageOpening);
// TODO temp disabled until bandaged wounds are supported by event sync.
// [_target, _impact, _part, _mostEffectiveSpot, _mostEffectiveInjury, _bandage] call FUNC(handleBandageOpening);
};
// If all wounds have been bandaged, we will reset all damage to 0, so the unit is not showing any blood on the model anymore.

View File

@ -17,7 +17,7 @@
#include "script_component.hpp"
private ["_caller", "_target","_selectionName","_className","_config","_callback", "_usersOfItems"];
private ["_caller", "_target","_selectionName","_className","_config","_callback", "_usersOfItems", "_weaponSelect"];
_args = _this select 0;
_caller = _args select 0;
@ -34,6 +34,13 @@ if (vehicle _caller == _caller) then {
};
_caller setvariable [QGVAR(treatmentPrevAnimCaller), nil];
_weaponSelect = (_caller getvariable [QGVAR(selectedWeaponOnTreatment), ""]);
if (_weaponSelect != "") then {
_caller selectWeapon _weaponSelect;
} else {
_caller action ["SwitchWeapon", _caller, _caller, 99];
};
{
(_x select 0) addItem (_x select 1);
}foreach _usersOfItems;

View File

@ -17,7 +17,7 @@
#include "script_component.hpp"
private ["_caller", "_target","_selectionName","_className","_config","_callback"];
private ["_caller", "_target","_selectionName","_className","_config","_callback", "_weaponSelect"];
_args = _this select 0;
_caller = _args select 0;
_target = _args select 1;
@ -32,6 +32,13 @@ if (vehicle _caller == _caller) then {
};
_caller setvariable [QGVAR(treatmentPrevAnimCaller), nil];
_weaponSelect = (_caller getvariable [QGVAR(selectedWeaponOnTreatment), ""]);
if (_weaponSelect != "") then {
_caller selectWeapon _weaponSelect;
} else {
_caller action ["SwitchWeapon", _caller, _caller, 99];
};
// Record specific callback
_config = (configFile >> "ACE_Medical_Actions" >> "Basic" >> _className);
if (GVAR(level) >= 2) then {

View File

@ -0,0 +1,93 @@
/*
* Author: Glowbal
* PFH logic for unconscious state
*
* Arguments:
* 0: The unit that will be put in an unconscious state <OBJECT>
*
* ReturnValue:
* nil
*
* Public: yes
*/
#include "script_component.hpp"
private ["_unit", "_vehicleOfUnit","_minWaitingTime", "_oldAnimation", "_captiveSwitch", "_hasMovedOut", "_parachuteCheck"];
_args = _this select 0;
_unit = _args select 0;
_oldAnimation = _args select 1;
_originalPos = _args select 2;
_startingTime = _args select 3;
_minWaitingTime = _args select 4;
_hasMovedOut = _args select 5;
_parachuteCheck = _args select 6;
if (!alive _unit) exitwith {
[_unit, QGVAR(unconscious), false] call EFUNC(common,setCaptivityStatus);
[_unit, false] call EFUNC(common,disableAI);
//_unit setUnitPos _originalPos;
_unit setUnconscious false;
["medical_onUnconscious", [_unit, false]] call EFUNC(common,globalEvent);
[(_this select 1)] call cba_fnc_removePerFrameHandler;
};
// In case the unit is no longer in an unconscious state, we are going to check if we can already reset the animation
if !(_unit getvariable ["ACE_isUnconscious",false]) exitwith {
// TODO, handle this with carry instead, so we can remove the PFH here.
// Wait until the unit isn't being carried anymore, so we won't end up with wierd animations
if !(([_unit] call FUNC(isBeingCarried)) || ([_unit] call FUNC(isBeingDragged))) then {
if (vehicle _unit == _unit) then {
if (animationState _unit == "AinjPpneMstpSnonWrflDnon") then {
[_unit,"AinjPpneMstpSnonWrflDnon_rolltofront", 2] call EFUNC(common,doAnimation);
[_unit,"amovppnemstpsnonwnondnon", 1] call EFUNC(common,doAnimation);
} else {
[_unit,"amovppnemstpsnonwnondnon", 2] call EFUNC(common,doAnimation);
};
} else {
// Switch to the units original animation, assuming
// TODO: what if the unit switched vehicle?
[_unit, _oldAnimation, 2] call EFUNC(common,doAnimation);
};
["medical_onUnconscious", [_unit, false]] call EFUNC(common,globalEvent);
// EXIT PFH
[(_this select 1)] call cba_fnc_removePerFrameHandler;
};
if (!_hasMovedOut) then {
// Reset the unit back to the previous captive state.
[_unit, QGVAR(unconscious), false] call EFUNC(common,setCaptivityStatus);
// Swhich the unit back to its original group
//Unconscious units shouldn't be put in another group #527:
// [_unit, false, "ACE_isUnconscious", side group _unit] call EFUNC(common,switchToGroupSide);
[_unit, false] call EFUNC(common,disableAI);
_unit setUnitPos _originalPos; // This is not position but stance (DOWN, MIDDLE, UP)
_unit setUnconscious false;
// ensure this statement runs only once
_args set [5, true];
};
};
if (_parachuteCheck) then {
if !(vehicle _unit isKindOf "ParachuteBase") then {
[_unit, [_unit] call EFUNC(common,getDeathAnim), 1, true] call EFUNC(common,doAnimation);
_args set [6, false];
};
};
if (!local _unit) exitwith {
_args set [ 4, _minWaitingTime - (time - _startingTime)];
_unit setvariable [QGVAR(unconsciousArguments), _args, true];
[(_this select 1)] call cba_fnc_removePerFrameHandler;
};
// Ensure we are waiting at least a minimum period before checking if we can wake up the unit again, allows for temp knock outs
if ((time - _startingTime) >= _minWaitingTime) exitwith {
if (!([_unit] call FUNC(getUnconsciousCondition))) then {
_unit setvariable ["ACE_isUnconscious", false, true];
};
};

View File

@ -11,4 +11,4 @@
#include "\z\ace\addons\main\script_macros.hpp"
#define USE_WOUND_EVENT_SYNC false
#define USE_WOUND_EVENT_SYNC true