From e85f6ad1b598afb07327b81a50d853e76cbb7f2c Mon Sep 17 00:00:00 2001 From: ebaydayz Date: Tue, 13 Sep 2016 15:02:16 -0400 Subject: [PATCH] Consolidate transfusion scripts Consolidated transfusion and transfusion_noBloodTypes to one script. Selfbloodbag.sqf will never run if DZE_selftransfuse = false; because the right click action is hidden. Total blood quantity is now added in 1/4 increments during self bloodbag as intended instead of all at once. --- Documents/1.0.6 Variable Name Changes.txt | 1 + SQF/dayz_code/compile/fn_damageActions.sqf | 5 +- SQF/dayz_code/compile/ui_selectSlot.sqf | 2 +- SQF/dayz_code/medical/selfbloodbag.sqf | 26 ++++----- SQF/dayz_code/medical/transfusion.sqf | 3 + .../medical/transfusion_NoBloodTypes.sqf | 57 ------------------- 6 files changed, 17 insertions(+), 77 deletions(-) delete mode 100644 SQF/dayz_code/medical/transfusion_NoBloodTypes.sqf diff --git a/Documents/1.0.6 Variable Name Changes.txt b/Documents/1.0.6 Variable Name Changes.txt index a74a5061f..1f8af0738 100644 --- a/Documents/1.0.6 Variable Name Changes.txt +++ b/Documents/1.0.6 Variable Name Changes.txt @@ -28,6 +28,7 @@ - HeliCrashArea --> (getMarkerSize "crashsites") select 1 - PVDZE_serverObjectMonitor --> dayz_serverObjectMonitor - r_action_count --> dayz_actionInProgress (now true/false instead of 1/0) + - selfTransfusionTime --> player getVariable ["LastTransfusion",0] - Duplicate public variables have been renamed: - dayzPlayerLogin --> PVCDZ_plr_Login diff --git a/SQF/dayz_code/compile/fn_damageActions.sqf b/SQF/dayz_code/compile/fn_damageActions.sqf index ad6557f06..3ceee85e6 100644 --- a/SQF/dayz_code/compile/fn_damageActions.sqf +++ b/SQF/dayz_code/compile/fn_damageActions.sqf @@ -201,9 +201,8 @@ if (isPlayer cursorTarget) then { }; //Allow player to transfuse blood if(_lowBlood && _hasBloodBag) then { - _transfuse = if (dayz_classicBloodBagSystem) then {"\z\addons\dayz_code\medical\transfusion_NoBloodTypes.sqf"} else {"\z\addons\dayz_code\medical\transfusion.sqf"}; r_action = true; - _action = _unit addAction [localize "str_actions_medical_08",_transfuse,[_unit], 0, true, true]; + _action = _unit addAction [localize "str_actions_medical_08", "\z\addons\dayz_code\medical\transfusion.sqf",[_unit], 0, true, true]; r_player_actions set [count r_player_actions,_action]; }; //Allow player to give antibiotics @@ -239,4 +238,4 @@ if ((!_isClose or !_hasPatient) && r_action) then { }; //Monitor -player setVariable ["damageActions", diag_ticktime, false]; \ No newline at end of file +player setVariable ["damageActions", diag_ticktime, false]; diff --git a/SQF/dayz_code/compile/ui_selectSlot.sqf b/SQF/dayz_code/compile/ui_selectSlot.sqf index 222563150..ce3eb0b7f 100644 --- a/SQF/dayz_code/compile/ui_selectSlot.sqf +++ b/SQF/dayz_code/compile/ui_selectSlot.sqf @@ -13,7 +13,7 @@ if (_button == 1) then { _pos = ctrlPosition _group; _item = gearSlotData _control; - if (!DZE_SelfTransfuse && {_item == "ItemBloodbag" or _item in ["wholeBloodBagANEG","wholeBloodBagAPOS","wholeBloodBagBNEG","wholeBloodBagBPOS","wholeBloodBagABNEG","wholeBloodBagABPOS","wholeBloodBagONEG","wholeBloodBagOPOS"]}) exitWith {}; // No right click option on bloodbags if DZE_SelfTransfuse = false; + if (!DZE_SelfTransfuse && _item in ["ItemBloodbag","wholeBloodBagANEG","wholeBloodBagAPOS","wholeBloodBagBNEG","wholeBloodBagBPOS","wholeBloodBagABNEG","wholeBloodBagABPOS","wholeBloodBagONEG","wholeBloodBagOPOS"]) exitWith {}; // No right click option on bloodbags if DZE_SelfTransfuse = false; if (mouseOverCarry) then { _item = DayZ_onBack; carryClick = true; diff --git a/SQF/dayz_code/medical/selfbloodbag.sqf b/SQF/dayz_code/medical/selfbloodbag.sqf index 6faa7dd1e..ec13a3d83 100644 --- a/SQF/dayz_code/medical/selfbloodbag.sqf +++ b/SQF/dayz_code/medical/selfbloodbag.sqf @@ -1,5 +1,4 @@ -if (!DZE_SelfTransfuse) exitWith {}; -private ["_unit","_blood","_lowBlood","_injured","_inPain","_lastused","_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"]; +private ["_unit","_blood","_lowBlood","_injured","_inPain","_lastused","_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","_transfusionInfection"]; // bleed.sqf _unit = _this select 0; @@ -9,9 +8,8 @@ _blood = _unit getVariable ["USEC_BloodQty", 0]; _lowBlood = _unit getVariable ["USEC_lowBlood", false]; _injured = _unit getVariable ["USEC_injured", false]; _inPain = _unit getVariable ["USEC_inPain", false]; -_lastused = _unit getVariable ["LastTransfusion", -(DZE_selfTransfuse_Values select 2)]; - -if (round(time - _lastused) <= DZE_selfTransfuse_Values select 2) exitWith {localize "str_actions_medical_18" call dayz_rollingMessages;}; +_lastused = _unit getVariable ["LastTransfusion", 0]; +if (time - _lastused <= DZE_selfTransfuse_Values select 2) exitWith {localize "str_actions_medical_18" call dayz_rollingMessages;}; call gear_ui_init; closeDialog 0; @@ -24,7 +22,7 @@ _wholeBag = false; _bagFound = false; _BBneeded = false; _forceClose = false; -_TransfusionInfection = false; +_transfusionInfection = if (DZE_selfTransfuse_Values select 1 <= 0) then {false} else {((random 100) < (DZE_selfTransfuse_Values select 1))}; if (_blood <= 4000) then { @@ -48,7 +46,7 @@ if (_haswholebag) then { _badBag = true; }; -if (dayz_classicBloodBagSystem && ("ItemBloodbag" in (magazines player))) then {_wholeBag = true; _badBag = false;}; +if (dayz_classicBloodBagSystem) then {_wholeBag = false; _badBag = false;}; call fnc_usec_medic_removeActions; r_action = false; @@ -85,7 +83,8 @@ while {r_doLoop and (_i < 12)} do { }; }; } else { - if (_wholeBag) then { _bagToRemove = if (dayz_classicBloodBagSystem) then {"ItemBloodbag"} else {_bloodBagWholeNeeded}; }; + 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;}; @@ -104,12 +103,7 @@ while {r_doLoop and (_i < 12)} do { r_player_blood = r_player_blood + 100 + _randomamount; } else { _randomamount = round(random 200); - if (DZE_SelfTransfuse) then { - r_player_blood = (r_player_blood + (DZE_selfTransfuse_Values select 0)) min r_player_bloodTotal; - _TransfusionInfection = if ((DZE_selfTransfuse_Values select 1) < 0) then {false} else {((random 100) < (DZE_selfTransfuse_Values select 1))}; - } else { - r_player_blood = r_player_blood + 800 + _randomamount; - }; + r_player_blood = (r_player_blood + ((DZE_selfTransfuse_Values select 0)/4)) min r_player_bloodTotal; }; //PVDZ_send = [_unit,"Transfuse",[_unit,player,1000]]; @@ -131,8 +125,8 @@ while {r_doLoop and (_i < 12)} do { if (((_blood >= r_player_bloodTotal) and !_badBag and _bagFound) or (_i == 12)) then { diag_log format ["TRANSFUSION: completed blood transfusion successfully (_i = %1)", _i]; - _unit setVariable ["LastTransfusion",time]; - if (_TransfusionInfection) then {r_player_infected = true; player setVariable["USEC_infected",true,true];}; + _unit setVariable ["LastTransfusion",time,false]; + 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; }; diff --git a/SQF/dayz_code/medical/transfusion.sqf b/SQF/dayz_code/medical/transfusion.sqf index 8744549b0..64e411c36 100644 --- a/SQF/dayz_code/medical/transfusion.sqf +++ b/SQF/dayz_code/medical/transfusion.sqf @@ -81,6 +81,8 @@ if (_BBneeded) then { }; }; +if (dayz_classicBloodBagSystem) then {_wholeBag = false; _badBag = false;}; + call fnc_usec_medic_removeActions; r_action = false; @@ -123,6 +125,7 @@ while {r_doLoop} do { }; } else { _bagToRemove = if (_wholeBag) then { _bloodBagWholeNeeded } else { _bbselect }; + if (dayz_classicBloodBagSystem) then {_bagToRemove = "ItemBloodbag";}; if (_bagToRemove in magazines player) then { _bagFound = true; }; diff --git a/SQF/dayz_code/medical/transfusion_NoBloodTypes.sqf b/SQF/dayz_code/medical/transfusion_NoBloodTypes.sqf deleted file mode 100644 index ece6e5b81..000000000 --- a/SQF/dayz_code/medical/transfusion_NoBloodTypes.sqf +++ /dev/null @@ -1,57 +0,0 @@ -private ["_started","_finished","_animState","_isMedic","_num_removed","_unit","_lastused"]; -// bleed.sqf -_unit = (_this select 3) select 0; -//_lowBlood = _unit getVariable ["USEC_lowBlood", false]; -//_injured = _unit getVariable ["USEC_injured", false]; -//_inPain = _unit getVariable ["USEC_inPain", false]; -//_lastused = _unit getVariable ["LastTransfusion", -(DZE_selfTransfuse_Values select 2)]; - -// if (_lastused - time < 60) exitwith {format[localize "str_actions_medical_18",_text] call dayz_rollingMessages;}; - -call fnc_usec_medic_removeActions; -r_action = false; - -// not possible to transfuse while in a vehicle -if (vehicle player != player) exitWith { }; - -player playActionNow "Medic"; - -r_interrupt = false; -_animState = animationState player; -r_doLoop = true; -_started = false; -_finished = false; -while {r_doLoop} do { - _animState = animationState player; - _isMedic = ["medic",_animState] call fnc_inString; - if (_isMedic) then { - _started = true; - }; - if (_started && !_isMedic) then { - r_doLoop = false; - _finished = true; - }; - if (r_interrupt) then { - r_doLoop = false; - }; - uiSleep 0.1; -}; -r_doLoop = false; - -if (_finished) then { - //_unit setVariable["LastTransfusion",time]; //reserve for self transfusion - _unit setVariable["USEC_lowBlood",false,true]; - _num_removed = ([player,"ItemBloodbag"] call BIS_fnc_invRemove); - if(_num_removed == 1) then { - - /* PVS/PVC - Skaronator */ - PVDZ_send = [_unit,"Transfuse",[_unit,player,12000]]; - publicVariableServer "PVDZ_send"; - - [player,100] call player_humanityChange; - }; -} else { - r_interrupt = false; - player switchMove ""; - player playActionNow "stop"; -}; \ No newline at end of file