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

@@ -39,6 +39,7 @@
[FIXED] Filling fuel barrels takes the correct amount from fuel tanks now (210 instead of 40 litres). #1834 @schwanzkopfhegel @oiad [FIXED] Filling fuel barrels takes the correct amount from fuel tanks now (210 instead of 40 litres). #1834 @schwanzkopfhegel @oiad
[FIXED] Base objects duplicating when using "take ownership" on plot pole. #1811 @BNG-Lance @Clanwarfare [FIXED] Base objects duplicating when using "take ownership" on plot pole. #1811 @BNG-Lance @Clanwarfare
[FIXED] Unable to sell some launchers like Javelin and Stinger which have the same classname for ammo and weapon. #1844 @ndavalos [FIXED] Unable to sell some launchers like Javelin and Stinger which have the same classname for ammo and weapon. #1844 @ndavalos
[FIXED] Long search delay when filling water bottles, drinking from hands and drinking from empty cans on Chernarus. #1835 @schwanzkopfhegel
[NOTE] The fixes below are included in the 1.0.6 Build C server package released December 29th, 2016 (http://dayzepoch.com/a2dayzepoch.php) [NOTE] The fixes below are included in the 1.0.6 Build C server package released December 29th, 2016 (http://dayzepoch.com/a2dayzepoch.php)
[FIXED] Hive child 309 errors that resulted in broken saving of newly built storage object inventory. @icomrade [FIXED] Hive child 309 errors that resulted in broken saving of newly built storage object inventory. @icomrade

View File

@@ -1,19 +0,0 @@
class Land_pumpa: House
{
class UserActions
{
class Drink
{
displayName = $STR_ACTIONS_DRINK2;
displayNameDefault = $STR_ACTIONS_DRINK2;
priority = 3;
radius = 3;
position = "";
showWindow = 1;
onlyForPlayer = 1;
shortcut = "";
condition = "(['Drink',this] call userActionConditions)";
statement = "'hands' spawn player_drinkWater;";
};
};
};

View File

@@ -0,0 +1,39 @@
class Land_pumpa: House
{
class UserActions
{
class Drink
{
displayName = $STR_ACTIONS_DRINK2;
displayNameDefault = $STR_ACTIONS_DRINK2;
priority = 3;
radius = 3;
position = "";
showWindow = 1;
onlyForPlayer = 1;
shortcut = "";
condition = "(['Drink',this] call userActionConditions)";
statement = "'Land_pumpa' spawn player_drinkWater;";
};
};
};
class Land_Barrel_water: Thing
{
class UserActions
{
class Drink
{
displayName = $STR_ACTIONS_DRINK2;
displayNameDefault = $STR_ACTIONS_DRINK2;
priority = 3;
radius = 3;
position = "";
showWindow = 1;
onlyForPlayer = 1;
shortcut = "";
condition = "(['Drink',this] call userActionConditions)";
statement = "'Land_Barrel_water' spawn player_drinkWater;";
};
};
};

View File

@@ -457,6 +457,7 @@ class CfgVehicles {
class SpawnableWreck : House {}; class SpawnableWreck : House {};
class Strategic; class Strategic;
class NonStrategic; class NonStrategic;
class Thing;
// class Land_Fire; // class Land_Fire;
class BuiltItems; class BuiltItems;
class Building; class Building;
@@ -578,7 +579,7 @@ class CfgVehicles {
#include "Buildings\Land_telek1.hpp" #include "Buildings\Land_telek1.hpp"
#include "Buildings\Land_VASICore.hpp" #include "Buildings\Land_VASICore.hpp"
#include "Buildings\Land_Vysilac_FM.hpp" #include "Buildings\Land_Vysilac_FM.hpp"
#include "Buildings\Land_pumpa.hpp" #include "Buildings\WaterSources.hpp"
//Duplicates of Epoch items in DZE\Prop_Defs.hpp //Duplicates of Epoch items in DZE\Prop_Defs.hpp
//#include "CamoNetting.hpp" //#include "CamoNetting.hpp"

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; call gear_ui_init;
closeDialog 0; 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; _onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1;
if (_onLadder) exitWith {localize "str_player_21" call dayz_rollingMessages;}; if (_onLadder) exitWith {localize "str_player_21" call dayz_rollingMessages;};
_itemorignal = _this; _posASL = getPosASL player;
//diag_log(str(_itemorignal)); _posATL = ASLtoATL _posASL;
if (!dayz_isSwimming) then { _canFill = switch true do {
player playActionNow "PutDown"; //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 { if (_canFill select 0) then {
_objectsWell = nearestObjects [_playerPos, [], 4]; if (_this in boil_tin_cans) then {
{
//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 {
_chance = 0.06; _chance = 0.06;
["FoodDrink",0,[0,0,300,0]] call dayz_NutritionSystem; //[Energy,food,water,temp] ["FoodDrink",0,[0,0,300,0]] call dayz_NutritionSystem; //[Energy,food,water,temp]
} else { } else {
@@ -63,20 +28,22 @@ if (_canFill) then {
["FoodDrink",0,[0,0,150,0]] call dayz_NutritionSystem; //[Energy,food,water,temp] ["FoodDrink",0,[0,0,150,0]] call dayz_NutritionSystem; //[Energy,food,water,temp]
}; };
[player,"drink",0,false,5] call dayz_zombieSpeak; if (!dayz_isSwimming) then {
[player,10,true,(getPosATL player)] call player_alertZombies; player playActionNow "PutDown";
};
if(!_isWell) then { [player,"drink",0,false,5] call dayz_zombieSpeak;
if (_isInfected) then { [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; 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; localize "str_drinkwithhands" call dayz_rollingMessages;
} else { } else {
localize "str_player_32" call dayz_rollingMessages; localize "str_player_32" call dayz_rollingMessages;

View File

@@ -1,67 +1,31 @@
#include "\z\addons\dayz_code\util\player.hpp" #include "\z\addons\dayz_code\util\player.hpp"
private ["_water","_filled","_canFill","_infected","_well"]; private ["_canFill","_water","_filled","_posASL","_posATL"];
call gear_ui_init; call gear_ui_init;
closeDialog 0; closeDialog 0;
if Player_IsOnLadder() exitWith { (localize "str_player_21") call dayz_rollingMessages; }; if Player_IsOnLadder() exitWith { (localize "str_player_21") call dayz_rollingMessages; };
_water = call _posASL = getPosASL player;
{ _posATL = ASLtoATL _posASL;
private ["_canFill", "_infected"];
_canFill = switch true do {
_canFill = count nearestObjects [player, ["Land_pumpa","Land_water_tank","Land_Barrel_water"], 4] > 0; //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
if (_canFill) exitWith { "safe" }; case (toLower worldName == "chernarus"): {(call fn_nearWaterHole)};
//Slow searches for maps without waterHoleProxy objects added yet
//Check for wells 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]};
if (["_well", str _x, false] call fnc_inString) exitWith default {[false,false]};
{
_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" };
""
}; };
if (isNil "_water") exitWith if !(_canFill select 0) exitWith {
{ localize "str_player_20" call dayz_rollingMessages;
(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; _water = "containerwater" + _water;
_filled = 0; _filled = 0;
@@ -74,9 +38,6 @@ _filled = 0;
{ {
player playActionNow "PutDown"; player playActionNow "PutDown";
}; };
[player, "fillwater", 0, false, 5] call dayz_zombieSpeak;
[player, 5, true, getPosATL player] call player_alertZombies;
}; };
_filled = _filled + 1; _filled = _filled + 1;
@@ -87,6 +48,10 @@ _filled = 0;
} }
foreach magazines player; foreach magazines player;
if (_filled > 0) if (_filled > 0) then {
then { (format [localize "str_player_01", _filled]) call dayz_rollingMessages; } [player, "fillwater", 0, false, 5] call dayz_zombieSpeak;
else { (localize "str_player_02") call dayz_rollingMessages; }; [player, 5, true, _posATL] call player_alertZombies;
format [localize "str_player_01", _filled] call dayz_rollingMessages;
} else {
localize "str_player_02" call dayz_rollingMessages;
};

View File

@@ -1,6 +1,6 @@
private ["_bb","_dir","_nearWaterHole","_w2m"]; private ["_bb","_dir","_nearWaterHole","_pond","_well","_w2m"];
_nearWaterHole = false; _nearWaterHole = [false,false];
{ {
{ {
@@ -12,13 +12,15 @@ _nearWaterHole = false;
_dir = _dir - 360; _dir = _dir - 360;
}; };
if ((abs _dir < 45 && {_x distance player < 2.22}) // wells, kasna, pumpa _well = (abs _dir < 45 && {_x distance player < 2.22}); // wells, kasna, pumpa
or {("" == typeOf _x && (_w2m select 2 < 0.05)) && {(abs(_w2m select 0) < (_bb select 0)) && (abs(_w2m select 1) < (_bb select 1))}}) exitWith { // ponds _pond = (("" == typeOf _x && (_w2m select 2 < 0.05)) && {(abs(_w2m select 0) < (_bb select 0)) && (abs(_w2m select 1) < (_bb select 1))});
_nearWaterHole = true;
if (_well or _pond) exitWith {
_nearWaterHole = [true,_pond];
}; };
} count (nearestObjects [_x, [], 1]); } count (nearestObjects [_x, [], 1]);
if (_nearWaterHole) exitWith {}; if (_nearWaterHole select 0) exitWith {};
} forEach (nearestObjects [player, ["waterHoleProxy"], 50]); } forEach (nearestObjects [player, ["waterHoleProxy"], 50]);
_nearWaterHole _nearWaterHole

View File

@@ -99,9 +99,9 @@ if ((_primaryWeapon in Dayz_fishingItems) && {!dayz_fishingInprogress} && {_inVe
/* /*
//FPS killer. Moved to CfgVehicles for Land_pumpa //FPS killer. Moved to CfgVehicles for Land_pumpa
if (_canDo && !_inVehicle && !dayz_isSwimming && (call fn_nearWaterHole)) then { if (_canDo && !_inVehicle && !dayz_isSwimming && ((call fn_nearWaterHole) select 0)) then {
if (s_player_Drinkfromhands < 0) then { if (s_player_Drinkfromhands < 0) then {
s_player_Drinkfromhands = player addAction [localize "STR_ACTIONS_DRINK2", "\z\addons\dayz_code\actions\player_drinkWater.sqf",player, 0.5, false, true]; s_player_Drinkfromhands = player addAction [localize "STR_ACTIONS_DRINK2", "\z\addons\dayz_code\actions\player_drinkWater.sqf","hands", 0.5, false, true];
}; };
} else { } else {
if (s_player_Drinkfromhands >= 0) then { if (s_player_Drinkfromhands >= 0) then {

View File

@@ -34,7 +34,7 @@ if (isNil "keyboard_keys") then {
dayz_autoRunThread = [] spawn { dayz_autoRunThread = [] spawn {
while {dayz_autoRun} do { while {dayz_autoRun} do {
// SurfaceIsWater does not work for ponds // SurfaceIsWater does not work for ponds
if (player != vehicle player or (surfaceIsWater getPosASL player) or (call fn_nearWaterHole) or r_fracture_legs) exitWith { if (player != vehicle player or (surfaceIsWater getPosASL player) or ((call fn_nearWaterHole) select 0) or r_fracture_legs) exitWith {
call dayz_autoRunOff; call dayz_autoRunOff;
}; };
player playAction "FastF"; player playAction "FastF";

View File

@@ -51,4 +51,4 @@
5 sideLogic !"{ \nBIS_MPF_ServerInitDone = true;\ncreatecenter sidelogic;\nBIS_MPF_dummygroup = createGroup sideLogic;" !"{ \nBIS_MPF_ServerInitDone = true;\ncreatecenter sidelogic;\n\n\nBIS_MPF_dummygroup = createGroup sideLogic;" 5 sideLogic !"{ \nBIS_MPF_ServerInitDone = true;\ncreatecenter sidelogic;\nBIS_MPF_dummygroup = createGroup sideLogic;" !"{ \nBIS_MPF_ServerInitDone = true;\ncreatecenter sidelogic;\n\n\nBIS_MPF_dummygroup = createGroup sideLogic;"
5 switchCamera !"\"switchCamera\", \n\n\n\"fadeMusic\"," !="rswitchCamera = 'switchCamera'" !"rswitchCameracode" !"\"switchCamera\", \"taskHint\"," !="player switchCamera (Dayz_constructionContext select 2);" !="player switchCamera _currentCamera;" 5 switchCamera !"\"switchCamera\", \n\n\n\"fadeMusic\"," !="rswitchCamera = 'switchCamera'" !"rswitchCameracode" !"\"switchCamera\", \"taskHint\"," !="player switchCamera (Dayz_constructionContext select 2);" !="player switchCamera _currentCamera;"
5 toString !="_skinToModel = toString (_finalArray);" !="{_textArrayTemp = _textArrayTemp + [tostring [_x]]} foreach _line;" !="_cmpt = toString _cmpt;" !="_objName = toLower(toString(_objName));" !"if (toString _hayArr != _needle) then {" !="_type = toString _typeA;" !="_anim4 = toString _anim4;" !"{(count _stance>17)}) then {toString [_stance select 17]}" !="lbAdd [7102, if (typeName _name == \"ARRAY\") then {toString _name} else {_name}];" !="lbAdd [7002, if (typeName _name == \"ARRAY\") then {toString _name} else {_name}];" !"if (isnil 'BIS_fnc_timeToString' || false) then {" 5 toString !="_skinToModel = toString (_finalArray);" !="{_textArrayTemp = _textArrayTemp + [tostring [_x]]} foreach _line;" !="_cmpt = toString _cmpt;" !="_objName = toLower(toString(_objName));" !"if (toString _hayArr != _needle) then {" !="_type = toString _typeA;" !="_anim4 = toString _anim4;" !"{(count _stance>17)}) then {toString [_stance select 17]}" !="lbAdd [7102, if (typeName _name == \"ARRAY\") then {toString _name} else {_name}];" !="lbAdd [7002, if (typeName _name == \"ARRAY\") then {toString _name} else {_name}];" !"if (isnil 'BIS_fnc_timeToString' || false) then {"
5 worldTo !"ect 1;\n_inside = false;\n_offset = 1; \n\n_relPos = _building worldToModel _point;\n_boundingBox = boundingBox _building;\n\n_min = _" !"\n\n_new = getPosATL _obj;\n\nif (_isPlayer) then {\n_x = _pos worldToModel _new;\n_dir = _dir + (if ((_x select 1)==0) then { 0 } else" !"_pondPos = (_x worldToModel _playerPos) select 2;\n" !"ts [_new, [], 100];\n{\nif (((typeOf(_x) == \"\")\nAND {((((_x worldToModel _new) select 2) < 0))\nAND {([_x, _new] call _checkPerimete" !"t = _this select 1;\n_inside = false;\n\n_relPos = _building worldToModel _point;\n_boundingBox = boundingBox _building;\n\n_min = _bou" !"fascl,getDir _x,\"\",1];if(_fash==_forEachIndex)then{_fapos2D=worldtoscreen _fapos;if(count _fapos2D>=2)then{_fasp ctrlsetposition" !"_pondPos = (_x worldToModel _playerPos) select 2;\nif (_pondPos < 0) then {\n_canFill" !"_w2m = _x worldToModel (getPosATL player);\n_bb = (boundingbox _x) select 1;" !"_bn == 1) then { \n_bb = boundingBox _o;\n_h = _offset + ((_o worldToModel (getPosATL _o)) select 2);\n_p = [ (_bb select 0) select" !"if (_distance > 1 && _distance < 2500) then {\n_pos set [2,(_pos select 2) + 1.5];\n_screen = worldToScreen _pos;\n_text = composeText [image" 5 worldTo !"ect 1;\n_inside = false;\n_offset = 1; \n\n_relPos = _building worldToModel _point;\n_boundingBox = boundingBox _building;\n\n_min = _" !"\n\n_new = getPosATL _obj;\n\nif (_isPlayer) then {\n_x = _pos worldToModel _new;\n_dir = _dir + (if ((_x select 1)==0) then { 0 } else" !"ts [_new, [], 100];\n{\nif (((typeOf(_x) == \"\")\nAND {((((_x worldToModel _new) select 2) < 0))\nAND {([_x, _new] call _checkPerimete" !"t = _this select 1;\n_inside = false;\n\n_relPos = _building worldToModel _point;\n_boundingBox = boundingBox _building;\n\n_min = _bou" !"fascl,getDir _x,\"\",1];if(_fash==_forEachIndex)then{_fapos2D=worldtoscreen _fapos;if(count _fapos2D>=2)then{_fasp ctrlsetposition" !"_w2m = _x worldToModel (getPosATL player);\n_bb = (boundingbox _x) select 1;" !"_bn == 1) then { \n_bb = boundingBox _o;\n_h = _offset + ((_o worldToModel (getPosATL _o)) select 2);\n_p = [ (_bb select 0) select" !"if (_distance > 1 && _distance < 2500) then {\n_pos set [2,(_pos select 2) + 1.5];\n_screen = worldToScreen _pos;\n_text = composeText [image"