added buff strings, quick bugfix

This commit is contained in:
OfficialCHenry 2022-04-20 17:07:50 -04:00
parent c1a00694f6
commit 07665e0e6f
5 changed files with 77 additions and 27 deletions

View File

@ -24,6 +24,7 @@ import MathUtils from "../../Wolfie2D/Utils/MathUtils";
import { Player_Events } from "../sword_enums";
import InputWrapper from "../Tools/InputWrapper";
import Timer from "../../Wolfie2D/Timing/Timer";
import PlayerController from "../Player/PlayerController";
export default class EnemyAI extends StateMachineGoapAI implements BattlerAI {
/** The owner of this AI */
owner: AnimatedSprite;
@ -64,7 +65,7 @@ export default class EnemyAI extends StateMachineGoapAI implements BattlerAI {
direction: number; //1 for right, -1 for left
exp_val: number =0; //exp value to give player when this dies
exp_val: number = 100; //exp value to give player when this dies
poisonTimer : Timer;
poisonCounter : number = 0;
@ -76,7 +77,7 @@ export default class EnemyAI extends StateMachineGoapAI implements BattlerAI {
bleedCounter :number = 0;
initializeAI(owner: AnimatedSprite, options: Record<string, any>): void {
initializeAI(owner: AnimatedSprite, options: Record<string, any>): void {
this.owner = owner;
//add states
@ -220,21 +221,21 @@ export default class EnemyAI extends StateMachineGoapAI implements BattlerAI {
}
*/
//TODO - add extra dot damage
//TODO
if(this.burnTimer.isStopped() && this.burnCounter >0){
this.burnCounter --;
this.burnTimer.start();
this.damage(5);
this.damage(5 + (<PlayerController>this.player._ai).extraDotDmg + (<PlayerController>this.player._ai).CURRENT_ATK * .2);
}
if(this.poisonTimer.isStopped() && this.poisonCounter >0){
this.poisonCounter --;
this.poisonTimer.start();
this.damage(5);
this.damage(5 + (<PlayerController>this.player._ai).extraDotDmg + (<PlayerController>this.player._ai).CURRENT_ATK * .2);
}
if(this.bleedTimer.isStopped() && this.bleedCounter >0){
this.bleedCounter --;
this.bleedTimer.start();
this.damage(5);
this.damage(5 + (<PlayerController>this.player._ai).extraDotDmg + (<PlayerController>this.player._ai).CURRENT_ATK * .08);
}
}
}

View File

@ -37,7 +37,10 @@ export default class BattleManager {
if(player.hasBurn){
(<EnemyAI>enemy).burnCounter =5 ;
}
if(player.hasDoubleStrike){
enemy.damage(weapon.type.damage * (<PlayerController>this.players[0]).CURRENT_ATK/200);
}
}
}
}

View File

@ -22,6 +22,7 @@ export default class Weapon extends Item {
/** The battle manager */
battleManager: BattleManager;
cooldown : number = 0;
/** The cooldown timer for this weapon's use */
cooldownTimer: Timer;
@ -46,6 +47,8 @@ export default class Weapon extends Item {
// Create the cooldown timer
this.cooldownTimer = new Timer(type.cooldown);
this.cooldown = type.cooldown;
this.EXTRA_DAMAGE = 0;
this.EXTRA_RANGE=0;
}

View File

@ -127,6 +127,7 @@ export default class PlayerController extends StateMachineAI implements BattlerA
hasLifesteal : Boolean = false;
lifestealratio : number = 0; //percent of damage to steal
hasOneShot: Boolean = false;
extraDotDmg : number =0;
//TODO - add new buffs here
CURRENT_BUFFS: {
@ -170,7 +171,7 @@ export default class PlayerController extends StateMachineAI implements BattlerA
//to test the buffs
//this.addBuff( {type:BuffType.HEALTH, value:1} );
this.addBuff({type:BuffType.BLEED, value:1, category:BuffCategory.DOT});
this.addBuff({type:BuffType.BURN, value:1, category:BuffCategory.DOT});
}
@ -260,16 +261,22 @@ export default class PlayerController extends StateMachineAI implements BattlerA
//console.log("hurt anim");
(<AnimatedSprite>this.owner).animation.play("HURT" );
this.CURRENT_HP -= damage;
if(this.CURRENT_HP <= 0){
(<AnimatedSprite>this.owner).animation.play("DYING");
(<AnimatedSprite>this.owner).animation.queue("DEAD", true, Player_Events.PLAYER_KILLED);
//if player has shield buff give them shield when damaged
if(this.hasShield){
this.CURRENT_SHIELD += damage * .5;
}
}
}
else{
//console.log("player is invincible");
}
if(this.CURRENT_HP <= 0){
(<AnimatedSprite>this.owner).animation.play("DYING");
(<AnimatedSprite>this.owner).animation.queue("DEAD", true, Player_Events.PLAYER_KILLED);
}
}
/**
@ -280,6 +287,14 @@ export default class PlayerController extends StateMachineAI implements BattlerA
this.CURRENT_SHIELD = (this.CURRENT_SHIELD + shield) % this.MAX_SHIELD;
}
/**
* gives health to the player
* @param health health to give player
*/
addHealth(health : number){
this.CURRENT_HP = (this.CURRENT_HP + health) %this.MAX_HP + this.CURRENT_BUFFS.hp;
}
/**
* gives the player exp
* @param exp amount of exp to give the player
@ -314,23 +329,25 @@ export default class PlayerController extends StateMachineAI implements BattlerA
let attackBuffs : Buff[] = [
{type:BuffType.RANGE, value:num, category: BuffCategory.ATTACK},
{type:BuffType.ATKSPEED, value:num, category: BuffCategory.ATTACK},
{type:BuffType.DOUBLESTRIKE, value:num, category: BuffCategory.ATTACK},
];
if(!this.hasDoubleStrike){
attackBuffs.push({type:BuffType.DOUBLESTRIKE, value:num, category: BuffCategory.ATTACK, string:"your attacks are followed by a weaker strike"});
}
let dotBuffs : Buff[] = [
{type:BuffType.BLEED, value:num, category: BuffCategory.DOT},
{type:BuffType.BURN, value:num, category: BuffCategory.DOT},
{type:BuffType.POISON, value:num, category: BuffCategory.DOT},
{type:BuffType.EXTRA_DOT, value:num, category: BuffCategory.DOT},
{type:BuffType.BLEED, value:1, category: BuffCategory.DOT, string: "Your hits apply Bleed"},
{type:BuffType.BURN, value:1, category: BuffCategory.DOT, string: "Your hits apply Burn"},
{type:BuffType.POISON, value:1, category: BuffCategory.DOT, string: "Your hits apply poison"},
{type:BuffType.EXTRA_DOT, value:num, category: BuffCategory.DOT, string: "increase your DOT damage"},
];
let shieldBuffs : Buff[] = [
{type:BuffType.HEALTH, value:num, category: BuffCategory.SHIELD},
{type:BuffType.HEALTH, value:1, category: BuffCategory.SHIELD},
];
//if player doesnt have shield buff, give them the option, otherwise give buff shield option
if(!this.hasShield){
shieldBuffs.push({type:BuffType.SHIELD, value:num, category: BuffCategory.SHIELD});
shieldBuffs.push({type:BuffType.SHIELD, value:1, category: BuffCategory.SHIELD, string: "Gain Shield When Damaged"});
}
else{
shieldBuffs.push({type:BuffType.SHIELD_DMG, value:num, category: BuffCategory.SHIELD});
@ -341,20 +358,20 @@ export default class PlayerController extends StateMachineAI implements BattlerA
{type:BuffType.DEF, value:num, category: BuffCategory.HEALTH}
];
if(!this.hasLifesteal){
shieldBuffs.push({type:BuffType.LIFESTEAL, value:num, category: BuffCategory.HEALTH});
healthBuffs.push({type:BuffType.LIFESTEAL, value:1, category: BuffCategory.HEALTH, string:"Gain lifesteal"});
}
else{
shieldBuffs.push({type:BuffType.LIFESTEALBUFF, value:num, category: BuffCategory.HEALTH});
healthBuffs.push({type:BuffType.LIFESTEALBUFF, value:num, category: BuffCategory.HEALTH});
}
let extraBuffs : Buff[] = [
{type:BuffType.EXTRALIFE, value:num, category: BuffCategory.EXTRA},
{type:BuffType.EXTRALIFE, value:1, category: BuffCategory.EXTRA, string: "Gain an Extra Life"},
{type:BuffType.SPEED, value:num, category: BuffCategory.EXTRA},
{type:BuffType.ATK, value:num, category: BuffCategory.EXTRA}
];
if(!this.hasOneShot){
extraBuffs.push({type:BuffType.ONESHOT, value:num, category: BuffCategory.EXTRA});
extraBuffs.push({type:BuffType.ONESHOT, value:1, category: BuffCategory.EXTRA, string: "Your hits hurt 100x more but you die in one shot"});
};
@ -434,14 +451,18 @@ export default class PlayerController extends StateMachineAI implements BattlerA
case BuffType.POISON:
this.hasPoison = true;
break;
case BuffType.EXTRA_DOT:
this.extraDotDmg += buff.value;
break;
case BuffType.SHIELD:
this.hasShield = true;
break;
case BuffType.ATKSPEED:
if (item) {
//reduce cooldowntimer
//(<Weapon>item).cooldownTimer
}
}
break;
case BuffType.DOUBLESTRIKE:
break;
@ -455,6 +476,9 @@ export default class PlayerController extends StateMachineAI implements BattlerA
this.hasLifesteal = true;
break;
case BuffType.ONESHOT:
this.MAX_HP = 1;
this.CURRENT_HP = 1;
this.CURRENT_ATK *= 100;
break;
}
}

View File

@ -246,7 +246,9 @@ export default class GameLevel extends Scene {
this.enemies = this.enemies.filter(item => item !== event.data.get("ai"));
this.battleManager.removeEnemy(event.data.get("ai"));
//give the player the exp value of the enemy killed
(<PlayerController>this.player._ai).giveExp(event.data.get("ai").exp_val);
if(event.data.get("ai").exp_val !== undefined){
(<PlayerController>this.player._ai).giveExp(event.data.get("ai").exp_val);
}
node.destroy(); //destroy enemy node
//TODO - this is for testing, add some chance here later
//this.emitter.fireEvent(Player_Events.GIVE_BUFF);
@ -254,9 +256,26 @@ export default class GameLevel extends Scene {
case Player_Events.GIVE_BUFF:
this.buffs = (<PlayerController>this.player._ai).generateBuffs();
this.buffButton1.text = "Increase "+this.buffs[0].type.toString() + " by "+this.buffs[0].value;
this.buffButton2.text = "Increase "+this.buffs[1].type + " by "+this.buffs[1].value;
this.buffButton3.text = "Increase "+this.buffs[2].type + " by "+this.buffs[2].value;
if(this.buffs[0].string !== undefined){
this.buffButton1.text = this.buffs[0].string;
}
else{
this.buffButton1.text = "Increase "+this.buffs[0].type + " by "+this.buffs[0].value;
}
if(this.buffs[1].string !== undefined){
this.buffButton2.text = this.buffs[1].string;
}
else{
this.buffButton2.text = "Increase "+this.buffs[1].type + " by "+this.buffs[1].value;
}
if(this.buffs[2].string !== undefined){
this.buffButton3.text = this.buffs[2].string;
}
else{
this.buffButton3.text = "Increase "+this.buffs[2].type + " by "+this.buffs[2].value;
}
//pause game here
this.setGameState(GameState.BUFF);