mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-02-07 01:18:55 +01:00
Core/AI: reduce differences in ScriptedEscortAI between 4.x and 335
This commit is contained in:
@@ -174,7 +174,7 @@ bool EscortAI::IsPlayerOrGroupInRange()
|
||||
void EscortAI::UpdateAI(uint32 diff)
|
||||
{
|
||||
// Waypoint Updating
|
||||
if (HasEscortState(STATE_ESCORT_ESCORTING) && !me->IsInCombat() && !HasEscortState(STATE_ESCORT_RETURNING))
|
||||
if (HasEscortState(STATE_ESCORT_ESCORTING) && !me->IsEngaged() && !HasEscortState(STATE_ESCORT_RETURNING))
|
||||
{
|
||||
if (_pauseTimer <= diff)
|
||||
{
|
||||
@@ -227,7 +227,7 @@ void EscortAI::UpdateAI(uint32 diff)
|
||||
}
|
||||
|
||||
// Check if player or any member of his group is within range
|
||||
if (_despawnAtFar && HasEscortState(STATE_ESCORT_ESCORTING) && _playerGUID && !me->GetVictim() && !HasEscortState(STATE_ESCORT_RETURNING))
|
||||
if (_despawnAtFar && HasEscortState(STATE_ESCORT_ESCORTING) && _playerGUID && !me->IsEngaged() && !HasEscortState(STATE_ESCORT_RETURNING))
|
||||
{
|
||||
if (_playerCheckTimer <= diff)
|
||||
{
|
||||
@@ -239,10 +239,13 @@ void EscortAI::UpdateAI(uint32 diff)
|
||||
if (CreatureData const* creatureData = me->GetCreatureData())
|
||||
isEscort = (sWorld->getBoolConfig(CONFIG_RESPAWN_DYNAMIC_ESCORTNPC) && (creatureData->spawnGroupData->flags & SPAWNGROUP_FLAG_ESCORTQUESTNPC));
|
||||
|
||||
if (_instantRespawn && !isEscort)
|
||||
me->DespawnOrUnsummon(0, Seconds(1));
|
||||
else if (_instantRespawn && isEscort)
|
||||
me->GetMap()->Respawn(SPAWN_TYPE_CREATURE, me->GetSpawnId());
|
||||
if (_instantRespawn)
|
||||
{
|
||||
if (!isEscort)
|
||||
me->DespawnOrUnsummon(0s, 1s);
|
||||
else
|
||||
me->GetMap()->Respawn(SPAWN_TYPE_CREATURE, me->GetSpawnId());
|
||||
}
|
||||
else
|
||||
me->DespawnOrUnsummon();
|
||||
|
||||
@@ -368,16 +371,13 @@ void EscortAI::SetRun(bool on)
|
||||
void EscortAI::Start(bool isActiveAttacker /* = true*/, bool run /* = false */, ObjectGuid playerGUID /* = 0 */, Quest const* quest /* = nullptr */, bool instantRespawn /* = false */, bool canLoopPath /* = false */, bool resetWaypoints /* = true */)
|
||||
{
|
||||
// Queue respawn from the point it starts
|
||||
if (Map* map = me->GetMap())
|
||||
if (CreatureData const* cdata = me->GetCreatureData())
|
||||
{
|
||||
if (CreatureData const* cdata = me->GetCreatureData())
|
||||
{
|
||||
if (sWorld->getBoolConfig(CONFIG_RESPAWN_DYNAMIC_ESCORTNPC) && (cdata->spawnGroupData->flags & SPAWNGROUP_FLAG_ESCORTQUESTNPC))
|
||||
me->SaveRespawnTime(me->GetRespawnDelay());
|
||||
}
|
||||
if (sWorld->getBoolConfig(CONFIG_RESPAWN_DYNAMIC_ESCORTNPC) && (cdata->spawnGroupData->flags & SPAWNGROUP_FLAG_ESCORTQUESTNPC))
|
||||
me->SaveRespawnTime(me->GetRespawnDelay());
|
||||
}
|
||||
|
||||
if (me->GetVictim())
|
||||
if (me->IsEngaged())
|
||||
{
|
||||
TC_LOG_ERROR("scripts", "EscortAI::Start: (script: %s, creature entry: %u) attempts to Start while in combat", me->GetScriptName().c_str(), me->GetEntry());
|
||||
return;
|
||||
|
||||
@@ -132,7 +132,7 @@ void WaypointMovementGenerator<Creature>::HandleMovementInformationHooks(Creatur
|
||||
|
||||
// Inform the AI that the path has ended.
|
||||
if (creature->IsAIEnabled)
|
||||
creature->AI()->WaypointPathEnded(_path->Nodes.at(_currentNode).Id, _path->Id);
|
||||
creature->AI()->WaypointPathEnded(waypoint.Id, _path->Id);
|
||||
}
|
||||
|
||||
if (waypoint.EventId && urand(0, 99) < waypoint.EventChance)
|
||||
@@ -142,6 +142,8 @@ void WaypointMovementGenerator<Creature>::HandleMovementInformationHooks(Creatur
|
||||
creature->GetMap()->ScriptsStart(sWaypointScripts, waypoint.EventId, creature, nullptr);
|
||||
}
|
||||
|
||||
creature->UpdateCurrentWaypointInfo(waypoint.Id, _path->Id);
|
||||
|
||||
// inform AI
|
||||
if (creature->IsAIEnabled)
|
||||
{
|
||||
@@ -149,8 +151,6 @@ void WaypointMovementGenerator<Creature>::HandleMovementInformationHooks(Creatur
|
||||
creature->AI()->WaypointReached(waypoint.Id, _path->Id);
|
||||
}
|
||||
|
||||
creature->UpdateCurrentWaypointInfo(waypoint.Id, _path->Id);
|
||||
|
||||
// All hooks called and infos updated. Time to increment the waypoint node id
|
||||
if (_path && !_path->Nodes.empty()) // ensure that the path has not been changed in one of the hooks.
|
||||
_currentNode = (_currentNode + 1) % _path->Nodes.size();
|
||||
|
||||
Reference in New Issue
Block a user