Core/AI: rearrange SAI private methods

Port From (https://github.com/TrinityCore/TrinityCore/commit/3e5a955fc8980df1332a3faa741731fbddc31b24)
This commit is contained in:
hondacrx
2021-02-04 10:37:28 -05:00
parent 0e77439e20
commit ae9b0040a1
+93 -87
View File
@@ -46,26 +46,6 @@ namespace Game.AI
return !mIsCharmed; return !mIsCharmed;
} }
void UpdateDespawn(uint diff)
{
if (mDespawnState <= 1 || mDespawnState > 3)
return;
if (mDespawnTime < diff)
{
if (mDespawnState == 2)
{
me.SetVisible(false);
mDespawnTime = 5000;
mDespawnState++;
}
else
me.DespawnOrUnsummon(0, TimeSpan.FromSeconds(mRespawnTime));
}
else
mDespawnTime -= diff;
}
public void StartPath(bool run = false, uint pathId = 0, bool repeat = false, Unit invoker = null, uint nodeId = 1) public void StartPath(bool run = false, uint pathId = 0, bool repeat = false, Unit invoker = null, uint nodeId = 1)
{ {
if (me.IsInCombat())// no wp movement in combat if (me.IsInCombat())// no wp movement in combat
@@ -302,80 +282,16 @@ namespace Game.AI
me.GetMotionMaster().MovePoint(EventId.SmartEscortLastOCCPoint, me.GetHomePosition()); me.GetMotionMaster().MovePoint(EventId.SmartEscortLastOCCPoint, me.GetHomePosition());
} }
void UpdatePath(uint diff)
{
if (!HasEscortState(SmartEscortState.Escorting))
return;
if (_escortInvokerCheckTimer < diff)
{
if (!IsEscortInvokerInRange())
{
StopPath(0, mEscortQuestID, true);
// allow to properly hook out of range despawn action, which in most cases should perform the same operation as dying
GetScript().ProcessEventsFor(SmartEvents.Death, me);
me.DespawnOrUnsummon();
return;
}
_escortInvokerCheckTimer = 1000;
}
else
_escortInvokerCheckTimer -= diff;
// handle pause
if (HasEscortState(SmartEscortState.Paused) && (_waypointReached || _waypointPauseForced))
{
if (_waypointPauseTimer < diff)
{
if (!me.IsInCombat() && !HasEscortState(SmartEscortState.Returning))
ResumePath();
}
else
_waypointPauseTimer -= diff;
}
else if (_waypointPathEnded) // end path
{
_waypointPathEnded = false;
StopPath();
return;
}
if (HasEscortState(SmartEscortState.Returning))
{
if (_OOCReached)//reached OOC WP
{
_OOCReached = false;
RemoveEscortState(SmartEscortState.Returning);
if (!HasEscortState(SmartEscortState.Paused))
ResumePath();
}
}
}
public override void UpdateAI(uint diff) public override void UpdateAI(uint diff)
{ {
CheckConditions(diff); CheckConditions(diff);
GetScript().OnUpdate(diff); GetScript().OnUpdate(diff);
UpdatePath(diff); UpdatePath(diff);
UpdateFollow(diff);
UpdateDespawn(diff); UpdateDespawn(diff);
if (!mFollowGuid.IsEmpty())
{
if (mFollowArrivedTimer < diff)
{
if (me.FindNearestCreature(mFollowArrivedEntry, SharedConst.InteractionDistance, true))
{
StopFollow(true);
return;
}
mFollowArrivedTimer = 1000;
}
else
mFollowArrivedTimer -= diff;
}
if (!IsAIControlled()) if (!IsAIControlled())
return; return;
@@ -988,6 +904,96 @@ namespace Game.AI
mConditionsTimer -= diff; mConditionsTimer -= diff;
} }
void UpdatePath(uint diff)
{
if (!HasEscortState(SmartEscortState.Escorting))
return;
if (_escortInvokerCheckTimer < diff)
{
if (!IsEscortInvokerInRange())
{
StopPath(0, mEscortQuestID, true);
// allow to properly hook out of range despawn action, which in most cases should perform the same operation as dying
GetScript().ProcessEventsFor(SmartEvents.Death, me);
me.DespawnOrUnsummon();
return;
}
_escortInvokerCheckTimer = 1000;
}
else
_escortInvokerCheckTimer -= diff;
// handle pause
if (HasEscortState(SmartEscortState.Paused) && (_waypointReached || _waypointPauseForced))
{
if (_waypointPauseTimer < diff)
{
if (!me.IsInCombat() && !HasEscortState(SmartEscortState.Returning))
ResumePath();
}
else
_waypointPauseTimer -= diff;
}
else if (_waypointPathEnded) // end path
{
_waypointPathEnded = false;
StopPath();
return;
}
if (HasEscortState(SmartEscortState.Returning))
{
if (_OOCReached)//reached OOC WP
{
_OOCReached = false;
RemoveEscortState(SmartEscortState.Returning);
if (!HasEscortState(SmartEscortState.Paused))
ResumePath();
}
}
}
void UpdateFollow(uint diff)
{
if (mFollowGuid.IsEmpty())
{
if (mFollowArrivedTimer < diff)
{
if (me.FindNearestCreature(mFollowArrivedEntry, SharedConst.InteractionDistance, true))
{
StopFollow(true);
return;
}
mFollowArrivedTimer = 1000;
}
else
mFollowArrivedTimer -= diff;
}
}
void UpdateDespawn(uint diff)
{
if (mDespawnState <= 1 || mDespawnState > 3)
return;
if (mDespawnTime < diff)
{
if (mDespawnState == 2)
{
me.SetVisible(false);
mDespawnTime = 5000;
mDespawnState++;
}
else
me.DespawnOrUnsummon(0, TimeSpan.FromSeconds(mRespawnTime));
}
else
mDespawnTime -= diff;
}
public override void Reset() public override void Reset()
{ {
if (!HasEscortState(SmartEscortState.Escorting))//dont mess up escort movement after combat if (!HasEscortState(SmartEscortState.Escorting))//dont mess up escort movement after combat