summaryrefslogtreecommitdiffstats
path: root/source/cPlayer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/cPlayer.cpp')
-rw-r--r--source/cPlayer.cpp72
1 files changed, 63 insertions, 9 deletions
diff --git a/source/cPlayer.cpp b/source/cPlayer.cpp
index 87db2d19d..9cfe4d644 100644
--- a/source/cPlayer.cpp
+++ b/source/cPlayer.cpp
@@ -305,20 +305,31 @@ void cPlayer::Heal( int a_Health )
}
}
-void cPlayer::Feed( short a_Food )
+
+
+
+
+bool cPlayer::Feed(short a_Food)
{
- if( m_FoodLevel < GetMaxFoodLevel() )
+ if (m_FoodLevel >= GetMaxFoodLevel())
{
- m_FoodLevel = MIN(a_Food + m_FoodLevel, GetMaxFoodLevel());
-
- cPacket_UpdateHealth Health;
- Health.m_Health = m_Health;
- Health.m_Food = GetFood();
- Health.m_Saturation = GetFoodSaturation();
- m_ClientHandle->Send( Health );
+ return false;
}
+
+ m_FoodLevel = MIN(a_Food + m_FoodLevel, GetMaxFoodLevel());
+
+ cPacket_UpdateHealth Health;
+ Health.m_Health = m_Health;
+ Health.m_Food = GetFood();
+ Health.m_Saturation = GetFoodSaturation();
+ m_ClientHandle->Send( Health );
+ return true;
}
+
+
+
+
void cPlayer::TakeDamage( int a_Damage, cEntity* a_Instigator )
{
if ( !(m_GameMode == 1) ) {
@@ -985,3 +996,46 @@ void cPlayer::UseEquippedItem()
+
+bool cPlayer::EatItem(int a_ItemType)
+{
+ // TODO: Handle hunger
+ switch (a_ItemType)
+ {
+ case E_ITEM_APPLE: return Feed(24); // 2 food bars
+ case E_ITEM_GOLDEN_APPLE: return Feed(60); // 5 food
+ case E_ITEM_MUSHROOM_SOUP: return Feed(48); // 4 food
+ case E_ITEM_BREAD: return Feed(30); // 2.5 food
+ case E_ITEM_RAW_MEAT: return Feed(18); // 1.5 food
+ case E_ITEM_COOKED_MEAT: return Feed(48); // 4 food
+ case E_ITEM_RAW_FISH: return Feed(12); // 1 food
+ case E_ITEM_COOKED_FISH: return Feed(30); // 2.5 food
+ case E_ITEM_COOKED_CHICKEN: return Feed(36); // 3 food
+ case E_ITEM_RAW_BEEF: return Feed(18); // 1.5 food
+ case E_ITEM_STEAK: return Feed(48); // 4 food
+ case E_ITEM_RAW_CHICKEN:
+ {
+ if (!Feed(12)) // 1 food
+ {
+ return false;
+ }
+ // TODO: A random chance to get food-poisoned
+ return true;
+ }
+
+ case E_ITEM_ROTTEN_FLESH:
+ {
+ if (!Feed(24))
+ {
+ return false;
+ }
+ // TODO: Food-poisoning
+ return true;
+ }
+ }
+ return false;
+}
+
+
+
+