improvement(cbs): rework the choregraphy system
This commit is contained in:
parent
c59486dbcb
commit
86b5ad1cae
4 changed files with 86 additions and 98 deletions
|
@ -21,7 +21,7 @@ return {
|
||||||
{'jumpToCursor', 'none', true},
|
{'jumpToCursor', 'none', true},
|
||||||
{"sendDamageFromCursor", "none", 0, 0, 110, 100, false, true, true},
|
{"sendDamageFromCursor", "none", 0, 0, 110, 100, false, true, true},
|
||||||
{'addGFX', "sentDamage", 'hitGFX', 0, 0, true, false},
|
{'addGFX', "sentDamage", 'hitGFX', 0, 0, true, false},
|
||||||
--{'jumpBack', "none", true},
|
{'jumpBack', "none", true},
|
||||||
{'setAnimation', "none", 'idle', false},
|
{'setAnimation', "none", 'idle', false},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ function Battler:sendDamage(x, y, value, accuracy, isSpecial, isAerial)
|
||||||
|
|
||||||
local fromEnnemy = self.isEnnemy
|
local fromEnnemy = self.isEnnemy
|
||||||
|
|
||||||
local other = self.world:getActorInCase(x, y)
|
local other = self.world:getActorInCase(x, y, self)
|
||||||
if (other ~= nil) then
|
if (other ~= nil) then
|
||||||
core.debug:print("battler", "sending damage to actor at position <" .. x .. ";" .. y .. ">")
|
core.debug:print("battler", "sending damage to actor at position <" .. x .. ";" .. y .. ">")
|
||||||
other:receiveDamage(value, accuracy, isSpecial, isAerial, fromWho)
|
other:receiveDamage(value, accuracy, isSpecial, isAerial, fromWho)
|
||||||
|
|
|
@ -190,11 +190,13 @@ function Hero:applyMotion(dt)
|
||||||
local size = self.choregraphy.effectArea[4]
|
local size = self.choregraphy.effectArea[4]
|
||||||
local direction = self.choregraphy.direction
|
local direction = self.choregraphy.direction
|
||||||
|
|
||||||
local new_case_x = math.floor(dx)
|
local new_case_x = utils.math.round(dx)
|
||||||
local new_case_y = math.floor(self.y)
|
local new_case_y = utils.math.round(self.y)
|
||||||
if self.maputils.isInMask(dx, self.y, ox, oy, shape, size, direction) and self.world:caseIsEmpty(new_case_x, self.y) then
|
print(new_case_x, new_case_y, self.world:caseIsEmpty(new_case_x, new_case_y, self))
|
||||||
|
if self.maputils.isInMask(dx, self.y, ox, oy, shape, size, direction) and self.world:caseIsEmpty(new_case_x, new_case_y, self) then
|
||||||
self.x = dx
|
self.x = dx
|
||||||
else
|
else
|
||||||
|
self.x = dx
|
||||||
self.motion = 0
|
self.motion = 0
|
||||||
if (self.choregraphy.blockedBy == 'action_dashForward') then
|
if (self.choregraphy.blockedBy == 'action_dashForward') then
|
||||||
self.choregraphy.changeAction = true
|
self.choregraphy.changeAction = true
|
||||||
|
@ -327,9 +329,10 @@ function Hero:switchAction()
|
||||||
self.isChoregraphyActive = false
|
self.isChoregraphyActive = false
|
||||||
self:switchActiveBattler()
|
self:switchActiveBattler()
|
||||||
else
|
else
|
||||||
local condition = nextAction[2]
|
local args = game.skills:getActionArguments(nextAction)
|
||||||
|
local condition = args.condition
|
||||||
if (condition == "sentDamage") and (not self.choregraphy.haveSentDamage) then
|
if (condition == "sentDamage") and (not self.choregraphy.haveSentDamage) then
|
||||||
core.debug:print("cbs/hero", "you didn't do damage, skipping " .. nextAction[1])
|
core.debug:print("cbs/hero", "you didn't do damage, skipping " .. args.name)
|
||||||
self:switchAction()
|
self:switchAction()
|
||||||
else
|
else
|
||||||
self:doChoregraphyAction(nextAction)
|
self:doChoregraphyAction(nextAction)
|
||||||
|
@ -339,93 +342,86 @@ function Hero:switchAction()
|
||||||
end
|
end
|
||||||
|
|
||||||
function Hero:doChoregraphyAction(choregraphyAction)
|
function Hero:doChoregraphyAction(choregraphyAction)
|
||||||
local type = choregraphyAction[1] or "unknown"
|
local args = game.skills:getActionArguments(choregraphyAction)
|
||||||
|
local type = args.type or "unknown"
|
||||||
|
local effectArea = self.choregraphy.effectArea
|
||||||
self.choregraphy.changeAction = true
|
self.choregraphy.changeAction = true
|
||||||
|
|
||||||
if type == "wait" then
|
if type == "wait" then
|
||||||
local duration = choregraphyAction[3] or 1
|
local duration = choregraphyAction[3] or 1
|
||||||
self:wait(duration)
|
self:wait(args.duration)
|
||||||
elseif type == "setAnimation" then
|
elseif type == "setAnimation" then
|
||||||
local animation = choregraphyAction[3]
|
self:chorSetAnimation(args)
|
||||||
local blockProcess = choregraphyAction[4]
|
|
||||||
self:changeAnimation(animation)
|
|
||||||
if (blockProcess) then
|
|
||||||
self.choregraphy.blockedBy = animation
|
|
||||||
self.choregraphy.changeAction = false
|
|
||||||
end
|
|
||||||
elseif type == "sendDamage" then
|
elseif type == "sendDamage" then
|
||||||
local power = choregraphyAction[3]
|
self:sendDamageToArea(effectArea, args.power, args.accuracy, args.isSpecial, args.isAerial)
|
||||||
local accuracy = choregraphyAction[4]
|
elseif type == "sendDamageToPoint" then
|
||||||
local isSpecial = choregraphyAction[5]
|
self:chorSendDamageToPoint(args)
|
||||||
local isAerial = choregraphyAction[6]
|
|
||||||
self.choregraphy.haveSentDamage = self:sendDamageToArea(self.choregraphy.effectArea, power, accuracy, isSpecial, isAerial)
|
|
||||||
elseif type == "sendDamageFromPos" then
|
|
||||||
local xx = utils.math.round(self.x)
|
|
||||||
local yy = utils.math.round(self.y)
|
|
||||||
local dx = choregraphyAction[3]
|
|
||||||
local dy = choregraphyAction[4]
|
|
||||||
local power = choregraphyAction[5]
|
|
||||||
local accuracy = choregraphyAction[6]
|
|
||||||
local isSpecial = choregraphyAction[7]
|
|
||||||
local isAerial = choregraphyAction[8]
|
|
||||||
local affectedByDirection = choregraphyAction[9]
|
|
||||||
if affectedByDirection then
|
|
||||||
dx = dx * self.choregraphy.direction
|
|
||||||
end
|
|
||||||
xx = xx + dx
|
|
||||||
yy = yy + dy
|
|
||||||
self.choregraphy.haveSentDamage = self:sendDamage(xx, yy, power, accuracy, isSpecial, isAerial)
|
|
||||||
elseif type == "sendDamageFromCursor" then
|
|
||||||
local xx = self.choregraphy.dx
|
|
||||||
local yy = self.choregraphy.dy
|
|
||||||
local dx = choregraphyAction[3]
|
|
||||||
local dy = choregraphyAction[4]
|
|
||||||
local power = choregraphyAction[5]
|
|
||||||
local accuracy = choregraphyAction[6]
|
|
||||||
local isSpecial = choregraphyAction[7]
|
|
||||||
local isAerial = choregraphyAction[8]
|
|
||||||
local affectedByDirection = choregraphyAction[9]
|
|
||||||
if affectedByDirection then
|
|
||||||
dx = dx * self.choregraphy.direction
|
|
||||||
end
|
|
||||||
xx = xx + dx
|
|
||||||
yy = yy + dy
|
|
||||||
self.choregraphy.haveSentDamage = self:sendDamage(xx, yy, power, accuracy, isSpecial, isAerial)
|
|
||||||
elseif type == "addGFX" then
|
elseif type == "addGFX" then
|
||||||
local sprite = choregraphyAction[3]
|
self:chorAddGFX(args)
|
||||||
local dx = choregraphyAction[4]
|
|
||||||
local dy = choregraphyAction[5]
|
|
||||||
local affectedByDirection = choregraphyAction[6]
|
|
||||||
if (affectedByDirection) then
|
|
||||||
dx = dx * self.direction
|
|
||||||
end
|
|
||||||
local blockProcess = choregraphyAction[7]
|
|
||||||
|
|
||||||
local x = self.x
|
|
||||||
local y = self.y
|
|
||||||
local z = 0
|
|
||||||
|
|
||||||
self.world.obj.GFX(self.world, x + dx, y + dy, z, sprite, self, blockProcess)
|
|
||||||
elseif type == "playSFX" then
|
elseif type == "playSFX" then
|
||||||
local sfx = choregraphyAction[3]
|
self.assets.sfx[args.sfx]:play()
|
||||||
self.assets.sfx[sfx]:play()
|
|
||||||
elseif type == "dashForward" then
|
elseif type == "dashForward" then
|
||||||
local speed = choregraphyAction[3]
|
self:setMotionX(self.direction, args.speed)
|
||||||
local blockProcess = choregraphyAction[4]
|
self:blockChoregraphy(args.blockProcess, "action_dashForward")
|
||||||
self:setMotionX(self.direction, speed)
|
elseif type == "jump" then
|
||||||
if (blockProcess) then
|
self:chorJump(args)
|
||||||
self.choregraphy.blockedBy = "action_dashForward"
|
|
||||||
self.choregraphy.changeAction = false
|
|
||||||
end
|
|
||||||
elseif type == "jumpBack" then
|
|
||||||
local blockProcess = choregraphyAction[3]
|
|
||||||
if (blockProcess) then
|
|
||||||
self.choregraphy.blockedBy = "action_jumpBack"
|
|
||||||
self.choregraphy.changeAction = false
|
|
||||||
end
|
|
||||||
self:jumpTo(self.choregraphy.startx, self.choregraphy.starty, 32, "action_jumpBack", false)
|
|
||||||
else
|
else
|
||||||
core.debug:warning("cbs/hero", "unknown action type " .. type)
|
core.debug:warning("cbs/hero", "unknown action type " .. type .. ' (' .. args.name .. ')')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Hero:chorSetAnimation(args)
|
||||||
|
self:changeAnimation(args.animation)
|
||||||
|
self:blockChoregraphy(args.blockProcess, args.animation)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Hero:chorAddGFX(args)
|
||||||
|
local dx = args.dx
|
||||||
|
if (args.affectedByDirection) then
|
||||||
|
dx = dx * self.direction
|
||||||
|
end
|
||||||
|
local x = self.x
|
||||||
|
local y = self.y
|
||||||
|
local z = 0
|
||||||
|
|
||||||
|
self.world.obj.GFX(self.world, x + dx, y + args.dy, z, args.sprite, self, args.blockProcess)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Hero:chorSendDamageToPoint(args)
|
||||||
|
local xx, yy
|
||||||
|
if args.name == "sendDamageFromCursor" then
|
||||||
|
xx = self.choregraphy.dx
|
||||||
|
yy = self.choregraphy.dy
|
||||||
|
elseif args.name == "sendDamageFromPos" then
|
||||||
|
xx = utils.math.round(self.x)
|
||||||
|
yy = utils.math.round(self.y)
|
||||||
|
end
|
||||||
|
|
||||||
|
local dx = args.dx
|
||||||
|
if (args.affectedByDirection) then
|
||||||
|
dx = dx * self.choregraphy.direction
|
||||||
|
end
|
||||||
|
xx = xx + dx
|
||||||
|
yy = yy + args.dy
|
||||||
|
self.choregraphy.haveSentDamage = self:sendDamage(xx, yy, args.power, args.accuracy, args.isSpecial, args.isAerial)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Hero:chorJump(args)
|
||||||
|
local xx, yy
|
||||||
|
if args.name == "jumpBack" then
|
||||||
|
xx, yy = self.choregraphy.startx, self.choregraphy.starty
|
||||||
|
elseif args.name == "jumpToCursor" then
|
||||||
|
xx, yy = self.choregraphy.dx, self.choregraphy.dy
|
||||||
|
end
|
||||||
|
|
||||||
|
self:jumpTo(xx, yy, 32, "action_jumpBack", false)
|
||||||
|
self:blockChoregraphy(args.blockProcess, "action_jumpBack")
|
||||||
|
end
|
||||||
|
|
||||||
|
function Hero:blockChoregraphy(isBlocked, blockedBy)
|
||||||
|
if (isBlocked) then
|
||||||
|
self.choregraphy.blockedBy = blockedBy
|
||||||
|
self.choregraphy.changeAction = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -448,7 +444,7 @@ function Hero:sendDamageToArea(effectArea, power, accuracy, isSpecial, isAerial)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return test
|
self.choregraphy.haveSentDamage = test
|
||||||
end
|
end
|
||||||
|
|
||||||
function Hero:wait(time)
|
function Hero:wait(time)
|
||||||
|
|
|
@ -85,23 +85,15 @@ end
|
||||||
-- INFO FUNCTIONS
|
-- INFO FUNCTIONS
|
||||||
-- Get info from the world
|
-- Get info from the world
|
||||||
|
|
||||||
function World:caseIsEmpty(x, y)
|
function World:caseIsEmpty(x, y, notThisActor)
|
||||||
local isEmpty = true
|
local actor = self:getActorInCase(x, y, notThisActor)
|
||||||
|
|
||||||
for i, actor in ipairs(self.actors) do
|
return (actor == nil)
|
||||||
if (actor.x == x) and (actor.y == y) then
|
|
||||||
isEmpty = false
|
|
||||||
else
|
|
||||||
isEmpty = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return isEmpty
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function World:getActorInCase(x, y)
|
function World:getActorInCase(x, y, notThisActor)
|
||||||
for i, actor in ipairs(self.actors) do
|
for i, actor in ipairs(self.actors) do
|
||||||
if (actor.x == x) and (actor.y == y) then
|
if (actor.x == x) and (actor.y == y) and (actor ~= notThisActor) then
|
||||||
core.debug:print("cbs/world", "one actor found in case <" .. x .. ";" .. y .. ">")
|
core.debug:print("cbs/world", "one actor found in case <" .. x .. ";" .. y .. ">")
|
||||||
return actor
|
return actor
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue