Skip to content

Commit

Permalink
Added bot command 'petgetlost' to dismiss summoned pets
Browse files Browse the repository at this point in the history
  • Loading branch information
Uleat committed Jun 27, 2019
1 parent ee49ad3 commit 6c73fee
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 3 deletions.
2 changes: 1 addition & 1 deletion common/version.h
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions utils/sql/git/bots/bots_db_update_manifest.txt
Expand Up @@ -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
Expand Down
@@ -0,0 +1 @@
INSERT INTO `bot_command_settings`(`bot_command`, `access`, `aliases`) VALUES ('petgetlost', '0', 'pgl');
37 changes: 35 additions & 2 deletions zone/bot_command.cpp
Expand Up @@ -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) ||
Expand Down Expand Up @@ -3479,12 +3480,13 @@ void bot_command_pet(Client *c, const Seperator *sep)
{
/* VS2012 code - begin */
std::list<const char*> 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<const char*> subcommand_list = { "petremove", "petsettype" };
const std::list<const char*> subcommand_list = { "petgetlost", "petremove", "petsettype" };
*/

if (helper_command_alias_fail(c, "bot_command_pet", sep->arg[0], "pet"))
Expand Down Expand Up @@ -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<Bot*> 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"))
Expand Down
1 change: 1 addition & 0 deletions zone/bot_command.h
Expand Up @@ -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);
Expand Down

0 comments on commit 6c73fee

Please sign in to comment.