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},
|
||||
{"sendDamageFromCursor", "none", 0, 0, 110, 100, false, true, true},
|
||||
{'addGFX', "sentDamage", 'hitGFX', 0, 0, true, false},
|
||||
--{'jumpBack', "none", true},
|
||||
{'jumpBack', "none", true},
|
||||
{'setAnimation', "none", 'idle', false},
|
||||
},
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ function Battler:sendDamage(x, y, value, accuracy, isSpecial, isAerial)
|
|||
|
||||
local fromEnnemy = self.isEnnemy
|
||||
|
||||
local other = self.world:getActorInCase(x, y)
|
||||
local other = self.world:getActorInCase(x, y, self)
|
||||
if (other ~= nil) then
|
||||
core.debug:print("battler", "sending damage to actor at position <" .. x .. ";" .. y .. ">")
|
||||
other:receiveDamage(value, accuracy, isSpecial, isAerial, fromWho)
|
||||
|
|
|
@ -190,11 +190,13 @@ function Hero:applyMotion(dt)
|
|||
local size = self.choregraphy.effectArea[4]
|
||||
local direction = self.choregraphy.direction
|
||||
|
||||
local new_case_x = math.floor(dx)
|
||||
local new_case_y = math.floor(self.y)
|
||||
if self.maputils.isInMask(dx, self.y, ox, oy, shape, size, direction) and self.world:caseIsEmpty(new_case_x, self.y) then
|
||||
local new_case_x = utils.math.round(dx)
|
||||
local new_case_y = utils.math.round(self.y)
|
||||
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
|
||||
else
|
||||
self.x = dx
|
||||
self.motion = 0
|
||||
if (self.choregraphy.blockedBy == 'action_dashForward') then
|
||||
self.choregraphy.changeAction = true
|
||||
|
@ -327,9 +329,10 @@ function Hero:switchAction()
|
|||
self.isChoregraphyActive = false
|
||||
self:switchActiveBattler()
|
||||
else
|
||||
local condition = nextAction[2]
|
||||
local args = game.skills:getActionArguments(nextAction)
|
||||
local condition = args.condition
|
||||
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()
|
||||
else
|
||||
self:doChoregraphyAction(nextAction)
|
||||
|
@ -339,93 +342,86 @@ function Hero:switchAction()
|
|||
end
|
||||
|
||||
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
|
||||
|
||||
if type == "wait" then
|
||||
local duration = choregraphyAction[3] or 1
|
||||
self:wait(duration)
|
||||
self:wait(args.duration)
|
||||
elseif type == "setAnimation" then
|
||||
local animation = choregraphyAction[3]
|
||||
local blockProcess = choregraphyAction[4]
|
||||
self:changeAnimation(animation)
|
||||
if (blockProcess) then
|
||||
self.choregraphy.blockedBy = animation
|
||||
self.choregraphy.changeAction = false
|
||||
end
|
||||
self:chorSetAnimation(args)
|
||||
elseif type == "sendDamage" then
|
||||
local power = choregraphyAction[3]
|
||||
local accuracy = choregraphyAction[4]
|
||||
local isSpecial = choregraphyAction[5]
|
||||
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)
|
||||
self:sendDamageToArea(effectArea, args.power, args.accuracy, args.isSpecial, args.isAerial)
|
||||
elseif type == "sendDamageToPoint" then
|
||||
self:chorSendDamageToPoint(args)
|
||||
elseif type == "addGFX" then
|
||||
local sprite = choregraphyAction[3]
|
||||
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)
|
||||
self:chorAddGFX(args)
|
||||
elseif type == "playSFX" then
|
||||
local sfx = choregraphyAction[3]
|
||||
self.assets.sfx[sfx]:play()
|
||||
self.assets.sfx[args.sfx]:play()
|
||||
elseif type == "dashForward" then
|
||||
local speed = choregraphyAction[3]
|
||||
local blockProcess = choregraphyAction[4]
|
||||
self:setMotionX(self.direction, speed)
|
||||
if (blockProcess) then
|
||||
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)
|
||||
self:setMotionX(self.direction, args.speed)
|
||||
self:blockChoregraphy(args.blockProcess, "action_dashForward")
|
||||
elseif type == "jump" then
|
||||
self:chorJump(args)
|
||||
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
|
||||
|
||||
|
@ -448,7 +444,7 @@ function Hero:sendDamageToArea(effectArea, power, accuracy, isSpecial, isAerial)
|
|||
end
|
||||
end
|
||||
|
||||
return test
|
||||
self.choregraphy.haveSentDamage = test
|
||||
end
|
||||
|
||||
function Hero:wait(time)
|
||||
|
|
|
@ -85,23 +85,15 @@ end
|
|||
-- INFO FUNCTIONS
|
||||
-- Get info from the world
|
||||
|
||||
function World:caseIsEmpty(x, y)
|
||||
local isEmpty = true
|
||||
function World:caseIsEmpty(x, y, notThisActor)
|
||||
local actor = self:getActorInCase(x, y, notThisActor)
|
||||
|
||||
for i, actor in ipairs(self.actors) do
|
||||
if (actor.x == x) and (actor.y == y) then
|
||||
isEmpty = false
|
||||
else
|
||||
isEmpty = true
|
||||
end
|
||||
end
|
||||
|
||||
return isEmpty
|
||||
return (actor == nil)
|
||||
end
|
||||
|
||||
function World:getActorInCase(x, y)
|
||||
function World:getActorInCase(x, y, notThisActor)
|
||||
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 .. ">")
|
||||
return actor
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue