Merge selfbloodbag and self_transfuse

This commit is contained in:
ebaydayz
2016-03-30 20:50:06 -04:00
parent 69091965a1
commit c54a52a103
56 changed files with 172 additions and 970 deletions

View File

@@ -39,7 +39,7 @@ while {r_doLoop} do {
r_doLoop = false;
_finished = true;
};
uisleep 0.1;
uiSleep 0.1;
};
r_doLoop = false;

View File

@@ -1,12 +1,10 @@
// bleed.sqf
private ["_unit","_isDead"];
_unit = (_this select 3) select 0;
_isDead = _unit getVariable["USEC_isDead",false];
call fnc_usec_medic_removeActions;
player removeMagazine "ItemEpinephrine";
player playActionNow "Medic";
player removeMagazine "ItemEpinephrine";
uiSleep 3;
@@ -14,7 +12,10 @@ if (!_isDead) then {
_unit setVariable ["NORRN_unconscious", false, true];
_unit setVariable ["USEC_isCardiac",false,true];
uiSleep 5;
/* PVS/PVC - Skaronator */
//give humanity
[player,25] call player_humanityChange;
PVDZ_send = [_unit,"Epinephrine",[_unit,player,"ItemEpinephrine"]];
publicVariableServer "PVDZ_send";
};

View File

@@ -1,8 +1,7 @@
// allowDamage.sqf
private ["_unit"];
_unit = _this select 0;
_unit switchMove "AmovPpneMstpSnonWnonDnon_healed";
_unit allowDamage true;
_unit switchMove "AmovPpneMstpSnonWnonDnon_healed";
_unit allowDamage true;
_unit setCaptive false;

View File

@@ -1,6 +1,5 @@
// animDrag.sqf
private ["_dragee"];
_dragee = _this select 0;
_dragee switchmove "ainjppnemstpsnonwrfldb_still";

View File

@@ -1,10 +1,9 @@
// animHealed.sqf
private ["_unit"];
_unit = _this select 0;
_unit switchMove "AmovPpneMstpSnonWnonDnon_healed";
if ((_unit == player) || (vehicle player != player)) then {
if (_unit == player) then {
r_player_unconscious = false;
r_player_injured = false;
};

View File

@@ -1,5 +1,4 @@
//carriedUp.sqf
private ["_dragee"];
_dragee = _this select 0;
_dragee switchmove "ainjpfalmstpsnonwrfldnon_carried_up";

View File

@@ -1,6 +1,6 @@
//deadState.sqf
private ["_unit"];
_unit = _this select 0;
_unit switchMove "deadState";
_unit switchMove "deadState";

View File

@@ -1,6 +1,6 @@
//lieStill.sqf
private ["_dragee"];
_dragee = _this select 0;
_dragee playMoveNow "ainjppnemstpsnonwrfldnon";
_dragee playMoveNow "ainjppnemstpsnonwrfldnon";

View File

@@ -1,6 +1,5 @@
// load_wounded.sqf
private ["_unit"];
_unit = _this select 0;
_unit switchMove "kia_hmmwv_driver";

View File

@@ -1,5 +1,6 @@
// called by PublicVariableEventHandler "PVCDZ_hlt_Epi", received from the server,
// because another player sent a PVDZ_send = [_unit,"Epinephrine",[_unit,player,"ItemEpinephrine"]];
_array = _this; //_this select 0;
_unit = _array select 0; // healed
_medic = _array select 1; // healer
@@ -12,4 +13,4 @@ if (_unit == player and !(_unit getVariable["USEC_isDead",false]) and _medic !=
_unit setVariable ["NORRN_unconscious", false, false]; r_player_unconscious = false;
_unit setVariable ["USEC_isCardiac",false, false]; r_player_cardiac = false;
//AmovPpneMstpSnonWnonDnon_healed
};
};

View File

