diff --git a/game/data/keybinds/actions.lua b/game/data/keybinds/actions.lua index 074418f1b2c10b875ba93a52d22ef0e91fbc98ff..5821a992fa58aa8d87fa43567de33d21f9d65a54 100644 --- a/game/data/keybinds/actions.lua +++ b/game/data/keybinds/actions.lua @@ -60,6 +60,13 @@ defineAction{ name = "Show game calendar", } +defineAction{ + default = { "uni:C" }, + type = "SHOW_CHARACTER_SHEET", + group = "actions", + name = "Show character sheet", +} + defineAction{ default = { "sym:115:false:false:true:false" }, type = "SWITCH_GFX", diff --git a/game/modules/tome/class/Game.lua b/game/modules/tome/class/Game.lua index 078093616f489e88885ccb2ef570e243a4ecc205..fee56a8913518f9213574c9e78df0436da6eec7e 100644 --- a/game/modules/tome/class/Game.lua +++ b/game/modules/tome/class/Game.lua @@ -488,6 +488,10 @@ function _M:setupCommands() self:registerDialog(require("engine.dialogs.ShowQuests").new(self.player)) end, + SHOW_CHARACTER_SHEET = function() + self:registerDialog(require("mod.dialogs.CharacterSheet").new(self.player)) + end, + -- Show time SHOW_TIME = function() self.log(self.calendar:getTimeDate(self.turn)) diff --git a/game/modules/tome/class/PlayerDisplay.lua b/game/modules/tome/class/PlayerDisplay.lua index e056b03150adea83473e111198b9e1b0c58a3762..315c4edd970397e7961e59a4f1f7285de02fa7c9 100644 --- a/game/modules/tome/class/PlayerDisplay.lua +++ b/game/modules/tome/class/PlayerDisplay.lua @@ -31,7 +31,7 @@ function _M:display() self.surface:drawString(self.font, game.player.descriptor.subrace or "", 0, h, 0, 200, 255) h = h + self.font_h h = h + self.font_h self.surface:drawColorString(self.font, "Level: #00ff00#"..game.player.level, 0, h, 255, 255, 255) h = h + self.font_h - self.surface:drawColorString(self.font, ("Exp: #00ff00#%2d%%"):format(100 * cur_exp / max_exp), 0, h, 255, 255, 255) h = h + self.font_h + self.surface:drawColorString(self.font, ("Exp: #00ff00#%2d%%"):format(100 * cur_exp / max_exp), 0, h, 255, 255, 255) h = h + self.font_h self.surface:drawColorString(self.font, ("Gold: #00ff00#%0.2f"):format(game.player.money), 0, h, 255, 255, 255) h = h + self.font_h h = h + self.font_h @@ -64,7 +64,7 @@ function _M:display() self.surface:drawColorString(self.font, ("CON: #00ff00#%3d"):format(game.player:getCon()), 0, h, 255, 255, 255) h = h + self.font_h h = h + self.font_h self.surface:drawString(self.font, ("Fatigue %3d%%"):format(game.player.fatigue), 0, h, 255, 255, 255) h = h + self.font_h - self.surface:drawString(self.font, ("Armor %3d"):format(game.player:combatArmor()), 0, h, 255, 255, 255) h = h + self.font_h + self.surface:drawString(self.font, ("Armor %3d"):format(game.player:combatArmor()), 0, h, 255, 255, 255) h = h + self.font_h self.surface:drawString(self.font, ("Defence %3d"):format(game.player:combatDefense()), 0, h, 255, 255, 255) h = h + self.font_h if game.zone and game.level then diff --git a/game/modules/tome/dialogs/CharacterSheet.lua b/game/modules/tome/dialogs/CharacterSheet.lua new file mode 100644 index 0000000000000000000000000000000000000000..278f7a7da37c9278a466e2737879bbb80af53265 --- /dev/null +++ b/game/modules/tome/dialogs/CharacterSheet.lua @@ -0,0 +1,113 @@ +require "engine.class" +require "engine.Dialog" +local DamageType = require "engine.DamageType" +local Talents = require "engine.interface.ActorTalents" + +module(..., package.seeall, class.inherit(engine.Dialog)) + +function _M:init(actor) + self.actor = actor + engine.Dialog.init(self, "Character Sheet: "..self.actor.name, 800, 400, nil, nil, nil, core.display.newFont("/data/font/VeraMono.ttf", 12)) + + self:keyCommands(nil, { + ACCEPT = "EXIT", + EXIT = function() + game:unregisterDialog(self) + end, + }) +end + +function _M:drawDialog(s) + local cur_exp, max_exp = game.player.exp, game.player:getExpChart(game.player.level+1) + + local h = 0 + local w = 0 + s:drawString(self.font, "Sex: "..game.player.descriptor.sex, w, h, 0, 200, 255) h = h + self.font_h + s:drawString(self.font, "Race: "..game.player.descriptor.subrace, w, h, 0, 200, 255) h = h + self.font_h + s:drawString(self.font, "Class: "..game.player.descriptor.subclass, w, h, 0, 200, 255) h = h + self.font_h + h = h + self.font_h + s:drawColorString(self.font, "Level: #00ff00#"..game.player.level, w, h, 255, 255, 255) h = h + self.font_h + s:drawColorString(self.font, ("Exp: #00ff00#%2d%%"):format(100 * cur_exp / max_exp), w, h, 255, 255, 255) h = h + self.font_h + s:drawColorString(self.font, ("Gold: #00ff00#%0.2f"):format(game.player.money), w, h, 255, 255, 255) h = h + self.font_h + + h = h + self.font_h + + s:drawColorString(self.font, ("#c00000#Life: #00ff00#%d/%d"):format(game.player.life, game.player.max_life), w, h, 255, 255, 255) h = h + self.font_h + if game.player:knowTalent(game.player.T_STAMINA_POOL) then + s:drawColorString(self.font, ("#ffcc80#Stamina: #00ff00#%d/%d"):format(game.player:getStamina(), game.player.max_stamina), w, h, 255, 255, 255) h = h + self.font_h + end + if game.player:knowTalent(game.player.T_MANA_POOL) then + s:drawColorString(self.font, ("#7fffd4#Mana: #00ff00#%d/%d"):format(game.player:getMana(), game.player.max_mana), w, h, 255, 255, 255) h = h + self.font_h + end + if game.player:knowTalent(game.player.T_SOUL_POOL) then + s:drawColorString(self.font, ("#777777#Soul: #00ff00#%d/%d"):format(game.player:getSoul(), game.player.max_soul), w, h, 255, 255, 255) h = h + self.font_h + end + if game.player:knowTalent(game.player.T_EQUILIBRIUM_POOL) then + s:drawColorString(self.font, ("#00ff74#Equi: #00ff00#%d"):format(game.player:getEquilibrium()), w, h, 255, 255, 255) h = h + self.font_h + end + + h = h + self.font_h + s:drawColorString(self.font, ("STR: #00ff00#%3d"):format(game.player:getStr()), w, h, 255, 255, 255) h = h + self.font_h + s:drawColorString(self.font, ("DEX: #00ff00#%3d"):format(game.player:getDex()), w, h, 255, 255, 255) h = h + self.font_h + s:drawColorString(self.font, ("MAG: #00ff00#%3d"):format(game.player:getMag()), w, h, 255, 255, 255) h = h + self.font_h + s:drawColorString(self.font, ("WIL: #00ff00#%3d"):format(game.player:getWil()), w, h, 255, 255, 255) h = h + self.font_h + s:drawColorString(self.font, ("CUN: #00ff00#%3d"):format(game.player:getCun()), w, h, 255, 255, 255) h = h + self.font_h + s:drawColorString(self.font, ("CON: #00ff00#%3d"):format(game.player:getCon()), w, h, 255, 255, 255) h = h + self.font_h + + h = 0 + w = 200 + -- All weapons in main hands + if self.actor:getInven(self.actor.INVEN_MAINHAND) then + for i, o in ipairs(self.actor:getInven(self.actor.INVEN_MAINHAND)) do + if o.combat then + s:drawColorString(self.font, ("Attack(Main Hand): #00ff00#%3d"):format(game.player:combatAttack(o.combat)), w, h, 255, 255, 255) h = h + self.font_h + s:drawColorString(self.font, ("Damage(Main Hand): #00ff00#%3d"):format(game.player:combatDamage(o.combat)), w, h, 255, 255, 255) h = h + self.font_h + s:drawColorString(self.font, ("APR (Main Hand): #00ff00#%3d"):format(game.player:combatAPR(o.combat)), w, h, 255, 255, 255) h = h + self.font_h + s:drawColorString(self.font, ("Crit (Main Hand): #00ff00#%3d%%"):format(game.player:combatCrit(o.combat)), w, h, 255, 255, 255) h = h + self.font_h + s:drawColorString(self.font, ("Speed (Main Hand): #00ff00#%0.2f"):format(game.player:combatSpeed(o.combat)), w, h, 255, 255, 255) h = h + self.font_h + end + end + end + h = h + self.font_h + -- All wpeaons in off hands + -- Offhand atatcks are with a damage penality, taht can be reduced by talents + if self.actor:getInven(self.actor.INVEN_OFFHAND) then + local offmult = (mult or 1) / 2 + if self.actor:knowTalent(Talents.T_DUAL_WEAPON_TRAINING) then + offmult = (mult or 1) / (2 - (self.actor:getTalentLevel(Talents.T_DUAL_WEAPON_TRAINING) / 6)) + end + for i, o in ipairs(self.actor:getInven(self.actor.INVEN_OFFHAND)) do + if o.combat then + s:drawColorString(self.font, ("Attack(Off Hand): #00ff00#%3d"):format(game.player:combatAttack(o.combat)), w, h, 255, 255, 255) h = h + self.font_h + s:drawColorString(self.font, ("Damage(Off Hand): #00ff00#%3d"):format(game.player:combatDamage(o.combat) * offmult), w, h, 255, 255, 255) h = h + self.font_h + s:drawColorString(self.font, ("APR (Off Hand): #00ff00#%3d"):format(game.player:combatAPR(o.combat)), w, h, 255, 255, 255) h = h + self.font_h + s:drawColorString(self.font, ("Crit (Off Hand): #00ff00#%3d%%"):format(game.player:combatCrit(o.combat)), w, h, 255, 255, 255) h = h + self.font_h + s:drawColorString(self.font, ("Speed (Off Hand): #00ff00#%0.2f"):format(game.player:combatSpeed(o.combat)), w, h, 255, 255, 255) h = h + self.font_h + end + end + end + h = h + self.font_h + s:drawColorString(self.font, ("Spellpower: #00ff00#%3d"):format(game.player:combatSpellpower()), w, h, 255, 255, 255) h = h + self.font_h + s:drawColorString(self.font, ("Spell Crit: #00ff00#%3d"):format(game.player:combatSpellCrit()), w, h, 255, 255, 255) h = h + self.font_h + s:drawColorString(self.font, ("Spell Speed: #00ff00#%3d"):format(game.player:combatSpellSpeed()), w, h, 255, 255, 255) h = h + self.font_h + + h = 0 + w = 400 + s:drawColorString(self.font, ("Fatigue: #00ff00#%3d%%"):format(game.player.fatigue), w, h, 255, 255, 255) h = h + self.font_h + s:drawColorString(self.font, ("Armor: #00ff00#%3d"):format(game.player:combatArmor()), w, h, 255, 255, 255) h = h + self.font_h + s:drawColorString(self.font, ("Defence: #00ff00#%3d"):format(game.player:combatDefense()), w, h, 255, 255, 255) h = h + self.font_h + + h = h + self.font_h + s:drawColorString(self.font, ("Physical Resist: #00ff00#%3d"):format(game.player:combatPhysicalResist()), w, h, 255, 255, 255) h = h + self.font_h + s:drawColorString(self.font, ("Spell Resist: #00ff00#%3d"):format(game.player:combatSpellResist()), w, h, 255, 255, 255) h = h + self.font_h + s:drawColorString(self.font, ("Mental Resist: #00ff00#%3d"):format(game.player:combatMentalResist()), w, h, 255, 255, 255) h = h + self.font_h + + h = h + self.font_h + for i, t in ipairs(DamageType.dam_def) do + if self.actor.resists[DamageType[t.type]] then + s:drawColorString(self.font, ("%s Resist: #00ff00#%3d%%"):format(t.name:capitalize(), self.actor.resists[DamageType[t.type]]), w, h, 255, 255, 255) h = h + self.font_h + end + end + + self.changed = false +end