eqemu-server/zone/gm_commands/killallnpcs.cpp
Chris Miles 0550fcfd3f
[GM Commands] Split GM Commands Into Separate Files (#1766)
* Split GM commands into their own files

* Code cleanup
2021-11-14 22:48:47 -06:00

46 lines
859 B
C++
Executable File

#include "../client.h"
void command_killallnpcs(Client *c, const Seperator *sep)
{
std::string search_string;
if (sep->arg[1]) {
search_string = sep->arg[1];
}
int count = 0;
for (auto &itr : entity_list.GetMobList()) {
Mob *entity = itr.second;
if (!entity->IsNPC()) {
continue;
}
std::string entity_name = entity->GetName();
/**
* Filter by name
*/
if (search_string.length() > 0 && entity_name.find(search_string) == std::string::npos) {
continue;
}
bool is_not_attackable =
(
entity->IsInvisible() ||
!entity->IsAttackAllowed(c) ||
entity->GetRace() == 127 ||
entity->GetRace() == 240
);
if (is_not_attackable) {
continue;
}
entity->Damage(c, 1000000000, 0, EQ::skills::SkillDragonPunch);
count++;
}
c->Message(Chat::Yellow, "Killed (%i) npc(s)", count);
}