Аутор | SHA1 | Порука | Датум |
---|---|---|---|
Shaun | 471fa79b27 | Merge remote-tracking branch 'origin/master' into release | пре 2 месеци |
Shaun | 6b7d8c4d6f | bug #2022 | пре 2 месеци |
Shaun | 4ea6a9e801 | Merge remote-tracking branch 'origin/master' into release | пре 2 месеци |
Shaun | 427498fb65 | bug #2022: Fixed charge and fireblast stun being cancelled when it shouldn't | пре 2 месеци |
@@ -409,6 +409,13 @@ module.exports = { | |||||
return didCast || isCasting; | 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) { | registerCallback: function (sourceId, callback, time, destroyCallback, targetId, destroyOnRezone) { | ||||
let obj = { | let obj = { | ||||
sourceId: sourceId, | sourceId: sourceId, | ||||
@@ -508,8 +515,8 @@ module.exports = { | |||||
destroy: function () { | destroy: function () { | ||||
this.callbacks.forEach(c => { | this.callbacks.forEach(c => { | ||||
if (c.destroyCallback) | |||||
c.destroyCallback(); | |||||
if (c.cbOnSelfDestroyed) | |||||
c.cbOnSelfDestroyed(); | |||||
}); | }); | ||||
this.spells.forEach(s => { | this.spells.forEach(s => { | ||||
@@ -87,10 +87,12 @@ module.exports = { | |||||
this.queueCallback( | this.queueCallback( | ||||
this.reachDestination.bind(this, target, targetPos, targetEffect, selfEffect), | 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; | return true; | ||||
}, | }, | ||||
@@ -147,7 +149,8 @@ module.exports = { | |||||
}, | }, | ||||
destroyEffectOnTarget: function (target, targetEffect) { | destroyEffectOnTarget: function (target, targetEffect) { | ||||
target.effects.removeEffect(targetEffect.id); | |||||
if (targetEffect) | |||||
target.effects.removeEffect(targetEffect.id); | |||||
}, | }, | ||||
isTileValid: function (physics, fromX, fromY, toX, toY) { | isTileValid: function (physics, fromX, fromY, toX, toY) { | ||||
@@ -148,9 +148,12 @@ module.exports = { | |||||
this.queueCallback( | this.queueCallback( | ||||
this.endEffect.bind(this, m, targetPos, targetEffect), | this.endEffect.bind(this, m, targetPos, targetEffect), | ||||
ttl, | ttl, | ||||
this.destroyEffectOnTarget.bind(this, m, targetEffect), | |||||
null, | |||||
m | m | ||||
); | ); | ||||
//To be called when the object is destroyed | |||||
this.obj.spellbook.registerDestroyCallback(this.destroyEffectOnTarget.bind(this, m, targetEffect)); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -208,6 +211,7 @@ module.exports = { | |||||
}, | }, | ||||
destroyEffectOnTarget: function (target, targetEffect) { | destroyEffectOnTarget: function (target, targetEffect) { | ||||
target.effects.removeEffect(targetEffect.id); | |||||
if (targetEffect) | |||||
target.effects.removeEffect(targetEffect.id); | |||||
} | } | ||||
}; | }; |