feat: add basis for item handling
This commit is contained in:
parent
83eef941bb
commit
5d90ead710
5 changed files with 44 additions and 9 deletions
30
sonic-radiance.love/datas/gamedata/skills/useitem.lua
Normal file
30
sonic-radiance.love/datas/gamedata/skills/useitem.lua
Normal 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.
|
||||
},
|
||||
}
|
|
@ -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},
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue