mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2026-02-09 01:32:53 +03:00
Combine player_fillWater and player_drinkWater to one function
This commit is contained in:
@@ -1,50 +0,0 @@
|
||||
private ["_canFill","_onLadder","_chance","_posASL","_posATL"];
|
||||
|
||||
call gear_ui_init;
|
||||
closeDialog 0;
|
||||
|
||||
_onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1;
|
||||
if (_onLadder) exitWith {localize "str_player_21" call dayz_rollingMessages;};
|
||||
|
||||
_posASL = getPosASL player;
|
||||
_posATL = ASLtoATL _posASL;
|
||||
|
||||
_canFill = switch true do {
|
||||
//Return: [nearWaterHole, isPond]
|
||||
case (count nearestObjects [_posATL,["Land_pumpa","Land_Barrel_water"],4] > 0): {[true,false]}; //"Land_water_tank" has no spout or opening, doesn't make sense to include
|
||||
case (toLower worldName == "chernarus"): {(call fn_nearWaterHole)};
|
||||
//Slow searches for maps without waterHoleProxy objects added yet
|
||||
case ({["_well",str _x] call fnc_inString} count nearestObjects [_posATL,[],4] > 0): {[true,false]};
|
||||
case ({["pond",str _x] call fnc_inString && {_posASL select 2 < ((getPosASL _x) select 2)}} count nearestObjects [player,[],50] > 0): {[true,true]};
|
||||
default {[false,false]};
|
||||
};
|
||||
|
||||
if (_canFill select 0) then {
|
||||
if (_this in boil_tin_cans) then {
|
||||
_chance = 0.06;
|
||||
["FoodDrink",0,[0,0,300,0]] call dayz_NutritionSystem; //[Energy,food,water,temp]
|
||||
} else {
|
||||
_chance = 0.03;
|
||||
["FoodDrink",0,[0,0,150,0]] call dayz_NutritionSystem; //[Energy,food,water,temp]
|
||||
};
|
||||
|
||||
if (!dayz_isSwimming) then {
|
||||
player playActionNow "PutDown";
|
||||
};
|
||||
|
||||
[player,"drink",0,false,5] call dayz_zombieSpeak;
|
||||
[player,10,true,_posATL] call player_alertZombies;
|
||||
|
||||
//Check if water source is infected only for ponds
|
||||
if (dayz_infectiousWaterholes && {_canFill select 1} && {count nearestObjects [_posATL,["Body","Body1","Body2","Mass_grave"],50] > 0}) then {
|
||||
r_player_infected = true;
|
||||
} else {
|
||||
if ([_chance] call fn_chance) then {
|
||||
r_player_infected = true;
|
||||
};
|
||||
};
|
||||
|
||||
localize "str_drinkwithhands" call dayz_rollingMessages;
|
||||
} else {
|
||||
localize "str_player_32" call dayz_rollingMessages;
|
||||
};
|
||||
@@ -1,6 +1,14 @@
|
||||
#include "\z\addons\dayz_code\util\player.hpp"
|
||||
|
||||
private ["_canFill","_water","_filled","_posASL","_posATL"];
|
||||
private ["_canFill","_water","_filled","_posASL","_posATL","_chance","_container","_drinking","_message","_recover","_wells"];
|
||||
|
||||
if (typeName _this == "ARRAY") then {
|
||||
_container = if (count _this == 1) then {_this select 0} else {_this select 3};
|
||||
_drinking = true;
|
||||
} else {
|
||||
_container = _this;
|
||||
_drinking = false;
|
||||
};
|
||||
|
||||
call gear_ui_init;
|
||||
closeDialog 0;
|
||||
@@ -9,10 +17,12 @@ if Player_IsOnLadder() exitWith { (localize "str_player_21") call dayz_rollingMe
|
||||
|
||||
_posASL = getPosASL player;
|
||||
_posATL = ASLtoATL _posASL;
|
||||
//"Land_water_tank" has no spout or opening, doesn't make sense to include
|
||||
_wells = ["Land_pumpa","Land_Barrel_water","Land_Misc_Well_C_EP1","Land_Misc_Well_L_EP1","land_smd_water_pump"];
|
||||
|
||||
_canFill = switch true do {
|
||||
//Return: [nearWaterHole, isPond]
|
||||
case (count nearestObjects [_posATL,["Land_pumpa","Land_Barrel_water"],4] > 0): {[true,false]}; //"Land_water_tank" has no spout or opening, doesn't make sense to include
|
||||
case (count nearestObjects [_posATL,_wells,4] > 0): {[true,false]};
|
||||
case (toLower worldName == "chernarus"): {(call fn_nearWaterHole)};
|
||||
//Slow searches for maps without waterHoleProxy objects added yet
|
||||
case ({["_well",str _x] call fnc_inString} count nearestObjects [_posATL,[],4] > 0): {[true,false]};
|
||||
@@ -21,37 +31,59 @@ _canFill = switch true do {
|
||||
};
|
||||
|
||||
if !(_canFill select 0) exitWith {
|
||||
localize "str_player_20" call dayz_rollingMessages;
|
||||
_message = if (_drinking) then {"str_player_32"} else {"str_player_20"};
|
||||
localize _message call dayz_rollingMessages;
|
||||
};
|
||||
|
||||
//Check if water source is infected only for ponds
|
||||
//Check if guaranteed infected (only for ponds)
|
||||
_water = if (dayz_infectiousWaterholes && {_canFill select 1} && {count nearestObjects [_posATL,["Body","Body1","Body2","Mass_grave"],50] > 0}) then {"infected"} else {"safe"};
|
||||
_water = "containerwater" + _water;
|
||||
_filled = 0;
|
||||
|
||||
{
|
||||
if (isText (configFile >> "CfgMagazines" >> _x >> _water)) then
|
||||
{
|
||||
if (_filled < 1) then
|
||||
{
|
||||
if (!dayz_isSwimming) then
|
||||
{
|
||||
player playActionNow "PutDown";
|
||||
};
|
||||
};
|
||||
|
||||
_filled = _filled + 1;
|
||||
|
||||
player removeMagazine _x;
|
||||
player addMagazine getText (configFile >> "CfgMagazines" >> _x >> _water);
|
||||
};
|
||||
}
|
||||
foreach magazines player;
|
||||
|
||||
if (_filled > 0) then {
|
||||
[player, "fillwater", 0, false, 5] call dayz_zombieSpeak;
|
||||
[player, 5, true, _posATL] call player_alertZombies;
|
||||
format [localize "str_player_01", _filled] call dayz_rollingMessages;
|
||||
if (_container == "hands") then {
|
||||
_chance = 0.03;
|
||||
_recover = 150;
|
||||
} else {
|
||||
localize "str_player_02" call dayz_rollingMessages;
|
||||
_chance = 0.06;
|
||||
_recover = 300;
|
||||
};
|
||||
|
||||
//Additional chance to be infected (only for ponds)
|
||||
if (_canFill select 1 && {[_chance] call fn_chance}) then {
|
||||
_water = "containerwaterinfected";
|
||||
};
|
||||
|
||||
if (!dayz_isSwimming) then {
|
||||
player playActionNow "PutDown";
|
||||
};
|
||||
|
||||
if (_drinking) then {
|
||||
["FoodDrink",0,[0,0,_recover,0]] call dayz_NutritionSystem; //[Energy,food,water,temp]
|
||||
[player,"drink",0,false,5] call dayz_zombieSpeak;
|
||||
[player,10,true,_posATL] call player_alertZombies;
|
||||
|
||||
if (_water == "containerwaterinfected") then {
|
||||
r_player_infected = true;
|
||||
};
|
||||
|
||||
localize "str_drinkwithhands" call dayz_rollingMessages;
|
||||
} else {
|
||||
{
|
||||
if (isText (configFile >> "CfgMagazines" >> _x >> _water)) then
|
||||
{
|
||||
_filled = _filled + 1;
|
||||
|
||||
player removeMagazine _x;
|
||||
player addMagazine getText (configFile >> "CfgMagazines" >> _x >> _water);
|
||||
};
|
||||
}
|
||||
foreach magazines player;
|
||||
|
||||
if (_filled > 0) then {
|
||||
[player, "fillwater", 0, false, 5] call dayz_zombieSpeak;
|
||||
[player, 5, true, _posATL] call player_alertZombies;
|
||||
format [localize "str_player_01", _filled] call dayz_rollingMessages;
|
||||
} else {
|
||||
localize "str_player_02" call dayz_rollingMessages;
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user