Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Commands] #npcspawn Changes #4311

Merged
merged 9 commits into from
May 16, 2024
Prev Previous commit
Next Next commit
WIP npcspawn command changes
  • Loading branch information
twincannon committed May 13, 2024
commit e2d57c25a19fb4c13639427967feea50d09b097b
9 changes: 5 additions & 4 deletions zone/gm_commands/npcedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1666,22 +1666,23 @@ void command_npcedit(Client *c, const Seperator *sep)
} else if (!strcasecmp(sep->arg[1], "set_grid")) {
if (sep->IsNumber(2)) {
const uint32 grid_id = Strings::ToUnsignedInt(sep->arg[2]);
if (grid_id) {
if (grid_id >= 0) {
d = fmt::format(
"{} now has a Grid ID of {} on Spawn Group ID {}.",
npc_id_string,
grid_id,
Strings::Commify(std::to_string(t->GetSpawnGroupId()))
);
auto query = fmt::format(
"UPDATE spawn2 SET pathgrid = {} WHERE spawngroupID = {} AND version = {}",
"UPDATE spawn2 SET pathgrid = {} WHERE spawngroupID = {} AND version = {} AND zone = {}", // actually is this dangerous? since spawngroupID isn't unique? should also check zone?
grid_id,
t->GetSpawnGroupId(),
zone->GetInstanceVersion()
zone->GetInstanceVersion(),
zone->GetShortName()
);
content_db.QueryDatabase(query);
} else {
c->Message(Chat::White, "Grid ID must be greater than 0.");
c->Message(Chat::White, "Grid ID must be greater than or equal to 0.");
return;
}
} else {
Expand Down
8 changes: 4 additions & 4 deletions zone/npc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1269,7 +1269,7 @@ uint32 ZoneDatabase::CreateNewNPCCommand(
return false;
}

auto sg = SpawngroupRepository::NewEntity();
/*auto sg = SpawngroupRepository::NewEntity();

sg.name = fmt::format(
"{}-{}",
Expand All @@ -1283,7 +1283,7 @@ uint32 ZoneDatabase::CreateNewNPCCommand(
return false;
}

n->SetSpawnGroupId(sg.id);
n->SetSpawnGroupId(sg.id);*/
n->SetNPCTypeID(e.id);

auto s2 = Spawn2Repository::NewEntity();
Expand All @@ -1295,7 +1295,7 @@ uint32 ZoneDatabase::CreateNewNPCCommand(
s2.z = n->GetZ();
s2.respawntime = 1200;
s2.heading = n->GetHeading();
s2.spawngroupID = sg.id;
s2.spawngroupID = n->GetSpawnGroupId(); //sg.id; //this isn't right... I want to optionally create a new spawngroup - initially yes, subsequently no

s2 = Spawn2Repository::InsertOne(*this, s2);

Expand All @@ -1305,7 +1305,7 @@ uint32 ZoneDatabase::CreateNewNPCCommand(

auto se = SpawnentryRepository::NewEntity();

se.spawngroupID = sg.id;
se.spawngroupID = n->GetSpawnGroupId(); //sg.id;
se.npcID = e.id;
se.chance = 100;

Expand Down