Use waterHoleProxy in drink water and fill water #1835

The slow searches are needed on other maps until waterHoleProxy objects
are added for them. They need to be added at every pond and
non-"Land_pumpa" well. Right now Chernarus is the only map that has them
placed.

Fixes #1835
Fixes #1841
This commit is contained in:
ebaydayz
2017-01-01 16:55:00 -05:00
parent 30f1827509
commit e4aeee37fd
10 changed files with 102 additions and 146 deletions

View File

@@ -1,61 +1,26 @@
private ["_playerPos","_canFill","_isPond","_isWell","_pondPos","_objectsWell","_onLadder","_hasbottleitem","_config","_item","_text","_objectsPond","_qty","_dis","_sfx","_isInfected","_bodiesNear","_chance","_itemorignal","_well"];
private ["_canFill","_onLadder","_chance","_posASL","_posATL"];
call gear_ui_init;
closeDialog 0;
_item = _this;
_playerPos = getPosATL player;
_canFill = count nearestObjects [_playerPos, ["Land_pumpa","Land_water_tank"], 4] > 0;
_isPond = false;
_isWell = false;
_isInfected = false;
_pondPos = [];
_objectsWell = [];
_onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1;
if (_onLadder) exitWith {localize "str_player_21" call dayz_rollingMessages;};
_itemorignal = _this;
//diag_log(str(_itemorignal));
_posASL = getPosASL player;
_posATL = ASLtoATL _posASL;
if (!dayz_isSwimming) then {
player playActionNow "PutDown";
_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) then {
_objectsWell = nearestObjects [_playerPos, [], 4];
{
//Check for Well
_isWell = ["_well",str(_x),false] call fnc_inString;
if (_isWell) then {_canFill = true};
} forEach _objectsWell;
};
if (!_canFill) then {
_objectsPond = nearestObjects [_playerPos, [], 100];
{
//Check for pond
_isPond = ["pond",str(_x),false] call fnc_inString;
//Check for Dead Bodies
_bodiesNear = ["dead",str(_x),false] call fnc_inString;
if (!_bodiesNear) then {
_bodiesNear = ["massgrave",str(_x),false] call fnc_inString;
};
if (_bodiesNear) then {
_isInfected = true;
};
if (_isPond) then {
_pondPos = (_x worldToModel _playerPos) select 2;
if (_pondPos < 0) then {
_canFill = true;
};
};
} forEach _objectsPond;
};
if (_canFill) then {
_chance = 0.1;
if (_itemorignal in boil_tin_cans) then {
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 {
@@ -63,20 +28,22 @@ if (_canFill) then {
["FoodDrink",0,[0,0,150,0]] call dayz_NutritionSystem; //[Energy,food,water,temp]
};
[player,"drink",0,false,5] call dayz_zombieSpeak;
[player,10,true,(getPosATL player)] call player_alertZombies;
if (!dayz_isSwimming) then {
player playActionNow "PutDown";
};
if(!_isWell) then {
if (_isInfected) then {
[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;
player setVariable["USEC_infected",true,true];
} else {
if ([_chance] call fn_chance) then {
r_player_infected = true;
player setVariable["USEC_infected",true,true];
};
};
};
localize "str_drinkwithhands" call dayz_rollingMessages;
} else {
localize "str_player_32" call dayz_rollingMessages;

View File

@@ -1,67 +1,31 @@
#include "\z\addons\dayz_code\util\player.hpp"
private ["_water","_filled","_canFill","_infected","_well"];
private ["_canFill","_water","_filled","_posASL","_posATL"];
call gear_ui_init;
closeDialog 0;
if Player_IsOnLadder() exitWith { (localize "str_player_21") call dayz_rollingMessages; };
_water = call
{
private ["_canFill", "_infected"];
_canFill = count nearestObjects [player, ["Land_pumpa","Land_water_tank","Land_Barrel_water"], 4] > 0;
if (_canFill) exitWith { "safe" };
//Check for wells
{
if (["_well", str _x, false] call fnc_inString) exitWith
{
_canFill = true;
};
}
foreach nearestObjects [player, [], 4];
if (_canFill) exitWith { "safe" };
_infected = false;
//Check for ponds and corpses
{
if (!_canFill) then
{
if (["pond", str _x, false] call fnc_inString && {((getPosASL player) select 2) < ((GetPosASL _x) select 2)}) then
{
_canFill = true;
};
};
if (!_infected) then
{
if (["dead", str _x, false] call fnc_inString || {["massgrave", str _x, false] call fnc_inString}) then
{
_infected = true;
};
};
if (_canFill && {_infected}) exitWith {};
}
foreach nearestObjects [player, [], 50];
if (!_canFill) exitWith { nil };
if (_infected) exitWith { "infected" };
""
_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 (isNil "_water") exitWith
{
(localize "str_player_20") call dayz_rollingMessages;
if !(_canFill select 0) exitWith {
localize "str_player_20" call dayz_rollingMessages;
};
//Check if water source is 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;
@@ -74,9 +38,6 @@ _filled = 0;
{
player playActionNow "PutDown";
};
[player, "fillwater", 0, false, 5] call dayz_zombieSpeak;
[player, 5, true, getPosATL player] call player_alertZombies;
};
_filled = _filled + 1;
@@ -87,6 +48,10 @@ _filled = 0;
}
foreach magazines player;
if (_filled > 0)
then { (format [localize "str_player_01", _filled]) call dayz_rollingMessages; }
else { (localize "str_player_02") call dayz_rollingMessages; };
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;
};