mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 21:01:29 +00:00
Add GetCloseMobList into other calls
This commit is contained in:
parent
ec5faea9b1
commit
233f26996b
@ -5032,6 +5032,9 @@ void EntityList::ReloadMerchants() {
|
||||
}
|
||||
|
||||
/**
|
||||
* If we have a distance requested that is greater than our scanning distance
|
||||
* then we return the full list
|
||||
*
|
||||
* @param mob
|
||||
* @param distance
|
||||
* @return
|
||||
|
||||
@ -512,7 +512,7 @@ public:
|
||||
inline const std::unordered_map<uint16, Object *> &GetObjectList() { return object_list; }
|
||||
inline const std::unordered_map<uint16, Doors *> &GetDoorsList() { return door_list; }
|
||||
|
||||
std::unordered_map<uint16, Mob *> &GetCloseMobList(Mob *mob, float distance);
|
||||
std::unordered_map<uint16, Mob *> &GetCloseMobList(Mob *mob, float distance = 0);
|
||||
|
||||
void DepopAll(int NPCTypeID, bool StartSpawnTimer = true);
|
||||
|
||||
|
||||
@ -171,7 +171,6 @@ public:
|
||||
void DisplayInfo(Mob *mob);
|
||||
|
||||
std::unordered_map<uint16, Mob *> close_mobs;
|
||||
std::unordered_map<uint16, Mob *>& GetSmartMobList(float distance = 0);
|
||||
Timer mob_scan_close;
|
||||
Timer mob_check_moving_timer;
|
||||
|
||||
|
||||
26
zone/npc.cpp
26
zone/npc.cpp
@ -3019,14 +3019,14 @@ void NPC::SetSimpleRoamBox(float box_size, float move_distance, int move_delay)
|
||||
/**
|
||||
* @param caster
|
||||
* @param chance
|
||||
* @param in_cast_range
|
||||
* @param cast_range
|
||||
* @param spell_types
|
||||
* @return
|
||||
*/
|
||||
bool NPC::AICheckCloseBeneficialSpells(
|
||||
NPC *caster,
|
||||
uint8 chance,
|
||||
float in_cast_range,
|
||||
float cast_range,
|
||||
uint32 spell_types
|
||||
)
|
||||
{
|
||||
@ -3061,24 +3061,18 @@ bool NPC::AICheckCloseBeneficialSpells(
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cast range
|
||||
*/
|
||||
in_cast_range = (in_cast_range * in_cast_range);
|
||||
|
||||
/**
|
||||
* Check through close range mobs
|
||||
*/
|
||||
for (auto & close_mob : close_mobs) {
|
||||
for (auto & close_mob : entity_list.GetCloseMobList(caster, cast_range)) {
|
||||
Mob *mob = close_mob.second;
|
||||
|
||||
if (mob->IsClient()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
float distance = DistanceSquared(mob->GetPosition(), GetPosition());
|
||||
|
||||
if (distance > in_cast_range) {
|
||||
float distance = Distance(mob->GetPosition(), caster->GetPosition());
|
||||
if (distance > cast_range) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -3086,7 +3080,7 @@ bool NPC::AICheckCloseBeneficialSpells(
|
||||
"NPC [{}] Distance [{}] Cast Range [{}] Caster [{}]",
|
||||
mob->GetCleanName(),
|
||||
distance,
|
||||
in_cast_range,
|
||||
cast_range,
|
||||
caster->GetCleanName()
|
||||
);
|
||||
|
||||
@ -3134,7 +3128,7 @@ void NPC::AIYellForHelp(Mob *sender, Mob *attacker)
|
||||
GetID()
|
||||
);
|
||||
|
||||
for (auto &close_mob : close_mobs) {
|
||||
for (auto &close_mob : entity_list.GetCloseMobList(sender)) {
|
||||
Mob *mob = close_mob.second;
|
||||
float distance = DistanceSquared(m_Position, mob->GetPosition());
|
||||
|
||||
@ -3143,18 +3137,18 @@ void NPC::AIYellForHelp(Mob *sender, Mob *attacker)
|
||||
}
|
||||
|
||||
float assist_range = (mob->GetAssistRange() * mob->GetAssistRange());
|
||||
|
||||
if (distance > assist_range) {
|
||||
continue;
|
||||
}
|
||||
|
||||
LogAIYellForHelpDetail(
|
||||
"NPC [{}] ID [{}] is scanning - checking against NPC [{}] range [{}] dist [{}]",
|
||||
"NPC [{}] ID [{}] is scanning - checking against NPC [{}] range [{}] dist [{}] in_range [{}]",
|
||||
GetCleanName(),
|
||||
GetID(),
|
||||
mob->GetCleanName(),
|
||||
assist_range,
|
||||
distance
|
||||
distance,
|
||||
(distance < assist_range)
|
||||
);
|
||||
|
||||
if (mob->CheckAggro(attacker)) {
|
||||
|
||||
@ -143,7 +143,7 @@ public:
|
||||
virtual bool AI_IdleCastCheck();
|
||||
virtual void AI_Event_SpellCastFinished(bool iCastSucceeded, uint16 slot);
|
||||
|
||||
bool AICheckCloseBeneficialSpells(NPC* caster, uint8 chance, float in_cast_range, uint32 spell_types);
|
||||
bool AICheckCloseBeneficialSpells(NPC* caster, uint8 chance, float cast_range, uint32 spell_types);
|
||||
void AIYellForHelp(Mob* sender, Mob* attacker);
|
||||
|
||||
void LevelScale();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user