enable battleground

This commit is contained in:
Yunfan Li
2023-10-19 00:20:45 +08:00
parent e5e05988b2
commit 29b748803e
16 changed files with 151 additions and 36 deletions

View File

@@ -8,6 +8,7 @@
#include "BattlegroundMgr.h"
#include "Event.h"
#include "GroupMgr.h"
#include "PlayerbotAI.h"
#include "Playerbots.h"
#include "PositionValue.h"
@@ -466,7 +467,8 @@ bool BGJoinAction::JoinQueue(uint32 type)
// get battlemaster
Unit* unit = botAI->GetUnit(AI_VALUE2(CreatureData const*, "bg master", bgTypeId));
if (!unit && isArena)
{
{
botAI->GetAiObjectContext()->GetValue<uint32>("bg type")->Set(0);
LOG_DEBUG("playerbots", "Bot {} could not find Battlemaster to join", bot->GetGUID().ToString().c_str());
return false;
}
@@ -1102,3 +1104,17 @@ bool BGStatusCheckAction::isUseful()
{
return bot->InBattlegroundQueue();
}
bool BGStrategyCheckAction::Execute(Event event)
{
bool inside_bg = bot->InBattleground() && bot->GetBattleground();;
if (!inside_bg && botAI->HasStrategy("battleground", BOT_STATE_NON_COMBAT)) {
botAI->ResetStrategies();
return true;
}
if (inside_bg && !botAI->HasStrategy("battleground", BOT_STATE_NON_COMBAT)) {
botAI->ResetStrategies();
return false;
}
return false;
}

View File

@@ -66,4 +66,11 @@ class BGStatusCheckAction : public Action
bool isUseful() override;
};
class BGStrategyCheckAction : public Action
{
public:
BGStrategyCheckAction(PlayerbotAI* botAI, std::string const name = "bg strategy check") : Action(botAI, name) { }
bool Execute(Event event) override;
};
#endif

View File

@@ -120,7 +120,7 @@ bool EquipUpgradesAction::Execute(Event event)
ItemUsage usage = AI_VALUE2(ItemUsage, "item usage", i->first);
if (usage == ITEM_USAGE_EQUIP || usage == ITEM_USAGE_REPLACE || usage == ITEM_USAGE_BAD_EQUIP)
{
LOG_INFO("playerbots", "Bot {} <{}> auto equips item {} ({})", bot->GetGUID().ToString().c_str(), bot->GetName().c_str(), i->first, usage == 1 ? "no item in slot" : usage == 2 ? "replace" : usage == 3 ? "wrong item but empty slot" : "");
// LOG_INFO("playerbots", "Bot {} <{}> auto equips item {} ({})", bot->GetGUID().ToString().c_str(), bot->GetName().c_str(), i->first, usage == 1 ? "no item in slot" : usage == 2 ? "replace" : usage == 3 ? "wrong item but empty slot" : "");
items.insert(i->first);
}
}

View File

