feat(cbs): new damage functions for choregraphies

This commit is contained in:
Kazhnuz 2019-08-24 22:21:07 +02:00
parent 163e122b97
commit be4504ff2b
3 changed files with 64 additions and 4 deletions

View file

@ -62,6 +62,15 @@ return {
-- :: -- ::
-- :: {"sendDamage", condition, damageEffect, accuracy, isSpecial, isAerial} -- :: {"sendDamage", condition, damageEffect, accuracy, isSpecial, isAerial}
-- "sendDamageFromPos" :: Send Damage on a point from Actor position
-- ::
-- :: {"sendDamageFromPos", condition, dx, dy, damageEffect, accuracy, isSpecial, isAerial, affectedByDirection}
-- "sendDamageFromCursor" :: Send Damage on a point from Cursor final position
-- ::
-- :: {"sendDamageFromCursor", condition, dx, dy, damageEffect, accuracy, isSpecial, isAerial, affectedByDirection}
-- "dashForward" :: Dash until your are stopped -- "dashForward" :: Dash until your are stopped
-- :: {"dashForward", condition, speed, blockProcess} -- :: {"dashForward", condition, speed, blockProcess}

View file

@ -8,7 +8,7 @@ return {
{"wait", "none", 0.5}, {"wait", "none", 0.5},
{"setAnimation", "none", "spin", false}, {"setAnimation", "none", "spin", false},
{"dashForward", "none", 12, true}, {"dashForward", "none", 12, true},
{'sendDamage', "none", 120, 100, false, false}, {"sendDamageFromPos", "none", 0, 0, 120, 100, false, false, 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},

View file

@ -183,7 +183,6 @@ end
function Hero:applyMotion(dt) function Hero:applyMotion(dt)
if self.motion ~= 0 and self.motion ~= nil then if self.motion ~= 0 and self.motion ~= nil then
local dx = self.x + self.motion * self.motionDirection * dt local dx = self.x + self.motion * self.motionDirection * dt
print(dx)
-- {1, 0, "line", 5, true} -- {1, 0, "line", 5, true}
local ox = self.choregraphy.startx + (self.choregraphy.effectArea[1] * self.choregraphy.direction) local ox = self.choregraphy.startx + (self.choregraphy.effectArea[1] * self.choregraphy.direction)
local oy = self.choregraphy.starty + self.choregraphy.effectArea[2] local oy = self.choregraphy.starty + self.choregraphy.effectArea[2]
@ -354,12 +353,42 @@ function Hero:doChoregraphyAction(choregraphyAction)
self.choregraphy.changeAction = false self.choregraphy.changeAction = false
end end
elseif type == "sendDamage" then elseif type == "sendDamage" then
local xx = self.x + self.direction
local yy = self.y
local power = choregraphyAction[3] local power = choregraphyAction[3]
local accuracy = choregraphyAction[4] local accuracy = choregraphyAction[4]
local isSpecial = choregraphyAction[5] local isSpecial = choregraphyAction[5]
local isAerial = choregraphyAction[6] 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.choregraphy.haveSentDamage = self:sendDamage(xx, yy, power, accuracy, isSpecial, isAerial)
elseif type == "addGFX" then elseif type == "addGFX" then
local sprite = choregraphyAction[3] local sprite = choregraphyAction[3]
@ -399,6 +428,28 @@ function Hero:doChoregraphyAction(choregraphyAction)
end end
end end
function Hero:sendDamageToArea(effectArea, power, accuracy, isSpecial, isAerial)
local dx = effectArea[1]
if effectArea[5] then
dx = dx * self.choregraphy.direction
end
local ox = self.choregraphy.startx + dx
local oy = self.choregraphy.starty + effectArea[2]
local grid = self.maputils.maskToMap(ox, oy, effectArea[3], effectArea[4], self.choregraphy.direction)
local test = false
for i, line in ipairs(grid) do
for j, case in ipairs(line) do
if grid[i][j] == 1 then
test = self:sendDamage(j, i, power, accuracy, isSpecial, isAerial)
end
end
end
return test
end
function Hero:wait(time) function Hero:wait(time)
self.tweens:newTimer(time, "wait") self.tweens:newTimer(time, "wait")
self.choregraphy.changeAction = false self.choregraphy.changeAction = false