1
0

Merge pull request #2615 from Gargaj/cavespider-attack

Fix cavespider poisoning even if attack is in cooldown
This commit is contained in:
worktycho 2015-11-08 22:08:40 +00:00
commit a1926ca16e
16 changed files with 48 additions and 27 deletions

View File

@ -92,15 +92,17 @@ void cAggressiveMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
void cAggressiveMonster::Attack(std::chrono::milliseconds a_Dt)
bool cAggressiveMonster::Attack(std::chrono::milliseconds a_Dt)
{
m_AttackInterval += (static_cast<float>(a_Dt.count()) / 1000) * m_AttackRate;
if ((m_Target == nullptr) || (m_AttackInterval < 3.0))
{
return;
return false;
}
// Setting this higher gives us more wiggle room for attackrate
m_AttackInterval = 0.0;
m_Target->TakeDamage(dtMobAttack, this, m_AttackDamage, 0);
return true;
}

View File

@ -20,7 +20,7 @@ public:
virtual void InStateChasing(std::chrono::milliseconds a_Dt) override;
virtual void EventSeePlayer(cEntity *) override;
virtual void Attack(std::chrono::milliseconds a_Dt);
virtual bool Attack(std::chrono::milliseconds a_Dt);
} ;

View File

@ -32,7 +32,7 @@ void cBlaze::GetDrops(cItems & a_Drops, cEntity * a_Killer)
void cBlaze::Attack(std::chrono::milliseconds a_Dt)
bool cBlaze::Attack(std::chrono::milliseconds a_Dt)
{
m_AttackInterval += (static_cast<float>(a_Dt.count()) / 1000) * m_AttackRate;
@ -44,16 +44,18 @@ void cBlaze::Attack(std::chrono::milliseconds a_Dt)
cFireChargeEntity * FireCharge = new cFireChargeEntity(this, GetPosX(), GetPosY() + 1, GetPosZ(), Speed);
if (FireCharge == nullptr)
{
return;
return false;
}
if (!FireCharge->Initialize(*m_World))
{
delete FireCharge;
FireCharge = nullptr;
return;
return false;
}
m_World->BroadcastSpawnEntity(*FireCharge);
m_AttackInterval = 0.0;
// ToDo: Shoot 3 fireballs instead of 1.
return true;
}
return false;
}

View File

@ -18,5 +18,5 @@ public:
CLASS_PROTODEF(cBlaze)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
virtual void Attack(std::chrono::milliseconds a_Dt) override;
virtual bool Attack(std::chrono::milliseconds a_Dt) override;
} ;

View File

@ -27,15 +27,19 @@ void cCaveSpider::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
void cCaveSpider::Attack(std::chrono::milliseconds a_Dt)
bool cCaveSpider::Attack(std::chrono::milliseconds a_Dt)
{
super::Attack(a_Dt);
if (!super::Attack(a_Dt))
{
return false;
}
if (m_Target->IsPawn())
{
// TODO: Easy = no poison, Medium = 7 seconds, Hard = 15 seconds
static_cast<cPawn *>(m_Target)->AddEntityEffect(cEntityEffect::effPoison, 7 * 20, 0);
}
return true;
}

View File

@ -17,7 +17,7 @@ public:
CLASS_PROTODEF(cCaveSpider)
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual void Attack(std::chrono::milliseconds a_Dt) override;
virtual bool Attack(std::chrono::milliseconds a_Dt) override;
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
} ;

View File

@ -121,7 +121,7 @@ bool cCreeper::DoTakeDamage(TakeDamageInfo & a_TDI)
void cCreeper::Attack(std::chrono::milliseconds a_Dt)
bool cCreeper::Attack(std::chrono::milliseconds a_Dt)
{
UNUSED(a_Dt);
@ -130,7 +130,10 @@ void cCreeper::Attack(std::chrono::milliseconds a_Dt)
m_World->BroadcastSoundEffect("game.tnt.primed", GetPosX(), GetPosY(), GetPosZ(), 1.f, (0.75f + (static_cast<float>((GetUniqueID() * 23) % 32)) / 64));
m_bIsBlowing = true;
m_World->BroadcastEntityMetadata(*this);
return true;
}
return false;
}

View File

@ -19,7 +19,7 @@ public:
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
virtual void Attack(std::chrono::milliseconds a_Dt) override;
virtual bool Attack(std::chrono::milliseconds a_Dt) override;
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual void OnRightClicked(cPlayer & a_Player) override;

