mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
There was existing code to ignore practice targets (anything with Dummy in the name) so I've just added the names of practice targets located in the tournament grounds: Charge Target Melee Target Ranged Target I considered just using the phrase "Target", but it is too generic and there are 246 creature_template names containing Target.
169 lines
5.1 KiB
C++
169 lines
5.1 KiB
C++
/*
|
|
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license, you may redistribute it
|
|
* and/or modify it under version 2 of the License, or (at your option), any later version.
|
|
*/
|
|
|
|
#include "ChooseTargetActions.h"
|
|
|
|
#include "ChooseRpgTargetAction.h"
|
|
#include "Event.h"
|
|
#include "LootObjectStack.h"
|
|
#include "Playerbots.h"
|
|
#include "PossibleRpgTargetsValue.h"
|
|
#include "PvpTriggers.h"
|
|
#include "ServerFacade.h"
|
|
|
|
bool AttackEnemyPlayerAction::isUseful()
|
|
{
|
|
if (PlayerHasFlag::IsCapturingFlag(bot))
|
|
return false;
|
|
|
|
return !sPlayerbotAIConfig->IsPvpProhibited(bot->GetZoneId(), bot->GetAreaId());
|
|
}
|
|
|
|
bool AttackEnemyFlagCarrierAction::isUseful()
|
|
{
|
|
Unit* target = context->GetValue<Unit*>("enemy flag carrier")->Get();
|
|
return target && sServerFacade->IsDistanceLessOrEqualThan(sServerFacade->GetDistance2d(bot, target), 75.0f) &&
|
|
PlayerHasFlag::IsCapturingFlag(bot);
|
|
}
|
|
|
|
bool AttackAnythingAction::isUseful()
|
|
{
|
|
if (!botAI->AllowActivity(GRIND_ACTIVITY)) // Bot not allowed to be active
|
|
return false;
|
|
|
|
if (!AI_VALUE(bool, "can move around"))
|
|
return false;
|
|
|
|
if (context->GetValue<TravelTarget*>("travel target")->Get()->isTraveling() &&
|
|
ChooseRpgTargetAction::isFollowValid(
|
|
bot, *context->GetValue<TravelTarget*>("travel target")->Get()->getPosition())) // Bot is traveling
|
|
return false;
|
|
// if (bot->IsInCombat()) {
|
|
// return false;
|
|
// }
|
|
Unit* target = GetTarget();
|
|
|
|
if (!target)
|
|
return false;
|
|
|
|
std::string const name = std::string(target->GetName());
|
|
// Check for invalid targets: Dummy, Charge Target, Melee Target, Ranged Target
|
|
if (!name.empty() &&
|
|
(name.find("Dummy") != std::string::npos ||
|
|
name.find("Charge Target") != std::string::npos ||
|
|
name.find("Melee Target") != std::string::npos ||
|
|
name.find("Ranged Target") != std::string::npos))
|
|
{
|
|
return false; // Target is one of the disallowed types
|
|
}
|
|
|
|
// if (!ChooseRpgTargetAction::isFollowValid(bot, target)) //Do not grind mobs far
|
|
// away from master.
|
|
// return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
bool DropTargetAction::Execute(Event event)
|
|
{
|
|
Unit* target = context->GetValue<Unit*>("current target")->Get();
|
|
if (target && target->isDead())
|
|
{
|
|
ObjectGuid guid = target->GetGUID();
|
|
if (guid)
|
|
context->GetValue<LootObjectStack*>("available loot")->Get()->Add(guid);
|
|
}
|
|
|
|
// ObjectGuid pullTarget = context->GetValue<ObjectGuid>("pull target")->Get();
|
|
// GuidVector possible = botAI->GetAiObjectContext()->GetValue<GuidVector>("possible targets no los")->Get();
|
|
|
|
// if (pullTarget && find(possible.begin(), possible.end(), pullTarget) == possible.end())
|
|
// {
|
|
// context->GetValue<ObjectGuid>("pull target")->Set(ObjectGuid::Empty);
|
|
// }
|
|
|
|
context->GetValue<Unit*>("current target")->Set(nullptr);
|
|
|
|
bot->SetTarget(ObjectGuid::Empty);
|
|
bot->SetSelection(ObjectGuid());
|
|
botAI->ChangeEngine(BOT_STATE_NON_COMBAT);
|
|
// botAI->InterruptSpell();
|
|
bot->AttackStop();
|
|
|
|
// if (Pet* pet = bot->GetPet())
|
|
// {
|
|
// if (CreatureAI* creatureAI = ((Creature*)pet)->AI())
|
|
// {
|
|
// pet->SetReactState(REACT_PASSIVE);
|
|
// pet->GetCharmInfo()->SetCommandState(COMMAND_FOLLOW);
|
|
// pet->GetCharmInfo()->SetIsCommandFollow(true);
|
|
// pet->AttackStop();
|
|
// pet->GetCharmInfo()->IsReturning();
|
|
// pet->GetMotionMaster()->MoveFollow(bot, PET_FOLLOW_DIST, pet->GetFollowAngle());
|
|
// }
|
|
// }
|
|
|
|
return true;
|
|
}
|
|
|
|
bool AttackAnythingAction::Execute(Event event)
|
|
{
|
|
bool result = AttackAction::Execute(event);
|
|
if (result)
|
|
{
|
|
if (Unit* grindTarget = GetTarget())
|
|
{
|
|
if (char const* grindName = grindTarget->GetName().c_str())
|
|
{
|
|
context->GetValue<ObjectGuid>("pull target")->Set(grindTarget->GetGUID());
|
|
bot->GetMotionMaster()->Clear();
|
|
// bot->StopMoving();
|
|
}
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
bool AttackAnythingAction::isPossible() { return AttackAction::isPossible() && GetTarget(); }
|
|
|
|
bool DpsAssistAction::isUseful()
|
|
{
|
|
if (PlayerHasFlag::IsCapturingFlag(bot))
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
bool AttackRtiTargetAction::Execute(Event event)
|
|
{
|
|
Unit* rtiTarget = AI_VALUE(Unit*, "rti target");
|
|
|
|
if (rtiTarget && rtiTarget->IsInWorld() && rtiTarget->GetMapId() == bot->GetMapId())
|
|
{
|
|
botAI->GetAiObjectContext()->GetValue<GuidVector>("prioritized targets")->Set({rtiTarget->GetGUID()});
|
|
bool result = Attack(botAI->GetUnit(rtiTarget->GetGUID()));
|
|
if (result)
|
|
{
|
|
context->GetValue<ObjectGuid>("pull target")->Set(rtiTarget->GetGUID());
|
|
return true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
botAI->TellError("I dont see my rti attack target");
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool AttackRtiTargetAction::isUseful()
|
|
{
|
|
if (botAI->ContainsStrategy(STRATEGY_TYPE_HEAL))
|
|
return false;
|
|
|
|
return true;
|
|
}
|