sonic-radiance/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/actions/flee.lua

35 lines
1,002 B
Lua
Raw Normal View History

local ActionParent = require "scenes.battlesystem.controllers.fighters.systems.actions.parent"
local FleeAction = ActionParent:extend()
local STATS = require "datas.consts.stats"
function FleeAction:new(fighter)
FleeAction.super.new(self, fighter)
end
function FleeAction:needTarget()
return false, false
end
function FleeAction:startAction()
core.debug:print("cbs/action", "Starting flee action")
2021-07-03 09:51:19 +02:00
local stats = self.fighter.abstract.stats
2021-03-13 18:00:39 +01:00
if (self.fighter.abstract.name == "shadow") then
self.fighter.turns.hud:showMessage("You won't flee the battle")
self:finishAction()
return
end
local chanceToFlee = self.fighter.turnSystem:getChanceTooFlee(self.fighter:getStat(STATS.SPEED))
2021-03-13 18:00:39 +01:00
if (math.random(100) < chanceToFlee) then
self.fighter.turnSystem.hud:showMessage("You flee the battle")
self.fighter.turnSystem:fleeBattle()
else
self.fighter.turnSystem.hud:showMessage("You failed to flee the battle")
self:finishAction()
end
end
return FleeAction