summaryrefslogtreecommitdiffstats
path: root/source/Mobs/Horse.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/Mobs/Horse.cpp')
-rw-r--r--source/Mobs/Horse.cpp61
1 files changed, 39 insertions, 22 deletions
diff --git a/source/Mobs/Horse.cpp b/source/Mobs/Horse.cpp
index c2a8f6ed0..d18887ea4 100644
--- a/source/Mobs/Horse.cpp
+++ b/source/Mobs/Horse.cpp
@@ -1,4 +1,3 @@
-
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "Horse.h"
@@ -10,7 +9,7 @@
cHorse::cHorse(int Type, int Color, int Style, int TameTimes) :
- super("Horse", 100, "mob.horse.hit", "mob.horse.death", 1.4, 1.6),
+ super("Horse", mtHorse, "mob.horse.hit", "mob.horse.death", 1.4, 1.6),
m_bHasChest(false),
m_bIsEating(false),
m_bIsRearing(false),
@@ -76,8 +75,12 @@ void cHorse::Tick(float a_Dt, cChunk & a_Chunk)
if (m_RearTickCount == 20)
{
m_bIsRearing = false;
+ m_RearTickCount = 0;
+ }
+ else
+ {
+ m_RearTickCount++;
}
- else { m_RearTickCount++;}
}
m_World->BroadcastEntityMetadata(*this);
@@ -89,35 +92,45 @@ void cHorse::Tick(float a_Dt, cChunk & a_Chunk)
void cHorse::OnRightClicked(cPlayer & a_Player)
{
- if (m_Attachee != NULL)
+ if (!m_bIsSaddled && m_bIsTame)
{
- if (m_Attachee->GetUniqueID() == a_Player.GetUniqueID())
+ if (a_Player.GetEquippedItem().m_ItemType == E_ITEM_SADDLE)
{
- a_Player.Detach();
- return;
+ // Saddle the horse:
+ if (!a_Player.IsGameModeCreative())
+ {
+ a_Player.GetInventory().RemoveOneEquippedItem();
+ }
+ m_bIsSaddled = true;
+ m_World->BroadcastEntityMetadata(*this);
}
-
- if (m_Attachee->IsPlayer())
+ else if (!a_Player.GetEquippedItem().IsEmpty())
{
- return;
+ // The horse doesn't like being hit, make it rear:
+ m_bIsRearing = true;
+ m_RearTickCount = 0;
}
-
- m_Attachee->Detach();
}
-
- m_TameAttemptTimes++;
- a_Player.AttachTo(this);
-
- if (a_Player.GetEquippedItem().m_ItemType == E_ITEM_SADDLE)
+ else
{
- if (!a_Player.IsGameModeCreative())
+ if (m_Attachee != NULL)
{
- a_Player.GetInventory().RemoveOneEquippedItem();
+ if (m_Attachee->GetUniqueID() == a_Player.GetUniqueID())
+ {
+ a_Player.Detach();
+ return;
+ }
+
+ if (m_Attachee->IsPlayer())
+ {
+ return;
+ }
+
+ m_Attachee->Detach();
}
- // Set saddle state & broadcast metadata
- m_bIsSaddled = true;
- m_World->BroadcastEntityMetadata(*this);
+ m_TameAttemptTimes++;
+ a_Player.AttachTo(this);
}
}
@@ -128,6 +141,10 @@ void cHorse::OnRightClicked(cPlayer & a_Player)
void cHorse::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
AddRandomDropItem(a_Drops, 0, 2, E_ITEM_LEATHER);
+ if (m_bIsSaddled)
+ {
+ a_Drops.push_back(cItem(E_ITEM_SADDLE, 1));
+ }
}