/* * Copyright (C) 2016+ AzerothCore , 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("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("travel target")->Get()->isTraveling() && ChooseRpgTargetAction::isFollowValid( bot, *context->GetValue("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("current target")->Get(); if (target && target->isDead()) { ObjectGuid guid = target->GetGUID(); if (guid) context->GetValue("available loot")->Get()->Add(guid); } // ObjectGuid pullTarget = context->GetValue("pull target")->Get(); // GuidVector possible = botAI->GetAiObjectContext()->GetValue("possible targets no los")->Get(); // if (pullTarget && find(possible.begin(), possible.end(), pullTarget) == possible.end()) // { // context->GetValue("pull target")->Set(ObjectGuid::Empty); // } context->GetValue("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("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("prioritized targets")->Set({rtiTarget->GetGUID()}); bool result = Attack(botAI->GetUnit(rtiTarget->GetGUID())); if (result) { context->GetValue("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; }