added buff strings, quick bugfix
This commit is contained in:
parent
c1a00694f6
commit
07665e0e6f
|
@ -24,6 +24,7 @@ import MathUtils from "../../Wolfie2D/Utils/MathUtils";
|
||||||
import { Player_Events } from "../sword_enums";
|
import { Player_Events } from "../sword_enums";
|
||||||
import InputWrapper from "../Tools/InputWrapper";
|
import InputWrapper from "../Tools/InputWrapper";
|
||||||
import Timer from "../../Wolfie2D/Timing/Timer";
|
import Timer from "../../Wolfie2D/Timing/Timer";
|
||||||
|
import PlayerController from "../Player/PlayerController";
|
||||||
export default class EnemyAI extends StateMachineGoapAI implements BattlerAI {
|
export default class EnemyAI extends StateMachineGoapAI implements BattlerAI {
|
||||||
/** The owner of this AI */
|
/** The owner of this AI */
|
||||||
owner: AnimatedSprite;
|
owner: AnimatedSprite;
|
||||||
|
@ -64,7 +65,7 @@ export default class EnemyAI extends StateMachineGoapAI implements BattlerAI {
|
||||||
|
|
||||||
direction: number; //1 for right, -1 for left
|
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;
|
poisonTimer : Timer;
|
||||||
poisonCounter : number = 0;
|
poisonCounter : number = 0;
|
||||||
|
@ -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){
|
if(this.burnTimer.isStopped() && this.burnCounter >0){
|
||||||
this.burnCounter --;
|
this.burnCounter --;
|
||||||
this.burnTimer.start();
|
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){
|
if(this.poisonTimer.isStopped() && this.poisonCounter >0){
|
||||||
this.poisonCounter --;
|
this.poisonCounter --;
|
||||||
this.poisonTimer.start();
|
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){
|
if(this.bleedTimer.isStopped() && this.bleedCounter >0){
|
||||||
this.bleedCounter --;
|
this.bleedCounter --;
|
||||||
this.bleedTimer.start();
|
this.bleedTimer.start();
|
||||||
this.damage(5);
|
this.damage(5 + (<PlayerController>this.player._ai).extraDotDmg + (<PlayerController>this.player._ai).CURRENT_ATK * .08);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,9 @@ export default class BattleManager {
|
||||||
(<EnemyAI>enemy).burnCounter =5 ;
|
(<EnemyAI>enemy).burnCounter =5 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(player.hasDoubleStrike){
|
||||||
|
enemy.damage(weapon.type.damage * (<PlayerController>this.players[0]).CURRENT_ATK/200);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ export default class Weapon extends Item {
|
||||||
/** The battle manager */
|
/** The battle manager */
|
||||||
battleManager: BattleManager;
|
battleManager: BattleManager;
|
||||||
|
|
||||||
|
cooldown : number = 0;
|
||||||
/** The cooldown timer for this weapon's use */
|
/** The cooldown timer for this weapon's use */
|
||||||
cooldownTimer: Timer;
|
cooldownTimer: Timer;
|
||||||
|
|
||||||
|
@ -46,6 +47,8 @@ export default class Weapon extends Item {
|
||||||
|
|
||||||
// Create the cooldown timer
|
// Create the cooldown timer
|
||||||
this.cooldownTimer = new Timer(type.cooldown);
|
this.cooldownTimer = new Timer(type.cooldown);
|
||||||
|
this.cooldown = type.cooldown;
|
||||||
|
|
||||||
this.EXTRA_DAMAGE = 0;
|
this.EXTRA_DAMAGE = 0;
|
||||||
this.EXTRA_RANGE=0;
|
this.EXTRA_RANGE=0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,6 +127,7 @@ export default class PlayerController extends StateMachineAI implements BattlerA
|
||||||
hasLifesteal : Boolean = false;
|
hasLifesteal : Boolean = false;
|
||||||
lifestealratio : number = 0; //percent of damage to steal
|
lifestealratio : number = 0; //percent of damage to steal
|
||||||
hasOneShot: Boolean = false;
|
hasOneShot: Boolean = false;
|
||||||
|
extraDotDmg : number =0;
|
||||||
|
|
||||||
//TODO - add new buffs here
|
//TODO - add new buffs here
|
||||||
CURRENT_BUFFS: {
|
CURRENT_BUFFS: {
|
||||||
|
@ -170,7 +171,7 @@ export default class PlayerController extends StateMachineAI implements BattlerA
|
||||||
|
|
||||||
//to test the buffs
|
//to test the buffs
|
||||||
//this.addBuff( {type:BuffType.HEALTH, value:1} );
|
//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");
|
//console.log("hurt anim");
|
||||||
(<AnimatedSprite>this.owner).animation.play("HURT" );
|
(<AnimatedSprite>this.owner).animation.play("HURT" );
|
||||||
this.CURRENT_HP -= damage;
|
this.CURRENT_HP -= damage;
|
||||||
if(this.CURRENT_HP <= 0){
|
//if player has shield buff give them shield when damaged
|
||||||
(<AnimatedSprite>this.owner).animation.play("DYING");
|
if(this.hasShield){
|
||||||
(<AnimatedSprite>this.owner).animation.queue("DEAD", true, Player_Events.PLAYER_KILLED);
|
this.CURRENT_SHIELD += damage * .5;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
//console.log("player is invincible");
|
//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;
|
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
|
* gives the player exp
|
||||||
* @param exp amount of exp to give the player
|
* @param exp amount of exp to give the player
|
||||||
|
@ -314,23 +329,25 @@ export default class PlayerController extends StateMachineAI implements BattlerA
|
||||||
let attackBuffs : Buff[] = [
|
let attackBuffs : Buff[] = [
|
||||||
{type:BuffType.RANGE, value:num, category: BuffCategory.ATTACK},
|
{type:BuffType.RANGE, value:num, category: BuffCategory.ATTACK},
|
||||||
{type:BuffType.ATKSPEED, 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[] = [
|
let dotBuffs : Buff[] = [
|
||||||
{type:BuffType.BLEED, value:num, category: BuffCategory.DOT},
|
{type:BuffType.BLEED, value:1, category: BuffCategory.DOT, string: "Your hits apply Bleed"},
|
||||||
{type:BuffType.BURN, value:num, category: BuffCategory.DOT},
|
{type:BuffType.BURN, value:1, category: BuffCategory.DOT, string: "Your hits apply Burn"},
|
||||||
{type:BuffType.POISON, value:num, category: BuffCategory.DOT},
|
{type:BuffType.POISON, value:1, category: BuffCategory.DOT, string: "Your hits apply poison"},
|
||||||
{type:BuffType.EXTRA_DOT, value:num, category: BuffCategory.DOT},
|
{type:BuffType.EXTRA_DOT, value:num, category: BuffCategory.DOT, string: "increase your DOT damage"},
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
let shieldBuffs : Buff[] = [
|
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 player doesnt have shield buff, give them the option, otherwise give buff shield option
|
||||||
if(!this.hasShield){
|
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{
|
else{
|
||||||
shieldBuffs.push({type:BuffType.SHIELD_DMG, value:num, category: BuffCategory.SHIELD});
|
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}
|
{type:BuffType.DEF, value:num, category: BuffCategory.HEALTH}
|
||||||
];
|
];
|
||||||
if(!this.hasLifesteal){
|
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{
|
else{
|
||||||
shieldBuffs.push({type:BuffType.LIFESTEALBUFF, value:num, category: BuffCategory.HEALTH});
|
healthBuffs.push({type:BuffType.LIFESTEALBUFF, value:num, category: BuffCategory.HEALTH});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let extraBuffs : Buff[] = [
|
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.SPEED, value:num, category: BuffCategory.EXTRA},
|
||||||
{type:BuffType.ATK, value:num, category: BuffCategory.EXTRA}
|
{type:BuffType.ATK, value:num, category: BuffCategory.EXTRA}
|
||||||
];
|
];
|
||||||
if(!this.hasOneShot){
|
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,9 +451,13 @@ export default class PlayerController extends StateMachineAI implements BattlerA
|
||||||
case BuffType.POISON:
|
case BuffType.POISON:
|
||||||
this.hasPoison = true;
|
this.hasPoison = true;
|
||||||
break;
|
break;
|
||||||
|
case BuffType.EXTRA_DOT:
|
||||||
|
this.extraDotDmg += buff.value;
|
||||||
|
break;
|
||||||
case BuffType.SHIELD:
|
case BuffType.SHIELD:
|
||||||
this.hasShield = true;
|
this.hasShield = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BuffType.ATKSPEED:
|
case BuffType.ATKSPEED:
|
||||||
if (item) {
|
if (item) {
|
||||||
//reduce cooldowntimer
|
//reduce cooldowntimer
|
||||||
|
@ -455,6 +476,9 @@ export default class PlayerController extends StateMachineAI implements BattlerA
|
||||||
this.hasLifesteal = true;
|
this.hasLifesteal = true;
|
||||||
break;
|
break;
|
||||||
case BuffType.ONESHOT:
|
case BuffType.ONESHOT:
|
||||||
|
this.MAX_HP = 1;
|
||||||
|
this.CURRENT_HP = 1;
|
||||||
|
this.CURRENT_ATK *= 100;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -246,7 +246,9 @@ export default class GameLevel extends Scene {
|
||||||
this.enemies = this.enemies.filter(item => item !== event.data.get("ai"));
|
this.enemies = this.enemies.filter(item => item !== event.data.get("ai"));
|
||||||
this.battleManager.removeEnemy(event.data.get("ai"));
|
this.battleManager.removeEnemy(event.data.get("ai"));
|
||||||
//give the player the exp value of the enemy killed
|
//give the player the exp value of the enemy killed
|
||||||
|
if(event.data.get("ai").exp_val !== undefined){
|
||||||
(<PlayerController>this.player._ai).giveExp(event.data.get("ai").exp_val);
|
(<PlayerController>this.player._ai).giveExp(event.data.get("ai").exp_val);
|
||||||
|
}
|
||||||
node.destroy(); //destroy enemy node
|
node.destroy(); //destroy enemy node
|
||||||
//TODO - this is for testing, add some chance here later
|
//TODO - this is for testing, add some chance here later
|
||||||
//this.emitter.fireEvent(Player_Events.GIVE_BUFF);
|
//this.emitter.fireEvent(Player_Events.GIVE_BUFF);
|
||||||
|
@ -254,9 +256,26 @@ export default class GameLevel extends Scene {
|
||||||
|
|
||||||
case Player_Events.GIVE_BUFF:
|
case Player_Events.GIVE_BUFF:
|
||||||
this.buffs = (<PlayerController>this.player._ai).generateBuffs();
|
this.buffs = (<PlayerController>this.player._ai).generateBuffs();
|
||||||
this.buffButton1.text = "Increase "+this.buffs[0].type.toString() + " by "+this.buffs[0].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;
|
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;
|
this.buffButton3.text = "Increase "+this.buffs[2].type + " by "+this.buffs[2].value;
|
||||||
|
}
|
||||||
|
|
||||||
//pause game here
|
//pause game here
|
||||||
this.setGameState(GameState.BUFF);
|
this.setGameState(GameState.BUFF);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user