From 489027703e2d8cc0a974b68b6610e7b84d1d7899 Mon Sep 17 00:00:00 2001 From: treeston Date: Thu, 24 Mar 2016 16:12:53 +0100 Subject: Entities/Unit: Finally fix no-path evasion. - When a creature cannot find a path to its victim, it begins evading all attacks and regenerating health. - If this persists for 5 seconds, it evades back to spawn position with new EvadeReason value EVADE_REASON_NO_PATH. - Also some SmartAI cleanup (why oh why does it have so much duplicated code) and getting rid of #defines in favor of type-checked compile-time constants. (cherry picked from commit 7b1560fccba77ecbdfecd7b33af740aea41b7087) --- src/server/game/AI/CreatureAI.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/server/game/AI/CreatureAI.cpp') diff --git a/src/server/game/AI/CreatureAI.cpp b/src/server/game/AI/CreatureAI.cpp index 379834a7e3d..5e98945e1de 100644 --- a/src/server/game/AI/CreatureAI.cpp +++ b/src/server/game/AI/CreatureAI.cpp @@ -268,6 +268,7 @@ bool CreatureAI::_EnterEvadeMode(EvadeReason /*why*/) me->SetLootRecipient(NULL); me->ResetPlayerDamageReq(); me->SetLastDamagedTime(0); + me->SetCannotReachTarget(false); if (me->IsInEvadeMode()) return false; @@ -275,11 +276,11 @@ bool CreatureAI::_EnterEvadeMode(EvadeReason /*why*/) return true; } -#define BOUNDARY_VISUALIZE_CREATURE 15425 -#define BOUNDARY_VISUALIZE_CREATURE_SCALE 0.25f -#define BOUNDARY_VISUALIZE_STEP_SIZE 1 -#define BOUNDARY_VISUALIZE_FAILSAFE_LIMIT 750 -#define BOUNDARY_VISUALIZE_SPAWN_HEIGHT 5 +const uint32 BOUNDARY_VISUALIZE_CREATURE = 15425; +const float BOUNDARY_VISUALIZE_CREATURE_SCALE = 0.25f; +const int8 BOUNDARY_VISUALIZE_STEP_SIZE = 1; +const int32 BOUNDARY_VISUALIZE_FAILSAFE_LIMIT = 750; +const float BOUNDARY_VISUALIZE_SPAWN_HEIGHT = 5.0f; int32 CreatureAI::VisualizeBoundary(uint32 duration, Unit* owner, bool fill) const { typedef std::pair coordinate; @@ -295,13 +296,13 @@ int32 CreatureAI::VisualizeBoundary(uint32 duration, Unit* owner, bool fill) con std::unordered_set outOfBounds; Position startPosition = owner->GetPosition(); - if (!CheckBoundary(&startPosition)) // fall back to creature position - { + if (!CheckBoundary(&startPosition)) + { // fall back to creature position startPosition = me->GetPosition(); if (!CheckBoundary(&startPosition)) - { + { // fall back to creature home position startPosition = me->GetHomePosition(); - if (!CheckBoundary(&startPosition)) // fall back to creature home position + if (!CheckBoundary(&startPosition)) return LANG_CREATURE_NO_INTERIOR_POINT_FOUND; } } -- cgit v1.2.3