diff --git a/sonic-radiance.love/datas/gamedata/skills/attack.lua b/sonic-radiance.love/datas/gamedata/skills/attack.lua index b6679ed..021eee9 100644 --- a/sonic-radiance.love/datas/gamedata/skills/attack.lua +++ b/sonic-radiance.love/datas/gamedata/skills/attack.lua @@ -62,6 +62,15 @@ return { -- :: -- :: {"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", condition, speed, blockProcess} diff --git a/sonic-radiance.love/datas/gamedata/skills/spinattack.lua b/sonic-radiance.love/datas/gamedata/skills/spinattack.lua index 4bb67db..9c994b9 100644 --- a/sonic-radiance.love/datas/gamedata/skills/spinattack.lua +++ b/sonic-radiance.love/datas/gamedata/skills/spinattack.lua @@ -8,7 +8,7 @@ return { {"wait", "none", 0.5}, {"setAnimation", "none", "spin", false}, {"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}, {'jumpBack', "none", true}, {'setAnimation', "none", 'idle', false}, diff --git a/sonic-radiance.love/scenes/battlesystem/actors/hero.lua b/sonic-radiance.love/scenes/battlesystem/actors/hero.lua index 2db6786..006a581 100644 --- a/sonic-radiance.love/scenes/battlesystem/actors/hero.lua +++ b/sonic-radiance.love/scenes/battlesystem/actors/hero.lua @@ -183,7 +183,6 @@ end function Hero:applyMotion(dt) if self.motion ~= 0 and self.motion ~= nil then local dx = self.x + self.motion * self.motionDirection * dt - print(dx) -- {1, 0, "line", 5, true} local ox = self.choregraphy.startx + (self.choregraphy.effectArea[1] * self.choregraphy.direction) local oy = self.choregraphy.starty + self.choregraphy.effectArea[2] @@ -354,12 +353,42 @@ function Hero:doChoregraphyAction(choregraphyAction) self.choregraphy.changeAction = false end elseif type == "sendDamage" then - local xx = self.x + self.direction - local yy = self.y 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) elseif type == "addGFX" then local sprite = choregraphyAction[3] @@ -399,6 +428,28 @@ function Hero:doChoregraphyAction(choregraphyAction) 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) self.tweens:newTimer(time, "wait") self.choregraphy.changeAction = false