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

View file

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

View file

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

View file

@ -64,6 +64,16 @@ function HeroFighter:doBasicAction(action)
self:verifyTargets() self:verifyTargets()
end 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() function HeroFighter:verifyTargets()
local needTarget, targetEnnemies = self.action:needTarget() local needTarget, targetEnnemies = self.action:needTarget()

View file

@ -1,8 +1,8 @@
local actions = {} local actions = {}
actions.attack = require "scenes.battlesystem.controllers.fighters.systems.actions.attack" actions.attack = require "scenes.battlesystem.controllers.fighters.systems.actions.attack"
--actions.skill = require "scenes.battlesystem.controllers.fighters.systems.actions.skill" actions.skill = require "scenes.battlesystem.controllers.fighters.systems.actions.skill"
--actions.item = require "scenes.battlesystem.controllers.fighters.systems.actions.item" actions.item = require "scenes.battlesystem.controllers.fighters.systems.actions.item"
actions.defend = require "scenes.battlesystem.controllers.fighters.systems.actions.defend" actions.defend = require "scenes.battlesystem.controllers.fighters.systems.actions.defend"
actions.flee = require "scenes.battlesystem.controllers.fighters.systems.actions.flee" 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 if self.skilldata ~= nil then
self.assets.sfx["mSelect"]:play() self.assets.sfx["mSelect"]:play()
self.character:doNothing() self.character:useSkill(self.skillname)
--self.character:useSkill(self.skillname, self.character.x, self.character.y)
else else
core.debug:warning("cbs/menu", "skill " .. self.skillname .. " doesn't exist") core.debug:warning("cbs/menu", "skill " .. self.skillname .. " doesn't exist")
self.character:doNothing() self.character:doNothing()