From 80e6a3a412740da7d0203ad0f30ab17fbf0ac57f Mon Sep 17 00:00:00 2001 From: Jelle Meeus Date: Thu, 12 Dec 2024 06:54:40 +0100 Subject: [PATCH] fix(Scripts/TrialOfChampion): fail and send custom spell error when trying to mount without lance equipped (#19932) --- .../rev_1725926206241976759.sql | 2 + .../boss_grand_champions.cpp | 44 +++++++++---------- 2 files changed, 22 insertions(+), 24 deletions(-) create mode 100644 data/sql/updates/pending_db_world/rev_1725926206241976759.sql diff --git a/data/sql/updates/pending_db_world/rev_1725926206241976759.sql b/data/sql/updates/pending_db_world/rev_1725926206241976759.sql new file mode 100644 index 000000000..9fa159c62 --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1725926206241976759.sql @@ -0,0 +1,2 @@ +-- +UPDATE `conditions` SET `Comment` = 'Player must have aura Lance Equipped' WHERE (`SourceTypeOrReferenceId` = 16) AND (`SourceGroup` = 0) AND (`SourceEntry` IN (35644, 36588)) AND (`ConditionValue1` = 62853); diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_grand_champions.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_grand_champions.cpp index a1616ea0a..649a60c6f 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_grand_champions.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_grand_champions.cpp @@ -28,6 +28,7 @@ enum MountSpells { + SPELL_LANCE_EQUIPPED = 62853, SPELL_PLAYER_VEHICLE_DEFEND = 66482, SPELL_MINIONS_DEFEND = 64100, SPELL_BOSS_DEFEND = 62719, @@ -152,16 +153,9 @@ public: return GetTrialOfTheChampionAI(pCreature); } - struct npc_toc5_player_vehicleAI : public NullCreatureAI + struct npc_toc5_player_vehicleAI : public VehicleAI { - npc_toc5_player_vehicleAI(Creature* pCreature) : NullCreatureAI(pCreature) - { - conditions = sConditionMgr->GetConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_CREATURE_TEMPLATE_VEHICLE, me->GetEntry()); - m_ConditionsTimer = 1000; - } - - ConditionList conditions; - uint16 m_ConditionsTimer; + npc_toc5_player_vehicleAI(Creature* creature) : VehicleAI(creature) { } void Reset() override { @@ -203,23 +197,25 @@ public: } } - //void EnterEvadeMode() { CreatureAI::EnterEvadeMode(); } - void MoveInLineOfSight(Unit* /*who*/) override {} - void UpdateAI(uint32 diff) override + bool BeforeSpellClick(Unit* clicker) override { - if (m_ConditionsTimer <= diff) - { - if (!conditions.empty()) - if (Unit* passenger = me->GetVehicleKit()->GetPassenger(0)) - if (!sConditionMgr->IsObjectMeetToConditions(passenger, me, conditions)) - passenger->ExitVehicle(); - m_ConditionsTimer = VEHICLE_CONDITION_CHECK_TIME; - } - else - m_ConditionsTimer -= diff; + if (!clicker->IsPlayer()) + return true; + + if (clicker->IsInDisallowedMountForm()) + clicker->RemoveAurasByType(SPELL_AURA_MOD_SHAPESHIFT); + + if (clicker->HasAura(SPELL_LANCE_EQUIPPED)) + return true; + + WorldPacket data(SMSG_CAST_FAILED, 1 + 4 + 1); + data << uint8(0); // single cast or multi 2.3 (0/1) + data << uint32(VEHICLE_SPELL_RIDE_HARDCODED); + data << uint8(SPELL_FAILED_CUSTOM_ERROR); + data << uint32(SPELL_CUSTOM_ERROR_MUST_HAVE_LANCE_EQUIPPED); + clicker->ToPlayer()->GetSession()->SendPacket(&data); + return false; } - void AttackStart(Unit* /*who*/) override {} - void JustEngagedWith(Unit* /*who*/) override {} }; };