aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorModoX <moardox@gmail.com>2024-01-25 16:11:49 +0100
committerModoX <moardox@gmail.com>2024-01-25 16:12:06 +0100
commit61d16856e432730e1346e40f84aeb4b1bc34324d (patch)
tree05f7db708b118adfd6d86f1a4dc5cf7fb56a9c55 /src
parent608d13bf83aa61570a1ad53938cffe183facb0cf (diff)
Core/Unit: Set DemonCreator for wild allied summons
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp10
-rw-r--r--src/server/game/Entities/Unit/Unit.h2
-rw-r--r--src/server/game/Spells/SpellEffects.cpp2
-rw-r--r--src/server/scripts/ExilesReach/zone_exiles_reach.cpp42
4 files changed, 35 insertions, 21 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 8189d5c8bec..e0e3c0011cf 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -5976,6 +5976,16 @@ void Unit::SetOwnerGUID(ObjectGuid owner)
player->SendDirectMessage(&packet);
}
+Unit* Unit::GetDemonCreator() const
+{
+ return ObjectAccessor::GetUnit(*this, GetDemonCreatorGUID());
+}
+
+Player* Unit::GetDemonCreatorPlayer() const
+{
+ return ObjectAccessor::GetPlayer(*this, GetDemonCreatorGUID());
+}
+
Player* Unit::GetControllingPlayer() const
{
ObjectGuid guid = GetCharmerOrOwnerGUID();
diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h
index e278384a315..2bd5dad9b24 100644
--- a/src/server/game/Entities/Unit/Unit.h
+++ b/src/server/game/Entities/Unit/Unit.h
@@ -1166,6 +1166,8 @@ class TC_GAME_API Unit : public WorldObject
void SetBattlePetCompanionGUID(ObjectGuid guid) { SetUpdateFieldValue(m_values.ModifyValue(&Unit::m_unitData).ModifyValue(&UF::UnitData::BattlePetCompanionGUID), guid); }
ObjectGuid GetDemonCreatorGUID() const { return m_unitData->DemonCreator; }
void SetDemonCreatorGUID(ObjectGuid guid) { SetUpdateFieldValue(m_values.ModifyValue(&Unit::m_unitData).ModifyValue(&UF::UnitData::DemonCreator), guid); }
+ Unit* GetDemonCreator() const;
+ Player* GetDemonCreatorPlayer() const;
ObjectGuid GetCharmerGUID() const { return m_unitData->CharmedBy; }
Unit* GetCharmer() const { return m_charmer; }
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
index 93a6b015504..9d073e84c59 100644
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -1964,6 +1964,8 @@ void Spell::EffectSummonType()
summon->SetTempSummonType(summonType);
if (properties->Control == SUMMON_CATEGORY_ALLY)
summon->SetOwnerGUID(caster->GetGUID());
+ else if (properties->Control == SUMMON_CATEGORY_WILD && caster->IsPlayer()) // there might be more conditions involved
+ summon->SetDemonCreatorGUID(caster->GetGUID());
ExecuteLogEffectSummonObject(SpellEffectName(effectInfo->Effect), summon);
}
diff --git a/src/server/scripts/ExilesReach/zone_exiles_reach.cpp b/src/server/scripts/ExilesReach/zone_exiles_reach.cpp
index 6ecb380ca1e..a414344dec1 100644
--- a/src/server/scripts/ExilesReach/zone_exiles_reach.cpp
+++ b/src/server/scripts/ExilesReach/zone_exiles_reach.cpp
@@ -363,7 +363,7 @@ struct npc_sparring_partner_exiles_reach : public ScriptedAI
me->GetMotionMaster()->MovePoint(POSITION_SPARPOINT_READY, me->GetFirstCollisionPosition(2.0f, rand_norm() * static_cast<float>(2 * M_PI)));
break;
case POSITION_SPARPOINT_READY:
- if (Unit* owner = me->GetOwner())
+ if (Unit* owner = me->GetDemonCreator())
me->SetFacingToObject(owner);
me->SetImmuneToPC(false);
me->SetUninteractible(false);
@@ -378,7 +378,7 @@ struct npc_sparring_partner_exiles_reach : public ScriptedAI
if (pathId != _path)
return;
- if (Unit* owner = me->GetOwner())
+ if (Unit* owner = me->GetDemonCreator())
{
me->DespawnOrUnsummon();
owner->CastSpell(owner, SPELL_UPDATE_PHASE_SHIFT);
@@ -397,7 +397,7 @@ struct npc_sparring_partner_exiles_reach : public ScriptedAI
me->SetUninteractible(true);
_events.CancelEvent(EVENT_JUMP_BEHIND);
- if (Player* player = me->GetAffectingPlayer())
+ if (Player* player = me->GetDemonCreatorPlayer())
{
me->SetFacingToObject(player);
Talk(TALK_SPARING_COMPLETE, player);
@@ -428,7 +428,7 @@ struct npc_sparring_partner_exiles_reach : public ScriptedAI
void StartPrivateConversation(uint32 conversationId)
{
- if (Unit* owner = me->GetOwner())
+ if (Unit* owner = me->GetDemonCreator())
{
Conversation* conversation = Conversation::CreateConversation(conversationId, owner, *owner, owner->GetGUID(), nullptr, false);
conversation->AddActor(_actorId, _actorIndex, me->GetGUID());
@@ -1767,7 +1767,7 @@ struct npc_garrick_summoned_beach : public ScriptedAI
_reachedCamp = true;
- if (Unit* owner = me->GetOwner())
+ if (Unit* owner = me->GetDemonCreator())
{
Conversation* conversation = Conversation::CreateConversation(CONVERSATION_LINE_ESCORT_SURVIVOR_CAMP, owner, *owner, owner->GetGUID(), nullptr, false);
conversation->AddActor(ACTOR_ID_ALLIANCE_SURVIVOR, 1, me->GetGUID());
@@ -1783,7 +1783,7 @@ struct npc_garrick_summoned_beach : public ScriptedAI
if (uiType != POINT_MOTION_TYPE || uiId != POINT_CAMP_POSITION)
return;
- if (Unit* owner = me->GetOwner())
+ if (Unit* owner = me->GetDemonCreator())
{
owner->CastSpell(owner, SPELL_UPDATE_PHASE_SHIFT);
owner->RemoveAura(SPELL_SUMMON_ADMIRAL_GARRICK_GUARDIAN);
@@ -1800,7 +1800,7 @@ struct npc_garrick_summoned_beach : public ScriptedAI
{
case EVENT_INITIAL_SPAWN_CHECK:
{
- Unit* owner = me->GetOwner();
+ Unit* owner = me->GetDemonCreator();
if (!owner)
break;
@@ -1824,7 +1824,7 @@ struct npc_garrick_summoned_beach : public ScriptedAI
break;
}
case EVENT_FOLLOW_PLAYER:
- if (Unit* owner = me->GetOwner())
+ if (Unit* owner = me->GetDemonCreator())
me->GetMotionMaster()->MoveFollow(owner, 0.0f, float(M_PI / 4.0f));
break;
default:
@@ -1858,7 +1858,7 @@ struct npc_grimaxe_summoned_beach : public ScriptedAI
if (_reachedCamp)
return;
- if (Unit* owner = me->GetOwner())
+ if (Unit* owner = me->GetDemonCreator())
{
Conversation* conversation = Conversation::CreateConversation(CONVERSATION_LINE_ESCORT_SURVIVOR_CAMP, owner, *owner, owner->GetGUID(), nullptr, false);
conversation->AddActor(ACTOR_ID_HORDE_SURVIVOR, 3, me->GetGUID());
@@ -1874,7 +1874,7 @@ struct npc_grimaxe_summoned_beach : public ScriptedAI
if (uiType != POINT_MOTION_TYPE || uiId != POINT_CAMP_POSITION)
return;
- if (Unit* owner = me->GetOwner())
+ if (Unit* owner = me->GetDemonCreator())
{
owner->CastSpell(owner, SPELL_UPDATE_PHASE_SHIFT);
owner->RemoveAura(SPELL_SUMMON_WARLORD_GRIMAXE_GUARDIAN);
@@ -1891,7 +1891,7 @@ struct npc_grimaxe_summoned_beach : public ScriptedAI
{
case EVENT_INITIAL_SPAWN_CHECK:
{
- Unit* owner = me->GetOwner();
+ Unit* owner = me->GetDemonCreator();
if (!owner)
break;
@@ -1915,7 +1915,7 @@ struct npc_grimaxe_summoned_beach : public ScriptedAI
break;
}
case EVENT_FOLLOW_PLAYER:
- if (Unit* owner = me->GetOwner())
+ if (Unit* owner = me->GetDemonCreator())
me->GetMotionMaster()->MoveFollow(owner, 0.0f, float(M_PI / 4.0f));
break;
default:
@@ -2466,7 +2466,7 @@ struct npc_sparring_partner_combat_training : public ScriptedAI
}
case POINT_TRAINING_POINT_ENHANCED_TRAINING:
{
- Unit* owner = me->GetOwner();
+ Unit* owner = me->GetDemonCreator();
if (!owner)
break;
@@ -2516,7 +2516,7 @@ struct npc_sparring_partner_combat_training : public ScriptedAI
// Used to check if reached home
if (pathId == PATH_COMBAT_TRAINER_HOME)
{
- if (Unit* owner = me->GetOwner())
+ if (Unit* owner = me->GetDemonCreator())
{
owner->CastSpell(owner, SPELL_UPDATE_PHASE_SHIFT);
owner->RemoveAura(_summonSpellAuraID);
@@ -2541,7 +2541,7 @@ struct npc_sparring_partner_combat_training : public ScriptedAI
case EVENT_COMBAT_TRAINING_FACE_PLAYER:
{
// Used by all classes
- if (Unit* owner = me->GetOwner())
+ if (Unit* owner = me->GetDemonCreator())
me->SetFacingToObject(owner);
me->SetImmuneToPC(false);
@@ -2553,7 +2553,7 @@ struct npc_sparring_partner_combat_training : public ScriptedAI
me->SetImmuneToPC(true);
me->SetUnitFlag(UNIT_FLAG_UNINTERACTIBLE);
me->RemoveAllAuras();
- if (Unit* owner = me->GetOwner())
+ if (Unit* owner = me->GetDemonCreator())
{
me->SetFacingToObject(owner);
StartConversationWithPlayer(CONVERSATION_CHARGE_FINAL_ENHANCED);
@@ -2676,7 +2676,7 @@ struct npc_sparring_partner_enhanced_combat_training_paladin : public npc_sparri
{
if (_holyPowerCheck) // Used by paladin
{
- if (Unit* owner = me->GetOwner())
+ if (Unit* owner = me->GetDemonCreator())
{
if (owner->GetPower(POWER_HOLY_POWER) >= 3)
{
@@ -2794,7 +2794,7 @@ struct npc_sparring_partner_enhanced_combat_training_rogue : public npc_sparring
{
if (_comboPointCheck) // Used by rogue
{
- if (Unit* owner = me->GetOwner())
+ if (Unit* owner = me->GetDemonCreator())
_comboPointsCounter = owner->GetPower(POWER_COMBO_POINTS);
if (_comboPointsCounter >= (GetQuestCredits() + 3))
@@ -2999,7 +2999,7 @@ struct npc_sparring_partner_enhanced_combat_training_shaman : public npc_sparrin
switch (eventId)
{
case EVENT_COMBAT_TRAINING_RESET_SHAMAN:
- if (Unit* owner = me->GetOwner())
+ if (Unit* owner = me->GetDemonCreator())
{
me->CastSpell(owner, SPELL_KNOCKBACK);
_events.ScheduleEvent(EVENT_COMBAT_TRAINING_AGGRO_CHECK_SHAMAN, 2s);
@@ -3092,7 +3092,7 @@ struct npc_sparring_partner_enhanced_combat_training_mage : public npc_sparring_
switch (eventId)
{
case EVENT_COMBAT_TRAINING_RESET_MAGE:
- if (Unit* owner = me->GetOwner())
+ if (Unit* owner = me->GetDemonCreator())
{
me->CastSpell(owner, SPELL_KNOCKBACK);
_events.ScheduleEvent(EVENT_COMBAT_TRAINING_AGGRO_CHECK_MAGE, 2s);
@@ -3593,7 +3593,7 @@ struct npc_leader_northbound : public ScriptedAI
switch (eventId)
{
case EVENT_FOLLOW_PLAYER:
- if (Unit* owner = me->GetOwner())
+ if (Unit* owner = me->GetDemonCreator())
me->GetMotionMaster()->MoveFollow(owner, 0.0f, float(M_PI / 4.0f));
break;
default: