From 00627d820e8bdc0687fdec89d0f4e589fe9a3e34 Mon Sep 17 00:00:00 2001 From: Vishwanath Martur <64204611+vishwamartur@users.noreply.github.com> Date: Wed, 27 Nov 2024 16:48:27 +0530 Subject: [PATCH] Revamp Gumble's passive ability Related to #2635 Revamp Gumble's passive ability 'Gooey Body' to create a trap when Gumble is killed. * Modify `src/abilities/Gumble.ts` to implement the new 'Gooey Body' ability. * When Gumble is killed, create a trap at Gumble's location that pins any unit that walks over it. * The trap prevents movement for the current round but allows the use of abilities. * Movement-related abilities can free the unit if landing outside the goo. * The trap remains until overlapped by another similar trap. * The upgraded ability does not affect allied units. * Add the sprite file `assets/autoload/phaser/units/sprites/trap_goey-body.png` to the repository. * Ensure the new ability is triggered by the 'onDeath' event. --- src/abilities/Gumble.ts | 71 ++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 36 deletions(-) diff --git a/src/abilities/Gumble.ts b/src/abilities/Gumble.ts index df0474a3c..3cf59b355 100644 --- a/src/abilities/Gumble.ts +++ b/src/abilities/Gumble.ts @@ -18,7 +18,7 @@ export default (G: Game) => { // First Ability: Gooey Body { // Update stat buffs whenever health changes - trigger: 'onCreatureSummon onDamage onHeal', + trigger: 'onDeath', require: function () { // Always active @@ -27,48 +27,47 @@ export default (G: Game) => { activate: function () { if (this.creature.dead) { - return; - } - // Attach a permanent effect that gives Gumble stat buffs - // Bonus points to pierce, slash and crush based on remaining health - const healthBonusDivisor = this.isUpgraded() ? 5 : 7; - const bonus = Math.floor((this.creature.health / healthBonusDivisor) * 3); - // Log whenever the bonus applied changes - const noLog = bonus == this._lastBonus; - this._lastBonus = bonus; - const statsToApplyBonus = ['pierce', 'slash', 'crush']; - const alterations = {}; - for (let i = 0; i < statsToApplyBonus.length; i++) { - const key = statsToApplyBonus[i]; - alterations[key] = bonus; - } - this.creature.replaceEffect( - new Effect( - 'Gooey Body', // name - this.creature, // Caster - this.creature, // Target - '', // Trigger + const effect = new Effect( + 'Gooey Body', + this.creature, + this.creature.hexagons[0], + 'onStepIn', { - alterations: alterations, - deleteTrigger: '', - stackable: false, - effectFn: () => { - if (bonus !== this._lastBonus) { - G.log('Effect ' + this.title + ' triggered'); + requireFn: function (creature) { + if (this.isUpgraded() && creature.team === this.creature.team) { + return false; } + return true; + }, + effectFn: function (effect, creature) { + creature.remainingMove = 0; }, + alterations: { + moveable: false, + }, + deleteTrigger: 'onStartPhase', + turnLifetime: 1, }, G, - ), - ); - if (!noLog) { - G.log( - '%CreatureName' + this.creature.id + '% receives ' + bonus + ' pierce, slash and crush', + 'trap_goey-body', ); + + const trap = new Trap( + this.creature.x, + this.creature.y, + 'trap_goey-body', + [effect], + this.creature.player, + { + ownerCreature: this.creature, + fullTurnLifetime: true, + }, + G, + ); + + trap.hide(); } }, - - _lastBonus: 0, }, // Second Ability: Gummy Mallet @@ -241,7 +240,7 @@ export default (G: Game) => { 'royal-seal', [effect], ability.creature.player, - { + { ownerCreature: ability.creature, fullTurnLifetime: true, },