From 427498fb6541106ed5109ab6647b9754d87673fe Mon Sep 17 00:00:00 2001 From: Shaun Date: Thu, 14 Mar 2024 10:45:15 +0200 Subject: [PATCH] bug #2022: Fixed charge and fireblast stun being cancelled when it shouldn't --- src/server/components/spellbook.js | 11 +++++++++-- src/server/config/spells/spellCharge.js | 6 ++++-- src/server/config/spells/spellFireblast.js | 5 ++++- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/server/components/spellbook.js b/src/server/components/spellbook.js index 6c2e5d3f..cabd1204 100644 --- a/src/server/components/spellbook.js +++ b/src/server/components/spellbook.js @@ -409,6 +409,13 @@ module.exports = { return didCast || isCasting; }, + //Callbacks to be called when this object is destroyed + registerDestroyCallback: function (callback) { + this.callbacks.push({ + cbOnSelfDestroyed: callback + }); + }, + registerCallback: function (sourceId, callback, time, destroyCallback, targetId, destroyOnRezone) { let obj = { sourceId: sourceId, @@ -508,8 +515,8 @@ module.exports = { destroy: function () { this.callbacks.forEach(c => { - if (c.destroyCallback) - c.destroyCallback(); + if (c.cbOnSelfDestroyed) + c.cbOnSelfDestroyed(); }); this.spells.forEach(s => { diff --git a/src/server/config/spells/spellCharge.js b/src/server/config/spells/spellCharge.js index 2d65f904..53978f71 100644 --- a/src/server/config/spells/spellCharge.js +++ b/src/server/config/spells/spellCharge.js @@ -87,10 +87,12 @@ module.exports = { this.queueCallback( this.reachDestination.bind(this, target, targetPos, targetEffect, selfEffect), - ttl - 50, - this.destroyEffectOnTarget.bind(this, target, targetEffect) + ttl - 50 ); + //To be called when the object is destroyed + this.obj.spellbook.registerDestroyCallback(this.destroyEffectOnTarget.bind(this, target, targetEffect)); + return true; }, diff --git a/src/server/config/spells/spellFireblast.js b/src/server/config/spells/spellFireblast.js index cfd60f19..f7a8dff1 100644 --- a/src/server/config/spells/spellFireblast.js +++ b/src/server/config/spells/spellFireblast.js @@ -148,9 +148,12 @@ module.exports = { this.queueCallback( this.endEffect.bind(this, m, targetPos, targetEffect), ttl, - this.destroyEffectOnTarget.bind(this, m, targetEffect), + null, m ); + + //To be called when the object is destroyed + this.obj.spellbook.registerDestroyCallback(this.destroyEffectOnTarget.bind(this, m, targetEffect)); } } }