mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
68 lines
2.3 KiB
C++
68 lines
2.3 KiB
C++
/*
|
|
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license, you may redistribute it
|
|
* and/or modify it under version 2 of the License, or (at your option), any later version.
|
|
*/
|
|
|
|
#include "NearestNpcsValue.h"
|
|
|
|
#include "CellImpl.h"
|
|
#include "GridNotifiers.h"
|
|
#include "GridNotifiersImpl.h"
|
|
#include "Playerbots.h"
|
|
#include "Vehicle.h"
|
|
|
|
void NearestNpcsValue::FindUnits(std::list<Unit*>& targets)
|
|
{
|
|
Acore::AnyUnitInObjectRangeCheck u_check(bot, range);
|
|
Acore::UnitListSearcher<Acore::AnyUnitInObjectRangeCheck> searcher(bot, targets, u_check);
|
|
Cell::VisitAllObjects(bot, searcher, range);
|
|
}
|
|
|
|
bool NearestNpcsValue::AcceptUnit(Unit* unit) { return !unit->IsPlayer(); }
|
|
|
|
void NearestHostileNpcsValue::FindUnits(std::list<Unit*>& targets)
|
|
{
|
|
Acore::AnyUnitInObjectRangeCheck u_check(bot, range);
|
|
Acore::UnitListSearcher<Acore::AnyUnitInObjectRangeCheck> searcher(bot, targets, u_check);
|
|
Cell::VisitAllObjects(bot, searcher, range);
|
|
}
|
|
|
|
bool NearestHostileNpcsValue::AcceptUnit(Unit* unit) { return unit->IsHostileTo(bot) && !unit->IsPlayer(); }
|
|
|
|
void NearestVehiclesValue::FindUnits(std::list<Unit*>& targets)
|
|
{
|
|
Acore::AnyUnitInObjectRangeCheck u_check(bot, range);
|
|
Acore::UnitListSearcher<Acore::AnyUnitInObjectRangeCheck> searcher(bot, targets, u_check);
|
|
Cell::VisitAllObjects(bot, searcher, range);
|
|
}
|
|
|
|
bool NearestVehiclesValue::AcceptUnit(Unit* unit)
|
|
{
|
|
if (!unit || !unit->IsVehicle() || !unit->IsAlive())
|
|
return false;
|
|
|
|
Vehicle* veh = unit->GetVehicleKit();
|
|
if (!veh || !veh->GetAvailableSeatCount())
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
void NearestTriggersValue::FindUnits(std::list<Unit*>& targets)
|
|
{
|
|
Acore::AnyUnfriendlyUnitInObjectRangeCheck u_check(bot, bot, range);
|
|
Acore::UnitListSearcher<Acore::AnyUnfriendlyUnitInObjectRangeCheck> searcher(bot, targets, u_check);
|
|
Cell::VisitAllObjects(bot, searcher, range);
|
|
}
|
|
|
|
bool NearestTriggersValue::AcceptUnit(Unit* unit) { return !unit->IsPlayer(); }
|
|
|
|
void NearestTotemsValue::FindUnits(std::list<Unit*>& targets)
|
|
{
|
|
Acore::AnyUnitInObjectRangeCheck u_check(bot, range);
|
|
Acore::UnitListSearcher<Acore::AnyUnitInObjectRangeCheck> searcher(bot, targets, u_check);
|
|
Cell::VisitAllObjects(bot, searcher, range);
|
|
}
|
|
|
|
bool NearestTotemsValue::AcceptUnit(Unit* unit) { return unit->IsTotem(); }
|