From 76ac4addc52655a1ebc7e4375ffb318b23fd9e02 Mon Sep 17 00:00:00 2001 From: A Man Date: Fri, 3 Apr 2020 12:45:37 +0200 Subject: [PATCH] Update medical functions This updates the medical functions for the new player_humanityChange call and updates the code where it was needed. --- SQF/dayz_code/medical/antibiotics.sqf | 2 +- SQF/dayz_code/medical/bandage.sqf | 16 +- SQF/dayz_code/medical/bloodCalc.sqf | 23 +- SQF/dayz_code/medical/blood_test.sqf | 199 +++++++++--------- SQF/dayz_code/medical/brokeBones.sqf | 20 +- SQF/dayz_code/medical/epinephrine.sqf | 12 +- SQF/dayz_code/medical/fillBloodBag.sqf | 18 +- SQF/dayz_code/medical/painkiller.sqf | 6 +- SQF/dayz_code/medical/selfbloodbag.sqf | 8 +- SQF/dayz_code/medical/setup_functions_med.sqf | 127 +++++------ SQF/dayz_code/medical/transfusion.sqf | 38 ++-- SQF/dayz_code/medical/wipes.sqf | 2 +- 12 files changed, 234 insertions(+), 237 deletions(-) diff --git a/SQF/dayz_code/medical/antibiotics.sqf b/SQF/dayz_code/medical/antibiotics.sqf index 00de23def..df5d43100 100644 --- a/SQF/dayz_code/medical/antibiotics.sqf +++ b/SQF/dayz_code/medical/antibiotics.sqf @@ -42,7 +42,7 @@ if !(isNil "_medsUsed") then { publicVariableServer "PVDZ_send"; //Give humnaity for good deeds - [20,0] call player_humanityChange; + 20 call player_humanityChange; _msg = format[localize "str_actions_medical_gave_antibiotics", (name _unit)]; }; diff --git a/SQF/dayz_code/medical/bandage.sqf b/SQF/dayz_code/medical/bandage.sqf index 4587cac63..d06f9ada9 100644 --- a/SQF/dayz_code/medical/bandage.sqf +++ b/SQF/dayz_code/medical/bandage.sqf @@ -1,11 +1,11 @@ +if (dayz_actionInProgress) exitWith {localize "str_player_actionslimit" call dayz_rollingMessages;}; +dayz_actionInProgress = true; + private ["_msg","_finished","_unit","_item"]; _unit = (_this select 3) select 0; _item = (_this select 3) select 1; -if (dayz_actionInProgress) exitWith {localize "str_player_actionslimit" call dayz_rollingMessages;}; -dayz_actionInProgress = true; - player removeMagazine _item; closedialog 0; @@ -26,17 +26,17 @@ if (_finished) then { //Self Healing //Self Healing [player, player, if (_item == "ItemSepsisBandage") then {true} else {false}] call player_medBandage; - _msg = if (_item == "ItemSepsisBandage") then {"str_actions_medical_sepsisbandage_self"} else {"str_actions_medical_bandage_self"}; + _msg = ["str_actions_medical_bandage_self","str_actions_medical_sepsisbandage_self"] select (_item == "ItemSepsisBandage"); localize _msg call dayz_rollingMessages; } else { // Heal another player PVDZ_send = [_unit,"Bandage",[_unit, player, if (_item == "ItemSepsisBandage") then {true} else {false}]]; publicVariableServer "PVDZ_send"; - + //Give humanity - [20,0] call player_humanityChange; - - _msg = if (_item == "ItemSepsisBandage") then {"str_actions_medical_gave_sepsisbandage"} else {"str_actions_medical_gave_bandage"}; + 20 call player_humanityChange; + + _msg = ["str_actions_medical_gave_bandage","str_actions_medical_gave_sepsisbandage"] select (_item == "ItemSepsisBandage"); format[localize _msg,(name _unit)] call dayz_rollingMessages; }; } else { diff --git a/SQF/dayz_code/medical/bloodCalc.sqf b/SQF/dayz_code/medical/bloodCalc.sqf index 61f11fbf3..3644ddcdb 100644 --- a/SQF/dayz_code/medical/bloodCalc.sqf +++ b/SQF/dayz_code/medical/bloodCalc.sqf @@ -17,27 +17,26 @@ _randRh = random 100; _randType = random 100; _bt_val = nil; _rh_val = nil; -switch true do { - case (_randType >= 61) : { + +call { + if (_randType >= 61) exitwith { _bt_val = "O"; - _rh_val = if (_randRh >= 89) then { false } else { true }; + _rh_val = [true,false] select (_randRh >= 89); }; - case (_randType >= 29) : { + if (_randType >= 29) exitwith { _bt_val = "A"; - _rh_val = if (_randRh >= 89) then { false } else { true }; + _rh_val = [true,false] select (_randRh >= 89); }; - case (_randType >= 6) : { + if (_randType >= 6) exitwith { _bt_val = "B"; - _rh_val = if (_randRh >= 94) then { false } else { true }; - }; - default { - _bt_val = "AB"; - _rh_val = if (_randRh >= 91) then { false } else { true }; + _rh_val = [true,false] select (_randRh >= 94); }; + _bt_val = "AB"; + _rh_val = [true,false] select (_randRh >= 91); }; //diag_log ["_playerObj BLOOD CALC: Blood Type,Rh Type=", _bt_val, _rh_val]; //RH type _playerObj setVariable ["rh_factor", _rh_val, true]; //blood type -_playerObj setVariable ["blood_type", _bt_val, true]; \ No newline at end of file +_playerObj setVariable ["blood_type", _bt_val, true]; diff --git a/SQF/dayz_code/medical/blood_test.sqf b/SQF/dayz_code/medical/blood_test.sqf index 66a48b2ff..4ff944920 100644 --- a/SQF/dayz_code/medical/blood_test.sqf +++ b/SQF/dayz_code/medical/blood_test.sqf @@ -2,7 +2,7 @@ Used to check and display blood type + Rh By icomrade for DayZ Mod ********************************************************* */ -private ["_unit","_abc","_opened","_water_displayed","_A_Watered","_B_Watered","_allDisplayed","_water_closed","_D_Watered","_control_Watered","_needleOpened","_needleRed","_needleRest","_antiABlooded","_allClicked","_antiBBlooded","_antiDBlooded","_control_displayed","_antiA_displayed","_antiB_displayed","_antiD_displayed","_results_shown","_isDone","_watered","_watered_complete","_isClose","_unit","_hasTester","_dialog","_display","_resultsCard_hidden","_antiA","_AntiB","_AntiD","_Control","_waterBottle","_needle","_name","_resultsCard_front","_antiAUntested","_antiBUntested","_antiDUntested","_controlUntested","_waterBottleImage","_waterBottleClickedImage","_needleClosedImage","_needleOpenImage","_watered_image","_needleRedImage","_bloodTypeCard","_bloodTypeCardHidden","_controlImage","_RBWhole1","_RBWhole2","_RBWhole3","_RBWhole4","_RBWhole5","_Aglut1","_Aglut2","_Aglut3","_Aglut4","_Aglut5","_wholeArray","_aglutArray","_rnd1","_rnd2","_rnd3","_type","_rh"]; +private ["_unit","_abc","_opened","_water_displayed","_A_Watered","_B_Watered","_allDisplayed","_water_closed","_D_Watered","_control_Watered","_needleOpened","_needleRed","_antiABlooded","_allClicked","_antiBBlooded","_antiDBlooded","_control_displayed","_antiA_displayed","_antiB_displayed","_antiD_displayed","_results_shown","_isDone","_watered","_watered_complete","_isClose","_unit","_hasTester","_display","_resultsCard_hidden","_antiA","_AntiB","_AntiD","_Control","_waterBottle","_needle","_name","_resultsCard_front","_antiAUntested","_antiBUntested","_antiDUntested","_controlUntested","_waterBottleImage","_waterBottleClickedImage","_needleClosedImage","_needleOpenImage","_watered_image","_needleRedImage","_bloodTypeCard","_bloodTypeCardHidden","_controlImage","_RBWhole1","_RBWhole2","_RBWhole3","_RBWhole4","_RBWhole5","_Aglut1","_Aglut2","_Aglut3","_Aglut4","_Aglut5","_wholeArray","_aglutArray","_rnd1","_rnd2","_rnd3","_type","_rh"]; disableSerialization; //remove option @@ -33,11 +33,10 @@ _needleRed = false; _antiABlooded = false; _antiBBlooded = false; _antiDBlooded = false; -_needleRest = false; _allClicked = 0; if (!_hasTester) exitWith {}; -_dialog = createDialog "bloodTest"; +createDialog "bloodTest"; uiSleep 0.02; @@ -102,7 +101,7 @@ _rnd3 = ceil(random 4); _type = _unit getVariable ["blood_type", false]; _rh = _unit getVariable ["rh_factor", false]; -while {!_isDone and r_doLoop} do { +while {!_isDone && r_doLoop} do { _watered = r_A_watered or r_B_watered or r_D_watered or r_control_watered; //display untested images @@ -121,30 +120,30 @@ _watered = r_A_watered or r_B_watered or r_D_watered or r_control_watered; }; //display clicked water bottle image - if (r_water_clicked and !_water_displayed) then { + if (r_water_clicked && {!_water_displayed}) then { _waterBottle ctrlSetText _waterBottleClickedImage; _water_displayed = true; player removeMagazine "bloodTester"; }; //display water marks - if (r_water_clicked and _watered and (_watered_complete <= 4)) then { - if (r_A_watered and !_A_Watered) then { + if (r_water_clicked && {_watered} && {_watered_complete <= 4}) then { + if (r_A_watered && {!_A_Watered}) then { _antiA ctrlSetText _watered_image; _A_Watered = true; _watered_complete = _watered_complete + 1; }; - if (r_B_watered and !_B_Watered) then { + if (r_B_watered && {!_B_Watered}) then { _antiB ctrlSetText _watered_image; _B_Watered = true; _watered_complete = _watered_complete + 1; }; - if (r_D_watered and !_D_Watered) then { + if (r_D_watered && {!_D_Watered}) then { _antiD ctrlSetText _watered_image; _D_Watered = true; _watered_complete = _watered_complete + 1; }; - if (r_control_watered and !_control_Watered) then { + if (r_control_watered && {!_control_Watered}) then { _Control ctrlSetText _watered_image; _control_Watered = true; _watered_complete = _watered_complete + 1; @@ -152,49 +151,49 @@ _watered = r_A_watered or r_B_watered or r_D_watered or r_control_watered; }; //open needle - if ((r_needleclicked == 1) and !_needleOpened) then { + if ((r_needleclicked == 1) && {!_needleOpened}) then { _needle ctrlSetText _needleOpenImage; _needleOpened = true; }; //close water - if ((_watered_complete >= 4) and !_water_closed) then { + if ((_watered_complete >= 4) && {!_water_closed}) then { _water_closed = true; _waterBottle ctrlSetText _waterBottleImage; }; //needle clicked - if ((r_needleclicked >= 2) and !_needleRed and _needleOpened and (_watered_complete >= 4) and !r_needleReset) then { + if ((r_needleclicked >= 2) && {!_needleRed && {_needleOpened} && {_watered_complete >= 4} && {!r_needleReset}}) then { _needle ctrlSetText _needleRedImage; _needleRed = true; }; //reset needle - if (_needleRed and r_needleReset) then { + if (_needleRed && {r_needleReset}) then { _needle ctrlSetText _needleOpenImage; _needleRed = false; }; //fill with blood - if (r_antiA_done and !_antiABlooded and _needleRed) then { + if (r_antiA_done && {!_antiABlooded} && {_needleRed}) then { r_needleReset = true; _antiA ctrlSetText _controlImage; _antiABlooded = true; _allClicked = _allClicked + 1; }; - if (r_antiB_done and !_antiBBlooded and _needleRed) then { + if (r_antiB_done && {!_antiBBlooded} && {_needleRed}) then { r_needleReset = true; _antiB ctrlSetText _controlImage; _antiBBlooded = true; _allClicked = _allClicked + 1; }; - if (r_antiD_done and !_antiDBlooded and _needleRed) then { + if (r_antiD_done && {!_antiDBlooded} && {_needleRed}) then { r_needleReset = true; _antiD ctrlSetText _controlImage; _antiDBlooded = true; _allClicked = _allClicked + 1; }; - if (r_control_done and !_control_displayed and _needleRed) then { + if (r_control_done && {!_control_displayed} && {_needleRed}) then { r_needleReset = true; _Control ctrlSetText _controlImage; _control_displayed = true; @@ -207,106 +206,106 @@ _watered = r_A_watered or r_B_watered or r_D_watered or r_control_watered; }; //The magic happens if (_allClicked == 4) then { - switch (_type) do { - case "A" : { - if (!_allDisplayed) then { - uiSleep 2; - if (r_antiA_done and !_antiA_displayed) then { - _antiA ctrlSetText (_aglutArray select _rnd1); - _antiA_displayed = true; - }; - if (r_antiB_done and !_antiB_displayed) then { - _AntiB ctrlSetText (_wholeArray select _rnd2); - _antiB_displayed = true; - }; - if (r_antiD_done and !_antiD_displayed) then { - if (_rh) then { - _AntiD ctrlSetText (_aglutArray select _rnd3); - } else { - _AntiD ctrlSetText (_wholeArray select _rnd3); + call { + if (_type == "A") exitwith { + if (!_allDisplayed) then { + uiSleep 2; + if (r_antiA_done && {!_antiA_displayed}) then { + _antiA ctrlSetText (_aglutArray select _rnd1); + _antiA_displayed = true; }; - _antiD_displayed = true; - }; - _allDisplayed = true; - }; - }; - case "B" : { - if (!_allDisplayed) then { - uiSleep 2; - if (r_antiA_done and !_antiA_displayed) then { - _antiA ctrlSetText (_wholeArray select _rnd1); - _antiA_displayed = true; - }; - if (r_antiB_done and !_antiB_displayed) then { - _AntiB ctrlSetText (_aglutArray select _rnd2); - _antiB_displayed = true; - }; - if (r_antiD_done and !_antiD_displayed) then { - if (_rh) then { - _AntiD ctrlSetText (_aglutArray select _rnd3); - } else { - _AntiD ctrlSetText (_wholeArray select _rnd3); + if (r_antiB_done && {!_antiB_displayed}) then { + _AntiB ctrlSetText (_wholeArray select _rnd2); + _antiB_displayed = true; }; - _antiD_displayed = true; - }; - _allDisplayed = true; - }; - }; - case "AB" : { - if (!_allDisplayed) then { - uiSleep 2; - if (r_antiA_done and !_antiA_displayed) then { - _antiA ctrlSetText (_aglutArray select _rnd1); - _antiA_displayed = true; - }; - if (r_antiB_done and !_antiB_displayed) then { - _AntiB ctrlSetText (_aglutArray select _rnd2); - _antiB_displayed = true; - }; - if (r_antiD_done and !_antiD_displayed) then { - if (_rh) then { - _AntiD ctrlSetText (_aglutArray select _rnd3); - } else { - _AntiD ctrlSetText (_wholeArray select _rnd3); + if (r_antiD_done && {!_antiD_displayed}) then { + if (_rh) then { + _AntiD ctrlSetText (_aglutArray select _rnd3); + } else { + _AntiD ctrlSetText (_wholeArray select _rnd3); + }; + _antiD_displayed = true; }; - _antiD_displayed = true; + _allDisplayed = true; }; - _allDisplayed = true; }; - }; - case "O" : { - if (!_allDisplayed) then { - uiSleep 2; - if (r_antiA_done and !_antiA_displayed) then { - _antiA ctrlSetText (_wholeArray select _rnd1); - _antiA_displayed = true; - }; - if (r_antiB_done and !_antiB_displayed) then { - _AntiB ctrlSetText (_wholeArray select _rnd2); - _antiB_displayed = true; - }; - if (r_antiD_done and !_antiD_displayed) then { - if (_rh) then { - _AntiD ctrlSetText (_aglutArray select _rnd3); - } else { - _AntiD ctrlSetText (_wholeArray select _rnd3); + if (_type == "B") exitwith { + if (!_allDisplayed) then { + uiSleep 2; + if (r_antiA_done && {!_antiA_displayed}) then { + _antiA ctrlSetText (_wholeArray select _rnd1); + _antiA_displayed = true; }; - _antiD_displayed = true; + if (r_antiB_done && {!_antiB_displayed}) then { + _AntiB ctrlSetText (_aglutArray select _rnd2); + _antiB_displayed = true; + }; + if (r_antiD_done && {!_antiD_displayed}) then { + if (_rh) then { + _AntiD ctrlSetText (_aglutArray select _rnd3); + } else { + _AntiD ctrlSetText (_wholeArray select _rnd3); + }; + _antiD_displayed = true; + }; + _allDisplayed = true; }; - _allDisplayed = true; }; + if (_type == "AB") exitwith { + if (!_allDisplayed) then { + uiSleep 2; + if (r_antiA_done && {!_antiA_displayed}) then { + _antiA ctrlSetText (_aglutArray select _rnd1); + _antiA_displayed = true; + }; + if (r_antiB_done && {!_antiB_displayed}) then { + _AntiB ctrlSetText (_aglutArray select _rnd2); + _antiB_displayed = true; + }; + if (r_antiD_done && {!_antiD_displayed}) then { + if (_rh) then { + _AntiD ctrlSetText (_aglutArray select _rnd3); + } else { + _AntiD ctrlSetText (_wholeArray select _rnd3); + }; + _antiD_displayed = true; + }; + _allDisplayed = true; + }; + }; + if (_type == "O") exitwith { + if (!_allDisplayed) then { + uiSleep 2; + if (r_antiA_done && {!_antiA_displayed}) then { + _antiA ctrlSetText (_wholeArray select _rnd1); + _antiA_displayed = true; + }; + if (r_antiB_done && {!_antiB_displayed}) then { + _AntiB ctrlSetText (_wholeArray select _rnd2); + _antiB_displayed = true; + }; + if (r_antiD_done && {!_antiD_displayed}) then { + if (_rh) then { + _AntiD ctrlSetText (_aglutArray select _rnd3); + } else { + _AntiD ctrlSetText (_wholeArray select _rnd3); + }; + _antiD_displayed = true; + }; + _allDisplayed = true; + }; }; }; r_canClick_resultsCard = true; - if (r_resultsCard_Clicked and _antiD_displayed and _antiB_displayed and _antiA_displayed and _control_displayed and !_results_shown) then { + if (r_resultsCard_Clicked && {_antiD_displayed && {_antiB_displayed} && {_antiA_displayed} && {_control_displayed} && {!_results_shown}}) then { _resultsCard_hidden ctrlShow false; _resultsCard_front ctrlShow true; _resultsCard_front ctrlSetText _bloodTypeCard; _results_shown = true; }; }; - if (_antiD_displayed and _antiB_displayed and _antiA_displayed and _control_displayed and _results_shown) then { + if (_antiD_displayed && {_antiB_displayed && {_antiA_displayed} && {_control_displayed} && {_results_shown}}) then { r_doLoop = false; _isDone = true; [] spawn { diff --git a/SQF/dayz_code/medical/brokeBones.sqf b/SQF/dayz_code/medical/brokeBones.sqf index ed0a53477..3c01040a9 100644 --- a/SQF/dayz_code/medical/brokeBones.sqf +++ b/SQF/dayz_code/medical/brokeBones.sqf @@ -1,11 +1,11 @@ -private ["_msg","_finished","_id","_unit","_item","_humanityGain"]; +if (dayz_actionInProgress) exitWith {localize "str_player_actionslimit" call dayz_rollingMessages;}; +dayz_actionInProgress = true; + +private ["_msg","_finished","_unit","_item","_humanityGain"]; _unit = (_this select 3) select 0; _item = (_this select 3) select 1; -if (dayz_actionInProgress) exitWith {localize "str_player_actionslimit" call dayz_rollingMessages;}; -dayz_actionInProgress = true; - player removeMagazine _item; call fnc_usec_medic_removeActions; @@ -18,22 +18,22 @@ if (vehicle player == player) then { _finished = true; }; -_msg = if (_item == "equip_woodensplint") then {"STR_ITEM_NAME_WOODENSPLINT"} else {"STR_EQUIP_NAME_15"}; +_msg = ["STR_EQUIP_NAME_15","STR_ITEM_NAME_WOODENSPLINT"] select (_item == "equip_woodensplint"); if (_finished) then { if (_unit == player) then { //Self Healing [player,player,_item] call player_medMorphine; - + format [localize "str_actions_medical_general_self", (localize _msg)] call dayz_rollingMessages; } else { //Give humanity reward to player giving the morphine to another player. - _humanityGain = if (_item == "ItemMorphine") then {50} else {25}; - [_humanityGain,0] call player_humanityChange; - + _humanityGain = [25,50] select (_item == "ItemMorphine"); + _humanityGain call player_humanityChange; + PVDZ_send = [_unit,"Morphine",[_unit,player,_item]]; publicVariableServer "PVDZ_send"; - + format [localize "str_actions_medical_general_give", (localize _msg),(name _unit)] call dayz_rollingMessages; }; } else { diff --git a/SQF/dayz_code/medical/epinephrine.sqf b/SQF/dayz_code/medical/epinephrine.sqf index 058112536..2c6c09cd8 100644 --- a/SQF/dayz_code/medical/epinephrine.sqf +++ b/SQF/dayz_code/medical/epinephrine.sqf @@ -1,11 +1,11 @@ +if (dayz_actionInProgress) exitWith {localize "str_player_actionslimit" call dayz_rollingMessages;}; +dayz_actionInProgress = true; + private ["_finished","_isDead","_unit"]; _unit = (_this select 3) select 0; call fnc_usec_medic_removeActions; -if (dayz_actionInProgress) exitWith {localize "str_player_actionslimit" call dayz_rollingMessages;}; -dayz_actionInProgress = true; - player removeMagazine "ItemEpinephrine"; _finished = ["Medic",1] call fn_loopAction; @@ -13,11 +13,11 @@ _isDead = _unit getVariable["USEC_isDead",false]; if (!_isDead && {_finished}) then { //give humanity - [25,0] call player_humanityChange; - + 25 call player_humanityChange; + PVDZ_send = [_unit,"Epinephrine",[_unit,player]]; publicVariableServer "PVDZ_send"; - + format [localize "str_actions_medical_general_give", (localize "STR_EQUIP_NAME_14"), (name _unit)] call dayz_rollingMessages; } else { player addMagazine "ItemEpinephrine"; diff --git a/SQF/dayz_code/medical/fillBloodBag.sqf b/SQF/dayz_code/medical/fillBloodBag.sqf index 69fcca982..d4ee39fb3 100644 --- a/SQF/dayz_code/medical/fillBloodBag.sqf +++ b/SQF/dayz_code/medical/fillBloodBag.sqf @@ -39,17 +39,17 @@ if (vehicle player == player) then { player playActionNow "Medic"; }; -while {r_doLoop and (_i < 25)} do { +while {r_doLoop && (_i < 25)} do { _animState = animationState player; _isMedic = ["medic",_animState] call fnc_inString; - if (_isMedic and !_started) then { + if (_isMedic && {!_started}) then { player removeMagazine "emptyBloodBag"; localize "str_actions_medical_transfusion_start" call dayz_rollingMessages; //[player,_victim,"loc",rTITLETEXT,localize "str_actions_medical_transfusion_start","PLAIN DOWN"] call RE; _started = true; }; - + if (_started) then { if ((diag_tickTime - _timer) >= 1) then { _timer = diag_tickTime; @@ -93,8 +93,8 @@ if (_complete) then { if (dayz_classicBloodBagSystem) then { player addMagazine "ItemBloodbag"; } else { - switch (_bloodType) do { - case "A" : { + call { + if (_bloodType == "A") exitwith { if (_rh) then { player addMagazine "wholeBloodBagAPOS"; } else { @@ -102,7 +102,7 @@ if (_complete) then { }; }; - case "B" : { + if (_bloodType == "B") exitwith { if (_rh) then { player addMagazine "wholeBloodBagBPOS"; } else { @@ -110,7 +110,7 @@ if (_complete) then { }; }; - case "AB" : { + if (_bloodType == "AB") exitwith { if (_rh) then { player addMagazine "wholeBloodBagABPOS"; } else { @@ -118,7 +118,7 @@ if (_complete) then { }; }; - case "O" : { + if (_bloodType == "O") exitwith { if (_rh) then { player addMagazine "wholeBloodBagOPOS"; } else { @@ -129,4 +129,4 @@ if (_complete) then { }; } else { diag_log format ["Fill Bag: Something went wrong and the bloodBag was not added!"]; -}; \ No newline at end of file +}; diff --git a/SQF/dayz_code/medical/painkiller.sqf b/SQF/dayz_code/medical/painkiller.sqf index 0cf9225df..8d720564a 100644 --- a/SQF/dayz_code/medical/painkiller.sqf +++ b/SQF/dayz_code/medical/painkiller.sqf @@ -19,9 +19,9 @@ if (_unit == player) then { // Heal another player PVDZ_send = [_unit,"Painkiller",[_unit,player]]; publicVariableServer "PVDZ_send"; - + // Give humanity - [20,0] call player_humanityChange; - + 20 call player_humanityChange; + format [localize "str_actions_medical_painkillers_give",(name _unit)] call dayz_rollingMessages; }; diff --git a/SQF/dayz_code/medical/selfbloodbag.sqf b/SQF/dayz_code/medical/selfbloodbag.sqf index f0c527a67..a987eca63 100644 --- a/SQF/dayz_code/medical/selfbloodbag.sqf +++ b/SQF/dayz_code/medical/selfbloodbag.sqf @@ -1,8 +1,8 @@ -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;}; +private ["_msg","_unit","_bagUsed","_duration","_rhVal","_badBag","_bloodType","_bloodBagWholeNeeded","_wholeBag","_transfusionInfection","_finished","_bloodAmount"]; + _unit = _this select 0; _bagUsed = _this select 1; @@ -26,7 +26,7 @@ if (!dayz_classicBloodBagSystem) then { if (!_wholeBag) then {_badBag = true;}; }; -_bloodAmount = if (!_wholeBag) then {(DZE_selfTransfuse_Values select 0)} else {4000}; +_bloodAmount = [4000,(DZE_selfTransfuse_Values select 0)] select (!_wholeBag); localize "str_actions_medical_transfusion_start" call dayz_rollingMessages; _unit removeMagazine _bagUsed; @@ -58,4 +58,4 @@ if (!_finished) then { }; }; -localize _msg call dayz_rollingMessages; \ No newline at end of file +localize _msg call dayz_rollingMessages; diff --git a/SQF/dayz_code/medical/setup_functions_med.sqf b/SQF/dayz_code/medical/setup_functions_med.sqf index d1fe5244b..2d794b245 100644 --- a/SQF/dayz_code/medical/setup_functions_med.sqf +++ b/SQF/dayz_code/medical/setup_functions_med.sqf @@ -4,7 +4,7 @@ fnc_usec_damageHandle = { - Function - [unit] call fnc_usec_damageHandle; ************************************************************/ - //private["_unit","_eh"]; + private "_unit"; _unit = _this select 0; mydamage_eh1 = _unit addeventhandler ["HandleDamage",{_this call fnc_usec_damageHandler;} ]; mydamage_eh2 = _unit addEventHandler ["Fired", {_this call player_fired;}]; @@ -12,6 +12,8 @@ fnc_usec_damageHandle = { }; fnc_usec_pitchWhine = { + private ["_visual", "_sound"]; + _visual = _this select 0; _sound = _this select 1; //affect the player @@ -33,28 +35,30 @@ fnc_usec_pitchWhine = { }; fnc_usec_damageUnconscious = { - private["_unit","_damage"]; + private["_unit","_damage","_inVehicle"]; + _unit = _this select 0; _damage = _this select 1; - + diag_log format["fnc_usec_damageUnconscious: %1,%2,%3",_unit,_damage, player]; - + _inVehicle = (vehicle _unit != _unit); if (_unit == player) then { if (r_player_timeout <= 0) then { r_player_timeout = 120 min (round((((random 2) max 0.1) * _damage) * 20)); }; r_player_unconscious = true; - + player setVariable ["unconsciousTime", r_player_timeout, true]; }; - + if (_inVehicle) then { _unit spawn { private["_veh","_unit"]; _veh = vehicle _this; _unit = _this; - waitUntil{(((getPosATL _veh select 2 < 1) and (speed _veh < 1)) or (!r_player_unconscious))}; + waitUntil {(((getPosATL _veh select 2 < 1) && {speed _veh < 1}) || (!r_player_unconscious))}; + if (r_player_unconscious) then { _unit action ["eject", _veh]; waitUntil{((vehicle _this) != _this)}; @@ -70,12 +74,13 @@ fnc_usec_damageUnconscious = { //Action Handlers added to init file fnc_usec_bulletHit = { - //private["_commit"]; + private "_commit"; + _commit = _this; if (!r_player_unconscious) then { "colorCorrections" ppEffectEnable true; "colorCorrections" ppEffectAdjust [1, 1.1, -0.02, [0.4,-0.2,-0.2, .04], [1,1,1,0], [1,1,1, 0]]; "colorCorrections" ppEffectCommit 0; "dynamicBlur" ppEffectEnable true;"dynamicBlur" ppEffectAdjust [1]; "dynamicBlur" ppEffectCommit 0; - //setCamShakeParams [0.05, 4, 1, 3, true]; + //setCamShakeParams [0.05, 4, 1, 3, true]; addCamShake [5, 0.5, 25]; "colorCorrections" ppEffectAdjust [1, 1, 0, [0,0,0,0], [1, 1, 1, 1], [1, 1, 1, 1]]; "colorCorrections" ppEffectCommit _commit; "dynamicBlur" ppEffectAdjust [0]; "dynamicBlur" ppEffectCommit _commit; @@ -83,7 +88,8 @@ fnc_usec_bulletHit = { }; fnc_usec_damageGetWound = { - //private["_wound"]; + private ["_hit", "_sPoint", "_options", "_rnd", "_wound"]; + _hit = format["%1",_this]; _sPoint = USEC_woundHit find _hit; _options = USEC_woundPoint select _sPoint; @@ -93,6 +99,8 @@ fnc_usec_damageGetWound = { }; fnc_usec_medic_removeActions = { + private "_obj"; + _obj = player; { _obj = _x; @@ -105,7 +113,8 @@ fnc_usec_medic_removeActions = { }; fnc_usec_calculateBloodPerSec = { - private["_bloodLossPerSec","_bloodGainPerSec","_bloodPerSec"]; + private["_bloodLossPerSec","_bloodGainPerSec","_bloodPerSec","_wounded","_time"]; + _bloodLossPerSec = 0; _bloodGainPerSec = 0; @@ -128,7 +137,7 @@ fnc_usec_calculateBloodPerSec = { }; } forEach USEC_typeOfWounds; }; - + //Sepsis if (!r_player_infected) then { if (r_player_Sepsis select 0) then { @@ -144,8 +153,8 @@ fnc_usec_calculateBloodPerSec = { player setVariable["USEC_infected",true,true]; }; }; - - if ((_time < 1) and (isNil "sepsisStarted")) then { + + if ((_time < 1) && {isNil "sepsisStarted"}) then { //if (isNil "sepsisStarted") then { localize "str_medical_sepsis_warning" call dayz_rollingMessages; //systemChat (localize "str_medical_sepsis_warning"); @@ -155,16 +164,16 @@ fnc_usec_calculateBloodPerSec = { } else { _bloodLossPerSec = _bloodLossPerSec + 3; }; - + //_golbalNutrition = 1200 / r_player_Nutrition; if (r_player_bloodregen > 0) then { _bloodGainPerSec = r_player_bloodregen * 0.1; -/* +/* if ((r_player_bloodregen) < 30) then { _bloodGainPerSec = r_player_bloodregen * _golbalNutrition; }; - + if ((r_player_bloodregen)< 60) then { _bloodGainPerSec = r_player_bloodregen * _golbalNutrition; }; @@ -183,7 +192,7 @@ _foodVal = round(100*(1 - (dayz_hunger / SleepFood))); _thirstVal = round(100*(1 - (dayz_thirst / SleepWater))); _tempVal = round(100*(1 - ((dayz_temperatur - dayz_temperaturmin)/(dayz_temperaturmax - dayz_temperaturmin)))); - hintSilent format [ "blood/s: %1\ngain/s: %2\nloss/s: %3\nbloodregen: %4\ninjured: %5\ninfected: %6\nsepsis: %7\ninpain:%15\nblood: %8\nthirst: %9 (%12%%)\nhunger: %10 (%13%%)\ntemp: %11 (%14%%)\nFoodstack: %16\n", + hintSilent format [ "blood/s: %1\ngain/s: %2\nloss/s: %3\nbloodregen: %4\ninjured: %5\ninfected: %6\nsepsis: %7\ninpain:%15\nblood: %8\nthirst: %9 (%12%%)\nhunger: %10 (%13%%)\ntemp: %11 (%14%%)\nFoodstack: %16\n", _bloodPerSec, r_player_bloodgainpersec, r_player_bloodlosspersec, @@ -202,25 +211,26 @@ _tempVal = round(100*(1 - ((dayz_temperatur - dayz_temperaturmin)/(dayz_temperat r_player_foodstack ]; */ - dayz_lastMedicalSource = switch (true) do { - case (dayz_thirst >= SleepWater): {"dehyd"}; //10 - case (dayz_hunger >= SleepFood): {"starve"}; //10 - case (r_player_infected): {"sick"}; //3 - default {"none"}; //reset + dayz_lastMedicalSource = call { + if (dayz_thirst >= SleepWater) exitwith {"dehyd"}; //10 + if (dayz_hunger >= SleepFood) exitwith {"starve"}; //10 + if (r_player_infected) exitwith {"sick"}; //3 + "none"; //reset }; - if (_bloodPerSec < 0 && dayz_lastMedicalSource != "none") then {dayz_lastMedicalTime = diag_tickTime;}; - + if (_bloodPerSec < 0 && {dayz_lastMedicalSource != "none"}) then {dayz_lastMedicalTime = diag_tickTime;}; + r_player_bloodpersec = _bloodPerSec; _bloodPerSec }; fnc_usec_playerHandleBlood = { - private["_bloodPerSec","_elapsedTime"]; + private["_bloodPerSec","_elapsedTime","_bleedTime","_bloodDiff"]; + if (r_player_injured) then { // bleeding _bleedTime = (random 500) + 100; _elapsedTime = 0; - while {(r_player_injured) and (r_player_blood > 0)} do { + while {(r_player_injured) && (r_player_blood > 0)} do { _bloodPerSec = [] call fnc_usec_calculateBloodPerSec; r_player_blood = r_player_blood + _bloodPerSec; _elapsedTime = _elapsedTime + 1; @@ -231,12 +241,12 @@ fnc_usec_playerHandleBlood = { }; _bloodDiff = r_player_blood - (player getVariable["USEC_BloodQty", r_player_bloodTotal]); - + if ((_bloodDiff >= 500) or (_bloodDiff <= -500)) then { player setVariable["USEC_BloodQty",r_player_blood,true]; }; - - + + uiSleep 1; }; } else { // not bleeding @@ -268,48 +278,43 @@ fnc_usec_damageBleed = { - Function fnc_usec_damageBleed: Draw a creepy blood stream from a player limb - [_unit, _wound] call fnc_usec_damageBleed; ************************************************************/ - private["_wound","_modelPos","_point","_source"]; + private["_unit","_wound","_modelPos","_point","_source","_rndX"]; + _unit = _this select 0; _wound = _this select 1; _point = objNull; _source = objNull; if (isServer) exitWith{}; // no graphical effects on server! - /* - if ((dayz_bleedingeffect == 1) or (dayz_bleedingeffect == 3)) then { - [] spawn fnc_blooddrops; - };*/ - //diag_log format ["%1::fnc_usec_damageBleed %2", __FILE__, _this]; - _modelPos = [0,0,0]; - - switch (_wound) do { - case "Pelvis": { - _modelPos = [0,0,0.2]; - }; - case "aimpoint": { - _rndX = (0.1 - random 0.2); - _modelPos = [_rndX,0,0.2]; - }; - case "RightShoulder": { - _modelPos = [0,0,0.2]; - }; - case "LeftShoulder": { - _modelPos = [0,0,0.2]; - }; - //added visual wounds to foots - case "RightFoot": { - _modelPos = [0,0,0.2]; - }; - case "LeftFoot": { - _modelPos = [0,0,0.2]; - }; + _modelPos = call { + if (_wound == "Pelvis") exitwith { + [0,0,0.2] }; + if (_wound == "aimpoint") exitwith { + _rndX = (0.1 - random 0.2); + [_rndX,0,0.2] + }; + if (_wound == "RightShoulder") exitwith { + [0,0,0.2] + }; + if (_wound == "LeftShoulder") exitwith { + [0,0,0.2] + }; + //added visual wounds to foots + if (_wound == "RightFoot") exitwith { + [0,0,0.2] + }; + if (_wound == "LeftFoot") exitwith { + [0,0,0.2] + }; + [0,0,0]; + }; while {1 == 1} do { scopeName "main"; waitUntil {(vehicle _unit == _unit)}; - + if ((dayz_bleedingeffect == 2) or (dayz_bleedingeffect == 3)) then { //Blood partical _point = "Logic" createVehicleLocal getPosATL _unit; @@ -337,7 +342,7 @@ fnc_usec_damageBleed = { uiSleep 5; - while {((_unit getVariable["USEC_injured",true]) and (alive _unit))} do { + while {((_unit getVariable["USEC_injured",true]) && {alive _unit})} do { scopeName "loop"; if (vehicle _unit != _unit) then { BreakOut "loop"; diff --git a/SQF/dayz_code/medical/transfusion.sqf b/SQF/dayz_code/medical/transfusion.sqf index 2bd22d0ee..e16cd42c7 100644 --- a/SQF/dayz_code/medical/transfusion.sqf +++ b/SQF/dayz_code/medical/transfusion.sqf @@ -1,4 +1,4 @@ -private ["_msg","_bagUsed","_bloodResult","_bloodAmount","_unit","_hasTransfusionKit","_timer","_i","_isClose","_duration","_rhVal","_bloodBagArrayNeeded","_bloodBagNeeded","_badBag","_wholeBag","_bagFound","_bloodType","_rh","_bloodBagWholeNeeded","_wholeBagFound","_bloodTestdone"];// bleed.sqf +private ["_msg","_bagUsed","_bloodResult","_bloodAmount","_unit","_humanityAwarded","_timer","_i","_isClose","_duration","_rhVal","_bloodBagArrayNeeded","_badBag","_wholeBag","_bagFound","_bloodType","_rh","_bloodBagWholeNeeded","_wholeBagFound","_bloodTestdone"];// bleed.sqf _unit = (_this select 3) select 0; _bagUsed = (_this select 3) select 1; @@ -10,11 +10,11 @@ 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 +if (time - dayz_lastTransfusion > 120) then {dayz_bloodBagHumanity = 300;}; //Reset humanity reward to full value after two minutes _badBag = false; _wholeBag = 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 @@ -26,7 +26,7 @@ if (!dayz_classicBloodBagSystem) then { //if (!_hasTransfusionKit) exitWith { localize "str_actions_medical_transfusion_failed_transfusionkit" call dayz_rollingMessages; }; //Unconscious timeout for receiving unit - _duration = if ((_unit getVariable ["USEC_BloodQty", 0]) <= 4000) then { 3 } else { 2 }; + _duration = [2,3] select (_unit getVariable ["USEC_BloodQty", 0]); _bloodBagArrayNeeded = ["bloodBagONEG"]; if (_bloodTestdone) then { // if the recipient does not know his blood type, only O- can apply @@ -61,15 +61,14 @@ _timer = diag_tickTime; _i = 0; _humanityAwarded = 0; _msg = ""; - -_bloodAmount = if (!_wholeBag) then { r_player_bloodTotal/*Full bloodbag*/ } else { 4000 /*Whole blood only gives 4k*/ }; +_bloodAmount = [4000 /*Whole blood only gives 4k*/,r_player_bloodTotal/*Full bloodbag*/] select (!_wholeBag); //diag_log format ["TRANSFUSION: starting blood transfusion (%1 > %2)", name player, name _unit]; player removeMagazine _bagUsed; player playActionNow "Medic"; -if (!_badBag) then { +if (!_badBag) then { PVDZ_send = [_unit,"Transfuse",[_unit,player,_bloodAmount]]; publicVariableServer "PVDZ_send"; }; @@ -77,11 +76,11 @@ if (!_badBag) then { 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 { @@ -91,34 +90,34 @@ while {r_doLoop} do { }; 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; + _humanityAwarded = _humanityAwarded + 25; }; } else { // 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 ((_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_bloodBagHumanity = dayz_bloodBagHumanity / 2; //Diminish humanity reward for subsequent transfusions. Resets to full reward after two minutes. dayz_lastTransfusion = time; if (!_badBag) then { - [_humanityAwarded,0] call player_humanityChange; + _humanityAwarded call player_humanityChange; _msg = "str_actions_medical_transfusion_successful"; }; r_doLoop = false; @@ -126,7 +125,7 @@ while {r_doLoop} do { _isClose = ((player distance _unit) < ((sizeOf typeOf _unit) / 2)); - if (r_interrupt or !_isClose) then { + if (r_interrupt || {!_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; @@ -147,8 +146,3 @@ if (r_interrupt) then { 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 - -*/ diff --git a/SQF/dayz_code/medical/wipes.sqf b/SQF/dayz_code/medical/wipes.sqf index e8f6bf709..245b54d92 100644 --- a/SQF/dayz_code/medical/wipes.sqf +++ b/SQF/dayz_code/medical/wipes.sqf @@ -33,7 +33,7 @@ if (_finished) then { publicVariableServer "PVDZ_send"; // Give humanity - [20,0] call player_humanityChange; + 20 call player_humanityChange; format[localize "str_actions_medical_gave_wipes",(name _unit)] call dayz_rollingMessages; };