1
0

Fix mob attack interval

This commit is contained in:
LogicParrot
2016-01-12 12:11:10 +02:00
parent e2a053263f
commit 21df3cb0d8
7 changed files with 28 additions and 24 deletions

View File

@@ -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;