This includes a new postEnter hook for status effects, so that they can distinguish between consumption and transfermaster
| @@ -753,6 +753,17 @@ export class Effective { | |||||
| return nilLog | return nilLog | ||||
| } | } | ||||
| /** | |||||
| * Triggers after prey enters a container | |||||
| */ | |||||
| postEnter ( | |||||
| predator: Creature, | |||||
| prey: Creature, | |||||
| container: Container | |||||
| ): LogEntry { | |||||
| return nilLog | |||||
| } | |||||
| /** | /** | ||||
| * Affects a stat | * Affects a stat | ||||
| */ | */ | ||||
| @@ -10,8 +10,9 @@ import { | |||||
| import { DynText, LiveText, ToBe, Verb } from "@/game/language" | import { DynText, LiveText, ToBe, Verb } from "@/game/language" | ||||
| import { Creature } from "../creature" | import { Creature } from "../creature" | ||||
| import { LogLine, LogEntry, LogLines, FAElem, nilLog } from "@/game/interface" | import { LogLine, LogEntry, LogLines, FAElem, nilLog } from "@/game/interface" | ||||
| import { Container } from "@/game/vore" | |||||
| import { Container, ContainerCapability } from "@/game/vore" | |||||
| import * as Words from "@/game/words" | import * as Words from "@/game/words" | ||||
| import * as Onomatopoeia from "@/game/onomatopoeia" | |||||
| export class InstantKillEffect extends StatusEffect { | export class InstantKillEffect extends StatusEffect { | ||||
| constructor () { | constructor () { | ||||
| @@ -307,7 +308,10 @@ export class InstantDigestionEffect extends StatusEffect { | |||||
| ) | ) | ||||
| } | } | ||||
| postConsume (predator: Creature, prey: Creature, container: Container) { | |||||
| postEnter (predator: Creature, prey: Creature, container: Container) { | |||||
| if (!container.capabilities.has(ContainerCapability.Digest)) { | |||||
| return nilLog | |||||
| } | |||||
| prey.applyEffect(new InstantKillEffect()) | prey.applyEffect(new InstantKillEffect()) | ||||
| predator.voreStats.Mass += prey.voreStats.Mass | predator.voreStats.Mass += prey.voreStats.Mass | ||||
| prey.voreStats.Mass = 0 | prey.voreStats.Mass = 0 | ||||
| @@ -316,6 +320,7 @@ export class InstantDigestionEffect extends StatusEffect { | |||||
| new ToBe() | new ToBe() | ||||
| )} instantly digested! `, | )} instantly digested! `, | ||||
| new FAElem("fas fa-skull"), | new FAElem("fas fa-skull"), | ||||
| Onomatopoeia.makeOnomatopoeia(Onomatopoeia.Crunch), | |||||
| container.tick(0, [prey]) | container.tick(0, [prey]) | ||||
| ) | ) | ||||
| } | } | ||||
| @@ -1,5 +1,9 @@ | |||||
| import { Onomatopoeia, RandomWord } from "./language" | |||||
| import { FormatEntry, FormatOpt, LogEntry, LogLine } from "./interface" | |||||
| import { Onomatopoeia, RandomWord, Word } from "./language" | |||||
| export function makeOnomatopoeia (word: Word): LogEntry { | |||||
| return new FormatEntry(new LogLine(`${word}`), FormatOpt.Onomatopoeia) | |||||
| } | |||||
| export const Swallow = new RandomWord([ | export const Swallow = new RandomWord([ | ||||
| new Onomatopoeia([ | new Onomatopoeia([ | ||||
| ["GL", 1, 1], | ["GL", 1, 1], | ||||
| @@ -56,3 +60,33 @@ export const Gurgle = new RandomWord([ | |||||
| ["e", 1, 1] | ["e", 1, 1] | ||||
| ]) | ]) | ||||
| ]) | ]) | ||||
| export const MuffledScream = new RandomWord([ | |||||
| new Onomatopoeia([ | |||||
| ["m", 5, 9], | |||||
| ["p", 2, 4], | |||||
| ["h", 4, 8] | |||||
| ]), | |||||
| new Onomatopoeia([ | |||||
| ["h", 4, 9], | |||||
| ["m", 3, 8], | |||||
| ["p", 1, 3], | |||||
| ["h", 3, 5] | |||||
| ]), | |||||
| new Onomatopoeia([ | |||||
| ["n", 4, 9], | |||||
| ["g", 3, 5], | |||||
| ["h", 5, 10] | |||||
| ]) | |||||
| ]) | |||||
| export const Crunch = new RandomWord([ | |||||
| new Onomatopoeia([ | |||||
| ["C", 1, 1], | |||||
| ["R", 4, 8], | |||||
| ["U", 1, 3], | |||||
| ["N", 2, 4], | |||||
| ["CH", 1, 1], | |||||
| ["!", 1, 1] | |||||
| ]) | |||||
| ]) | |||||
| @@ -214,6 +214,7 @@ export abstract class DefaultContainer implements Container { | |||||
| this.voreRelay.dispatch("onReleased", this, { prey: prey }), | this.voreRelay.dispatch("onReleased", this, { prey: prey }), | ||||
| prey.voreRelay.dispatch("onReleased", this, { prey: prey }) | prey.voreRelay.dispatch("onReleased", this, { prey: prey }) | ||||
| ] | ] | ||||
| return new LogLines(...results) | return new LogLines(...results) | ||||
| } | } | ||||
| @@ -229,6 +230,8 @@ export abstract class DefaultContainer implements Container { | |||||
| prey.voreRelay.dispatch("onEntered", this, { prey: prey }) | prey.voreRelay.dispatch("onEntered", this, { prey: prey }) | ||||
| ] | ] | ||||
| this.owner.effects.forEach(effect => results.push(effect.postEnter(this.owner, prey, this))) | |||||
| return new LogLines(...results) | return new LogLines(...results) | ||||
| } | } | ||||