Scripts/Outland: Fix npc_ancestral_wolf not starting waypoint

Port From (https://github.com/TrinityCore/TrinityCore/commit/913f0903a3264f14ea44356bc86dade81348a546)
This commit is contained in:
hondacrx
2022-01-04 20:01:29 -05:00
parent 4e5db9135d
commit 6fe5a31fab
2 changed files with 71 additions and 66 deletions
+1 -1
View File
@@ -192,7 +192,7 @@ namespace Game.AI
if (summon != null) if (summon != null)
{ {
// Only apply this to specific types of summons // Only apply this to specific types of summons
if (!summon.GetVehicle() && ShouldFollowOnSpawn(summon.m_Properties)) if (!summon.GetVehicle() && ShouldFollowOnSpawn(summon.m_Properties) && summon.CanFollowOwner())
{ {
Unit owner = summon.GetCharmerOrOwner(); Unit owner = summon.GetCharmerOrOwner();
if (owner != null) if (owner != null)
+70 -65
View File
@@ -31,6 +31,7 @@ namespace Game.Entities
m_summonerGUID = owner != null ? owner.GetGUID() : ObjectGuid.Empty; m_summonerGUID = owner != null ? owner.GetGUID() : ObjectGuid.Empty;
UnitTypeMask |= UnitTypeMask.Summon; UnitTypeMask |= UnitTypeMask.Summon;
m_canFollowOwner = true;
} }
public WorldObject GetSummoner() public WorldObject GetSummoner()
@@ -46,7 +47,7 @@ namespace Game.Entities
return null; return null;
} }
public Creature GetSummonerCreatureBase() public Creature GetSummonerCreatureBase()
{ {
return !m_summonerGUID.IsEmpty() ? ObjectAccessor.GetCreature(this, m_summonerGUID) : null; return !m_summonerGUID.IsEmpty() ? ObjectAccessor.GetCreature(this, m_summonerGUID) : null;
@@ -60,7 +61,7 @@ namespace Game.Entities
return null; return null;
} }
public override void Update(uint diff) public override void Update(uint diff)
{ {
base.Update(diff); base.Update(diff);
@@ -77,6 +78,19 @@ namespace Game.Entities
case TempSummonType.DeadDespawn: case TempSummonType.DeadDespawn:
break; break;
case TempSummonType.TimedDespawn: case TempSummonType.TimedDespawn:
{
if (m_timer <= diff)
{
UnSummon();
return;
}
m_timer -= diff;
break;
}
case TempSummonType.TimedDespawnOutOfCombat:
{
if (!IsInCombat())
{ {
if (m_timer <= diff) if (m_timer <= diff)
{ {
@@ -85,89 +99,76 @@ namespace Game.Entities
} }
m_timer -= diff; m_timer -= diff;
break;
} }
case TempSummonType.TimedDespawnOutOfCombat: else if (m_timer != m_lifetime)
{ m_timer = m_lifetime;
if (!IsInCombat())
{
if (m_timer <= diff)
{
UnSummon();
return;
}
m_timer -= diff; break;
} }
else if (m_timer != m_lifetime)
m_timer = m_lifetime;
break;
}
case TempSummonType.CorpseTimedDespawn: case TempSummonType.CorpseTimedDespawn:
{
if (m_deathState == DeathState.Corpse)
{ {
if (m_deathState == DeathState.Corpse) if (m_timer <= diff)
{ {
if (m_timer <= diff) UnSummon();
{ return;
UnSummon();
return;
}
m_timer -= diff;
} }
break;
m_timer -= diff;
} }
break;
}
case TempSummonType.CorpseDespawn: case TempSummonType.CorpseDespawn:
{
// if m_deathState is DEAD, CORPSE was skipped
if (m_deathState == DeathState.Corpse)
{ {
// if m_deathState is DEAD, CORPSE was skipped UnSummon();
if (m_deathState == DeathState.Corpse) return;
{
UnSummon();
return;
}
break;
} }
break;
}
case TempSummonType.TimedOrCorpseDespawn: case TempSummonType.TimedOrCorpseDespawn:
{
if (m_deathState == DeathState.Corpse)
{ {
if (m_deathState == DeathState.Corpse) UnSummon();
return;
}
if (!IsInCombat())
{
if (m_timer <= diff)
{ {
UnSummon(); UnSummon();
return; return;
} }
else
if (!IsInCombat()) m_timer -= diff;
{
if (m_timer <= diff)
{
UnSummon();
return;
}
else
m_timer -= diff;
}
else if (m_timer != m_lifetime)
m_timer = m_lifetime;
break;
} }
else if (m_timer != m_lifetime)
m_timer = m_lifetime;
break;
}
case TempSummonType.TimedOrDeadDespawn: case TempSummonType.TimedOrDeadDespawn:
{
if (!IsInCombat() && IsAlive())
{ {
if (!IsInCombat() && IsAlive()) if (m_timer <= diff)
{ {
if (m_timer <= diff) UnSummon();
{ return;
UnSummon();
return;
}
else
m_timer -= diff;
} }
else if (m_timer != m_lifetime) else
m_timer = m_lifetime; m_timer -= diff;
break;
} }
else if (m_timer != m_lifetime)
m_timer = m_lifetime;
break;
}
default: default:
UnSummon(); UnSummon();
Log.outError(LogFilter.Unit, "Temporary summoned creature (entry: {0}) have unknown type {1} of ", GetEntry(), m_type); Log.outError(LogFilter.Unit, "Temporary summoned creature (entry: {0}) have unknown type {1} of ", GetEntry(), m_type);
@@ -190,7 +191,7 @@ namespace Game.Entities
{ {
SetLevel(owner.GetLevel()); SetLevel(owner.GetLevel());
if (owner.IsTypeId(TypeId.Player)) if (owner.IsTypeId(TypeId.Player))
m_ControlledByPlayer = true; m_ControlledByPlayer = true;
} }
@@ -227,9 +228,9 @@ namespace Game.Entities
if (owner != null) if (owner != null)
{ {
if (owner.IsCreature()) if (owner.IsCreature())
owner.ToCreature().GetAI()?.JustSummoned(this); owner.ToCreature().GetAI()?.JustSummoned(this);
else if (owner.IsGameObject()) else if (owner.IsGameObject())
owner.ToGameObject().GetAI()?.JustSummoned(this); owner.ToGameObject().GetAI()?.JustSummoned(this);
if (IsAIEnabled()) if (IsAIEnabled())
GetAI().IsSummonedBy(owner); GetAI().IsSummonedBy(owner);
@@ -307,11 +308,15 @@ namespace Game.Entities
public uint GetTimer() { return m_timer; } public uint GetTimer() { return m_timer; }
public bool CanFollowOwner() { return m_canFollowOwner; }
public void SetCanFollowOwner(bool can) { m_canFollowOwner = can; }
public SummonPropertiesRecord m_Properties; public SummonPropertiesRecord m_Properties;
TempSummonType m_type; TempSummonType m_type;
uint m_timer; uint m_timer;
uint m_lifetime; uint m_lifetime;
ObjectGuid m_summonerGUID; ObjectGuid m_summonerGUID;
bool m_canFollowOwner;
} }
public class Minion : TempSummon public class Minion : TempSummon