fix(Scripts/AhnKahet): fix Jedoga Shadowseeker's ritual not starting (#23921)

This commit is contained in:
sogladev 2025-11-27 02:14:27 +01:00 committed by GitHub
parent d90d3904e0
commit dfe44b7e86
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 32 additions and 13 deletions

View file

@ -15,12 +15,13 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptedCreature.h"
#include "Cell.h"
#include "CellImpl.h"
#include "Containers.h"
#include "GameTime.h"
#include "GridNotifiers.h"
#include "ObjectMgr.h"
#include "ScriptedCreature.h"
#include "Spell.h"
#include "TemporarySummon.h"
@ -141,6 +142,23 @@ Creature* SummonList::GetCreatureWithEntry(uint32 entry) const
return nullptr;
}
Creature* SummonList::GetRandomCreatureWithEntry(uint32 entry) const
{
std::vector<ObjectGuid> candidates;
candidates.reserve(storage_.size());
for (auto const guid : storage_)
if (Creature* summon = ObjectAccessor::GetCreature(*me, guid))
if (summon->GetEntry() == entry)
candidates.push_back(guid);
if (candidates.empty())
return nullptr;
ObjectGuid randomGuid = Acore::Containers::SelectRandomContainerElement(candidates);
return ObjectAccessor::GetCreature(*me, randomGuid);
}
bool SummonList::IsAnyCreatureAlive() const
{
for (auto const& guid : storage_)

View file

@ -157,6 +157,7 @@ public:
uint32 GetEntryCount(uint32 entry) const;
void Respawn();
Creature* GetCreatureWithEntry(uint32 entry) const;
Creature* GetRandomCreatureWithEntry(uint32 entry) const;
private:
Creature* me;

View file

@ -16,7 +16,6 @@
*/
#include "AchievementCriteriaScript.h"
#include "Containers.h"
#include "CreatureScript.h"
#include "ObjectAccessor.h"
#include "ScriptedCreature.h"
@ -209,7 +208,7 @@ struct boss_jedoga_shadowseeker : public BossAI
}
}
sacraficeTarget_GUID.Clear();
sacrificeTargetGUID.Clear();
sayPreachTimer = 120000;
ritualTriggered = false;
volunteerWork = true;
@ -268,12 +267,12 @@ struct boss_jedoga_shadowseeker : public BossAI
}
case NPC_TWILIGHT_VOLUNTEER:
{
if (sacraficeTarget_GUID && summon->GetGUID() != sacraficeTarget_GUID)
if (sacrificeTargetGUID && summon->GetGUID() != sacrificeTargetGUID)
{
break;
}
if (killer != me && killer->GetGUID() != sacraficeTarget_GUID)
if (killer != me && killer->GetGUID() != sacrificeTargetGUID)
{
volunteerWork = false;
}
@ -315,7 +314,7 @@ struct boss_jedoga_shadowseeker : public BossAI
{
if (action == ACTION_SACRAFICE)
{
if (Creature* target = ObjectAccessor::GetCreature(*me, sacraficeTarget_GUID))
if (Creature* target = ObjectAccessor::GetCreature(*me, sacrificeTargetGUID))
{
Unit::Kill(me, target);
}
@ -395,9 +394,9 @@ struct boss_jedoga_shadowseeker : public BossAI
me->SetFacingTo(5.66f);
if (!summons.empty())
{
sacraficeTarget_GUID = Acore::Containers::SelectRandomContainerElement(summons);
if (ObjectAccessor::GetCreature(*me, sacraficeTarget_GUID))
if (Creature* creature = summons.GetRandomCreatureWithEntry(NPC_TWILIGHT_VOLUNTEER))
{
sacrificeTargetGUID = creature->GetGUID();
events.ScheduleEvent(EVENT_JEDGA_START_RITUAL, 3s, 0, PHASE_RITUAL);
}
// Something failed, let players continue but do not grant achievement
@ -518,15 +517,16 @@ struct boss_jedoga_shadowseeker : public BossAI
}
case EVENT_JEDGA_START_RITUAL:
{
sacraficeTarget_GUID = Acore::Containers::SelectRandomContainerElement(summons);
if (Creature* volunteer = ObjectAccessor::GetCreature(*me, sacraficeTarget_GUID))
if (Creature* creature = summons.GetRandomCreatureWithEntry(NPC_TWILIGHT_VOLUNTEER))
{
sacrificeTargetGUID = creature->GetGUID();
Talk(SAY_SACRIFICE_1);
sacraficeTarget_GUID = volunteer->GetGUID();
volunteer->AI()->DoAction(ACTION_RITUAL_BEGIN);
creature->AI()->DoAction(ACTION_RITUAL_BEGIN);
}
break;
}
default:
break;
}
}
@ -546,7 +546,7 @@ struct boss_jedoga_shadowseeker : public BossAI
private:
GuidList oocSummons;
GuidList oocTriggers;
ObjectGuid sacraficeTarget_GUID;
ObjectGuid sacrificeTargetGUID;
uint32 sayPreachTimer;
bool combatSummonsSummoned;
bool ritualTriggered;