aboutsummaryrefslogtreecommitdiff
path: root/src/server/game
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game')
-rw-r--r--src/server/game/AI/CoreAI/GameObjectAI.h7
-rw-r--r--src/server/game/AI/CoreAI/PassiveAI.cpp2
-rw-r--r--src/server/game/AI/CoreAI/PassiveAI.h2
-rw-r--r--src/server/game/AI/CreatureAI.h2
-rw-r--r--src/server/game/AI/SmartScripts/SmartAI.cpp4
-rw-r--r--src/server/game/AI/SmartScripts/SmartAI.h2
-rw-r--r--src/server/game/AI/SmartScripts/SmartScript.cpp6
-rw-r--r--src/server/game/Entities/Creature/TemporarySummon.cpp50
-rw-r--r--src/server/game/Entities/Creature/TemporarySummon.h6
-rw-r--r--src/server/game/Entities/Object/Object.cpp14
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp15
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp2
-rw-r--r--src/server/game/Maps/Map.h2
-rw-r--r--src/server/game/Spells/Spell.cpp2
14 files changed, 81 insertions, 35 deletions
diff --git a/src/server/game/AI/CoreAI/GameObjectAI.h b/src/server/game/AI/CoreAI/GameObjectAI.h
index 954c7c28427..4ff14eefd82 100644
--- a/src/server/game/AI/CoreAI/GameObjectAI.h
+++ b/src/server/game/AI/CoreAI/GameObjectAI.h
@@ -24,6 +24,7 @@
#include "Optional.h"
#include "QuestDef.h"
+class Creature;
class GameObject;
class Unit;
class SpellInfo;
@@ -93,6 +94,12 @@ class TC_GAME_API GameObjectAI
// Called when spell hits a target
virtual void SpellHitTarget(Unit* /*target*/, SpellInfo const* /*spellInfo*/) { }
virtual void SpellHitTargetGameObject(GameObject* /*target*/, SpellInfo const* /*spellInfo*/) { }
+
+ // Called when the gameobject summon successfully other creature
+ virtual void JustSummoned(Creature* /*summon*/) { }
+
+ virtual void SummonedCreatureDespawn(Creature* /*summon*/) { }
+ virtual void SummonedCreatureDies(Creature* /*summon*/, Unit* /*killer*/) { }
};
class TC_GAME_API NullGameObjectAI : public GameObjectAI
diff --git a/src/server/game/AI/CoreAI/PassiveAI.cpp b/src/server/game/AI/CoreAI/PassiveAI.cpp
index 4995facfb97..de74f43f638 100644
--- a/src/server/game/AI/CoreAI/PassiveAI.cpp
+++ b/src/server/game/AI/CoreAI/PassiveAI.cpp
@@ -101,7 +101,7 @@ int32 CritterAI::Permissible(Creature const* creature)
return PERMIT_BASE_NO;
}
-void TriggerAI::IsSummonedBy(Unit* summoner)
+void TriggerAI::IsSummonedBy(WorldObject* summoner)
{
if (me->m_spells[0])
{
diff --git a/src/server/game/AI/CoreAI/PassiveAI.h b/src/server/game/AI/CoreAI/PassiveAI.h
index f7aae9d83f5..ba8e4d1279c 100644
--- a/src/server/game/AI/CoreAI/PassiveAI.h
+++ b/src/server/game/AI/CoreAI/PassiveAI.h
@@ -78,7 +78,7 @@ class TC_GAME_API TriggerAI : public NullCreatureAI
{
public:
explicit TriggerAI(Creature* creature) : NullCreatureAI(creature) { }
- void IsSummonedBy(Unit* summoner) override;
+ void IsSummonedBy(WorldObject* summoner) override;
static int32 Permissible(Creature const* creature);
};
diff --git a/src/server/game/AI/CreatureAI.h b/src/server/game/AI/CreatureAI.h
index ad540bcc233..5931b447d06 100644
--- a/src/server/game/AI/CreatureAI.h
+++ b/src/server/game/AI/CreatureAI.h
@@ -125,7 +125,7 @@ class TC_GAME_API CreatureAI : public UnitAI
// Called when the creature summon successfully other creature
virtual void JustSummoned(Creature* /*summon*/) { }
- virtual void IsSummonedBy(Unit* /*summoner*/) { }
+ virtual void IsSummonedBy(WorldObject* /*summoner*/) { }
virtual void SummonedCreatureDespawn(Creature* /*summon*/) { }
virtual void SummonedCreatureDies(Creature* /*summon*/, Unit* /*killer*/) { }
diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp
index 83d07dc78e1..461e3c2b01f 100644
--- a/src/server/game/AI/SmartScripts/SmartAI.cpp
+++ b/src/server/game/AI/SmartScripts/SmartAI.cpp
@@ -636,9 +636,9 @@ void SmartAI::ReceiveEmote(Player* player, uint32 textEmote)
GetScript()->ProcessEventsFor(SMART_EVENT_RECEIVE_EMOTE, player, textEmote);
}
-void SmartAI::IsSummonedBy(Unit* summoner)
+void SmartAI::IsSummonedBy(WorldObject* summoner)
{
- GetScript()->ProcessEventsFor(SMART_EVENT_JUST_SUMMONED, summoner);
+ GetScript()->ProcessEventsFor(SMART_EVENT_JUST_SUMMONED, summoner->ToUnit(), 0, 0, false, nullptr, summoner->ToGameObject());
}
void SmartAI::DamageDealt(Unit* doneTo, uint32& damage, DamageEffectType /*damagetype*/)
diff --git a/src/server/game/AI/SmartScripts/SmartAI.h b/src/server/game/AI/SmartScripts/SmartAI.h
index 152e3cf5b44..9f083a9c9a0 100644
--- a/src/server/game/AI/SmartScripts/SmartAI.h
+++ b/src/server/game/AI/SmartScripts/SmartAI.h
@@ -119,7 +119,7 @@ class TC_GAME_API SmartAI : public CreatureAI
void MovementInform(uint32 MovementType, uint32 Data) override;
// Called when creature is summoned by another unit
- void IsSummonedBy(Unit* summoner) override;
+ void IsSummonedBy(WorldObject* summoner) override;
// Called at any Damage to any victim (before damage apply)
void DamageDealt(Unit* doneTo, uint32& damage, DamageEffectType /*damagetype*/) override;
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp
index 9255d52bd70..825920c5d7d 100644
--- a/src/server/game/AI/SmartScripts/SmartScript.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScript.cpp
@@ -2708,13 +2708,13 @@ void SmartScript::GetTargets(ObjectVector& targets, SmartScriptHolder const& e,
if (!charmerOrOwnerGuid)
if (TempSummon* tempSummon = me->ToTempSummon())
- if (Unit* summoner = tempSummon->GetSummoner())
+ if (WorldObject* summoner = tempSummon->GetSummoner())
charmerOrOwnerGuid = summoner->GetGUID();
if (!charmerOrOwnerGuid)
charmerOrOwnerGuid = me->GetCreatorGUID();
- if (Unit* owner = ObjectAccessor::GetUnit(*me, charmerOrOwnerGuid))
+ if (WorldObject* owner = ObjectAccessor::GetWorldObject(*me, charmerOrOwnerGuid))
targets.push_back(owner);
}
else if (go)
@@ -2726,7 +2726,7 @@ void SmartScript::GetTargets(ObjectVector& targets, SmartScriptHolder const& e,
// Get owner of owner
if (e.target.owner.useCharmerOrOwner && !targets.empty())
{
- Unit* owner = targets.front()->ToUnit();
+ WorldObject* owner = targets.front();
targets.clear();
if (Unit* base = ObjectAccessor::GetUnit(*owner, owner->GetCharmerOrOwnerGUID()))
diff --git a/src/server/game/Entities/Creature/TemporarySummon.cpp b/src/server/game/Entities/Creature/TemporarySummon.cpp
index b68bf43b4a5..6d6e72f9117 100644
--- a/src/server/game/Entities/Creature/TemporarySummon.cpp
+++ b/src/server/game/Entities/Creature/TemporarySummon.cpp
@@ -19,13 +19,15 @@
#include "TemporarySummon.h"
#include "CreatureAI.h"
#include "DBCStructure.h"
+#include "GameObject.h"
+#include "GameObjectAI.h"
#include "Log.h"
#include "Map.h"
#include "ObjectAccessor.h"
#include "Pet.h"
#include "Player.h"
-TempSummon::TempSummon(SummonPropertiesEntry const* properties, Unit* owner, bool isWorldObject) :
+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)
{
@@ -35,9 +37,16 @@ m_timer(0), m_lifetime(0)
m_unitTypeMask |= UNIT_MASK_SUMMON;
}
-Unit* TempSummon::GetSummoner() const
+WorldObject* TempSummon::GetSummoner() const
{
- return m_summonerGUID ? ObjectAccessor::GetUnit(*this, m_summonerGUID) : nullptr;
+ return m_summonerGUID ? ObjectAccessor::GetWorldObject(*this, m_summonerGUID) : nullptr;
+}
+
+Unit* TempSummon::GetSummonerUnit() const
+{
+ if (WorldObject* summoner = GetSummoner())
+ return summoner->ToUnit();
+ return nullptr;
}
Creature* TempSummon::GetSummonerCreatureBase() const
@@ -45,6 +54,13 @@ Creature* TempSummon::GetSummonerCreatureBase() const
return m_summonerGUID ? ObjectAccessor::GetCreature(*this, m_summonerGUID) : nullptr;
}
+GameObject* TempSummon::GetSummonerGameObject() const
+{
+ if (WorldObject* summoner = GetSummoner())
+ return summoner->ToGameObject();
+ return nullptr;
+}
+
void TempSummon::Update(uint32 diff)
{
Creature::Update(diff);
@@ -168,7 +184,7 @@ void TempSummon::InitStats(uint32 duration)
if (m_type == TEMPSUMMON_MANUAL_DESPAWN)
m_type = (duration == 0) ? TEMPSUMMON_DEAD_DESPAWN : TEMPSUMMON_TIMED_DESPAWN;
- Unit* owner = GetSummoner();
+ Unit* owner = GetSummonerUnit();
if (owner && IsTrigger() && m_spells[0])
{
@@ -203,11 +219,19 @@ void TempSummon::InitStats(uint32 duration)
void TempSummon::InitSummon()
{
- Unit* owner = GetSummoner();
+ WorldObject* owner = GetSummoner();
if (owner)
{
- if (owner->GetTypeId() == TYPEID_UNIT && owner->ToCreature()->IsAIEnabled())
- owner->ToCreature()->AI()->JustSummoned(this);
+ if (owner->GetTypeId() == TYPEID_UNIT)
+ {
+ if (owner->ToCreature()->IsAIEnabled())
+ owner->ToCreature()->AI()->JustSummoned(this);
+ }
+ else if (owner->GetTypeId() == TYPEID_GAMEOBJECT)
+ {
+ if (owner->ToGameObject()->AI())
+ owner->ToGameObject()->AI()->JustSummoned(this);
+ }
if (IsAIEnabled())
AI()->IsSummonedBy(owner);
}
@@ -241,9 +265,13 @@ void TempSummon::UnSummon(uint32 msTime)
return;
}
- Unit* owner = GetSummoner();
- if (owner && owner->GetTypeId() == TYPEID_UNIT && owner->ToCreature()->IsAIEnabled())
- owner->ToCreature()->AI()->SummonedCreatureDespawn(this);
+ if (WorldObject * owner = GetSummoner())
+ {
+ if (owner->GetTypeId() == TYPEID_UNIT && owner->ToCreature()->IsAIEnabled())
+ owner->ToCreature()->AI()->SummonedCreatureDespawn(this);
+ else if (owner->GetTypeId() == TYPEID_GAMEOBJECT && owner->ToGameObject()->AI())
+ owner->ToGameObject()->AI()->SummonedCreatureDespawn(this);
+ }
AddObjectToRemoveList();
}
@@ -261,7 +289,7 @@ void TempSummon::RemoveFromWorld()
if (m_Properties)
if (uint32 slot = m_Properties->Slot)
- if (Unit* owner = GetSummoner())
+ if (Unit* owner = GetSummonerUnit())
if (owner->m_SummonSlot[slot] == GetGUID())
owner->m_SummonSlot[slot].Clear();
diff --git a/src/server/game/Entities/Creature/TemporarySummon.h b/src/server/game/Entities/Creature/TemporarySummon.h
index d0ef8cb38e4..de44bda118e 100644
--- a/src/server/game/Entities/Creature/TemporarySummon.h
+++ b/src/server/game/Entities/Creature/TemporarySummon.h
@@ -36,7 +36,7 @@ struct SummonPropertiesEntry;
class TC_GAME_API TempSummon : public Creature
{
public:
- explicit TempSummon(SummonPropertiesEntry const* properties, Unit* owner, bool isWorldObject);
+ explicit TempSummon(SummonPropertiesEntry const* properties, WorldObject* owner, bool isWorldObject);
virtual ~TempSummon() { }
void Update(uint32 time) override;
virtual void InitStats(uint32 lifetime);
@@ -46,8 +46,10 @@ class TC_GAME_API TempSummon : public Creature
void RemoveFromWorld() override;
void SetTempSummonType(TempSummonType type);
void SaveToDB(uint32 /*mapid*/, uint8 /*spawnMask*/, uint32 /*phaseMask*/) override { }
- Unit* GetSummoner() const;
+ WorldObject* GetSummoner() const;
+ Unit* GetSummonerUnit() const;
Creature* GetSummonerCreatureBase() const;
+ GameObject* GetSummonerGameObject() const;
ObjectGuid GetSummonerGUID() const { return m_summonerGUID; }
TempSummonType GetSummonType() const { return m_type; }
uint32 GetTimer() const { return m_timer; }
diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp
index afdd4dcdd25..3820e3e8523 100644
--- a/src/server/game/Entities/Object/Object.cpp
+++ b/src/server/game/Entities/Object/Object.cpp
@@ -1830,7 +1830,7 @@ void WorldObject::AddObjectToRemoveList()
map->AddObjectToRemoveList(this);
}
-TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropertiesEntry const* properties /*= nullptr*/, uint32 duration /*= 0*/, Unit* summoner /*= nullptr*/, uint32 spellId /*= 0*/, uint32 vehId /*= 0*/)
+TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropertiesEntry const* properties /*= nullptr*/, uint32 duration /*= 0*/, WorldObject* summoner /*= nullptr*/, uint32 spellId /*= 0*/, uint32 vehId /*= 0*/)
{
uint32 mask = UNIT_MASK_SUMMON;
if (properties)
@@ -1884,6 +1884,8 @@ TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropert
if (summoner)
phase = summoner->GetPhaseMask();
+ Unit* summonerUnit = summoner ? summoner->ToUnit() : nullptr;
+
TempSummon* summon = nullptr;
switch (mask)
{
@@ -1891,16 +1893,16 @@ TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropert
summon = new TempSummon(properties, summoner, false);
break;
case UNIT_MASK_GUARDIAN:
- summon = new Guardian(properties, summoner, false);
+ summon = new Guardian(properties, summonerUnit, false);
break;
case UNIT_MASK_PUPPET:
- summon = new Puppet(properties, summoner);
+ summon = new Puppet(properties, summonerUnit);
break;
case UNIT_MASK_TOTEM:
- summon = new Totem(properties, summoner);
+ summon = new Totem(properties, summonerUnit);
break;
case UNIT_MASK_MINION:
- summon = new Minion(properties, summoner, false);
+ summon = new Minion(properties, summonerUnit, false);
break;
}
@@ -1969,7 +1971,7 @@ TempSummon* WorldObject::SummonCreature(uint32 entry, Position const& pos, TempS
{
if (Map* map = FindMap())
{
- if (TempSummon* summon = map->SummonCreature(entry, pos, nullptr, despawnTime, ToUnit(), spellId))
+ if (TempSummon* summon = map->SummonCreature(entry, pos, nullptr, despawnTime, this, spellId))
{
summon->SetTempSummonType(despawnType);
return summon;
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 5b2cdfd0b7e..fbd2f89d611 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -31,6 +31,7 @@
#include "CreatureAI.h"
#include "CreatureAIImpl.h"
#include "Formulas.h"
+#include "GameObjectAI.h"
#include "GameTime.h"
#include "GridNotifiersImpl.h"
#include "Group.h"
@@ -806,7 +807,7 @@ bool Unit::HasBreakableByDamageCrowdControlAura(Unit* excludeCasterChannel) cons
if (!victim->ToCreature()->hasLootRecipient())
victim->ToCreature()->SetLootRecipient(attacker);
- if (!attacker || attacker->IsControlledByPlayer() || (attacker->ToTempSummon() && attacker->ToTempSummon()->GetSummoner() && attacker->ToTempSummon()->GetSummoner()->GetTypeId() == TYPEID_PLAYER))
+ if (!attacker || attacker->IsControlledByPlayer() || (attacker->ToTempSummon() && attacker->ToTempSummon()->GetSummonerUnit() && attacker->ToTempSummon()->GetSummonerUnit()->GetTypeId() == TYPEID_PLAYER))
victim->ToCreature()->LowerPlayerDamageReq(health < damage ? health : damage);
}
@@ -10955,10 +10956,16 @@ bool Unit::InitTamedPet(Pet* pet, uint8 level, uint32 spell_id)
if (CreatureAI* ai = creature->AI())
ai->JustDied(attacker);
- if (TempSummon* summon = creature->ToTempSummon())
- if (Unit* summoner = summon->GetSummoner())
- if (summoner->ToCreature() && summoner->IsAIEnabled())
+ if (TempSummon * summon = creature->ToTempSummon())
+ {
+ if (WorldObject * summoner = summon->GetSummoner())
+ {
+ if (summoner->ToCreature() && summoner->ToCreature()->IsAIEnabled())
summoner->ToCreature()->AI()->SummonedCreatureDies(creature, attacker);
+ else if (summoner->ToGameObject() && summoner->ToGameObject()->AI())
+ summoner->ToGameObject()->AI()->SummonedCreatureDies(creature, attacker);
+ }
+ }
// Dungeon specific stuff, only applies to players killing creatures
if (creature->GetInstanceId())
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index ad92d1e04e5..26bde95c536 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -202,7 +202,7 @@ bool SpellClickInfo::IsFitToRequirements(Unit const* clicker, Unit const* clicke
Unit const* summoner = nullptr;
// Check summoners for party
if (clickee->IsSummon())
- summoner = clickee->ToTempSummon()->GetSummoner();
+ summoner = clickee->ToTempSummon()->GetSummonerUnit();
if (!summoner)
summoner = clickee;
diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h
index ecc13fca277..94014708e7f 100644
--- a/src/server/game/Maps/Map.h
+++ b/src/server/game/Maps/Map.h
@@ -490,7 +490,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, Unit* summoner = nullptr, uint32 spellId = 0, uint32 vehId = 0);
+ TempSummon* SummonCreature(uint32 entry, Position const& pos, SummonPropertiesEntry const* properties = nullptr, uint32 duration = 0, WorldObject* summoner = nullptr, uint32 spellId = 0, uint32 vehId = 0);
void SummonCreatureGroup(uint8 group, std::list<TempSummon*>* list = nullptr);
Player* GetPlayer(ObjectGuid const& guid);
Corpse* GetCorpse(ObjectGuid const& guid);
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index af4a1f131fd..3a4adeeec0b 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -1506,7 +1506,7 @@ void Spell::SelectImplicitCasterObjectTargets(SpellEffIndex effIndex, SpellImpli
case TARGET_UNIT_SUMMONER:
if (Unit* unitCaster = m_caster->ToUnit())
if (unitCaster->IsSummon())
- target = unitCaster->ToTempSummon()->GetSummoner();
+ target = unitCaster->ToTempSummon()->GetSummonerUnit();
break;
case TARGET_UNIT_VEHICLE:
if (Unit* unitCaster = m_caster->ToUnit())