Browse Source

Add an instant digestion effect

Also makes it possible to selectively digest prey
master
Fen Dweller 5 years ago
parent
commit
50fcb8f222
4 changed files with 50 additions and 5 deletions
  1. +7
    -0
      src/game/combat.ts
  2. +17
    -0
      src/game/combat/effects.ts
  3. +12
    -1
      src/game/maps/town.ts
  4. +14
    -4
      src/game/vore.ts

+ 7
- 0
src/game/combat.ts View File

@@ -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
*/


+ 17
- 0
src/game/combat/effects.ts View File

@@ -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')
)
}
}

+ 12
- 1
src/game/maps/town.ts View File

@@ -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",


+ 14
- 4
src/game/vore.ts View File

@@ -160,7 +160,7 @@ export abstract class InnerContainer extends NormalContainer {

export interface VoreContainer extends Container {
digested: Array<Creature>;
tick: (dt: number) => LogEntry;
tick: (dt: number, victims?: Array<Creature>) => 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<Creature>): LogEntry {
const justDigested: Array<Creature> = []
const justAbsorbed: Array<Creature> = []

@@ -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<LogEntry> = []
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(


Loading…
Cancel
Save