From e4500c9e6f17222b62d44223e4c83ecc78ccc950 Mon Sep 17 00:00:00 2001 From: OfficialCHenry Date: Mon, 25 Apr 2022 21:23:28 -0400 Subject: [PATCH] added dot timers to player --- .../Player/PlayerController.ts | 41 ++++++++++++++----- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/src/shattered_sword/Player/PlayerController.ts b/src/shattered_sword/Player/PlayerController.ts index 6b375bb..33d3fcb 100644 --- a/src/shattered_sword/Player/PlayerController.ts +++ b/src/shattered_sword/Player/PlayerController.ts @@ -133,16 +133,15 @@ export default class PlayerController extends StateMachineAI implements BattlerA cooldownMultiplier : number = 1; fullHpBonus: Boolean = false; - //TODO - add new buffs here - /* - CURRENT_BUFFS: { - atk: number; //flat value to add to weapon - hp: number; //flat value - def: number; //flat value - speed: number; //flat value - range:number; //range will be a multiplier value: 1.5 = 150% range - } - */ + poisonTimer : Timer; + poisonCounter : number = 0; + + burnTimer : Timer ; + burnCounter : number =0; + + bleedTimer : Timer; + bleedCounter :number = 0; + @@ -174,6 +173,11 @@ export default class PlayerController extends StateMachineAI implements BattlerA PlayerController.buffPool.push(BuffCategory.HEALTH); } + //initialize dot timers + this.burnTimer = new Timer(1000); + this.bleedTimer = new Timer(1000); + this.poisonTimer = new Timer(1000); + //to test the buffs //this.addBuff( {type:BuffType.HEALTH, value:1} ); //this.addBuff({type:BuffType.BURN, value:1, category:BuffCategory.DOT}); @@ -237,6 +241,23 @@ export default class PlayerController extends StateMachineAI implements BattlerA item.use(this.owner, "player", this.lookDirection); } } + + //check dot effects + if(this.burnTimer.isStopped() && this.burnCounter >0){ + this.burnCounter --; + this.burnTimer.start(); + this.damage(10); + } + if(this.poisonTimer.isStopped() && this.poisonCounter >0){ + this.poisonCounter --; + this.poisonTimer.start(); + this.damage( Math.round(this.CURRENT_HP/20) ); + } + if(this.bleedTimer.isStopped() && this.bleedCounter >0){ + this.bleedCounter --; + this.bleedTimer.start(); + this.damage( 2 + Math.round(this.CURRENT_HP/33) ); + } }