mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 17:51:28 +00:00
- #guild rename was checking argument count and not allowing you to rename guilds to names that had spaces. - #killallnpcs was crashing zones when used sometimes due to getting a nullptr somewhere in the loop. - #worldwide message was using just the first word of the message sent using the command, not all of them.
77 lines
1.2 KiB
C++
Executable File
77 lines
1.2 KiB
C++
Executable File
#include "../client.h"
|
|
|
|
void command_killallnpcs(Client *c, const Seperator *sep)
|
|
{
|
|
std::string search_string;
|
|
if (sep->arg[1]) {
|
|
search_string = str_tolower(sep->arg[1]);
|
|
}
|
|
|
|
int killed_count = 0;
|
|
for (auto& npc_entity : entity_list.GetNPCList()) {
|
|
auto entity_id = npc_entity.first;
|
|
if (!entity_id) {
|
|
continue;
|
|
}
|
|
|
|
auto npc = npc_entity.second;
|
|
if (!npc) {
|
|
continue;
|
|
}
|
|
|
|
std::string entity_name = str_tolower(npc->GetName());
|
|
if (
|
|
(
|
|
!search_string.empty() &&
|
|
entity_name.find(search_string) == std::string::npos
|
|
) ||
|
|
!npc->IsAttackAllowed(c)
|
|
) {
|
|
continue;
|
|
}
|
|
|
|
npc->Damage(
|
|
c,
|
|
npc->GetHP(),
|
|
SPELL_UNKNOWN,
|
|
EQ::skills::SkillDragonPunch
|
|
);
|
|
|
|
killed_count++;
|
|
}
|
|
|
|
if (killed_count) {
|
|
c->Message(
|
|
Chat::White,
|
|
fmt::format(
|
|
"Killed {} NPC{}{}.",
|
|
killed_count,
|
|
killed_count != 1 ? "s" : "",
|
|
(
|
|
!search_string.empty() ?
|
|
fmt::format(
|
|
" that matched '{}'",
|
|
search_string
|
|
) :
|
|
""
|
|
)
|
|
).c_str()
|
|
);
|
|
} else {
|
|
c->Message(
|
|
Chat::White,
|
|
fmt::format(
|
|
"There were no NPCs to kill{}.",
|
|
(
|
|
!search_string.empty() ?
|
|
fmt::format(
|
|
" that matched '{}'",
|
|
search_string
|
|
) :
|
|
""
|
|
)
|
|
).c_str()
|
|
);
|
|
}
|
|
}
|