From a05c0a17213f9ba08e43d5254d7a251c886a15a6 Mon Sep 17 00:00:00 2001 From: OfficialCHenry Date: Sat, 23 Apr 2022 18:53:29 -0400 Subject: [PATCH] changed some enemy collision sizes, added slice outlines, fixed enemy attack times, added damage multiplier instead of def --- .../data/weaponData.json | 2 +- .../spritesheets/slice.json | 2 +- .../spritesheets/slice_black.png | Bin 0 -> 270 bytes .../spritesheets/slice_red.png | Bin 0 -> 276 bytes src/shattered_sword/AI/EnemyAI.ts | 8 ++-- .../Player/PlayerController.ts | 35 ++++++++++++------ src/shattered_sword/Scenes/GameLevel.ts | 15 +++++--- src/shattered_sword/Scenes/Tutorial.ts | 6 +-- 8 files changed, 41 insertions(+), 27 deletions(-) create mode 100644 dist/shattered_sword_assets/spritesheets/slice_black.png create mode 100644 dist/shattered_sword_assets/spritesheets/slice_red.png diff --git a/dist/shattered_sword_assets/data/weaponData.json b/dist/shattered_sword_assets/data/weaponData.json index ef9bb15..a2e79ce 100644 --- a/dist/shattered_sword_assets/data/weaponData.json +++ b/dist/shattered_sword_assets/data/weaponData.json @@ -7,7 +7,7 @@ "displayName": "Knife", "animationSprite": "slice", "spriteKey": "knife", - "damage": 50, + "damage": 10, "cooldown": 30, "useVolume": 0 } diff --git a/dist/shattered_sword_assets/spritesheets/slice.json b/dist/shattered_sword_assets/spritesheets/slice.json index 4f68387..3862151 100644 --- a/dist/shattered_sword_assets/spritesheets/slice.json +++ b/dist/shattered_sword_assets/spritesheets/slice.json @@ -1,6 +1,6 @@ { "name": "slice", - "spriteSheetImage": "slice.png", + "spriteSheetImage": "slice_black.png", "spriteWidth": 16, "spriteHeight": 16, "columns": 4, diff --git a/dist/shattered_sword_assets/spritesheets/slice_black.png b/dist/shattered_sword_assets/spritesheets/slice_black.png new file mode 100644 index 0000000000000000000000000000000000000000..5e912d5a8bf34a25db5354cc82586c962c479dcc GIT binary patch literal 270 zcmV+p0rCEcP)9bAP&uhy+q*2ov^whXm_Uv#@o+$xebVwF*+e>;Nq(0+@1nF+Ra$tb+oF>e?fqo z69yc06X6%YXv??TF2`Us2gF-2e-Ty^0KEX^1yVb6raPb{0h5;ulGv*_sfyL|;tgkz zk``qMI>pi+k68q$hMt&xk2sCQ;9LZl7hH&M=1^t%6NC`Y7nFXO7hE_*YvSe|Z|hbO U_BI(300000NkvXXu0mjf02PjKQ~&?~ literal 0 HcmV?d00001 diff --git a/dist/shattered_sword_assets/spritesheets/slice_red.png b/dist/shattered_sword_assets/spritesheets/slice_red.png new file mode 100644 index 0000000000000000000000000000000000000000..8683d79b04c03abcd7c019d40268aef584d23200 GIT binary patch literal 276 zcmV+v0qg#WP)1Oy)Cs(%o| z0Nj!Gjz0|{J%E-IypC#Z!VAD_&7SM(V=$BhN>PLx~#X): void { } @@ -217,7 +217,7 @@ export default class EnemyAI extends StateMachineGoapAI implements BattlerAI { if (hit !== null && start.distanceSqTo(hit.pos) < start.distanceSqTo(pos)) { // We hit a wall, we can't see the player - console.log("player not visible") + //console.log("player not visible") return null; } } @@ -287,10 +287,10 @@ export default class EnemyAI extends StateMachineGoapAI implements BattlerAI { return; } let distance = this.owner.position.distanceTo(this.getPlayerPosition()); - if( distance <= 60){ + if( distance <= 20){ if( this.direction == Math.sign(this.getPlayerPosition().x -this.owner.position.x) ){ let dir = this.getPlayerPosition().clone().sub(this.owner.position).normalize(); - if(this.attackTimer.isPaused()){ + if(this.attackTimer.isStopped()){ this.weapon.use(this.owner, "enemy", dir.scale(1,0)) this.attackTimer.start(); } diff --git a/src/shattered_sword/Player/PlayerController.ts b/src/shattered_sword/Player/PlayerController.ts index 46a1b6a..1bb281e 100644 --- a/src/shattered_sword/Player/PlayerController.ts +++ b/src/shattered_sword/Player/PlayerController.ts @@ -88,11 +88,8 @@ export default class PlayerController extends StateMachineAI implements BattlerA MAX_HP: number = 100; CURRENT_HP: number = 100; BASE_ATK: number = 100; - MAX_ATK: number = 100; CURRENT_ATK: number = 100; - BASE_DEF: number = 100; - MAX_DEF: number = 100; - CURRENT_DEF: number = 100; + damage_multiplier: number = 1; CURRENT_EXP : number = 0; MAX_EXP : number = 100; CURRENT_SHIELD : number =0; @@ -117,7 +114,9 @@ export default class PlayerController extends StateMachineAI implements BattlerA static invincibilityTimer: Timer; - static buffPool : Array; + static buffPool : Array = new Array(); + + static appliedBuffs: Array = new Array(); //add to current_buffs later hasBleed : Boolean = false; @@ -239,7 +238,6 @@ export default class PlayerController extends StateMachineAI implements BattlerA } - // TODO - figure out attacker damage(damage: number, attacker?: GameNode): void { if (this.godMode) { @@ -265,7 +263,8 @@ export default class PlayerController extends StateMachineAI implements BattlerA this.invincible = true; //console.log("hurt anim"); (this.owner).animation.play("HURT" ); - damage /= this.BASE_DEF/ this.CURRENT_DEF; + damage *= this.damage_multiplier; + damage = parseFloat(damage.toPrecision(2)); this.CURRENT_HP -= damage; this.emitter.fireEvent(GameEventType.PLAY_SOUND, {key: "hurt", loop: false, holdReference: false}); @@ -380,7 +379,7 @@ export default class PlayerController extends StateMachineAI implements BattlerA let healthBuffs : Buff[] = [ - {type:BuffType.DEF, value: num, category: BuffCategory.HEALTH} + {type:BuffType.DEF, value: num/10, category: BuffCategory.HEALTH, string: "decrease damage by"+num/10+"%"} ]; if(!this.hasLifesteal){ healthBuffs.push({type:BuffType.LIFESTEAL, value:1, category: BuffCategory.HEALTH, string:"Gain lifesteal"}); @@ -438,7 +437,8 @@ export default class PlayerController extends StateMachineAI implements BattlerA //increase weight of selected buff category PlayerController.buffPool.push(buff.category); - + //add buff to array of applied buffs + PlayerController.appliedBuffs.push(buff); // TODO let item = this.inventory.getItem(); switch(buff.type){ @@ -456,8 +456,7 @@ export default class PlayerController extends StateMachineAI implements BattlerA this.speed += buff.value; break; case BuffType.DEF: - this.CURRENT_BUFFS.def += buff.value; - this.CURRENT_DEF += buff.value; + this.damage_multiplier *= (1-buff.value); break; case BuffType.RANGE: this.CURRENT_BUFFS.range += buff.value; @@ -511,8 +510,20 @@ export default class PlayerController extends StateMachineAI implements BattlerA this.CURRENT_HP = 1; this.CURRENT_ATK *= 100; break; - } } + } + + /** + * + * @returns record of the player stats + */ + getStats(): Record{ + let stats = {} as Record; + stats.current_health = this.CURRENT_HP; + + + return + } } \ No newline at end of file diff --git a/src/shattered_sword/Scenes/GameLevel.ts b/src/shattered_sword/Scenes/GameLevel.ts index 775d333..2ab2926 100644 --- a/src/shattered_sword/Scenes/GameLevel.ts +++ b/src/shattered_sword/Scenes/GameLevel.ts @@ -152,13 +152,14 @@ export default class GameLevel extends Scene { this.load.image("knife", "shattered_sword_assets/sprites/knife.png"); - this.load.spritesheet("slice", "shattered_sword_assets/spritesheets/slice.json"); this.load.image("inventorySlot", "shattered_sword_assets/sprites/inventory.png"); this.load.image("black", "shattered_sword_assets/images/black.png"); this.load.image("poisoning", "shattered_sword_assets/images/poisoning.png"); this.load.image("burning", "shattered_sword_assets/images/burning.png"); this.load.image("bleeding", "shattered_sword_assets/images/bleeding.png"); - + + //TODO - choose spritesheet for slice - modify the slice.json + this.load.spritesheet("slice", "shattered_sword_assets/spritesheets/slice.json"); this.load.spritesheet("test_dummy","shattered_sword_assets/spritesheets/test_dummy.json") this.enemies = new Array(); this.battleManager = new BattleManager(); @@ -418,6 +419,7 @@ export default class GameLevel extends Scene { } //TODO - this is for testing + /* if(InputWrapper.isSpawnJustPressed()){ console.log("trying to spawn enemy"); this.addEnemy("test_dummy",this.player.position,{player: this.player, @@ -431,6 +433,7 @@ export default class GameLevel extends Scene { weapon : this.createWeapon("knife") }); } + */ if (InputWrapper.isInventoryJustPressed()) { console.log("LoadingStory"); @@ -878,8 +881,8 @@ export default class GameLevel extends Scene { actions: actionsDefault, status: statusArray, goal: Statuses.REACHED_GOAL, - size: new Vec2(16,16), - offset : new Vec2(0, 16), + size: new Vec2(14,10), + offset : new Vec2(0, 22), exp: 50, weapon : this.createWeapon("knife"), }) @@ -918,8 +921,8 @@ export default class GameLevel extends Scene { //actions:actions, goal: Statuses.REACHED_GOAL, scale: .25, - size: new Vec2(16,16), - offset : new Vec2(0,0), + size: new Vec2(16,10), + offset : new Vec2(0,6), exp: 50, weapon : this.createWeapon("knife"), actions: actionsDefault, diff --git a/src/shattered_sword/Scenes/Tutorial.ts b/src/shattered_sword/Scenes/Tutorial.ts index 6a3dd73..4a93155 100644 --- a/src/shattered_sword/Scenes/Tutorial.ts +++ b/src/shattered_sword/Scenes/Tutorial.ts @@ -37,15 +37,15 @@ export default class Tutorial extends GameLevel { super.updateScene(deltaT); //spawn snake() - if(Math.random() < .001){ + if(Math.random() < .0001){ console.log("RANDOM SNAKE!"); this.addEnemy("Snake", this.player.position.clone().add(new Vec2(0,-320)),{ player: this.player, health: 50, tilemap: "Main", goal: Statuses.REACHED_GOAL, - size: new Vec2(16,16), - offset : new Vec2(0, 16), + size: new Vec2(14,10), + offset : new Vec2(0, 22), exp: 50, actions: [new AttackAction(3, [Statuses.IN_RANGE], [Statuses.REACHED_GOAL]), new Move(2, [], [Statuses.IN_RANGE], {inRange: 60})],