diff --git a/src/shattered_sword/AI/EnemyAI.ts b/src/shattered_sword/AI/EnemyAI.ts index 794ba11..e04c0b2 100644 --- a/src/shattered_sword/AI/EnemyAI.ts +++ b/src/shattered_sword/AI/EnemyAI.ts @@ -23,6 +23,7 @@ import MathUtils from "../../Wolfie2D/Utils/MathUtils"; import { Player_Events } from "../sword_enums"; import InputWrapper from "../Tools/InputWrapper"; +import Timer from "../../Wolfie2D/Timing/Timer"; export default class EnemyAI extends StateMachineGoapAI implements BattlerAI { /** The owner of this AI */ owner: AnimatedSprite; @@ -65,6 +66,16 @@ export default class EnemyAI extends StateMachineGoapAI implements BattlerAI { exp_val: number =0; //exp value to give player when this dies + poisonTimer : Timer; + poisonCounter : number = 0; + + burnTimer : Timer ; + burnCounter : number =0; + + bleedTimer : Timer; + bleedCounter :number = 0; + + initializeAI(owner: AnimatedSprite, options: Record): void { this.owner = owner; @@ -106,6 +117,12 @@ export default class EnemyAI extends StateMachineGoapAI implements BattlerAI { //exp value this.exp_val = options.exp; + + //TODO - dots every 1 sec? can change + this.burnTimer = new Timer(1000); + this.bleedTimer = new Timer(1000); + this.poisonTimer = new Timer(1000); + } @@ -116,7 +133,7 @@ export default class EnemyAI extends StateMachineGoapAI implements BattlerAI { this.CURRENT_HP -= damage; //TODO - this.owner.animation.play("HURT",false); - //console.log(damage +" damage taken, "+this.CURRENT_HP+" hp left"); + console.log(damage +" damage taken, "+this.CURRENT_HP+" hp left"); // If we're low enough, add Low Health status to enemy if (this.CURRENT_HP <= Math.floor(this.maxHealth/2)) { @@ -203,6 +220,22 @@ export default class EnemyAI extends StateMachineGoapAI implements BattlerAI { } */ + //TODO - add extra dot damage + if(this.burnTimer.isStopped() && this.burnCounter >0){ + this.burnCounter --; + this.burnTimer.start(); + this.damage(5); + } + if(this.poisonTimer.isStopped() && this.poisonCounter >0){ + this.poisonCounter --; + this.poisonTimer.start(); + this.damage(5); + } + if(this.bleedTimer.isStopped() && this.bleedCounter >0){ + this.bleedCounter --; + this.bleedTimer.start(); + this.damage(5); + } } } diff --git a/src/shattered_sword/GameSystems/BattleManager.ts b/src/shattered_sword/GameSystems/BattleManager.ts index ee27aaa..afb6986 100644 --- a/src/shattered_sword/GameSystems/BattleManager.ts +++ b/src/shattered_sword/GameSystems/BattleManager.ts @@ -3,6 +3,7 @@ import GameNode from "../../Wolfie2D/Nodes/GameNode"; import BattlerAI from "../AI/BattlerAI"; import Weapon from "./items/Weapon"; import PlayerController from "../Player/PlayerController"; +import EnemyAI from "../AI/EnemyAI"; export default class BattleManager { players: Array; @@ -23,7 +24,20 @@ export default class BattleManager { //TODO - test shield, //add checking for each onhit buff here - (this.players[0]).addShield(1); + let player = (this.players[0]); + + player.addShield(1); + //DOTS + if(player.hasBleed){ + (enemy).bleedCounter +=3; + } + if(player.hasPoison){ + (enemy).poisonCounter =5 ; + } + if(player.hasBurn){ + (enemy).burnCounter =5 ; + } + } } } diff --git a/src/shattered_sword/Player/PlayerController.ts b/src/shattered_sword/Player/PlayerController.ts index 4d6c248..6a87e58 100644 --- a/src/shattered_sword/Player/PlayerController.ts +++ b/src/shattered_sword/Player/PlayerController.ts @@ -154,8 +154,6 @@ export default class PlayerController extends StateMachineAI implements BattlerA this.CURRENT_BUFFS = {hp:0, atk:0, def:0, speed:0, range:0}; - //to test the buffs - //this.addBuff( {type:BuffType.HEALTH, value:1} ); //i frame timer PlayerController.invincibilityTimer = new Timer(2000); @@ -169,6 +167,11 @@ export default class PlayerController extends StateMachineAI implements BattlerA PlayerController.buffPool.push(BuffCategory.SHIELD); PlayerController.buffPool.push(BuffCategory.HEALTH); } + + //to test the buffs + //this.addBuff( {type:BuffType.HEALTH, value:1} ); + this.addBuff({type:BuffType.BLEED, value:1, category:BuffCategory.DOT}); + }