mirror of
https://github.com/liyunfan1223/mod-playerbots.git
synced 2026-02-21 10:30:01 +01:00
Merge pull request #476 from liyunfan1223/fix-lag
Fix lag and hunter melee attack
This commit is contained in:
commit
e97c0350aa
@ -112,8 +112,9 @@ bool AttackAction::Attack(Unit* target, bool with_pet /*true*/)
|
|||||||
bot->SetSelection(target->GetGUID());
|
bot->SetSelection(target->GetGUID());
|
||||||
|
|
||||||
Unit* oldTarget = context->GetValue<Unit*>("current target")->Get();
|
Unit* oldTarget = context->GetValue<Unit*>("current target")->Get();
|
||||||
|
bool melee = bot->IsWithinMeleeRange(target) || botAI->IsMelee(bot);
|
||||||
|
|
||||||
if (oldTarget == target && botAI->GetState() == BOT_STATE_COMBAT && bot->GetVictim() == target)
|
if (oldTarget == target && botAI->GetState() == BOT_STATE_COMBAT && bot->GetVictim() == target && (bot->HasUnitState(UNIT_STATE_MELEE_ATTACKING) == melee))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
context->GetValue<Unit*>("old target")->Set(oldTarget);
|
context->GetValue<Unit*>("old target")->Set(oldTarget);
|
||||||
@ -129,7 +130,6 @@ bool AttackAction::Attack(Unit* target, bool with_pet /*true*/)
|
|||||||
bot->StopMoving();
|
bot->StopMoving();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool melee = bot->IsWithinMeleeRange(target) || botAI->IsMelee(bot);
|
|
||||||
|
|
||||||
if (IsMovingAllowed() && !bot->HasInArc(CAST_ANGLE_IN_FRONT, target))
|
if (IsMovingAllowed() && !bot->HasInArc(CAST_ANGLE_IN_FRONT, target))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -54,24 +54,14 @@ float ChooseRpgTargetAction::getMaxRelevance(GuidPosition guidP)
|
|||||||
GuidPosition currentRpgTarget = AI_VALUE(GuidPosition, "rpg target");
|
GuidPosition currentRpgTarget = AI_VALUE(GuidPosition, "rpg target");
|
||||||
SET_AI_VALUE(GuidPosition, "rpg target", guidP);
|
SET_AI_VALUE(GuidPosition, "rpg target", guidP);
|
||||||
|
|
||||||
Strategy* rpgStrategy;
|
Strategy* rpgStrategy = botAI->GetAiObjectContext()->GetStrategy("rpg");
|
||||||
|
if (!rpgStrategy) return 0.0f;
|
||||||
|
|
||||||
std::vector<TriggerNode*> triggerNodes;
|
std::vector<TriggerNode*> triggerNodes;
|
||||||
|
rpgStrategy->InitTriggers(triggerNodes);
|
||||||
|
|
||||||
float maxRelevance = 0.0f;
|
float maxRelevance = 0.0f;
|
||||||
|
|
||||||
for (auto& strategy : botAI->GetAiObjectContext()->GetSupportedStrategies())
|
|
||||||
{
|
|
||||||
if (strategy.find("rpg") == std::string::npos)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!botAI->HasStrategy(strategy, BotState::BOT_STATE_NON_COMBAT))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
rpgStrategy = botAI->GetAiObjectContext()->GetStrategy(strategy);
|
|
||||||
|
|
||||||
rpgStrategy->InitTriggers(triggerNodes);
|
|
||||||
|
|
||||||
for (auto triggerNode : triggerNodes)
|
for (auto triggerNode : triggerNodes)
|
||||||
{
|
{
|
||||||
Trigger* trigger = context->GetTrigger(triggerNode->getName());
|
Trigger* trigger = context->GetTrigger(triggerNode->getName());
|
||||||
@ -115,9 +105,7 @@ float ChooseRpgTargetAction::getMaxRelevance(GuidPosition guidP)
|
|||||||
{
|
{
|
||||||
delete trigger;
|
delete trigger;
|
||||||
}
|
}
|
||||||
|
|
||||||
triggerNodes.clear();
|
triggerNodes.clear();
|
||||||
}
|
|
||||||
|
|
||||||
SET_AI_VALUE(GuidPosition, "rpg target", currentRpgTarget);
|
SET_AI_VALUE(GuidPosition, "rpg target", currentRpgTarget);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user