/* * Copyright (C) 2016+ AzerothCore , released under GNU AGPL v3 license, you may redistribute it * and/or modify it under version 3 of the License, or (at your option), any later version. */ #include "TellTargetAction.h" #include "Event.h" #include "CombatManager.h" #include "ThreatManager.h" #include "AiObjectContext.h" #include "PlayerbotAI.h" bool TellTargetAction::Execute(Event /*event*/) { Unit* target = context->GetValue("current target")->Get(); if (target) { std::ostringstream out; out << "Attacking " << target->GetName(); botAI->TellMaster(out); context->GetValue("old target")->Set(target); } return true; } bool TellAttackersAction::Execute(Event /*event*/) { botAI->TellMaster("--- Attackers ---"); GuidVector attackers = context->GetValue("attackers")->Get(); int32 count = 0; for (ObjectGuid const guid : attackers) { Unit* unit = botAI->GetUnit(guid); if (!unit || !unit->IsAlive()) continue; botAI->TellMaster(std::to_string(++count) + std::string(".") + unit->GetName()); } botAI->TellMaster("--- Threat ---"); auto const& threatenedByMe = bot->GetThreatMgr().GetThreatenedByMeList(); if (threatenedByMe.empty()) return true; for (auto const& [guid, ref] : threatenedByMe) { Unit* unit = ref->GetOwner(); if (!unit) continue; float threat = ref->GetThreat(); std::ostringstream out; out << unit->GetName() << " (" << threat << ")"; botAI->TellMaster(out); } return true; }