@@ -1,35 +1,76 @@
private ["_selfTransValues","_unit","_display","_control","_rndInfection","_TransfusionInfection"];
// animHealed.sqf
private["_array","_unit","_medic","_amount","_display","_control","_lowBlood"];
disableserialization;
_unit = _this select 0;
//[_unit,player,_bloodAmount]
_array = _this; //_this select 0;
_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
_rndInfection = (random 15);
_TransfusionInfection = (_rndInfection < 1);
if (_unit == player) then {
if (((count _this) > 1) && {(typeName (_this select 1)) == "ARRAY"}) then { //DO NOT TOUCH THE CODE BRACKETS!
_selfTransValues = _this select 1;
r_player_blood = (r_player_blood + (_selfTransValues select 0)) min r_player_bloodTotal;
if ((_selfTransValues select 1) < 0) then {
_TransfusionInfection = false;
} else {
_TransfusionInfection = ((random (_selfTransValues select 1)) < 1);
_timer = diag_tickTime;
r_doLoop = true;
r_interrupt = false;
if (_amount < 0) exitWith { /* someone is trying to kill the player */ };
//Start the loop to mimic the transfusion to cut back on issues flooding the server
while {r_doLoop} do {
if ((diag_tickTime - _timer) >= 1) then {
_timer = diag_tickTime;
//Infection chance
_rndInfection = (random 20);
_TransfusionInfection = (_rndInfection < 0.3);
//Mimic the transfer of the blood (cut out the server)
if (_amount > 0) then {
_amount = _amount - 500;
};
cutText [localize "str_actions_medical_transfusion_start", "PLAIN DOWN"];
//Make sure the unit is a player and update stats based on whats being sent (should mimic 500 units of blood being sent)
if (_unit == player) then {
if ((r_player_blood + 500) >= r_player_bloodTotal) then {
r_player_blood = r_player_bloodTotal;
player setVariable["USEC_BloodQty",r_player_bloodTotal,true];
} else {
r_player_blood = r_player_blood + 500;
player setVariable["USEC_BloodQty",r_player_blood,true];
};
if (((r_player_blood / r_player_bloodTotal) >= 0.35) and (r_player_lowblood)) then {
r_player_lowblood = false;
player setVariable["USEC_lowBlood",false,true];
};
if (_TransfusionInfection) then {
r_player_infected = true;
player setVariable["USEC_infected",true,true];
};
//Ensure Control is visible
_display = uiNamespace getVariable 'DAYZ_GUI_display';
_control = _display displayCtrl 1300;
_control ctrlShow true;
};
} else {
r_player_blood = r_player_bloodTotal;
};
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;
if (_TransfusionInfection) then {
r_player_infected = true;
player setVariable["USEC_infected",true,true];
};
//Ensure Control is visible
_display = uiNamespace getVariable 'DAYZ_GUI_display';
_control = _display displayCtrl 1300;
_control ctrlShow true;
//If the players blood is equals too or aboue 12000 stop or if the blood mimic amount reaches 0 end the loop.
_blood = _unit getVariable ["USEC_BloodQty", 0];
player setVariable["USEC_BloodQty",r_player_blood,true];
};
//diag_log format["Player Blood %1 - %2, - %3, - %4",_blood,_unit,_medic,(_unit getVariable "USEC_BloodQty")];
if (_blood >= r_player_bloodTotal or _amount == 0) then {
cutText [localize "str_actions_medical_transfusion_successful", "PLAIN DOWN"];
r_doLoop = false;
};
if (r_interrupt) then {
cutText [localize "str_actions_medical_transfusion_interrupted", "PLAIN DOWN"];
r_doLoop = false;
};
//Rerun the loop
sleep 1;
};

View File

@@ -1,6 +1,4 @@
// animHealed.sqf
private ["_array","_unit","_medic","_item"];
_array = _this; //_this select 0;
_unit = _array select 0;
_medic = _array select 1;

View File

@@ -1,6 +1,5 @@
//noAnim.sqf
private ["_unit"];
_unit = _this select 0;
_unit switchMove "";

View File

@@ -1,9 +1,8 @@
// noDamage.sqf
private ["_unit"];
_unit = _this select 0;
_unit setCaptive 3;
_unit switchMove "AmovPpneMstpSnonWnonDnon_healed";
_unit allowDamage false;
uiSleep 0.01;
_unit switchMove "AmovPpneMstpSnonWnonDnon_healed";
_unit allowDamage false;
sleep 0.01;

View File

@@ -1,6 +1,5 @@
// pickUp.sqf
private ["_unit"];
_unit = _this select 0;
_unit switchMove "acinpknlmstpsraswrfldnon_acinpercmrunsraswrfldnon";

View File

@@ -1,6 +1,6 @@
// rolltoback.sqf
private ["_unit"];
_unit = _this select 0;
_unit switchMove "ainjppnemstpsnonwrfldnon_rolltoback";
_unit switchMove "ainjppnemstpsnonwrfldnon_rolltoback";

View File

@@ -1,6 +1,6 @@
// rolltofront.sqf
private ["_unit"];
_unit = _this select 0;
_unit switchMove "ainjppnemstpsnonwrfldnon_rolltofront";
_unit switchMove "ainjppnemstpsnonwrfldnon_rolltofront";

View File

@@ -1,6 +1,5 @@
// set180.sqf
//set180.sqf
private ["_dragee"];
_dragee = _this select 0;
_dragee setDir 180;
_dragee setDir 180;

View File

@@ -1,56 +0,0 @@
private ["_started","_finished","_animState","_isMedic","_num_removed","_unit","_lastused","_timeout"];
if (!DZE_SelfTransfuse) exitWith {};
_unit = player;
_lastused = selfTransfusionTime;
_timeout = (DZE_selfTransfuse_Values select 2);
if ((round(time - _lastused)) <= _timeout) exitWith {cutText [format[(localize "str_actions_medical_18"),(_timeout - (round(time - _lastused)))] , "PLAIN DOWN"]};
call fnc_usec_medic_removeActions;
r_action = false;
if (vehicle player == player) then {
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;
};
if (vehicle player != player) then {
uiSleep 6;
r_doLoop = false;
_finished = true;
};
uiSleep 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, DZE_selfTransfuse_Values] call player_medTransfuse;
};
} else {
r_interrupt = false;
player switchMove "";
player playActionNow "stop";
};

