diff --git a/playerbot/PlayerbotAI.cpp b/playerbot/PlayerbotAI.cpp index 9612f522..898ec2e1 100644 --- a/playerbot/PlayerbotAI.cpp +++ b/playerbot/PlayerbotAI.cpp @@ -3178,6 +3178,37 @@ bool PlayerbotAI::TellPlayerNoFacing(Player* player, std::string text, Playerbot if (type == CHAT_MSG_SYSTEM && (sPlayerbotAIConfig.randomBotSayWithoutMaster || HasStrategy("debug", BotState::BOT_STATE_NON_COMBAT))) type = CHAT_MSG_SAY; + if ((sPlayerbotAIConfig.hasLog("chat_log.csv") && HasStrategy("debug log", BotState::BOT_STATE_NON_COMBAT)) || HasStrategy("debug logname", BotState::BOT_STATE_NON_COMBAT)) + { + std::ostringstream out; + out << sPlayerbotAIConfig.GetTimestampStr() << "+00,"; + out << bot->GetName() << ","; + out << std::fixed << std::setprecision(2); + + out << std::to_string(bot->getRace()) << ","; + out << std::to_string(bot->getClass()) << ","; + float subLevel = GetLevelFloat(); + + out << subLevel << ","; + out << std::fixed << std::setprecision(2); + WorldPosition(bot).printWKT(out); + + out << type << ","; + out << text; + + if (HasStrategy("debug logname", BotState::BOT_STATE_NON_COMBAT)) + { + std::string fileName = "chat_log_"; + fileName += bot->GetName(); + fileName += ".csv"; + if (!sPlayerbotAIConfig.isLogOpen(fileName)) + sPlayerbotAIConfig.openLog(fileName, "a", true); + sPlayerbotAIConfig.log(fileName, out.str().c_str()); + } + else + sPlayerbotAIConfig.log("chat_log.csv", out.str().c_str()); + } + WorldPacket data; switch (type) diff --git a/playerbot/strategy/StrategyContext.h b/playerbot/strategy/StrategyContext.h index 044da0ba..0905063e 100644 --- a/playerbot/strategy/StrategyContext.h +++ b/playerbot/strategy/StrategyContext.h @@ -128,6 +128,8 @@ namespace ai creators["debug mount"] = &StrategyContext::debug_mount; creators["debug grind"] = &StrategyContext::debug_grind; creators["debug loot"] = &StrategyContext::debug_loot; + creators["debug log"] = &StrategyContext::debug_log; + creators["debug logname"] = &StrategyContext::debug_logname; creators["rtsc"] = &StrategyContext::rtsc; creators["rtsc jump"] = &StrategyContext::rtsc_jump; creators["maintenance"] = &StrategyContext::maintenance; @@ -231,6 +233,8 @@ namespace ai static Strategy* debug_mount(PlayerbotAI* ai) { return new DebugMountStrategy(ai); } static Strategy* debug_grind(PlayerbotAI* ai) { return new DebugGrindStrategy(ai); } static Strategy* debug_loot(PlayerbotAI* ai) { return new DebugLootStrategy(ai); } + static Strategy* debug_log(PlayerbotAI* ai) { return new DebugLogStrategy(ai); } + static Strategy* debug_logname(PlayerbotAI* ai) { return new DebugLogNameStrategy(ai); } static Strategy* rtsc(PlayerbotAI* ai) { return new RTSCStrategy(ai); } static Strategy* rtsc_jump(PlayerbotAI* ai) { return new RTSCSJumptrategy(ai); } static Strategy* maintenance(PlayerbotAI* ai) { return new MaintenanceStrategy(ai); } diff --git a/playerbot/strategy/generic/DebugStrategy.h b/playerbot/strategy/generic/DebugStrategy.h index 1bc8d173..9cb1223d 100644 --- a/playerbot/strategy/generic/DebugStrategy.h +++ b/playerbot/strategy/generic/DebugStrategy.h @@ -148,6 +148,36 @@ namespace ai return "This strategy will make the bot give chat feedback about looting."; } virtual std::vector GetRelatedStrategies() { return { "debug" }; } +#endif + }; + + class DebugLogStrategy : public Strategy + { + public: + DebugLogStrategy(PlayerbotAI* ai) : Strategy(ai) {} + virtual int GetType() { return STRATEGY_TYPE_NONCOMBAT; } + virtual std::string getName() { return "debug log"; } +#ifdef GenerateBotHelp + virtual std::string GetHelpName() { return "debug log"; } //Must equal iternal name + virtual std::string GetHelpDescription() { + return "This strategy will bots log anything they say to master to a logfile"; + } + virtual std::vector GetRelatedStrategies() { return { "debug" }; } +#endif + }; + + class DebugLogNameStrategy : public Strategy + { + public: + DebugLogNameStrategy(PlayerbotAI* ai) : Strategy(ai) {} + virtual int GetType() { return STRATEGY_TYPE_NONCOMBAT; } + virtual std::string getName() { return "debug logname"; } +#ifdef GenerateBotHelp + virtual std::string GetHelpName() { return "debug logname"; } //Must equal iternal name + virtual std::string GetHelpDescription() { + return "This strategy will bots log anything they say to master to a logfile with the bot's name"; + } + virtual std::vector GetRelatedStrategies() { return { "debug" }; } #endif }; }