feat(Core/GameObject): Expand IsSummonedBy() to GameObjects (#14789)

Co-authored-by: jackpoz <giacomopoz@gmail.com>
This commit is contained in:
Skjalf
2023-01-29 09:44:33 -03:00
committed by GitHub
parent 4ecf96c379
commit bf30c66ba4
44 changed files with 191 additions and 95 deletions

View File

@@ -219,10 +219,15 @@ public:
{
npc_burning_spiritAI(Creature* creature) : ScriptedAI(creature) {}
void IsSummonedBy(Unit* summoner) override
void IsSummonedBy(WorldObject* summoner) override
{
if (summoner->GetTypeId() != TYPEID_UNIT)
{
return;
}
_flamelasherGUID = summoner->GetGUID();
me->GetMotionMaster()->MoveFollow(summoner, 0.f, 0.f);
me->GetMotionMaster()->MoveFollow(summoner->ToCreature(), 0.f, 0.f);
}
void EnterEvadeMode(EvadeReason /*why*/) override

View File

@@ -86,7 +86,7 @@ public:
BossAI::EnterEvadeMode(why);
}
void IsSummonedBy(Unit* /*summoner*/) override
void IsSummonedBy(WorldObject* /*summoner*/) override
{
events.ScheduleEvent(EVENT_SUMMONED_1, 1000);
}

View File

@@ -69,7 +69,7 @@ public:
frenzy15 = false;
}
void IsSummonedBy(Unit* /*summoner*/) override
void IsSummonedBy(WorldObject* /*summoner*/) override
{
StartTalking(TALK_SUMMON, 8 * IN_MILLISECONDS);
}

View File

@@ -174,7 +174,7 @@ public:
me->DespawnOrUnsummon();
}
void IsSummonedBy(Unit* /*summoner*/) override
void IsSummonedBy(WorldObject* /*summoner*/) override
{
Talk(EMOTE_BLACKHAND_DISMOUNT);
}

View File

