From 4ff4c989d4cb29a8d3fe0fb0c3294647c6366e13 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sat, 22 Aug 2020 23:28:05 +0200 Subject: [PATCH] fix: correctly apply death at start of battle Fix #28 --- .../datas/gamedata/characters/amy/sprites.lua | 9 ++++++++- .../datas/gamedata/characters/sonic/sprites.lua | 9 ++++++++- .../datas/gamedata/characters/tails/sprites.lua | 9 ++++++++- sonic-radiance.love/scenes/battlesystem/actors/hero.lua | 9 +++++++++ .../battlesystem/controllers/fighters/character.lua | 6 +++++- .../scenes/battlesystem/controllers/init.lua | 1 + 6 files changed, 39 insertions(+), 4 deletions(-) diff --git a/sonic-radiance.love/datas/gamedata/characters/amy/sprites.lua b/sonic-radiance.love/datas/gamedata/characters/amy/sprites.lua index 89a8e56..bc77bf6 100644 --- a/sonic-radiance.love/datas/gamedata/characters/amy/sprites.lua +++ b/sonic-radiance.love/datas/gamedata/characters/amy/sprites.lua @@ -119,12 +119,19 @@ return { speed = 15, pauseAtEnd = true, }, - ["ko"] = { + ["getKo"] = { startAt = 50, endAt = 52, loop = 52, speed = 15, pauseAtEnd = true, + }, + ["ko"] = { + startAt = 52, + endAt = 52, + loop = 52, + speed = 15, + pauseAtEnd = true, } } } diff --git a/sonic-radiance.love/datas/gamedata/characters/sonic/sprites.lua b/sonic-radiance.love/datas/gamedata/characters/sonic/sprites.lua index 479d4d0..91bf2c2 100644 --- a/sonic-radiance.love/datas/gamedata/characters/sonic/sprites.lua +++ b/sonic-radiance.love/datas/gamedata/characters/sonic/sprites.lua @@ -119,12 +119,19 @@ return { speed = 15, pauseAtEnd = true, }, - ["ko"] = { + ["getKo"] = { startAt = 58, endAt = 62, loop = 62, speed = 15, pauseAtEnd = true, + }, + ["ko"] = { + startAt = 62, + endAt = 62, + loop = 62, + speed = 15, + pauseAtEnd = true, } } } diff --git a/sonic-radiance.love/datas/gamedata/characters/tails/sprites.lua b/sonic-radiance.love/datas/gamedata/characters/tails/sprites.lua index c275b7f..bcf738c 100644 --- a/sonic-radiance.love/datas/gamedata/characters/tails/sprites.lua +++ b/sonic-radiance.love/datas/gamedata/characters/tails/sprites.lua @@ -119,12 +119,19 @@ return { speed = 15, pauseAtEnd = true, }, - ["ko"] = { + ["getKo"] = { startAt = 53, endAt = 59, loop = 59, speed = 15, pauseAtEnd = true, + }, + ["ko"] = { + startAt = 59, + endAt = 59, + loop = 59, + speed = 15, + pauseAtEnd = true, } } } diff --git a/sonic-radiance.love/scenes/battlesystem/actors/hero.lua b/sonic-radiance.love/scenes/battlesystem/actors/hero.lua index b804d2d..4c67468 100644 --- a/sonic-radiance.love/scenes/battlesystem/actors/hero.lua +++ b/sonic-radiance.love/scenes/battlesystem/actors/hero.lua @@ -7,6 +7,7 @@ local Hero = Battler:extend() function Hero:new(world, x, y, owner, charnumber) Hero.super.new(self, world, x, y, 0, owner) self:initSprite() + self.isKo = false end -- UPDATE FUNCTION @@ -24,7 +25,15 @@ function Hero:getHurt() end function Hero:die() + if (not self.isKo) then + self:changeAnimation("getKo") + self.isKo = true + end +end + +function Hero:setAsKo() self:changeAnimation("ko") + self.isKo = true end -- ASSETS FUNCTIONS diff --git a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/character.lua b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/character.lua index ed1d374..c7776ed 100644 --- a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/character.lua +++ b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/character.lua @@ -39,7 +39,11 @@ end function HeroFighter:createActor() local x, y = HEROES_LINE, ((self.id-1)*(4/(#game.characters.team-1))+1) - return self.world.obj.Hero(self.world, x, y, self) + local hero = self.world.obj.Hero(self.world, x, y, self) + if (self.abstract.hp <= 0) then + hero:setAsKo() + end + return hero end function HeroFighter:startAction() diff --git a/sonic-radiance.love/scenes/battlesystem/controllers/init.lua b/sonic-radiance.love/scenes/battlesystem/controllers/init.lua index 03851ae..ca41ead 100644 --- a/sonic-radiance.love/scenes/battlesystem/controllers/init.lua +++ b/sonic-radiance.love/scenes/battlesystem/controllers/init.lua @@ -31,6 +31,7 @@ function TurnController:new(scene, battleData) -- Change the seed at the start of each battle math.randomseed( os.time() ) + self:applyDeath() end function TurnController:startBattle()