summaryrefslogtreecommitdiffstats
path: root/src/Mobs/Monster.cpp
diff options
context:
space:
mode:
authorLogicParrot <LogicParrot@users.noreply.github.com>2016-01-12 13:46:02 +0100
committerLogicParrot <LogicParrot@users.noreply.github.com>2016-01-12 13:46:02 +0100
commitd4e99aedb1d202b3fa6f6b3f5bd5fd31a4ecc2f3 (patch)
treef313b63965b5dde2d2d9255b3d0cda2dda1068e4 /src/Mobs/Monster.cpp
parentMerge pull request #2860 from LogicParrot/wolfChecks (diff)
parentFix mob attack interval (diff)
downloadcuberite-d4e99aedb1d202b3fa6f6b3f5bd5fd31a4ecc2f3.tar
cuberite-d4e99aedb1d202b3fa6f6b3f5bd5fd31a4ecc2f3.tar.gz
cuberite-d4e99aedb1d202b3fa6f6b3f5bd5fd31a4ecc2f3.tar.bz2
cuberite-d4e99aedb1d202b3fa6f6b3f5bd5fd31a4ecc2f3.tar.lz
cuberite-d4e99aedb1d202b3fa6f6b3f5bd5fd31a4ecc2f3.tar.xz
cuberite-d4e99aedb1d202b3fa6f6b3f5bd5fd31a4ecc2f3.tar.zst
cuberite-d4e99aedb1d202b3fa6f6b3f5bd5fd31a4ecc2f3.zip
Diffstat (limited to 'src/Mobs/Monster.cpp')
-rw-r--r--src/Mobs/Monster.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp
index 7d8c3de02..a24df6bc2 100644
--- a/src/Mobs/Monster.cpp
+++ b/src/Mobs/Monster.cpp
@@ -88,7 +88,7 @@ cMonster::cMonster(const AString & a_ConfigName, eMonsterType a_MobType, const A
, m_AttackRate(3)
, m_AttackDamage(1)
, m_AttackRange(1)
- , m_AttackInterval(0)
+ , m_AttackCoolDownTicksLeft(0)
, m_SightDistance(25)
, m_DropChanceWeapon(0.085f)
, m_DropChanceHelmet(0.085f)
@@ -214,6 +214,11 @@ void cMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
super::Tick(a_Dt, a_Chunk);
GET_AND_VERIFY_CURRENT_CHUNK(Chunk, POSX_TOINT, POSZ_TOINT);
+ if (m_AttackCoolDownTicksLeft > 0)
+ {
+ m_AttackCoolDownTicksLeft -= 1;
+ }
+
if (m_Health <= 0)
{
// The mob is dead, but we're still animating the "puff" they leave when they die
@@ -690,6 +695,15 @@ void cMonster::InStateEscaping(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
+void cMonster::ResetAttackCooldown()
+{
+ m_AttackCoolDownTicksLeft = static_cast<int>(3 * 20 * m_AttackRate); // A second has 20 ticks, an attack rate of 1 means 1 hit every 3 seconds
+}
+
+
+
+
+
void cMonster::SetCustomName(const AString & a_CustomName)
{
m_CustomName = a_CustomName;