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

4 difficulty settings: Easy/Normal/Nightmare/Insane

git-svn-id: http://svn.net-core.org/repos/t-engine4@664 51575b47-30f0-44d4-a5cc-537603b46e54
parent 419cdbc0
No related branches found
No related tags found
No related merge requests found
......@@ -90,6 +90,7 @@ function _M:init(actor, order, at_end)
end
function _M:selectType(type)
local default = 1
self.list = {}
-- Make up the list
for i, d in ipairs(self.birth_descriptor_def[type]) do
......@@ -108,9 +109,10 @@ function _M:selectType(type)
-- Check it is allowed
if allowed then
table.insert(self.list, d)
if d.selection_default then default = #self.list end
end
end
self.sel = 1
self.sel = default
self.current_type = type
end
......
......@@ -57,6 +57,12 @@ local QuitDialog = require "mod.dialogs.Quit"
module(..., package.seeall, class.inherit(engine.GameTurnBased, engine.interface.GameMusic, engine.interface.GameSound))
-- Difficulty settings
DIFFICULTY_EASY = 1
DIFFICULTY_NORMAL = 2
DIFFICULTY_NIGHTMARE = 3
DIFFICULTY_INSANE = 4
function _M:init()
engine.GameTurnBased.init(self, engine.KeyBind.new(), 1000, 100)
engine.interface.GameMusic.init(self)
......@@ -114,7 +120,7 @@ function _M:newGame()
Map:setViewerActor(self.player)
self:setupDisplayMode()
local birth = Birther.new(self.player, {"base", "world", "race", "subrace", "sex", "class", "subclass" }, function()
local birth = Birther.new(self.player, {"base", "difficulty", "world", "race", "subrace", "sex", "class", "subclass" }, function()
self.player.wild_x, self.player.wild_y = self.player.default_wilderness[1], self.player.default_wilderness[2]
self:changeLevel(1, self.player.starting_zone)
print("[PLAYER BIRTH] resolve...")
......@@ -219,8 +225,10 @@ function _M:getSaveDescription()
return {
name = self.player.name,
description = ([[%s the level %d %s %s.
Difficulty: %s
Exploring level %d of %s.]]):format(
self.player.name, self.player.level, self.player.descriptor.subrace, self.player.descriptor.subclass,
self.player.descriptor.difficulty,
self.level.level, self.zone.name
),
}
......
......@@ -193,6 +193,19 @@ function _M:onTakeHit(value, src)
return ret
end
function _M:heal(value, src)
-- Difficulty settings
if game.difficulty == game.DIFFICULTY_EASY then
value = value * 1.1
elseif game.difficulty == game.DIFFICULTY_NIGHTMARE then
value = value * 0.9
elseif game.difficulty == game.DIFFICULTY_INSANE then
value = value * 0.8
end
mod.class.Actor.heal(self, value, src)
end
function _M:die(src)
if self.game_ender then
engine.interface.ActorLife.die(self, src)
......
......@@ -57,6 +57,54 @@ newBirthDescriptor{
},
}
--------------- Difficulties
newBirthDescriptor{
type = "difficulty",
name = "Easy",
desc =
{
"Easy game setting",
"All damage done to the player reduced by 20%",
"All healing for the player increased by 10%",
},
copy = { resolvers.generic(function() game.difficulty = game.DIFFICULTY_EASY end) },
}
newBirthDescriptor{
type = "difficulty",
name = "Normal",
selection_default = true,
desc =
{
"Normal game setting",
"No changes to the rules.",
},
copy = { resolvers.generic(function() game.difficulty = game.DIFFICULTY_NORMAL end) },
}
newBirthDescriptor{
type = "difficulty",
name = "Nightmare",
desc =
{
"Hard game setting",
"All damage done to the player increased by 20%",
"All healing for the player decreased by 10%",
},
copy = { resolvers.generic(function() game.difficulty = game.DIFFICULTY_NIGHTMARE end) },
}
newBirthDescriptor{
type = "difficulty",
name = "Insane",
desc =
{
"Absolutly unfair game setting",
"All damage done to the player increased by 20%",
"All damage done by the player decreased by 20%",
"All healing for the player decreased by 20%",
},
copy = { resolvers.generic(function() game.difficulty = game.DIFFICULTY_INSANE end) },
}
-- Worlds
load("/data/birth/worlds.lua")
......
......@@ -21,6 +21,19 @@
setDefaultProjector(function(src, x, y, type, dam)
local target = game.level.map(x, y, Map.ACTOR)
if target then
print("[PROJECTOR] starting dam", dam)
-- Difficulty settings
if game.difficulty == game.DIFFICULTY_EASY and target.player then
dam = dam * 0.8
elseif game.difficulty == game.DIFFICULTY_NIGHTMARE and target.player then
dam = dam * 1.2
elseif game.difficulty == game.DIFFICULTY_INSANE then
if target.player then dam = dam * 1.2
elseif src.player then dam = dam * 0.8 end
end
print("[PROJECTOR] after difficulty dam", dam)
-- Increases damage
if src.inc_damage then
local inc = src.inc_damage[type] or 0
......
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