From f1540173da442878e132b0bbca1f8f60141e1cd0 Mon Sep 17 00:00:00 2001 From: SafwatHalaby Date: Thu, 28 May 2015 17:45:47 +0300 Subject: AI - Sane Skeleton --- src/Mobs/Skeleton.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/Mobs/Skeleton.cpp') diff --git a/src/Mobs/Skeleton.cpp b/src/Mobs/Skeleton.cpp index f99404669..d1a481960 100644 --- a/src/Mobs/Skeleton.cpp +++ b/src/Mobs/Skeleton.cpp @@ -50,12 +50,13 @@ void cSkeleton::GetDrops(cItems & a_Drops, cEntity * a_Killer) void cSkeleton::Attack(std::chrono::milliseconds a_Dt) { + cFastRandom Random; m_AttackInterval += (static_cast(a_Dt.count()) / 1000) * m_AttackRate; if ((m_Target != nullptr) && (m_AttackInterval > 3.0)) { - // Setting this higher gives us more wiggle room for attackrate - Vector3d Speed = GetLookVector() * 20; - Speed.y = Speed.y + 1; + Vector3d Inaccuracy = Vector3d(Random.NextFloat(0.5) - 0.25, Random.NextFloat(0.5) - 0.25, Random.NextFloat(0.5) - 0.25); + Vector3d Speed = (m_Target->GetPosition() + Inaccuracy - GetPosition()) * 5; + Speed.y = Speed.y - 1 + Random.NextInt(3); cArrowEntity * Arrow = new cArrowEntity(this, GetPosX(), GetPosY() + 1, GetPosZ(), Speed); if (Arrow == nullptr) { -- cgit v1.2.3