summaryrefslogtreecommitdiffstats
path: root/source/Mobs/Wolf.cpp
diff options
context:
space:
mode:
authorSamuel Barney <samjbarney@gmail.com>2013-10-14 17:42:43 +0200
committerSamuel Barney <samjbarney@gmail.com>2013-10-14 17:42:43 +0200
commit5df5176f8d1793b44c7e2353cb46ca0966be1bdd (patch)
tree95343394cd9902ceaf885f379342c593392e9c16 /source/Mobs/Wolf.cpp
parentMobs no longer spawn up in the air. (diff)
parentAPIDump: Documented HOOK_HANDSHAKE. (diff)
downloadcuberite-5df5176f8d1793b44c7e2353cb46ca0966be1bdd.tar
cuberite-5df5176f8d1793b44c7e2353cb46ca0966be1bdd.tar.gz
cuberite-5df5176f8d1793b44c7e2353cb46ca0966be1bdd.tar.bz2
cuberite-5df5176f8d1793b44c7e2353cb46ca0966be1bdd.tar.lz
cuberite-5df5176f8d1793b44c7e2353cb46ca0966be1bdd.tar.xz
cuberite-5df5176f8d1793b44c7e2353cb46ca0966be1bdd.tar.zst
cuberite-5df5176f8d1793b44c7e2353cb46ca0966be1bdd.zip
Diffstat (limited to 'source/Mobs/Wolf.cpp')
-rw-r--r--source/Mobs/Wolf.cpp79
1 files changed, 79 insertions, 0 deletions
diff --git a/source/Mobs/Wolf.cpp b/source/Mobs/Wolf.cpp
new file mode 100644
index 000000000..e76f991dc
--- /dev/null
+++ b/source/Mobs/Wolf.cpp
@@ -0,0 +1,79 @@
+
+#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
+
+#include "Wolf.h"
+#include "../World.h"
+#include "../Entities/Player.h"
+
+
+
+
+
+cWolf::cWolf(void) :
+ super("Wolf", 95, "mob.wolf.hurt", "mob.wolf.death", 0.6, 0.8),
+ m_bIsAngry(false),
+ m_bIsTame(false),
+ m_bIsSitting(false),
+ m_bIsBegging(false)
+{
+}
+
+
+
+
+
+void cWolf::DoTakeDamage(TakeDamageInfo & a_TDI)
+{
+ super::DoTakeDamage(a_TDI);
+ if (!m_bIsTame)
+ {
+ m_bIsAngry = true;
+ }
+ m_World->BroadcastEntityMetadata(*this); // Broadcast health and possibly angry face
+}
+
+
+
+
+
+void cWolf::OnRightClicked(cPlayer & a_Player)
+{
+ if ((!m_bIsTame) && (!m_bIsAngry))
+ {
+ if (a_Player.GetEquippedItem().m_ItemType == E_ITEM_BONE)
+ {
+ if (!a_Player.IsGameModeCreative())
+ {
+ a_Player.GetInventory().RemoveOneEquippedItem();
+ }
+
+ if (m_World->GetTickRandomNumber(10) == 5)
+ {
+ SetMaxHealth(20);
+ m_bIsTame = true;
+ m_World->BroadcastEntityStatus(*this, ENTITY_STATUS_WOLF_TAMED);
+ }
+ else
+ {
+ m_World->BroadcastEntityStatus(*this, ENTITY_STATUS_WOLF_TAMING);
+ }
+ }
+ }
+ else if (m_bIsTame)
+ {
+ if (m_bIsSitting)
+ {
+ m_bIsSitting = false;
+ }
+ else
+ {
+ m_bIsSitting = true;
+ }
+ }
+
+ m_World->BroadcastEntityMetadata(*this);
+}
+
+
+
+