mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-15 01:59:09 +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
|
||||
// *************
|
||||
|
||||
Reference in New Issue
Block a user