Add files via upload

These files are either new or have extensive edits.
This commit is contained in:
worldwidesorrow
2019-12-11 20:42:24 -06:00
committed by GitHub
parent 07c1105dcd
commit bcc5b631cb
7 changed files with 284 additions and 402 deletions

View File

@@ -6,54 +6,69 @@
JULY 2010 - norrin
*****************************************************************************************************************************
Start carry.sqf
Updated December 2019 - JasonTM
*/
private ["_unit","_dragee","_pos","_dir"];
private ["_medic","_dragee","_unconscious","_dropObjects"];
_dragee = _this select 3;
_can_be_revived = NORRN_revive_array select 20;
_can_be_revived_2 = NORRN_revive_array select 21;
_unit = player;
r_carry_sqf = true;
r_drag_sqf = false;
_medic = player;
_unconscious = _dragee getVariable ["NORRN_unconscious", false];
_unit removeAction Norrn_carryAction;
if (isNull _dragee) exitWith {};
_dragee setVariable ["NORRN_unit_dragged", true, true];
if (!_unconscious) exitWith {};
_dropObjects = nearestObjects [player, DayZ_DropDrageeObjects, 3];
if (count _dropObjects > 0) exitWith {};
// Attach before the other client sets direction and position
_dragee attachto [_medic,[0.1, 1.01, 0]];
// Send information to start the carry process
PVDZ_send = [_dragee,"CarryPlayer",_dragee,[_dragee,dayz_authKey,_medic]];
publicVariableServer "PVDZ_send";
// Wait until the other client has performed its actions.
waitUntil {((_dragee getVariable ["NORRN_unit_dragged",false]) || (!alive _dragee));};
uiSleep 1;
detach _dragee;
uiSleep 1.5;
// public EH
//PVDZ_drg_RACarUp = _dragee; // not used
//publicVariable "PVDZ_drg_RACarUp"; // not used
//_dragee switchMove "ainjpfalmstpsnonwrfldnon_carried_up";
//PVDZ_drg_RAPicUp = _unit; // not used
//publicVariable "PVDZ_drg_RAPicUp"; // not used
_unit switchMove "acinpknlmstpsraswrfldnon_acinpercmrunsraswrfldnon";
// Animation needs to be synced on all clients.
[nil, _medic, rSWITCHMOVE, "acinpknlmstpsraswrfldnon_acinpercmrunsraswrfldnon"] call RE;
_medic switchMove "acinpknlmstpsraswrfldnon_acinpercmrunsraswrfldnon";
// Fix from fn_unconscious
disableUserInput false; disableUserInput false;
disableUserInput true; disableUserInput true;
disableUserInput false; disableUserInput false;
uiSleep 10;
_dragee switchmove "ainjpfalmstpsnonwrfldnon_carried_still";
_dragee attachto [_unit,[-0.2, 0.2, 0]];
// Wait until first animation done to attach player
_dragee attachto [_medic,[-0.2, 0.2, 0]];
while {r_carry_sqf} do
{
_anim_name = animationstate _unit;
if (!(_dragee getVariable "NORRN_unconscious")) exitWith
{
detach _dragee;
_unit switchMove "";
player removeAction Norrn_dropAction;
r_carry_sqf = false;
//Unnecessary actions removed & drop body added
call fnc_usec_medic_removeActions;
r_action = false;
force_dropBody = false;
NORRN_dropAction = player addAction [localize "str_actions_medical_dropbody", "\z\addons\dayz_code\medical\drop_body.sqf",[_medic,_dragee], 0, false, true];
r_drag_sqf = true;
while {r_drag_sqf} do {
_dropObjects = nearestObjects [player, DayZ_DropDrageeObjects, 3]; //Prevent exploit of glitching through doors
if (force_dropBody || {count _dropObjects > 0} || {!(_dragee getVariable ["NORRN_unconscious", false])} || {!alive _dragee}) then {
[0,0,0,[_medic,_dragee]] execVM "\z\addons\dayz_code\medical\drop_body.sqf";
};
//check that dragged unit still exists
if (!alive _unit || _anim_name != "acinpknlmstpsraswrfldnon_acinpercmrunsraswrfldnon" && _anim_name != "acinpercmstpsraswrfldnon" && _anim_name != "acinpercmrunsraswrfldf") exitWith
{
player removeAction NORRN_dropAction;
detach _dragee;
_unit switchMove "";
r_carry_sqf = false;
if (vehicle player != player) then {
player action ["eject", vehicle player];
localize "str_actions_medical_dragbody_veh" call dayz_rollingMessages;
[0,0,0,[_medic,_dragee]] execVM "\z\addons\dayz_code\medical\drop_body.sqf";
};
uiSleep 0.1;
};
if (true) exitWith {};

View File

@@ -6,14 +6,14 @@
JULY 2010 - norrin
*****************************************************************************************************************************
Start drag.sqf
Updated December 2019 - JasonTM
*/
private ["_unit","_dragee","_pos","_dir","_addAction"];
private ["_medic","_dragee","_dropObjects","_unconscious"];
_dragee = _this select 3;
_unit = player;
_medic = player;
_unconscious = _dragee getVariable ["NORRN_unconscious", false];
_addAction = false;
if (isNull _dragee) exitWith {};
if (!_unconscious) exitWith {};
@@ -21,48 +21,45 @@ if (!_unconscious) exitWith {};
_dropObjects = nearestObjects [player, DayZ_DropDrageeObjects, 3];
if (count _dropObjects > 0) exitWith {};
//player assumes dragging posture
// Animation needs to be synced on all clients.
[nil, _medic, rSWITCHMOVE, "AmovPercMstpSlowWrflDnon_AcinPknlMwlkSlowWrflDb_2"] call RE;
_medic switchmove "AmovPercMstpSlowWrflDnon_AcinPknlMwlkSlowWrflDb_2";
// Fix from fn_unconscious
disableUserInput false; disableUserInput false;
disableUserInput true; disableUserInput true;
disableUserInput false; disableUserInput false;
uiSleep .5;
// Attach before the other client sets direction and position
_dragee attachto [_medic,[0.1, 1.01, 0]];
// Send information to start the drag process
PVDZ_send = [_dragee,"DragPlayer",_dragee,[_dragee,dayz_authKey,_medic]];
publicVariableServer "PVDZ_send";
// Wait until the other client has performed its actions.
waitUntil {uiSleep 0.02; ((_dragee getVariable ["NORRN_unit_dragged",false]) || (!alive _dragee));};
//Unnecessary actions removed & drop body added
call fnc_usec_medic_removeActions;
r_action = false;
force_dropBody = false;
NORRN_dropAction = player addAction [localize "str_actions_medical_dropbody", "\z\addons\dayz_code\medical\drop_body.sqf",[_medic,_dragee], 0, false, true];
r_drag_sqf = true;
while {r_drag_sqf} do {
if (!_addAction) then {
_dragee setVariable ["NORRN_unit_dragged", true, true];
_unit playActionNow "grabDrag";
uiSleep 2;
//unconscious unit assumes dragging posture
//public EH
//PVDZ_drg_RaDrag = _dragee;
PVDZ_drg_RaDrag = [_dragee];
publicVariable "PVDZ_drg_RaDrag";
//_dragee switchmove "ainjppnemstpsnonwrfldb_still";
_dragee attachto [_unit,[0.1, 1.01, 0]];
uiSleep 0.02;
//rotate wounded units so that it is facing the correct direction
//PVDZ_drg_R180 = _dragee; // not used
//publicVariable "PVDZ_drg_R180"; // not used
_dragee setDir 180;
//Uneccesary actions removed & drop body added
call fnc_usec_medic_removeActions;
NORRN_dropAction = player addAction [localize "str_actions_medical_dropbody", "\z\addons\dayz_code\medical\drop_body.sqf",_dragee, 0, false, true];
//NORRN_carryAction = player addAction ["Carry body", "\z\addons\dayz_code\medical\carry.sqf",_dragee, 0, false, true];
uiSleep 1;
_addAction = true;
};
_dropObjects = nearestObjects [player, DayZ_DropDrageeObjects, 3]; //Prevent exploit of glitching through doors
if (force_dropBody || (count _dropObjects > 0)) then {
[cursorTarget, _unit, _unconscious, _dragee] execVM "\z\addons\dayz_code\medical\drop_body.sqf";
if (force_dropBody || {count _dropObjects > 0} || {!(_dragee getVariable ["NORRN_unconscious", false])} || {!alive _dragee}) then {
[0,0,0,[_medic,_dragee]] execVM "\z\addons\dayz_code\medical\drop_body.sqf";
};
if (vehicle player != player) then {
player action ["eject", vehicle player];
localize "str_actions_medical_dragbody_veh" call dayz_rollingMessages;
[cursorTarget, _unit, _unconscious, _dragee] execVM "\z\addons\dayz_code\medical\drop_body.sqf";
[0,0,0,[_medic,_dragee]] execVM "\z\addons\dayz_code\medical\drop_body.sqf";
};
if (!r_drag_sqf) exitWith {};
uiSleep 0.001;
uiSleep 0.1;
};

View File

@@ -7,28 +7,20 @@
*****************************************************************************************************************************
Start drop_body.sqf
*/
private ["_medic","_dragee"];
_dragee = _this select 3;
_medic = (_this select 3) select 0;
_dragee = (_this select 3) select 1;
player removeAction NORRN_dropAction;
//player removeAction NORRN_carryAction;
NORRN_remove_drag = true;
r_drag_sqf = false;
r_carry_sqf = false;
r_action = false;
_unit = player;
detach _unit;
detach _dragee;
_unit switchMove "";
_dragee switchMove "";
NORRN_Dragged_body = objNull;
_dragee setVariable ["NORRN_unit_dragged", false, true];
//lie on back
_dragee playMoveNow "ainjppnemstpsnonwrfldnon";
//PVDZ_drg_Ralie = _dragee; // not used
//publicVariable "PVDZ_drg_Ralie"; // not used
force_dropBody = false;
r_drag_sqf = false;
if (true) exitWith {};
//detach _medic;
_medic switchMove "";
if (alive _dragee) then {
PVDZ_send = [_dragee, "DropPlayer",_dragee,[_dragee,dayz_authKey,_medic]];
publicVariableServer "PVDZ_send";
};

View File

@@ -0,0 +1,26 @@
// animDrag.sqf
private "_dragee";
_dragee = _this;
// Check to see that the passed object matches local player object
if (player != _dragee) exitWith {};
if !(r_player_unconscious) exitWith {};
// Have to wait until attached to set direction and position
_dragee setDir -180;
_dragee setPos (getPos _dragee);
_dragee setVariable ["NORRN_unit_dragged", true, true];
uiSleep 1.5;
// First animation
[nil, _dragee, rSWITCHMOVE, "ainjpfalmstpsnonwrfldnon_carried_up"] call RE;
_dragee switchmove "ainjpfalmstpsnonwrfldnon_carried_up";
uiSleep 10;
// Second animation
[nil, _dragee, rSWITCHMOVE, "ainjpfalmstpsnonwrfldnon_carried_still"] call RE;
_dragee switchmove "ainjpfalmstpsnonwrfldnon_carried_still";

View File

@@ -0,0 +1,18 @@
// animDrop.sqf
private "_dragee";
_dragee = _this;
// Check to see that the passed object matches local player object
if (player != _dragee) exitWith {};
_dragee setVariable ["NORRN_unit_dragged", false, true];
detach _dragee;
// We don't want to override the animations from fn_unconscious or load_act.sqf
if (r_player_unconscious) then {
// Animation needs to be synced on all clients.
[nil, _dragee, rSWITCHMOVE, "ainjppnemstpsnonwrfldnon"] call RE;
_dragee switchmove "ainjppnemstpsnonwrfldnon";
};

View File

@@ -1,153 +1,61 @@
private ["_unit","_blood","_lowBlood","_injured","_inPain","_animState","_started","_finished","_timer","_i","_isMedic","_duration","_rhVal","_bloodBagArrayNeeded","_BBneeded","_bbselect","_bloodBagNeeded","_badBag","_wholeBag","_bagFound","_bagToRemove","_forceClose","_bloodType","_rh","_bloodBagArray","_bbarray_length","_bloodBagWholeNeeded","_haswholebag","_r","_transfusionInfection"];
private ["_msg","_unit","_bagUsed","_duration","_rhVal","_badBag","_bloodType","_bloodBagWholeNeeded","_wholeBag","_transfusionInfection","_finished","_bloodAmount"];
// Check to see if enough time has passed since the last self-transfusion.
if (time - dayz_lastSelfTransfusion <= DZE_selfTransfuse_Values select 2) exitWith {localize "str_actions_medical_18" call dayz_rollingMessages;};
// bleed.sqf
_unit = _this select 0;
_bagUsed = _this select 1;
_blood = _unit getVariable ["USEC_BloodQty", 0];
_lowBlood = _unit getVariable ["USEC_lowBlood", false];
_injured = _unit getVariable ["USEC_injured", false];
_inPain = _unit getVariable ["USEC_inPain", false];
if (time - dayz_lastSelfTransfusion <= DZE_selfTransfuse_Values select 2) exitWith {localize "str_actions_medical_18" call dayz_rollingMessages;};
call gear_ui_init;
closeDialog 0;
_bloodType = _unit getVariable ["blood_type", false];
_rh = _unit getVariable ["rh_factor", false];
_badBag = false;
_wholeBag = false;
_bagFound = false;
_BBneeded = false;
_forceClose = false;
_transfusionInfection = if (DZE_selfTransfuse_Values select 1 <= 0) then {false} else {((random 100) < (DZE_selfTransfuse_Values select 1))};
if (_blood <= 4000) then {
_duration = 3;
} else {
_duration = 2;
};
_bloodBagArray = ["wholeBloodBagANEG","wholeBloodBagAPOS","wholeBloodBagBNEG","wholeBloodBagBPOS","wholeBloodBagABNEG","wholeBloodBagABPOS","wholeBloodBagONEG","wholeBloodBagOPOS"];
if (_rh) then {_rhVal = "POS";} else {_rhVal = "NEG";};
//No subs for whole blood :(
_bloodBagWholeNeeded = "wholeBloodBag" + _bloodType + _rhVal;
_haswholebag = _bloodBagWholeNeeded in magazines player;
if (_haswholebag) then {
_wholeBag = true;
} else {
_badBag = true;
};
if (dayz_classicBloodBagSystem) then {_wholeBag = true; _badBag = false;};
call fnc_usec_medic_removeActions;
r_action = false;
if (vehicle player == player) then {
//not in a vehicle
player playActionNow "Medic";
};
r_interrupt = false;
_animState = animationState player;
r_doLoop = true;
_started = false;
_msg = "";
_finished = false;
_timer = diag_tickTime;
_i = 0;
_r = 0;
_transfusionInfection = if (DZE_selfTransfuse_Values select 1 <= 0) then {false} else {((random 100) < (DZE_selfTransfuse_Values select 1))};
_duration = if ((_unit getVariable ["USEC_BloodQty", 0]) <= 4000) then {3} else {2};
while {r_doLoop and (_i < 12)} do {
_animState = animationState player;
_isMedic = ["medic",_animState] call fnc_inString;
if (((vehicle player != player) || _isMedic) and !_started) then {
closeDialog 0;
diag_log format ["TRANSFUSION: starting blood transfusion (%1 > %2)", name player, name _unit];
if (_badBag) then {
for "_r" from 0 to 15 do {
_bagToRemove = _bagUsed;
if (_bagToRemove in magazines player) exitWith { //TODO: add separate action menu options so the removed bag isn't random
_bagFound = true;
if (_r >= 8) then {
_wholeBag = true;
};
};
};
} else {
if (_wholeBag) then {_bagToRemove = _bloodBagWholeNeeded; };
if (dayz_classicBloodBagSystem) then { _bagToRemove = _bagUsed; };
if (_bagToRemove in magazines player) then { _bagFound = true; };
};
if (!_bagFound) then {_forceClose = true;} else { player removeMagazine _bagToRemove;};
localize "str_actions_medical_transfusion_start" call dayz_rollingMessages;
_started = true;
};
if (_started) then {
if ((diag_tickTime - _timer) >= 1) then {
_timer = diag_tickTime;
_i = _i + 3;
if (!_badBag) then {
if (!_forceClose) then {
if (!_wholeBag) then {
_randomamount = round(random 60);
r_player_blood = r_player_blood + 100 + _randomamount;
} else {
_randomamount = round(random 200);
r_player_blood = (r_player_blood + ((DZE_selfTransfuse_Values select 0)/4)) min r_player_bloodTotal;
};
//PVDZ_send = [_unit,"Transfuse",[_unit,player,1000]];
//publicVariableServer "PVDZ_send";
};
} else {
if (!_forceClose and (_i >= 12)) then {
[_unit, _duration] call fnc_usec_damageUnconscious;
};
};
};
if (vehicle player == player) then {
if (!_isMedic) then {
player playActionNow "Medic";
};
} else {
uisleep 4;
};
};
_blood = _unit getVariable ["USEC_BloodQty", 0];
if (((_blood >= r_player_bloodTotal) and !_badBag and _bagFound) or (_i == 12)) then {
diag_log format ["TRANSFUSION: completed blood transfusion successfully (_i = %1)", _i];
dayz_lastSelfTransfusion = time;
if (_transfusionInfection) then {r_player_infected = true; player setVariable["USEC_infected",true,true];};
localize "str_actions_medical_transfusion_successful" call dayz_rollingMessages;
r_doLoop = false;
};
if (r_interrupt or _forceClose) then {
diag_log format ["TRANSFUSION: transfusion was interrupted (r_interrupt: %1 | distance: %2 | _i = %3)", r_interrupt, player distance _unit, _i];
localize "str_actions_medical_transfusion_interrupted" call dayz_rollingMessages;
r_doLoop = false;
};
uiSleep 0.1;
if (!dayz_classicBloodBagSystem) then {
// A player can only self blood bag with a whole typed bag or the classic ItemBloodbag.
// If not using dayz_classicBloodBagSystem then the player needs to know his/her blood type or use wholeBloodBagONEG.
_bloodType = _unit getVariable ["blood_type", ""];
_rhVal = if (_unit getVariable ["rh_factor", false]) then {"POS"} else {"NEG"};
_bloodBagWholeNeeded = "wholeBloodBag" + _bloodType + _rhVal;
_wholeBag = _bagUsed in ["wholeBloodBagONEG",_bloodBagWholeNeeded];
if (!_wholeBag) then {_badBag = true;};
};
r_doLoop = false;
_bloodAmount = if (!_wholeBag) then {(DZE_selfTransfuse_Values select 0)} else {4000};
if (r_interrupt) then {
r_interrupt = false;
if (vehicle player == player) then {
player switchMove "";
player playActionNow "stop";
localize "str_actions_medical_transfusion_start" call dayz_rollingMessages;
_unit removeMagazine _bagUsed;
// Players can self blood bag in a vehicle so we use this simple method.
if (vehicle player == player) then {
_finished = ["Medic",1] call fn_loopAction;
} else {
uiSleep 3;
_finished = true;
};
if (!_finished) then {
_unit addMagazine _bagUsed;
_msg = "str_actions_medical_transfusion_interrupted";
} else {
if (!_badBag) then {
r_player_blood = (r_player_blood + _bloodAmount) min r_player_bloodTotal;
_msg = "str_actions_medical_transfusion_successful";
} else {
// Player gets knocked unconscious and receives no blood if wrong type is used.
[_unit, _duration] call fnc_usec_damageUnconscious;
_msg = "str_actions_medical_transfusion_fail";
};
dayz_lastSelfTransfusion = time;
if (_transfusionInfection) then {
r_player_infected = true;
player setVariable["USEC_infected",true,true];
};
};
localize _msg call dayz_rollingMessages;

View File

@@ -1,213 +1,134 @@
private ["_bloodAmount","_unit","_blood","_lowBlood","_injured","_inPain","_hasTransfusionKit","_animState","_started","_finished","_timer","_i","_isMedic","_isClose","_duration","_rhVal","_bloodBagArrayNeeded","_BBneeded","_bbselect","_bloodBagNeeded","_badBag","_wholeBag","_bagFound","_bagToRemove","_forceClose","_bloodType","_rh","_bloodBagArray","_bbarray_length","_bloodBagWholeNeeded","_haswholebag","_r","_bloodTestdone","_sentRequest"];// bleed.sqf
//Get receving unit
private ["_msg","_bagUsed","_bloodResult","_bloodAmount","_unit","_hasTransfusionKit","_timer","_i","_isClose","_duration","_rhVal","_bloodBagArrayNeeded","_bloodBagNeeded","_badBag","_wholeBag","_bagFound","_bloodType","_rh","_bloodBagWholeNeeded","_wholeBagFound","_bloodTestdone"];// bleed.sqf
_unit = (_this select 3) select 0;
_bagUsed = (_this select 3) select 1;
call fnc_usec_medic_removeActions;
r_action = false;
if !(vehicle player == player) exitWith {/* This check is probably not necessary */};
//Does the player have a transfusionKit
//_hasTransfusionKit = "transfusionKit" in magazines player;
if (time - dayz_lastTransfusion > 120) then {dayz_bloodBagHumanity = 300;}; //Reset humanity reward to full value after two minutes
//Get receving units blood value
_blood = _unit getVariable ["USEC_BloodQty", 0];
//Get receving units bloodtype
_bloodType = _unit getVariable ["blood_type", ""];
//Get the receving units RH type
_rh = _unit getVariable ["rh_factor", false];
//Get status of bloodtest of receving unit
_bloodTestdone = _unit getVariable ["blood_testdone", false];
r_interrupt = false;
_badBag = false;
_wholeBag = false;
_bagFound = false;
_forceClose = false;
if (!dayz_classicBloodBagSystem) then {
_bloodType = _unit getVariable ["blood_type", ""]; //Get receiving units blood type
_rh = _unit getVariable ["rh_factor", false]; //Get the receiving units RH type
_rhVal = if (_rh) then {"POS"} else {"NEG"}; // Get the RH value.
_bloodTestdone = _unit getVariable ["blood_testdone", false]; //Get status of blood test of receiving unit
_bloodResult = _bloodType + _rhVal; // Combine strings for convenience
//End if the player does not have a transfusion kit
//if (!_hasTransfusionKit) exitWith { localize "str_actions_medical_transfusion_failed_transfusionkit" call dayz_rollingMessages; };
//End if the player does not have a transfusion kit
//if (!_hasTransfusionKit) exitWith { localize "str_actions_medical_transfusion_failed_transfusionkit" call dayz_rollingMessages; };
//Unconscious timeout for receving unit
_duration = if (_blood <= 4000) then { 3 } else { 2 };
_bloodBagArray = ["bloodBagANEG","bloodBagAPOS","bloodBagBNEG","bloodBagBPOS","bloodBagABNEG","bloodBagABPOS","bloodBagONEG","bloodBagOPOS","wholeBloodBagANEG","wholeBloodBagAPOS","wholeBloodBagBNEG","wholeBloodBagBPOS","wholeBloodBagABNEG","wholeBloodBagABPOS","wholeBloodBagONEG","wholeBloodBagOPOS"];
_bloodBagArrayNeeded = ["ItemBloodbag","bloodBagONEG"];
if (_bloodTestdone) then { // if the recipient does not know his blood type, only O- can apply
switch (_bloodType) do {
case "A" : {
if (_rh) then {
_bloodBagArrayNeeded = ["ItemBloodbag","bloodBagAPOS","bloodBagANEG","bloodBagONEG","bloodBagOPOS"];
} else {
_bloodBagArrayNeeded = ["ItemBloodbag","bloodBagANEG","bloodBagONEG"];
};
};
case "B" : {
if (_rh) then {
_bloodBagArrayNeeded = ["ItemBloodbag","bloodBagBPOS","bloodBagBNEG","bloodBagONEG","bloodBagOPOS"];
} else {
_bloodBagArrayNeeded = ["ItemBloodbag","bloodBagBNEG","bloodBagONEG"];
};
};
case "AB" : {
if (_rh) then {
_bloodBagArrayNeeded = ["ItemBloodbag","bloodBagABPOS","bloodBagABNEG","bloodBagANEG","bloodBagAPOS","bloodBagBNEG","bloodBagBPOS","bloodBagONEG","bloodBagOPOS"];
} else {
_bloodBagArrayNeeded = ["ItemBloodbag","bloodBagABNEG","bloodBagANEG","bloodBagBNEG","bloodBagONEG"];
};
};
case "O" : {
if (_rh) then {
_bloodBagArrayNeeded = ["ItemBloodbag","bloodBagOPOS","bloodBagONEG"];
} else {
_bloodBagArrayNeeded = ["ItemBloodbag","bloodBagONEG"];
};
//Unconscious timeout for receiving unit
_duration = if ((_unit getVariable ["USEC_BloodQty", 0]) <= 4000) then { 3 } else { 2 };
_bloodBagArrayNeeded = ["bloodBagONEG"];
if (_bloodTestdone) then { // if the recipient does not know his blood type, only O- can apply
_bloodBagArrayNeeded = call {
if (_bloodResult == "APOS") exitWith {["bloodBagAPOS","bloodBagANEG","bloodBagONEG","bloodBagOPOS"];};
if (_bloodResult == "ANEG") exitWith {["bloodBagANEG","bloodBagONEG"];};
if (_bloodResult == "BPOS") exitWith {["bloodBagBPOS","bloodBagBNEG","bloodBagONEG","bloodBagOPOS"];};
if (_bloodResult == "BNEG") exitWith {["bloodBagBNEG","bloodBagONEG"];};
if (_bloodResult == "ABPOS") exitWith {["bloodBagABPOS","bloodBagABNEG","bloodBagANEG","bloodBagAPOS","bloodBagBNEG","bloodBagBPOS","bloodBagONEG","bloodBagOPOS"];};
if (_bloodResult == "ABNEG") exitWith {["bloodBagABNEG","bloodBagANEG","bloodBagBNEG","bloodBagONEG"];};
if (_bloodResult == "OPOS") exitWith {["bloodBagOPOS","bloodBagONEG"];};
if (_bloodResult == "ONEG") exitWith {["bloodBagONEG"];};
};
};
};
_BBneeded = false;
{ if (_x in magazines player) exitWith { _BBneeded = true; _bbselect = _x; }; } count _bloodBagArrayNeeded;
_bagFound = (_bagUsed in _bloodBagArrayNeeded);
//No subs for whole blood :(
_rhVal = if (_rh) then { "POS" } else { "NEG" };
_bloodBagWholeNeeded = "wholeBloodBag" + _bloodType + _rhVal;
_haswholebag = _bloodBagWholeNeeded in magazines player;
//No subs for whole blood :(
_bloodBagWholeNeeded = "wholeBloodBag" + _bloodResult;
_wholeBagFound = (_bagUsed == _bloodBagWholeNeeded);
if (!_BBneeded and !_haswholebag) then {
_badBag = true;
};
//use packed/separated bags first
if (_BBneeded) then {
_wholeBag = false;
} else {
if (_haswholebag) then {
_wholeBag = true;
call { // Options are listed top to bottom in order of precedence
if (_bagFound) exitWith {_wholeBag = false; _badBag = false;}; //use packed/separated bags first
if (_wholeBagFound) exitWith {_wholeBag = true; _badBag = false;};
_wholeBag = false; _badBag = true; // Default
};
};
if (dayz_classicBloodBagSystem) then {_wholeBag = false; _badBag = false;};
call fnc_usec_medic_removeActions;
r_action = false;
if (vehicle player == player) then {
//not in a vehicle
player playActionNow "Medic";
};
r_interrupt = false;
_animState = animationState player;
r_doLoop = true;
_started = false;
_finished = false;
_sentRequest = false;
_timer = diag_tickTime;
_i = 0;
_r = 0;
_humanityAwarded = 0;
_msg = "";
_bloodAmount = if (!_wholeBag) then { r_player_bloodTotal/*Full bloodbag*/ } else { 4000 /*Whole blood only gives 4k*/ };
while {r_doLoop} do {
_animState = animationState player;
_isMedic = ["medic",_animState] call fnc_inString;
//diag_log format ["TRANSFUSION: starting blood transfusion (%1 > %2)", name player, name _unit];
if (_isMedic and !_started) then {
closeDialog 0;
diag_log format ["TRANSFUSION: starting blood transfusion (%1 > %2)", name player, name _unit];
if (_badBag) then {
for "_r" from 0 to 15 do {
//select random bloodbag if the player has more then one of the required types
_bagToRemove = _bloodBagArray select _r;
//TODO: add separate action menu options so the removed bag isn't random
if (_bagToRemove in magazines player) exitWith {
_bagFound = true;
if (_r >= 8) then {
_wholeBag = true;
};
};
player removeMagazine _bagUsed;
player playActionNow "Medic";
if (!_badBag) then {
PVDZ_send = [_unit,"Transfuse",[_unit,player,_bloodAmount]];
publicVariableServer "PVDZ_send";
};
localize "str_actions_medical_transfusion_start" call dayz_rollingMessages;
while {r_doLoop} do {
if (!(["medic",animationState player] call fnc_inString)) then {
player playActionNow "Medic";
};
if ((diag_tickTime - _timer) >= 1) then {
_timer = diag_tickTime;
if (!_wholeBag) then {
_i = _i + 1; //Full bloodbag
} else {
_i = _i + 3; //Whole blood only gives 4k
};
if (!_badBag) then {
_bloodAmount = _bloodAmount - 500;
// 25 points to be given up to a maximum of 300 points if the player stays for the full duration
//This should be better this way to keep calculus simple and prevent people getting points for giving blood transfusions to healthy players (and less humanity for only very small amounts of blood)
//Pulled from pull request from ILoveBeans
if (_humanityAwarded < dayz_bloodBagHumanity) then {
_humanityAwarded = _humanityAwarded + 25;
};
} else {
_bagToRemove = if (_wholeBag) then { _bloodBagWholeNeeded } else { _bbselect };
if (dayz_classicBloodBagSystem) then {_bagToRemove = "ItemBloodbag";};
if (_bagToRemove in magazines player) then {
_bagFound = true;
// This is designed to knock the player out after 12 seconds if they get a bad blood bag.
if (_i >= 12) then {
_bloodAmount = 0;
// Send to server with key for security
PVDZ_send = [_unit,"Unconscious",[_unit,_duration],[_unit,dayz_authKey,player]];
publicVariableServer "PVDZ_send";
//diag_log ("Transfusion: "+str(PVDZ_send select 2));
_msg = "str_actions_medical_transfusion_fail";
};
};
if (!_bagFound) then {_forceClose = true;} else { player removeMagazine _bagToRemove;};
localize "str_actions_medical_transfusion_start" call dayz_rollingMessages;
//see Note 1
//[player,_unit,"loc",rTITLETEXT,format["Transfusion of %1 in progress, remain still...",_bagToRemove],"PLAIN DOWN"] call RE;
_started = true;
};
if (_started) then {
//_sentRequest var stops the pvs running more then once as it's no longer needs too 1.8.4
if ((!_sentRequest) And (!_badBag)) then {
PVDZ_send = [_unit,"Transfuse",[_unit,player,_bloodAmount]];
publicVariableServer "PVDZ_send";
_sentRequest = true;
};
if ((diag_tickTime - _timer) >= 1) then {
_timer = diag_tickTime;
//see Note 1
//PVCDZ_hlt_Transfuse = [_unit,player,1000];
//publicVariable "PVCDZ_hlt_Transfuse";
if (!_wholeBag) then {
_i = _i + 1; //Full bloodbag
} else {
_i = _i + 3; //Whole blood only gives 4k
};
if (!_badBag) then {
if (!_forceClose) then {
_bloodAmount = _bloodAmount - 500;
//see Note 1
//PVDZ_send = [_unit,"Transfuse",[_unit,player,500]];
//publicVariableServer "PVDZ_send";
// 25 points to be givin upto a maximum of 300 points if the player stays for the full duration
//This should be better this way to keep calculus simple and prevent people getting points for giving blood transfusions to healthy players (and less humanity for only very small amounts of blood)
//Pulled from pullrequest from ILoveBeans
if (_humanityAwarded < dayz_bloodBagHumanity) then {
_humanityAwarded = _humanityAwarded + 25;
};
};
} else {
if (!_forceClose and (_i >= 12)) then {
_bloodAmount = 0;
PVDZ_sendUnconscious = [_unit,_duration];
publicVariableServer "PVDZ_sendUnconscious";
diag_log ("Transfusion: "+str(PVDZ_sendUnconscious));
};
};
//see Note 1
//[player,_unit,"loc",rTITLETEXT,format["Transfusion of %1 in progress, remain still...",_bagToRemove],"PLAIN DOWN"] call RE;
};
if (!_isMedic) then {
player playActionNow "Medic";
};
};
_blood = _unit getVariable ["USEC_BloodQty", 0];
if (_blood >= r_player_bloodTotal or _bloodAmount == 0) then {
diag_log format ["TRANSFUSION: completed blood transfusion successfully (_i = %1)", _i];
localize "str_actions_medical_transfusion_successful" call dayz_rollingMessages;
dayz_bloodBagHumanity = dayz_bloodBagHumanity / 2; //Diminish humanity reward for subsequent bloodbags. Resets to full reward after two minutes.
if ((_unit getVariable ["USEC_BloodQty", 0]) >= r_player_bloodTotal || _bloodAmount == 0) then {
//diag_log format ["TRANSFUSION: completed blood transfusion successfully (_i = %1)", _i];
dayz_bloodBagHumanity = dayz_bloodBagHumanity / 2; //Diminish humanity reward for subsequent transfusions. Resets to full reward after two minutes.
dayz_lastTransfusion = time;
//see Note 1
//[player,_unit,"loc",rTITLETEXT,localize "str_actions_medical_transfusion_successful","PLAIN DOWN"] call RE;
if (!_badBag and _bagFound) then { [_humanityAwarded,0] call player_humanityChange; };
if (!_badBag) then {
[_humanityAwarded,0] call player_humanityChange;
_msg = "str_actions_medical_transfusion_successful";
};
r_doLoop = false;
};
_isClose = ((player distance _unit) < ((sizeOf typeOf _unit) / 2));
if (r_interrupt or !_isClose or _forceClose) then {
diag_log format ["TRANSFUSION: transfusion was interrupted (r_interrupt: %1 | distance: %2 (%3) | _i = %4)", r_interrupt, player distance _unit, _isClose, _i];
localize "str_actions_medical_transfusion_interrupted" call dayz_rollingMessages;
//see Note 1
//[player,_unit,"loc",rTITLETEXT,localize "str_actions_medical_transfusion_interrupted","PLAIN DOWN"] call RE;
if (r_interrupt or !_isClose) then {
//diag_log format ["TRANSFUSION: transfusion was interrupted (r_interrupt: %1 | distance: %2 (%3) | _i = %4)", r_interrupt, player distance _unit, _isClose, _i];
_msg = "str_actions_medical_transfusion_interrupted";
r_doLoop = false;
};
@@ -222,6 +143,11 @@ if (r_interrupt) then {
player playActionNow "stop";
};
// Wait until the animation stops to display the message.
waitUntil {uiSleep .5; (!(["medic",animationState player] call fnc_inString))};
localize _msg call dayz_rollingMessages;
/*
Note 1 - 1.8 system sending way too much info upto 12 times to the server on top of each call RE also being sent upto 12 times. System removed