From 8b785eb0a31b00b5a99f9ac68bc69c67a02c0f38 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 8 Aug 2021 11:34:54 +0200 Subject: [PATCH] feat: support multiple target for skills --- .../battlesystem/controllers/fighters/parent.lua | 14 ++++++++++++++ .../systems/choregraphy/mixins/wrappers.lua | 13 ++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/parent.lua b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/parent.lua index d075300..6ab0fc9 100644 --- a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/parent.lua +++ b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/parent.lua @@ -76,6 +76,20 @@ function FighterParent:haveProtecType(type) return self.abstract:haveProtecType(type) end +function FighterParent:sendDamageToAll(listTarget, value, type, element, isSpecial) + for _, target in ipairs(listTarget) do + self:sendDamage(target, value, type, element, isSpecial) + end +end + +function FighterParent:getTargets(ourSide) + if (self.isHero == ourSide) then + return self.turnSystem.player:getTargets(true) + else + return self.turnSystem.ennemies:getTargets(true) + end +end + function FighterParent:sendDamage(target, value, type, element, isSpecial) local damage = battleutils.computeLaunchingDamages(value, self, isSpecial) diff --git a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/mixins/wrappers.lua b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/mixins/wrappers.lua index 6acdee6..6aefe54 100644 --- a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/mixins/wrappers.lua +++ b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/mixins/wrappers.lua @@ -13,6 +13,11 @@ end function InfosMixin:initTargets(target) self.target = target self.haveSentDamage = false + + if (self.target == nil) then + local _, targetEnnemies = self.action:needTarget() + self.targetList = self.fighter:getTargets(targetEnnemies == false) + end end function InfosMixin:getActor(name) @@ -30,12 +35,14 @@ function InfosMixin:getTargetActor() end function InfosMixin:sendDamage(power, type, element, isSpecial) - if (self.target ~= nil) then - if (self.fighter.isAlive) then + if (self.fighter.isAlive) then + if (self.target ~= nil) then self.haveSentDamage = self.fighter:sendDamage(self.target, power, type, element, isSpecial) else - self.haveSentDamage = false + self.haveSentDamage = self.fighter:sendDamageToAll(self.targetList, power, type, element, isSpecial) end + else + self.haveSentDamage = false end end