feat: add counter system for choregraphy

This commit is contained in:
Kazhnuz 2021-07-18 08:59:01 +02:00
parent 5b0dde30e0
commit eedf981c54
5 changed files with 32 additions and 1 deletions

View file

@ -9,11 +9,12 @@ return {
["setAnimation"] = {"animation", "blockProcess"}, ["setAnimation"] = {"animation", "blockProcess"},
["jump"] = {"power", "bounceNumber", "blockProcess"}, ["jump"] = {"power", "bounceNumber", "blockProcess"},
["jumpTo"] = {"origin", "x", "y", "duration", "blockProcess"}, ["jumpTo"] = {"origin", "x", "y", "duration", "blockProcess"},
["jumpBack"] = {"duration", "blockProcess"}, ["jumpBack"] = {"height", "speed", "blockProcess"},
["waitActorFinished"] = {"waitFor"}, ["waitActorFinished"] = {"waitFor"},
["waitFor"] = {"waitFor"}, ["waitFor"] = {"waitFor"},
["skipTo"] = {"skipTo"}, ["skipTo"] = {"skipTo"},
["addQTE"] = {"qteData", "origin", "blockProcess"}, ["addQTE"] = {"qteData", "origin", "blockProcess"},
["setCounter"] = {"counterName", "number", "relative"},
["useItemEffect"] = {}, ["useItemEffect"] = {},
--[name] = {args}, --[name] = {args},
}, },

View file

@ -24,4 +24,8 @@ function Conditions.actionStarted(cond, predicate, asker)
return asker:testTagAction(cond[2], 1) return asker:testTagAction(cond[2], 1)
end end
function Conditions.counter(cond, predicate, asker)
return predicate.utils.testVariables(asker:getCounter(cond[2]), cond[3], cond[4])
end
return Conditions return Conditions

View file

@ -29,6 +29,7 @@ function ChoregraphySystem:new(action, choregraphy)
self.qte.list = {} self.qte.list = {}
self.finishedTagActions = {} self.finishedTagActions = {}
self.counters = {}
end end
function ChoregraphySystem:update(dt) function ChoregraphySystem:update(dt)
@ -131,6 +132,17 @@ function ChoregraphySystem:finishTagAction(tag)
self.finishedTagActions[tag] = ACTION_FINISHED self.finishedTagActions[tag] = ACTION_FINISHED
end 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) function ChoregraphySystem:sendDamage(power, type, element, isSpecial)
if (self.target ~= nil) then if (self.target ~= nil) then
if (self.fighter.isAlive) then if (self.fighter.isAlive) then

View file

@ -14,5 +14,6 @@ actions["waitFor"] = require(baseURI .. "waitFor")
actions["skipTo"] = require(baseURI .. "skipTo") actions["skipTo"] = require(baseURI .. "skipTo")
actions["waitActorFinished"] = require(baseURI .. "waitActorFinished") actions["waitActorFinished"] = require(baseURI .. "waitActorFinished")
actions["useItemEffect"] = require(baseURI .. "useItemEffect") actions["useItemEffect"] = require(baseURI .. "useItemEffect")
actions["setCounter"] = require(baseURI .. "setCounter")
return actions return actions

View file

@ -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