diff --git a/Source/Game/Conditions/ConditionManager.cs b/Source/Game/Conditions/ConditionManager.cs index a87d33591..7259c7610 100644 --- a/Source/Game/Conditions/ConditionManager.cs +++ b/Source/Game/Conditions/ConditionManager.cs @@ -279,6 +279,11 @@ namespace Game return true; } + public bool IsSpellUsedInSpellClickConditions(uint spellId) + { + return spellsUsedInSpellClickConditions.Contains(spellId); + } + public List GetConditionsForAreaTrigger(uint areaTriggerId, bool isServerSide) { return areaTriggerConditionContainerStorage.LookupByKey(Tuple.Create(areaTriggerId, isServerSide)); @@ -486,6 +491,8 @@ namespace Game spellClickEventConditionStorage[cond.SourceGroup] = new MultiMap(); spellClickEventConditionStorage[cond.SourceGroup].Add((uint)cond.SourceEntry, cond); + if (cond.ConditionType == ConditionTypes.Aura) + spellsUsedInSpellClickConditions.Add(cond.ConditionValue1); ++count; continue; // do not add to m_AllocatedMemory to avoid double deleting } @@ -550,6 +557,9 @@ namespace Game } //add new Condition to storage based on Type/Entry + if (cond.SourceType == ConditionSourceType.SpellClickEvent && cond.ConditionType == ConditionTypes.Aura) + spellsUsedInSpellClickConditions.Add(cond.ConditionValue1); + conditionStorage[cond.SourceType].Add((uint)cond.SourceEntry, cond); ++count; } @@ -1703,6 +1713,7 @@ namespace Game smartEventConditionStorage.Clear(); spellClickEventConditionStorage.Clear(); + spellsUsedInSpellClickConditions.Clear(); npcVendorConditionContainerStorage.Clear(); @@ -2488,6 +2499,7 @@ namespace Game MultiMap conditionReferenceStorage = new(); Dictionary> vehicleSpellConditionStorage = new(); Dictionary> spellClickEventConditionStorage = new(); + List spellsUsedInSpellClickConditions = new(); Dictionary> npcVendorConditionContainerStorage = new(); Dictionary, MultiMap> smartEventConditionStorage = new(); MultiMap, Condition> areaTriggerConditionContainerStorage = new(); diff --git a/Source/Game/Entities/Player/Player.Quest.cs b/Source/Game/Entities/Player/Player.Quest.cs index 89e1203cf..96d7055c2 100644 --- a/Source/Game/Entities/Player/Player.Quest.cs +++ b/Source/Game/Entities/Player/Player.Quest.cs @@ -1884,7 +1884,7 @@ namespace Game.Entities } } - UpdateForQuestWorldObjects(); + UpdateVisibleGameobjectsOrSpellClicks(); PhasingHandler.OnConditionChange(this); } @@ -2254,7 +2254,7 @@ namespace Game.Entities } } - UpdateForQuestWorldObjects(); + UpdateVisibleGameobjectsOrSpellClicks(); } public void KilledMonster(CreatureTemplate cInfo, ObjectGuid guid) @@ -2433,7 +2433,7 @@ namespace Game.Entities } if (anyObjectiveChangedCompletionState) - UpdateForQuestWorldObjects(); + UpdateVisibleGameobjectsOrSpellClicks(); } public bool HasQuestForItem(uint itemid) @@ -2900,7 +2900,7 @@ namespace Game.Entities return false; } - public void UpdateForQuestWorldObjects() + public void UpdateVisibleGameobjectsOrSpellClicks() { if (m_clientGUIDs.Empty()) return; @@ -2950,24 +2950,14 @@ namespace Game.Entities var clickBounds = Global.ObjectMgr.GetSpellClickInfoMapBounds(obj.GetEntry()); foreach (var spellClickInfo in clickBounds) { - //! This code doesn't look right, but it was logically converted to condition system to do the exact - //! same thing it did before. It definitely needs to be overlooked for intended functionality. List conds = Global.ConditionMgr.GetConditionsForSpellClickEvent(obj.GetEntry(), spellClickInfo.spellId); if (conds != null) { - bool buildUpdateBlock = false; - for (var i = 0; i < conds.Count && !buildUpdateBlock; ++i) - if (conds[i].ConditionType == ConditionTypes.QuestRewarded || conds[i].ConditionType == ConditionTypes.QuestTaken || conds[i].ConditionType == ConditionTypes.QuestComplete) - buildUpdateBlock = true; - - if (buildUpdateBlock) - { - ObjectFieldData objMask = new(); - UnitData unitMask = new(); - unitMask.MarkChanged(obj.m_unitData.NpcFlags, 0); // NpcFlags[0] has UNIT_NPC_FLAG_SPELLCLICK - obj.BuildValuesUpdateForPlayerWithMask(udata, objMask._changesMask, unitMask._changesMask, this); - break; - } + ObjectFieldData objMask = new(); + UnitData unitMask = new(); + unitMask.MarkChanged(m_unitData.NpcFlags, 0); // NpcFlags[0] has UNIT_NPC_FLAG_SPELLCLICK + obj.BuildValuesUpdateForPlayerWithMask(udata, objMask.GetUpdateMask(), unitMask.GetUpdateMask(), this); + break; } } } diff --git a/Source/Game/Entities/Unit/Unit.Spells.cs b/Source/Game/Entities/Unit/Unit.Spells.cs index a2d4a5932..096578aec 100644 --- a/Source/Game/Entities/Unit/Unit.Spells.cs +++ b/Source/Game/Entities/Unit/Unit.Spells.cs @@ -3601,6 +3601,11 @@ namespace Game.Entities } aura.HandleAuraSpecificMods(aurApp, caster, false, false); + + Player player = ToPlayer(); + if (player != null) + if (Global.ConditionMgr.IsSpellUsedInSpellClickConditions(aurApp.GetBase().GetId())) + player.UpdateVisibleGameobjectsOrSpellClicks(); } public void _UnapplyAura(AuraApplication aurApp, AuraRemoveMode removeMode) @@ -3810,6 +3815,11 @@ namespace Game.Entities if (Convert.ToBoolean(effMask & 1 << i) && !(aurApp.HasRemoveMode())) aurApp._HandleEffect(i, true); } + + Player player = ToPlayer(); + if (player != null) + if (Global.ConditionMgr.IsSpellUsedInSpellClickConditions(aurApp.GetBase().GetId())) + player.UpdateVisibleGameobjectsOrSpellClicks(); } public void _AddAura(UnitAura aura, Unit caster) diff --git a/Source/Game/Groups/Group.cs b/Source/Game/Groups/Group.cs index ac1de6ba3..8807a9f9a 100644 --- a/Source/Game/Groups/Group.cs +++ b/Source/Game/Groups/Group.cs @@ -273,7 +273,7 @@ namespace Game.Groups { Player player = Global.ObjAccessor.FindPlayer(member.guid); if (player != null) - player.UpdateForQuestWorldObjects(); + player.UpdateVisibleGameobjectsOrSpellClicks(); } } @@ -303,7 +303,7 @@ namespace Game.Groups { Player player = Global.ObjAccessor.FindPlayer(member.guid); if (player != null) - player.UpdateForQuestWorldObjects(); + player.UpdateVisibleGameobjectsOrSpellClicks(); } } @@ -482,7 +482,7 @@ namespace Game.Groups // quest related GO state dependent from raid membership if (IsRaidGroup()) - player.UpdateForQuestWorldObjects(); + player.UpdateVisibleGameobjectsOrSpellClicks(); { // Broadcast new player group member fields to rest of the group @@ -572,7 +572,7 @@ namespace Game.Groups player.SetGroup(null); // quest related GO state dependent from raid membership - player.UpdateForQuestWorldObjects(); + player.UpdateVisibleGameobjectsOrSpellClicks(); } @@ -809,7 +809,7 @@ namespace Game.Groups // quest related GO state dependent from raid membership if (IsRaidGroup()) - player.UpdateForQuestWorldObjects(); + player.UpdateVisibleGameobjectsOrSpellClicks(); if (!hideDestroy) player.SendPacket(new GroupDestroyed()); diff --git a/Source/Game/Handlers/MiscHandler.cs b/Source/Game/Handlers/MiscHandler.cs index ad622f1e0..b59c725f1 100644 --- a/Source/Game/Handlers/MiscHandler.cs +++ b/Source/Game/Handlers/MiscHandler.cs @@ -242,7 +242,7 @@ namespace Game } if (anyObjectiveChangedCompletionState) - player.UpdateForQuestWorldObjects(); + player.UpdateVisibleGameobjectsOrSpellClicks(); } }