Core/Misc: Kill AnyPlayerInObjectRangeCheck (duplicate of AnyUnitInObjectRangeCheck)

This commit is contained in:
Shauren
2025-06-08 01:07:44 +02:00
parent aab8cdec35
commit 0f9a0accf1
9 changed files with 39 additions and 77 deletions

View File

@@ -16,10 +16,8 @@
*/
#include "ScriptMgr.h"
#include "CellImpl.h"
#include "Containers.h"
#include "CreatureAIImpl.h"
#include "GridNotifiersImpl.h"
#include "Player.h"
#include "SpellAuraEffects.h"
#include "SpellScript.h"
@@ -75,21 +73,16 @@ class spell_love_is_in_the_air_romantic_picnic : public AuraScript
bool foundSomeone = false;
// For nearby players, check if they have the same aura. If so, cast Romantic Picnic (45123)
// required by achievement and "hearts" visual
std::list<Player*> playerList;
Trinity::AnyPlayerInObjectRangeCheck checker(target, INTERACTION_DISTANCE*2);
Trinity::PlayerListSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(target, playerList, checker);
Cell::VisitWorldObjects(target, searcher, INTERACTION_DISTANCE * 2);
for (std::list<Player*>::const_iterator itr = playerList.begin(); itr != playerList.end(); ++itr)
std::vector<Player*> playerList;
target->GetPlayerListInGrid(playerList, INTERACTION_DISTANCE * 2);
for (Player* playerFound : playerList)
{
if (Player* playerFound = (*itr))
if (target != playerFound && playerFound->HasAura(GetId()))
{
if (target != playerFound && playerFound->HasAura(GetId()))
{
playerFound->CastSpell(playerFound, SPELL_ROMANTIC_PICNIC_ACHIEV, true);
target->CastSpell(target, SPELL_ROMANTIC_PICNIC_ACHIEV, true);
foundSomeone = true;
break;
}
playerFound->CastSpell(playerFound, SPELL_ROMANTIC_PICNIC_ACHIEV, true);
target->CastSpell(target, SPELL_ROMANTIC_PICNIC_ACHIEV, true);
foundSomeone = true;
break;
}
}

View File

@@ -30,13 +30,13 @@ npc_magwin
EndContentData */
#include "ScriptMgr.h"
#include "CellImpl.h"
#include "GameObjectAI.h"
#include "GridNotifiersImpl.h"
#include "GameObject.h"
#include "MotionMaster.h"
#include "ObjectAccessor.h"
#include "Player.h"
#include "ScriptedEscortAI.h"
#include "ScriptedGossip.h"
#include "SpellInfo.h"
#include "SpellScript.h"
#include "TemporarySummon.h"
@@ -571,14 +571,12 @@ public:
void CompleteQuest()
{
float radius = 50.0f;
std::list<Player*> players;
Trinity::AnyPlayerInObjectRangeCheck checker(me, radius);
Trinity::PlayerListSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(me, players, checker);
Cell::VisitWorldObjects(me, searcher, radius);
std::vector<Player*> players;
me->GetPlayerListInGrid(players, radius);
for (std::list<Player*>::const_iterator itr = players.begin(); itr != players.end(); ++itr)
if ((*itr)->GetQuestStatus(QUEST_TREES_COMPANY) == QUEST_STATUS_INCOMPLETE && (*itr)->HasAura(SPELL_TREE_DISGUISE))
(*itr)->KilledMonsterCredit(NPC_SPARK);
for (Player* player : players)
if (player->GetQuestStatus(QUEST_TREES_COMPANY) == QUEST_STATUS_INCOMPLETE && player->HasAura(SPELL_TREE_DISGUISE))
player->KilledMonsterCredit(NPC_SPARK);
}
void DespawnNagaFlag(bool despawn)

View File

@@ -685,8 +685,8 @@ struct npc_crok_scourgebane : public EscortAI
{
_wipeCheckTimer = 1000;
Player* player = nullptr;
Trinity::AnyPlayerInObjectRangeCheck check(me, 60.0f);
Trinity::PlayerSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(me, player, check);
Trinity::AnyUnitInObjectRangeCheck check(me, 60.0f);
Trinity::PlayerSearcher searcher(me, player, check);
Cell::VisitWorldObjects(me, searcher, 60.0f);
// wipe
if (!player)

View File

@@ -942,8 +942,8 @@ struct npc_dream_cloud : public ScriptedAI
case EVENT_CHECK_PLAYER:
{
Player* player = nullptr;
Trinity::AnyPlayerInObjectRangeCheck check(me, 5.0f);
Trinity::PlayerSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(me, player, check);
Trinity::AnyUnitInObjectRangeCheck check(me, 5.0f);
Trinity::PlayerSearcher searcher(me, player, check);
Cell::VisitWorldObjects(me, searcher, 7.5f);
_events.ScheduleEvent(player ? EVENT_EXPLODE : EVENT_CHECK_PLAYER, 1s);
break;

View File

@@ -22,9 +22,7 @@
*/
#include "ScriptMgr.h"
#include "CellImpl.h"
#include "CreatureAIImpl.h"
#include "GridNotifiersImpl.h"
#include "ObjectMgr.h"
#include "Player.h"
#include "ScriptedCreature.h"
@@ -724,15 +722,13 @@ class spell_q11010_q11102_q11023_choose_loc : public SpellScript
{
Unit* caster = GetCaster();
// Check for player that is in 65 y range
std::list<Player*> playerList;
Trinity::AnyPlayerInObjectRangeCheck checker(caster, 65.0f);
Trinity::PlayerListSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(caster, playerList, checker);
Cell::VisitWorldObjects(caster, searcher, 65.0f);
for (std::list<Player*>::const_iterator itr = playerList.begin(); itr != playerList.end(); ++itr)
std::vector<Player*> playerList;
caster->GetPlayerListInGrid(playerList, 65.0f);
for (Player* player : playerList)
// Check if found player target is on fly mount or using flying form
if ((*itr)->HasAuraType(SPELL_AURA_FLY) || (*itr)->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED))
if (player->HasAuraType(SPELL_AURA_FLY) || player->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED))
// Summom Fel Cannon (bunny version) at found player
caster->SummonCreature(NPC_FEL_CANNON2, (*itr)->GetPositionX(), (*itr)->GetPositionY(), (*itr)->GetPositionZ());
caster->SummonCreature(NPC_FEL_CANNON2, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ());
}
void Register() override

View File

@@ -402,8 +402,8 @@ class spell_volkaal_rapid_decay : public AuraScript
float range = 100.0f;
Player* player = nullptr;
Trinity::AnyPlayerInObjectRangeCheck check(caster, range);
Trinity::PlayerSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(caster, player, check);
Trinity::AnyUnitInObjectRangeCheck check(caster, range);
Trinity::PlayerSearcher searcher(caster, player, check);
Cell::VisitWorldObjects(caster, searcher, range);
CastSpellExtraArgs args;