diff --git a/zone/command.cpp b/zone/command.cpp index e4baf134e..a83fc46fa 100755 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -209,7 +209,7 @@ int command_init(void) command_add("hair", "- Change the hair style of your target", AccountStatus::QuestTroupe, command_hair) || command_add("haircolor", "- Change the hair color of your target", AccountStatus::QuestTroupe, command_haircolor) || command_add("haste", "[percentage] - Set your haste percentage", AccountStatus::GMAdmin, command_haste) || - command_add("hatelist", " - Display hate list for target.", AccountStatus::QuestTroupe, command_hatelist) || + command_add("hatelist", "- Display hate list for NPC.", AccountStatus::QuestTroupe, command_hatelist) || command_add("heal", "- Completely heal your target", AccountStatus::Steward, command_heal) || command_add("helm", "- Change the helm of your target", AccountStatus::QuestTroupe, command_helm) || command_add("help", "[search term] - List available commands and their description, specify partial command as argument to search", AccountStatus::Player, command_help) || diff --git a/zone/gm_commands/hatelist.cpp b/zone/gm_commands/hatelist.cpp index 13006d47b..83fe75e20 100755 --- a/zone/gm_commands/hatelist.cpp +++ b/zone/gm_commands/hatelist.cpp @@ -2,14 +2,12 @@ void command_hatelist(Client *c, const Seperator *sep) { - Mob *target = c->GetTarget(); - if (target == nullptr) { - c->Message(Chat::White, "Error: you must have a target."); + if (!c->GetTarget() || !c->GetTarget()->IsNPC()) { + c->Message(Chat::White, "You must target an NPC to use this command."); return; } - c->Message(Chat::White, "Display hate list for %s..", target->GetName()); + auto target = c->GetTarget(); + target->PrintHateListToClient(c); } - - diff --git a/zone/hate_list.cpp b/zone/hate_list.cpp index 83ec481fa..75923c99e 100644 --- a/zone/hate_list.cpp +++ b/zone/hate_list.cpp @@ -645,15 +645,53 @@ bool HateList::IsHateListEmpty() { void HateList::PrintHateListToClient(Client *c) { - auto iterator = list.begin(); - while (iterator != list.end()) - { - struct_HateList *e = (*iterator); - c->Message(Chat::White, "- name: %s, damage: %d, hate: %d", - (e->entity_on_hatelist && e->entity_on_hatelist->GetName()) ? e->entity_on_hatelist->GetName() : "(null)", - e->hatelist_damage, e->stored_hate_amount); + if (list.size()) { + c->Message( + Chat::White, + fmt::format( + "Displaying hate list for {} ({}).", + hate_owner->GetCleanName(), + hate_owner->GetID() + ).c_str() + ); - ++iterator; + auto entity_number = 1; + for (const auto& hate_entity : list) { + if (hate_entity->entity_on_hatelist) { + c->Message( + Chat::White, + fmt::format( + "Hate Entity {} | Name: {} ({}) Damage: {} Hate: {}", + entity_number, + hate_entity->entity_on_hatelist->GetName(), + hate_entity->entity_on_hatelist->GetID(), + hate_entity->hatelist_damage, + hate_entity->stored_hate_amount + ).c_str() + ); + } else { + c->Message( + Chat::White, + fmt::format( + "Hate Entity {} | Damage: {} Hate: {}", + entity_number, + hate_entity->hatelist_damage, + hate_entity->stored_hate_amount + ).c_str() + ); + } + + entity_number++; + } + } else { + c->Message( + Chat::White, + fmt::format( + "{} ({}) has nothing on its hatelist.", + hate_owner->GetCleanName(), + hate_owner->GetID() + ).c_str() + ); } }