mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 06:21:28 +00:00
Fix some zone/npc.cpp functions
This commit is contained in:
parent
96925f0dde
commit
b5d45effec
337
zone/npc.cpp
337
zone/npc.cpp
@ -987,298 +987,267 @@ NPC* NPC::SpawnNPC(const char* spawncommand, const glm::vec4& position, Client*
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 ZoneDatabase::CreateNewNPCCommand(const char* zone, uint32 zone_version,Client *client, NPC* spawn, uint32 extra) {
|
uint32 ZoneDatabase::CreateNewNPCCommand(const char *zone, uint32 zone_version, Client *client, NPC *spawn,
|
||||||
|
uint32 extra)
|
||||||
|
{
|
||||||
|
uint32 npc_type_id = 0;
|
||||||
|
|
||||||
uint32 npc_type_id = 0;
|
if (extra && client && client->GetZoneID()) {
|
||||||
|
|
||||||
if (extra && client && client->GetZoneID())
|
|
||||||
{
|
|
||||||
// Set an npc_type ID within the standard range for the current zone if possible (zone_id * 1000)
|
// Set an npc_type ID within the standard range for the current zone if possible (zone_id * 1000)
|
||||||
int starting_npc_id = client->GetZoneID() * 1000;
|
int starting_npc_id = client->GetZoneID() * 1000;
|
||||||
|
|
||||||
std::string query = StringFormat("SELECT MAX(id) FROM npc_types WHERE id >= %i AND id < %i",
|
std::string query = StringFormat("SELECT MAX(id) FROM npc_types WHERE id >= %i AND id < %i",
|
||||||
starting_npc_id, starting_npc_id + 1000);
|
starting_npc_id, starting_npc_id + 1000);
|
||||||
auto results = QueryDatabase(query);
|
auto results = QueryDatabase(query);
|
||||||
if (results.Success()) {
|
if (results.Success()) {
|
||||||
if (results.RowCount() != 0)
|
if (results.RowCount() != 0) {
|
||||||
{
|
auto row = results.begin();
|
||||||
auto row = results.begin();
|
npc_type_id = atoi(row[0]) + 1;
|
||||||
npc_type_id = atoi(row[0]) + 1;
|
// Prevent the npc_type id from exceeding the range for this zone
|
||||||
// Prevent the npc_type id from exceeding the range for this zone
|
if (npc_type_id >= (starting_npc_id + 1000))
|
||||||
if (npc_type_id >= (starting_npc_id + 1000))
|
npc_type_id = 0;
|
||||||
npc_type_id = 0;
|
} else // No npc_type IDs set in this range yet
|
||||||
}
|
npc_type_id = starting_npc_id;
|
||||||
else // No npc_type IDs set in this range yet
|
}
|
||||||
npc_type_id = starting_npc_id;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
char tmpstr[64];
|
char tmpstr[64];
|
||||||
EntityList::RemoveNumbers(strn0cpy(tmpstr, spawn->GetName(), sizeof(tmpstr)));
|
EntityList::RemoveNumbers(strn0cpy(tmpstr, spawn->GetName(), sizeof(tmpstr)));
|
||||||
std::string query;
|
std::string query;
|
||||||
if (npc_type_id)
|
if (npc_type_id) {
|
||||||
{
|
query = StringFormat("INSERT INTO npc_types (id, name, level, race, class, hp, gender, "
|
||||||
query = StringFormat("INSERT INTO npc_types (id, name, level, race, class, hp, gender, "
|
"texture, helmtexture, size, loottable_id, merchant_id, face, "
|
||||||
"texture, helmtexture, size, loottable_id, merchant_id, face, "
|
"runspeed, prim_melee_type, sec_melee_type) "
|
||||||
"runspeed, prim_melee_type, sec_melee_type) "
|
"VALUES(%i, \"%s\" , %i, %i, %i, %i, %i, %i, %i, %f, %i, %i, %i, %f, %i, %i)",
|
||||||
"VALUES(%i, \"%s\" , %i, %i, %i, %i, %i, %i, %i, %f, %i, %i, %i, %f, %i, %i)",
|
npc_type_id, tmpstr, spawn->GetLevel(), spawn->GetRace(), spawn->GetClass(),
|
||||||
npc_type_id, tmpstr, spawn->GetLevel(), spawn->GetRace(), spawn->GetClass(),
|
spawn->GetMaxHP(), spawn->GetGender(), spawn->GetTexture(),
|
||||||
spawn->GetMaxHP(), spawn->GetGender(), spawn->GetTexture(),
|
spawn->GetHelmTexture(), spawn->GetSize(), spawn->GetLoottableID(),
|
||||||
spawn->GetHelmTexture(), spawn->GetSize(), spawn->GetLoottableID(),
|
spawn->MerchantType, 0, spawn->GetRunspeed(), 28, 28);
|
||||||
spawn->MerchantType, 0, spawn->GetRunspeed(), 28, 28);
|
auto results = QueryDatabase(query);
|
||||||
auto results = QueryDatabase(query);
|
if (!results.Success()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
npc_type_id = results.LastInsertedID();
|
||||||
|
} else {
|
||||||
|
query = StringFormat("INSERT INTO npc_types (name, level, race, class, hp, gender, "
|
||||||
|
"texture, helmtexture, size, loottable_id, merchant_id, face, "
|
||||||
|
"runspeed, prim_melee_type, sec_melee_type) "
|
||||||
|
"VALUES(\"%s\", %i, %i, %i, %i, %i, %i, %i, %f, %i, %i, %i, %f, %i, %i)",
|
||||||
|
tmpstr, spawn->GetLevel(), spawn->GetRace(), spawn->GetClass(), spawn->GetMaxHP(),
|
||||||
|
spawn->GetGender(), spawn->GetTexture(), spawn->GetHelmTexture(), spawn->GetSize(),
|
||||||
|
spawn->GetLoottableID(), spawn->MerchantType, 0, spawn->GetRunspeed(), 28, 28);
|
||||||
|
auto results = QueryDatabase(query);
|
||||||
if (!results.Success()) {
|
if (!results.Success()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
npc_type_id = results.LastInsertedID();
|
npc_type_id = results.LastInsertedID();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
query = StringFormat("INSERT INTO npc_types (name, level, race, class, hp, gender, "
|
|
||||||
"texture, helmtexture, size, loottable_id, merchant_id, face, "
|
|
||||||
"runspeed, prim_melee_type, sec_melee_type) "
|
|
||||||
"VALUES(\"%s\", %i, %i, %i, %i, %i, %i, %i, %f, %i, %i, %i, %f, %i, %i)",
|
|
||||||
tmpstr, spawn->GetLevel(), spawn->GetRace(), spawn->GetClass(),
|
|
||||||
spawn->GetMaxHP(), spawn->GetGender(), spawn->GetTexture(),
|
|
||||||
spawn->GetHelmTexture(), spawn->GetSize(), spawn->GetLoottableID(),
|
|
||||||
spawn->MerchantType, 0, spawn->GetRunspeed(), 28, 28);
|
|
||||||
auto results = QueryDatabase(query);
|
|
||||||
if (!results.Success()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
npc_type_id = results.LastInsertedID();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(client)
|
|
||||||
|
|
||||||
query = StringFormat("INSERT INTO spawngroup (id, name) VALUES(%i, '%s-%s')", 0, zone, spawn->GetName());
|
query = StringFormat("INSERT INTO spawngroup (id, name) VALUES(%i, '%s-%s')", 0, zone, spawn->GetName());
|
||||||
auto results = QueryDatabase(query);
|
auto results = QueryDatabase(query);
|
||||||
if (!results.Success()) {
|
if (!results.Success()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
uint32 spawngroupid = results.LastInsertedID();
|
uint32 spawngroupid = results.LastInsertedID();
|
||||||
|
|
||||||
if(client)
|
query = StringFormat("INSERT INTO spawn2 (zone, version, x, y, z, respawntime, heading, spawngroupID) "
|
||||||
|
"VALUES('%s', %u, %f, %f, %f, %i, %f, %i)",
|
||||||
query = StringFormat("INSERT INTO spawn2 (zone, version, x, y, z, respawntime, heading, spawngroupID) "
|
zone, zone_version, spawn->GetX(), spawn->GetY(), spawn->GetZ(), 1200, spawn->GetHeading(),
|
||||||
"VALUES('%s', %u, %f, %f, %f, %i, %f, %i)",
|
spawngroupid);
|
||||||
zone, zone_version, spawn->GetX(), spawn->GetY(), spawn->GetZ(), 1200,
|
results = QueryDatabase(query);
|
||||||
spawn->GetHeading(), spawngroupid);
|
|
||||||
results = QueryDatabase(query);
|
|
||||||
if (!results.Success()) {
|
if (!results.Success()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(client)
|
query = StringFormat("INSERT INTO spawnentry (spawngroupID, npcID, chance) VALUES(%i, %i, %i)", spawngroupid,
|
||||||
|
npc_type_id, 100);
|
||||||
query = StringFormat("INSERT INTO spawnentry (spawngroupID, npcID, chance) VALUES(%i, %i, %i)",
|
results = QueryDatabase(query);
|
||||||
spawngroupid, npc_type_id, 100);
|
|
||||||
results = QueryDatabase(query);
|
|
||||||
if (!results.Success()) {
|
if (!results.Success()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(client)
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 ZoneDatabase::AddNewNPCSpawnGroupCommand(const char* zone, uint32 zone_version, Client *client, NPC* spawn, uint32 respawnTime) {
|
uint32 ZoneDatabase::AddNewNPCSpawnGroupCommand(const char *zone, uint32 zone_version, Client *client, NPC *spawn,
|
||||||
uint32 last_insert_id = 0;
|
uint32 respawnTime)
|
||||||
|
{
|
||||||
|
uint32 last_insert_id = 0;
|
||||||
|
|
||||||
std::string query = StringFormat("INSERT INTO spawngroup (name) VALUES('%s%s%i')",
|
std::string query = StringFormat("INSERT INTO spawngroup (name) VALUES('%s%s%i')", zone, spawn->GetName(),
|
||||||
zone, spawn->GetName(), Timer::GetCurrentTime());
|
Timer::GetCurrentTime());
|
||||||
auto results = QueryDatabase(query);
|
auto results = QueryDatabase(query);
|
||||||
if (!results.Success()) {
|
if (!results.Success()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
last_insert_id = results.LastInsertedID();
|
last_insert_id = results.LastInsertedID();
|
||||||
|
|
||||||
uint32 respawntime = 0;
|
uint32 respawntime = 0;
|
||||||
uint32 spawnid = 0;
|
uint32 spawnid = 0;
|
||||||
if (respawnTime)
|
if (respawnTime)
|
||||||
respawntime = respawnTime;
|
respawntime = respawnTime;
|
||||||
else if(spawn->respawn2 && spawn->respawn2->RespawnTimer() != 0)
|
else if (spawn->respawn2 && spawn->respawn2->RespawnTimer() != 0)
|
||||||
respawntime = spawn->respawn2->RespawnTimer();
|
respawntime = spawn->respawn2->RespawnTimer();
|
||||||
else
|
else
|
||||||
respawntime = 1200;
|
respawntime = 1200;
|
||||||
|
|
||||||
query = StringFormat("INSERT INTO spawn2 (zone, version, x, y, z, respawntime, heading, spawngroupID) "
|
query = StringFormat("INSERT INTO spawn2 (zone, version, x, y, z, respawntime, heading, spawngroupID) "
|
||||||
"VALUES('%s', %u, %f, %f, %f, %i, %f, %i)",
|
"VALUES('%s', %u, %f, %f, %f, %i, %f, %i)",
|
||||||
zone, zone_version, spawn->GetX(), spawn->GetY(), spawn->GetZ(), respawntime,
|
zone, zone_version, spawn->GetX(), spawn->GetY(), spawn->GetZ(), respawntime,
|
||||||
spawn->GetHeading(), last_insert_id);
|
spawn->GetHeading(), last_insert_id);
|
||||||
results = QueryDatabase(query);
|
results = QueryDatabase(query);
|
||||||
if (!results.Success()) {
|
if (!results.Success()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
spawnid = results.LastInsertedID();
|
spawnid = results.LastInsertedID();
|
||||||
|
|
||||||
if(client)
|
query = StringFormat("INSERT INTO spawnentry (spawngroupID, npcID, chance) VALUES(%i, %i, %i)", last_insert_id,
|
||||||
|
spawn->GetNPCTypeID(), 100);
|
||||||
|
results = QueryDatabase(query);
|
||||||
|
if (!results.Success()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
query = StringFormat("INSERT INTO spawnentry (spawngroupID, npcID, chance) VALUES(%i, %i, %i)",
|
return spawnid;
|
||||||
last_insert_id, spawn->GetNPCTypeID(), 100);
|
|
||||||
results = QueryDatabase(query);
|
|
||||||
if (!results.Success()) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(client)
|
|
||||||
|
|
||||||
return spawnid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 ZoneDatabase::UpdateNPCTypeAppearance(Client *client, NPC* spawn) {
|
uint32 ZoneDatabase::UpdateNPCTypeAppearance(Client *client, NPC *spawn)
|
||||||
|
{
|
||||||
std::string query = StringFormat("UPDATE npc_types SET name = \"%s\", level = %i, race = %i, class = %i, "
|
std::string query =
|
||||||
"hp = %i, gender = %i, texture = %i, helmtexture = %i, size = %i, "
|
StringFormat("UPDATE npc_types SET name = \"%s\", level = %i, race = %i, class = %i, "
|
||||||
"loottable_id = %i, merchant_id = %i, face = %i, WHERE id = %i",
|
"hp = %i, gender = %i, texture = %i, helmtexture = %i, size = %i, "
|
||||||
spawn->GetName(), spawn->GetLevel(), spawn->GetRace(), spawn->GetClass(),
|
"loottable_id = %i, merchant_id = %i, face = %i, WHERE id = %i",
|
||||||
spawn->GetMaxHP(), spawn->GetGender(), spawn->GetTexture(),
|
spawn->GetName(), spawn->GetLevel(), spawn->GetRace(), spawn->GetClass(), spawn->GetMaxHP(),
|
||||||
spawn->GetHelmTexture(), spawn->GetSize(), spawn->GetLoottableID(),
|
spawn->GetGender(), spawn->GetTexture(), spawn->GetHelmTexture(), spawn->GetSize(),
|
||||||
spawn->MerchantType, spawn->GetNPCTypeID());
|
spawn->GetLoottableID(), spawn->MerchantType, spawn->GetNPCTypeID());
|
||||||
auto results = QueryDatabase(query);
|
auto results = QueryDatabase(query);
|
||||||
if (!results.Success() && client)
|
return results.Success() == true ? 1 : 0;
|
||||||
|
|
||||||
return results.Success() == true? 1: 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 ZoneDatabase::DeleteSpawnLeaveInNPCTypeTable(const char* zone, Client *client, NPC* spawn) {
|
uint32 ZoneDatabase::DeleteSpawnLeaveInNPCTypeTable(const char *zone, Client *client, NPC *spawn)
|
||||||
|
{
|
||||||
uint32 id = 0;
|
uint32 id = 0;
|
||||||
uint32 spawngroupID = 0;
|
uint32 spawngroupID = 0;
|
||||||
|
|
||||||
std::string query = StringFormat("SELECT id, spawngroupID FROM spawn2 WHERE "
|
std::string query = StringFormat("SELECT id, spawngroupID FROM spawn2 WHERE "
|
||||||
"zone='%s' AND spawngroupID=%i", zone, spawn->GetSp2());
|
"zone='%s' AND spawngroupID=%i",
|
||||||
auto results = QueryDatabase(query);
|
zone, spawn->GetSp2());
|
||||||
if (!results.Success())
|
auto results = QueryDatabase(query);
|
||||||
|
if (!results.Success())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (results.RowCount() == 0)
|
if (results.RowCount() == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
auto row = results.begin();
|
auto row = results.begin();
|
||||||
if (row[0])
|
if (row[0])
|
||||||
id = atoi(row[0]);
|
id = atoi(row[0]);
|
||||||
|
|
||||||
if (row[1])
|
if (row[1])
|
||||||
spawngroupID = atoi(row[1]);
|
spawngroupID = atoi(row[1]);
|
||||||
|
|
||||||
query = StringFormat("DELETE FROM spawn2 WHERE id = '%i'", id);
|
query = StringFormat("DELETE FROM spawn2 WHERE id = '%i'", id);
|
||||||
results = QueryDatabase(query);
|
results = QueryDatabase(query);
|
||||||
if (!results.Success())
|
if (!results.Success())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if(client)
|
query = StringFormat("DELETE FROM spawngroup WHERE id = '%i'", spawngroupID);
|
||||||
|
results = QueryDatabase(query);
|
||||||
query = StringFormat("DELETE FROM spawngroup WHERE id = '%i'", spawngroupID);
|
|
||||||
results = QueryDatabase(query);
|
|
||||||
if (!results.Success())
|
if (!results.Success())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if(client)
|
query = StringFormat("DELETE FROM spawnentry WHERE spawngroupID = '%i'", spawngroupID);
|
||||||
|
results = QueryDatabase(query);
|
||||||
query = StringFormat("DELETE FROM spawnentry WHERE spawngroupID = '%i'", spawngroupID);
|
|
||||||
results = QueryDatabase(query);
|
|
||||||
if (!results.Success())
|
if (!results.Success())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if(client)
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 ZoneDatabase::DeleteSpawnRemoveFromNPCTypeTable(const char* zone, uint32 zone_version, Client *client, NPC* spawn) {
|
uint32 ZoneDatabase::DeleteSpawnRemoveFromNPCTypeTable(const char *zone, uint32 zone_version, Client *client,
|
||||||
|
NPC *spawn)
|
||||||
|
{
|
||||||
uint32 id = 0;
|
uint32 id = 0;
|
||||||
uint32 spawngroupID = 0;
|
uint32 spawngroupID = 0;
|
||||||
|
|
||||||
std::string query = StringFormat("SELECT id, spawngroupID FROM spawn2 WHERE zone = '%s' "
|
std::string query = StringFormat("SELECT id, spawngroupID FROM spawn2 WHERE zone = '%s' "
|
||||||
"AND version = %u AND spawngroupID = %i",
|
"AND version = %u AND spawngroupID = %i",
|
||||||
zone, zone_version, spawn->GetSp2());
|
zone, zone_version, spawn->GetSp2());
|
||||||
auto results = QueryDatabase(query);
|
auto results = QueryDatabase(query);
|
||||||
if (!results.Success())
|
if (!results.Success())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (results.RowCount() == 0)
|
if (results.RowCount() == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
auto row = results.begin();
|
auto row = results.begin();
|
||||||
|
|
||||||
if (row[0])
|
if (row[0])
|
||||||
id = atoi(row[0]);
|
id = atoi(row[0]);
|
||||||
|
|
||||||
if (row[1])
|
if (row[1])
|
||||||
spawngroupID = atoi(row[1]);
|
spawngroupID = atoi(row[1]);
|
||||||
|
|
||||||
query = StringFormat("DELETE FROM spawn2 WHERE id = '%i'", id);
|
query = StringFormat("DELETE FROM spawn2 WHERE id = '%i'", id);
|
||||||
results = QueryDatabase(query);
|
|
||||||
if (!results.Success())
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if(client)
|
|
||||||
|
|
||||||
query = StringFormat("DELETE FROM spawngroup WHERE id = '%i'", spawngroupID);
|
|
||||||
results = QueryDatabase(query);
|
results = QueryDatabase(query);
|
||||||
if (!results.Success())
|
if (!results.Success())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if(client)
|
query = StringFormat("DELETE FROM spawngroup WHERE id = '%i'", spawngroupID);
|
||||||
|
|
||||||
query = StringFormat("DELETE FROM spawnentry WHERE spawngroupID = '%i'", spawngroupID);
|
|
||||||
results = QueryDatabase(query);
|
results = QueryDatabase(query);
|
||||||
if (!results.Success())
|
if (!results.Success())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if(client)
|
query = StringFormat("DELETE FROM spawnentry WHERE spawngroupID = '%i'", spawngroupID);
|
||||||
|
|
||||||
query = StringFormat("DELETE FROM npc_types WHERE id = '%i'", spawn->GetNPCTypeID());
|
|
||||||
results = QueryDatabase(query);
|
results = QueryDatabase(query);
|
||||||
if (!results.Success())
|
if (!results.Success())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if(client)
|
query = StringFormat("DELETE FROM npc_types WHERE id = '%i'", spawn->GetNPCTypeID());
|
||||||
|
results = QueryDatabase(query);
|
||||||
|
if (!results.Success())
|
||||||
|
return 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 ZoneDatabase::AddSpawnFromSpawnGroup(const char* zone, uint32 zone_version, Client *client, NPC* spawn, uint32 spawnGroupID) {
|
uint32 ZoneDatabase::AddSpawnFromSpawnGroup(const char *zone, uint32 zone_version, Client *client, NPC *spawn,
|
||||||
|
uint32 spawnGroupID)
|
||||||
|
{
|
||||||
uint32 last_insert_id = 0;
|
uint32 last_insert_id = 0;
|
||||||
std::string query = StringFormat("INSERT INTO spawn2 (zone, version, x, y, z, respawntime, heading, spawngroupID) "
|
std::string query =
|
||||||
"VALUES('%s', %u, %f, %f, %f, %i, %f, %i)",
|
StringFormat("INSERT INTO spawn2 (zone, version, x, y, z, respawntime, heading, spawngroupID) "
|
||||||
zone, zone_version, client->GetX(), client->GetY(), client->GetZ(),
|
"VALUES('%s', %u, %f, %f, %f, %i, %f, %i)",
|
||||||
120, client->GetHeading(), spawnGroupID);
|
zone, zone_version, client->GetX(), client->GetY(), client->GetZ(), 120, client->GetHeading(),
|
||||||
auto results = QueryDatabase(query);
|
spawnGroupID);
|
||||||
if (!results.Success())
|
auto results = QueryDatabase(query);
|
||||||
|
if (!results.Success())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if(client)
|
return 1;
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 ZoneDatabase::AddNPCTypes(const char* zone, uint32 zone_version, Client *client, NPC* spawn, uint32 spawnGroupID) {
|
uint32 ZoneDatabase::AddNPCTypes(const char *zone, uint32 zone_version, Client *client, NPC *spawn, uint32 spawnGroupID)
|
||||||
|
{
|
||||||
uint32 npc_type_id;
|
uint32 npc_type_id;
|
||||||
char numberlessName[64];
|
char numberlessName[64];
|
||||||
|
|
||||||
EntityList::RemoveNumbers(strn0cpy(numberlessName, spawn->GetName(), sizeof(numberlessName)));
|
EntityList::RemoveNumbers(strn0cpy(numberlessName, spawn->GetName(), sizeof(numberlessName)));
|
||||||
std::string query = StringFormat("INSERT INTO npc_types (name, level, race, class, hp, gender, "
|
std::string query =
|
||||||
"texture, helmtexture, size, loottable_id, merchant_id, face, "
|
StringFormat("INSERT INTO npc_types (name, level, race, class, hp, gender, "
|
||||||
"runspeed, prim_melee_type, sec_melee_type) "
|
"texture, helmtexture, size, loottable_id, merchant_id, face, "
|
||||||
"VALUES(\"%s\", %i, %i, %i, %i, %i, %i, %i, %f, %i, %i, %i, %f, %i, %i)",
|
"runspeed, prim_melee_type, sec_melee_type) "
|
||||||
numberlessName, spawn->GetLevel(), spawn->GetRace(), spawn->GetClass(),
|
"VALUES(\"%s\", %i, %i, %i, %i, %i, %i, %i, %f, %i, %i, %i, %f, %i, %i)",
|
||||||
spawn->GetMaxHP(), spawn->GetGender(), spawn->GetTexture(),
|
numberlessName, spawn->GetLevel(), spawn->GetRace(), spawn->GetClass(), spawn->GetMaxHP(),
|
||||||
spawn->GetHelmTexture(), spawn->GetSize(), spawn->GetLoottableID(),
|
spawn->GetGender(), spawn->GetTexture(), spawn->GetHelmTexture(), spawn->GetSize(),
|
||||||
spawn->MerchantType, 0, spawn->GetRunspeed(), 28, 28);
|
spawn->GetLoottableID(), spawn->MerchantType, 0, spawn->GetRunspeed(), 28, 28);
|
||||||
auto results = QueryDatabase(query);
|
auto results = QueryDatabase(query);
|
||||||
if (!results.Success())
|
if (!results.Success())
|
||||||
return 0;
|
return 0;
|
||||||
npc_type_id = results.LastInsertedID();
|
npc_type_id = results.LastInsertedID();
|
||||||
|
|
||||||
if(client)
|
if (client)
|
||||||
|
client->Message(0, "%s npc_type ID %i created successfully!", numberlessName, npc_type_id);
|
||||||
if(client)
|
|
||||||
client->Message(0, "%s npc_type ID %i created successfully!", numberlessName, npc_type_id);
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user