mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-12-01 21:12:50 +08:00
chore(value): attackers value
This commit is contained in:
@@ -431,6 +431,7 @@ void PlayerbotHolder::OnBotLogin(Player* const bot)
|
||||
uint32 accountId = bot->GetSession()->GetAccountId();
|
||||
bool isRandomAccount = sPlayerbotAIConfig->IsInRandomAccountList(accountId);
|
||||
|
||||
bot->SaveToDB(false, false);
|
||||
if (master && isRandomAccount && master->GetLevel() < bot->GetLevel()) {
|
||||
PlayerbotFactory factory(bot, master->getLevel());
|
||||
factory.Randomize(false);
|
||||
|
||||
@@ -1670,6 +1670,9 @@ bool RandomPlayerbotMgr::HandlePlayerbotConsoleCommand(ChatHandler* handler, cha
|
||||
|
||||
uint32 botId = fields[0].Get<uint32>();
|
||||
ObjectGuid guid = ObjectGuid::Create<HighGuid::Player>(botId);
|
||||
if (!sRandomPlayerbotMgr->IsRandomBot(guid.GetCounter())) {
|
||||
continue;
|
||||
}
|
||||
Player* bot = ObjectAccessor::FindPlayer(guid);
|
||||
if (!bot)
|
||||
continue;
|
||||
|
||||
@@ -83,20 +83,41 @@ void AttackersValue::AddAttackersOf(Player* player, std::set<Unit*>& targets)
|
||||
|
||||
void AttackersValue::RemoveNonThreating(std::set<Unit*>& targets)
|
||||
{
|
||||
for (std::set<Unit*>::iterator tIter = targets.begin(); tIter != targets.end();)
|
||||
for(std::set<Unit *>::iterator tIter = targets.begin(); tIter != targets.end();)
|
||||
{
|
||||
Unit* unit = *tIter;
|
||||
if (!IsValidTarget(unit, bot) || !bot->IsWithinLOSInMap(unit))
|
||||
if(!bot->IsWithinLOSInMap(unit) || bot->GetMapId() != unit->GetMapId() || !hasRealThreat(unit))
|
||||
{
|
||||
std::set<Unit*>::iterator tIter2 = tIter;
|
||||
std::set<Unit *>::iterator tIter2 = tIter;
|
||||
++tIter;
|
||||
targets.erase(tIter2);
|
||||
}
|
||||
else
|
||||
++tIter;
|
||||
}
|
||||
// Unit* unit = *tIter;
|
||||
// if (!IsValidTarget(unit, bot) || !bot->IsWithinLOSInMap(unit))
|
||||
// {
|
||||
// std::set<Unit*>::iterator tIter2 = tIter;
|
||||
// ++tIter;
|
||||
// targets.erase(tIter2);
|
||||
// }
|
||||
// else
|
||||
// ++tIter;
|
||||
}
|
||||
|
||||
bool AttackersValue::hasRealThreat(Unit *attacker)
|
||||
{
|
||||
return attacker &&
|
||||
attacker->IsInWorld() &&
|
||||
attacker->IsAlive() &&
|
||||
// !attacker->IsPolymorphed() &&
|
||||
// !attacker->isInRoots() &&
|
||||
!attacker->IsFriendlyTo(bot) &&
|
||||
(attacker->GetThreatMgr().getCurrentVictim() || dynamic_cast<Player*>(attacker));
|
||||
}
|
||||
|
||||
|
||||
bool AttackersValue::IsPossibleTarget(Unit* attacker, Player* bot, float range)
|
||||
{
|
||||
Creature* c = attacker->ToCreature();
|
||||
|
||||
@@ -25,7 +25,8 @@ class AttackersValue : public ObjectGuidListCalculatedValue
|
||||
private:
|
||||
void AddAttackersOf(Group* group, std::set<Unit*>& targets);
|
||||
void AddAttackersOf(Player* player, std::set<Unit*>& targets);
|
||||
void RemoveNonThreating(std::set<Unit*>& targets);
|
||||
void RemoveNonThreating(std::set<Unit*>& targets);
|
||||
bool hasRealThreat(Unit* attacker);
|
||||
};
|
||||
|
||||
class PossibleAddsValue : public BoolCalculatedValue
|
||||
|
||||
Reference in New Issue
Block a user