From ec77e3a6fd2e2529a7e8e2b329a0c5d08faec9bf Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Wed, 19 Jul 2017 02:17:08 -0400 Subject: [PATCH] Add show_name and untargetable to npc_types fixes #637 Note the bodytype hack is still there since I was having issues with some npcs still showing names --- common/eq_packet_structs.h | 1 + common/patches/rof.cpp | 2 +- common/patches/rof2.cpp | 2 +- common/patches/sod.cpp | 2 +- common/patches/sof.cpp | 10 +++++----- common/patches/uf.cpp | 2 +- utils/sql/git/required/2017_07_19_show_name.sql | 3 +++ zone/client.cpp | 1 + zone/entity.cpp | 4 ++++ zone/npc.cpp | 2 ++ zone/zonedb.cpp | 6 +++++- zone/zonedump.h | 2 ++ 12 files changed, 27 insertions(+), 10 deletions(-) create mode 100644 utils/sql/git/required/2017_07_19_show_name.sql diff --git a/common/eq_packet_structs.h b/common/eq_packet_structs.h index c234e303a..6e853b4bd 100644 --- a/common/eq_packet_structs.h +++ b/common/eq_packet_structs.h @@ -305,6 +305,7 @@ union uint8 DestructibleUnk8; uint32 DestructibleUnk9; bool targetable_with_hotkey; + bool show_name; }; diff --git a/common/patches/rof.cpp b/common/patches/rof.cpp index 23e521a57..7ce6f900f 100644 --- a/common/patches/rof.cpp +++ b/common/patches/rof.cpp @@ -3930,7 +3930,7 @@ namespace RoF if (strlen(emu->suffix)) PacketSize += strlen(emu->suffix) + 1; - bool ShowName = 1; + bool ShowName = emu->show_name; if (emu->bodytype >= 66) { emu->race = 127; diff --git a/common/patches/rof2.cpp b/common/patches/rof2.cpp index 5befaf08c..30efa95b9 100644 --- a/common/patches/rof2.cpp +++ b/common/patches/rof2.cpp @@ -4086,7 +4086,7 @@ namespace RoF2 PacketSize += strlen(emu->DestructibleString) + 1; } - bool ShowName = 1; + bool ShowName = emu->show_name; if (emu->bodytype >= 66) { emu->race = 127; diff --git a/common/patches/sod.cpp b/common/patches/sod.cpp index f6d85f2bb..276f939e5 100644 --- a/common/patches/sod.cpp +++ b/common/patches/sod.cpp @@ -2560,7 +2560,7 @@ namespace SoD PacketSize += strlen(emu->DestructibleString) + 1; } - bool ShowName = 1; + bool ShowName = emu->show_name; if (emu->bodytype >= 66) { emu->race = 127; diff --git a/common/patches/sof.cpp b/common/patches/sof.cpp index 44f093044..77d65ce16 100644 --- a/common/patches/sof.cpp +++ b/common/patches/sof.cpp @@ -2097,7 +2097,7 @@ namespace SoF int k; for (r = 0; r < entrycount; r++, eq++, emu++) { - eq->showname = 1; //New Field - Toggles Name Display on or off - 0 = off, 1 = on + eq->showname = emu->show_name ? 1 : 0; //New Field - Toggles Name Display on or off - 0 = off, 1 = on eq->linkdead = 0; //New Field - Toggles LD on or off after name - 0 = off, 1 = on eq->statue = 0; //New Field - 1 freezes animation eq->showhelm = emu->showhelm; @@ -2136,10 +2136,10 @@ namespace SoF eq->findable = emu->findable; if (emu->bodytype >= 66) { - eq->bodytype = 11; //non-targetable - eq->showname = 0; //no visible name - eq->race = 127; //invisible man - eq->gender = 0; //invisible men are gender 0 + eq->bodytype = 11; //non-targetable + eq->showname = 0; //no visible name + eq->race = 127; //invisible man + eq->gender = 0; //invisible men are gender 0 } else { diff --git a/common/patches/uf.cpp b/common/patches/uf.cpp index b6d251953..8b0c86cc5 100644 --- a/common/patches/uf.cpp +++ b/common/patches/uf.cpp @@ -2844,7 +2844,7 @@ namespace UF PacketSize += strlen(emu->DestructibleString) + 1; } - bool ShowName = 1; + bool ShowName = emu->show_name; if (emu->bodytype >= 66) { emu->race = 127; diff --git a/utils/sql/git/required/2017_07_19_show_name.sql b/utils/sql/git/required/2017_07_19_show_name.sql new file mode 100644 index 000000000..e5bda11cf --- /dev/null +++ b/utils/sql/git/required/2017_07_19_show_name.sql @@ -0,0 +1,3 @@ +ALTER TABLE `npc_types` ADD COLUMN `show_name` TINYINT(2) NOT NULL DEFAULT 1; +ALTER TABLE `npc_types` ADD COLUMN `untargetable` TINYINT(2) NOT NULL DEFAULT 0; +UPDATE `npc_types` SET `show_name` = 0, `untargetable` = 1 WHERE `bodytype` >= 66; diff --git a/zone/client.cpp b/zone/client.cpp index 12988450b..4866013a3 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -1944,6 +1944,7 @@ void Client::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho) ns->spawn.guildID = GuildID(); // ns->spawn.linkdead = IsLD() ? 1 : 0; // ns->spawn.pvp = GetPVP() ? 1 : 0; + ns->spawn.show_name = true; strcpy(ns->spawn.title, m_pp.title); diff --git a/zone/entity.cpp b/zone/entity.cpp index 52eb41165..e9d8139a7 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -659,6 +659,8 @@ void EntityList::AddNPC(NPC *npc, bool SendSpawnPacket, bool dontqueue) QueueClients(npc, app); npc->SendArmorAppearance(); npc->SetAppearance(npc->GetGuardPointAnim(),false); + if (!npc->IsTargetable()) + npc->SendTargetable(false); safe_delete(app); } else { auto ns = new NewSpawn_Struct; @@ -799,6 +801,8 @@ void EntityList::CheckSpawnQueue() NPC *pnpc = it->second; pnpc->SendArmorAppearance(); pnpc->SetAppearance(pnpc->GetGuardPointAnim(), false); + if (!pnpc->IsTargetable()) + pnpc->SendTargetable(false); } safe_delete(outapp); iterator.RemoveCurrent(); diff --git a/zone/npc.cpp b/zone/npc.cpp index 8ddd9b2e3..a4e6c4214 100644 --- a/zone/npc.cpp +++ b/zone/npc.cpp @@ -375,6 +375,7 @@ NPC::NPC(const NPCType* d, Spawn2* in_respawn, const glm::vec4& position, int if CalcBonuses(); raid_target = d->raid_target; ignore_despawn = d->ignore_despawn; + m_targetable = !d->untargetable; } NPC::~NPC() @@ -1906,6 +1907,7 @@ void NPC::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho) ns->spawn.is_npc = 1; UpdateActiveLight(); ns->spawn.light = GetActiveLightType(); + ns->spawn.show_name = NPCTypedata->show_name; } void NPC::PetOnSpawn(NewSpawn_Struct* ns) diff --git a/zone/zonedb.cpp b/zone/zonedb.cpp index d647dcbf7..c90b30ce7 100644 --- a/zone/zonedb.cpp +++ b/zone/zonedb.cpp @@ -1967,7 +1967,9 @@ const NPCType* ZoneDatabase::LoadNPCTypesData(uint32 npc_type_id, bool bulk_load "npc_types.handtexture, " "npc_types.legtexture, " "npc_types.feettexture, " - "npc_types.ignore_despawn " + "npc_types.ignore_despawn, " + "npc_types.show_name, " + "npc_types.untargetable " "FROM npc_types %s", where_condition.c_str() ); @@ -2143,6 +2145,8 @@ const NPCType* ZoneDatabase::LoadNPCTypesData(uint32 npc_type_id, bool bulk_load temp_npctype_data->legtexture = atoi(row[95]); temp_npctype_data->feettexture = atoi(row[96]); temp_npctype_data->ignore_despawn = atoi(row[97]) == 1 ? true : false; + temp_npctype_data->show_name = atoi(row[98]) != 0 ? true : false; + temp_npctype_data->untargetable = atoi(row[99]) != 0 ? true : false; // If NPC with duplicate NPC id already in table, // free item we attempted to add. diff --git a/zone/zonedump.h b/zone/zonedump.h index 713bfca7e..2bd78c2d8 100644 --- a/zone/zonedump.h +++ b/zone/zonedump.h @@ -133,6 +133,8 @@ struct NPCType uint8 legtexture; uint8 feettexture; bool ignore_despawn; + bool show_name; // should default on + bool untargetable; }; namespace player_lootitem {