mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-22 12:18:27 +00:00
[Commands] Cleanup #attack Command. (#2103)
- Cleanup messages and logic.
This commit is contained in:
+30
-10
@@ -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()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user