summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortonibm19 <tonibm19@gmail.com>2014-03-02 14:35:03 +0100
committertonibm19 <tonibm19@gmail.com>2014-03-02 14:35:03 +0100
commit10fdc51b0a9b571b118b257109014e1c29591698 (patch)
treebfebf1ba211aaa595cd0396804be75e51899a810
parentMerge pull request #733 from Howaner/Slabs (diff)
downloadcuberite-10fdc51b0a9b571b118b257109014e1c29591698.tar
cuberite-10fdc51b0a9b571b118b257109014e1c29591698.tar.gz
cuberite-10fdc51b0a9b571b118b257109014e1c29591698.tar.bz2
cuberite-10fdc51b0a9b571b118b257109014e1c29591698.tar.lz
cuberite-10fdc51b0a9b571b118b257109014e1c29591698.tar.xz
cuberite-10fdc51b0a9b571b118b257109014e1c29591698.tar.zst
cuberite-10fdc51b0a9b571b118b257109014e1c29591698.zip
-rw-r--r--src/Mobs/Creeper.cpp41
-rw-r--r--src/Mobs/Creeper.h3
2 files changed, 34 insertions, 10 deletions
diff --git a/src/Mobs/Creeper.cpp b/src/Mobs/Creeper.cpp
index 40ee20e44..3471b4cf1 100644
--- a/src/Mobs/Creeper.cpp
+++ b/src/Mobs/Creeper.cpp
@@ -4,6 +4,7 @@
#include "Creeper.h"
#include "../World.h"
#include "../Entities/ProjectileEntity.h"
+#include "../Entities/Player.h"
@@ -13,6 +14,7 @@ cCreeper::cCreeper(void) :
super("Creeper", mtCreeper, "mob.creeper.say", "mob.creeper.say", 0.6, 1.8),
m_bIsBlowing(false),
m_bIsCharged(false),
+ m_BurnedWithFlintAndSteel(false),
m_ExplodingTimer(0)
{
}
@@ -25,12 +27,25 @@ void cCreeper::Tick(float a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
- if (!ReachedFinalDestination())
+ if (!ReachedFinalDestination() && !m_BurnedWithFlintAndSteel)
{
m_ExplodingTimer = 0;
m_bIsBlowing = false;
m_World->BroadcastEntityMetadata(*this);
}
+ else
+ {
+ if (m_bIsBlowing)
+ {
+ m_ExplodingTimer += 1;
+ }
+
+ if (m_ExplodingTimer == 30)
+ {
+ m_World->DoExplosionAt((m_bIsCharged ? 5 : 3), GetPosX(), GetPosY(), GetPosZ(), false, esMonster, this);
+ Destroy();
+ }
+ }
}
@@ -80,22 +95,30 @@ void cCreeper::Attack(float a_Dt)
{
UNUSED(a_Dt);
- m_ExplodingTimer += 1;
-
if (!m_bIsBlowing)
{
m_World->BroadcastSoundEffect("game.tnt.primed", (int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 1.f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
m_bIsBlowing = true;
m_World->BroadcastEntityMetadata(*this);
}
-
- if (m_ExplodingTimer == 20)
- {
- m_World->DoExplosionAt((m_bIsCharged ? 5 : 3), GetPosX(), GetPosY(), GetPosZ(), false, esMonster, this);
- Destroy();
- }
}
+
+void cCreeper::OnRightClicked(cPlayer & a_Player)
+{
+ if ((a_Player.GetEquippedItem().m_ItemType == E_ITEM_FLINT_AND_STEEL))
+ {
+ if (!a_Player.IsGameModeCreative())
+ {
+ a_Player.UseEquippedItem();
+ }
+ m_World->BroadcastSoundEffect("game.tnt.primed", (int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 1.f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
+ m_bIsBlowing = true;
+ m_World->BroadcastEntityMetadata(*this);
+ m_BurnedWithFlintAndSteel = true;
+ }
+}
+
diff --git a/src/Mobs/Creeper.h b/src/Mobs/Creeper.h
index 0f71e5ad2..9abca369b 100644
--- a/src/Mobs/Creeper.h
+++ b/src/Mobs/Creeper.h
@@ -21,13 +21,14 @@ public:
virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override;
virtual void Attack(float a_Dt) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+ virtual void OnRightClicked(cPlayer & a_Player) override;
bool IsBlowing(void) const {return m_bIsBlowing; }
bool IsCharged(void) const {return m_bIsCharged; }
private:
- bool m_bIsBlowing, m_bIsCharged;
+ bool m_bIsBlowing, m_bIsCharged, m_BurnedWithFlintAndSteel;
int m_ExplodingTimer;
} ;