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"
|
|
|
|
|
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
|
|
|
|
self.turnAction = nil
|
|
|
|
self.startx, self.starty = self.x, self.y
|
|
|
|
self.dx, self.dy = self.x, self.y
|
|
|
|
self.direction = 1
|
|
|
|
self.directionPrevious = 1
|
|
|
|
|
|
|
|
if charid == nil then
|
2019-08-13 22:28:05 +02:00
|
|
|
core.debug:error("FATAL ERROR: charid not set")
|
2019-03-10 13:11:26 +01:00
|
|
|
end
|
2019-08-14 20:24:32 +02:00
|
|
|
self.charid = charid
|
|
|
|
self.charnumber = charnumber or 1
|
|
|
|
|
2019-08-22 22:04:14 +02:00
|
|
|
self.hp = game.characters.list[self.charid].stats.hp
|
|
|
|
self.pp = game.characters.list[self.charid].stats.pp
|
|
|
|
|
|
|
|
|
2019-08-12 12:37:00 +02:00
|
|
|
self.actionPerTurn = game.characters.list[self.charid].turns
|
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()
|
|
|
|
end
|
|
|
|
|
|
|
|
-- ASSETS FUNCTIONS
|
|
|
|
-- Load and play assets needed by the character
|
|
|
|
|
|
|
|
function Hero:initVoices()
|
|
|
|
self:addVoiceEffect("move")
|
|
|
|
self:addVoiceEffect("turnstart")
|
|
|
|
end
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
function Hero:talk(name)
|
|
|
|
local completename = self.charid .. "_" .. name
|
|
|
|
self.assets.sfx[completename]:play()
|
2019-03-10 13:11:26 +01:00
|
|
|
end
|
|
|
|
|
2019-08-14 17:32:33 +02:00
|
|
|
-- INFO FUNCTIONS
|
|
|
|
-- All functions to get information from the character
|
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
|
|
|
-- STATS FUNCTIONS
|
|
|
|
-- All functions related to stats
|
|
|
|
|
|
|
|
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
|
|
|
|
self.tweens:newTween(0, 0.3, {hp = game.characters.list[self.charid].stats.hp}, 'linear')
|
|
|
|
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
|
|
|
|
self.tweens:newTween(0, 0.3, {pp = game.characters.list[self.charid].stats.pp}, 'linear')
|
|
|
|
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-03-10 13:11:26 +01:00
|
|
|
self.startx, self.starty = self.x, self.y
|
2019-08-14 16:26:23 +02:00
|
|
|
self.world.cursor:set(self.startx, self.starty)
|
2019-03-10 13:11:26 +01:00
|
|
|
self.currentAction = "selectDirection"
|
|
|
|
|
2019-08-19 15:34:52 +02:00
|
|
|
self:talk("turnstart")
|
|
|
|
|
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-14 20:24:32 +02:00
|
|
|
|
2019-08-14 16:26:23 +02:00
|
|
|
self.keys = self.scene:getKeys(1)
|
2019-08-18 19:02:14 +02:00
|
|
|
|
|
|
|
if (self.isChoregraphyActive) then
|
|
|
|
self:updateChoregraphy()
|
|
|
|
end
|
|
|
|
|
2019-03-10 13:11:26 +01:00
|
|
|
if (self.currentAction == "moving") then
|
2019-08-14 17:32:33 +02:00
|
|
|
self:updateMoving(dt)
|
2019-03-10 13:11:26 +01:00
|
|
|
elseif (self.currentAction == "selectAttack") then
|
2019-08-14 17:32:33 +02:00
|
|
|
self:updateActionSelection(dt)
|
2019-03-10 13:11:26 +01:00
|
|
|
elseif (self.currentAction == "selectDirection") then
|
2019-08-14 17:32:33 +02:00
|
|
|
self:updateDirectionSelection(dt)
|
2019-03-10 13:11:26 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-08-14 17:32:33 +02:00
|
|
|
function Hero:updateMoving(dt)
|
|
|
|
-- Store previous position, in order to be able to go back here more easily
|
|
|
|
-- when needed
|
|
|
|
self.xprevious = self.x
|
|
|
|
self.yprevious = self.y
|
2019-03-10 13:11:26 +01:00
|
|
|
|
2019-08-14 17:32:33 +02:00
|
|
|
-- Move the player toward its destination
|
2019-08-15 08:57:47 +02:00
|
|
|
self.x = (self.x) + ((self.dx) - (self.x)) * dt*10
|
|
|
|
self.y = (self.y) + ((self.dy) - (self.y)) * dt*10
|
2019-08-14 17:32:33 +02:00
|
|
|
|
|
|
|
-- Calculate speed to calculate animation speed
|
|
|
|
local xspeed, yspeed = math.abs(self.x - self.xprevious),
|
|
|
|
math.abs(self.y - self.yprevious)
|
|
|
|
|
|
|
|
local speed = math.sqrt(xspeed*xspeed + yspeed*yspeed) * 32
|
2019-08-15 08:57:47 +02:00
|
|
|
self:setCustomSpeed(speed * 10)
|
2019-08-14 17:32:33 +02:00
|
|
|
|
|
|
|
-- Handle direction
|
|
|
|
local direction = utils.math.sign(self.x - self.xprevious)
|
|
|
|
if direction ~= 0 then
|
|
|
|
self.direction = direction
|
|
|
|
end
|
|
|
|
|
|
|
|
-- If the hero is near enough its final destination, switch to
|
|
|
|
-- action selection
|
|
|
|
if (math.abs(self.x - self.dx) < 0.01) and (math.abs(self.y - self.dy) < 0.01) then
|
|
|
|
self.x = self.dx
|
|
|
|
self.y = self.dy
|
2019-08-14 20:24:32 +02:00
|
|
|
self:changeAnimation("idle")
|
2019-08-14 17:32:33 +02:00
|
|
|
self.currentAction = "selectAttack"
|
2019-08-22 22:40:31 +02:00
|
|
|
self.world:resetActiveGrid()
|
2019-08-14 17:32:33 +02:00
|
|
|
self.scene.menu:set( self )
|
2019-03-10 13:11:26 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-08-14 17:32:33 +02:00
|
|
|
function Hero:updateActionSelection(dt)
|
|
|
|
-- 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-14 17:32:33 +02:00
|
|
|
function Hero:updateDirectionSelection(dt)
|
|
|
|
self.xprevious = self.x
|
|
|
|
self.yprevious = self.y
|
|
|
|
|
2019-08-15 08:57:47 +02:00
|
|
|
self.x = (self.x) + ((self.startx) - (self.x)) * dt*10
|
|
|
|
self.y = (self.y) + ((self.starty) - (self.y)) * dt*10
|
2019-08-14 17:32:33 +02:00
|
|
|
|
|
|
|
local xspeed, yspeed = math.abs(self.x - self.xprevious),
|
|
|
|
math.abs(self.y - self.yprevious)
|
|
|
|
|
|
|
|
local speed = math.sqrt(xspeed*xspeed + yspeed*yspeed) * 32
|
2019-08-15 08:57:47 +02:00
|
|
|
self:setCustomSpeed(speed * 10)
|
2019-08-14 17:32:33 +02:00
|
|
|
local direction = utils.math.sign(self.x - self.xprevious)
|
|
|
|
if direction ~= 0 then
|
|
|
|
self.direction = direction
|
|
|
|
end
|
|
|
|
|
|
|
|
if (math.abs(self.x - self.startx) < 0.01) and (math.abs(self.y - self.starty) < 0.01) then
|
|
|
|
self.x = self.startx
|
|
|
|
self.y = self.starty
|
2019-08-14 20:24:32 +02:00
|
|
|
self:changeAnimation("idle")
|
2019-08-14 17:32:33 +02:00
|
|
|
self.direction = self.directionPrevious
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- 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-22 22:04:14 +02:00
|
|
|
self:useSkill(id)
|
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
|
|
|
|
|
2019-08-14 17:32:33 +02:00
|
|
|
function Hero:receiveBackSignal()
|
2019-03-31 17:35:55 +02:00
|
|
|
self.currentAction = "selectDirection"
|
2019-08-14 16:26:23 +02:00
|
|
|
self.world.cursor:set(self.x, self.y)
|
2019-08-22 22:40:31 +02:00
|
|
|
|
2019-08-14 20:24:32 +02:00
|
|
|
self:changeAnimation("walk")
|
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
|
|
|
|
self.world:switchActiveBattler()
|
2019-08-18 19:02:14 +02:00
|
|
|
elseif timer == "wait" then
|
|
|
|
self.choregraphy.changeAction = true
|
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
|
|
|
|
|
|
|
|
function Hero:validateAction()
|
|
|
|
if (self.currentAction == "selectDirection") then
|
2019-08-14 20:24:32 +02:00
|
|
|
self:changeAnimation("walk", true)
|
2019-08-14 17:32:33 +02:00
|
|
|
self.currentAction = "moving"
|
|
|
|
self.dx, self.dy = self.world.cursor.x, self.world.cursor.y
|
|
|
|
|
2019-08-19 20:41:47 +02:00
|
|
|
--self:talk("move")
|
2019-08-19 15:34:52 +02:00
|
|
|
|
2019-08-14 17:32:33 +02:00
|
|
|
self.world.cursor:unset( )
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-08-18 16:46:57 +02:00
|
|
|
function Hero:switchActiveBattler()
|
|
|
|
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()
|
|
|
|
self.choregraphy = {}
|
|
|
|
self.choregraphy.current = 0
|
|
|
|
self.choregraphy.isFinished = false
|
|
|
|
self.choregraphy.changeAction = true
|
|
|
|
self.choregraphy.data = {}
|
|
|
|
self.choregraphy.effectArea = nil
|
|
|
|
self.choregraphy.dx = self.x
|
|
|
|
self.choregraphy.dy = self.y
|
|
|
|
self.choregraphy.blockedBy = ""
|
|
|
|
|
|
|
|
self.isChoregraphyActive = false
|
|
|
|
end
|
|
|
|
|
2019-08-22 22:04:14 +02:00
|
|
|
function Hero:attack(id, dx, dy)
|
|
|
|
local skill = game.skills:getSkillData("attack")
|
|
|
|
self:startChoregraphy(skill, dx, dy)
|
|
|
|
end
|
|
|
|
|
|
|
|
function Hero:useSkill(id, dx, dy)
|
|
|
|
local skill = game.skills:getSkillData(id)
|
|
|
|
self:setPP(skill.cost * -1, true)
|
|
|
|
self:startChoregraphy(skill, dx, dy)
|
|
|
|
end
|
|
|
|
|
2019-08-18 19:02:14 +02:00
|
|
|
function Hero:startChoregraphy(skill, dx, dy)
|
2019-08-22 22:04:14 +02:00
|
|
|
local skill = skill
|
2019-08-18 19:02:14 +02:00
|
|
|
self.choregraphy.current = 0
|
|
|
|
self.choregraphy.isFinished = false
|
|
|
|
self.choregraphy.changeAction = true
|
|
|
|
self.choregraphy.data = skill.choregraphy
|
|
|
|
self.choregraphy.effectArea = skill.effectArea
|
|
|
|
self.choregraphy.dx = dx or self.x
|
|
|
|
self.choregraphy.dy = dy or self.y
|
|
|
|
|
2019-08-19 11:54:06 +02:00
|
|
|
self.choregraphy.haveSentDamage = false
|
|
|
|
|
2019-08-18 19:02:14 +02:00
|
|
|
self.isChoregraphyActive = true
|
|
|
|
end
|
|
|
|
|
|
|
|
function Hero:updateChoregraphy(dt)
|
|
|
|
if (self.choregraphy.changeAction) then
|
|
|
|
self:switchAction()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function Hero:switchAction()
|
|
|
|
self.choregraphy.current = self.choregraphy.current + 1
|
|
|
|
local nextAction = self.choregraphy.data[self.choregraphy.current]
|
|
|
|
if nextAction == nil then
|
|
|
|
self.isChoregraphyActive = false
|
|
|
|
self:switchActiveBattler()
|
|
|
|
else
|
2019-08-19 11:54:06 +02:00
|
|
|
local condition = nextAction[2]
|
|
|
|
if (condition == "sentDamage") and (not self.choregraphy.haveSentDamage) then
|
|
|
|
core.debug:print("cbs/hero", "you didn't do damage, skipping " .. nextAction[1])
|
|
|
|
self:switchAction()
|
|
|
|
else
|
|
|
|
self:doChoregraphyAction(nextAction)
|
|
|
|
end
|
|
|
|
|
2019-08-18 19:02:14 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function Hero:doChoregraphyAction(choregraphyAction)
|
|
|
|
local type = choregraphyAction[1] or "unknown"
|
|
|
|
self.choregraphy.changeAction = true
|
|
|
|
|
|
|
|
if type == "wait" then
|
2019-08-19 11:54:06 +02:00
|
|
|
local duration = choregraphyAction[3] or 1
|
2019-08-18 19:02:14 +02:00
|
|
|
self:wait(duration)
|
|
|
|
elseif type == "setAnimation" then
|
2019-08-19 11:54:06 +02:00
|
|
|
local animation = choregraphyAction[3]
|
|
|
|
local blockProcess = choregraphyAction[4]
|
2019-08-18 19:02:14 +02:00
|
|
|
self:changeAnimation(animation)
|
|
|
|
if (blockProcess) then
|
|
|
|
self.choregraphy.blockedBy = animation
|
|
|
|
self.choregraphy.changeAction = false
|
|
|
|
end
|
|
|
|
elseif type == "sendDamage" then
|
|
|
|
local xx = self.x + self.direction
|
|
|
|
local yy = self.y
|
2019-08-19 11:54:06 +02:00
|
|
|
local power = choregraphyAction[3]
|
|
|
|
local accuracy = choregraphyAction[4]
|
|
|
|
local isSpecial = choregraphyAction[5]
|
|
|
|
local isAerial = choregraphyAction[6]
|
|
|
|
self.choregraphy.haveSentDamage = self:sendDamage(xx, yy, power, accuracy, isSpecial, isAerial)
|
2019-08-18 19:02:14 +02:00
|
|
|
elseif type == "addGFX" then
|
2019-08-19 11:54:06 +02:00
|
|
|
local sprite = choregraphyAction[3]
|
|
|
|
local dx = choregraphyAction[4]
|
|
|
|
local dy = choregraphyAction[5]
|
|
|
|
local affectedByDirection = choregraphyAction[6]
|
2019-08-18 19:02:14 +02:00
|
|
|
if (affectedByDirection) then
|
|
|
|
dx = dx * self.direction
|
|
|
|
end
|
2019-08-19 11:54:06 +02:00
|
|
|
local blockProcess = choregraphyAction[7]
|
2019-08-18 19:02:14 +02:00
|
|
|
|
|
|
|
local x = self.x
|
|
|
|
local y = self.y
|
|
|
|
local z = 0
|
|
|
|
|
|
|
|
self.world.obj.GFX(self.world, x + dx, y + dy, z, sprite, self, blockProcess)
|
2019-08-19 16:46:30 +02:00
|
|
|
elseif type == "playSFX" then
|
|
|
|
local sfx = choregraphyAction[3]
|
|
|
|
self.assets.sfx[sfx]:play()
|
2019-08-18 19:02:14 +02:00
|
|
|
else
|
|
|
|
core.debug:warning("cbs/hero", "unknown action type " .. type)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function Hero:wait(time)
|
|
|
|
self.tweens:newTimer(time, "wait")
|
|
|
|
self.choregraphy.changeAction = false
|
|
|
|
end
|
|
|
|
|
2019-08-14 20:24:32 +02:00
|
|
|
-- SPRITE FUNCTIONS
|
|
|
|
-- Handle the hero sprite
|
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)
|
2019-08-18 19:02:14 +02:00
|
|
|
if (animation == self.choregraphy.blockedBy) then
|
|
|
|
self.choregraphy.blockedBy = ""
|
|
|
|
self.choregraphy.changeAction = true
|
2019-08-14 20:44:20 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-08-15 15:06:13 +02:00
|
|
|
-- STATS FUNCTIONS
|
|
|
|
-- Handle character stats and stuff
|
|
|
|
|
|
|
|
function Hero:setHP(value, relative)
|
|
|
|
if (relative) then
|
|
|
|
local hp = game.characters.list[self.charid].stats.hp
|
|
|
|
value = hp + value
|
|
|
|
end
|
|
|
|
|
|
|
|
game.characters.list[self.charid].stats.hp = value
|
|
|
|
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()
|
|
|
|
x, y = self.maputils.gridToPixel(self.x, self.y, true)
|
|
|
|
--love.graphics.rectangle("fill", x - 8, y - 32, 16, 32)
|
|
|
|
self:drawSprite()
|
|
|
|
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()
|
2019-08-14 22:47:10 +02:00
|
|
|
local HUDBASE = 8
|
2019-08-14 13:56:25 +02:00
|
|
|
local HUDSEP = 152
|
|
|
|
local x = HUDBASE + (self.charnumber-1)*HUDSEP
|
2019-08-16 18:40:00 +02:00
|
|
|
local y = self.world:getPlayerHUDPosition()
|
2019-08-14 22:47:10 +02:00
|
|
|
|
|
|
|
self.assets.images["e_speedster"]:draw(x, y)
|
2019-08-15 15:09:48 +02:00
|
|
|
core.screen:setScissor(x, y-16, 32, 40)
|
2019-08-14 22:47:10 +02:00
|
|
|
self.assets.sprites[self.charid]:drawAnimation(x+14, y+14)
|
2019-08-15 15:09:48 +02:00
|
|
|
core.screen:resetScissor( )
|
2019-08-14 22:47:10 +02:00
|
|
|
self.assets.images["m_speedster"]:draw(x, y)
|
|
|
|
self.assets.images["statusbar"]:draw(x+12, y-6)
|
|
|
|
|
|
|
|
local hpmax = game.characters.list[self.charid].stats.hpmax
|
|
|
|
local ppmax = game.characters.list[self.charid].stats.ppmax
|
|
|
|
|
2019-08-22 22:04:14 +02:00
|
|
|
local bar1 = math.floor((self.hp/hpmax)*107)
|
|
|
|
local bar2 = math.floor((self.pp/ppmax)*108)
|
2019-08-14 22:47:10 +02:00
|
|
|
|
|
|
|
love.graphics.setColor(248/255, 160/255, 0, 1)
|
|
|
|
gui.drawBar(x+29, y+5, bar1, 7)
|
|
|
|
love.graphics.setColor(0, 248/255, 248/255, 1)
|
|
|
|
gui.drawBar(x+17, y+17, bar2, 7)
|
|
|
|
utils.graphics.resetColor()
|
|
|
|
|
|
|
|
self.assets.fonts["hudnbrs_small"]:set()
|
2019-08-22 22:04:14 +02:00
|
|
|
love.graphics.print(math.floor(self.hp) .. "/" .. hpmax, x+34, y+5)
|
|
|
|
love.graphics.print(math.floor(self.pp) .. "/" .. ppmax, x+28, y+17)
|
2019-08-14 22:47:10 +02:00
|
|
|
|
|
|
|
local lvl = game.characters.list[self.charid].stats.level
|
|
|
|
|
|
|
|
if lvl < 100 then
|
|
|
|
lvl = "0" .. lvl
|
|
|
|
end
|
2019-08-14 13:56:25 +02:00
|
|
|
|
2019-08-14 22:47:10 +02:00
|
|
|
love.graphics.print(lvl, x+122, y-5)
|
2019-04-01 08:55:59 +02:00
|
|
|
end
|
|
|
|
|
2019-08-14 16:26:23 +02:00
|
|
|
return Hero
|