sonic-radiance/sonic-radiance.love/scenes/battlesystem/fighters/character/actions/item.lua

29 lines
862 B
Lua
Raw Normal View History

local ActionParent = require "scenes.battlesystem.fighters.character.actions.parent"
2020-07-20 12:24:26 +02:00
local ItemAction = ActionParent:extend()
local EffectManager = require "game.loot.effectManager"
2020-07-20 12:24:26 +02:00
2020-08-22 23:10:22 +02:00
function ItemAction:new(fighter, category, item)
2020-07-20 12:24:26 +02:00
ItemAction.super.new(self, fighter)
2020-08-22 23:10:22 +02:00
self.category = category
self.item = item
self.itemdata = core.datas:get("items", item)
self.effectManager = EffectManager()
self.effectManager:getItemData(category, item)
2020-07-20 12:24:26 +02:00
end
function ItemAction:needTarget()
2020-08-22 23:10:22 +02:00
return (not self.itemdata.affectEverybody), (self.category == "wisps")
2020-07-20 12:24:26 +02:00
end
function ItemAction:useItemEffect()
self.effectManager:applyEffectsBattle(self.target)
end
2020-07-20 12:24:26 +02:00
function ItemAction:startAction()
2020-08-22 23:10:22 +02:00
core.debug:print("cbs/action", "Starting item action")
self:loadChoregraphy("useitem")
game.loot:removeItem(self.category, self.item, 1)
2020-07-20 12:24:26 +02:00
end
return ItemAction