diff --git a/src/game/combat.ts b/src/game/combat.ts index 6c8aa91..d93848e 100644 --- a/src/game/combat.ts +++ b/src/game/combat.ts @@ -580,6 +580,13 @@ export class Effective { return damage } + /** + * Triggers after consumption + */ + postConsume (predator: Creature, prey: Creature, container: VoreContainer): LogEntry { + return nilLog + } + /** * Affects a stat */ diff --git a/src/game/combat/effects.ts b/src/game/combat/effects.ts index 5523e1c..49b4c45 100644 --- a/src/game/combat/effects.ts +++ b/src/game/combat/effects.ts @@ -208,3 +208,20 @@ export class StatEffect extends StatusEffect { } } } + +export class InstantDigestionEffect extends StatusEffect { + constructor () { + super("Instant digestion", "This creature will melt people instantly", "fas fa-skull") + } + + postConsume (predator: Creature, prey: Creature, container: VoreContainer) { + prey.applyEffect(new InstantKillEffect()) + predator.voreStats.Mass += prey.voreStats.Mass + prey.voreStats.Mass = 0 + container.tick(1, [prey]) + return new LogLines( + `${prey.name.capital} ${prey.name.conjugate(new ToBe())} instantly digested! `, + new FAElem('fas fa-skull') + ) + } +} diff --git a/src/game/maps/town.ts b/src/game/maps/town.ts index ce9c3b1..ff7945c 100644 --- a/src/game/maps/town.ts +++ b/src/game/maps/town.ts @@ -6,7 +6,7 @@ import * as Items from '../items' import { LogLine, nilLog, LogLines } from '../interface' import { Creature } from '../creature' import { DevourAction } from '../combat/actions' -import { SurrenderEffect } from '../combat/effects' +import { InstantDigestionEffect, SurrenderEffect } from '../combat/effects' import moment from 'moment' import { VoreAI } from '../ai' import { DeliciousPerk } from '../combat/perks' @@ -434,6 +434,17 @@ export const Town = (): Place => { ) ) + debug.choices.push( + new Choice( + "Instant Digestion", + "Make your stomach REALLY powerful", + (world, executor) => { + executor.applyEffect(new InstantDigestionEffect()) + return new LogLine(`You're really gonna melt people now.`) + } + ) + ) + debug.choices.push( new Choice( "Set Name", diff --git a/src/game/vore.ts b/src/game/vore.ts index 931f890..080fbff 100644 --- a/src/game/vore.ts +++ b/src/game/vore.ts @@ -160,7 +160,7 @@ export abstract class InnerContainer extends NormalContainer { export interface VoreContainer extends Container { digested: Array; - tick: (dt: number) => LogEntry; + tick: (dt: number, victims?: Array) => LogEntry; digest: (preys: Creature[]) => LogEntry; absorb: (preys: Creature[]) => LogEntry; sound: Word; @@ -222,7 +222,7 @@ export abstract class NormalVoreContainer extends NormalContainer implements Vor return new LogLine(`${user.name.capital.possessive} ${this.name} ${this.name.conjugate(new Verb('finish', 'finishes'))} ${Words.Absorb.present} ${target.name.objective}, fully claiming ${target.pronouns.objective}.`) } - tick (dt: number): LogEntry { + tick (dt: number, victims?: Array): LogEntry { const justDigested: Array = [] const justAbsorbed: Array = [] @@ -230,7 +230,8 @@ export abstract class NormalVoreContainer extends NormalContainer implements Vor const tickedEntryList: LogEntry[] = [] - this.contents.forEach(prey => { + const victimList = victims ?? this.contents + victimList.forEach(prey => { const scaled = this.damage.calc(this.owner, prey).scale(dt / 60) const modified = this.owner.effects.reduce((damage, effect) => effect.modDigestionDamage(this.owner, prey, this, damage), scaled) tickedEntryList.push(this.tickLine(this.owner, prey, { damage: modified })) @@ -288,6 +289,13 @@ export abstract class NormalVoreContainer extends NormalContainer implements Vor return new LogLines(...preys.map(prey => this.digestLine(this.owner, prey))) } + consume (prey: Creature): LogEntry { + const logLine = super.consume(prey) + const results: Array = [] + this.owner.effects.forEach(effect => results.push(effect.postConsume(this.owner, prey, this))) + return new LogLines(...[logLine].concat(results)) + } + onAbsorb (prey: Creature): LogEntry { return nilLog } @@ -486,10 +494,12 @@ export class InnerBladder extends InnerVoreContainer { } export function biconnectContainers (outer: VoreContainer, inner: VoreContainer): void { + const old = outer.onDigest outer.onDigest = (prey: Creature) => { + const oldResult = old(prey) outer.digested = outer.digested.filter(victim => victim !== prey) inner.digested.push(prey) - return inner.consumeLine(inner.owner, prey) + return new LogLines(oldResult, inner.consumeLine(inner.owner, prey), inner.tick(0, [prey])) } outer.actions.push(