From 3ef98c941155e1aa5b55ed95cf1940502e26d126 Mon Sep 17 00:00:00 2001 From: Uleat Date: Tue, 12 Apr 2016 16:46:45 -0400 Subject: [PATCH] Added bot command 'inventorywindow' --- common/version.h | 2 +- .../sql/git/bots/bots_db_update_manifest.txt | 1 + .../2016_04_12_bots_inventory_window.sql | 2 + zone/bot_command.cpp | 61 ++++++++++++++++++- zone/bot_command.h | 1 + zone/botspellsai.cpp | 3 + 6 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 utils/sql/git/bots/required/2016_04_12_bots_inventory_window.sql diff --git a/common/version.h b/common/version.h index bebd65ade..e5a4e6322 100644 --- a/common/version.h +++ b/common/version.h @@ -32,7 +32,7 @@ #define CURRENT_BINARY_DATABASE_VERSION 9096 #ifdef BOTS - #define CURRENT_BINARY_BOTS_DATABASE_VERSION 9005 + #define CURRENT_BINARY_BOTS_DATABASE_VERSION 9006 #else #define CURRENT_BINARY_BOTS_DATABASE_VERSION 0 // must be 0 #endif diff --git a/utils/sql/git/bots/bots_db_update_manifest.txt b/utils/sql/git/bots/bots_db_update_manifest.txt index 08ef5f161..0bfabf0ff 100644 --- a/utils/sql/git/bots/bots_db_update_manifest.txt +++ b/utils/sql/git/bots/bots_db_update_manifest.txt @@ -4,6 +4,7 @@ 9003|2016_04_05_bots_pet_spell_id_field.sql|SHOW COLUMNS FROM `bot_pets` LIKE 'pet_id'|not_empty| 9004|2016_04_07_bots_heal_override_target.sql|SELECT `bot_command` FROM `bot_command_settings` WHERE `bot_command` LIKE 'healrotationclearhot'|empty| 9005|2016_04_08_bots_heal_rotations.sql|SHOW TABLES LIKE 'bot_heal_rotations'|empty| +9006|2016_04_12_bots_inventory_window.sql|SELECT `bot_command` FROM `bot_command_settings` WHERE `bot_command` LIKE 'inventorywindow'|empty| # Upgrade conditions: # This won't be needed after this system is implemented, but it is used database that are not diff --git a/utils/sql/git/bots/required/2016_04_12_bots_inventory_window.sql b/utils/sql/git/bots/required/2016_04_12_bots_inventory_window.sql new file mode 100644 index 000000000..b0269559d --- /dev/null +++ b/utils/sql/git/bots/required/2016_04_12_bots_inventory_window.sql @@ -0,0 +1,2 @@ +INSERT INTO `bot_command_settings` VALUES +('inventorywindow', 0, 'invwindow'); diff --git a/zone/bot_command.cpp b/zone/bot_command.cpp index 5422c41ab..3553f7e8d 100644 --- a/zone/bot_command.cpp +++ b/zone/bot_command.cpp @@ -1390,6 +1390,7 @@ int bot_command_init(void) bot_command_add("inventorygive", "Gives the item on your cursor to a bot", 0, bot_subcommand_inventory_give) || bot_command_add("inventorylist", "Lists all items in a bot's inventory", 0, bot_subcommand_inventory_list) || bot_command_add("inventoryremove", "Removes an item from a bot's inventory", 0, bot_subcommand_inventory_remove) || + bot_command_add("inventorywindow", "Displays all items in a bot's inventory in a pop-up window", 0, bot_subcommand_inventory_window) || bot_command_add("invisibility", "Orders a bot to cast a cloak of invisibility, or allow them to be seen", 0, bot_command_invisibility) || bot_command_add("levitation", "Orders a bot to cast a levitation spell", 0, bot_command_levitation) || bot_command_add("lull", "Orders a bot to cast a pacification spell", 0, bot_command_lull) || @@ -3199,10 +3200,11 @@ void bot_command_inventory(Client *c, const Seperator *sep) subcommand_list.push_back("inventorygive"); subcommand_list.push_back("inventorylist"); subcommand_list.push_back("inventoryremove"); + subcommand_list.push_back("inventorywindow"); /* VS2012 code - end */ /* VS2013 code - const std::list subcommand_list = { "inventorygive", "inventorylist", "inventoryremove" }; + const std::list subcommand_list = { "inventorygive", "inventorylist", "inventoryremove", "inventorywindow" }; */ if (helper_command_alias_fail(c, "bot_command_inventory", sep->arg[0], "inventory")) @@ -7203,6 +7205,63 @@ void bot_subcommand_inventory_remove(Client *c, const Seperator *sep) } } +void bot_subcommand_inventory_window(Client *c, const Seperator *sep) +{ + if (helper_command_alias_fail(c, "bot_subcommand_inventory_window", sep->arg[0], "inventorywindow")) + return; + if (helper_is_help_or_usage(sep->arg[1])) { + c->Message(m_usage, "usage: %s [actionable: target]", sep->arg[0]); + return; + } + int ab_mask = ActionableBots::ABM_Target; + + std::list sbl; + if (ActionableBots::PopulateSBL(c, sep->arg[1], sbl, ab_mask, sep->arg[2]) == ActionableBots::ABT_None) + return; + + auto my_bot = sbl.front(); + if (!my_bot) { + c->Message(m_unknown, "ActionableBots returned 'nullptr'"); + return; + } + + std::string window_title = my_bot->GetCleanName(); + window_title.append("`s Inventory"); + + std::string window_text; + //std::string item_link; + //Client::TextLink linker; + //linker.SetLinkType(linker.linkItemInst); + + for (int i = EQEmu::Constants::EQUIPMENT_BEGIN; i <= (EQEmu::Constants::EQUIPMENT_END + 1); ++i) { + const Item_Struct* item = nullptr; + const ItemInst* inst = my_bot->CastToBot()->GetBotItem(i == 22 ? SlotPowerSource : i); + if (inst) + item = inst->GetItem(); + + window_text.append(""); + window_text.append(GetBotEquipSlotName(i == 22 ? SlotPowerSource : i)); + window_text.append(": "); + if (item) { + //window_text.append(""); + //linker.SetItemInst(inst); + //item_link = linker.GenerateLink(); + //window_text.append(item_link.c_str()); + + window_text.append(""); + window_text.append(StringFormat("%s", item->Name)); + } + else { + window_text.append(""); + window_text.append("[empty]"); + } + window_text.append("
"); + } + window_text.append("
"); + + c->SendPopupToClient(window_title.c_str(), window_text.c_str()); +} + void bot_subcommand_pet_remove(Client *c, const Seperator *sep) { if (helper_command_alias_fail(c, "bot_subcommand_pet_remove", sep->arg[0], "petremove")) diff --git a/zone/bot_command.h b/zone/bot_command.h index 6c7d66a9c..c25c7b0eb 100644 --- a/zone/bot_command.h +++ b/zone/bot_command.h @@ -649,6 +649,7 @@ void bot_subcommand_heal_rotation_stop(Client *c, const Seperator *sep); void bot_subcommand_inventory_give(Client *c, const Seperator *sep); void bot_subcommand_inventory_list(Client *c, const Seperator *sep); void bot_subcommand_inventory_remove(Client *c, const Seperator *sep); +void bot_subcommand_inventory_window(Client *c, const Seperator *sep); void bot_subcommand_pet_remove(Client *c, const Seperator *sep); void bot_subcommand_pet_set_type(Client *c, const Seperator *sep); void bot_subcommand_portal(Client *c, const Seperator *sep); diff --git a/zone/botspellsai.cpp b/zone/botspellsai.cpp index f19808d74..a35760535 100644 --- a/zone/botspellsai.cpp +++ b/zone/botspellsai.cpp @@ -1332,6 +1332,9 @@ bool Bot::AIHealRotation(Mob* tar, bool useFastHeals) { Log.Out(Logs::Detail, Logs::AI, "Bot::AIHealRotation: heal spellid = %u, fastheals = %c, casterlevel = %u", botSpell.SpellId, ((useFastHeals) ? ('T') : ('F')), GetLevel()); #endif +#if BotAI_DEBUG_Spells >= 25 + Log.Out(Logs::Detail, Logs::AI, "Bot::AIHealRotation: target = %s, current_time = %u, donthealmebefore = %u", tar->GetCleanName(), Timer::GetCurrentTime(), tar->DontHealMeBefore()); +#endif // If there is still no spell id, then there isn't going to be one so we are done if (botSpell.SpellId == 0)