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

autoleveling

git-svn-id: http://svn.net-core.org/repos/t-engine4@79 51575b47-30f0-44d4-a5cc-537603b46e54
parent 3c7b9b46
No related branches found
No related tags found
No related merge requests found
......@@ -10,4 +10,12 @@ _M.schemes = {}
function _M:registerScheme(t)
assert(t.name, "no autolevel name")
assert(t.levelup, "no autolevel levelup function")
_M.schemes[t.name] = t
end
function _M:autoLevel(actor)
if not actor.autolevel then return end
assert(_M.schemes[actor.autolevel], "no autoleveling scheme "..actor.autolevel)
_M.schemes[actor.autolevel].levelup(actor)
end
require "engine.class"
require "engine.Actor"
require "engine.Autolevel"
require "engine.interface.ActorTemporaryEffects"
require "engine.interface.ActorLife"
require "engine.interface.ActorLevel"
......@@ -85,6 +86,7 @@ function _M:levelup()
-- Auto levelup ?
if self.autolevel then
engine.Autolevel:autoLevel(self)
end
end
......
......@@ -52,6 +52,8 @@ function _M:run()
ActorStats:defineStat("Willpower", "wil", 10, 1, 100, "Willpower defines your character's ability to concentrate. It increases your mana and stamina capacity, and your chance to resist mental attacks.")
ActorStats:defineStat("Cunning", "cun", 10, 1, 100, "Cunning defines your character's ability to learn and think. It allows you to learn many wordly abilities, increases your mental resistance and armor penetration.")
ActorStats:defineStat("Constitution", "con", 10, 1, 100, "Constitution defines your character's ability to withstand and resist damage. It increases your maximun life and physical resistance.")
-- Actor autolevel schemes
dofile("/data/autolevel_schemes.lua")
self.log = LogDisplay.new(0, self.h * 0.80, self.w * 0.5, self.h * 0.20, nil, nil, nil, {255,255,255}, {30,30,30})
self.player_display = PlayerDisplay.new(0, 0, self.w * 0.2, self.h * 0.8, {30,30,0})
......@@ -82,7 +84,8 @@ end
function _M:newGame()
self.zone = Zone.new("ancient_ruins")
self.player = Player.new{
name=self.player_name, max_life=10000, image='player.png', display='@', color_r=230, color_g=230, color_b=230,
name=self.player_name, max_life=10000, display='@', color_r=230, color_g=230, color_b=230,
level = 10,
}
self:changeLevel(1)
end
......
local Autolevel = require "engine.Autolevel"
local function learnStats(self, statorder)
local i = 1
while self.unused_stats > 0 do
self:incStat(statorder[i], 1)
i = util.boundWrap(i + 1, 1, #statorder)
self.unused_stats = self.unused_stats - 1
end
end
Autolevel:registerScheme{ name = "warrior", levelup = function(self)
-- 2 STR for 1 CON
learnStats(self, { self.STAT_STR, self.STAT_STR, self.STAT_CON })
end}
Autolevel:registerScheme{ name = "caster", levelup = function(self)
-- 2 STR for 1 CON
learnStats(self, { self.STAT_MAG, self.STAT_MAG, self.STAT_WIL })
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