From 15058fa7f87c75085d8ddbf001c104cbf2b1f9bd Mon Sep 17 00:00:00 2001 From: a327ex Date: Wed, 19 May 2021 02:21:08 -0300 Subject: [PATCH] Bug fixes --- enemies.lua | 3 ++- engine/init.lua | 1 + engine/system.lua | 6 +++++- player.lua | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/enemies.lua b/enemies.lua index 798f840..d1b6ec9 100644 --- a/enemies.lua +++ b/enemies.lua @@ -392,9 +392,10 @@ function Seeker:hit(damage, projectile) if self.push_invulnerable then return end self:show_hp() - local actual_damage = self:calculate_damage(damage)*(self.stun_dmg_m or 1)*(self.bane_dmg_m or 1) + local actual_damage = math.max(self:calculate_damage(damage)*(self.stun_dmg_m or 1)*(self.bane_dmg_m or 1), 0) if self.vulnerable then actual_damage = actual_damage*1.2 end self.hp = self.hp - actual_damage + if self.hp > self.max_hp then self.hp = self.max_hp end main.current.damage_dealt = main.current.damage_dealt + actual_damage if projectile and projectile.spawn_critters_on_hit then diff --git a/engine/init.lua b/engine/init.lua index a1fb606..096227c 100644 --- a/engine/init.lua +++ b/engine/init.lua @@ -48,6 +48,7 @@ function engine_run(config) love.filesystem.setIdentity(config.game_name) steam.init() system.load_state() + if type(state) ~= 'table' then state = {} end local _, _, flags = love.window.getMode() local window_width, window_height = love.window.getDesktopDimensions(flags.display) diff --git a/engine/system.lua b/engine/system.lua index 778e40c..50cc0b8 100644 --- a/engine/system.lua +++ b/engine/system.lua @@ -120,7 +120,11 @@ end function system.save_state() if not system.does_file_exist(love.filesystem.getSaveDirectory()) then love.filesystem.createDirectory("") end - binser.w(state_path, state or {}) + local file = io.open(state_path, "r") + if file then + file:close() + binser.w(state_path, state or {}) + end end diff --git a/player.lua b/player.lua index 3c2a10f..ede404d 100644 --- a/player.lua +++ b/player.lua @@ -1438,7 +1438,7 @@ function Projectile:on_collision_enter(other, contact) self:die(x, y, r, 0) knife_hit_wall1:play{pitch = random:float(0.9, 1.1), volume = 0.2} local r = Unit.bounce(self, nx, ny) - trigger:after(0.01, function() + self.parent.t:after(0.01, function() WallKnife{group = main.current.main, x = x, y = y, r = r, v = self.v*0.1, color = self.color} end) if self.character == 'spellblade' then