Core/Conditions: allow spellclick conditions to properly work for aura apply/remove
Port From (https://github.com/TrinityCore/TrinityCore/commit/edf12fd6a1b989d7785bc0619002eda1ccc87368)
This commit is contained in:
@@ -279,6 +279,11 @@ namespace Game
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsSpellUsedInSpellClickConditions(uint spellId)
|
||||||
|
{
|
||||||
|
return spellsUsedInSpellClickConditions.Contains(spellId);
|
||||||
|
}
|
||||||
|
|
||||||
public List<Condition> GetConditionsForAreaTrigger(uint areaTriggerId, bool isServerSide)
|
public List<Condition> GetConditionsForAreaTrigger(uint areaTriggerId, bool isServerSide)
|
||||||
{
|
{
|
||||||
return areaTriggerConditionContainerStorage.LookupByKey(Tuple.Create(areaTriggerId, isServerSide));
|
return areaTriggerConditionContainerStorage.LookupByKey(Tuple.Create(areaTriggerId, isServerSide));
|
||||||
@@ -486,6 +491,8 @@ namespace Game
|
|||||||
spellClickEventConditionStorage[cond.SourceGroup] = new MultiMap<uint, Condition>();
|
spellClickEventConditionStorage[cond.SourceGroup] = new MultiMap<uint, Condition>();
|
||||||
|
|
||||||
spellClickEventConditionStorage[cond.SourceGroup].Add((uint)cond.SourceEntry, cond);
|
spellClickEventConditionStorage[cond.SourceGroup].Add((uint)cond.SourceEntry, cond);
|
||||||
|
if (cond.ConditionType == ConditionTypes.Aura)
|
||||||
|
spellsUsedInSpellClickConditions.Add(cond.ConditionValue1);
|
||||||
++count;
|
++count;
|
||||||
continue; // do not add to m_AllocatedMemory to avoid double deleting
|
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
|
//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);
|
conditionStorage[cond.SourceType].Add((uint)cond.SourceEntry, cond);
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
@@ -1703,6 +1713,7 @@ namespace Game
|
|||||||
smartEventConditionStorage.Clear();
|
smartEventConditionStorage.Clear();
|
||||||
|
|
||||||
spellClickEventConditionStorage.Clear();
|
spellClickEventConditionStorage.Clear();
|
||||||
|
spellsUsedInSpellClickConditions.Clear();
|
||||||
|
|
||||||
npcVendorConditionContainerStorage.Clear();
|
npcVendorConditionContainerStorage.Clear();
|
||||||
|
|
||||||
@@ -2488,6 +2499,7 @@ namespace Game
|
|||||||
MultiMap<uint, Condition> conditionReferenceStorage = new();
|
MultiMap<uint, Condition> conditionReferenceStorage = new();
|
||||||
Dictionary<uint, MultiMap<uint, Condition>> vehicleSpellConditionStorage = new();
|
Dictionary<uint, MultiMap<uint, Condition>> vehicleSpellConditionStorage = new();
|
||||||
Dictionary<uint, MultiMap<uint, Condition>> spellClickEventConditionStorage = new();
|
Dictionary<uint, MultiMap<uint, Condition>> spellClickEventConditionStorage = new();
|
||||||
|
List<uint> spellsUsedInSpellClickConditions = new();
|
||||||
Dictionary<uint, MultiMap<uint, Condition>> npcVendorConditionContainerStorage = new();
|
Dictionary<uint, MultiMap<uint, Condition>> npcVendorConditionContainerStorage = new();
|
||||||
Dictionary<Tuple<int, uint>, MultiMap<uint, Condition>> smartEventConditionStorage = new();
|
Dictionary<Tuple<int, uint>, MultiMap<uint, Condition>> smartEventConditionStorage = new();
|
||||||
MultiMap<Tuple<uint, bool>, Condition> areaTriggerConditionContainerStorage = new();
|
MultiMap<Tuple<uint, bool>, Condition> areaTriggerConditionContainerStorage = new();
|
||||||
|
|||||||
@@ -1884,7 +1884,7 @@ namespace Game.Entities
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateForQuestWorldObjects();
|
UpdateVisibleGameobjectsOrSpellClicks();
|
||||||
PhasingHandler.OnConditionChange(this);
|
PhasingHandler.OnConditionChange(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2254,7 +2254,7 @@ namespace Game.Entities
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateForQuestWorldObjects();
|
UpdateVisibleGameobjectsOrSpellClicks();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void KilledMonster(CreatureTemplate cInfo, ObjectGuid guid)
|
public void KilledMonster(CreatureTemplate cInfo, ObjectGuid guid)
|
||||||
@@ -2433,7 +2433,7 @@ namespace Game.Entities
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (anyObjectiveChangedCompletionState)
|
if (anyObjectiveChangedCompletionState)
|
||||||
UpdateForQuestWorldObjects();
|
UpdateVisibleGameobjectsOrSpellClicks();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool HasQuestForItem(uint itemid)
|
public bool HasQuestForItem(uint itemid)
|
||||||
@@ -2900,7 +2900,7 @@ namespace Game.Entities
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateForQuestWorldObjects()
|
public void UpdateVisibleGameobjectsOrSpellClicks()
|
||||||
{
|
{
|
||||||
if (m_clientGUIDs.Empty())
|
if (m_clientGUIDs.Empty())
|
||||||
return;
|
return;
|
||||||
@@ -2950,24 +2950,14 @@ namespace Game.Entities
|
|||||||
var clickBounds = Global.ObjectMgr.GetSpellClickInfoMapBounds(obj.GetEntry());
|
var clickBounds = Global.ObjectMgr.GetSpellClickInfoMapBounds(obj.GetEntry());
|
||||||
foreach (var spellClickInfo in clickBounds)
|
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<Condition> conds = Global.ConditionMgr.GetConditionsForSpellClickEvent(obj.GetEntry(), spellClickInfo.spellId);
|
List<Condition> conds = Global.ConditionMgr.GetConditionsForSpellClickEvent(obj.GetEntry(), spellClickInfo.spellId);
|
||||||
if (conds != null)
|
if (conds != null)
|
||||||
{
|
{
|
||||||
bool buildUpdateBlock = false;
|
ObjectFieldData objMask = new();
|
||||||
for (var i = 0; i < conds.Count && !buildUpdateBlock; ++i)
|
UnitData unitMask = new();
|
||||||
if (conds[i].ConditionType == ConditionTypes.QuestRewarded || conds[i].ConditionType == ConditionTypes.QuestTaken || conds[i].ConditionType == ConditionTypes.QuestComplete)
|
unitMask.MarkChanged(m_unitData.NpcFlags, 0); // NpcFlags[0] has UNIT_NPC_FLAG_SPELLCLICK
|
||||||
buildUpdateBlock = true;
|
obj.BuildValuesUpdateForPlayerWithMask(udata, objMask.GetUpdateMask(), unitMask.GetUpdateMask(), this);
|
||||||
|
break;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3601,6 +3601,11 @@ namespace Game.Entities
|
|||||||
}
|
}
|
||||||
|
|
||||||
aura.HandleAuraSpecificMods(aurApp, caster, false, false);
|
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)
|
public void _UnapplyAura(AuraApplication aurApp, AuraRemoveMode removeMode)
|
||||||
@@ -3810,6 +3815,11 @@ namespace Game.Entities
|
|||||||
if (Convert.ToBoolean(effMask & 1 << i) && !(aurApp.HasRemoveMode()))
|
if (Convert.ToBoolean(effMask & 1 << i) && !(aurApp.HasRemoveMode()))
|
||||||
aurApp._HandleEffect(i, true);
|
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)
|
public void _AddAura(UnitAura aura, Unit caster)
|
||||||
|
|||||||
@@ -273,7 +273,7 @@ namespace Game.Groups
|
|||||||
{
|
{
|
||||||
Player player = Global.ObjAccessor.FindPlayer(member.guid);
|
Player player = Global.ObjAccessor.FindPlayer(member.guid);
|
||||||
if (player != null)
|
if (player != null)
|
||||||
player.UpdateForQuestWorldObjects();
|
player.UpdateVisibleGameobjectsOrSpellClicks();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -303,7 +303,7 @@ namespace Game.Groups
|
|||||||
{
|
{
|
||||||
Player player = Global.ObjAccessor.FindPlayer(member.guid);
|
Player player = Global.ObjAccessor.FindPlayer(member.guid);
|
||||||
if (player != null)
|
if (player != null)
|
||||||
player.UpdateForQuestWorldObjects();
|
player.UpdateVisibleGameobjectsOrSpellClicks();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -482,7 +482,7 @@ namespace Game.Groups
|
|||||||
|
|
||||||
// quest related GO state dependent from raid membership
|
// quest related GO state dependent from raid membership
|
||||||
if (IsRaidGroup())
|
if (IsRaidGroup())
|
||||||
player.UpdateForQuestWorldObjects();
|
player.UpdateVisibleGameobjectsOrSpellClicks();
|
||||||
|
|
||||||
{
|
{
|
||||||
// Broadcast new player group member fields to rest of the group
|
// Broadcast new player group member fields to rest of the group
|
||||||
@@ -572,7 +572,7 @@ namespace Game.Groups
|
|||||||
player.SetGroup(null);
|
player.SetGroup(null);
|
||||||
|
|
||||||
// quest related GO state dependent from raid membership
|
// 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
|
// quest related GO state dependent from raid membership
|
||||||
if (IsRaidGroup())
|
if (IsRaidGroup())
|
||||||
player.UpdateForQuestWorldObjects();
|
player.UpdateVisibleGameobjectsOrSpellClicks();
|
||||||
|
|
||||||
if (!hideDestroy)
|
if (!hideDestroy)
|
||||||
player.SendPacket(new GroupDestroyed());
|
player.SendPacket(new GroupDestroyed());
|
||||||
|
|||||||
@@ -242,7 +242,7 @@ namespace Game
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (anyObjectiveChangedCompletionState)
|
if (anyObjectiveChangedCompletionState)
|
||||||
player.UpdateForQuestWorldObjects();
|
player.UpdateVisibleGameobjectsOrSpellClicks();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user