mirror of
https://github.com/liyunfan1223/mod-playerbots.git
synced 2026-02-20 18:10:02 +01:00
chore(value): attackers value
This commit is contained in:
parent
c9367debeb
commit
209fdbd6b5
@ -431,6 +431,7 @@ void PlayerbotHolder::OnBotLogin(Player* const bot)
|
|||||||
uint32 accountId = bot->GetSession()->GetAccountId();
|
uint32 accountId = bot->GetSession()->GetAccountId();
|
||||||
bool isRandomAccount = sPlayerbotAIConfig->IsInRandomAccountList(accountId);
|
bool isRandomAccount = sPlayerbotAIConfig->IsInRandomAccountList(accountId);
|
||||||
|
|
||||||
|
bot->SaveToDB(false, false);
|
||||||
if (master && isRandomAccount && master->GetLevel() < bot->GetLevel()) {
|
if (master && isRandomAccount && master->GetLevel() < bot->GetLevel()) {
|
||||||
PlayerbotFactory factory(bot, master->getLevel());
|
PlayerbotFactory factory(bot, master->getLevel());
|
||||||
factory.Randomize(false);
|
factory.Randomize(false);
|
||||||
|
|||||||
@ -1670,6 +1670,9 @@ bool RandomPlayerbotMgr::HandlePlayerbotConsoleCommand(ChatHandler* handler, cha
|
|||||||
|
|
||||||
uint32 botId = fields[0].Get<uint32>();
|
uint32 botId = fields[0].Get<uint32>();
|
||||||
ObjectGuid guid = ObjectGuid::Create<HighGuid::Player>(botId);
|
ObjectGuid guid = ObjectGuid::Create<HighGuid::Player>(botId);
|
||||||
|
if (!sRandomPlayerbotMgr->IsRandomBot(guid.GetCounter())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
Player* bot = ObjectAccessor::FindPlayer(guid);
|
Player* bot = ObjectAccessor::FindPlayer(guid);
|
||||||
if (!bot)
|
if (!bot)
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@ -83,20 +83,41 @@ void AttackersValue::AddAttackersOf(Player* player, std::set<Unit*>& targets)
|
|||||||
|
|
||||||
void AttackersValue::RemoveNonThreating(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;
|
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;
|
++tIter;
|
||||||
targets.erase(tIter2);
|
targets.erase(tIter2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
++tIter;
|
++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)
|
bool AttackersValue::IsPossibleTarget(Unit* attacker, Player* bot, float range)
|
||||||
{
|
{
|
||||||
Creature* c = attacker->ToCreature();
|
Creature* c = attacker->ToCreature();
|
||||||
|
|||||||
@ -25,7 +25,8 @@ class AttackersValue : public ObjectGuidListCalculatedValue
|
|||||||
private:
|
private:
|
||||||
void AddAttackersOf(Group* group, std::set<Unit*>& targets);
|
void AddAttackersOf(Group* group, std::set<Unit*>& targets);
|
||||||
void AddAttackersOf(Player* player, 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
|
class PossibleAddsValue : public BoolCalculatedValue
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user