From 6c73fee075d81ff8442c2f666e0af938b91ac142 Mon Sep 17 00:00:00 2001 From: Uleat Date: Thu, 27 Jun 2019 19:00:02 -0400 Subject: [PATCH] Added bot command 'petgetlost' to dismiss summoned pets --- common/version.h | 2 +- .../sql/git/bots/bots_db_update_manifest.txt | 1 + .../required/2019_06_27_bots_pet_get_lost.sql | 1 + zone/bot_command.cpp | 37 ++++++++++++++++++- zone/bot_command.h | 1 + 5 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 utils/sql/git/bots/required/2019_06_27_bots_pet_get_lost.sql diff --git a/common/version.h b/common/version.h index 1684fe0d2..19d05220b 100644 --- a/common/version.h +++ b/common/version.h @@ -34,7 +34,7 @@ #define CURRENT_BINARY_DATABASE_VERSION 9139 #ifdef BOTS - #define CURRENT_BINARY_BOTS_DATABASE_VERSION 9023 + #define CURRENT_BINARY_BOTS_DATABASE_VERSION 9024 #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 21aa4161b..982200f2a 100644 --- a/utils/sql/git/bots/bots_db_update_manifest.txt +++ b/utils/sql/git/bots/bots_db_update_manifest.txt @@ -22,6 +22,7 @@ 9021|2018_10_09_bots_owner_options.sql|SHOW TABLES LIKE 'bot_owner_options'|empty| 9022|2019_02_07_bots_stance_type_update.sql|SELECT * FROM `bot_spell_casting_chances` WHERE `spell_type_index` = '255' AND `class_id` = '255' AND `stance_index` = '0'|not_empty| 9023|2019_06_22_bots_owner_option_stats_update.sql|SHOW COLUMNS FROM `bot_owner_options` LIKE 'stats_update'|empty| +9024|2019_06_27_bots_pet_get_lost.sql|SELECT `bot_command` FROM `bot_command_settings` WHERE `bot_command` LIKE 'petgetlost'|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/2019_06_27_bots_pet_get_lost.sql b/utils/sql/git/bots/required/2019_06_27_bots_pet_get_lost.sql new file mode 100644 index 000000000..7d0c36624 --- /dev/null +++ b/utils/sql/git/bots/required/2019_06_27_bots_pet_get_lost.sql @@ -0,0 +1 @@ +INSERT INTO `bot_command_settings`(`bot_command`, `access`, `aliases`) VALUES ('petgetlost', '0', 'pgl'); diff --git a/zone/bot_command.cpp b/zone/bot_command.cpp index d92e501d1..69191d991 100644 --- a/zone/bot_command.cpp +++ b/zone/bot_command.cpp @@ -1401,7 +1401,8 @@ int bot_command_init(void) bot_command_add("movementspeed", "Orders a bot to cast a movement speed enhancement spell", 0, bot_command_movement_speed) || bot_command_add("owneroption", "Sets options available to bot owners", 0, bot_command_owner_option) || bot_command_add("pet", "Lists the available bot pet [subcommands]", 0, bot_command_pet) || - bot_command_add("petremove", "Orders a bot to remove its pet", 0, bot_subcommand_pet_remove) || + bot_command_add("petgetlost", "Orders a bot to remove its summoned pet", 0, bot_subcommand_pet_get_lost) || + bot_command_add("petremove", "Orders a bot to remove its charmed pet", 0, bot_subcommand_pet_remove) || bot_command_add("petsettype", "Orders a Magician bot to use a specified pet type", 0, bot_subcommand_pet_set_type) || bot_command_add("picklock", "Orders a capable bot to pick the lock of the closest door", 0, bot_command_pick_lock) || bot_command_add("portal", "Orders a Wizard bot to open a magical doorway to a specified destination", 0, bot_subcommand_portal) || @@ -3479,12 +3480,13 @@ void bot_command_pet(Client *c, const Seperator *sep) { /* VS2012 code - begin */ std::list subcommand_list; + subcommand_list.push_back("petgetlost"); subcommand_list.push_back("petremove"); subcommand_list.push_back("petsettype"); /* VS2012 code - end */ /* VS2013 code - const std::list subcommand_list = { "petremove", "petsettype" }; + const std::list subcommand_list = { "petgetlost", "petremove", "petsettype" }; */ if (helper_command_alias_fail(c, "bot_command_pet", sep->arg[0], "pet")) @@ -7433,6 +7435,37 @@ void bot_subcommand_inventory_window(Client *c, const Seperator *sep) c->SendPopupToClient(window_title.c_str(), window_text.c_str()); } +void bot_subcommand_pet_get_lost(Client *c, const Seperator *sep) +{ + if (helper_command_alias_fail(c, "bot_subcommand_pet_get_lost", sep->arg[0], "petgetlost")) + return; + if (helper_is_help_or_usage(sep->arg[1])) { + c->Message(m_usage, "usage: %s ([actionable: target | byname | ownergroup | botgroup | targetgroup | namesgroup | healrotation | spawned] ([actionable_name]))", sep->arg[0]); + return; + } + int ab_mask = ActionableBots::ABM_NoFilter; + + std::list sbl; + if (ActionableBots::PopulateSBL(c, sep->arg[1], sbl, ab_mask, sep->arg[2]) == ActionableBots::ABT_None) + return; + + int summoned_pet = 0; + for (auto bot_iter : sbl) { + if (!bot_iter->GetPet() || bot_iter->GetPet()->IsCharmed()) + continue; + + bot_iter->GetPet()->Say_StringID(PET_GETLOST_STRING); + bot_iter->GetPet()->Depop(false); + bot_iter->SetPetID(0); + database.botdb.DeletePetItems(bot_iter->GetBotID()); + database.botdb.DeletePetBuffs(bot_iter->GetBotID()); + database.botdb.DeletePetStats(bot_iter->GetBotID()); + ++summoned_pet; + } + + c->Message(m_action, "%i of your bots released their summoned pet%s", summoned_pet, (summoned_pet == 1) ? "" : "s"); +} + 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 603852b38..d60238f23 100644 --- a/zone/bot_command.h +++ b/zone/bot_command.h @@ -652,6 +652,7 @@ 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_get_lost(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);