Implement flymode

This commit is contained in:
Akkadius 2019-07-10 03:39:07 -05:00
parent dfa90aaac5
commit 35eb5b24dd
8 changed files with 172 additions and 134 deletions

View File

@ -1,5 +1,10 @@
EQEMu Changelog (Started on Sept 24, 2003 15:50) EQEMu Changelog (Started on Sept 24, 2003 15:50)
------------------------------------------------------- -------------------------------------------------------
== 7/10/2019 ==
Akkadius: Add #npcedit flymode [0 = ground, 1 = flying, 2 = levitate, 3 = water, 4 = floating]
Akkadius: Added "flymode" to npc_types database table
== 7/3/2019 == == 7/3/2019 ==
Akkadius/KLS: Akkadius/KLS:

View File

@ -31,7 +31,7 @@
*/ */
#define CURRENT_BINARY_DATABASE_VERSION 9140 #define CURRENT_BINARY_DATABASE_VERSION 9141
#ifdef BOTS #ifdef BOTS
#define CURRENT_BINARY_BOTS_DATABASE_VERSION 9024 #define CURRENT_BINARY_BOTS_DATABASE_VERSION 9024

View File

@ -394,6 +394,7 @@
9138|2018_12_12_convert_to_client_functions.sql|SELECT `id` FROM `faction_list` WHERE `id` > 4999|empty| 9138|2018_12_12_convert_to_client_functions.sql|SELECT `id` FROM `faction_list` WHERE `id` > 4999|empty|
9139|2019_03_25_optional_npc_model.sql|SHOW COLUMNS FROM `npc_types` LIKE 'model'|empty| 9139|2019_03_25_optional_npc_model.sql|SHOW COLUMNS FROM `npc_types` LIKE 'model'|empty|
9140|2019_07_03_update_range.sql|SHOW COLUMNS FROM `npc_types` LIKE 'max_movement_update_range'|empty| 9140|2019_07_03_update_range.sql|SHOW COLUMNS FROM `npc_types` LIKE 'max_movement_update_range'|empty|
9141|2019_07_10_npc_flymode.sql|SHOW COLUMNS FROM `npc_types` LIKE 'flymode'|empty|
# Upgrade conditions: # Upgrade conditions:
# This won't be needed after this system is implemented, but it is used database that are not # This won't be needed after this system is implemented, but it is used database that are not

View File

@ -0,0 +1 @@
ALTER TABLE `npc_types` ADD COLUMN `flymode` tinyint(4) NOT NULL DEFAULT -1;

View File

