mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-01-17 10:45:43 +00:00
Auto do quest feature (new rpg strategy) (#1034)
* New rpg startup speed up and refactor * New rpg do quest * Fix invalid height in quest poi * Add quest accept and reward limitation * New rpg quest improvement * Organize quest log, reward quests and fix grind target * Quest dropped statistic and remove redundant code * Decrease grind relevance lower than loot * Fix new rpg drop quest * Go to reward quest instead of innkeeper when quest completed * Fix incorrect logic in do quest reward * Fix reset quests in factory * Fix crash on grind target value Co-authored-by: SaW <swerkhoven@outlook.com> * Fix a minor error in DoCompletedQuest * Let bots get rid of impossible quests faster * Increase loot fluency (especially for caster) * Remove seasonal quests from auto accept * Enhance quest accept condition check * Add questgiver check (limit acceptation of quest 7946) * Questgiver check and localization * Near npc fix * Fix quest item report * Add lowPriorityQuest set for quests can not be done * Improve gameobjects loot * Do complete quest * FIx move far to teleport check * Accept or reward quest from game objects * Fix possible crash in rpg game objects * Fix ChooseNpcOrGameObjectToInteract crash --------- Co-authored-by: SaW <swerkhoven@outlook.com>
This commit is contained in:
@@ -87,7 +87,7 @@ bool AcceptQuestAction::Execute(Event event)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "AcceptQuestAction [" << qInfo->GetTitle() << "] - [" << std::to_string(qInfo->GetQuestId()) << "]";
|
||||
LOG_INFO("playerbots", "{}", ss.str().c_str());
|
||||
LOG_DEBUG("playerbots", "{}", ss.str().c_str());
|
||||
// botAI->TellMaster(ss.str());
|
||||
}
|
||||
|
||||
|
||||
@@ -247,6 +247,7 @@ public:
|
||||
creators["new rpg go innkeeper"] = &ActionContext::new_rpg_go_innkeeper;
|
||||
creators["new rpg move random"] = &ActionContext::new_rpg_move_random;
|
||||
creators["new rpg move npc"] = &ActionContext::new_rpg_move_npc;
|
||||
creators["new rpg do quest"] = &ActionContext::new_rpg_do_quest;
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -428,6 +429,7 @@ private:
|
||||
static Action* new_rpg_go_innkeeper(PlayerbotAI* ai) { return new NewRpgGoInnKeeperAction(ai); }
|
||||
static Action* new_rpg_move_random(PlayerbotAI* ai) { return new NewRpgMoveRandomAction(ai); }
|
||||
static Action* new_rpg_move_npc(PlayerbotAI* ai) { return new NewRpgMoveNpcAction(ai); }
|
||||
static Action* new_rpg_do_quest(PlayerbotAI* ai) { return new NewRpgDoQuestAction(ai); }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -90,6 +90,7 @@ public:
|
||||
creators["log"] = &ChatActionContext::log;
|
||||
creators["los"] = &ChatActionContext::los;
|
||||
creators["rpg status"] = &ChatActionContext::rpg_status;
|
||||
creators["rpg do quest"] = &ChatActionContext::rpg_do_quest;
|
||||
creators["aura"] = &ChatActionContext::aura;
|
||||
creators["drop"] = &ChatActionContext::drop;
|
||||
creators["clean quest log"] = &ChatActionContext::clean_quest_log;
|
||||
@@ -261,6 +262,7 @@ private:
|
||||
static Action* log(PlayerbotAI* botAI) { return new LogLevelAction(botAI); }
|
||||
static Action* los(PlayerbotAI* botAI) { return new TellLosAction(botAI); }
|
||||
static Action* rpg_status(PlayerbotAI* botAI) { return new TellRpgStatusAction(botAI); }
|
||||
static Action* rpg_do_quest(PlayerbotAI* botAI) { return new StartRpgDoQuestAction(botAI); }
|
||||
static Action* aura(PlayerbotAI* ai) { return new TellAuraAction(ai); }
|
||||
static Action* ll(PlayerbotAI* botAI) { return new LootStrategyAction(botAI); }
|
||||
static Action* ss(PlayerbotAI* botAI) { return new SkipSpellsListAction(botAI); }
|
||||
|
||||
@@ -34,28 +34,17 @@ bool AttackAnythingAction::isUseful()
|
||||
if (!botAI->AllowActivity(GRIND_ACTIVITY)) // Bot not allowed to be active
|
||||
return false;
|
||||
|
||||
if (!AI_VALUE(bool, "can move around"))
|
||||
if (botAI->HasStrategy("stay", BOT_STATE_NON_COMBAT))
|
||||
return false;
|
||||
|
||||
if (bot->IsInCombat())
|
||||
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;
|
||||
|
||||
Unit* target = GetTarget();
|
||||
|
||||
if (!target)
|
||||
return false;
|
||||
|
||||
bool inactiveGrindStatus = botAI->rpgInfo.status == NewRpgStatus::GO_GRIND ||
|
||||
botAI->rpgInfo.status == NewRpgStatus::NEAR_NPC ||
|
||||
botAI->rpgInfo.status == NewRpgStatus::REST ||
|
||||
botAI->rpgInfo.status == NewRpgStatus::GO_INNKEEPER;
|
||||
|
||||
if (inactiveGrindStatus && bot->GetDistance(target) > 25.0f)
|
||||
return false;
|
||||
|
||||
std::string const name = std::string(target->GetName());
|
||||
// Check for invalid targets: Dummy, Charge Target, Melee Target, Ranged Target
|
||||
if (!name.empty() &&
|
||||
|
||||
@@ -132,6 +132,7 @@ bool CleanQuestLogAction::Execute(Event event)
|
||||
}
|
||||
|
||||
// Remove quest
|
||||
botAI->rpgStatistic.questDropped++;
|
||||
bot->SetQuestSlot(slot, 0);
|
||||
bot->TakeQuestSourceItem(questId, false);
|
||||
bot->SetQuestStatus(questId, QUEST_STATUS_NONE);
|
||||
|
||||
@@ -4,9 +4,14 @@
|
||||
*/
|
||||
|
||||
#include "QuestAction.h"
|
||||
#include <sstream>
|
||||
|
||||
#include "Chat.h"
|
||||
#include "ChatHelper.h"
|
||||
#include "Event.h"
|
||||
#include "ItemTemplate.h"
|
||||
#include "ObjectGuid.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "Playerbots.h"
|
||||
#include "ReputationMgr.h"
|
||||
#include "ServerFacade.h"
|
||||
@@ -258,6 +263,7 @@ bool QuestAction::AcceptQuest(Quest const* quest, ObjectGuid questGiver)
|
||||
|
||||
bool QuestUpdateCompleteAction::Execute(Event event)
|
||||
{
|
||||
// the action can hardly be triggered
|
||||
WorldPacket p(event.getPacket());
|
||||
p.rpos(0);
|
||||
|
||||
@@ -265,22 +271,26 @@ bool QuestUpdateCompleteAction::Execute(Event event)
|
||||
p >> questId;
|
||||
|
||||
p.print_storage();
|
||||
LOG_INFO("playerbots", "Packet: empty{} questId{}", p.empty(), questId);
|
||||
// LOG_INFO("playerbots", "Packet: empty{} questId{}", p.empty(), questId);
|
||||
|
||||
Quest const* qInfo = sObjectMgr->GetQuestTemplate(questId);
|
||||
if (qInfo)
|
||||
{
|
||||
std::map<std::string, std::string> placeholders;
|
||||
// std::map<std::string, std::string> placeholders;
|
||||
// placeholders["%quest_link"] = format;
|
||||
|
||||
// if (botAI->HasStrategy("debug quest", BotState::BOT_STATE_NON_COMBAT) || botAI->HasStrategy("debug rpg", BotState::BOT_STATE_COMBAT))
|
||||
// {
|
||||
// LOG_INFO("playerbots", "{} => Quest [ {} ] completed", bot->GetName(), qInfo->GetTitle());
|
||||
// bot->Say("Quest [ " + format + " ] completed", LANG_UNIVERSAL);
|
||||
// }
|
||||
const auto format = ChatHelper::FormatQuest(qInfo);
|
||||
placeholders["%quest_link"] = format;
|
||||
|
||||
if (botAI->HasStrategy("debug quest", BotState::BOT_STATE_NON_COMBAT) || botAI->HasStrategy("debug rpg", BotState::BOT_STATE_COMBAT))
|
||||
{
|
||||
LOG_INFO("playerbots", "{} => Quest [ {} ] completed", bot->GetName(), qInfo->GetTitle());
|
||||
bot->Say("Quest [ " + format + " ] completed", LANG_UNIVERSAL);
|
||||
}
|
||||
botAI->TellMasterNoFacing("Quest completed " + format);
|
||||
if (botAI->GetMaster())
|
||||
botAI->TellMasterNoFacing("Quest completed " + format);
|
||||
BroadcastHelper::BroadcastQuestUpdateComplete(botAI, bot, qInfo);
|
||||
botAI->rpgStatistic.questCompleted++;
|
||||
// LOG_DEBUG("playerbots", "[New rpg] {} complete quest {}", bot->GetName(), qInfo->GetQuestId());
|
||||
// botAI->rpgStatistic.questCompleted++;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -296,39 +306,39 @@ bool QuestUpdateAddKillAction::Execute(Event event)
|
||||
|
||||
uint32 entry, questId, available, required;
|
||||
p >> questId >> entry >> available >> required;
|
||||
|
||||
// LOG_INFO("playerbots", "[New rpg] Quest {} -> Creature {} ({}/{})", questId, entry, available, required);
|
||||
const Quest* qInfo = sObjectMgr->GetQuestTemplate(questId);
|
||||
if (qInfo && (entry & 0x80000000))
|
||||
{
|
||||
entry &= 0x7FFFFFFF;
|
||||
const GameObjectTemplate* info = sObjectMgr->GetGameObjectTemplate(entry);
|
||||
if (info)
|
||||
BroadcastHelper::BroadcastQuestUpdateAddKill(botAI, bot, qInfo, available, required, info->name);
|
||||
{
|
||||
std::string infoName = botAI->GetLocalizedGameObjectName(entry);
|
||||
BroadcastHelper::BroadcastQuestUpdateAddKill(botAI, bot, qInfo, available, required, infoName);
|
||||
if (botAI->GetMaster())
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << infoName << " " << available << "/" << required << " " << ChatHelper::FormatQuest(qInfo);
|
||||
botAI->TellMasterNoFacing(out.str());
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (qInfo)
|
||||
{
|
||||
CreatureTemplate const* info = sObjectMgr->GetCreatureTemplate(entry);
|
||||
if (info)
|
||||
{
|
||||
BroadcastHelper::BroadcastQuestUpdateAddKill(botAI, bot, qInfo, available, required, info->Name);
|
||||
std::string infoName = botAI->GetLocalizedCreatureName(entry);
|
||||
BroadcastHelper::BroadcastQuestUpdateAddKill(botAI, bot, qInfo, available, required, infoName);
|
||||
if (botAI->GetMaster())
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << infoName << " " << available << "/" << required << " " << ChatHelper::FormatQuest(qInfo);
|
||||
botAI->TellMasterNoFacing(out.str());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::map<std::string, std::string> placeholders;
|
||||
placeholders["%quest_id"] = questId;
|
||||
placeholders["%available"] = available;
|
||||
placeholders["%required"] = required;
|
||||
|
||||
if (botAI->HasStrategy("debug quest", BotState::BOT_STATE_COMBAT) || botAI->HasStrategy("debug quest", BotState::BOT_STATE_NON_COMBAT))
|
||||
{
|
||||
LOG_INFO("playerbots", "{} => {}", bot->GetName(), BOT_TEXT2("%available/%required for questId: %quest_id", placeholders));
|
||||
botAI->Say(BOT_TEXT2("%available/%required for questId: %quest_id", placeholders));
|
||||
}
|
||||
|
||||
botAI->TellMasterNoFacing(BOT_TEXT2("%available/%required for questId: %quest_id", placeholders));
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -363,8 +373,62 @@ bool QuestUpdateAddItemAction::Execute(Event event)
|
||||
|
||||
BroadcastHelper::BroadcastQuestUpdateAddItem(botAI, bot, pair.first, availableItemsCount, requiredItemsCount, itemPrototype);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool QuestItemPushResultAction::Execute(Event event)
|
||||
{
|
||||
WorldPacket packet = event.getPacket();
|
||||
ObjectGuid guid;
|
||||
uint32 received, created, sendChatMessage, itemSlot, itemEntry, itemSuffixFactory, count, itemCount;
|
||||
uint8 bagSlot;
|
||||
int32 itemRandomPropertyId;
|
||||
packet >> guid >> received >> created >> sendChatMessage;
|
||||
packet >> bagSlot >> itemSlot >> itemEntry >> itemSuffixFactory >> itemRandomPropertyId;
|
||||
packet >> count >> itemCount;
|
||||
|
||||
if (guid != bot->GetGUID())
|
||||
return false;
|
||||
|
||||
const ItemTemplate* proto = sObjectMgr->GetItemTemplate(itemEntry);
|
||||
if (!proto)
|
||||
return false;
|
||||
|
||||
for (uint16 i = 0; i < MAX_QUEST_LOG_SIZE; ++i)
|
||||
{
|
||||
uint32 questId = bot->GetQuestSlotQuestId(i);
|
||||
if (!questId)
|
||||
continue;
|
||||
|
||||
const Quest* quest = sObjectMgr->GetQuestTemplate(questId);
|
||||
if (!quest)
|
||||
return false;
|
||||
|
||||
const QuestStatusData& q_status = bot->getQuestStatusMap().at(questId);
|
||||
|
||||
for (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; i++)
|
||||
{
|
||||
uint32 itemId = quest->RequiredItemId[i];
|
||||
if (!itemId)
|
||||
continue;
|
||||
|
||||
int32 previousCount = itemCount - count;
|
||||
if (itemId == itemEntry && previousCount < quest->RequiredItemCount[i])
|
||||
{
|
||||
if (botAI->GetMaster())
|
||||
{
|
||||
std::string itemLink = ChatHelper::FormatItem(proto);
|
||||
std::ostringstream out;
|
||||
int32 required = quest->RequiredItemCount[i];
|
||||
int32 available = std::min((int32)itemCount, required);
|
||||
out << itemLink << " " << available << "/" << required << " " << ChatHelper::FormatQuest(quest);
|
||||
botAI->TellMasterNoFacing(out.str());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -66,4 +66,11 @@ public:
|
||||
bool Execute(Event event) override;
|
||||
};
|
||||
|
||||
class QuestItemPushResultAction : public Action
|
||||
{
|
||||
public:
|
||||
QuestItemPushResultAction(PlayerbotAI* ai) : Action(ai, "quest item push result") {}
|
||||
bool Execute(Event event) override;;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -173,7 +173,6 @@ void TalkToQuestGiverAction::RewardMultipleItem(Quest const* quest, Object* ques
|
||||
std::ostringstream outid;
|
||||
if (!botAI->IsAlt() || sPlayerbotAIConfig->autoPickReward == "yes")
|
||||
{
|
||||
// Pick the first item of the best rewards.
|
||||
bestIds = BestRewards(quest);
|
||||
if (!bestIds.empty())
|
||||
{
|
||||
|
||||
@@ -79,7 +79,8 @@ public:
|
||||
creators["quest update failed timer"] = &WorldPacketActionContext::quest_update_failed_timer;
|
||||
creators["quest update complete"] = &WorldPacketActionContext::quest_update_complete;
|
||||
creators["turn in query quest"] = &WorldPacketActionContext::turn_in_query_quest;
|
||||
|
||||
creators["quest item push result"] = &WorldPacketActionContext::quest_item_push_result;
|
||||
|
||||
creators["party command"] = &WorldPacketActionContext::party_command;
|
||||
creators["tell cast failed"] = &WorldPacketActionContext::tell_cast_failed;
|
||||
creators["accept duel"] = &WorldPacketActionContext::accept_duel;
|
||||
@@ -139,6 +140,7 @@ private:
|
||||
static Action* quest_update_failed(PlayerbotAI* ai) { return new QuestUpdateFailedAction(ai); }
|
||||
static Action* quest_update_failed_timer(PlayerbotAI* ai) { return new QuestUpdateFailedTimerAction(ai); }
|
||||
static Action* quest_update_complete(PlayerbotAI* botAI) { return new QuestUpdateCompleteAction(botAI); }
|
||||
static Action* quest_item_push_result(PlayerbotAI* ai) { return new QuestItemPushResultAction(ai); }
|
||||
|
||||
static Action* turn_in_quest(PlayerbotAI* botAI) { return new TalkToQuestGiverAction(botAI); }
|
||||
static Action* accept_quest(PlayerbotAI* botAI) { return new AcceptQuestAction(botAI); }
|
||||
|
||||
Reference in New Issue
Block a user