Skip to content
Snippets Groups Projects
Commit fa767f02 authored by DarkGod's avatar DarkGod
Browse files

New achievements for Normal (Roguelike), Nightmare/Insane/Madness (Adventure)

Achievements list onyl shows the ones for the current difficulty to reduce clutter
parent 8ee5c99c
No related branches found
No related tags found
No related merge requests found
......@@ -1656,7 +1656,7 @@ do return end
local menu
local l = {
"resume",
"achievements",
{ "Show Achievements", function() self:unregisterDialog(menu) self:registerDialog(require("mod.dialogs.ShowAchievements").new("Tales of Maj'Eyal Achievements", self.player)) end },
{ "Show known Lore", function() self:unregisterDialog(menu) self:registerDialog(require("mod.dialogs.ShowLore").new("Tales of Maj'Eyal Lore", self.party)) end },
{ "Show ingredients", function() self:unregisterDialog(menu) self:registerDialog(require("mod.dialogs.ShowIngredients").new(self.party)) end },
"highscores",
......
......@@ -55,8 +55,12 @@ function _M:gainAchievement(id, src, ...)
if game.difficulty == game.DIFFICULTY_EASY and not a.tutorial then return end
if game.permadeath == game.PERMADEATH_INFINITE then id = "EXPLORATION_"..id end
if game.difficulty == game.DIFFICULTY_NORMAL and game.permadeath == game.PERMADEATH_ONE then id = "NORMAL_ROGUELIKE_"..id end
if game.difficulty == game.DIFFICULTY_NIGHTMARE and game.permadeath == game.PERMADEATH_MANY then id = "NIGHTMARE_ADVENTURE_".. id end
if game.difficulty == game.DIFFICULTY_NIGHTMARE and game.permadeath == game.PERMADEATH_ONE then id = "NIGHTMARE_"..id end
if game.difficulty == game.DIFFICULTY_INSANE and game.permadeath == game.PERMADEATH_MANY then id = "INSANE_ADVENTURE_"..id end
if game.difficulty == game.DIFFICULTY_INSANE and game.permadeath == game.PERMADEATH_ONE then id = "INSANE_"..id end
if game.difficulty == game.DIFFICULTY_MADNESS and game.permadeath == game.PERMADEATH_MANY then id = "MADNESS_ADVENTURE_"..id end
if game.difficulty == game.DIFFICULTY_MADNESS and game.permadeath == game.PERMADEATH_ONE then id = "MADNESS_"..id end
local knew = self.achieved[id]
......
......@@ -23,6 +23,17 @@ local WA = require "engine.interface.WorldAchievements"
--- Handles achievements in a world
module(..., package.seeall, class.inherit(class.make{}, WA))
-- Duplicate from Game.lua because Game.lua is not loaded yet
local DIFFICULTY_EASY = 1
local DIFFICULTY_NORMAL = 2
local DIFFICULTY_NIGHTMARE = 3
local DIFFICULTY_INSANE = 4
local DIFFICULTY_MADNESS = 5
local PERMADEATH_INFINITE = 1
local PERMADEATH_MANY = 2
local PERMADEATH_ONE = 3
--- Make a new achievement with a name and desc
function _M:newAchievement(t)
t.id = t.id or t.name
......@@ -31,24 +42,64 @@ function _M:newAchievement(t)
WA.newAchievement(self, t)
if not t.no_difficulty_duplicate then
-- Normal
local t2 = table.clone(t)
t2.id = "NORMAL_ROGUELIKE_"..t2.id
t2.name = t2.name.." (Roguelike)"
t2.difficulty = DIFFICULTY_NORMAL
t2.permadeath = PERMADEATH_ONE
WA.newAchievement(self, t2)
-- Exploration
local t2 = table.clone(t)
t2.id = "EXPLORATION_"..t2.id
t2.name = t2.name.." (Exploration mode)"
t2.permadeath = PERMADEATH_INFINITE
WA.newAchievement(self, t2)
-- Nightmare
local t2 = table.clone(t)
t2.id = "NIGHTMARE_ADVENTURE_"..t2.id
t2.name = t2.name.." (Nightmare (Adventure) difficulty)"
t2.difficulty = DIFFICULTY_NIGHTMARE
t2.permadeath = PERMADEATH_MANY
WA.newAchievement(self, t2)
local t2 = table.clone(t)
t2.id = "NIGHTMARE_"..t2.id
t2.name = t2.name.." (Nightmare difficulty)"
t2.name = t2.name.." (Nightmare (Roguelike) difficulty)"
t2.difficulty = DIFFICULTY_NIGHTMARE
t2.permadeath = PERMADEATH_ONE
WA.newAchievement(self, t2)
-- Insane
local t2 = table.clone(t)
t2.id = "INSANE_ADVENTURE_"..t2.id
t2.name = t2.name.." (Insane (Adventure) difficulty)"
t2.difficulty = DIFFICULTY_INSANE
t2.permadeath = PERMADEATH_MANY
WA.newAchievement(self, t2)
local t2 = table.clone(t)
t2.id = "INSANE_"..t2.id
t2.name = t2.name.." (Insane difficulty)"
t2.name = t2.name.." (Insane (Roguelike) difficulty)"
t2.difficulty = DIFFICULTY_INSANE
t2.permadeath = PERMADEATH_ONE
WA.newAchievement(self, t2)
-- Madness
local t2 = table.clone(t)
t2.id = "MADNESS_ADVENTURE_"..t2.id
t2.name = t2.name.." (Madness (Adventure) difficulty)"
t2.difficulty = DIFFICULTY_MADNESS
t2.permadeath = PERMADEATH_MANY
WA.newAchievement(self, t2)
local t2 = table.clone(t)
t2.id = "MADNESS_"..t2.id
t2.name = t2.name.." (Madness difficulty)"
t2.name = t2.name.." (Madness (Roguelike) difficulty)"
t2.difficulty = DIFFICULTY_MADNESS
t2.permadeath = PERMADEATH_ONE
WA.newAchievement(self, t2)
end
end
......
-- TE4 - T-Engine 4
-- Copyright (C) 2009, 2010, 2011, 2012, 2013 Nicolas Casalini
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-- Nicolas Casalini "DarkGod"
-- darkgod@te4.org
require "engine.class"
local Tiles = require "engine.Tiles"
local ShowAchievements = require "engine.dialogs.ShowAchievements"
module(..., package.seeall, class.inherit(ShowAchievements))
function _M:generateList(kind)
local tiles = Tiles.new(16, 16, nil, nil, true)
local cache = {}
-- Makes up the list
local list = {}
local i = 0
local function handle(id, data)
local a = world:getAchievementFromId(id)
local color = nil
if self.player and self.player.achievements and self.player.achievements[id] then
color = colors.simple(colors.LIGHT_GREEN)
end
local img = a.image or "trophy_gold.png"
local tex = cache[img]
if not tex then
local image = tiles:loadImage(img)
if image then
tex = {image:glTexture()}
cache[img] = tex
end
end
if not data.notdone or a.show then
if a.show == "full" or not data.notdone then
list[#list+1] = { name=a.name, color=color, desc=a.desc, when=data.when, who=data.who, order=a.order, id=id, tex=tex, a=a }
elseif a.show == "none" then
list[#list+1] = { name="???", color=color, desc="-- Unknown --", when=data.when, who=data.who, order=a.order, id=id, tex=tex, a=a }
elseif a.show == "name" then
list[#list+1] = { name=a.name, color=color, desc="-- Unknown --", when=data.when, who=data.who, order=a.order, id=id, tex=tex, a=a }
else
list[#list+1] = { name=a.name, color=color, desc=a.desc, when=data.when, who=data.who, order=a.order, id=id, tex=tex, a=a }
end
i = i + 1
end
end
if kind == "self" and self.player and self.player.achievements then
for id, data in pairs(self.player.achievements) do handle(id, world.achieved[id] or {notdone=true, when="--", who="--"}) end
elseif kind == "main" then
for id, data in pairs(world.achieved) do
local a = world.achiev_defs[id]
if a.no_difficulty_duplicate or ((a.difficulty or a.permadeath) and (not a.difficulty or a.difficulty == game.difficulty) and (not a.permadeath or a.permadeath == game.permadeath)) then
handle(id, data or {notdone=true, when="--", who="--"})
end
end
elseif kind == "all" then
for _, a in ipairs(world.achiev_defs) do
if a.no_difficulty_duplicate or ((a.difficulty or a.permadeath) and (not a.difficulty or a.difficulty == game.difficulty) and (not a.permadeath or a.permadeath == game.permadeath)) then
handle(a.id, world.achieved[a.id] or {notdone=true, when="--", who="--"})
end
end
end
table.sort(list, function(a, b) return a.name < b.name end)
self.list = list
end
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