2019-08-14 16:26:23 +02:00
|
|
|
local Battler = require("scenes.battlesystem.actors.battler")
|
|
|
|
local Hero = Battler:extend()
|
2019-03-10 13:11:26 +01:00
|
|
|
|
2019-08-14 22:47:10 +02:00
|
|
|
local gui = require "game.modules.gui"
|
2020-05-01 17:04:17 +02:00
|
|
|
local StatusBar = require "scenes.battlesystem.gui.statusbar"
|
2019-08-14 22:47:10 +02:00
|
|
|
|
2020-05-02 13:01:43 +02:00
|
|
|
local ChoregraphySystem = require "scenes.battlesystem.actors.systems.choregraphy"
|
|
|
|
|
2019-08-14 17:32:33 +02:00
|
|
|
-- INIT FUNCTIONS
|
|
|
|
-- Initialize the hero
|
|
|
|
|
2019-08-14 16:26:23 +02:00
|
|
|
function Hero:new(world, x, y, charid, charnumber)
|
|
|
|
Hero.super.new(self, world, x, y, 0)
|
2019-03-10 13:11:26 +01:00
|
|
|
self.isHero = true
|
|
|
|
|
2019-08-24 15:44:07 +02:00
|
|
|
self:initMovementSystem()
|
2019-08-22 22:04:14 +02:00
|
|
|
|
2019-08-24 16:13:22 +02:00
|
|
|
self:initCharacter(charid)
|
2019-08-14 13:56:25 +02:00
|
|
|
|
2019-08-14 20:24:32 +02:00
|
|
|
self:initSprite()
|
2019-08-18 19:02:14 +02:00
|
|
|
self:initChoregraphySystem()
|
2019-08-19 15:34:52 +02:00
|
|
|
|
|
|
|
self:initVoices()
|
2020-05-01 17:04:17 +02:00
|
|
|
|
|
|
|
self.statusbar = StatusBar(self)
|
|
|
|
|
|
|
|
self.side = "heroes"
|
2019-08-19 15:34:52 +02:00
|
|
|
end
|
|
|
|
|
2019-08-24 15:44:07 +02:00
|
|
|
-- CHARACTER FUNCTIONS
|
|
|
|
-- All functions related to character handling
|
2019-08-19 15:34:52 +02:00
|
|
|
|
2019-08-24 15:44:07 +02:00
|
|
|
function Hero:initCharacter(charid)
|
|
|
|
if charid == nil then
|
|
|
|
core.debug:error("FATAL ERROR: charid not set")
|
|
|
|
end
|
|
|
|
self.charid = charid
|
|
|
|
self.charnumber = charnumber or 1
|
2019-08-19 15:34:52 +02:00
|
|
|
|
2019-08-24 15:44:07 +02:00
|
|
|
self.hp = game.characters.list[self.charid].stats.hp
|
|
|
|
self.pp = game.characters.list[self.charid].stats.pp
|
2019-08-19 15:34:52 +02:00
|
|
|
|
2019-08-24 15:44:07 +02:00
|
|
|
self.actionPerTurn = game.characters.list[self.charid].turns
|
2019-03-10 13:11:26 +01:00
|
|
|
|
2019-08-24 15:44:07 +02:00
|
|
|
self.turnAction = nil
|
|
|
|
end
|
2019-03-10 13:11:26 +01:00
|
|
|
|
2019-08-14 17:32:33 +02:00
|
|
|
function Hero:getStats()
|
|
|
|
return game.characters.list[self.charid].stats
|
2019-03-10 13:11:26 +01:00
|
|
|
end
|
|
|
|
|
2019-08-22 22:04:14 +02:00
|
|
|
function Hero:setHP(value, relative)
|
|
|
|
if relative == true then
|
|
|
|
value = game.characters.list[self.charid].stats.hp + value
|
|
|
|
end
|
|
|
|
|
|
|
|
game.characters.list[self.charid].stats.hp = value
|
2020-05-01 17:04:17 +02:00
|
|
|
self.statusbar:updateHP()
|
2019-08-22 22:04:14 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function Hero:setPP(value, relative)
|
|
|
|
if relative == true then
|
|
|
|
value = game.characters.list[self.charid].stats.pp + value
|
|
|
|
end
|
|
|
|
|
|
|
|
game.characters.list[self.charid].stats.pp = value
|
2020-05-01 17:04:17 +02:00
|
|
|
self.statusbar:updatePP()
|
2019-08-22 22:04:14 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2019-08-14 17:32:33 +02:00
|
|
|
-- ACTIVITY FUNCTION
|
|
|
|
-- Function to set or unset activity to the character
|
2019-03-10 13:11:26 +01:00
|
|
|
|
2019-08-14 16:26:23 +02:00
|
|
|
function Hero:setActive()
|
2019-08-14 20:44:20 +02:00
|
|
|
core.debug:print("cbs/hero", "hero " .. self.charid .. " is now active")
|
2019-08-15 09:16:24 +02:00
|
|
|
local gridsize = game.characters.list[self.charid].move
|
2019-08-12 12:37:00 +02:00
|
|
|
if (gridsize == nil) then
|
|
|
|
gridsize = 3
|
|
|
|
core.debug:warning("cbs/character", "move value is nil")
|
|
|
|
end
|
2019-08-14 16:27:45 +02:00
|
|
|
self.world.cursor:setGrid(self.x, self.y, "circle", gridsize, 1, self)
|
2019-08-31 11:18:56 +02:00
|
|
|
self.x, self.y = utils.math.round(self.x), utils.math.round(self.y)
|
2019-03-10 13:11:26 +01:00
|
|
|
self.startx, self.starty = self.x, self.y
|
2019-08-31 11:18:56 +02:00
|
|
|
|
2019-08-24 15:44:07 +02:00
|
|
|
self.world.cursor:set(self.startx, self.starty, "cursorMove")
|
2019-03-10 13:11:26 +01:00
|
|
|
|
2020-05-02 13:01:43 +02:00
|
|
|
--self:talk("turnstart")
|
2019-08-19 15:34:52 +02:00
|
|
|
|
2019-03-10 13:11:26 +01:00
|
|
|
self.directionPrevious = self.direction
|
|
|
|
end
|
|
|
|
|
2019-08-14 17:32:33 +02:00
|
|
|
-- UPDATE FUNCTION
|
|
|
|
-- Update the hero
|
|
|
|
|
2019-08-14 16:26:23 +02:00
|
|
|
function Hero:update(dt)
|
2019-08-16 23:04:30 +02:00
|
|
|
Hero.super.update(self, dt)
|
2019-08-24 15:44:07 +02:00
|
|
|
-- Get keys to have some keyboard functions
|
2019-08-14 16:26:23 +02:00
|
|
|
self.keys = self.scene:getKeys(1)
|
2019-08-18 19:02:14 +02:00
|
|
|
|
2019-08-24 15:44:07 +02:00
|
|
|
-- Calculate speed to calculate animation speed
|
|
|
|
self:updateSpeed(dt)
|
|
|
|
|
2020-05-02 13:01:43 +02:00
|
|
|
self:updateChoregraphy(dt)
|
2019-08-18 19:02:14 +02:00
|
|
|
|
2019-08-24 15:44:07 +02:00
|
|
|
if (self.scene:haveMenus()) then
|
|
|
|
self:changeDirection(dt)
|
2019-03-10 13:11:26 +01:00
|
|
|
end
|
|
|
|
|
2019-08-14 17:32:33 +02:00
|
|
|
self.xprevious = self.x
|
|
|
|
self.yprevious = self.y
|
2019-08-31 17:30:56 +02:00
|
|
|
self.zprevious = self.z
|
2020-05-01 17:04:17 +02:00
|
|
|
|
|
|
|
self.statusbar:update(dt)
|
2019-08-24 15:44:07 +02:00
|
|
|
end
|
2019-03-10 13:11:26 +01:00
|
|
|
|
2019-08-24 15:44:07 +02:00
|
|
|
-- MOVE FUNCTIONS
|
|
|
|
-- All functions handling the moving
|
2019-08-14 17:32:33 +02:00
|
|
|
|
2019-08-24 21:06:05 +02:00
|
|
|
local MOVEMENT_DURATION = 0.20
|
|
|
|
|
2019-08-24 15:44:07 +02:00
|
|
|
function Hero:initMovementSystem()
|
|
|
|
self.startx, self.starty = self.x, self.y
|
2019-08-31 17:30:56 +02:00
|
|
|
self.xprevious, self.yprevious, self.zprevious = self.x, self.y, self.z
|
2019-08-24 15:44:07 +02:00
|
|
|
self.direction = 1
|
|
|
|
self.directionPrevious = 1
|
2019-08-31 17:30:56 +02:00
|
|
|
self.directionLocked = false
|
|
|
|
self.unlockDirection = true
|
2019-08-24 16:13:22 +02:00
|
|
|
|
|
|
|
self:initJump()
|
2019-08-24 15:44:07 +02:00
|
|
|
end
|
2019-08-14 17:32:33 +02:00
|
|
|
|
2019-08-31 17:30:56 +02:00
|
|
|
function Hero:getMovementDuration(dx, dy, factor)
|
|
|
|
local factor = factor or 1
|
|
|
|
local duration = MOVEMENT_DURATION / factor
|
|
|
|
local coef = 0.5
|
2019-08-24 21:06:05 +02:00
|
|
|
local dx, dy = dx, dy
|
|
|
|
local distance = utils.math.pointDistance(self.x, self.y, dx, dy) * coef
|
|
|
|
return duration * distance
|
|
|
|
end
|
|
|
|
|
2019-08-31 17:30:56 +02:00
|
|
|
function Hero:goTo(dx, dy, timerName, factor, easing)
|
|
|
|
local easing = easing or 'inOutQuad'
|
|
|
|
local factor = factor or 1
|
|
|
|
local duration = math.max(self:getMovementDuration(dx, dy, factor), 0.30)
|
2019-08-24 21:49:16 +02:00
|
|
|
if duration > 0 then
|
2019-08-31 17:30:56 +02:00
|
|
|
self.tweens:newTween(0, duration, {x = dx, y = dy}, easing)
|
2019-08-24 21:49:16 +02:00
|
|
|
end
|
2019-08-24 21:06:05 +02:00
|
|
|
self.tweens:newTimer(duration + 0.02, timerName)
|
2019-08-24 15:44:07 +02:00
|
|
|
end
|
|
|
|
|
2019-08-31 17:30:56 +02:00
|
|
|
function Hero:jumpTo(dx, dy, size, timerName, spinjump, factor, easing)
|
|
|
|
local easing = easing or 'inOutQuad'
|
|
|
|
local factor = factor or 1
|
|
|
|
local duration = math.max(self:getMovementDuration(dx, dy, factor), 0.30)
|
|
|
|
self.tweens:newTween(0, duration, {x = dx, y = dy}, easing)
|
2019-08-24 21:46:59 +02:00
|
|
|
self.tweens:newTimer(duration + 0.02, timerName)
|
2019-08-24 21:06:05 +02:00
|
|
|
self:setJump(size, spinjump, duration)
|
2019-08-24 16:13:22 +02:00
|
|
|
end
|
|
|
|
|
2019-08-24 15:44:07 +02:00
|
|
|
function Hero:updateSpeed(dt)
|
2019-08-24 21:46:59 +02:00
|
|
|
self:applyMotion(dt)
|
2019-08-24 15:44:07 +02:00
|
|
|
self.xspeed = self.x - self.xprevious
|
|
|
|
self.yspeed = self.y - self.yprevious
|
2019-08-31 17:30:56 +02:00
|
|
|
self.zspeed = self.z - self.zprevious
|
2019-08-24 15:44:07 +02:00
|
|
|
|
|
|
|
self.gspeed = math.sqrt(self.xspeed^2 + self.yspeed^2)
|
2019-08-14 17:32:33 +02:00
|
|
|
|
|
|
|
-- Handle direction
|
2019-08-24 15:44:07 +02:00
|
|
|
if math.abs(self.xspeed) > 0 then
|
2019-08-31 17:30:56 +02:00
|
|
|
if (self.directionLocked == false) then
|
|
|
|
self.direction = utils.math.sign(self.xspeed)
|
|
|
|
end
|
|
|
|
else
|
|
|
|
if self.unlockDirection then
|
|
|
|
self.unlockDirection = false
|
|
|
|
self.directionLocked = false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if self.z > 0 and self.jump.spin == false then
|
|
|
|
if self.zspeed > 0 then
|
|
|
|
self:changeAnimation("jump")
|
|
|
|
else
|
|
|
|
self:changeAnimation("fall")
|
|
|
|
end
|
2019-08-14 17:32:33 +02:00
|
|
|
end
|
|
|
|
|
2019-08-24 15:44:07 +02:00
|
|
|
self:setCustomSpeed(self.gspeed * 320)
|
2019-03-10 13:11:26 +01:00
|
|
|
end
|
|
|
|
|
2019-08-24 15:44:07 +02:00
|
|
|
function Hero:changeDirection(dt)
|
2019-08-14 17:32:33 +02:00
|
|
|
-- Change direction by pressing left or right when selecting the next action
|
|
|
|
if (self.keys["left"].isPressed) then
|
|
|
|
self.direction = -1
|
|
|
|
elseif (self.keys["right"].isPressed) then
|
|
|
|
self.direction = 1
|
|
|
|
end
|
2019-03-10 13:11:26 +01:00
|
|
|
end
|
|
|
|
|
2019-08-24 16:13:22 +02:00
|
|
|
function Hero:initJump()
|
|
|
|
self.jump = {}
|
|
|
|
self.jump.spin = false
|
|
|
|
end
|
|
|
|
|
|
|
|
function Hero:setJump(size, spinjump, duration)
|
|
|
|
local tweenDuration = duration / 2
|
|
|
|
self.tweens:newTween(0, tweenDuration, {z = size}, 'outQuad')
|
|
|
|
self.tweens:newTween(tweenDuration, tweenDuration, {z = 0}, 'inQuad')
|
2019-08-31 17:30:56 +02:00
|
|
|
self.jump.spin = spinjump
|
2019-08-24 16:13:22 +02:00
|
|
|
end
|
|
|
|
|
2019-08-24 21:46:59 +02:00
|
|
|
function Hero:setMotionX(direction, speed)
|
|
|
|
self.motion = speed
|
|
|
|
self.motionDirection = direction
|
|
|
|
end
|
|
|
|
|
|
|
|
function Hero:applyMotion(dt)
|
|
|
|
if self.motion ~= 0 and self.motion ~= nil then
|
|
|
|
local dx = self.x + self.motion * self.motionDirection * dt
|
|
|
|
-- {1, 0, "line", 5, true}
|
|
|
|
local ox = self.choregraphy.startx + (self.choregraphy.effectArea[1] * self.choregraphy.direction)
|
|
|
|
local oy = self.choregraphy.starty + self.choregraphy.effectArea[2]
|
|
|
|
local shape = self.choregraphy.effectArea[3]
|
|
|
|
local size = self.choregraphy.effectArea[4]
|
|
|
|
local direction = self.choregraphy.direction
|
|
|
|
|
2019-08-25 15:54:26 +02:00
|
|
|
local new_case_x = utils.math.round(dx)
|
|
|
|
local new_case_y = utils.math.round(self.y)
|
|
|
|
print(new_case_x, new_case_y, self.world:caseIsEmpty(new_case_x, new_case_y, self))
|
|
|
|
if self.maputils.isInMask(dx, self.y, ox, oy, shape, size, direction) and self.world:caseIsEmpty(new_case_x, new_case_y, self) then
|
2019-08-24 21:46:59 +02:00
|
|
|
self.x = dx
|
|
|
|
else
|
2019-08-25 15:54:26 +02:00
|
|
|
self.x = dx
|
2019-08-24 21:46:59 +02:00
|
|
|
self.motion = 0
|
2020-05-02 13:01:43 +02:00
|
|
|
if (self.blockingChoregraphy == 'action_dashForward') then
|
|
|
|
self:unblockChoregraphy()
|
2019-08-24 21:46:59 +02:00
|
|
|
self.direction = self.choregraphy.direction
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-08-14 17:32:33 +02:00
|
|
|
-- SIGNAL FUNCTIONS
|
|
|
|
-- All functions related to signal receiving
|
|
|
|
|
|
|
|
function Hero:receiveSignal(action_type, id)
|
|
|
|
if id == nil then
|
|
|
|
core.debug:print("battler/hero", "action selected : " .. action_type)
|
|
|
|
else
|
|
|
|
core.debug:print("battler/hero", "action selected : " .. action_type .. " (" .. id .. ")")
|
|
|
|
end
|
|
|
|
if (action_type == "defend") then
|
2019-03-10 13:11:26 +01:00
|
|
|
self.turnAction = "defend"
|
2019-08-18 16:46:57 +02:00
|
|
|
self:switchActiveBattler( )
|
2019-08-14 20:44:20 +02:00
|
|
|
elseif (action_type == "attack") then
|
2019-08-18 19:02:14 +02:00
|
|
|
--self:changeAnimation("hit1")
|
2019-08-22 22:04:14 +02:00
|
|
|
self:attack()
|
2019-08-19 11:54:06 +02:00
|
|
|
elseif (action_type == "skill") then
|
2019-08-25 10:38:06 +02:00
|
|
|
self.world.cursor:unset( )
|
|
|
|
self:useSkill(id, self.world.cursor.x, self.world.cursor.y)
|
2019-08-24 15:44:07 +02:00
|
|
|
elseif (action_type == "cursorMove") then
|
2019-08-31 17:39:22 +02:00
|
|
|
if (self.x ~= self.world.cursor.x) or (self.y ~= self.world.cursor.y) then
|
|
|
|
self:changeAnimation("walk", true)
|
|
|
|
self:goTo(self.world.cursor.x, self.world.cursor.y, 'cursorMove', 1)
|
|
|
|
self.assets.sfx["woosh"]:play()
|
|
|
|
else
|
|
|
|
self.world:resetActiveGrid()
|
|
|
|
self.scene.menu:set( self )
|
|
|
|
end
|
2019-08-24 15:44:07 +02:00
|
|
|
self.world.cursor:unset( )
|
2019-03-10 13:11:26 +01:00
|
|
|
else
|
2019-08-18 16:46:57 +02:00
|
|
|
self:switchActiveBattler( )
|
2019-03-10 13:11:26 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-07-18 09:51:02 +02:00
|
|
|
function Hero:positionSelected(x, y)
|
|
|
|
self:changeAnimation("walk", true)
|
|
|
|
self:goTo(self.world.cursor.x, self.world.cursor.y, 'cursorMove', 1)
|
|
|
|
self.assets.sfx["woosh"]:play()
|
|
|
|
end
|
|
|
|
|
2019-08-14 17:32:33 +02:00
|
|
|
function Hero:receiveBackSignal()
|
2019-08-24 15:44:07 +02:00
|
|
|
self.world.cursor:set(self.x, self.y, "cursorMove")
|
2019-08-31 17:39:22 +02:00
|
|
|
if (self.x ~= self.startx) or (self.y ~= self.starty) then
|
|
|
|
self.world.cursor:set(self.x, self.y, "cursorMove")
|
|
|
|
self.assets.sfx["woosh"]:play()
|
|
|
|
self:changeAnimation("walk")
|
|
|
|
end
|
2019-03-31 17:35:55 +02:00
|
|
|
end
|
|
|
|
|
2019-08-18 16:46:57 +02:00
|
|
|
function Hero:timerResponse(timer)
|
|
|
|
if timer == "switchActiveBattler" then
|
2020-05-01 17:04:17 +02:00
|
|
|
self.scene.turns:nextAction()
|
2019-08-18 19:02:14 +02:00
|
|
|
elseif timer == "wait" then
|
|
|
|
self.choregraphy.changeAction = true
|
2019-08-24 15:44:07 +02:00
|
|
|
elseif timer == "cursorMove" then
|
|
|
|
self:changeAnimation("idle")
|
|
|
|
self.world:resetActiveGrid()
|
|
|
|
self.scene.menu:set( self )
|
|
|
|
elseif timer == 'backMove' then
|
|
|
|
self:changeAnimation("idle")
|
|
|
|
self.direction = self.directionPrevious
|
2019-08-31 17:30:56 +02:00
|
|
|
elseif timer == 'action_jumpBack' then
|
|
|
|
self.unlockDirection = true
|
2020-05-02 13:01:43 +02:00
|
|
|
self:unblockChoregraphy()
|
|
|
|
elseif timer == self.choregraphy.blockedBy then
|
|
|
|
self:unblockChoregraphy()
|
2019-08-18 16:46:57 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-08-14 17:32:33 +02:00
|
|
|
-- ACTION FUNCTIONS
|
|
|
|
-- All functions related to actions
|
|
|
|
|
2019-08-18 16:46:57 +02:00
|
|
|
function Hero:switchActiveBattler()
|
2020-05-02 13:01:43 +02:00
|
|
|
print("Switching Active Battler")
|
2019-08-18 16:46:57 +02:00
|
|
|
self.tweens:newTimer(0.15, "switchActiveBattler")
|
|
|
|
end
|
|
|
|
|
2019-08-18 19:02:14 +02:00
|
|
|
-- CHOREGRAPHY FUNCTIONS
|
|
|
|
-- All functions related to the choregraphy system
|
|
|
|
|
|
|
|
function Hero:initChoregraphySystem()
|
2020-05-02 13:01:43 +02:00
|
|
|
self.choregraphy = ChoregraphySystem(self)
|
|
|
|
self.blockingChoregraphy = nil
|
2019-08-18 19:02:14 +02:00
|
|
|
end
|
|
|
|
|
2019-08-22 22:04:14 +02:00
|
|
|
function Hero:attack(id, dx, dy)
|
|
|
|
local skill = game.skills:getSkillData("attack")
|
2020-05-02 13:01:43 +02:00
|
|
|
self.choregraphy:start(skill, dx, dy)
|
2019-08-22 22:04:14 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function Hero:useSkill(id, dx, dy)
|
|
|
|
local skill = game.skills:getSkillData(id)
|
|
|
|
self:setPP(skill.cost * -1, true)
|
2020-05-02 13:01:43 +02:00
|
|
|
self.choregraphy:start(skill, dx, dy)
|
2019-08-18 19:02:14 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function Hero:updateChoregraphy(dt)
|
2020-05-02 13:01:43 +02:00
|
|
|
self.choregraphy:update(dt)
|
2019-08-25 15:54:26 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function Hero:blockChoregraphy(isBlocked, blockedBy)
|
|
|
|
if (isBlocked) then
|
2020-05-02 13:01:43 +02:00
|
|
|
self.blockingChoregraphy = blockedBy
|
2019-08-24 22:21:07 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-05-02 13:01:43 +02:00
|
|
|
function Hero:unblockChoregraphy()
|
|
|
|
self.choregraphy:endAction()
|
|
|
|
self.blockingChoregraphy = ""
|
2019-08-18 19:02:14 +02:00
|
|
|
end
|
|
|
|
|
2020-07-18 09:51:02 +02:00
|
|
|
-- INFO FUNCTIONS
|
|
|
|
-- Getting info about the actor
|
|
|
|
|
|
|
|
function Hero:getCharacterData()
|
|
|
|
return game.characters.list[self.charid]
|
|
|
|
end
|
|
|
|
|
2019-08-24 15:44:07 +02:00
|
|
|
-- ASSETS FUNCTIONS
|
|
|
|
-- Load and play assets needed by the character
|
2019-08-14 17:32:33 +02:00
|
|
|
|
2019-08-14 20:24:32 +02:00
|
|
|
function Hero:initSprite()
|
|
|
|
self.assets:addSprite(self.charid, "datas/gamedata/characters/" .. self.charid .. "/sprites")
|
|
|
|
self.assets.sprites[self.charid]:setCustomSpeed(16)
|
|
|
|
self:setSprite(self.charid, 32, 48, true)
|
|
|
|
self:cloneSprite()
|
|
|
|
self:changeAnimation("idle")
|
2019-08-14 17:32:33 +02:00
|
|
|
end
|
|
|
|
|
2019-08-14 20:44:20 +02:00
|
|
|
function Hero:animationEnded(animation)
|
2020-05-02 13:01:43 +02:00
|
|
|
if (animation == self.blockingChoregraphy) then
|
|
|
|
self:unblockChoregraphy()
|
2019-08-14 20:44:20 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-08-24 15:44:07 +02:00
|
|
|
function Hero:initVoices()
|
|
|
|
self:addVoiceEffect("move")
|
|
|
|
self:addVoiceEffect("turnstart")
|
|
|
|
end
|
2019-08-15 15:06:13 +02:00
|
|
|
|
2019-08-24 15:44:07 +02:00
|
|
|
function Hero:addVoiceEffect(name)
|
|
|
|
local completename = self.charid .. "_" .. name
|
|
|
|
local path = "datas/gamedata/characters/" .. self.charid .. "/voices/" .. name .. ".wav"
|
|
|
|
self.assets:newSFX(completename, path)
|
|
|
|
end
|
2019-08-15 15:06:13 +02:00
|
|
|
|
2019-08-24 15:44:07 +02:00
|
|
|
function Hero:talk(name)
|
|
|
|
local completename = self.charid .. "_" .. name
|
|
|
|
self.assets.sfx[completename]:play()
|
2019-08-15 15:06:13 +02:00
|
|
|
end
|
|
|
|
|
2019-08-14 20:24:32 +02:00
|
|
|
-- DRAW FUNCTIONS
|
|
|
|
-- Draw everything related to the hero
|
|
|
|
|
2019-08-14 17:32:33 +02:00
|
|
|
function Hero:draw()
|
2019-08-24 16:13:22 +02:00
|
|
|
self:drawSprite(0, -self.z)
|
2019-08-14 17:32:33 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function Hero:drawIcon(x, y)
|
|
|
|
local iconID = 1
|
|
|
|
self.assets.tileset["charicons"]:drawTile(iconID, x, y)
|
|
|
|
end
|
|
|
|
|
2019-08-14 16:26:23 +02:00
|
|
|
function Hero:drawHUD()
|
2020-05-01 17:04:17 +02:00
|
|
|
self.statusbar:draw()
|
2019-04-01 08:55:59 +02:00
|
|
|
end
|
|
|
|
|
2019-08-14 16:26:23 +02:00
|
|
|
return Hero
|