From 56afa0404bf236415f93bcf4cd79c84ea856f4ce Mon Sep 17 00:00:00 2001 From: Noudess Date: Wed, 2 Sep 2020 12:50:11 -0400 Subject: [PATCH] Updates to fix taunt button on PET UI to match live behavior. --- common/version.h | 2 +- utils/sql/db_update_manifest.txt | 1 + utils/sql/git/required/2020_09_02_pet_taunting.sql | 1 + zone/client.cpp | 6 +++++- zone/client_packet.cpp | 7 ++++++- zone/pets.cpp | 2 +- zone/spell_effects.cpp | 7 +++++-- zone/zonedb.cpp | 14 ++++++++------ zone/zonedb.h | 1 + 9 files changed, 29 insertions(+), 12 deletions(-) create mode 100644 utils/sql/git/required/2020_09_02_pet_taunting.sql diff --git a/common/version.h b/common/version.h index a481fd1f4..e524afb01 100644 --- a/common/version.h +++ b/common/version.h @@ -34,7 +34,7 @@ * Manifest: https://github.com/EQEmu/Server/blob/master/utils/sql/db_update_manifest.txt */ -#define CURRENT_BINARY_DATABASE_VERSION 9156 +#define CURRENT_BINARY_DATABASE_VERSION 9157 #ifdef BOTS #define CURRENT_BINARY_BOTS_DATABASE_VERSION 9027 diff --git a/utils/sql/db_update_manifest.txt b/utils/sql/db_update_manifest.txt index 58cb8930f..63af98bbd 100644 --- a/utils/sql/db_update_manifest.txt +++ b/utils/sql/db_update_manifest.txt @@ -410,6 +410,7 @@ 9154|2020_04_11_expansions_content_filters.sql|SHOW COLUMNS from `zone` LIKE 'min_expansion'|empty| 9155|2020_08_15_lootdrop_level_filtering.sql|SHOW COLUMNS from `lootdrop_entries` LIKE 'trivial_min_level'|empty| 9156|2020_08_16_virtual_zonepoints.sql|SHOW COLUMNS from `zone_points` LIKE 'is_virtual'|empty| +9157|2020_09_02_pet_taunting.sql|SHOW COLUMNS from `character_pet_info` LIKE 'taunting'|empty| # Upgrade conditions: # This won't be needed after this system is implemented, but it is used database that are not diff --git a/utils/sql/git/required/2020_09_02_pet_taunting.sql b/utils/sql/git/required/2020_09_02_pet_taunting.sql new file mode 100644 index 000000000..f4de1138f --- /dev/null +++ b/utils/sql/git/required/2020_09_02_pet_taunting.sql @@ -0,0 +1 @@ +ALTER TABLE `character_pet_info` ADD COLUMN `taunting` tinyint(1) NOT NULL DEFAULT '1' COMMENT ''; diff --git a/zone/client.cpp b/zone/client.cpp index a413c7899..fdc75cfe6 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -687,6 +687,7 @@ bool Client::Save(uint8 iCommitNow) { pet->GetPetState(m_petinfo.Buffs, m_petinfo.Items, m_petinfo.Name); m_petinfo.petpower = pet->GetPetPower(); m_petinfo.size = pet->GetSize(); + m_petinfo.taunting = pet->CastToNPC()->IsTaunting(); } else { memset(&m_petinfo, 0, sizeof(struct PetInfo)); } @@ -5642,6 +5643,8 @@ void Client::SuspendMinion() CurrentPet->SetMana(m_suspendedminion.Mana); + CurrentPet->SetTaunting(m_suspendedminion.taunting); + MessageString(Chat::Magenta, SUSPEND_MINION_UNSUSPEND, CurrentPet->GetCleanName()); memset(&m_suspendedminion, 0, sizeof(struct PetInfo)); @@ -5653,7 +5656,8 @@ void Client::SuspendMinion() SetPetCommandState(PET_BUTTON_REGROUP, 0); SetPetCommandState(PET_BUTTON_FOLLOW, 1); SetPetCommandState(PET_BUTTON_GUARD, 0); - SetPetCommandState(PET_BUTTON_TAUNT, 1); + // Taunt saved on client side for logging on with pet + // In our db for when we zone. SetPetCommandState(PET_BUTTON_HOLD, 0); SetPetCommandState(PET_BUTTON_GHOLD, 0); SetPetCommandState(PET_BUTTON_FOCUS, 0); diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 33a47c3a4..bfb9fd90c 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -904,7 +904,8 @@ void Client::CompleteConnect() SetPetCommandState(PET_BUTTON_REGROUP, 0); SetPetCommandState(PET_BUTTON_FOLLOW, 1); SetPetCommandState(PET_BUTTON_GUARD, 0); - SetPetCommandState(PET_BUTTON_TAUNT, 1); + // Taunt saved on client side for logging on with pet + // In our db for when we zone. SetPetCommandState(PET_BUTTON_HOLD, 0); SetPetCommandState(PET_BUTTON_GHOLD, 0); SetPetCommandState(PET_BUTTON_FOCUS, 0); @@ -1631,6 +1632,10 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) pet->CalcBonuses(); pet->SetHP(m_petinfo.HP); pet->SetMana(m_petinfo.Mana); + // 1st login, client takes care of this from button status + if (!firstlogon) { + pet->SetTaunting(m_petinfo.taunting); + } } m_petinfo.SpellID = 0; } diff --git a/zone/pets.cpp b/zone/pets.cpp index baaa779f0..dd66fccad 100644 --- a/zone/pets.cpp +++ b/zone/pets.cpp @@ -433,7 +433,7 @@ Pet::Pet(NPCType *type_data, Mob *owner, PetType type, uint16 spell_id, int16 po petpower = power; SetOwnerID(owner->GetID()); SetPetSpellID(spell_id); - taunting = true; + taunting = false; // Class should use npc constructor to set light properties } diff --git a/zone/spell_effects.cpp b/zone/spell_effects.cpp index 2eb17eb29..8c3599aca 100644 --- a/zone/spell_effects.cpp +++ b/zone/spell_effects.cpp @@ -1245,7 +1245,8 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove MakePet(spell_id, spell.teleport_zone); // TODO: we need to sync the states for these clients ... // Will fix buttons for now - if (IsClient()) { + Mob *pet=GetPet(); + if (IsClient() && pet) { auto c = CastToClient(); if (c->ClientVersionBit() & EQ::versions::maskUFAndLater) { c->SetPetCommandState(PET_BUTTON_SIT, 0); @@ -1253,7 +1254,9 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove c->SetPetCommandState(PET_BUTTON_REGROUP, 0); c->SetPetCommandState(PET_BUTTON_FOLLOW, 1); c->SetPetCommandState(PET_BUTTON_GUARD, 0); - c->SetPetCommandState(PET_BUTTON_TAUNT, 1); + // Creating pet from spell - taunt always false + // If suspended pet - that will be restore there + // If logging in, client will send toggle c->SetPetCommandState(PET_BUTTON_HOLD, 0); c->SetPetCommandState(PET_BUTTON_GHOLD, 0); c->SetPetCommandState(PET_BUTTON_FOCUS, 0); diff --git a/zone/zonedb.cpp b/zone/zonedb.cpp index ad29b10dc..bc1b542dd 100755 --- a/zone/zonedb.cpp +++ b/zone/zonedb.cpp @@ -3788,13 +3788,14 @@ void ZoneDatabase::SavePetInfo(Client *client) continue; query = StringFormat("INSERT INTO `character_pet_info` " - "(`char_id`, `pet`, `petname`, `petpower`, `spell_id`, `hp`, `mana`, `size`) " - "VALUES (%u, %u, '%s', %i, %u, %u, %u, %f) " + "(`char_id`, `pet`, `petname`, `petpower`, `spell_id`, `hp`, `mana`, `size`, `taunting`) " + "VALUES (%u, %u, '%s', %i, %u, %u, %u, %f, %u) " "ON DUPLICATE KEY UPDATE `petname` = '%s', `petpower` = %i, `spell_id` = %u, " - "`hp` = %u, `mana` = %u, `size` = %f", + "`hp` = %u, `mana` = %u, `size` = %f, `taunting` = %u", client->CharacterID(), pet, petinfo->Name, petinfo->petpower, petinfo->SpellID, - petinfo->HP, petinfo->Mana, petinfo->size, // and now the ON DUPLICATE ENTRIES - petinfo->Name, petinfo->petpower, petinfo->SpellID, petinfo->HP, petinfo->Mana, petinfo->size); + petinfo->HP, petinfo->Mana, petinfo->size, (petinfo->taunting) ? 1 : 0, + // and now the ON DUPLICATE ENTRIES + petinfo->Name, petinfo->petpower, petinfo->SpellID, petinfo->HP, petinfo->Mana, petinfo->size, (petinfo->taunting) ? 1 : 0); results = database.QueryDatabase(query); if (!results.Success()) return; @@ -3866,7 +3867,7 @@ void ZoneDatabase::LoadPetInfo(Client *client) memset(suspended, 0, sizeof(PetInfo)); std::string query = StringFormat("SELECT `pet`, `petname`, `petpower`, `spell_id`, " - "`hp`, `mana`, `size` FROM `character_pet_info` " + "`hp`, `mana`, `size` , `taunting` FROM `character_pet_info` " "WHERE `char_id` = %u", client->CharacterID()); auto results = database.QueryDatabase(query); @@ -3891,6 +3892,7 @@ void ZoneDatabase::LoadPetInfo(Client *client) pi->HP = atoul(row[4]); pi->Mana = atoul(row[5]); pi->size = atof(row[6]); + pi->taunting = (bool) atoi(row[7]); } query = StringFormat("SELECT `pet`, `slot`, `spell_id`, `caster_level`, `castername`, " diff --git a/zone/zonedb.h b/zone/zonedb.h index f3766c05c..bb6311eb0 100644 --- a/zone/zonedb.h +++ b/zone/zonedb.h @@ -155,6 +155,7 @@ struct PetInfo { SpellBuff_Struct Buffs[PET_BUFF_COUNT]; uint32 Items[EQ::invslot::EQUIPMENT_COUNT]; char Name[64]; + bool taunting; }; struct ZoneSpellsBlocked {