diff --git a/zone/command.cpp b/zone/command.cpp index 336cd9e59..6dc06cc3f 100755 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -122,7 +122,7 @@ int command_init(void) command_add("appearance", "[type] [value] - Send an appearance packet for you or your target", AccountStatus::GMLeadAdmin, command_appearance) || command_add("appearanceeffects", "- [view] [set] [remove] appearance effects.", AccountStatus::GMAdmin, command_appearanceeffects) || command_add("apply_shared_memory", "[shared_memory_name] - Tells every zone and world to apply a specific shared memory segment by name.", AccountStatus::GMImpossible, command_apply_shared_memory) || - command_add("attack", "[targetname] - Make your NPC target attack targetname", AccountStatus::GMLeadAdmin, command_attack) || + command_add("attack", "[Entity Name] - Make your NPC target attack an entity by name", AccountStatus::GMLeadAdmin, command_attack) || command_add("augmentitem", "Force augments an item. Must have the augment item window open.", AccountStatus::GMImpossible, command_augmentitem) || command_add("ban", "[name] [reason]- Ban by character name", AccountStatus::GMLeadAdmin, command_ban) || command_add("beard", "- Change the beard of your target", AccountStatus::QuestTroupe, command_beard) || diff --git a/zone/gm_commands/attack.cpp b/zone/gm_commands/attack.cpp index c4a483aa9..dc6f3e29e 100755 --- a/zone/gm_commands/attack.cpp +++ b/zone/gm_commands/attack.cpp @@ -2,17 +2,37 @@ void command_attack(Client *c, const Seperator *sep) { - if (c->GetTarget() && c->GetTarget()->IsNPC() && sep->arg[1] != 0) { - Mob *sictar = entity_list.GetMob(sep->argplus[1]); - if (sictar) { - c->GetTarget()->CastToNPC()->AddToHateList(sictar, 1, 0); - } - else { - c->Message(Chat::White, "Error: %s not found", sep->arg[1]); - } + if (!c->GetTarget() || !c->GetTarget()->IsNPC()) { + c->Message(Chat::White, "You must target an NPC to use this command."); + return; } - else { - c->Message(Chat::White, "Usage: (needs NPC targeted) #attack targetname"); + + std::string entity_name = sep->argplus[1]; + if (entity_name.empty()) { + c->Message(Chat::White, "Usage: #attack [Entity Name]"); + return; + } + + auto entity = entity_list.GetMob(entity_name.c_str()); + if (entity) { + c->GetTarget()->AddToHateList(entity, 1); + c->Message( + Chat::EchoChat1, + fmt::format( + "{} whispers, 'Attacking {} ({}).'", + c->GetTarget()->GetCleanName(), + entity->GetCleanName(), + entity->GetID() + ).c_str() + ); + } else { + c->Message( + Chat::White, + fmt::format( + "No entity by the name of '{}' could be found.", + entity_name + ).c_str() + ); } }