[Feature] Underworld Command auto return

- Add #underworld to list out all underworld mobs
- Add automatic return to spawn on underworld mobs
This commit is contained in:
Trust 2025-01-26 19:42:31 -05:00
parent 119151c0e3
commit 3ab671e7fe
6 changed files with 37 additions and 0 deletions

View File

@ -230,6 +230,7 @@ int command_init(void)
command_add("traindisc", "[level] - Trains all the disciplines usable by the target, up to level specified. (may freeze client for a few seconds)", AccountStatus::GMLeadAdmin, command_traindisc) ||
command_add("tune", "Calculate statistical values related to combat.", AccountStatus::GMAdmin, command_tune) ||
command_add("undye", "Remove dye from all of your or your target's armor slots", AccountStatus::GMAdmin, command_undye) ||
command_add("underworld", "- Show all mobs under the world", AccountStatus::GMAreas, command_underworld) ||
command_add("unmemspell", "[Spell ID] - Unmemorize a Spell by ID for you or your target", AccountStatus::Guide, command_unmemspell) ||
command_add("unmemspells", " Unmemorize all spells for you or your target", AccountStatus::Guide, command_unmemspells) ||
command_add("unscribespell", "[Spell ID] - Unscribe a spell from your or your target's spell book by Spell ID", AccountStatus::GMCoder, command_unscribespell) ||
@ -923,6 +924,7 @@ void command_bot(Client *c, const Seperator *sep)
#include "gm_commands/task.cpp"
#include "gm_commands/traindisc.cpp"
#include "gm_commands/tune.cpp"
#include "gm_commands/underworld.cpp"
#include "gm_commands/undye.cpp"
#include "gm_commands/unmemspell.cpp"
#include "gm_commands/unmemspells.cpp"

View File

@ -183,6 +183,7 @@ void command_task(Client *c, const Seperator *sep);
void command_petname(Client *c, const Seperator *sep);
void command_traindisc(Client *c, const Seperator *sep);
void command_tune(Client *c, const Seperator *sep);
void command_underworld(Client *c, const Seperator *sep);
void command_undye(Client *c, const Seperator *sep);
void command_unmemspell(Client *c, const Seperator *sep);
void command_unmemspells(Client *c, const Seperator *sep);

View File

@ -5963,3 +5963,20 @@ std::vector<NPC*> EntityList::GetExcludedNPCsByIDs(std::vector<uint32> npc_ids)
return v;
}
void EntityList::GetUnderworldMobs(Client* c) {
float underworld = zone->newzone_data.underworld;
auto it = npc_list.begin();
while (it != npc_list.end()) {
NPC* mob = it->second->CastToNPC();
if (mob->IsTrackable()) {
if (mob->GetZ() <= underworld) {
c->Message(Chat::White, "%s was under the world at %f %f %f. Resetting to spawn point at %f %f %f.",
mob->GetCleanName(), mob->GetX(), mob->GetY(), mob->GetZ(), mob->respawn2->GetX(), mob->respawn2->GetY(), mob->respawn2->GetZ());
mob->Teleport(glm::vec3(mob->respawn2->GetX(), mob->respawn2->GetY(), mob->respawn2->GetZ()));
mob->SentPositionPacket(0.0f, 0.0f, 0.0f, 0.0f, 0, true);
}
}
++it;
}
}

View File

@ -578,6 +578,8 @@ public:
int MovePlayerCorpsesToGraveyard(bool force_move_from_instance = false);
void GetUnderworldMobs(Client* c);
protected:
friend class Zone;
void Depop(bool StartSpawnTimer = false);

View File

@ -0,0 +1,5 @@
#include "../client.h"
void command_underworld(Client *c, const Seperator *sep) {
entity_list.GetUnderworldMobs(c);
}

View File

@ -595,6 +595,16 @@ bool NPC::Process()
spun_timer.Disable();
}
// If mobs are under the world, move them back to spawn point.
if (!IsEngaged() && IsTrackable()) {
if (GetZ() <= zone->newzone_data.underworld) {
if (respawn2) {
Teleport(glm::vec3(respawn2->GetX(), respawn2->GetY(), respawn2->GetZ()));
SentPositionPacket(0.0f, 0.0f, 0.0f, 0.0f, 0, true);
}
}
}
SpellProcess();
if (swarm_timer.Check()) {