From f2ff4245c0cdf901b05b3d25692ee681be7074f8 Mon Sep 17 00:00:00 2001 From: Alex King <89047260+Kinglykrab@users.noreply.github.com> Date: Sat, 24 Jun 2023 14:14:19 -0400 Subject: [PATCH] [Commands] Consolidate #merchant_close_shop and #merchant_open_shop to #merchantshop (#3433) * [Commands] Consolidate #merchant_close_shop and #merchant_open_shop to #merchantshop # Notes - `#merchant_close_shop` and `#merchant_open_shop` are now consolidated into `#merchantshop`. - Command now works on any type of merchant instead of just regular merchants. - Can be used on Merchants, Discord Merchants, Adventure Merchants, Norrath's Keepers Merchants, Dark Reign Merchants, and Alternate Currency Merchants. * Update merchantshop.cpp * Update merchantshop.cpp * Update merchantshop.cpp --- zone/client_packet.cpp | 12 ++++-- zone/command.cpp | 6 +-- zone/command.h | 3 +- zone/gm_commands/merchantcloseshop.cpp | 13 ------- zone/gm_commands/merchantopenshop.cpp | 13 ------- zone/gm_commands/merchantshop.cpp | 52 ++++++++++++++++++++++++++ zone/string_ids.h | 3 ++ 7 files changed, 66 insertions(+), 36 deletions(-) delete mode 100755 zone/gm_commands/merchantcloseshop.cpp delete mode 100755 zone/gm_commands/merchantopenshop.cpp create mode 100755 zone/gm_commands/merchantshop.cpp diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index c96df6b58..97fb2c21e 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -2120,6 +2120,11 @@ void Client::Handle_OP_AdventureMerchantRequest(const EQApplicationPacket *app) (tmp->GetClass() != DISCORD_MERCHANT) && (tmp->GetClass() != NORRATHS_KEEPERS_MERCHANT) && (tmp->GetClass() != DARK_REIGN_MERCHANT))) return; + if (!tmp->CastToNPC()->IsMerchantOpen()) { + tmp->SayString(zone->random.Int(MERCHANT_CLOSED_ONE, MERCHANT_CLOSED_THREE)); + return; + } + //you have to be somewhat close to them to be properly using them if (DistanceSquared(m_Position, tmp->GetPosition()) > USE_NPC_RANGE2) return; @@ -14021,9 +14026,8 @@ void Client::Handle_OP_ShopRequest(const EQApplicationPacket *app) if (tmp->Charmed()) action = 0; - // 1199 I don't have time for that now. etc if (!tmp->CastToNPC()->IsMerchantOpen()) { - tmp->SayString(zone->random.Int(1199, 1202)); + tmp->SayString(zone->random.Int(MERCHANT_CLOSED_ONE, MERCHANT_CLOSED_THREE)); action = 0; } @@ -14428,8 +14432,8 @@ void Client::Handle_OP_TargetCommand(const EQApplicationPacket *app) if (nt) { if (GetGM() || (!nt->IsInvisible(this) && (DistanceSquared(m_Position, nt->GetPosition()) <= TARGETING_RANGE*TARGETING_RANGE))) { - if (nt->GetBodyType() == BT_NoTarget2 || - nt->GetBodyType() == BT_Special || + if (nt->GetBodyType() == BT_NoTarget2 || + nt->GetBodyType() == BT_Special || nt->GetBodyType() == BT_NoTarget) { can_target = false; } diff --git a/zone/command.cpp b/zone/command.cpp index fdb72abb9..2fea8458e 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -205,8 +205,7 @@ int command_init(void) command_add("mana", "Fill your or your target's mana", AccountStatus::Guide, command_mana) || command_add("maxskills", "Maxes skills for you or your player target.", AccountStatus::GMMgmt, command_max_all_skills) || command_add("memspell", "[Spell ID] [Spell Gem] - Memorize a Spell by ID to the specified Spell Gem for you or your target", AccountStatus::Guide, command_memspell) || - command_add("merchant_close_shop", "Closes a merchant shop", AccountStatus::GMAdmin, command_merchantcloseshop) || - command_add("merchant_open_shop", "Opens a merchants shop", AccountStatus::GMAdmin, command_merchantopenshop) || + command_add("merchantshop", "Closes or opens your target merchant's shop", AccountStatus::GMAdmin, command_merchantshop) || command_add("modifynpcstat", "[Stat] [Value] - Modifies an NPC's stats temporarily.", AccountStatus::GMLeadAdmin, command_modifynpcstat) || command_add("motd", "[Message of the Day] - Set Message of the Day (leave empty to have no Message of the Day)", AccountStatus::GMLeadAdmin, command_motd) || command_add("movechar", "[Character ID|Character Name] [Zone ID|Zone Short Name] - Move an offline character to the specified zone", AccountStatus::Guide, command_movechar) || @@ -1045,8 +1044,7 @@ void command_bot(Client *c, const Seperator *sep) #include "gm_commands/mana.cpp" #include "gm_commands/max_all_skills.cpp" #include "gm_commands/memspell.cpp" -#include "gm_commands/merchantcloseshop.cpp" -#include "gm_commands/merchantopenshop.cpp" +#include "gm_commands/merchantshop.cpp" #include "gm_commands/modifynpcstat.cpp" #include "gm_commands/motd.cpp" #include "gm_commands/movechar.cpp" diff --git a/zone/command.h b/zone/command.h index c967229a0..9e6e1229d 100644 --- a/zone/command.h +++ b/zone/command.h @@ -155,8 +155,7 @@ void command_makepet(Client *c, const Seperator *sep); void command_mana(Client *c, const Seperator *sep); void command_max_all_skills(Client *c, const Seperator *sep); void command_memspell(Client *c, const Seperator *sep); -void command_merchantcloseshop(Client *c, const Seperator *sep); -void command_merchantopenshop(Client *c, const Seperator *sep); +void command_merchantshop(Client *c, const Seperator *sep); void command_modifynpcstat(Client *c, const Seperator *sep); void command_motd(Client *c, const Seperator *sep); void command_movechar(Client *c, const Seperator *sep); diff --git a/zone/gm_commands/merchantcloseshop.cpp b/zone/gm_commands/merchantcloseshop.cpp deleted file mode 100755 index 571d80d46..000000000 --- a/zone/gm_commands/merchantcloseshop.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "../client.h" - -void command_merchantcloseshop(Client *c, const Seperator *sep) -{ - Mob *merchant = c->GetTarget(); - if (!merchant || merchant->GetClass() != MERCHANT) { - c->Message(Chat::White, "You must target a merchant to close their shop."); - return; - } - - merchant->CastToNPC()->MerchantCloseShop(); -} - diff --git a/zone/gm_commands/merchantopenshop.cpp b/zone/gm_commands/merchantopenshop.cpp deleted file mode 100755 index cd05465ba..000000000 --- a/zone/gm_commands/merchantopenshop.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "../client.h" - -void command_merchantopenshop(Client *c, const Seperator *sep) -{ - Mob *merchant = c->GetTarget(); - if (!merchant || merchant->GetClass() != MERCHANT) { - c->Message(Chat::White, "You must target a merchant to open their shop."); - return; - } - - merchant->CastToNPC()->MerchantOpenShop(); -} - diff --git a/zone/gm_commands/merchantshop.cpp b/zone/gm_commands/merchantshop.cpp new file mode 100755 index 000000000..9a803f363 --- /dev/null +++ b/zone/gm_commands/merchantshop.cpp @@ -0,0 +1,52 @@ +#include "../client.h" + +void command_merchantshop(Client *c, const Seperator *sep) +{ + const auto m = c->GetTarget(); + if ( + !m || + !m->IsNPC() || + ( + m->GetClass() != MERCHANT && + m->GetClass() != DISCORD_MERCHANT && + m->GetClass() != ADVENTURE_MERCHANT && + m->GetClass() != NORRATHS_KEEPERS_MERCHANT && + m->GetClass() != DARK_REIGN_MERCHANT && + m->GetClass() != ALT_CURRENCY_MERCHANT + ) + ) { + c->Message(Chat::White, "You must target a merchant."); + return; + } + + const auto arguments = sep->argnum; + if (!arguments) { + c->Message(Chat::White, "#merchantshop close - Close your targeted merchant's shop"); + c->Message(Chat::White, "#merchantshop open - Open your targeted merchant's shop"); + return; + } + + const bool is_close = !strcasecmp(sep->arg[1], "close"); + const bool is_open = !strcasecmp(sep->arg[1], "open"); + if (!is_close && !is_open) { + c->Message(Chat::White, "#merchantshop close - Close your targeted merchant's shop"); + c->Message(Chat::White, "#merchantshop open - Open your targeted merchant's shop"); + return; + } + + if (is_close) { + m->CastToNPC()->MerchantCloseShop(); + } else if (is_open) { + m->CastToNPC()->MerchantOpenShop(); + } + + c->Message( + Chat::White, + fmt::format( + "{} shop for {}.", + is_close ? "Closed" : "Opened", + c->GetTargetDescription(m) + ).c_str() + ); +} + diff --git a/zone/string_ids.h b/zone/string_ids.h index 08a7a9a72..208fc030b 100644 --- a/zone/string_ids.h +++ b/zone/string_ids.h @@ -248,6 +248,9 @@ #define WONT_SELL_DEEDS5 1170 //I am tolerant by nature..but infidels like you push me past my limit..get out! #define WONT_SELL_DEEDS6 1171 //I cannot abide you or your actions against all that is right..BE GONE! #define AA_POINT 1197 //point +#define MERCHANT_CLOSED_ONE 1199 //I don't have time for that now. +#define MERCHANT_CLOSED_TWO 1200 //Can't you see I'm doing something here? +#define MERCHANT_CLOSED_THREE 1201 //I am not open for business right now. #define AA_POINTS 1215 //points #define SPELL_FIZZLE_OTHER 1218 //%1's spell fizzles! #define MISSED_NOTE_OTHER 1219 //A missed note brings %1's song to a close!