Skip to content
Snippets Groups Projects
Commit 1eefba39 authored by dg's avatar dg
Browse files

death screen, resurrection

git-svn-id: http://svn.net-core.org/repos/t-engine4@410 51575b47-30f0-44d4-a5cc-537603b46e54
parent 29f774c7
No related branches found
No related tags found
No related merge requests found
......@@ -55,7 +55,7 @@ function _M:init(t, no_default)
t.life_rating = t.life_rating or 10
t.mana_rating = t.mana_rating or 10
t.stamina_rating = t.stamina_rating or 10
t.stamina_rating = t.stamina_rating or 6
t.esp = t.esp or {range=10}
......@@ -329,7 +329,7 @@ function _M:onStatChange(stat, v)
self.max_life = self.max_life + 5 * v
elseif stat == self.STAT_WIL then
self:incMaxMana(5 * v)
self:incMaxStamina(2 * v)
self:incMaxStamina(3 * v)
end
end
......
......@@ -3,12 +3,12 @@ require "mod.class.Actor"
require "engine.interface.PlayerRest"
require "engine.interface.PlayerRun"
require "engine.interface.PlayerHotkeys"
local Savefile = require "engine.Savefile"
local Map = require "engine.Map"
local Dialog = require "engine.Dialog"
local ActorTalents = require "engine.interface.ActorTalents"
local LevelupStatsDialog = require "mod.dialogs.LevelupStatsDialog"
local LevelupTalentsDialog = require "mod.dialogs.LevelupTalentsDialog"
local DeathDialog = require "mod.dialogs.DeathDialog"
--- Defines the player for ToME
-- It is a normal actor, with some redefined methods to handle user interaction.<br/>
......@@ -107,10 +107,7 @@ function _M:onTakeHit(value, src)
end
function _M:die()
local save = Savefile.new(game.save_name)
save:delete()
save:close()
util.showMainMenu()
game:registerDialog(DeathDialog.new(self))
end
function _M:setName(name)
......
require "engine.class"
require "engine.Dialog"
local Savefile = require "engine.Savefile"
local Map = require "engine.Map"
module(..., package.seeall, class.inherit(engine.Dialog))
function _M:init(actor)
self.actor = actor
engine.Dialog.init(self, "Death!", 500, 300)
self:generateList()
self.sel = 1
self.scroll = 1
self.max = math.floor((self.ih - 45) / self.font_h) - 1
self:keyCommands(nil, {
MOVE_UP = function() self.sel = util.boundWrap(self.sel - 1, 1, #self.list) self.scroll = util.scroll(self.sel, self.scroll, self.max) self.changed = true end,
MOVE_DOWN = function() self.sel = util.boundWrap(self.sel + 1, 1, #self.list) self.scroll = util.scroll(self.sel, self.scroll, self.max) self.changed = true end,
ACCEPT = function() self:use() end,
})
self:mouseZones{
{ x=2, y=45, w=350, h=self.font_h*self.max, fct=function(button, x, y, xrel, yrel, tx, ty)
self.changed = true
self.sel = util.bound(self.scroll + math.floor(ty / self.font_h), 1, #self.list)
if button == "left" then self:learn(true)
elseif button == "right" then self:learn(false)
end
self.changed = true
end },
}
end
--- Clean the actor from debuffs/buffs
function _M:cleanActor()
local effs = {}
-- Go through all spell effects
for eff_id, p in pairs(self.actor.tmp) do
local e = self.actor.tempeffect_def[eff_id]
effs[#effs+1] = {"effect", eff_id}
end
-- Go through all sustained spells
for tid, act in pairs(self.actor.sustain_talents) do
if act then
effs[#effs+1] = {"talent", tid}
end
end
while #effs > 0 do
local eff = rng.tableRemove(effs)
if eff[1] == "effect" then
self.actor:removeEffect(eff[2])
else
local old = self.actor.energy.value
self.actor:useTalent(eff[2])
-- Prevent using energy
self.actor.energy.value = old
end
end
end
--- Restore ressources
function _M:restoreRessources()
self.actor.life = self.actor.max_life
self.actor.mana = self.actor.max_mana
self.actor.stamina = self.actor.max_stamina
self.actor.equilibrium = 0
self.actor.air = self.actor.max_air
self.actor.energy.value = game.energy_to_act
end
--- Basic resurection
function _M:resurrectBasic()
self.actor.dead = false
self.actor.died = (self.actor.died or 0) + 1
local x, y = util.findFreeGrid(self.actor.x, self.actor.y, 20, true, {[Map.ACTOR]=true})
if not x then x, y = self.actor.x, self.actor.y end
self.actor.x, self.actor.y = nil, nil
self.actor:move(x, y, true)
game.level:addEntity(self.actor)
game:unregisterDialog(self)
game.level.map:redisplay()
end
function _M:use()
if not self.list[self.sel] then return end
local act = self.list[self.sel].action
if act == "exit" then
local save = Savefile.new(game.save_name)
save:delete()
save:close()
util.showMainMenu()
elseif act == "dump" then
elseif act == "cheat" then
game.logPlayer(self.actor, "#LIGHT_BLUE#You resurrect! CHEATER !")
self:cleanActor()
self:restoreRessources()
self:resurrectBasic()
elseif act == "blood_life" then
game.logPlayer(self.actor, "#LIGHT_RED#The Blood of Life rushes through your dead body. You come back to life!")
self:cleanActor()
self:restoreRessources()
self:resurrectBasic()
end
end
function _M:generateList()
local list = {}
if self.actor.cheat or true then list[#list+1] = {name="Resurrect by cheating", action="cheat"} end
if self.actor:attr("blood_life") and not self.actor:attr("undead") then list[#list+1] = {name="Resurrect with the Blood of Life", action="blood_life"} end
list[#list+1] = {name="Character dump", action="dump"}
list[#list+1] = {name="Exit to main menu", action="exit"}
self.list = list
end
function _M:drawDialog(s)
local help = ([[
You have died!
Death in T.o.M.E is usually permanent. If you have a mean of resurrection it will be proposed in the menu below.
You can dump your character data to a file, to remember her/him forever or you can exit and try again to survive in the wilds!
]]):splitLines(self.iw - 10, self.font)
local h = 2
local r, g, b
for i = 1, #help do
r, g, b = s:drawColorString(self.font, help[i], 5, h, r, g, b)
h = h + self.font:lineSkip()
end
h = h + self.font:lineSkip()
self:drawWBorder(s, 2, h - 0.5 * self.font:lineSkip(), self.iw - 4)
self:drawSelectionList(s, 2, h, self.font_h, self.list, self.sel, "name")
self.changed = false
end
......@@ -100,10 +100,8 @@ function _M:learn(v)
end
function _M:checkDeps()
print("Check deps!")
for t_id, _ in pairs(self.talents_changed) do
local t = self.actor:getTalentFromId(t_id)
print("Check deps!", t.name, self.actor:canLearnTalent(t, 0), self.actor:knowTalent(t))
if not self.actor:canLearnTalent(t, 0) and self.actor:knowTalent(t) then return false, t.name end
end
return true
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment