diff options
author | LogicParrot <LogicParrot@users.noreply.github.com> | 2016-01-12 11:11:10 +0100 |
---|---|---|
committer | LogicParrot <LogicParrot@users.noreply.github.com> | 2016-01-12 13:20:17 +0100 |
commit | 21df3cb0d8a194461bbcec5803c5d6243f254a95 (patch) | |
tree | 77a4d9c9b928c8bca051b5e09a4299ae189201a8 /src/Mobs/Monster.cpp | |
parent | Merge pull request #2857 from LogicParrot/wolf (diff) | |
download | cuberite-21df3cb0d8a194461bbcec5803c5d6243f254a95.tar cuberite-21df3cb0d8a194461bbcec5803c5d6243f254a95.tar.gz cuberite-21df3cb0d8a194461bbcec5803c5d6243f254a95.tar.bz2 cuberite-21df3cb0d8a194461bbcec5803c5d6243f254a95.tar.lz cuberite-21df3cb0d8a194461bbcec5803c5d6243f254a95.tar.xz cuberite-21df3cb0d8a194461bbcec5803c5d6243f254a95.tar.zst cuberite-21df3cb0d8a194461bbcec5803c5d6243f254a95.zip |
Diffstat (limited to 'src/Mobs/Monster.cpp')
-rw-r--r-- | src/Mobs/Monster.cpp | 16 |
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; |