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
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;