Вспомнился старенький эмуль...
Получилось у меня сделать только с добавлением нового класса.
Что-то мне подсказывает, что это ох как не правильно
Всё хорошо, кроме как ,если воспользоваться командой с мобов не собрать лут (отсутствует владелец).
PHP код:
diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp
index d526d26..b4f5df4 100644
--- a/src/game/Chat.cpp
+++ b/src/game/Chat.cpp
@@ -708,6 +708,7 @@ ChatCommand * ChatHandler::getCommandTable()
{ "recall", SEC_MODERATOR, false, &ChatHandler::HandleRecallCommand, "", NULL },
{ "save", SEC_PLAYER, false, &ChatHandler::HandleSaveCommand, "", NULL },
{ "saveall", SEC_MODERATOR, true, &ChatHandler::HandleSaveAllCommand, "", NULL },
+ { "killallnpc", SEC_ADMINISTRATOR, false, &ChatHandler::HandleKillAllNpcCommand, "", NULL },
{ "kick", SEC_GAMEMASTER, true, &ChatHandler::HandleKickPlayerCommand, "", NULL },
{ "ban", SEC_ADMINISTRATOR, true, NULL, "", banCommandTable },
{ "unban", SEC_ADMINISTRATOR, true, NULL, "", unbanCommandTable },
diff --git a/src/game/Chat.h b/src/game/Chat.h
index d85c3e7..97097cf 100644
--- a/src/game/Chat.h
+++ b/src/game/Chat.h
@@ -532,6 +532,7 @@ class ChatHandler
bool HandleGetDistanceCommand(char* args);
bool HandleModifyStandStateCommand(char* args);
bool HandleDieCommand(char* args);
+ bool HandleKillAllNpcCommand(char* args);
bool HandleDamageCommand(char* args);
bool HandleReviveCommand(char* args);
bool HandleModifyMorphCommand(char* args);
diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp
index ec637db..40b4e0b 100644
--- a/src/game/Creature.cpp
+++ b/src/game/Creature.cpp
@@ -1469,6 +1469,15 @@ bool Creature::FallGround()
return true;
}
+void Creature::Kill()
+{
+ if (isAlive())
+ {
+ SetDeathState(JUST_DIED);
+ SetHealth(0);
+ }
+}
+
void Creature::Respawn()
{
RemoveCorpse();
diff --git a/src/game/Creature.h b/src/game/Creature.h
index 9d31181..41a99c1 100644
--- a/src/game/Creature.h
+++ b/src/game/Creature.h
@@ -593,6 +593,8 @@ class MANGOS_DLL_SPEC Creature : public Unit
void SetRespawnTime(uint32 respawn) { m_respawnTime = respawn ? time(NULL) + respawn : 0; }
void Respawn();
void SaveRespawnTime();
+
+ void Kill();
uint32 GetRespawnDelay() const { return m_respawnDelay; }
void SetRespawnDelay(uint32 delay) { m_respawnDelay = delay; }
diff --git a/src/game/GridNotifiers.cpp b/src/game/GridNotifiers.cpp
index ca2a774..d4431fd 100644
--- a/src/game/GridNotifiers.cpp
+++ b/src/game/GridNotifiers.cpp
@@ -237,6 +237,13 @@ void MaNGOS::RespawnDo::operator()( GameObject* u ) const
u->Respawn();
}
+void MaNGOS::KillDo::operator()( Creature* u ) const
+{
+ Map* map = u->GetMap();
+
+ u->Kill();
+}
+
template void ObjectUpdater::Visit<GameObject>(GameObjectMapType &);
template void ObjectUpdater::Visit<DynamicObject>(DynamicObjectMapType &);
diff --git a/src/game/GridNotifiers.h b/src/game/GridNotifiers.h
index 45c6b90..b633fe4 100644
--- a/src/game/GridNotifiers.h
+++ b/src/game/GridNotifiers.h
@@ -602,6 +602,13 @@ namespace MaNGOS
float i_range;
};
+ class KillDo
+ {
+ public:
+ KillDo() {}
+ void operator()(Creature* u) const;
+ };
+
// WorldObject do classes
class RespawnDo
diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp
index 3e3bb12..233499c 100644
--- a/src/game/Level3.cpp
+++ b/src/game/Level3.cpp
@@ -3694,6 +3694,16 @@ bool ChatHandler::HandleDieCommand(char* /*args*/)
return true;
}
+bool ChatHandler::HandleKillAllNpcCommand(char* /*args*/)
+{
+ Player* pl = m_session->GetPlayer();
+
+ MaNGOS::KillDo u_do;
+ MaNGOS::CreatureWorker<MaNGOS::KillDo> worker(pl, u_do);
+ Cell::VisitGridObjects(pl, worker, pl->GetMap()->GetVisibilityDistance());
+ return true;
+}
+
bool ChatHandler::HandleDamageCommand(char* args)
{
if (!*args)
Код:
DELETE FROM `command` WHERE (`name`='killallnpc');
INSERT INTO `command` VALUES
('killallnpc',3,'Syntax: .killallnpc\r\n\r\nKill all npc.');