From cdb9776d4ec63c0257fedf8797384adbab4c9ac1 Mon Sep 17 00:00:00 2001 From: ebaydayz Date: Tue, 15 Nov 2016 13:57:40 -0500 Subject: [PATCH] Add bloodbag cooldown --- SQF/dayz_code/configVariables.sqf | 1 + SQF/dayz_code/init/variables.sqf | 2 ++ SQF/dayz_code/medical/selfbloodbag.sqf | 7 +++---- SQF/dayz_code/medical/transfusion.sqf | 4 +++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/SQF/dayz_code/configVariables.sqf b/SQF/dayz_code/configVariables.sqf index 4b52d7395..7a415749e 100644 --- a/SQF/dayz_code/configVariables.sqf +++ b/SQF/dayz_code/configVariables.sqf @@ -10,6 +10,7 @@ dayz_waterBottleBreaking = false; // Water bottles have a chance to break when b dayz_tameDogs = false; // Allow taming dogs with raw meat dayz_townGenerator = false; // Spawn vanilla map junk instead of Epoch DynamicDebris. Currently only compatible with Chernarus. dayz_townGeneratorBlackList = []; // Town generator will not spawn junk within 150m of these positions. Example for Chernarus trader cities: [[4053,11668,0],[11463,11349,0],[6344,7806,0],[1606,7803,0],[12944,12766,0],[5075,9733,0],[12060,12638,0]] +dayz_transfuseCoolDown = 120; // Cooldown in seconds before a player can transfuse another player. DZE_NoVehicleExplosions = false; //Disable vehicle explosions to prevent damage to objects by ramming - doesn't work with amphibious pook which you should not use due to other issues DZE_TempVars = [7, 15, 4, 4, 2, 6, 3, 2, 0.25, 0.75, 0.5]; //[vehicle, fire, building, moving, sun, heatpack, water, standing, rain, wind, night] water, standing, rain, wind and night factors have a negative impact on temperature, the greater they are the quicker the player gets cold DZE_WeatherVariables = [10, 20, 5, 10, 0, 0.2, 0, 0.7, 0, 0.6, 0, 8, 25, 30, 0, false]; //See DynamicWeatherEffects.sqf for info on these values diff --git a/SQF/dayz_code/init/variables.sqf b/SQF/dayz_code/init/variables.sqf index 1758c5ac9..f643c5dca 100644 --- a/SQF/dayz_code/init/variables.sqf +++ b/SQF/dayz_code/init/variables.sqf @@ -614,6 +614,8 @@ if (!isDedicated) then { dayz_lastMedicalTime = 0; dayz_lastClothesChange = 0; dayZ_lastPlayerUpdate = 0; + dayz_lastSelfTransfusion = -(DZE_selfTransfuse_Values select 2); + dayz_lastTransfusion = -(dayz_transfuseCoolDown); dayz_playerName = "unknown"; dayz_hunger = 0; dayz_thirst = 0; diff --git a/SQF/dayz_code/medical/selfbloodbag.sqf b/SQF/dayz_code/medical/selfbloodbag.sqf index a5eee52a2..3d6e45d9e 100644 --- a/SQF/dayz_code/medical/selfbloodbag.sqf +++ b/SQF/dayz_code/medical/selfbloodbag.sqf @@ -1,4 +1,4 @@ -private ["_unit","_blood","_lowBlood","_injured","_inPain","_lastused","_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 ["_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"]; // bleed.sqf _unit = _this select 0; @@ -8,8 +8,7 @@ _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 (time - _lastused <= DZE_selfTransfuse_Values select 2) exitWith {localize "str_actions_medical_18" call dayz_rollingMessages;}; +if (time - dayz_lastSelfTransfusion <= DZE_selfTransfuse_Values select 2) exitWith {localize "str_actions_medical_18" call dayz_rollingMessages;}; call gear_ui_init; closeDialog 0; @@ -128,7 +127,7 @@ 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,false]; + 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; diff --git a/SQF/dayz_code/medical/transfusion.sqf b/SQF/dayz_code/medical/transfusion.sqf index 58f8aeccf..8101ad91d 100644 --- a/SQF/dayz_code/medical/transfusion.sqf +++ b/SQF/dayz_code/medical/transfusion.sqf @@ -1,7 +1,8 @@ -private ["_bloodAmount","_unit","_blood","_lowBlood","_injured","_inPain","_lastused","_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 +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 _unit = (_this select 3) select 0; +if (time - dayz_lastTransfusion <= dayz_transfuseCoolDown) exitWith {localize "str_actions_medical_18" call dayz_rollingMessages;}; //Does the player have a transfusionKit //_hasTransfusionKit = "transfusionKit" in magazines player; @@ -192,6 +193,7 @@ while {r_doLoop} do { 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_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; };