diff --git a/sonic-radiance.love/game/loot/effectManager.lua b/sonic-radiance.love/game/loot/effectManager.lua index 1ee0672..19d04f6 100644 --- a/sonic-radiance.love/game/loot/effectManager.lua +++ b/sonic-radiance.love/game/loot/effectManager.lua @@ -18,6 +18,15 @@ function EffectManager:applyEffects(character) end end +function EffectManager:applyEffectsBattle(battleTarget) + local character = battleTarget.abstract + for _, effect in ipairs(self.itemdata.effects) do + local effectInstance = self:getEffectObject(effect, character) + effectInstance:applyEffect() + effectInstance:battleCallback(battleTarget) + end +end + function EffectManager:getEffectStrings(character) local returnString = "No Effect"; if (#self.itemdata.effects >= 1) then diff --git a/sonic-radiance.love/game/loot/effects/parent.lua b/sonic-radiance.love/game/loot/effects/parent.lua index d3c85b2..eee5e40 100644 --- a/sonic-radiance.love/game/loot/effects/parent.lua +++ b/sonic-radiance.love/game/loot/effects/parent.lua @@ -13,4 +13,8 @@ function EffectParent:getText() return "No effect" end +function EffectParent:battleCallback(fighter) + +end + return EffectParent diff --git a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/actions/item.lua b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/actions/item.lua index fcffdee..930b9b9 100644 --- a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/actions/item.lua +++ b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/actions/item.lua @@ -1,20 +1,29 @@ local ActionParent = require "scenes.battlesystem.controllers.fighters.systems.actions.parent" local ItemAction = ActionParent:extend() +local EffectManager = require "game.loot.effectManager" function ItemAction:new(fighter, category, item) ItemAction.super.new(self, fighter) print(item) self.category = category + self.item = item self.itemdata = game.loot:getItemData(category, item) + self.effectManager = EffectManager() + self.effectManager:getItemData(category, item) end function ItemAction:needTarget() return (not self.itemdata.affectEverybody), (self.category == "wisps") end +function ItemAction:useItemEffect() + self.effectManager:applyEffectsBattle(self.target) +end + function ItemAction:startAction() core.debug:print("cbs/action", "Starting item action") self:loadChoregraphy("useitem") + game.loot:removeItem(self.category, self.item, 1) end return ItemAction diff --git a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/init.lua b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/init.lua index 3eee591..724d1a9 100644 --- a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/init.lua +++ b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/init.lua @@ -66,6 +66,10 @@ function ChoregraphySystem:sendDamage(power, accuracy, isSpecial, isAerial) end end +function ChoregraphySystem:useItemEffect() + self.action:useItemEffect() +end + function ChoregraphySystem:endStep() self.currentStep = nil end diff --git a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/step/init.lua b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/step/init.lua index a827847..9df3c40 100644 --- a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/step/init.lua +++ b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/step/init.lua @@ -11,5 +11,6 @@ actions["sendDamage"] = require(baseURI .. "sendDamage") actions["setAnimation"] = require(baseURI .. "setAnimation") actions["wait"] = require(baseURI .. "wait") actions["waitActorFinished"] = require(baseURI .. "waitActorFinished") +actions["useItemEffect"] = require(baseURI .. "useItemEffect") return actions diff --git a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/step/useItemEffect.lua b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/step/useItemEffect.lua new file mode 100644 index 0000000..e0a12fb --- /dev/null +++ b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/step/useItemEffect.lua @@ -0,0 +1,13 @@ +local StepParent = require "scenes.battlesystem.controllers.fighters.systems.choregraphy.step.parent" +local UseItemEffect = StepParent:extend() + +function UseItemEffect:new(system, args) + UseItemEffect.super.new(self, system, args) +end + +function UseItemEffect:start() + self.choregraphy:useItemEffect() + self:finish() +end + +return UseItemEffect