Files
DayZ-Epoch/SQF/dayz_code/medical/selfbloodbag.sqf
A Man 76ac4addc5 Update medical functions
This updates the medical functions for the new player_humanityChange call and updates the code where it was needed.
2020-04-03 12:45:37 +02:00

62 lines
2.3 KiB
Plaintext

// 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;};
private ["_msg","_unit","_bagUsed","_duration","_rhVal","_badBag","_bloodType","_bloodBagWholeNeeded","_wholeBag","_transfusionInfection","_finished","_bloodAmount"];
_unit = _this select 0;
_bagUsed = _this select 1;
call gear_ui_init;
closeDialog 0;
_badBag = false;
_wholeBag = false;
_msg = "";
_finished = false;
_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};
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;};
};
_bloodAmount = [4000,(DZE_selfTransfuse_Values select 0)] select (!_wholeBag);
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;