mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-13 19:52:38 +03:00
Combine player_fillWater and player_drinkWater to one function
This commit is contained in:
@@ -14,7 +14,7 @@ class ItemSodaEmpty : HandGrenade
|
|||||||
class Drink
|
class Drink
|
||||||
{
|
{
|
||||||
text = $STR_ACTIONS_DRINK2;
|
text = $STR_ACTIONS_DRINK2;
|
||||||
script = "spawn player_drinkWater;";
|
script = ";[_id] spawn player_fillWater;";
|
||||||
};
|
};
|
||||||
class Crafting {
|
class Crafting {
|
||||||
text = "Melt into Bars";
|
text = "Melt into Bars";
|
||||||
@@ -43,7 +43,7 @@ class TrashTinCan : HandGrenade
|
|||||||
class Drink
|
class Drink
|
||||||
{
|
{
|
||||||
text = $STR_ACTIONS_DRINK2;
|
text = $STR_ACTIONS_DRINK2;
|
||||||
script = "spawn player_drinkWater;";
|
script = ";[_id] spawn player_fillWater;";
|
||||||
};
|
};
|
||||||
class Crafting {
|
class Crafting {
|
||||||
text = "Melt into Bars";
|
text = "Melt into Bars";
|
||||||
|
|||||||
@@ -1,39 +1,35 @@
|
|||||||
|
#define ACTION_DRINK 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_fillWater;";\
|
||||||
|
};
|
||||||
|
|
||||||
class Land_pumpa: House
|
class Land_pumpa: House
|
||||||
{
|
{
|
||||||
class UserActions
|
class UserActions {ACTION_DRINK};
|
||||||
{
|
};
|
||||||
class Drink
|
|
||||||
{
|
class Land_Misc_Well_C_EP1: House_EP1
|
||||||
displayName = $STR_ACTIONS_DRINK2;
|
{
|
||||||
displayNameDefault = $STR_ACTIONS_DRINK2;
|
class UserActions {ACTION_DRINK};
|
||||||
priority = 3;
|
};
|
||||||
radius = 3;
|
|
||||||
position = "";
|
class Land_Misc_Well_L_EP1: House_EP1
|
||||||
showWindow = 1;
|
{
|
||||||
onlyForPlayer = 1;
|
class UserActions {ACTION_DRINK};
|
||||||
shortcut = "";
|
|
||||||
condition = "(['Drink',this] call userActionConditions)";
|
|
||||||
statement = "'Land_pumpa' spawn player_drinkWater;";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class Land_Barrel_water: Thing
|
class Land_Barrel_water: Thing
|
||||||
{
|
{
|
||||||
class UserActions
|
class UserActions {ACTION_DRINK};
|
||||||
{
|
};
|
||||||
class Drink
|
|
||||||
{
|
#undef ACTION_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;";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@@ -454,6 +454,7 @@ class CfgVehicles {
|
|||||||
{
|
{
|
||||||
class DestructionEffects;
|
class DestructionEffects;
|
||||||
};
|
};
|
||||||
|
class House_EP1;
|
||||||
class SpawnableWreck : House {};
|
class SpawnableWreck : House {};
|
||||||
class Strategic;
|
class Strategic;
|
||||||
class NonStrategic;
|
class NonStrategic;
|
||||||
|
|||||||
@@ -292,8 +292,8 @@ class CfgWeapons
|
|||||||
{
|
{
|
||||||
class Drink
|
class Drink
|
||||||
{
|
{
|
||||||
text = "Drink";
|
text = $STR_ACTIONS_DRINK2;
|
||||||
script = "spawn player_drinkWater;";
|
script = ";[_id] spawn player_fillWater;";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -310,8 +310,8 @@ class CfgWeapons
|
|||||||
{
|
{
|
||||||
class Drink
|
class Drink
|
||||||
{
|
{
|
||||||
text = "Drink";
|
text = $STR_ACTIONS_DRINK2;
|
||||||
script = "spawn player_drinkWater;";
|
script = ";[_id] spawn player_fillWater;";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};*/
|
};*/
|
||||||
|
|||||||
@@ -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"
|
#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;
|
call gear_ui_init;
|
||||||
closeDialog 0;
|
closeDialog 0;
|
||||||
@@ -9,10 +17,12 @@ if Player_IsOnLadder() exitWith { (localize "str_player_21") call dayz_rollingMe
|
|||||||
|
|
||||||
_posASL = getPosASL player;
|
_posASL = getPosASL player;
|
||||||
_posATL = ASLtoATL _posASL;
|
_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 {
|
_canFill = switch true do {
|
||||||
//Return: [nearWaterHole, isPond]
|
//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)};
|
case (toLower worldName == "chernarus"): {(call fn_nearWaterHole)};
|
||||||
//Slow searches for maps without waterHoleProxy objects added yet
|
//Slow searches for maps without waterHoleProxy objects added yet
|
||||||
case ({["_well",str _x] call fnc_inString} count nearestObjects [_posATL,[],4] > 0): {[true,false]};
|
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 {
|
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 = 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;
|
||||||
|
|
||||||
{
|
if (_container == "hands") then {
|
||||||
if (isText (configFile >> "CfgMagazines" >> _x >> _water)) then
|
_chance = 0.03;
|
||||||
{
|
_recover = 150;
|
||||||
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;
|
|
||||||
} else {
|
} 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;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
@@ -98,10 +98,10 @@ if ((_primaryWeapon in Dayz_fishingItems) && {!dayz_fishingInprogress} && {_inVe
|
|||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
//FPS killer. Moved to CfgVehicles for Land_pumpa
|
//FPS killer. Moved to CfgVehicles for wells
|
||||||
if (_canDo && !_inVehicle && !dayz_isSwimming && ((call fn_nearWaterHole) select 0)) 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","hands", 0.5, false, true];
|
s_player_Drinkfromhands = player addAction [localize "STR_ACTIONS_DRINK2", "\z\addons\dayz_code\actions\water_fill.sqf","hands", 0.5, false, true];
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
if (s_player_Drinkfromhands >= 0) then {
|
if (s_player_Drinkfromhands >= 0) then {
|
||||||
|
|||||||
@@ -78,7 +78,6 @@ if (!isDedicated) then {
|
|||||||
player_addtoBack = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\player_addtoBack.sqf";
|
player_addtoBack = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\player_addtoBack.sqf";
|
||||||
player_reloadMag = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\player_reloadMags.sqf";
|
player_reloadMag = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\player_reloadMags.sqf";
|
||||||
player_createstash = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\player_createstash.sqf";
|
player_createstash = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\player_createstash.sqf";
|
||||||
player_drinkWater = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\player_drinkWater.sqf";
|
|
||||||
player_consume = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\player_consume.sqf";
|
player_consume = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\player_consume.sqf";
|
||||||
player_emptyContainer = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\player_emptyContainer.sqf";
|
player_emptyContainer = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\player_emptyContainer.sqf";
|
||||||
player_useMeds = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\player_useMeds.sqf";
|
player_useMeds = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\player_useMeds.sqf";
|
||||||
|
|||||||
Reference in New Issue
Block a user