From 538edf8f4a0b26d88802cd6d61368ea306bd0b33 Mon Sep 17 00:00:00 2001 From: killerwife Date: Sat, 6 Apr 2024 13:05:56 +0200 Subject: [PATCH] [z2821] Creature: Add CharmedSpellList shorthand during charm Common and confirmed on reference --- sql/base/mangos.sql | 5 +++-- .../z2821_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, 37 insertions(+), 9 deletions(-) create mode 100644 sql/updates/mangos/z2821_01_mangos_charmed_spell_list.sql diff --git a/sql/base/mangos.sql b/sql/base/mangos.sql index a3ec46e5f6..6cd78e4ba4 100644 --- a/sql/base/mangos.sql +++ b/sql/base/mangos.sql @@ -23,7 +23,7 @@ DROP TABLE IF EXISTS `db_version`; CREATE TABLE `db_version` ( `version` varchar(120) DEFAULT NULL, `creature_ai_version` varchar(120) DEFAULT NULL, - `required_z2818_01_mangos_spell_template_ap` bit(1) DEFAULT NULL + `required_z2821_01_mangos_charmed_spell_list` bit(1) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Used DB version notes'; -- @@ -1297,6 +1297,7 @@ CREATE TABLE `creature_template` ( `Civilian` tinyint(3) unsigned NOT NULL DEFAULT '0', `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 '', @@ -1311,7 +1312,7 @@ CREATE TABLE `creature_template` ( LOCK TABLES `creature_template` WRITE; /*!40000 ALTER TABLE `creature_template` DISABLE KEYS */; INSERT INTO `creature_template` VALUES -(1,'Waypoint (Only GM can see it)','Visual',63,63,10045,0,0,0,35,0,8,8,7,1,0,0,4096,0,130,5242886,0,0,0,0,0.91,1.14286,20,0,0,0,0,0,3,1,1,1,1,1,1,9999,9999,0,0,7,7,1.76,2.42,0,3,100,2000,2200,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,0,0,0,0,0,'',''); +(1,'Waypoint (Only GM can see it)','Visual',63,63,10045,0,0,0,35,0,8,8,7,1,0,0,4096,0,130,5242886,0,0,0,0,0.91,1.14286,20,0,0,0,0,0,3,1,1,1,1,1,1,9999,9999,0,0,7,7,1.76,2.42,0,3,100,2000,2200,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,'',''); /*!40000 ALTER TABLE `creature_template` ENABLE KEYS */; UNLOCK TABLES; diff --git a/sql/updates/mangos/z2821_01_mangos_charmed_spell_list.sql b/sql/updates/mangos/z2821_01_mangos_charmed_spell_list.sql new file mode 100644 index 0000000000..f8896e86ba --- /dev/null +++ b/sql/updates/mangos/z2821_01_mangos_charmed_spell_list.sql @@ -0,0 +1,5 @@ +ALTER TABLE db_version CHANGE COLUMN required_z2818_01_mangos_spell_template_ap required_z2821_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 5865183407..62e16d082c 100644 --- a/src/game/Entities/Creature.cpp +++ b/src/game/Entities/Creature.cpp @@ -2282,6 +2282,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 ce8054edec..59efdccd1e 100644 --- a/src/game/Entities/Creature.h +++ b/src/game/Entities/Creature.h @@ -163,6 +163,7 @@ struct CreatureInfo uint32 InteractionPauseTimer; uint32 CorpseDelay; uint32 SpellList; + uint32 CharmedSpellList; uint32 StringID1; uint32 StringID2; uint32 EquipmentTemplateId; diff --git a/src/game/Entities/Unit.cpp b/src/game/Entities/Unit.cpp index 09e895810b..bf931c34b1 100644 --- a/src/game/Entities/Unit.cpp +++ b/src/game/Entities/Unit.cpp @@ -11070,6 +11070,8 @@ Unit* Unit::TakePossessOf(SpellEntry const* spellEntry, uint32 effIdx, float x, if (player) { // Initialize pet bar + if (uint32 charmedSpellList = possessed->GetCreatureInfo()->CharmedSpellList) + possessed->SetSpellList(charmedSpellList); charmInfo->InitPossessCreateSpells(); player->PossessSpellInitialize(); @@ -11137,6 +11139,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) { @@ -11242,7 +11247,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)) @@ -11267,7 +11272,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); @@ -11284,6 +11289,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 @@ -11467,7 +11475,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); @@ -11499,9 +11507,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 ac487650e2..ca8d306594 100644 --- a/src/game/Server/SQLStorages.cpp +++ b/src/game/Server/SQLStorages.cpp @@ -18,8 +18,8 @@ #include "Server/SQLStorages.h" -const char CreatureInfosrcfmt[] = "issiiiiiiifiiiiliiiiiiiiiffiiiiiiiffffffiiiiffffiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiss"; -const char CreatureInfodstfmt[] = "issiiiiiiifiiiiliiiiiiiiiffiiiiiiiffffffiiiiffffiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiisi"; +const char CreatureInfosrcfmt[] = "issiiiiiiifiiiiliiiiiiiiiffiiiiiiiffffffiiiiffffiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiss"; +const char CreatureInfodstfmt[] = "issiiiiiiifiiiiliiiiiiiiiffiiiiiiiffffffiiiiffffiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiisi"; const char CreatureDataAddonInfofmt[] = "iibbiis"; const char CreatureConditionalSpawnSrcFmt[] = "iiix"; const char CreatureConditionalSpawnDstFmt[] = "iii"; diff --git a/src/shared/revision_sql.h b/src/shared/revision_sql.h index 2f32e0490b..0f52d73d5b 100644 --- a/src/shared/revision_sql.h +++ b/src/shared/revision_sql.h @@ -3,5 +3,5 @@ #define REVISION_DB_REALMD "required_z2820_01_realmd_joindate_datetime" #define REVISION_DB_LOGS "required_z2778_01_logs_anticheat" #define REVISION_DB_CHARACTERS "required_z2819_01_characters_item_instance_text_id_fix" - #define REVISION_DB_MANGOS "required_z2818_01_mangos_spell_template_ap" + #define REVISION_DB_MANGOS "required_z2821_01_mangos_charmed_spell_list" #endif // __REVISION_SQL_H__