Skip to content

Commit

Permalink
[BloodBagging] - Quick fix
Browse files Browse the repository at this point in the history
Fixed missing _bbselect var.

Changed humanity, In place of 250 soon as you start to bloodbag, This
has changed to give 25 humanity per tick so the player giving the
bloodbag will now have to wait the full time and humanity is only gained
on the amount of blood given.
So if you only do one tick giving 500 blood you only get 25 humanity
  • Loading branch information
R4Z0R49 committed Dec 26, 2014
1 parent b14f70b commit c743362
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 18 deletions.
7 changes: 4 additions & 3 deletions SQF/dayz_code/medical/publicEH/medTransfuse.sqf
Expand Up @@ -3,12 +3,13 @@ private["_array","_unit","_medic","_amount","_display","_control","_lowBlood"];
disableserialization;
//[_unit,player,_bloodAmount]
_array = _this; //_this select 0;
_unit = _array select 0;
_medic = _array select 1;
_amount = _array select 2;
_unit = _array select 0; //Player receving the blood
_medic = _array select 1; //Player sending the blood
_amount = _array select 2; //total amount of blood given

_forceClose = false;
_timer = diag_tickTime;
r_doLoop = true;

if (_amount < 0) exitWith { /* someone is trying to kill the player */ };

Expand Down
58 changes: 43 additions & 15 deletions SQF/dayz_code/medical/transfusion.sqf
@@ -1,24 +1,28 @@
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"];
// bleed.sqf
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
//Get receving unit
_unit = (_this select 3) select 0;
_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", time];

//Does the player have a transfusionKit
_hasTransfusionKit = "transfusionKit" in magazines player;

//Get receving units blood value
_blood = _unit getVariable ["USEC_BloodQty", 0];
//Get receving units bloodtype
_bloodType = _unit getVariable ["blood_type", ""];
//Get the receving units RH type
_rh = _unit getVariable ["rh_factor", false];
//Get status of bloodtest of receving unit
_bloodTestdone = _unit getVariable ["blood_testdone", false];

_badBag = false;
_wholeBag = false;
_bagFound = false;
_forceClose = false;

if (!_hasTransfusionKit) exitWith {};
//End if the player does not have a transfusion kit
if (!_hasTransfusionKit) exitWith { cutText [localize "str_actions_medical_transfusion_failed_transfusionkit", "PLAIN DOWN"]; };

//Unconscious timeout for receving unit
_duration = if (_blood <= 4000) then { 3 } else { 2 };
_bloodBagArray = ["bloodBagANEG","bloodBagAPOS","bloodBagBNEG","bloodBagBPOS","bloodBagABNEG","bloodBagABPOS","bloodBagONEG","bloodBagOPOS","wholeBloodBagANEG","wholeBloodBagAPOS","wholeBloodBagBNEG","wholeBloodBagBPOS","wholeBloodBagABNEG","wholeBloodBagABPOS","wholeBloodBagONEG","wholeBloodBagOPOS"];
_bloodBagArrayNeeded = ["ItemBloodbag","bloodBagONEG"];
Expand Down Expand Up @@ -56,7 +60,7 @@ if (_bloodTestdone) then { // if the recipient does not know his blood type, onl
};

_BBneeded = false;
{ if (_x in magazines player) exitWith { _BBneeded = true; }; } count _bloodBagArrayNeeded;
{ if (_x in magazines player) exitWith { _BBneeded = true; _bbselect = _x; }; } count _bloodBagArrayNeeded;

//No subs for whole blood :(
_rhVal = if (_rh) then { "POS" } else { "NEG" };
Expand Down Expand Up @@ -89,9 +93,11 @@ _animState = animationState player;
r_doLoop = true;
_started = false;
_finished = false;
_sentRequest = false;
_timer = diag_tickTime;
_i = 0;
_r = 0;
_humanityAwarded = 0;

_bloodAmount = if (!_wholeBag) then { 12000/*Full bloodbag*/ } else { 4000 /*Whole blood only gives 4k*/ };

