[Commands] Cleanup #attack Command. (#2103)

- Cleanup messages and logic.
This commit is contained in:
Kinglykrab 2022-05-03 23:05:16 -04:00 committed by GitHub
parent 35044becc1
commit 04f3d6286c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 11 deletions

View File

@ -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) ||

View File

@ -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);
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, "Error: %s not found", sep->arg[1]);
std::string entity_name = sep->argplus[1];
if (entity_name.empty()) {
c->Message(Chat::White, "Usage: #attack [Entity Name]");
return;
}
}
else {
c->Message(Chat::White, "Usage: (needs NPC targeted) #attack targetname");
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()
);
}
}