diff --git a/src/shattered_sword/AI/EnemyAI.ts b/src/shattered_sword/AI/EnemyAI.ts index 9bad659..65aee5e 100644 --- a/src/shattered_sword/AI/EnemyAI.ts +++ b/src/shattered_sword/AI/EnemyAI.ts @@ -64,6 +64,7 @@ export default class EnemyAI extends StateMachineAI implements BattlerAI { attackTimer : Timer; isAttaking: boolean = false; + damageTimer: Timer; initializeAI(owner: AnimatedSprite, options: Record): void { @@ -96,6 +97,7 @@ export default class EnemyAI extends StateMachineAI implements BattlerAI { this.poisonTimer = new Timer(1000); this.attackTimer = new Timer(2500); + this.damageTimer = new Timer(400); } damage(damage: number): void { @@ -136,6 +138,7 @@ export default class EnemyAI extends StateMachineAI implements BattlerAI { this.emitter.fireEvent(Player_Events.ENEMY_KILLED, {owner: this.owner.id, ai:this}); } + this.damageTimer.start(); } collideWithPlayer(player: PlayerController): void { diff --git a/src/shattered_sword/AI/EnemyStates/EnemyState.ts b/src/shattered_sword/AI/EnemyStates/EnemyState.ts index b022cec..7116edf 100644 --- a/src/shattered_sword/AI/EnemyStates/EnemyState.ts +++ b/src/shattered_sword/AI/EnemyStates/EnemyState.ts @@ -27,6 +27,9 @@ export default abstract class EnemyState extends State { } update(deltaT: number): void { + if (!this.parent.damageTimer.isStopped()) { + this.parent.velocity.x = 0; + } // Do gravity this.parent.velocity.y += this.gravity * deltaT; this.owner.move(this.parent.velocity.scaled(deltaT));