feat: add basis for item handling

This commit is contained in:
Kazhnuz 2020-08-22 23:10:22 +02:00
parent 83eef941bb
commit 5d90ead710
5 changed files with 44 additions and 9 deletions

View file

@ -0,0 +1,30 @@
-- A basic file describing the basic attack, in order to make it customizable one
-- day ?
-- Also serve as a tutoriel for how to create a file attack and choregraphy
return {
name = "item", -- unused for this attack, but still usefull sometimes
cost = 00, -- the pp cost of the attack. Will be ignored if it's set
-- as character default attack
needTarget = true,
targetNumber = 1, -- 0 for targeting all ennemies
choregraphy = { -- the main attack choregraphy
{"setAnimation", "none", "walk", false},
{'goTo', "none", "start", 2, 0, 0.5, true},
{'setAnimation', "none", 'idle', false},
{'wait', "none", 0.4},
{'useItemEffect', "none"},
{"setAnimation", "none", "walk", false},
{'goTo', "none", "start", 0, 0, 0.5, true},
{'setAnimation', "none", 'idle', false},
},
onContact = { -- if the attack move and touch multiple ennemies, you can add
-- specific effect when you touch the ennemy.
},
}

View file

@ -9,7 +9,8 @@ return {
["jumpTo"] = {"origin", "x", "y", "duration", "blockProcess"},
["jumpBack"] = {"duration", "blockProcess"},
["waitActorFinished"] = {"waitFor"},
["addQTE"] = {"qteData", "origin", "blockProcess"}
["addQTE"] = {"qteData", "origin", "blockProcess"},
["useItemEffect"] = {},
--[name] = {args},
}

View file

@ -63,8 +63,8 @@ function HeroFighter:doBasicAction(action)
self:verifyTargets()
end
function HeroFighter:useItem(item)
self.action = actionList["item"](self, item)
function HeroFighter:useItem(category, item)
self.action = actionList["item"](self, category, item)
self:verifyTargets()
end

View file

@ -1,17 +1,20 @@
local ActionParent = require "scenes.battlesystem.controllers.fighters.systems.actions.parent"
local ItemAction = ActionParent:extend()
function ItemAction:new(fighter, item)
function ItemAction:new(fighter, category, item)
ItemAction.super.new(self, fighter)
print(item)
self.category = category
self.itemdata = game.loot:getItemData(category, item)
end
function ItemAction:needTarget()
return false, false
return (not self.itemdata.affectEverybody), (self.category == "wisps")
end
function ItemAction:startAction()
core.debug:print("cbs/action", "Starting flee action")
self:finishAction()
core.debug:print("cbs/action", "Starting item action")
self:loadChoregraphy("useitem")
end
return ItemAction

View file

@ -124,6 +124,7 @@ end
-- A widget to handle items
function widgets.ItemWidget:new(character, menu_name, item)
self.category = menu_name
self.itemname = item
local label2 = "00"
@ -136,8 +137,8 @@ function widgets.ItemWidget:new(character, menu_name, item)
end
function widgets.ItemWidget:sendCharacterData()
self.character:doNothing()
self.assets.sfx["mError"]:play()
self.character:useItem(self.category, self.itemname)
self.assets.sfx["mBeep"]:play()
end