Expand All @@ -104,8 +110,10 @@ while {r_doLoop} do {
diag_log format ["TRANSFUSION: starting blood transfusion (%1 > %2)", name player, name _unit];
if (_badBag) then {
for "_r" from 0 to 15 do {
//select random bloodbag if the player has more then one of the required types
_bagToRemove = _bloodBagArray select _r;
if (_bagToRemove in magazines player) exitWith { //TODO: add separate action menu options so the removed bag isn't random
//TODO: add separate action menu options so the removed bag isn't random
if (_bagToRemove in magazines player) exitWith {
_bagFound = true;
if (_r >= 8) then {
_wholeBag = true;
Expand All @@ -120,17 +128,21 @@ while {r_doLoop} do {
};
if (!_bagFound) then {_forceClose = true;} else { player removeMagazine _bagToRemove; player removeMagazine "transfusionKit";};
cutText [localize "str_actions_medical_transfusion_start", "PLAIN DOWN"];
[player,_unit,"loc",rTITLETEXT,format["Transfusion of %1 in progress, remain still...",_bagToRemove],"PLAIN DOWN"] call RE;
//see Note 1
//[player,_unit,"loc",rTITLETEXT,format["Transfusion of %1 in progress, remain still...",_bagToRemove],"PLAIN DOWN"] call RE;
_started = true;
};

if (_started) then {
if ((_bloodAmount == 12000) or (_bloodAmount == 4000)) then {
//_sentRequest var stops the pvs running more then once as it's no longer needs too 1.8.4
if (!_sentRequest) then {
PVDZ_send = [_unit,"Transfuse",[_unit,player,_bloodAmount]];
publicVariableServer "PVDZ_send";
_sentRequest = true;
};
if ((diag_tickTime - _timer) >= 1) then {
_timer = diag_tickTime;
//see Note 1
//PVCDZ_hlt_Transfuse = [_unit,player,1000];
//publicVariable "PVCDZ_hlt_Transfuse";
if (!_wholeBag) then {
Expand All @@ -141,8 +153,16 @@ while {r_doLoop} do {
if (!_badBag) then {
if (!_forceClose) then {
_bloodAmount = _bloodAmount - 500;
//see Note 1
//PVDZ_send = [_unit,"Transfuse",[_unit,player,500]];
//publicVariableServer "PVDZ_send";

// 25 points to be givin upto 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 pullrequest from ILoveBeans
if ( _humanityAwarded < 300 ) then {
_humanityAwarded = _humanityAwarded + 25 ;
};
};
} else {
if (!_forceClose and (_i >= 12)) then {
Expand All @@ -155,7 +175,8 @@ while {r_doLoop} do {
};

cutText [localize "str_actions_medical_transfusion_start", "PLAIN DOWN"];
[player,_unit,"loc",rTITLETEXT,format["Transfusion of %1 in progress, remain still...",_bagToRemove],"PLAIN DOWN"] call RE;
//see Note 1
//[player,_unit,"loc",rTITLETEXT,format["Transfusion of %1 in progress, remain still...",_bagToRemove],"PLAIN DOWN"] call RE;

};
if (!_isMedic) then {
Expand All @@ -168,8 +189,9 @@ while {r_doLoop} do {
if (_blood >= r_player_bloodTotal or _bloodAmount == 0) then {
diag_log format ["TRANSFUSION: completed blood transfusion successfully (_i = %1)", _i];
cutText [localize "str_actions_medical_transfusion_successful", "PLAIN DOWN"];
//see Note 1
//[player,_unit,"loc",rTITLETEXT,localize "str_actions_medical_transfusion_successful","PLAIN DOWN"] call RE;
if (!_badBag and _bagFound) then { [player,250] call player_humanityChange; };
if (!_badBag and _bagFound) then { [player,_humanityAwarded] call player_humanityChange; };
r_doLoop = false;
};

Expand All @@ -178,7 +200,8 @@ while {r_doLoop} do {
if (r_interrupt or !_isClose or _forceClose) then {
diag_log format ["TRANSFUSION: transfusion was interrupted (r_interrupt: %1 | distance: %2 (%3) | _i = %4)", r_interrupt, player distance _unit, _isClose, _i];
cutText [localize "str_actions_medical_transfusion_interrupted", "PLAIN DOWN"];
[player,_unit,"loc",rTITLETEXT,localize "str_actions_medical_transfusion_interrupted","PLAIN DOWN"] call RE;
//see Note 1
//[player,_unit,"loc",rTITLETEXT,localize "str_actions_medical_transfusion_interrupted","PLAIN DOWN"] call RE;
r_doLoop = false;
};

Expand All @@ -192,3 +215,8 @@ if (r_interrupt) then {
player switchMove "";
player playActionNow "stop";
};

/*
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
*/
8 changes: 8 additions & 0 deletions SQF/dayz_code/stringtable.xml
Expand Up @@ -626,6 +626,14 @@
<French>Eteindre %1</French>
<Czech>Uhasit %1</Czech>
</Key>
<Key ID="str_actions_medical_transfusion_failed_transfusionkit">
<English>Transfusion failed missing Transfusion Kit!</English>
<German>Transfusion failed missing Transfusion Kit!</German>
<Russian>Transfusion failed missing Transfusion Kit!</Russian>
<Spanish>Transfusion failed missing Transfusion Kit!</Spanish>
<French>Transfusion failed missing Transfusion Kit!</French>
<Czech>Transfusion failed missing Transfusion Kit!</Czech>
</Key>
<Key ID="str_actions_medical_transfusion_start">
<English>Transfusion in progress, remain still...</English>
<German>Transfusion wird verabreicht, stillhalten ...</German>
Expand Down

0 comments on commit c743362

Please sign in to comment.