1
0

Player: Removed food-poisoning-specific code, set duration to 30 seconds

http://minecraft.gamepedia.com/Hunger#Behavior
This commit is contained in:
archshift 2014-06-06 21:55:23 -07:00
parent 481f05b011
commit 2123173202
3 changed files with 3 additions and 27 deletions

View File

@ -40,7 +40,6 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName)
, m_FoodSaturationLevel(5) , m_FoodSaturationLevel(5)
, m_FoodTickTimer(0) , m_FoodTickTimer(0)
, m_FoodExhaustionLevel(0) , m_FoodExhaustionLevel(0)
, m_FoodPoisonedTicksRemaining(0)
, m_LastJumpHeight(0) , m_LastJumpHeight(0)
, m_LastGroundHeight(0) , m_LastGroundHeight(0)
, m_bTouchGround(false) , m_bTouchGround(false)
@ -551,15 +550,6 @@ void cPlayer::SetFoodExhaustionLevel(double a_FoodExhaustionLevel)
void cPlayer::SetFoodPoisonedTicksRemaining(int a_FoodPoisonedTicksRemaining)
{
m_FoodPoisonedTicksRemaining = a_FoodPoisonedTicksRemaining;
}
bool cPlayer::Feed(int a_Food, double a_Saturation) bool cPlayer::Feed(int a_Food, double a_Saturation)
{ {
if (m_FoodLevel >= MAX_FOOD_LEVEL) if (m_FoodLevel >= MAX_FOOD_LEVEL)
@ -580,16 +570,7 @@ bool cPlayer::Feed(int a_Food, double a_Saturation)
void cPlayer::FoodPoison(int a_NumTicks) void cPlayer::FoodPoison(int a_NumTicks)
{ {
bool HasBeenFoodPoisoned = (m_FoodPoisonedTicksRemaining > 0); AddEntityEffect(cEntityEffect::efHunger, cEntityEffect(0, a_NumTicks));
m_FoodPoisonedTicksRemaining = std::max(m_FoodPoisonedTicksRemaining, a_NumTicks);
if (!HasBeenFoodPoisoned)
{
SendHealth();
}
else
{
AddEntityEffect(cEntityEffect::efHunger, cEntityEffect(0, 400)); // Give the player the "Hunger" effect for 20 seconds.
}
} }

View File

@ -267,7 +267,6 @@ public:
double GetFoodSaturationLevel (void) const { return m_FoodSaturationLevel; } double GetFoodSaturationLevel (void) const { return m_FoodSaturationLevel; }
int GetFoodTickTimer (void) const { return m_FoodTickTimer; } int GetFoodTickTimer (void) const { return m_FoodTickTimer; }
double GetFoodExhaustionLevel (void) const { return m_FoodExhaustionLevel; } double GetFoodExhaustionLevel (void) const { return m_FoodExhaustionLevel; }
int GetFoodPoisonedTicksRemaining(void) const { return m_FoodPoisonedTicksRemaining; }
/** Returns true if the player is satiated, i. e. their foodlevel is at the max and they cannot eat anymore */ /** Returns true if the player is satiated, i. e. their foodlevel is at the max and they cannot eat anymore */
bool IsSatiated(void) const { return (m_FoodLevel >= MAX_FOOD_LEVEL); } bool IsSatiated(void) const { return (m_FoodLevel >= MAX_FOOD_LEVEL); }
@ -276,7 +275,6 @@ public:
void SetFoodSaturationLevel (double a_FoodSaturationLevel); void SetFoodSaturationLevel (double a_FoodSaturationLevel);
void SetFoodTickTimer (int a_FoodTickTimer); void SetFoodTickTimer (int a_FoodTickTimer);
void SetFoodExhaustionLevel (double a_FoodExhaustionLevel); void SetFoodExhaustionLevel (double a_FoodExhaustionLevel);
void SetFoodPoisonedTicksRemaining(int a_FoodPoisonedTicksRemaining);
/** Adds to FoodLevel and FoodSaturationLevel, returns true if any food has been consumed, false if player "full" */ /** Adds to FoodLevel and FoodSaturationLevel, returns true if any food has been consumed, false if player "full" */
bool Feed(int a_Food, double a_Saturation); bool Feed(int a_Food, double a_Saturation);
@ -287,7 +285,7 @@ public:
m_FoodExhaustionLevel += a_Exhaustion; m_FoodExhaustionLevel += a_Exhaustion;
} }
/** Starts the food poisoning for the specified amount of ticks; if already foodpoisoned, sets FoodPoisonedTicksRemaining to the larger of the two */ /** Starts the food poisoning for the specified amount of ticks */
void FoodPoison(int a_NumTicks); void FoodPoison(int a_NumTicks);
/** Returns true if the player is currently in the process of eating the currently equipped item */ /** Returns true if the player is currently in the process of eating the currently equipped item */
@ -442,9 +440,6 @@ protected:
/** A "buffer" which adds up hunger before it is substracted from m_FoodSaturationLevel or m_FoodLevel. Each action adds a little */ /** A "buffer" which adds up hunger before it is substracted from m_FoodSaturationLevel or m_FoodLevel. Each action adds a little */
double m_FoodExhaustionLevel; double m_FoodExhaustionLevel;
/** Number of ticks remaining for the foodpoisoning effect; zero if not foodpoisoned */
int m_FoodPoisonedTicksRemaining;
float m_LastJumpHeight; float m_LastJumpHeight;
float m_LastGroundHeight; float m_LastGroundHeight;
bool m_bTouchGround; bool m_bTouchGround;

View File

@ -577,7 +577,7 @@ bool cItemHandler::EatItem(cPlayer * a_Player, cItem * a_Item)
cFastRandom r1; cFastRandom r1;
if ((r1.NextInt(100, a_Player->GetUniqueID()) - Info.PoisonChance) <= 0) if ((r1.NextInt(100, a_Player->GetUniqueID()) - Info.PoisonChance) <= 0)
{ {
a_Player->FoodPoison(300); a_Player->FoodPoison(600); // Give the player food poisoning for 30 seconds.
} }
} }