@@ -981,7 +981,7 @@ public:
{
npc_vaelastrasz_the_redAI(Creature* creature) : CreatureAI(creature) { }
void IsSummonedBy(Unit* summoner) override
void IsSummonedBy(WorldObject* summoner) override
{
if (!summoner)
{

View File

@@ -871,7 +871,7 @@ struct npc_corrupted_totem : public ScriptedAI
}
}
void IsSummonedBy(Unit* /*summoner*/) override
void IsSummonedBy(WorldObject* /*summoner*/) override
{
me->SetInCombatWithZone();
@@ -942,7 +942,7 @@ struct npc_drakonid_spawner : public ScriptedAI
}
}
void IsSummonedBy(Unit* summoner) override
void IsSummonedBy(WorldObject* summoner) override
{
DoCastSelf(SPELL_SPAWN_DRAKONID_GEN);
_scheduler.Schedule(10s, 60s, [this](TaskContext /*context*/)

View File

@@ -387,9 +387,14 @@ public:
int room;
Unit* Gandling;
void IsSummonedBy(Unit* summoner) override
void IsSummonedBy(WorldObject* summoner) override
{
Gandling = summoner;
if (summoner->GetTypeId() != TYPEID_UNIT)
{
return;
}
Gandling = summoner->ToCreature();
if (instance)
{
room = Gandling->GetAI()->GetData(GANDLING_ROOM_TO_USE); // it's set just before my spawn

View File

@@ -106,7 +106,7 @@ public:
me->DespawnOrUnsummon(1);
}
void IsSummonedBy(Unit* /*summoner*/) override
void IsSummonedBy(WorldObject* /*summoner*/) override
{
events2.Reset();
events2.ScheduleEvent(INTRO_1, 1000);

View File

@@ -72,7 +72,7 @@ struct boss_kormok : public ScriptedAI
_summons.DespawnAll();
}
void IsSummonedBy(Unit* /*summoner*/) override
void IsSummonedBy(WorldObject* /*summoner*/) override
{
Talk(TALK_SUMMON);

View File

@@ -132,7 +132,7 @@ struct boss_jarien : public BossAI
_Reset();
}
void IsSummonedBy(Unit* /*summoner*/) override
void IsSummonedBy(WorldObject* /*summoner*/) override
{
Talk(SAY_JARIEN_ON_SUMMON_0);
@@ -257,7 +257,7 @@ struct boss_sothos : public BossAI
_Reset();
}
void IsSummonedBy(Unit* /*summoner*/) override
void IsSummonedBy(WorldObject* /*summoner*/) override
{
_scheduler.Schedule(12s, [this](TaskContext /*context*/)
{

View File

@@ -57,7 +57,7 @@ public:
{
boss_gahzrankaAI(Creature* creature) : BossAI(creature, DATA_GAHZRANKA) { }
void IsSummonedBy(Unit* /*summoner*/) override
void IsSummonedBy(WorldObject* /*summoner*/) override
{
me->GetMotionMaster()->MovePath(me->GetEntry() * 10, false);
}

View File

@@ -217,7 +217,7 @@ struct npc_shade_of_jindo : public ScriptedAI
{
npc_shade_of_jindo(Creature* creature) : ScriptedAI(creature) { }
void IsSummonedBy(Unit* /*summoner*/) override
void IsSummonedBy(WorldObject* /*summoner*/) override
{
DoZoneInCombat();
DoCastSelf(SPELL_SHADE_OF_JINDO_PASSIVE, true);

View File

@@ -1809,7 +1809,7 @@ struct npc_direbrew_minion : public ScriptedAI
DoZoneInCombat();
}
void IsSummonedBy(Unit* /*summoner*/) override
void IsSummonedBy(WorldObject* /*summoner*/) override
{
if (Creature* coren = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_COREN)))
{

View File

@@ -161,16 +161,19 @@ public:
_events.ScheduleEvent(EVENT_NOSUMMON, 50000);
}
void IsSummonedBy(Unit* summoner) override
void IsSummonedBy(WorldObject* summoner) override
{
if (summoner->GetTypeId() != TYPEID_PLAYER || !summoner->GetVehicle())
return;
_tigerGuid = summoner->GetVehicle()->GetBase()->GetGUID();
if (Unit* tiger = ObjectAccessor::GetUnit(*me, _tigerGuid))
if (Player* player = summoner->ToPlayer())
{
me->AddThreat(tiger, 500000.0f);
DoCast(me, SPELL_FURIOUS_BITE);
if (Vehicle* vehicle = player->GetVehicle())
{
_tigerGuid = vehicle->GetBase()->GetGUID();
if (Unit* tiger = ObjectAccessor::GetUnit(*me, _tigerGuid))
{
me->AddThreat(tiger, 500000.0f);
DoCast(me, SPELL_FURIOUS_BITE);
}
}
}
}

View File

@@ -320,7 +320,7 @@ public:
}
}
void IsSummonedBy(Unit* /*summoner*/) override
void IsSummonedBy(WorldObject* /*summoner*/) override
{
std::list<Player*> playerOnQuestList;
Acore::AnyPlayerInObjectRangeCheck checker(me, 5.0f);

View File

@@ -119,7 +119,7 @@ struct npc_taldaram_flamesphere : public NullCreatureAI
}
}
void IsSummonedBy(Unit* /*summoner*/) override
void IsSummonedBy(WorldObject* /*summoner*/) override
{
// Replace sphere instantly if sphere is summoned after prince death
if (instance->GetBossState(DATA_PRINCE_TALDARAM) != IN_PROGRESS)

View File

@@ -225,7 +225,7 @@ public:
// Prevent EvadeMode
}
void IsSummonedBy(Unit* /*summoner*/) override
void IsSummonedBy(WorldObject* /*summoner*/) override
{
// Let Zarithrian count as summoner. _instance cant be null since we got GetRubySanctumAI
if (Creature* zarithrian = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(NPC_GENERAL_ZARITHRIAN)))

View File

@@ -1456,7 +1456,7 @@ public:
{
npc_living_infernoAI(Creature* creature) : ScriptedAI(creature) { }
void IsSummonedBy(Unit* /*summoner*/) override
void IsSummonedBy(WorldObject* /*summoner*/) override
{
me->SetInCombatWithZone();
me->CastSpell(me, SPELL_BLAZING_AURA, true);

View File

@@ -1369,7 +1369,7 @@ public:
float _groundZ;
bool exploded;
void IsSummonedBy(Unit* /*summoner*/) override
void IsSummonedBy(WorldObject* /*summoner*/) override
{
if (InstanceScript* instance = me->GetInstanceScript())
{

View File

@@ -318,7 +318,7 @@ public:
EventMap events;
void IsSummonedBy(Unit* /*summoner*/) override
void IsSummonedBy(WorldObject* /*summoner*/) override
{
events.ScheduleEvent(1, 450);
events.ScheduleEvent(2, 12000);
@@ -404,24 +404,29 @@ public:
DoAction(-1337);
}
void IsSummonedBy(Unit* summoner) override
void IsSummonedBy(WorldObject* summoner) override
{
if (!summoner)
return;
if (Vehicle* v = summoner->GetVehicle())
if (summoner->GetTypeId() != TYPEID_UNIT)
{
return;
}
if (Vehicle* v = summoner->ToUnit()->GetVehicle())
if (Unit* u = v->GetBase())
if (u->GetEntry() == NPC_BONE_SPIKE && u->GetTypeId() == TYPEID_UNIT)
u->ToCreature()->AI()->DoAction(-1337);
ObjectGuid petGUID = summoner->GetPetGUID();
summoner->SetPetGUID(ObjectGuid::Empty);
me->CastSpell(summoner, SPELL_IMPALED, true);
summoner->CastSpell(me, SPELL_RIDE_VEHICLE, true);
ObjectGuid petGUID = summoner->ToUnit()->GetPetGUID();
summoner->ToUnit()->SetPetGUID(ObjectGuid::Empty);
me->CastSpell(summoner->ToUnit(), SPELL_IMPALED, true);
summoner->ToUnit()->CastSpell(me, SPELL_RIDE_VEHICLE, true);
//summoner->ClearUnitState(UNIT_STATE_ONVEHICLE);
summoner->SetPetGUID(petGUID);
summoner->GetMotionMaster()->Clear();
summoner->StopMoving();
summoner->ToUnit()->SetPetGUID(petGUID);
summoner->ToUnit()->GetMotionMaster()->Clear();
summoner->ToUnit()->StopMoving();
events.ScheduleEvent(1, 8000);
hasTrappedUnit = true;
}

View File

@@ -756,7 +756,7 @@ public:
targetGUID = guid;
}
void IsSummonedBy(Unit* /*summoner*/) override
void IsSummonedBy(WorldObject* /*summoner*/) override
{
if (InstanceScript* instance = me->GetInstanceScript())
if (Creature* professor = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_PROFESSOR_PUTRICIDE)))

View File

@@ -358,13 +358,18 @@ public:
EventMap events;
InstanceScript* instance;
void IsSummonedBy(Unit* summoner) override
void IsSummonedBy(WorldObject* summoner) override
{
if (!summoner)
return;
me->AddThreat(summoner, 500000.0f);
AttackStart(summoner);
if (summoner->GetTypeId() != TYPEID_UNIT)
{
return;
}
me->AddThreat(summoner->ToUnit(), 500000.0f);
AttackStart(summoner->ToUnit());
}
void JustDied(Unit* /*killer*/) override
@@ -437,7 +442,7 @@ public:
EventMap events;
InstanceScript* instance;
void IsSummonedBy(Unit* /*summoner*/) override
void IsSummonedBy(WorldObject* /*summoner*/) override
{
if (Player* p = me->SelectNearestPlayer(100.0f))
AttackStart(p);

View File

@@ -2339,7 +2339,7 @@ public:
}
}
void IsSummonedBy(Unit* /*summoner*/) override
void IsSummonedBy(WorldObject* /*summoner*/) override
{
// player is the spellcaster so register summon manually
if (Creature* lichKing = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_THE_LICH_KING)))
@@ -3121,11 +3121,16 @@ public:
EventMap _events;
InstanceScript* _instance;
void IsSummonedBy(Unit* summoner) override
void IsSummonedBy(WorldObject* summoner) override
{
if (!summoner)
return;
if (summoner->GetTypeId() != TYPEID_UNIT)
{
return;
}
if (Creature* lichKing = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_THE_LICH_KING)))
{
me->SetWalk(false);
@@ -3134,13 +3139,13 @@ public:
path.push_back(G3D::Vector3(me->GetPositionX(), me->GetPositionY(), 843.0f));
me->GetMotionMaster()->MoveSplinePath(&path);
ObjectGuid petGUID = summoner->GetPetGUID();
summoner->SetPetGUID(ObjectGuid::Empty);
summoner->StopMoving();
me->CastSpell(summoner, SPELL_HARVEST_SOUL_VEHICLE, true);
ObjectGuid petGUID = summoner->ToUnit()->GetPetGUID();
summoner->ToUnit()->SetPetGUID(ObjectGuid::Empty);
summoner->ToUnit()->StopMoving();
me->CastSpell(summoner->ToUnit(), SPELL_HARVEST_SOUL_VEHICLE, true);
//summoner->ClearUnitState(UNIT_STATE_ONVEHICLE);
summoner->SendMovementFlagUpdate(true);
summoner->SetPetGUID(petGUID);
summoner->ToUnit()->SendMovementFlagUpdate(true);
summoner->ToUnit()->SetPetGUID(petGUID);
_events.Reset();
_events.ScheduleEvent(EVENT_MOVE_TO_LICH_KING, 1000);
_events.ScheduleEvent(EVENT_TELEPORT, 6250);
@@ -3652,7 +3657,7 @@ public:
uint16 timer;
void IsSummonedBy(Unit* /*summoner*/) override
void IsSummonedBy(WorldObject* /*summoner*/) override
{
float destX, destY, destZ;
me->GetPosition(destX, destY);

View File

@@ -977,7 +977,7 @@ public:
ScriptedAI::AttackStart(who);
}
void IsSummonedBy(Unit* /*summoner*/) override
void IsSummonedBy(WorldObject* /*summoner*/) override
{
if (Creature* valithria = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_VALITHRIA_DREAMWALKER)))
AttackStart(valithria);

View File

@@ -352,8 +352,13 @@ public:
bool JustSummoned;
uint16 despawnTimer;
void IsSummonedBy(Unit* summoner) override
void IsSummonedBy(WorldObject* summoner) override
{
if (summoner->GetTypeId() != TYPEID_UNIT)
{
return;
}
if (m_pInstance->GetBossState(DATA_EREGOS) == IN_PROGRESS)
if (Creature* eregos = me->FindNearestCreature(NPC_EREGOS, 450.0f, true))
eregos->DespawnOrUnsummon(); // On retail this kills abusive call of drake during engaged Eregos
@@ -363,13 +368,13 @@ public:
switch (me->GetEntry())
{
case NPC_RUBY_DRAKE:
me->CastSpell(summoner, SPELL_RIDE_RUBY_DRAKE_QUE);
me->CastSpell(summoner->ToUnit(), SPELL_RIDE_RUBY_DRAKE_QUE);
break;
case NPC_EMERALD_DRAKE:
me->CastSpell(summoner, SPELL_RIDE_EMERALD_DRAKE_QUE);
me->CastSpell(summoner->ToUnit(), SPELL_RIDE_EMERALD_DRAKE_QUE);
break;
case NPC_AMBER_DRAKE:
me->CastSpell(summoner, SPELL_RIDE_AMBER_DRAKE_QUE);
me->CastSpell(summoner->ToUnit(), SPELL_RIDE_AMBER_DRAKE_QUE);
break;
default:
return;

View File

@@ -412,7 +412,7 @@ public:
vezax->AI()->DoAction(1);
}
void IsSummonedBy(Unit* /*summoner*/) override
void IsSummonedBy(WorldObject* /*summoner*/) override
{
Talk(SAY_EMOTE_VAPORS);
}

View File

@@ -670,7 +670,7 @@ public:
me->DespawnOrUnsummon(3s, 0s);
}
void IsSummonedBy(Unit* summoner) override
void IsSummonedBy(WorldObject* summoner) override
{
me->SetFacingToObject(summoner);
Position pos = summoner->GetPosition();
@@ -1677,7 +1677,7 @@ public:
return 5;
}
void IsSummonedBy(Unit* summoner) override
void IsSummonedBy(WorldObject* summoner) override
{
if (!summoner || summoner->GetTypeId() != TYPEID_PLAYER)
return;
@@ -1689,7 +1689,7 @@ public:
summoner->ToPlayer()->SendDirectMessage(&data);
if (id == 1)
if (Aura* aura = summoner->GetAura(47189)) // Transform Aura
if (Aura* aura = summoner->ToUnit()->GetAura(47189)) // Transform Aura
aura->SetDuration(aura->GetDuration() - MINUTE * IN_MILLISECONDS);
}
};

View File

@@ -1292,19 +1292,24 @@ public:
return nullptr;
}
void IsSummonedBy(Unit* summoner) override
void IsSummonedBy(WorldObject* summoner) override
{
if (!summoner)
return;
summoner->CastSpell(summoner, SPELL_WAITING_FOR_A_BOMBER, true);
summoner->CastSpell(summoner, SPELL_FLIGHT_ORDERS, true);
if (summoner->GetTypeId() != TYPEID_UNIT)
{
return;
}
summoner->ToUnit()->CastSpell(summoner->ToUnit(), SPELL_WAITING_FOR_A_BOMBER, true);
summoner->ToUnit()->CastSpell(summoner->ToUnit(), SPELL_FLIGHT_ORDERS, true);
events.ScheduleEvent(EVENT_START_FLIGHT, 0);
events.ScheduleEvent(EVENT_TAKE_PASSENGER, 3000);
me->SetCanFly(true);
me->AddUnitMovementFlag(MOVEMENTFLAG_FLYING);
me->SetSpeed(MOVE_FLIGHT, 0.1f);
me->SetFaction(summoner->GetFaction());
me->SetFaction(summoner->ToUnit()->GetFaction());
}
void DamageTaken(Unit* who, uint32&, DamageEffectType, SpellSchoolMask) override
@@ -2129,7 +2134,7 @@ public:
EventMap events;
void IsSummonedBy(Unit* summoner) override
void IsSummonedBy(WorldObject* summoner) override
{
if (!summoner)
return;

View File

@@ -294,7 +294,7 @@ public:
me->DespawnOrUnsummon(1);
}
void IsSummonedBy(Unit* summoner) override
void IsSummonedBy(WorldObject* summoner) override
{
if (!summoner)
return;

View File

@@ -1108,7 +1108,7 @@ public:
timer = 500;
}
void IsSummonedBy(Unit* summoner) override
void IsSummonedBy(WorldObject* summoner) override
{
if (summoner && summoner->isType(TYPEMASK_PLAYER))
playerGuid = summoner->GetGUID();

View File

@@ -236,7 +236,7 @@ public:
me->GetMotionMaster()->MoveRandom(5.0f);
}
void IsSummonedBy(Unit* summoner) override
void IsSummonedBy(WorldObject* summoner) override
{
if (!summoner)
return;

View File

@@ -407,7 +407,7 @@ public:
}
}
void IsSummonedBy(Unit* summoner) override
void IsSummonedBy(WorldObject* summoner) override
{
if (!summoner)
return;

View File

@@ -727,7 +727,7 @@ struct npc_pet_gen_fetch_ball : public NullCreatureAI
uint32 checkTimer;
ObjectGuid targetGUID;
void IsSummonedBy(Unit* summoner) override
void IsSummonedBy(WorldObject* summoner) override
{
if (!summoner)
return;

View File

@@ -459,13 +459,18 @@ public:
{
}
void IsSummonedBy(Unit* summoner) override
void IsSummonedBy(WorldObject* summoner) override
{
if (!summoner)
return;
if (summoner->GetTypeId() != TYPEID_UNIT)
{
return;
}
_summonerGuid = summoner->GetGUID();
me->GetMotionMaster()->MoveFollow(summoner, 0.0f, 0.0f);
me->GetMotionMaster()->MoveFollow(summoner->ToUnit(), 0.0f, 0.0f);
}
void MovementInform(uint32 moveType, uint32 data) override

View File

@@ -2521,7 +2521,7 @@ public:
{
npc_venomhide_hatchlingAI(Creature* creature) : ScriptedAI(creature) {}
void IsSummonedBy(Unit* summoner) override
void IsSummonedBy(WorldObject* summoner) override
{
if (summoner->GetTypeId() != TYPEID_PLAYER)
{
@@ -2597,9 +2597,14 @@ public:
events.ScheduleEvent(EVENT_FLAME_BREATH, 12s);
}
void IsSummonedBy(Unit* summoner) override
void IsSummonedBy(WorldObject* summoner) override
{
me->GetMotionMaster()->MoveFollow(summoner, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE);
if (summoner->GetTypeId() != TYPEID_UNIT)
{
return;
}
me->GetMotionMaster()->MoveFollow(summoner->ToUnit(), PET_FOLLOW_DIST, PET_FOLLOW_ANGLE);
}
void UpdateAI(uint32 diff) override