View File

@@ -1,3 +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"];
// bleed.sqf
_unit = _this select 0;
@@ -9,7 +10,7 @@ _injured = _unit getVariable ["USEC_injured", false];
_inPain = _unit getVariable ["USEC_inPain", false];
//_lastused = _unit getVariable ["LastTransfusion", time];
_lastused = selfTransfusionTime;
_timeout = (DZE_selfTransfuse_Values select 2);
_timeout = DZE_selfTransfuse_Values select 2;
if ((round(time - _lastused)) <= _timeout) exitWith {cutText [format[(localize "str_actions_medical_18"),(_timeout - (round(time - _lastused)))] , "PLAIN DOWN"]};
call gear_ui_init;
@@ -23,6 +24,7 @@ _wholeBag = false;
_bagFound = false;
_BBneeded = false;
_forceClose = false;
_TransfusionInfection = false;
if (_blood <= 4000) then {
@@ -39,8 +41,9 @@ if (_rh) then {_rhVal = "POS";} else {_rhVal = "NEG";};
//No subs for whole blood :(
_bloodBagWholeNeeded = "wholeBloodBag" + _bloodType + _rhVal;
_haswholebag = _bloodBagWholeNeeded in magazines player;
_hasUniversal = "ItemBloodbag" in magazines player;
if (_haswholebag) then {
if (_haswholebag or (!DZE_UseBloodTypes && _hasUniversal)) then {
_wholeBag = true;
} else {
_badBag = true;
@@ -69,7 +72,7 @@ while {r_doLoop and (_i < 12)} do {
if (_isMedic and !_started) then {
closeDialog 0;
//diag_log format ["TRANSFUSION: starting blood transfusion (%1 > %2)", name player, name _unit];
diag_log format ["TRANSFUSION: starting blood transfusion (%1 > %2)", name player, name _unit];
if (_badBag) then {
for "_r" from 0 to 15 do {
_bagToRemove = _bagUsed;
@@ -81,7 +84,7 @@ while {r_doLoop and (_i < 12)} do {
};
};
} else {
if (_wholeBag) then {_bagToRemove = _bloodBagWholeNeeded; };
if (_wholeBag) then { _bagToRemove = if (!DZE_UseBloodTypes) then {"ItemBloodbag"} else {_bloodBagWholeNeeded}; };
if (_bagToRemove in magazines player) then { _bagFound = true; };
};
if (!_bagFound) then {_forceClose = true;} else { player removeMagazine _bagToRemove;};
@@ -101,7 +104,12 @@ while {r_doLoop and (_i < 12)} do {
r_player_blood = r_player_blood + 100 + _randomamount;
} else {
_randomamount = round(random 200);
r_player_blood = r_player_blood + 800 + _randomamount;
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 (DZE_selfTransfuse_Values select 1)) < 1)};
} else {
r_player_blood = r_player_blood + 800 + _randomamount;
};
};
//PVDZ_send = [_unit,"Transfuse",[_unit,player,1000]];
@@ -122,19 +130,19 @@ while {r_doLoop and (_i < 12)} do {
_blood = _unit getVariable ["USEC_BloodQty", 0];
if (((_blood >= r_player_bloodTotal) and !_badBag and _bagFound) or (_i == 12)) then {
//diag_log format ["TRANSFUSION: completed blood transfusion successfully (_i = %1)", _i];
diag_log format ["TRANSFUSION: completed blood transfusion successfully (_i = %1)", _i];
selfTransfusionTime = time;
[_unit, DZE_selfTransfuse_Values] call player_medTransfuse;
if (_TransfusionInfection) then {r_player_infected = true; player setVariable["USEC_infected",true,true];};
cutText [localize "str_actions_medical_transfusion_successful", "PLAIN DOWN"];
[player,_unit,"loc",rTITLETEXT,localize "str_actions_medical_transfusion_successful","PLAIN DOWN"] call RE;
[player,25] call player_humanityChange;
r_doLoop = false;
};
_isClose = ((player distance _unit) < ((sizeOf typeOf _unit) / 2));
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"];
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;
r_doLoop = false;
};

View File

@@ -371,83 +371,4 @@ fnc_usec_damageBleed = {
deleteVehicle _source;
deleteVehicle _point;
};
//LEGACY BELOW HERE, LEFT IN FOR SCRIPTS THAT MAY REQUIRE THESE FUNCTIONS
fnc_usec_damageType = {
private["_damage","_ammo","_type"];
_damage = _this select 0;
_ammo = _this select 1;
_type = 0;
if ((_ammo isKindof "Grenade") || (_ammo isKindof "ShellBase") || (_ammo isKindof "TimeBombCore") || (_ammo isKindof "BombCore") || (_ammo isKindof "MissileCore") || (_ammo isKindof "RocketCore") || (_ammo isKindof "FuelExplosion") || (_ammo isKindof "GrenadeBase")) then {
_type = 1;
};
if ((_ammo isKindof "B_127x107_Ball") || (_ammo isKindof "B_127x99_Ball")) then {
_type = 2;
};
if (_ammo isKindof "Melee") then {
_type = 3;
};
_type;
};
fnc_usec_recoverUncons = {
player setVariable ["NORRN_unconscious",false,true];
player setVariable ["unconsciousTime",0,true];
player setVariable ["USEC_isCardiac",false,true];
// player setVariable["medForceUpdate",true,true];
r_player_unconscious = false;
r_player_cardiac = false;
r_player_handler1 = false;
uiSleep 1;
disableUserInput false;
if (vehicle player == player) then {
[objNull,player,rSwitchMove,"AinjPpneMstpSnonWnonDnon"] call RE;
player switchMove "AinjPpneMstpSnonWnonDnon";
player playMoveNow "AmovPpneMstpSnonWnonDnon_healed";
};
};
fnc_med_publicBlood = {
while {(r_player_injured || r_player_infected) && r_player_blood > 0} do {
player setVariable["USEC_BloodQty",r_player_blood,true];
player setVariable["medForceUpdate",true];
uiSleep 5;
};
};
fnc_usec_playerBleed = {
private ["_bleedTime","_bleedPerSec","_total","_bTime","_myBleedTime","_id"];
_bleedTime = 400; //seconds
_total = r_player_bloodTotal;
r_player_injured = true;
_myBleedTime = (random 300) + 30;
_bTime = 0;
while {r_player_injured} do {}
_bleedPerSec = 30;
// If kneeling || crawling reduce bleeding
if (dayz_isKneeling && !r_player_unconscious) then{
_bleedPerSec = 15;
};
if (dayz_isCrawling && !r_player_unconscious) then{
_bleedPerSec = 7.5;
};
//bleed out
if (r_player_blood > 0) then {
r_player_blood = r_player_blood - _bleedPerSec;
};
_bTime = _bTime + 1;
if (_bTime > _myBleedTime) then {
r_player_injured = false;
_id = [player,player] execVM "\z\addons\dayz_code\medical\publicEH\medBandaged.sqf";
dayz_sourceBleeding = objNull;
{player setVariable[_x,false,true];} count USEC_woundHit;
player setVariable ["USEC_injured",false,true];
};
uiSleep 1;
};
};

View File

@@ -108,7 +108,7 @@ while {r_doLoop} do {
if (_isMedic and !_started) then {
closeDialog 0;
//diag_log format ["TRANSFUSION: starting blood transfusion (%1 > %2)", name player, name _unit];
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
@@ -188,7 +188,7 @@ while {r_doLoop} do {
_blood = _unit getVariable ["USEC_BloodQty", 0];
if (_blood >= r_player_bloodTotal or _bloodAmount == 0) then {
//diag_log format ["TRANSFUSION: completed blood transfusion successfully (_i = %1)", _i];
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;
@@ -199,7 +199,7 @@ while {r_doLoop} do {
_isClose = ((player distance _unit) < ((sizeOf typeOf _unit) / 2));
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];
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"];
//see Note 1
//[player,_unit,"loc",rTITLETEXT,localize "str_actions_medical_transfusion_interrupted","PLAIN DOWN"] call RE;