From 6925d329c879abf5509b3562103f8a1dbef3d7ff Mon Sep 17 00:00:00 2001 From: killerwife Date: Sat, 6 Apr 2024 13:05:56 +0200 Subject: [PATCH] [14084] Creature: Add CharmedSpellList shorthand during charm Common and confirmed on reference --- sql/base/mangos.sql | 3 ++- .../14084_01_mangos_charmed_spell_list.sql | 5 +++++ src/game/Entities/Creature.cpp | 10 ++++++++++ src/game/Entities/Creature.h | 1 + src/game/Entities/Unit.cpp | 19 +++++++++++++++---- src/game/Server/SQLStorages.cpp | 4 ++-- src/shared/revision_sql.h | 2 +- 7 files changed, 36 insertions(+), 8 deletions(-) create mode 100644 sql/updates/mangos/14084_01_mangos_charmed_spell_list.sql diff --git a/sql/base/mangos.sql b/sql/base/mangos.sql index 850a4ec20f6..9d6370865d2 100644 --- a/sql/base/mangos.sql +++ b/sql/base/mangos.sql @@ -24,7 +24,7 @@ CREATE TABLE `db_version` ( `version` varchar(120) DEFAULT NULL, `creature_ai_version` varchar(120) DEFAULT NULL, `cache_id` int(10) DEFAULT '0', - `required_14082_01_mangos_spell_template` bit(1) DEFAULT NULL + `required_14084_01_mangos_charmed_spell_list` bit(1) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Used DB version notes'; -- @@ -1590,6 +1590,7 @@ CREATE TABLE `creature_template` ( `InteractionPauseTimer` INT(10) NOT NULL DEFAULT -1, `CorpseDecay` INT UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Time before corpse despawns', `SpellList` INT NOT NULL DEFAULT '0' COMMENT 'creature_spell_list_entry', + `CharmedSpellList` INT NOT NULL DEFAULT '0' COMMENT 'creature_spell_list_entry during charm', `StringId1` INT(11) UNSIGNED NOT NULL DEFAULT '0', `StringId2` INT(11) UNSIGNED NOT NULL DEFAULT '0', `AIName` char(64) NOT NULL DEFAULT '', diff --git a/sql/updates/mangos/14084_01_mangos_charmed_spell_list.sql b/sql/updates/mangos/14084_01_mangos_charmed_spell_list.sql new file mode 100644 index 00000000000..50a95260acd --- /dev/null +++ b/sql/updates/mangos/14084_01_mangos_charmed_spell_list.sql @@ -0,0 +1,5 @@ +ALTER TABLE db_version CHANGE COLUMN required_14082_01_mangos_spell_template required_14084_01_mangos_charmed_spell_list bit; + +ALTER TABLE `creature_template` ADD COLUMN `CharmedSpellList` INT NOT NULL DEFAULT '0' COMMENT 'creature_spell_list_entry during charm' AFTER `SpellList`; + + diff --git a/src/game/Entities/Creature.cpp b/src/game/Entities/Creature.cpp index 69f7ab10dfd..65f959cc2f4 100644 --- a/src/game/Entities/Creature.cpp +++ b/src/game/Entities/Creature.cpp @@ -2400,6 +2400,16 @@ void Creature::UpdateSpell(int32 index, int32 newSpellId) void Creature::SetSpellList(uint32 spellSet) { + if (spellSet == 0) + { + m_spellList.Disabled = true; + m_spellList.Spells.clear(); + + if (AI()) + AI()->SpellListChanged(); + return; + } + // Try difficulty dependent version before falling back to base entry auto spellList = GetMap()->GetMapDataContainer().GetCreatureSpellList(spellSet); if (!spellList) diff --git a/src/game/Entities/Creature.h b/src/game/Entities/Creature.h index 0f07a150347..b0a2de52069 100644 --- a/src/game/Entities/Creature.h +++ b/src/game/Entities/Creature.h @@ -172,6 +172,7 @@ struct CreatureInfo uint32 InteractionPauseTimer; uint32 CorpseDelay; uint32 SpellList; + uint32 CharmedSpellList; uint32 StringID1; uint32 StringID2; char const* AIName; diff --git a/src/game/Entities/Unit.cpp b/src/game/Entities/Unit.cpp index e20be8b963f..1964c6d9776 100644 --- a/src/game/Entities/Unit.cpp +++ b/src/game/Entities/Unit.cpp @@ -12620,6 +12620,8 @@ Unit* Unit::TakePossessOf(SpellEntry const* spellEntry, SummonPropertiesEntry co if (player) { // Initialize pet bar + if (uint32 charmedSpellList = possessed->GetCreatureInfo()->CharmedSpellList) + possessed->SetSpellList(charmedSpellList); charmInfo->InitPossessCreateSpells(); player->PossessSpellInitialize(); @@ -12687,6 +12689,9 @@ bool Unit::TakePossessOf(Unit* possessed) charmInfo->SetCharmState("PossessedAI"); possessedCreature->SetWalk(IsWalking(), true); getHostileRefManager().deleteReference(possessedCreature); + + if (uint32 charmedSpellList = possessedCreature->GetCreatureInfo()->CharmedSpellList) + possessedCreature->SetSpellList(charmedSpellList); } else if (possessed->GetTypeId() == TYPEID_PLAYER) { @@ -12796,7 +12801,7 @@ bool Unit::TakeCharmOf(Unit* charmed, uint32 spellId, bool advertised /*= true*/ Position combatStartPosition; - if (charmed->GetTypeId() == TYPEID_PLAYER) + if (charmed->IsPlayer()) { Player* charmedPlayer = static_cast(charmed); if (charmerPlayer && charmerPlayer->IsInDuelWith(charmedPlayer)) @@ -12821,7 +12826,7 @@ bool Unit::TakeCharmOf(Unit* charmed, uint32 spellId, bool advertised /*= true*/ charmedPlayer->SendForcedObjectUpdate(); } - else if (charmed->GetTypeId() == TYPEID_UNIT) + else if (charmed->IsCreature()) { Creature* charmedCreature = static_cast(charmed); @@ -12838,6 +12843,9 @@ bool Unit::TakeCharmOf(Unit* charmed, uint32 spellId, bool advertised /*= true*/ charmedCreature->SetFactionTemporary(GetFaction(), TEMPFACTION_NONE); + if (uint32 charmedSpellList = charmedCreature->GetCreatureInfo()->CharmedSpellList) + charmedCreature->SetSpellList(charmedSpellList); + if (isPossessCharm) charmInfo->InitPossessCreateSpells(); else @@ -13020,7 +13028,7 @@ void Unit::Uncharm(Unit* charmed, uint32 spellId) // TODO: maybe should be done on HomeMovementGenerator::MovementExpires charmed->GetCombatManager().SetEvadeState(EVADE_NONE); - if (charmed->GetTypeId() == TYPEID_UNIT) + if (charmed->IsCreature()) { // now we have to clean threat list to be able to restore normal creature behavior Creature* charmedCreature = static_cast(charmed); @@ -13052,9 +13060,12 @@ void Unit::Uncharm(Unit* charmed, uint32 spellId) charmed->DeleteCharmInfo(); } + if (charmedCreature->GetCreatureInfo()->CharmedSpellList) + charmedCreature->SetSpellList(charmedCreature->GetCreatureInfo()->SpellList); + charmed->SetTarget(charmed->GetVictim()); } - else if (charmed->GetTypeId() == TYPEID_PLAYER) + else if (charmed->IsPlayer()) { charmed->AttackStop(true, true); diff --git a/src/game/Server/SQLStorages.cpp b/src/game/Server/SQLStorages.cpp index ad62022038d..fbf9e88ed22 100644 --- a/src/game/Server/SQLStorages.cpp +++ b/src/game/Server/SQLStorages.cpp @@ -18,8 +18,8 @@ #include "Server/SQLStorages.h" -const char CreatureInfosrcfmt[] = "isssiiiiiiiiiifiiiiliiiiiiiiiifffiiiiiiiiffffffiiiiffffiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiss"; -const char CreatureInfodstfmt[] = "isssiiiiiiiiiifiiiiliiiiiiiiiifffiiiiiiiiffffffiiiiffffiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiisi"; +const char CreatureInfosrcfmt[] = "isssiiiiiiiiiifiiiiliiiiiiiiiifffiiiiiiiiffffffiiiiffffiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiss"; +const char CreatureInfodstfmt[] = "isssiiiiiiiiiifiiiiliiiiiiiiiifffiiiiiiiiffffffiiiiffffiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiisi"; const char CreatureDataAddonInfofmt[] = "iibbbiis"; const char CreatureConditionalSpawnSrcFmt[] = "iiix"; const char CreatureConditionalSpawnDstFmt[] = "iii"; diff --git a/src/shared/revision_sql.h b/src/shared/revision_sql.h index 7b3e9c5d09a..14da67736de 100644 --- a/src/shared/revision_sql.h +++ b/src/shared/revision_sql.h @@ -3,5 +3,5 @@ #define REVISION_DB_REALMD "required_14083_01_realmd_joindate_datetime" #define REVISION_DB_LOGS "required_14039_01_logs_anticheat" #define REVISION_DB_CHARACTERS "required_14061_01_characters_fishingSteps" - #define REVISION_DB_MANGOS "required_14082_01_mangos_spell_template" + #define REVISION_DB_MANGOS "required_14084_01_mangos_charmed_spell_list" #endif // __REVISION_SQL_H__