@ -7342,6 +7342,7 @@ void command_npcedit(Client *c, const Seperator *sep)
c->Message(0, "#npcedit no_target - Set an NPC's ability to be targeted with the target hotkey"); c->Message(0, "#npcedit no_target - Set an NPC's ability to be targeted with the target hotkey");
c->Message(0, "#npcedit version - Set an NPC's version"); c->Message(0, "#npcedit version - Set an NPC's version");
c->Message(0, "#npcedit slow_mitigation - Set an NPC's slow mitigation"); c->Message(0, "#npcedit slow_mitigation - Set an NPC's slow mitigation");
c->Message(0, "#npcedit flymode - Set an NPC's flymode [0 = ground, 1 = flying, 2 = levitate, 3 = water, 4 = floating]");
} }
@ -7360,6 +7361,13 @@ void command_npcedit(Client *c, const Seperator *sep)
return; return;
} }
if (strcasecmp(sep->arg[1], "flymode") == 0) {
c->Message(15,"NPCID %u now has flymode [%s]", npcTypeID, sep->argplus[2]);
std::string query = StringFormat("UPDATE npc_types SET flymode = '%s' WHERE id = %i", sep->argplus[2],npcTypeID);
database.QueryDatabase(query);
return;
}
if (strcasecmp(sep->arg[1], "race") == 0) { if (strcasecmp(sep->arg[1], "race") == 0) {
c->Message(15,"NPCID %u now has the race %i.", npcTypeID, atoi(sep->argplus[2])); c->Message(15,"NPCID %u now has the race %i.", npcTypeID, atoi(sep->argplus[2]));
std::string query = StringFormat("UPDATE npc_types SET race = %i WHERE id = %i", atoi(sep->argplus[2]),npcTypeID); std::string query = StringFormat("UPDATE npc_types SET race = %i WHERE id = %i", atoi(sep->argplus[2]),npcTypeID);

View File

@ -226,6 +226,11 @@ NPC::NPC(const NPCType *npc_type_data, Spawn2 *in_respawn, const glm::vec4 &posi
merchant_open = GetClass() == MERCHANT; merchant_open = GetClass() == MERCHANT;
adventure_template_id = npc_type_data->adventure_template; adventure_template_id = npc_type_data->adventure_template;
flymode = iflymode; flymode = iflymode;
if (npc_type_data->flymode >= 0) {
flymode = static_cast<GravityBehavior>(npc_type_data->flymode);
}
guard_anim = eaStanding; guard_anim = eaStanding;
roambox_distance = 0; roambox_distance = 0;
roambox_max_x = -2; roambox_max_x = -2;

View File

@ -2372,8 +2372,9 @@ const NPCType* ZoneDatabase::LoadNPCTypesData(uint32 npc_type_id, bool bulk_load
/* If there is a cached NPC entry, load it */ /* If there is a cached NPC entry, load it */
auto itr = zone->npctable.find(npc_type_id); auto itr = zone->npctable.find(npc_type_id);
if(itr != zone->npctable.end()) if (itr != zone->npctable.end()) {
return itr->second; return itr->second;
}
std::string where_condition = ""; std::string where_condition = "";
@ -2382,13 +2383,16 @@ const NPCType* ZoneDatabase::LoadNPCTypesData(uint32 npc_type_id, bool bulk_load
where_condition = StringFormat( where_condition = StringFormat(
"INNER JOIN spawnentry ON npc_types.id = spawnentry.npcID " "INNER JOIN spawnentry ON npc_types.id = spawnentry.npcID "
"INNER JOIN spawn2 ON spawnentry.spawngroupID = spawn2.spawngroupID " "INNER JOIN spawn2 ON spawnentry.spawngroupID = spawn2.spawngroupID "
"WHERE spawn2.zone = '%s' and spawn2.version = %u GROUP BY npc_types.id", zone->GetShortName(), zone->GetInstanceVersion()); "WHERE spawn2.zone = '%s' and spawn2.version = %u GROUP BY npc_types.id",
zone->GetShortName(),
zone->GetInstanceVersion());
} }
else { else {
where_condition = StringFormat("WHERE id = %u", npc_type_id); where_condition = StringFormat("WHERE id = %u", npc_type_id);
} }
std::string query = StringFormat("SELECT " std::string query = StringFormat(
"SELECT "
"npc_types.id, " "npc_types.id, "
"npc_types.name, " "npc_types.name, "
"npc_types.level, " "npc_types.level, "
@ -2499,7 +2503,8 @@ const NPCType* ZoneDatabase::LoadNPCTypesData(uint32 npc_type_id, bool bulk_load
"npc_types.skip_global_loot, " "npc_types.skip_global_loot, "
"npc_types.rare_spawn, " "npc_types.rare_spawn, "
"npc_types.stuck_behavior, " "npc_types.stuck_behavior, "
"npc_types.model " "npc_types.model, "
"npc_types.flymode "
"FROM npc_types %s", "FROM npc_types %s",
where_condition.c_str() where_condition.c_str()
); );
@ -2553,10 +2558,12 @@ const NPCType* ZoneDatabase::LoadNPCTypesData(uint32 npc_type_id, bool bulk_load
temp_npctype_data->max_dmg = atoi(row[33]); temp_npctype_data->max_dmg = atoi(row[33]);
temp_npctype_data->attack_count = atoi(row[34]); temp_npctype_data->attack_count = atoi(row[34]);
if (row[35] != nullptr) if (row[35] != nullptr) {
strn0cpy(temp_npctype_data->special_abilities, row[35], 512); strn0cpy(temp_npctype_data->special_abilities, row[35], 512);
else }
else {
temp_npctype_data->special_abilities[0] = '\0'; temp_npctype_data->special_abilities[0] = '\0';
}
temp_npctype_data->npc_spells_id = atoi(row[36]); temp_npctype_data->npc_spells_id = atoi(row[36]);
temp_npctype_data->npc_spells_effects_id = atoi(row[37]); temp_npctype_data->npc_spells_effects_id = atoi(row[37]);
@ -2574,17 +2581,21 @@ const NPCType* ZoneDatabase::LoadNPCTypesData(uint32 npc_type_id, bool bulk_load
// set default value for aggroradius // set default value for aggroradius
temp_npctype_data->aggroradius = (int32) atoi(row[49]); temp_npctype_data->aggroradius = (int32) atoi(row[49]);
if (temp_npctype_data->aggroradius <= 0) if (temp_npctype_data->aggroradius <= 0) {
temp_npctype_data->aggroradius = 70; temp_npctype_data->aggroradius = 70;
}
temp_npctype_data->assistradius = (int32) atoi(row[50]); temp_npctype_data->assistradius = (int32) atoi(row[50]);
if (temp_npctype_data->assistradius <= 0) if (temp_npctype_data->assistradius <= 0) {
temp_npctype_data->assistradius = temp_npctype_data->aggroradius; temp_npctype_data->assistradius = temp_npctype_data->aggroradius;
}
if (row[51] && strlen(row[51])) if (row[51] && strlen(row[51])) {
temp_npctype_data->bodytype = (uint8) atoi(row[51]); temp_npctype_data->bodytype = (uint8) atoi(row[51]);
else }
else {
temp_npctype_data->bodytype = 0; temp_npctype_data->bodytype = 0;
}
temp_npctype_data->npc_faction_id = atoi(row[52]); temp_npctype_data->npc_faction_id = atoi(row[52]);
@ -2618,10 +2629,12 @@ const NPCType* ZoneDatabase::LoadNPCTypesData(uint32 npc_type_id, bool bulk_load
"red8x, grn8x, blu8x, " "red8x, grn8x, blu8x, "
"red9x, grn9x, blu9x " "red9x, grn9x, blu9x "
"FROM npc_types_tint WHERE id = %d", "FROM npc_types_tint WHERE id = %d",
armor_tint_id); armor_tint_id
);
auto armortint_results = QueryDatabase(armortint_query); auto armortint_results = QueryDatabase(armortint_query);
if (!armortint_results.Success() || armortint_results.RowCount() == 0) if (!armortint_results.Success() || armortint_results.RowCount() == 0) {
armor_tint_id = 0; armor_tint_id = 0;
}
else { else {
auto armorTint_row = armortint_results.begin(); auto armorTint_row = armortint_results.begin();
@ -2629,7 +2642,8 @@ const NPCType* ZoneDatabase::LoadNPCTypesData(uint32 npc_type_id, bool bulk_load
temp_npctype_data->armor_tint.Slot[index].Color = atoi(armorTint_row[index * 3]) << 16; temp_npctype_data->armor_tint.Slot[index].Color = atoi(armorTint_row[index * 3]) << 16;
temp_npctype_data->armor_tint.Slot[index].Color |= atoi(armorTint_row[index * 3 + 1]) << 8; temp_npctype_data->armor_tint.Slot[index].Color |= atoi(armorTint_row[index * 3 + 1]) << 8;
temp_npctype_data->armor_tint.Slot[index].Color |= atoi(armorTint_row[index * 3 + 2]); temp_npctype_data->armor_tint.Slot[index].Color |= atoi(armorTint_row[index * 3 + 2]);
temp_npctype_data->armor_tint.Slot[index].Color |= (temp_npctype_data->armor_tint.Slot[index].Color) ? (0xFF << 24) : 0; temp_npctype_data->armor_tint.Slot[index].Color |= (temp_npctype_data->armor_tint.Slot[index].Color)
? (0xFF << 24) : 0;
} }
} }
} }
@ -2643,8 +2657,9 @@ const NPCType* ZoneDatabase::LoadNPCTypesData(uint32 npc_type_id, bool bulk_load
temp_npctype_data->see_invis = atoi(row[67]); temp_npctype_data->see_invis = atoi(row[67]);
temp_npctype_data->see_invis_undead = atoi(row[68]) == 0 ? false : true; // Set see_invis_undead flag temp_npctype_data->see_invis_undead = atoi(row[68]) == 0 ? false : true; // Set see_invis_undead flag
if (row[69] != nullptr) if (row[69] != nullptr) {
strn0cpy(temp_npctype_data->lastname, row[69], 32); strn0cpy(temp_npctype_data->lastname, row[69], 32);
}
temp_npctype_data->qglobal = atoi(row[70]) == 0 ? false : true; // qglobal temp_npctype_data->qglobal = atoi(row[70]) == 0 ? false : true; // qglobal
temp_npctype_data->AC = atoi(row[71]); temp_npctype_data->AC = atoi(row[71]);
@ -2690,6 +2705,8 @@ const NPCType* ZoneDatabase::LoadNPCTypesData(uint32 npc_type_id, bool bulk_load
temp_npctype_data->rare_spawn = atoi(row[108]) != 0; temp_npctype_data->rare_spawn = atoi(row[108]) != 0;
temp_npctype_data->stuck_behavior = atoi(row[109]); temp_npctype_data->stuck_behavior = atoi(row[109]);
temp_npctype_data->use_model = atoi(row[110]); temp_npctype_data->use_model = atoi(row[110]);
temp_npctype_data->flymode = atoi(row[111]);
temp_npctype_data->skip_auto_scale = false; // hardcoded here for now temp_npctype_data->skip_auto_scale = false; // hardcoded here for now
// If NPC with duplicate NPC id already in table, // If NPC with duplicate NPC id already in table,

View File

@ -146,6 +146,7 @@ struct NPCType
bool skip_auto_scale; // just so it doesn't mess up bots or mercs, probably should add to DB too just in case bool skip_auto_scale; // just so it doesn't mess up bots or mercs, probably should add to DB too just in case
int8 stuck_behavior; int8 stuck_behavior;
uint16 use_model; uint16 use_model;
int8 flymode;
}; };
namespace player_lootitem { namespace player_lootitem {