mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Misc: Kill AnyPlayerInObjectRangeCheck (duplicate of AnyUnitInObjectRangeCheck)
This commit is contained in:
@@ -1472,8 +1472,8 @@ void GameObject::Update(uint32 diff)
|
||||
{
|
||||
// Environmental trap: Any player
|
||||
Player* player = nullptr;
|
||||
Trinity::AnyPlayerInObjectRangeCheck checker(this, radius);
|
||||
Trinity::PlayerSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(this, player, checker);
|
||||
Trinity::AnyUnitInObjectRangeCheck checker(this, radius);
|
||||
Trinity::PlayerSearcher searcher(this, player, checker);
|
||||
Cell::VisitWorldObjects(this, searcher, radius);
|
||||
target = player;
|
||||
}
|
||||
|
||||
@@ -3452,8 +3452,8 @@ void WorldObject::GetCreatureListWithOptionsInGrid(Container& creatureContainer,
|
||||
template <typename Container>
|
||||
void WorldObject::GetPlayerListInGrid(Container& playerContainer, float maxSearchRange, bool alive /*= true*/) const
|
||||
{
|
||||
Trinity::AnyPlayerInObjectRangeCheck checker(this, maxSearchRange, alive);
|
||||
Trinity::PlayerListSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(this, playerContainer, checker);
|
||||
Trinity::AnyUnitInObjectRangeCheck checker(this, maxSearchRange, true, alive);
|
||||
Trinity::PlayerListSearcher searcher(this, playerContainer, checker);
|
||||
Cell::VisitWorldObjects(this, searcher, maxSearchRange);
|
||||
}
|
||||
|
||||
@@ -3746,26 +3746,23 @@ void WorldObject::DestroyForNearbyPlayers()
|
||||
if (!IsInWorld())
|
||||
return;
|
||||
|
||||
std::list<Player*> targets;
|
||||
Trinity::AnyPlayerInObjectRangeCheck check(this, GetVisibilityRange(), false);
|
||||
Trinity::PlayerListSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(this, targets, check);
|
||||
Cell::VisitWorldObjects(this, searcher, GetVisibilityRange());
|
||||
for (std::list<Player*>::const_iterator iter = targets.begin(); iter != targets.end(); ++iter)
|
||||
auto destroyer = [this](Player* player)
|
||||
{
|
||||
Player* player = (*iter);
|
||||
|
||||
if (player == this)
|
||||
continue;
|
||||
return;
|
||||
|
||||
if (!player->HaveAtClient(this))
|
||||
continue;
|
||||
return;
|
||||
|
||||
if (Unit const* unit = ToUnit(); unit && unit->GetCharmerGUID() == player->GetGUID()) /// @todo this is for puppet
|
||||
continue;
|
||||
return;
|
||||
|
||||
DestroyForPlayer(player);
|
||||
player->m_clientGUIDs.erase(GetGUID());
|
||||
}
|
||||
};
|
||||
|
||||
Trinity::PlayerDistWorker worker(this, GetVisibilityRange(), destroyer);
|
||||
Cell::VisitWorldObjects(this, worker, GetVisibilityRange());
|
||||
}
|
||||
|
||||
void WorldObject::UpdateObjectVisibility(bool /*forced*/)
|
||||
|
||||
@@ -1599,28 +1599,6 @@ namespace Trinity
|
||||
Customizer& i_customizer;
|
||||
};
|
||||
|
||||
class AnyPlayerInObjectRangeCheck
|
||||
{
|
||||
public:
|
||||
AnyPlayerInObjectRangeCheck(WorldObject const* obj, float range, bool reqAlive = true) : _obj(obj), _range(range), _reqAlive(reqAlive) { }
|
||||
|
||||
bool operator()(Player* u) const
|
||||
{
|
||||
if (_reqAlive && !u->IsAlive())
|
||||
return false;
|
||||
|
||||
if (!_obj->IsWithinDist(u, _range))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
WorldObject const* _obj;
|
||||
float _range;
|
||||
bool _reqAlive;
|
||||
};
|
||||
|
||||
class AnyPlayerInPositionRangeCheck
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user