mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-22 05:06:24 +00:00
fix(Core): Boss encounter disengage improvement (#4954)
This commit is contained in:
@@ -197,6 +197,51 @@ struct ScriptedAI : public CreatureAI
|
||||
// Called when AI is temporarily replaced or put back when possess is applied or removed
|
||||
void OnPossess(bool /*apply*/) {}
|
||||
|
||||
enum class Axis
|
||||
{
|
||||
AXIS_X,
|
||||
AXIS_Y
|
||||
};
|
||||
|
||||
/* This is called for bosses whenever an encounter is happening.
|
||||
* - Arguments:
|
||||
* - Position has to be passed as a constant pointer (&Position)
|
||||
* - Axis is the X or Y axis that is used to decide the position threshold
|
||||
* - Above decides if the boss position should be above the passed position
|
||||
* or below.
|
||||
* Example:
|
||||
* Hodir is in room until his Y position is below the Door position:
|
||||
* IsInRoom(doorPosition, AXIS_Y, false);
|
||||
*/
|
||||
bool IsInRoom(const Position* pos, Axis axis, bool above)
|
||||
{
|
||||
if (!pos)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (axis)
|
||||
{
|
||||
case Axis::AXIS_X:
|
||||
if ((!above && me->GetPositionX() < pos->GetPositionX()) || me->GetPositionX() > pos->GetPositionX())
|
||||
{
|
||||
EnterEvadeMode();
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case Axis::AXIS_Y:
|
||||
if ((!above && me->GetPositionY() < pos->GetPositionY()) || me->GetPositionY() > pos->GetPositionY())
|
||||
{
|
||||
EnterEvadeMode();
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// *************
|
||||
// Variables
|
||||
// *************
|
||||
|
||||
@@ -216,6 +216,10 @@ public:
|
||||
bool bAchievCoolestFriends{ true };
|
||||
uint16 addSpawnTimer{ 0 };
|
||||
|
||||
// Used to make Hodir disengage whenever he leaves his room
|
||||
const Position ENTRANCE_DOOR{ 1999.160034f, -297.792999f, 431.960999f, 0 };
|
||||
const Position EXIT_DOOR{ 1999.709961f, -166.259003f, 432.822998f, 0 };
|
||||
|
||||
void Reset() override
|
||||
{
|
||||
events.Reset();
|
||||
@@ -369,22 +373,12 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
bool IsInRoom()
|
||||
{
|
||||
// Calculate the distance between his home position to the gate
|
||||
if (me->GetExactDist(me->GetHomePosition().GetPositionX(),
|
||||
me->GetHomePosition().GetPositionY(),
|
||||
me->GetHomePosition().GetPositionZ()) > 80.0f)
|
||||
{
|
||||
EnterEvadeMode();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void UpdateAI(uint32 diff) override
|
||||
{
|
||||
if (!IsInRoom()) { return; }
|
||||
if (!IsInRoom(&ENTRANCE_DOOR, Axis::AXIS_Y, false) || !IsInRoom(&EXIT_DOOR, Axis::AXIS_Y, true))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!UpdateVictim())
|
||||
{
|
||||
@@ -398,9 +392,6 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
if( !berserk && (me->GetPositionX() < 1940.0f || me->GetPositionX() > 2070.0f || me->GetPositionY() < -300.0f || me->GetPositionY() > -155.0f) )
|
||||
events.RescheduleEvent(EVENT_BERSERK, 1);
|
||||
|
||||
events.Update(diff);
|
||||
|
||||
if( me->HasUnitState(UNIT_STATE_CASTING) )
|
||||
|
||||
Reference in New Issue
Block a user