Core/Movement: backported cleanup for determining follow movement on appearing instead of calling evade modes right away

This commit is contained in:
Ovahlord
2020-01-31 06:34:18 +01:00
parent a246b5a342
commit eaa635ab32
3 changed files with 51 additions and 5 deletions

View File

@@ -186,6 +186,56 @@ void CreatureAI::TriggerAlert(Unit const* who) const
me->SetFacingTo(me->GetAngle(who));
}
// adapted from logic in Spell:EFfectSummonType before commit 8499434
static bool ShouldFollowOnSpawn(SummonPropertiesEntry const* properties)
{
// Summons without SummonProperties are generally scripted summons that don't belong to any owner
if (!properties)
return false;
switch (properties->Control)
{
case SUMMON_CATEGORY_PET:
return true;
case SUMMON_CATEGORY_WILD:
case SUMMON_CATEGORY_ALLY:
case SUMMON_CATEGORY_UNK:
if (properties->Flags & 512)
return true;
switch (properties->Title)
{
case SUMMON_TYPE_PET:
case SUMMON_TYPE_GUARDIAN:
case SUMMON_TYPE_GUARDIAN2:
case SUMMON_TYPE_MINION:
case SUMMON_TYPE_MINIPET:
return true;
default:
return false;
}
default:
return false;
}
}
void CreatureAI::JustAppeared()
{
if (!me->IsInCombat())
{
if (TempSummon* summon = me->ToTempSummon())
{
// Only apply this to specific types of summons
if (!summon->GetVehicle() && ShouldFollowOnSpawn(summon->m_Properties))
{
if (Unit* owner = summon->GetCharmerOrOwner())
{
summon->GetMotionMaster()->Clear();
summon->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, summon->GetFollowAngle());
}
}
}
}
}
void CreatureAI::EnterEvadeMode(EvadeReason why)
{
if (!_EnterEvadeMode(why))

View File

@@ -143,7 +143,7 @@ class TC_GAME_API CreatureAI : public UnitAI
virtual bool IsEscorted() const { return false; }
// Called when creature appears in the world (spawn, respawn, grid load etc...)
virtual void JustAppeared() { }
virtual void JustAppeared();
// Called at waypoint reached or point movement finished
virtual void MovementInform(uint32 /*type*/, uint32 /*id*/) { }

View File

@@ -1929,8 +1929,6 @@ void Spell::EffectSummonType(SpellEffIndex effIndex)
summon->SetUInt32Value(UNIT_NPC_FLAGS, summon->GetCreatureTemplate()->npcflag);
summon->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
summon->AI()->EnterEvadeMode();
break;
}
default:
@@ -5383,8 +5381,6 @@ void Spell::SummonGuardian(uint32 i, uint32 entry, SummonPropertiesEntry const*
summon->SetDisplayId(1126); // modelid1
}
summon->AI()->EnterEvadeMode();
ExecuteLogEffectSummonObject(i, summon);
}
}