@@ -5,6 +5,8 @@
#include "ReleaseSpiritAction.h"
#include "Event.h"
#include "GameGraveyard.h"
#include "ObjectDefines.h"
#include "ObjectGuid.h"
#include "Playerbots.h"
#include "ServerFacade.h"
@@ -43,17 +45,34 @@ bool ReleaseSpiritAction::Execute(Event event)
packet << uint8(0);
bot->GetSession()->HandleRepopRequestOpcode(packet);
// add waiting for ress aura
if (bot->InBattleground() && !botAI->HasAura(2584, bot))
{
// cast Waiting for Resurrect
bot->CastSpell(bot, 2584, true);
}
// add waiting for ress aura
if (bot->InBattleground())
bot->CastSpell(bot, 2584, true);
// // add waiting for ress aura
// if (bot->InBattleground() && !botAI->HasAura(SPELL_WAITING_FOR_RESURRECT, bot) && !bot->IsAlive())
// {
// // cast Waiting for Resurrect
// GuidVector npcs = AI_VALUE(GuidVector, "nearest npcs");
// ObjectGuid guid;
// Unit* unit;
// for (GuidVector::iterator i = npcs.begin(); i != npcs.end(); i++)
// {
// unit = botAI->GetUnit(*i);
// if (unit && unit->IsSpiritService())
// {
// guid = unit->GetGUID();
// break;
// }
// }
// if (!guid) {
// return true;
// }
// if (bot->GetDistance(unit) >= INTERACTION_DISTANCE) {
// bot->GetMotionMaster()->MoveChase(unit);
// } else {
// WorldPacket packet(CMSG_GOSSIP_HELLO);
// packet << guid;
// bot->GetSession()->HandleGossipHelloOpcode(packet);
// }
// }
return true;
}
@@ -75,10 +94,31 @@ bool AutoReleaseSpiritAction::Execute(Event event)
LOG_DEBUG("playerbots", "Bot {} {}:{} <{}> releases spirit", bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->getLevel(), bot->GetName().c_str());
if (bot->InBattleground() && !botAI->HasAura(2584, bot))
if (bot->InBattleground() && (time(NULL) - bg_gossip_time >= 15 || !bot->HasAura(SPELL_WAITING_FOR_RESURRECT)))
{
// cast Waiting for Resurrect
bot->CastSpell(bot, 2584, true);
GuidVector npcs = AI_VALUE(GuidVector, "nearest npcs");
ObjectGuid guid;
Unit* unit;
for (GuidVector::iterator i = npcs.begin(); i != npcs.end(); i++)
{
unit = botAI->GetUnit(*i);
if (unit && unit->IsSpiritService())
{
guid = unit->GetGUID();
break;
}
}
if (!guid) {
return true;
}
if (bot->GetDistance(unit) >= INTERACTION_DISTANCE) {
bot->GetMotionMaster()->MoveChase(unit);
} else {
bg_gossip_time = time(NULL);
WorldPacket packet(CMSG_GOSSIP_HELLO);
packet << guid;
bot->GetSession()->HandleGossipHelloOpcode(packet);
}
}
return true;
@@ -93,7 +133,7 @@ bool AutoReleaseSpiritAction::isUseful()
return false;
if (bot->InBattleground())
return !bot->GetCorpse();
return true;
if (bot->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST))
return false;

View File

@@ -7,6 +7,7 @@
#include "Action.h"
#include "ReviveFromCorpseAction.h"
#include <cstdint>
class PlayerbotAI;
@@ -25,6 +26,8 @@ class AutoReleaseSpiritAction : public ReleaseSpiritAction
bool Execute(Event event) override;
bool isUseful() override;
private:
uint32_t bg_gossip_time = 0;
};
class RepopAction : public SpiritHealerAction

View File

@@ -90,8 +90,8 @@ bool FindCorpseAction::Execute(Event event)
{
if (dCount >= 5)
{
LOG_INFO("playerbots", "Bot {} {}:{} <{}>: died too many times, was revived and teleported",
bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->getLevel(), bot->GetName().c_str());
// LOG_INFO("playerbots", "Bot {} {}:{} <{}>: died too many times, was revived and teleported",
// bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->getLevel(), bot->GetName().c_str());
context->GetValue<uint32>("death count")->Set(0);
// sRandomPlayerbotMgr->RandomTeleportForLevel(bot);
sRandomPlayerbotMgr->Revive(bot);

View File

@@ -77,6 +77,7 @@ class WorldPacketActionContext : public NamedObjectContext<Action>
creators["guild accept"] = &WorldPacketActionContext::guild_accept;
creators["inventory change failure"] = &WorldPacketActionContext::inventory_change_failure;
creators["bg status check"] = &WorldPacketActionContext::bg_status_check;
creators["bg strategy check"] = &WorldPacketActionContext::bg_strategy_check;
creators["bg status"] = &WorldPacketActionContext::bg_status;
creators["bg join"] = &WorldPacketActionContext::bg_join;
creators["bg leave"] = &WorldPacketActionContext::bg_leave;
@@ -129,6 +130,7 @@ class WorldPacketActionContext : public NamedObjectContext<Action>
static Action* bg_leave(PlayerbotAI* botAI) { return new BGLeaveAction(botAI); }
static Action* bg_status(PlayerbotAI* botAI) { return new BGStatusAction(botAI); }
static Action* bg_status_check(PlayerbotAI* botAI) { return new BGStatusCheckAction(botAI); }
static Action* bg_strategy_check(PlayerbotAI* botAI) { return new BGStrategyCheckAction(botAI); }
static Action* arena_tactics(PlayerbotAI* botAI) { return new ArenaTactics(botAI); }
static Action* petition_sign(PlayerbotAI* botAI) { return new PetitionSignAction(botAI); }
static Action* lfg_teleport(PlayerbotAI* botAI) { return new LfgTeleportAction(botAI); }