From eedf981c54bb60b7f3b91b0fcbd72a6da5f806b2 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 18 Jul 2021 08:59:01 +0200 Subject: [PATCH] feat: add counter system for choregraphy --- .../datas/parsers/choregraphystep.lua | 3 ++- .../fighters/systems/choregraphy/conditions.lua | 4 ++++ .../fighters/systems/choregraphy/init.lua | 12 ++++++++++++ .../fighters/systems/choregraphy/step/init.lua | 1 + .../systems/choregraphy/step/setCounter.lua | 13 +++++++++++++ 5 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/step/setCounter.lua diff --git a/sonic-radiance.love/datas/parsers/choregraphystep.lua b/sonic-radiance.love/datas/parsers/choregraphystep.lua index 0358723..26afa89 100644 --- a/sonic-radiance.love/datas/parsers/choregraphystep.lua +++ b/sonic-radiance.love/datas/parsers/choregraphystep.lua @@ -9,11 +9,12 @@ return { ["setAnimation"] = {"animation", "blockProcess"}, ["jump"] = {"power", "bounceNumber", "blockProcess"}, ["jumpTo"] = {"origin", "x", "y", "duration", "blockProcess"}, - ["jumpBack"] = {"duration", "blockProcess"}, + ["jumpBack"] = {"height", "speed", "blockProcess"}, ["waitActorFinished"] = {"waitFor"}, ["waitFor"] = {"waitFor"}, ["skipTo"] = {"skipTo"}, ["addQTE"] = {"qteData", "origin", "blockProcess"}, + ["setCounter"] = {"counterName", "number", "relative"}, ["useItemEffect"] = {}, --[name] = {args}, }, diff --git a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/conditions.lua b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/conditions.lua index 272d153..1ecaa89 100644 --- a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/conditions.lua +++ b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/conditions.lua @@ -24,4 +24,8 @@ function Conditions.actionStarted(cond, predicate, asker) return asker:testTagAction(cond[2], 1) end +function Conditions.counter(cond, predicate, asker) + return predicate.utils.testVariables(asker:getCounter(cond[2]), cond[3], cond[4]) +end + return Conditions \ No newline at end of file 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 c42e139..6c01d48 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 @@ -29,6 +29,7 @@ function ChoregraphySystem:new(action, choregraphy) self.qte.list = {} self.finishedTagActions = {} + self.counters = {} end function ChoregraphySystem:update(dt) @@ -131,6 +132,17 @@ function ChoregraphySystem:finishTagAction(tag) self.finishedTagActions[tag] = ACTION_FINISHED end +function ChoregraphySystem:getCounter(counterName) + return (self.counters[counterName] or 0) +end + +function ChoregraphySystem:setCounter(counterName, number, relative) + if (relative == true) then + number = number + self:getCounter(counterName) + end + self.counters[counterName] = number +end + function ChoregraphySystem:sendDamage(power, type, element, isSpecial) if (self.target ~= nil) then if (self.fighter.isAlive) then 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 f968f33..6773208 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 @@ -14,5 +14,6 @@ actions["waitFor"] = require(baseURI .. "waitFor") actions["skipTo"] = require(baseURI .. "skipTo") actions["waitActorFinished"] = require(baseURI .. "waitActorFinished") actions["useItemEffect"] = require(baseURI .. "useItemEffect") +actions["setCounter"] = require(baseURI .. "setCounter") return actions diff --git a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/step/setCounter.lua b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/step/setCounter.lua new file mode 100644 index 0000000..174391d --- /dev/null +++ b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/step/setCounter.lua @@ -0,0 +1,13 @@ +local StepParent = require "scenes.battlesystem.controllers.fighters.systems.choregraphy.step.parent" +local SetCounterStep = StepParent:extend() + +function SetCounterStep:new(system, args) + SetCounterStep.super.new(self, system, args) +end + +function SetCounterStep:start() + self.choregraphy:setCounter(self.arguments.counterName, self.arguments.number, self.arguments.relative) + self:finish() +end + +return SetCounterStep