From 22bfba6573b39c624cb1668508c718c30a111927 Mon Sep 17 00:00:00 2001 From: icomrade Date: Wed, 19 Mar 2014 18:03:11 -0400 Subject: [PATCH] Add optional self transfuse Right click on blood bag, if enable it will show the self transfuse button. Currently replenishes all blood. May be used once every 5 minutes. --- CHANGE LOG 1.0.5.txt | 1 + .../Configs/CfgMagazines/DZE/Items.hpp | 17 ++++++ SQF/dayz_code/actions/player_useMeds.sqf | 4 +- SQF/dayz_code/compile/ui_selectSlot.sqf | 2 +- SQF/dayz_code/init/variables.sqf | 4 ++ .../medical/publicEH/medTransfuse.sqf | 8 +-- SQF/dayz_code/medical/self_transfusion.sqf | 55 +++++++++++++++++++ SQF/dayz_code/medical/transfusion.sqf | 4 +- SQF/dayz_epoch_b/stringtable.xml | 16 +++--- 9 files changed, 94 insertions(+), 17 deletions(-) create mode 100644 SQF/dayz_code/medical/self_transfusion.sqf diff --git a/CHANGE LOG 1.0.5.txt b/CHANGE LOG 1.0.5.txt index 479d72874..52652a870 100644 --- a/CHANGE LOG 1.0.5.txt +++ b/CHANGE LOG 1.0.5.txt @@ -3,6 +3,7 @@ [ADDED] Classname C130J_US_EP1_DZ Weapon: 50 Magazine: 400 Backpack: 10 @Fank [ADDED] Variable DZE_ForceNameTagsInTrader to force name tags in traders. @Skaronator @Fank [ADDED] Switch seats in all vehicles. @icomrade +[ADDED] Self transfusions (works in vehicles) must be enabled in mission using DZE_SelfTransfuse. @icomrade [FIXED] Instance already initialized error in server_monitor.sqf @vbawol [FIXED] Fixed infinite chainsaw fuel when put into vaults/lockboxes. @SilvDev diff --git a/SQF/dayz_code/Configs/CfgMagazines/DZE/Items.hpp b/SQF/dayz_code/Configs/CfgMagazines/DZE/Items.hpp index 53b885243..8a6d78b29 100644 --- a/SQF/dayz_code/Configs/CfgMagazines/DZE/Items.hpp +++ b/SQF/dayz_code/Configs/CfgMagazines/DZE/Items.hpp @@ -390,4 +390,21 @@ class ItemHotwireKit: CA_Magazine { picture = "\z\addons\dayz_epoch\pictures\equip_hotwire_ca.paa"; descriptionShort = "Used to temporarily unlock and start a vehicle has a chance of failure and is consumed on use."; weight = 2; +}; + +class ItemBloodbag: CA_Magazine +{ + scope = 2; + count = 1; + type = 256; + displayName = "$STR_EQUIP_NAME_16"; + model = "\dayz_equip\models\bloodbag.p3d"; + picture = "\dayz_equip\textures\equip_bloodbag_ca.paa"; + descriptionShort = "$STR_EQUIP_DESC_16"; + class ItemActions { + class use { + text = "Self transfusion"; + script = "spawn player_useMeds;"; + }; + }; }; \ No newline at end of file diff --git a/SQF/dayz_code/actions/player_useMeds.sqf b/SQF/dayz_code/actions/player_useMeds.sqf index ebd68e6bd..ae6aed930 100644 --- a/SQF/dayz_code/actions/player_useMeds.sqf +++ b/SQF/dayz_code/actions/player_useMeds.sqf @@ -10,7 +10,6 @@ _config = configFile >> "CfgMagazines" >> _item; _text = getText (_config >> "displayName"); if (!_hasmeditem) exitWith {cutText [format[(localize "str_player_31"),_text,"use"] , "PLAIN DOWN"]}; - switch (_item) do { case "ItemBandage": { _id = [0,0,0,[player]] execVM "\z\addons\dayz_code\medical\bandage.sqf"; @@ -24,6 +23,9 @@ switch (_item) do { case "ItemAntibiotic": { _id = [0,0,0,[player]] execVM "\z\addons\dayz_code\medical\antibiotics.sqf"; }; + case "ItemBloodbag": { + _id = [0,0,0,[player]] execVM "\z\addons\dayz_code\medical\self_transfusion.sqf"; + }; case "ItemHeatPack": { player removeMagazine "ItemHeatPack"; dayz_temperatur = (dayz_temperatur + 5) min dayz_temperaturmax; diff --git a/SQF/dayz_code/compile/ui_selectSlot.sqf b/SQF/dayz_code/compile/ui_selectSlot.sqf index db5608777..236cbc3b1 100644 --- a/SQF/dayz_code/compile/ui_selectSlot.sqf +++ b/SQF/dayz_code/compile/ui_selectSlot.sqf @@ -5,7 +5,7 @@ _button = _this select 1; _parent = findDisplay 106; //if ((time - dayzClickTime) < 1) exitWith {}; - +if (!DZE_SelfTransfuse && ((gearSlotData _control) == "ItemBloodBag")) exitWith {}; if (_button == 1) then { //dayzClickTime = time; _group = _parent displayCtrl 6902; diff --git a/SQF/dayz_code/init/variables.sqf b/SQF/dayz_code/init/variables.sqf index c52e4655d..7ac0af09a 100644 --- a/SQF/dayz_code/init/variables.sqf +++ b/SQF/dayz_code/init/variables.sqf @@ -436,7 +436,11 @@ dayz_spawnArea = 200; // radius around player where we can spawn loot & Z dayz_cantseeDist = 150; // distance from which we can spawn a Z in front of any player without ray-tracing and angle checks dayz_cantseefov = 70; // half player field-of-view. Visible Z won't be spawned in front of any near players dayz_canDelete = 300; // Z, further than this distance from its "owner", will be deleted +selfTransfusionTime = -300; //time to keep for last self transfusion. +if(isNil "DZE_SelfTransfuse") then { + DZE_SelfTransfuse = false; +}; if(isNil "dayz_maxAnimals") then { dayz_maxAnimals = 5; }; diff --git a/SQF/dayz_code/medical/publicEH/medTransfuse.sqf b/SQF/dayz_code/medical/publicEH/medTransfuse.sqf index 69b94d2ec..9f510cab0 100644 --- a/SQF/dayz_code/medical/publicEH/medTransfuse.sqf +++ b/SQF/dayz_code/medical/publicEH/medTransfuse.sqf @@ -1,16 +1,14 @@ // animHealed.sqf -private ["_array","_unit","_medic","_display","_control","_rndInfection","_TransfusionInfection"]; +private ["_array","_unit","_display","_control","_rndInfection","_TransfusionInfection"]; disableserialization; -_array = _this; //_this select 0; -_unit = _array select 0; -_medic = _array select 1; +_unit = _this select 0; _rndInfection = (random 15); _TransfusionInfection = (_rndInfection < 1); if (_unit == player) then { r_player_blood = r_player_bloodTotal; - r_player_lowblood = false; + r_player_lowblood = false; 10 fadeSound 1; "dynamicBlur" ppEffectAdjust [0]; "dynamicBlur" ppEffectCommit 5; "colorCorrections" ppEffectAdjust [1, 1, 0, [1, 1, 1, 0.0], [1, 1, 1, 1], [1, 1, 1, 1]];"colorCorrections" ppEffectCommit 5; diff --git a/SQF/dayz_code/medical/self_transfusion.sqf b/SQF/dayz_code/medical/self_transfusion.sqf new file mode 100644 index 000000000..5bb7d884f --- /dev/null +++ b/SQF/dayz_code/medical/self_transfusion.sqf @@ -0,0 +1,55 @@ +private ["_started","_finished","_animState","_isMedic","_num_removed","_unit","_lastused"]; +if (!DZE_SelfTransfuse) exitWith {}; +_unit = player; +_lastused = selfTransfusionTime; +if ((round(time - _lastused)) <= 300) exitWith {cutText [format[(localize "str_actions_medical_18"),(300 - (round(time - _lastused)))] , "PLAIN DOWN"]}; + +call fnc_usec_medic_removeActions; +r_action = false; + +if (vehicle player == player) then { + player playActionNow "Medic"; +}; +[1,1] call dayz_HungerThirst; +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 and !_isMedic) then { + r_doLoop = false; + _finished = true; + }; + if (r_interrupt) then { + r_doLoop = false; + }; + if (vehicle player != player) then { + sleep 6; + r_doLoop = false; + _finished = true; + }; + sleep 0.1; +}; +r_doLoop = false; + +if (_finished) then { + selfTransfusionTime = time; + _unit setVariable["USEC_lowBlood",false,true]; + _num_removed = ([player,"ItemBloodbag"] call BIS_fnc_invRemove); + if(_num_removed == 1) then { + if (vehicle player != player) then { + (findDisplay 106) closeDisplay 0; + }; + [_unit] call player_medTransfuse; + }; +} else { + r_interrupt = false; + player switchMove ""; + player playActionNow "stop"; +}; \ No newline at end of file diff --git a/SQF/dayz_code/medical/transfusion.sqf b/SQF/dayz_code/medical/transfusion.sqf index 554ee6a94..56f716d1d 100644 --- a/SQF/dayz_code/medical/transfusion.sqf +++ b/SQF/dayz_code/medical/transfusion.sqf @@ -4,7 +4,7 @@ _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", time]; +//_lastused = _unit getVariable ["LastTransfusion", time]; // if (_lastused - time < 60) exitwith {cutText [format[(localize "str_actions_medical_18"),_text] , "PLAIN DOWN"]}; @@ -41,7 +41,7 @@ while {r_doLoop} do { r_doLoop = false; if (_finished) then { - _unit setVariable["LastTransfusion",time,true]; + //_unit setVariable["LastTransfusion",time,true]; //reserve for self transfusion _unit setVariable["USEC_lowBlood",false,true]; _num_removed = ([player,"ItemBloodbag"] call BIS_fnc_invRemove); if(_num_removed == 1) then { diff --git a/SQF/dayz_epoch_b/stringtable.xml b/SQF/dayz_epoch_b/stringtable.xml index 449e5c173..956634f4f 100644 --- a/SQF/dayz_epoch_b/stringtable.xml +++ b/SQF/dayz_epoch_b/stringtable.xml @@ -1153,14 +1153,14 @@ Uhasit %1 - You cannot perform another blood transfusion so fast - You cannot perform another blood transfusion so fast - Sie können so schnell keine weitere Bluttransfusion durchführen - Вы не можете переливать кровь так быстро - No puedes realizar otra transfución de sangre tan rápido. - Je kunt niet zosnel aaneenvolgend een bloedtransfusie uitvoeren - Vous ne pouvez pas faire d'autre transfusion de sang aussi rapidement - Nelze znovu provést krevní transfúzi tak rychle po sobě. + You cannot perform another blood transfusion so fast, wait %1 seconds + You cannot perform another blood transfusion so fast, wait %1 seconds + Sie können eine weitere Bluttransfusion so schnell nicht durchführen, warten Sie %1 Sekunden. + Вы не можете выполнить другую переливание крови так быстро, подождите %1 секунд. + No es posible realizar otra transfusión de sangre tan rápido, esperar %1 segundos. + U kunt een bloedtransfusie niet uit te voeren zo snel, wacht %1 seconden. + Vous ne pouvez pas effectuer une autre transfusion sanguine si vite, attendez %1 secondes. + Nemůžete provádět další krevní transfuzi tak rychle, počkejte %1 sekund. Study Body