feat: add basic skill actions

This commit is contained in:
Kazhnuz 2020-07-20 12:24:26 +02:00
parent 9ece46fbb5
commit fcdd10484f
8 changed files with 56 additions and 20 deletions

View file

@ -8,10 +8,8 @@ return {
cost = 00, -- the pp cost of the attack. Will be ignored if it's set
-- as character default attack
target = nil, -- which area can be selected as a target with the cursor.
-- if not nil : {ox, oy, shape, size, affectedByDirection}
targetNumber = 1, -- how many ennemy you can target with the attack.
needTarget = true,
targetNumber = 1, -- 0 for targeting all ennemies
effectArea = {1, 0, "point", 1, true}, -- which area is affected by the attack
-- if not nil : {ox, oy, shape, size, affectedByDirection}

View file

@ -1,8 +1,8 @@
return {
name = "spinattack",
cost = 05,
target = nil, -- No targeting capacity
effectArea = {0, 0, "line", 5, true}, -- which area is affected by the attack
targetNumber = 1, -- 0 for targeting all ennemies
targetEnnemies = true,
choregraphy = {
{"setAnimation", "none", "spindash", false},
{'playSFX', "none", 'spincharge'},

View file

@ -4,17 +4,11 @@
-- Also serve as a tutoriel for how to create a file attack and choregraphy
return {
name = "spinjump", -- unused for this attack, but still usefull sometimes
cost = 03, -- the pp cost of the attack. Will be ignored if it's set
-- as character default attack
name = "spinjump",
cost = 03,
target = {2, -1, "square", 3, true}, -- which area can be selected as a target with the cursor.
-- if not nil : {ox, oy, shape, size, affectedByDirection}
targetNumber = 1, -- how many ennemy you can target with the attack.
effectArea = {1, 0, "point", 1, true}, -- which area is affected by the attack
-- if not nil : {ox, oy, shape, size, affectedByDirection}
targetNumber = 1, -- 0 for targeting all ennemies
targetEnnemies = true,
choregraphy = { -- the main attack choregraphy
{"setAnimation", "none", "spinjump", false},

View file

@ -64,6 +64,16 @@ function HeroFighter:doBasicAction(action)
self:verifyTargets()
end
function HeroFighter:useItem(item)
self.action = actionList["item"](self, item)
self:verifyTargets()
end
function HeroFighter:useSkill(skill)
self.action = actionList["skill"](self, skill)
self:verifyTargets()
end
function HeroFighter:verifyTargets()
local needTarget, targetEnnemies = self.action:needTarget()

View file

@ -1,8 +1,8 @@
local actions = {}
actions.attack = require "scenes.battlesystem.controllers.fighters.systems.actions.attack"
--actions.skill = require "scenes.battlesystem.controllers.fighters.systems.actions.skill"
--actions.item = require "scenes.battlesystem.controllers.fighters.systems.actions.item"
actions.skill = require "scenes.battlesystem.controllers.fighters.systems.actions.skill"
actions.item = require "scenes.battlesystem.controllers.fighters.systems.actions.item"
actions.defend = require "scenes.battlesystem.controllers.fighters.systems.actions.defend"
actions.flee = require "scenes.battlesystem.controllers.fighters.systems.actions.flee"

View file

@ -0,0 +1,17 @@
local ActionParent = require "scenes.battlesystem.controllers.fighters.systems.actions.parent"
local ItemAction = ActionParent:extend()
function ItemAction:new(fighter, item)
ItemAction.super.new(self, fighter)
end
function ItemAction:needTarget()
return false, false
end
function ItemAction:startAction()
core.debug:print("cbs/action", "Starting flee action")
self:finishAction()
end
return ItemAction

View file

@ -0,0 +1,18 @@
local ActionParent = require "scenes.battlesystem.controllers.fighters.systems.actions.parent"
local SkillAction = ActionParent:extend()
function SkillAction:new(fighter, skill)
self.data = game.skills:getSkillData(skill)
SkillAction.super.new(self, fighter)
end
function SkillAction:needTarget()
return (self.data.targetNumber == 1), self.data.targetEnnemies
end
function SkillAction:startAction()
core.debug:print("cbs/action", "Starting flee action")
self:finishAction()
end
return SkillAction

View file

@ -276,8 +276,7 @@ function SkillWidget:sendCharacterData()
if self.skilldata ~= nil then
self.assets.sfx["mSelect"]:play()
self.character:doNothing()
--self.character:useSkill(self.skillname, self.character.x, self.character.y)
self.character:useSkill(self.skillname)
else
core.debug:warning("cbs/menu", "skill " .. self.skillname .. " doesn't exist")
self.character:doNothing()