mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-19 17:05:44 +01:00
Core/Objects: Move personal summon handling from TemporarySummon/GameObject to WorldObject and check it using dedicated guid field
(cherry picked from commit 1082a6645e)
This commit is contained in:
@@ -374,21 +374,14 @@ void ThreatManager::AddThreat(Unit* target, float amount, SpellInfo const* spell
|
||||
return;
|
||||
amount = 0.0f;
|
||||
}
|
||||
else if (TempSummon* tempSummonVictim = target->ToTempSummon())
|
||||
|
||||
// If victim is personal spawn, redirect all aggro to summoner
|
||||
if (target->IsPrivateObject() && GetOwner()->IsPrivateObject() && GetOwner()->CanSeeOrDetect(target))
|
||||
{
|
||||
if (tempSummonVictim->IsVisibleBySummonerOnly())
|
||||
if (Unit* privateObjectOwner = ObjectAccessor::GetUnit(*GetOwner(), target->GetPrivateObjectOwner()))
|
||||
{
|
||||
if (Unit* tempSummonSummoner = tempSummonVictim->GetSummonerUnit())
|
||||
{
|
||||
// Personnal Spawns from same summoner can aggro each other
|
||||
if (!_owner->ToTempSummon() ||
|
||||
!_owner->ToTempSummon()->IsVisibleBySummonerOnly() ||
|
||||
tempSummonVictim->GetSummonerGUID() != GetOwner()->ToTempSummon()->GetSummonerGUID())
|
||||
{
|
||||
AddThreat(tempSummonSummoner, amount, spell, ignoreModifiers, ignoreRedirects);
|
||||
amount = 0.0f;
|
||||
}
|
||||
}
|
||||
AddThreat(privateObjectOwner, amount, spell, ignoreModifiers, ignoreRedirects);
|
||||
amount = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
TempSummon::TempSummon(SummonPropertiesEntry const* properties, WorldObject* owner, bool isWorldObject) :
|
||||
Creature(isWorldObject), m_Properties(properties), m_type(TEMPSUMMON_MANUAL_DESPAWN),
|
||||
m_timer(0), m_lifetime(0), m_canFollowOwner(true), m_visibleBySummonerOnly(false)
|
||||
m_timer(0), m_lifetime(0), m_canFollowOwner(true)
|
||||
{
|
||||
if (owner)
|
||||
m_summonerGUID = owner->GetGUID();
|
||||
|
||||
@@ -54,9 +54,6 @@ class TC_GAME_API TempSummon : public Creature
|
||||
uint32 GetTimer() const { return m_timer; }
|
||||
bool CanFollowOwner() const { return m_canFollowOwner; }
|
||||
void SetCanFollowOwner(bool can) { m_canFollowOwner = can; }
|
||||
void SetVisibleBySummonerOnly(bool visibleBySummonerOnly) { m_visibleBySummonerOnly = visibleBySummonerOnly; }
|
||||
bool IsVisibleBySummonerOnly() const { return m_visibleBySummonerOnly; }
|
||||
|
||||
SummonPropertiesEntry const* const m_Properties;
|
||||
|
||||
std::string GetDebugInfo() const override;
|
||||
@@ -66,7 +63,6 @@ class TC_GAME_API TempSummon : public Creature
|
||||
uint32 m_lifetime;
|
||||
ObjectGuid m_summonerGUID;
|
||||
bool m_canFollowOwner;
|
||||
bool m_visibleBySummonerOnly;
|
||||
};
|
||||
|
||||
class TC_GAME_API Minion : public TempSummon
|
||||
|
||||
@@ -1547,6 +1547,9 @@ bool WorldObject::CanSeeOrDetect(WorldObject const* obj, bool implicitDetect, bo
|
||||
if (this == obj)
|
||||
return true;
|
||||
|
||||
if (!obj->GetPrivateObjectOwner().IsEmpty())
|
||||
return GetGUID() == obj->GetPrivateObjectOwner() || GetPrivateObjectOwner() == obj->GetPrivateObjectOwner();
|
||||
|
||||
if (obj->IsNeverVisible(implicitDetect) || CanNeverSee(obj))
|
||||
return false;
|
||||
|
||||
@@ -1582,15 +1585,8 @@ bool WorldObject::CanSeeOrDetect(WorldObject const* obj, bool implicitDetect, bo
|
||||
|
||||
WorldObject const* viewpoint = this;
|
||||
if (Player const* player = ToPlayer())
|
||||
{
|
||||
viewpoint = player->GetViewpoint();
|
||||
|
||||
if (Creature const* creature = obj->ToCreature())
|
||||
if (TempSummon const* tempSummon = creature->ToTempSummon())
|
||||
if (tempSummon->IsVisibleBySummonerOnly() && GetGUID() != tempSummon->GetSummonerGUID())
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!viewpoint)
|
||||
viewpoint = this;
|
||||
|
||||
@@ -1858,7 +1854,7 @@ void WorldObject::AddObjectToRemoveList()
|
||||
map->AddObjectToRemoveList(this);
|
||||
}
|
||||
|
||||
TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropertiesEntry const* properties /*= nullptr*/, uint32 duration /*= 0*/, WorldObject* summoner /*= nullptr*/, uint32 spellId /*= 0*/, uint32 vehId /*= 0*/, bool visibleBySummonerOnly /*= false*/)
|
||||
TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropertiesEntry const* properties /*= nullptr*/, uint32 duration /*= 0*/, WorldObject* summoner /*= nullptr*/, uint32 spellId /*= 0*/, uint32 vehId /*= 0*/, bool personalSpawn /*= false*/)
|
||||
{
|
||||
uint32 mask = UNIT_MASK_SUMMON;
|
||||
if (properties)
|
||||
@@ -1946,7 +1942,8 @@ TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropert
|
||||
|
||||
summon->InitStats(duration);
|
||||
|
||||
summon->SetVisibleBySummonerOnly(visibleBySummonerOnly);
|
||||
if (personalSpawn && summoner)
|
||||
summon->SetPrivateObjectOwner(summoner->IsPrivateObject() ? summoner->GetPrivateObjectOwner() : summoner->GetGUID());
|
||||
|
||||
AddToMap(summon->ToCreature());
|
||||
summon->InitSummon();
|
||||
@@ -1998,11 +1995,11 @@ void WorldObject::ClearZoneScript()
|
||||
m_zoneScript = nullptr;
|
||||
}
|
||||
|
||||
TempSummon* WorldObject::SummonCreature(uint32 entry, Position const& pos, TempSummonType despawnType /*= TEMPSUMMON_MANUAL_DESPAWN*/, Milliseconds despawnTime /*= 0s*/, uint32 /*vehId = 0*/, uint32 spellId /*= 0*/, bool visibleBySummonerOnly /*= false*/)
|
||||
TempSummon* WorldObject::SummonCreature(uint32 entry, Position const& pos, TempSummonType despawnType /*= TEMPSUMMON_MANUAL_DESPAWN*/, Milliseconds despawnTime /*= 0s*/, uint32 /*vehId = 0*/, uint32 spellId /*= 0*/, bool personalSpawn /* = false */)
|
||||
{
|
||||
if (Map* map = FindMap())
|
||||
{
|
||||
if (TempSummon* summon = map->SummonCreature(entry, pos, nullptr, despawnTime.count(), this, spellId, 0, visibleBySummonerOnly))
|
||||
if (TempSummon* summon = map->SummonCreature(entry, pos, nullptr, despawnTime.count(), this, spellId, 0, personalSpawn))
|
||||
{
|
||||
summon->SetTempSummonType(despawnType);
|
||||
return summon;
|
||||
@@ -2012,13 +2009,13 @@ TempSummon* WorldObject::SummonCreature(uint32 entry, Position const& pos, TempS
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
TempSummon* WorldObject::SummonCreature(uint32 id, float x, float y, float z, float o /*= 0*/, TempSummonType despawnType /*= TEMPSUMMON_MANUAL_DESPAWN*/, Milliseconds despawnTime /*= 0s*/, bool visibleBySummonerOnly /*= false*/)
|
||||
TempSummon* WorldObject::SummonCreature(uint32 id, float x, float y, float z, float o /*= 0*/, TempSummonType despawnType /*= TEMPSUMMON_MANUAL_DESPAWN*/, Milliseconds despawnTime /*= 0s*/, bool personalSpawn /*= false*/)
|
||||
{
|
||||
if (!x && !y && !z)
|
||||
GetClosePoint(x, y, z, GetCombatReach());
|
||||
if (!o)
|
||||
o = GetOrientation();
|
||||
return SummonCreature(id, { x,y,z,o }, despawnType, despawnTime, 0, 0, visibleBySummonerOnly);
|
||||
return SummonCreature(id, { x,y,z,o }, despawnType, despawnTime, 0, 0, personalSpawn);
|
||||
}
|
||||
|
||||
GameObject* WorldObject::SummonGameObject(uint32 entry, Position const& pos, QuaternionData const& rot, Seconds respawnTime, GOSummonType summonType)
|
||||
|
||||
@@ -418,8 +418,8 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation
|
||||
void ClearZoneScript();
|
||||
ZoneScript* GetZoneScript() const { return m_zoneScript; }
|
||||
|
||||
TempSummon* SummonCreature(uint32 entry, Position const& pos, TempSummonType despawnType = TEMPSUMMON_MANUAL_DESPAWN, Milliseconds despawnTime = 0s, uint32 vehId = 0, uint32 spellId = 0, bool visibleBySummonerOnly = false);
|
||||
TempSummon* SummonCreature(uint32 entry, float x, float y, float z, float o = 0, TempSummonType despawnType = TEMPSUMMON_MANUAL_DESPAWN, Milliseconds despawnTime = 0s, bool visibleBySummonerOnly = false);
|
||||
TempSummon* SummonCreature(uint32 entry, Position const& pos, TempSummonType despawnType = TEMPSUMMON_MANUAL_DESPAWN, Milliseconds despawnTime = 0s, uint32 vehId = 0, uint32 spellId = 0, bool personalSpawn = false);
|
||||
TempSummon* SummonCreature(uint32 entry, float x, float y, float z, float o = 0, TempSummonType despawnType = TEMPSUMMON_MANUAL_DESPAWN, Milliseconds despawnTime = 0s, bool personalSpawn = false);
|
||||
GameObject* SummonGameObject(uint32 entry, Position const& pos, QuaternionData const& rot, Seconds respawnTime, GOSummonType summonType = GO_SUMMON_TIMED_OR_CORPSE_DESPAWN);
|
||||
GameObject* SummonGameObject(uint32 entry, float x, float y, float z, float ang, QuaternionData const& rot, Seconds respawnTime, GOSummonType summonType = GO_SUMMON_TIMED_OR_CORPSE_DESPAWN);
|
||||
Creature* SummonTrigger(float x, float y, float z, float ang, Milliseconds despawnTime, CreatureAI* (*GetAI)(Creature*) = nullptr);
|
||||
@@ -546,6 +546,11 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation
|
||||
// Event handler
|
||||
EventProcessor m_Events;
|
||||
|
||||
// Watcher
|
||||
bool IsPrivateObject() const { return !_privateObjectOwner.IsEmpty(); }
|
||||
ObjectGuid GetPrivateObjectOwner() const { return _privateObjectOwner; }
|
||||
void SetPrivateObjectOwner(ObjectGuid const& owner) { _privateObjectOwner = owner; }
|
||||
|
||||
protected:
|
||||
std::string m_name;
|
||||
bool m_isActive;
|
||||
@@ -582,6 +587,9 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation
|
||||
uint32 m_phaseMask; // in area phase state
|
||||
|
||||
uint16 m_notifyflags;
|
||||
|
||||
ObjectGuid _privateObjectOwner;
|
||||
|
||||
virtual bool _IsWithinDist(WorldObject const* obj, float dist2compare, bool is3D, bool incOwnRadius = true, bool incTargetRadius = true) const;
|
||||
|
||||
bool CanNeverSee(WorldObject const* obj) const;
|
||||
|
||||
@@ -1375,7 +1375,7 @@ namespace Trinity
|
||||
|
||||
bool operator()(Creature* u)
|
||||
{
|
||||
if (u->getDeathState() != DEAD && u->GetEntry() == i_entry && u->IsAlive() == i_alive && u->GetGUID() != i_obj.GetGUID() && i_obj.IsWithinDistInMap(u, i_range))
|
||||
if (u->getDeathState() != DEAD && u->GetEntry() == i_entry && u->IsAlive() == i_alive && u->GetGUID() != i_obj.GetGUID() && i_obj.IsWithinDistInMap(u, i_range) && u->CanSeeOrDetect(&i_obj))
|
||||
{
|
||||
i_range = i_obj.GetDistance(u); // use found unit range as new range limit for next check
|
||||
return true;
|
||||
|
||||
@@ -505,7 +505,7 @@ class TC_GAME_API Map : public GridRefManager<NGridType>
|
||||
|
||||
void UpdateIteratorBack(Player* player);
|
||||
|
||||
TempSummon* SummonCreature(uint32 entry, Position const& pos, SummonPropertiesEntry const* properties = nullptr, uint32 duration = 0, WorldObject* summoner = nullptr, uint32 spellId = 0, uint32 vehId = 0, bool visibleOnlyBySummoner = false);
|
||||
TempSummon* SummonCreature(uint32 entry, Position const& pos, SummonPropertiesEntry const* properties = nullptr, uint32 duration = 0, WorldObject* summoner = nullptr, uint32 spellId = 0, uint32 vehId = 0, bool personalSpawn = false);
|
||||
void SummonCreatureGroup(uint8 group, std::list<TempSummon*>* list = nullptr);
|
||||
Player* GetPlayer(ObjectGuid const& guid);
|
||||
Corpse* GetCorpse(ObjectGuid const& guid);
|
||||
|
||||
Reference in New Issue
Block a user