diff --git a/sonic-radiance.love/scenes/battlesystem/actors/battler.lua b/sonic-radiance.love/scenes/battlesystem/actors/battler.lua index 89913a7..1b045da 100644 --- a/sonic-radiance.love/scenes/battlesystem/actors/battler.lua +++ b/sonic-radiance.love/scenes/battlesystem/actors/battler.lua @@ -14,7 +14,6 @@ end function Battler:destroy() Battler.super.destroy(self) - self.world:destroyBattler(self) end function Battler:setActive() @@ -39,40 +38,4 @@ function Battler:validateAction() end -function Battler:sendDamage(x, y, value, accuracy, isSpecial, isAerial) - local stats = self:getStats() - local value = value / 10 - - if (isSpecial) then - value = value * stats.power - else - value = value * stats.attack - end - core.debug:print("battler", "sending " .. value .." damage at position <" .. x .. ";" .. y .. ">") - - local fromEnnemy = self.isEnnemy - - local other = self.world:getActorInCase(x, y, self) - if (other ~= nil) then - core.debug:print("battler", "sending damage to actor at position <" .. x .. ";" .. y .. ">") - other:receiveDamage(value, accuracy, isSpecial, isAerial, fromWho) - return true - else - return false - end -end - -function Battler:receiveDamage(value, accuracy, isSpecial, isAerial) - local stats = self:getStats() - if (fromEnnemy ~= self.isEnnemy) then - if (isSpecial) then - value = value / stats.mind - else - value = value / stats.defense - end - core.debug:print("battler", "taken " .. value .. " damage" ) - self:setHP(value * -1, true) - end -end - return Battler diff --git a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/parent.lua b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/parent.lua index 1e7bb52..6399b6b 100644 --- a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/parent.lua +++ b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/parent.lua @@ -31,7 +31,7 @@ function FighterParent:setPP(value, relative) end function FighterParent:applyDeath() - if (self.hp <= 0 and self.isAlive) then + if (self.abstract.hp <= 0 and self.isAlive) then self:die() end end @@ -40,6 +40,34 @@ function FighterParent:die() self.isAlive = false end +function FighterParent:sendDamage(target, value, accuracy, isSpecial, isAerial) + local stats = self:getStats() + local value = value / 10 + + if (isSpecial) then + value = value * stats.power + else + value = value * stats.attack + end + + core.debug:print("cbs/battler", "Sending " .. value .." damage at " .. target.name) + + target:receiveDamage(value, accuracy, isSpecial, isAerial, fromWho) +end + +function FighterParent:receiveDamage(value, accuracy, isSpecial, isAerial) + local stats = self:getStats() + + if (isSpecial) then + value = value / stats.mind + else + value = value / stats.defense + end + + core.debug:print("cbs/fighter", "Taken " .. value .. " damage" ) + self:setHP(value * -1, true) +end + function FighterParent:getAbstract() return {} end diff --git a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/villain.lua b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/villain.lua index 3fa98cc..a26ad18 100644 --- a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/villain.lua +++ b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/villain.lua @@ -35,6 +35,11 @@ function VillainFighter:endAction() end +function FighterParent:die() + self.isAlive = false + self.actor:destroy() +end + -- LIFE FUNCTIONS function VillainFighter:setHP(value, relative) VillainFighter.super.setHP(self, value, relative) diff --git a/sonic-radiance.love/scenes/battlesystem/controllers/init.lua b/sonic-radiance.love/scenes/battlesystem/controllers/init.lua index cfec8b6..a4f48aa 100644 --- a/sonic-radiance.love/scenes/battlesystem/controllers/init.lua +++ b/sonic-radiance.love/scenes/battlesystem/controllers/init.lua @@ -90,6 +90,12 @@ function TurnController:removeAllActionsFromFighter(fighterToRemove) end end +function TurnController:applyDeath() + self.ennemies:applyDeath() + self.player:applyDeath() +end + + function TurnController:startAction() core.debug:print("cbs/turns", "Starting action " .. self.turns.current) local nextAction = self.actionList[self.turns.current] diff --git a/sonic-radiance.love/scenes/battlesystem/controllers/parent.lua b/sonic-radiance.love/scenes/battlesystem/controllers/parent.lua index b9659fa..198f358 100644 --- a/sonic-radiance.love/scenes/battlesystem/controllers/parent.lua +++ b/sonic-radiance.love/scenes/battlesystem/controllers/parent.lua @@ -18,6 +18,12 @@ function FighterControllerParent:count() return #self.list end +function FighterControllerParent:applyDeath() + for i, fighter in ipairs(self.list) do + fighter:applyDeath() + end +end + function FighterControllerParent:setActive(activeActor) self.activeActor = activeActor activeActor:setActive()