Core/GameObjects: Fixed gameobject spell casts failing when triggered by SPELL_EFFECT_OPEN_LOCK

Port From (https://github.com/TrinityCore/TrinityCore/commit/3177c410e488866ece2803ddcf9ea09ea4b2b4fb)
This commit is contained in:
Hondacrx
2025-02-23 14:29:53 -05:00
parent 6a24e9ce29
commit 519c642cff
2 changed files with 10 additions and 8 deletions
@@ -1684,12 +1684,14 @@ namespace Game.Entities
SetGoState(GameObjectState.Ready); SetGoState(GameObjectState.Ready);
} }
public void Use(Unit user) public void Use(Unit user, bool ignoreCastInProgress = false)
{ {
// by default spell caster is user // by default spell caster is user
Unit spellCaster = user; Unit spellCaster = user;
uint spellId = 0; uint spellId = 0;
bool triggered = false; CastSpellExtraArgs spellArgs = new();
if (ignoreCastInProgress)
spellArgs.TriggerFlags |= TriggerCastFlags.IgnoreCastInProgress;
Player playerUser = user.ToPlayer(); Player playerUser = user.ToPlayer();
if (playerUser != null) if (playerUser != null)
@@ -2101,7 +2103,7 @@ namespace Game.Entities
if (fishingPool != null) if (fishingPool != null)
{ {
fishingPool.Use(player); fishingPool.Use(player, ignoreCastInProgress);
SetLootState(LootState.JustDeactivated); SetLootState(LootState.JustDeactivated);
} }
else else
@@ -2177,7 +2179,7 @@ namespace Game.Entities
player.CastSpell(player, info.Ritual.animSpell, true); player.CastSpell(player, info.Ritual.animSpell, true);
// for this case, summoningRitual.spellId is always triggered // for this case, summoningRitual.spellId is always triggered
triggered = true; spellArgs.TriggerFlags = TriggerCastFlags.FullMask;
} }
// full amount unique participants including original summoner // full amount unique participants including original summoner
@@ -2193,7 +2195,7 @@ namespace Game.Entities
// spell have reagent and mana cost but it not expected use its // spell have reagent and mana cost but it not expected use its
// it triggered spell in fact casted at currently channeled GO // it triggered spell in fact casted at currently channeled GO
spellId = 61993; spellId = 61993;
triggered = true; spellArgs.TriggerFlags = TriggerCastFlags.FullMask;
} }
// Cast casterTargetSpell at a random GO user // Cast casterTargetSpell at a random GO user
@@ -2636,10 +2638,10 @@ namespace Game.Entities
Global.OutdoorPvPMgr.HandleCustomSpell(player1, spellId, this); Global.OutdoorPvPMgr.HandleCustomSpell(player1, spellId, this);
if (spellCaster != null) if (spellCaster != null)
spellCaster.CastSpell(user, spellId, triggered); spellCaster.CastSpell(user, spellId, spellArgs);
else else
{ {
SpellCastResult castResult = CastSpell(user, spellId); SpellCastResult castResult = CastSpell(user, spellId, spellArgs);
if (castResult == SpellCastResult.Success) if (castResult == SpellCastResult.Success)
{ {
switch (GetGoType()) switch (GetGoType())
+1 -1
View File
@@ -1270,7 +1270,7 @@ namespace Game.Spells
} }
if (gameObjTarget != null) if (gameObjTarget != null)
gameObjTarget.Use(player); gameObjTarget.Use(player, true);
else if (itemTarget != null) else if (itemTarget != null)
{ {
itemTarget.SetItemFlag(ItemFieldFlags.Unlocked); itemTarget.SetItemFlag(ItemFieldFlags.Unlocked);