From e5ec277b5e894e307124ab3aff97e67fa3b248bc Mon Sep 17 00:00:00 2001 From: Uleat Date: Sat, 4 Jan 2020 01:56:38 -0500 Subject: [PATCH] Temporary bot impl until further work can be done --- zone/bot.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++++ zone/entity.h | 2 ++ 2 files changed, 46 insertions(+) diff --git a/zone/bot.cpp b/zone/bot.cpp index b7be0c962..b5628ecb4 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -2211,6 +2211,17 @@ bool Bot::Process() return false; } + if (mob_scan_close.Check()) { + LogAIScanClose( + "is_moving [{}] bot [{}] timer [{}]", + moving ? "true" : "false", + GetCleanName(), + mob_scan_close.GetDuration() + ); + + entity_list.ScanCloseClientMobs(close_mobs, this); + } + SpellProcess(); if(tic_timer.Check()) { @@ -9377,6 +9388,39 @@ void EntityList::ShowSpawnWindow(Client* client, int Distance, bool NamedOnly) { return; } +/** + * @param close_mobs + * @param scanning_mob + */ +void EntityList::ScanCloseClientMobs(std::unordered_map& close_mobs, Mob* scanning_mob) +{ + float scan_range = RuleI(Range, MobCloseScanDistance) * RuleI(Range, MobCloseScanDistance); + + close_mobs.clear(); + + for (auto& e : mob_list) { + auto mob = e.second; + + if (!mob->IsClient()) { + continue; + } + + if (mob->GetID() <= 0) { + continue; + } + + float distance = DistanceSquared(scanning_mob->GetPosition(), mob->GetPosition()); + if (distance <= scan_range) { + close_mobs.insert(std::pair(mob->GetID(), mob)); + } + else if (mob->GetAggroRange() >= scan_range) { + close_mobs.insert(std::pair(mob->GetID(), mob)); + } + } + + LogAIScanClose("Close Client Mob List Size [{}] for mob [{}]", close_mobs.size(), scanning_mob->GetCleanName()); +} + uint8 Bot::GetNumberNeedingHealedInGroup(uint8 hpr, bool includePets) { uint8 needHealed = 0; Group *g = nullptr; diff --git a/zone/entity.h b/zone/entity.h index ea97446a6..a296ca794 100644 --- a/zone/entity.h +++ b/zone/entity.h @@ -579,6 +579,8 @@ private: bool Bot_AICheckCloseBeneficialSpells(Bot* caster, uint8 iChance, float iRange, uint32 iSpellTypes); // TODO: Evaluate this closesly in hopes to eliminate void ShowSpawnWindow(Client* client, int Distance, bool NamedOnly); // TODO: Implement ShowSpawnWindow in the bot class but it needs entity list stuff + + void ScanCloseClientMobs(std::unordered_map& close_mobs, Mob* scanning_mob); private: std::list bot_list; #endif