import { Anim, Character, type CharacterContext } from './Character'; import { aimDir } from './Mamie'; /** * Captain Prout. * - Attack: cape swipe. * - Special: a small jetpack thrust (toward the aim, mostly up) that leaves a toxic cloud * behind: players inside get blurred vision and cough. * - Flaw: every thrust is heard ("PROUT !" for everyone, giving away where he is). */ export class Prout extends Character { private capeTimer = 0; private puffTimer = 0; onAttack(ctx: CharacterContext): void { const p = this.stats.params; const [dx, dy] = aimDir(ctx); const reach = this.size + p.capeReach; const cx = ctx.x + dx * reach; const cy = ctx.y + dy * reach; ctx.hit(cx, cy, p.capeRadius, p.capeKnockback, p.capeStun); ctx.emitOp({ kind: 'carve', x: Math.round(cx), y: Math.round(cy), r: Math.round(p.capeCarve), power: Math.round(p.capePower) }); this.capeTimer = p.capeAnim; } onSpecial(ctx: CharacterContext): void { const p = this.stats.params; const [dx] = aimDir(ctx); ctx.setVelocity(ctx.vx + dx * p.puffSide, Math.min(ctx.vy, 0) - p.puffLift); ctx.cloud(ctx.x, ctx.y + this.size * 0.8, p.cloudRadius, p.cloudLife); ctx.cue('prout'); this.puffTimer = p.puffAnim; } override onTick(_ctx: CharacterContext, dt: number): void { this.capeTimer = Math.max(0, this.capeTimer - dt); this.puffTimer = Math.max(0, this.puffTimer - dt); } override anim(): number { return (this.capeTimer > 0 ? Anim.Attack : 0) | (this.puffTimer > 0 ? Anim.Special : 0); } }