hondacrx
2021-12-07 20:42:47 -05:00
parent b7e4c2fd76
commit c37e1c9f7d
17 changed files with 91 additions and 46 deletions
+1 -1
View File
@@ -1415,7 +1415,7 @@ namespace Game.Entities
Map map = GetMap();
if (map != null)
{
TempSummon summon = map.SummonCreature(entry, pos, null, despawnTime, ToUnit(), spellId, vehId, privateObjectOwner);
TempSummon summon = map.SummonCreature(entry, pos, null, despawnTime, this, spellId, vehId, privateObjectOwner);
if (summon != null)
{
summon.SetTempSummonType(despawnType);
+37 -12
View File
@@ -24,7 +24,7 @@ namespace Game.Entities
{
public class TempSummon : Creature
{
public TempSummon(SummonPropertiesRecord properties, Unit owner, bool isWorldObject) : base(isWorldObject)
public TempSummon(SummonPropertiesRecord properties, WorldObject owner, bool isWorldObject) : base(isWorldObject)
{
m_Properties = properties;
m_type = TempSummonType.ManualDespawn;
@@ -33,15 +33,33 @@ namespace Game.Entities
UnitTypeMask |= UnitTypeMask.Summon;
}
public Unit GetSummoner()
public WorldObject GetSummoner()
{
return !m_summonerGUID.IsEmpty() ? Global.ObjAccessor.GetUnit(this, m_summonerGUID) : null;
return !m_summonerGUID.IsEmpty() ? Global.ObjAccessor.GetWorldObject(this, m_summonerGUID) : null;
}
public Unit GetSummonerUnit()
{
WorldObject summoner = GetSummoner();
if (summoner != null)
return summoner.ToUnit();
return null;
}
public Creature GetSummonerCreatureBase()
{
return !m_summonerGUID.IsEmpty() ? ObjectAccessor.GetCreature(this, m_summonerGUID) : null;
}
public GameObject GetSummonerGameObject()
{
WorldObject summoner = GetSummoner();
if (summoner != null)
return summoner.ToGameObject();
return null;
}
public override void Update(uint diff)
{
@@ -167,8 +185,7 @@ namespace Game.Entities
if (m_type == TempSummonType.ManualDespawn)
m_type = (duration == 0) ? TempSummonType.DeadDespawn : TempSummonType.TimedDespawn;
Unit owner = GetSummoner();
Unit owner = GetSummonerUnit();
if (owner != null && IsTrigger() && m_spells[0] != 0)
{
SetLevel(owner.GetLevel());
@@ -206,11 +223,14 @@ namespace Game.Entities
public virtual void InitSummon()
{
Unit owner = GetSummoner();
WorldObject owner = GetSummoner();
if (owner != null)
{
if (owner.IsTypeId(TypeId.Unit) && owner.ToCreature().IsAIEnabled())
owner.ToCreature().GetAI().JustSummoned(this);
if (owner.IsCreature())
owner.ToCreature().GetAI()?.JustSummoned(this);
else if (owner.IsGameObject())
owner.ToGameObject().GetAI()?.JustSummoned(this);
if (IsAIEnabled())
GetAI().IsSummonedBy(owner);
}
@@ -244,9 +264,14 @@ namespace Game.Entities
return;
}
Unit owner = GetSummoner();
if (owner != null && owner.IsTypeId(TypeId.Unit) && owner.ToCreature().IsAIEnabled())
owner.ToCreature().GetAI().SummonedCreatureDespawn(this);
WorldObject owner = GetSummoner();
if (owner != null)
{
if (owner.IsCreature())
owner.ToCreature().GetAI()?.SummonedCreatureDespawn(this);
else if (owner.IsGameObject())
owner.ToGameObject().GetAI()?.SummonedCreatureDespawn(this);
}
AddObjectToRemoveList();
}
@@ -261,7 +286,7 @@ namespace Game.Entities
int slot = m_Properties.Slot;
if (slot > 0)
{
Unit owner = GetSummoner();
Unit owner = GetSummonerUnit();
if (owner != null)
if (owner.m_SummonSlot[slot] == GetGUID())
owner.m_SummonSlot[slot].Clear();
+7 -3
View File
@@ -876,10 +876,14 @@ namespace Game.Entities
TempSummon summon = creature.ToTempSummon();
if (summon != null)
{
Unit summoner = summon.GetSummoner();
WorldObject summoner = summon.GetSummoner();
if (summoner != null)
if (summoner.IsTypeId(TypeId.Unit) && summoner.IsAIEnabled())
summoner.ToCreature().GetAI().SummonedCreatureDies(creature, attacker);
{
if (summoner.IsCreature())
summoner.ToCreature().GetAI()?.SummonedCreatureDies(creature, attacker);
else if (summoner.IsGameObject())
summoner.ToGameObject().GetAI()?.SummonedCreatureDies(creature, attacker);
}
}
// Dungeon specific stuff, only applies to players killing creatures