summaryrefslogtreecommitdiffstats
path: root/source/Mobs/Horse.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2013-10-08 20:20:49 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2013-10-08 20:20:49 +0200
commit5db6213f34318031ece7e2a6765f69564b671891 (patch)
tree074213cf13247c4e6370528eaa000bbd4b3a625d /source/Mobs/Horse.cpp
parentMerge pull request #2 from tigerw/bugfixes (diff)
downloadcuberite-5db6213f34318031ece7e2a6765f69564b671891.tar
cuberite-5db6213f34318031ece7e2a6765f69564b671891.tar.gz
cuberite-5db6213f34318031ece7e2a6765f69564b671891.tar.bz2
cuberite-5db6213f34318031ece7e2a6765f69564b671891.tar.lz
cuberite-5db6213f34318031ece7e2a6765f69564b671891.tar.xz
cuberite-5db6213f34318031ece7e2a6765f69564b671891.tar.zst
cuberite-5db6213f34318031ece7e2a6765f69564b671891.zip
Diffstat (limited to 'source/Mobs/Horse.cpp')
-rw-r--r--source/Mobs/Horse.cpp95
1 files changed, 93 insertions, 2 deletions
diff --git a/source/Mobs/Horse.cpp b/source/Mobs/Horse.cpp
index 05ac73c15..50eab33cc 100644
--- a/source/Mobs/Horse.cpp
+++ b/source/Mobs/Horse.cpp
@@ -2,13 +2,26 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "Horse.h"
+#include "../World.h"
+#include "../Entities/Player.h"
-cHorse::cHorse(void) :
- super("Horse", 100, "mob.horse.hit", "mob.horse.death", 1.4, 1.6)
+cHorse::cHorse(int Type, int Color, int Style, int TameTimes) :
+ super("Horse", 100, "mob.horse.hit", "mob.horse.death", 1.4, 1.6),
+ m_bIsChested(false),
+ m_bIsEating(false),
+ m_bIsRearing(false),
+ m_bIsMouthOpen(false),
+ m_bIsTame(false),
+ m_Type(Type),
+ m_Color(Color),
+ m_Style(Style),
+ m_Armour(0),
+ m_TimesToTame(TameTimes),
+ m_TameAttemptTimes(0)
{
}
@@ -16,6 +29,84 @@ cHorse::cHorse(void) :
+void cHorse::Tick(float a_Dt, cChunk & a_Chunk)
+{
+ super::Tick(a_Dt, a_Chunk);
+
+ if (!m_bIsMouthOpen)
+ {
+ if (m_World->GetTickRandomNumber(50) == 25)
+ {
+ m_bIsMouthOpen = true;
+ }
+ }
+ else
+ {
+ if (m_World->GetTickRandomNumber(10) == 5)
+ {
+ m_bIsMouthOpen = false;
+ }
+ }
+
+ if ((m_Attachee != NULL) && (!m_bIsTame))
+ {
+ if (m_TameAttemptTimes < m_TimesToTame)
+ {
+ if (m_World->GetTickRandomNumber(50) == 25)
+ {
+ m_World->BroadcastSoundParticleEffect(2000, (int)(floor(GetPosX()) * 8), (int)(floor(GetPosY()) * 8), (int)(floor(GetPosZ()) * 8), 0);
+ m_World->BroadcastSoundParticleEffect(2000, (int)(floor(GetPosX()) * 8), (int)(floor(GetPosY()) * 8), (int)(floor(GetPosZ()) * 8), 2);
+ m_World->BroadcastSoundParticleEffect(2000, (int)(floor(GetPosX()) * 8), (int)(floor(GetPosY()) * 8), (int)(floor(GetPosZ()) * 8), 6);
+ m_World->BroadcastSoundParticleEffect(2000, (int)(floor(GetPosX()) * 8), (int)(floor(GetPosY()) * 8), (int)(floor(GetPosZ()) * 8), 8);
+
+ m_Attachee->Detach();
+ m_bIsRearing = true;
+ }
+ }
+ else
+ {
+ m_bIsTame = true;
+ }
+ }
+
+ if ((m_bIsRearing) && (m_World->GetTickRandomNumber(15) == 6))
+ {
+ m_bIsRearing = false;
+ }
+
+ m_World->BroadcastEntityMetadata(*this);
+}
+
+
+
+
+
+void cHorse::OnRightClicked(cPlayer & a_Player)
+{
+ if (m_Attachee != NULL)
+ {
+ if (m_Attachee->GetUniqueID() == a_Player.GetUniqueID())
+ {
+ a_Player.Detach();
+ return;
+ }
+
+ if (m_Attachee->IsPlayer())
+ {
+ return;
+ }
+
+ m_Attachee->Detach();
+ }
+
+ m_TameAttemptTimes++;
+ a_Player.AttachTo(this);
+}
+
+
+
+
+
void cHorse::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
AddRandomDropItem(a_Drops, 0, 2, E_ITEM_LEATHER);