View File

@ -32,7 +32,7 @@ void cGhast::GetDrops(cItems & a_Drops, cEntity * a_Killer)
void cGhast::Attack(std::chrono::milliseconds a_Dt)
bool cGhast::Attack(std::chrono::milliseconds a_Dt)
{
m_AttackInterval += (static_cast<float>(a_Dt.count()) / 1000) * m_AttackRate;
@ -44,17 +44,20 @@ void cGhast::Attack(std::chrono::milliseconds a_Dt)
cGhastFireballEntity * GhastBall = new cGhastFireballEntity(this, GetPosX(), GetPosY() + 1, GetPosZ(), Speed);
if (GhastBall == nullptr)
{
return;
return false;
}
if (!GhastBall->Initialize(*m_World))
{
delete GhastBall;
GhastBall = nullptr;
return;
return false;
}
m_World->BroadcastSpawnEntity(*GhastBall);
m_AttackInterval = 0.0;
return true;
}
return false;
}

View File

@ -18,7 +18,7 @@ public:
CLASS_PROTODEF(cGhast)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
virtual void Attack(std::chrono::milliseconds a_Dt) override;
virtual bool Attack(std::chrono::milliseconds a_Dt) override;
bool IsCharging(void) const {return false; }
} ;

View File

@ -48,7 +48,7 @@ void cSkeleton::GetDrops(cItems & a_Drops, cEntity * a_Killer)
void cSkeleton::Attack(std::chrono::milliseconds a_Dt)
bool cSkeleton::Attack(std::chrono::milliseconds a_Dt)
{
cFastRandom Random;
m_AttackInterval += (static_cast<float>(a_Dt.count()) / 1000) * m_AttackRate;
@ -60,17 +60,20 @@ void cSkeleton::Attack(std::chrono::milliseconds a_Dt)
cArrowEntity * Arrow = new cArrowEntity(this, GetPosX(), GetPosY() + 1, GetPosZ(), Speed);
if (Arrow == nullptr)
{
return;
return false;
}
if (!Arrow->Initialize(*m_World))
{
delete Arrow;
Arrow = nullptr;
return;
return false;
}
m_World->BroadcastSpawnEntity(*Arrow);
m_AttackInterval = 0.0;
return true;
}
return false;
}

View File

@ -18,7 +18,7 @@ public:
CLASS_PROTODEF(cSkeleton)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
virtual void Attack(std::chrono::milliseconds a_Dt) override;
virtual bool Attack(std::chrono::milliseconds a_Dt) override;
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
virtual bool IsUndead(void) override { return true; }

View File

@ -46,13 +46,15 @@ void cSlime::GetDrops(cItems & a_Drops, cEntity * a_Killer)
void cSlime::Attack(std::chrono::milliseconds a_Dt)
bool cSlime::Attack(std::chrono::milliseconds a_Dt)
{
if (m_Size > 1)
{
// Only slimes larger than size 1 attack a player.
super::Attack(a_Dt);
return super::Attack(a_Dt);
}
return false;
}

View File

@ -20,7 +20,7 @@ public:
// cAggressiveMonster overrides:
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
virtual void Attack(std::chrono::milliseconds a_Dt) override;
virtual bool Attack(std::chrono::milliseconds a_Dt) override;
virtual void KilledBy(TakeDamageInfo & a_TDI) override;
int GetSize(void) const { return m_Size; }

View File

@ -45,7 +45,7 @@ bool cWolf::DoTakeDamage(TakeDamageInfo & a_TDI)
void cWolf::Attack(std::chrono::milliseconds a_Dt)
bool cWolf::Attack(std::chrono::milliseconds a_Dt)
{
UNUSED(a_Dt);
@ -53,13 +53,15 @@ void cWolf::Attack(std::chrono::milliseconds a_Dt)
{
if (static_cast<cPlayer *>(m_Target)->GetName() != m_OwnerName)
{
super::Attack(a_Dt);
return super::Attack(a_Dt);
}
}
else
{
super::Attack(a_Dt);
return super::Attack(a_Dt);
}
return false;
}

View File

@ -22,7 +22,7 @@ public:
virtual void OnRightClicked(cPlayer & a_Player) override;
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual void TickFollowPlayer();
virtual void Attack(std::chrono::milliseconds a_Dt) override;
virtual bool Attack(std::chrono::milliseconds a_Dt) override;
// Get functions
bool IsSitting (void) const override { return m_IsSitting; }