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

autoalloc stats at birth to meet equipment requirements

git-svn-id: http://svn.net-core.org/repos/t-engine4@369 51575b47-30f0-44d4-a5cc-537603b46e54
parent 0751aaa1
No related branches found
No related tags found
No related merge requests found
......@@ -133,7 +133,8 @@ function _M:drawSelectionList(s, x, y, hskip, list, sel, prop, scroll, max, colo
for i = scroll, math.min(#list, scroll + max - 1) do
local v = list[i]
local vc = v.color
local vc = nil
if type(v) == "table" then vc = v.color end
if prop and type(v[prop]) == "string" then v = tostring(v[prop])
elseif prop and type(v[prop]) == "function" then v = tostring(v[prop](v))
else v = tostring(v) end
......
......@@ -5,6 +5,8 @@ require "engine.class"
-- to the monster level default exp
module(..., package.seeall, class.make)
_M.actors_max_level = false
_M.exp_chart = function(level)
local exp = 10
local mult = 10
......@@ -37,10 +39,17 @@ end
--- Defines the experience chart used
-- Static!
-- @param chart etiher a table of format "[level] = exp_needed" or a function that takes one parameter, a level, and returns the experience needed to reach it.
-- @param chart either a table of format "[level] = exp_needed" or a function that takes one parameter, a level, and returns the experience needed to reach it.
function _M:defineExperienceChart(chart)
assert(type(chart) == "table" or type(chart) == "function", "chart is neither table nor function")
self.exp_chart = chart
_M.exp_chart = chart
end
--- Defines the max level attainable
-- @param max the maximun level. Can be nil to not have a limit
-- Static!
function _M:defineMaxLevel(max)
_M.actors_max_level = max
end
--- Get the exp needed for the given level
......@@ -57,8 +66,9 @@ end
--- Gains some experience
-- If a levelup happens it calls self:levelup(), modules are encourraged to rewrite it to do whatever is needed.
function _M:gainExp(value)
if self.actors_max_level and self.level >= self.actors_max_level then return end
self.exp = self.exp + value
while self:getExpChart(self.level + 1) and self.exp >= self:getExpChart(self.level + 1) do
while self:getExpChart(self.level + 1) and self.exp >= self:getExpChart(self.level + 1) and (not self.actors_max_level or self.level < self.actors_max_level) do
-- At max level, if any
if self.max_level and self.level >= self.max_level then break end
......
......@@ -30,8 +30,6 @@ local Tooltip = require "engine.Tooltip"
local Calendar = require "engine.Calendar"
local QuitDialog = require "mod.dialogs.Quit"
local LevelupStatsDialog = require "mod.dialogs.LevelupStatsDialog"
local LevelupTalentsDialog = require "mod.dialogs.LevelupTalentsDialog"
module(..., package.seeall, class.inherit(engine.GameTurnBased))
......@@ -90,9 +88,8 @@ function _M:newGame()
self.player.current_wilderness = self.player.default_wilderness[1]
self:changeLevel(1)
self.player:resolve()
local ds = LevelupStatsDialog.new(self.player)
self:registerDialog(ds)
self.player:resolve(nil, true)
self.player:playerLevelup()
end)
self:registerDialog(birth)
end
......@@ -459,13 +456,7 @@ function _M:setupCommands()
end,
LEVELUP = function()
if self.player.unused_stats > 0 then
local ds = LevelupStatsDialog.new(self.player)
self:registerDialog(ds)
else
local dt = LevelupTalentsDialog.new(self.player)
self:registerDialog(dt)
end
self.player:playerLevelup()
end,
SAVE_GAME = function()
......
......@@ -7,6 +7,8 @@ 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"
--- Defines the player for ToME
-- It is a normal actor, with some redefined methods to handle user interaction.<br/>
......@@ -286,3 +288,13 @@ function _M:playerUseItem(object, item)
true
)
end
function _M:playerLevelup()
if self.unused_stats > 0 then
local ds = LevelupStatsDialog.new(self)
game:registerDialog(ds)
else
local dt = LevelupTalentsDialog.new(self)
game:registerDialog(dt)
end
end
......@@ -48,10 +48,10 @@ newBirthDescriptor{
[ActorTalents.T_HEAVY_ARMOUR_TRAINING] = 1,
},
copy = {
equipment = resolvers.equip{ id=true,
{type="weapon", subtype="longsword", name="iron longsword"},
{type="armor", subtype="shield", name="iron shield"},
{type="armor", subtype="heavy", name="iron mail armour"}
resolvers.equip{ id=true,
{type="weapon", subtype="longsword", name="iron longsword", autoreq=true},
{type="armor", subtype="shield", name="iron shield", autoreq=true},
{type="armor", subtype="heavy", name="iron mail armour", autoreq=true}
},
},
}
......@@ -85,7 +85,7 @@ newBirthDescriptor{
[ActorTalents.T_HEAVY_ARMOUR_TRAINING] = 1,
},
copy = {
equipment = resolvers.equip{ id=true,
resolvers.equip{ id=true,
{type="weapon", subtype="greatsword", name="iron greatsword"},
{type="armor", subtype="heavy", name="iron mail armour"}
},
......
......@@ -112,13 +112,13 @@ newTalent{
local a, id = rng.table(tgts)
table.remove(tgts, id)
self:project(tg, a.x, a.y, DamageType.LIGHTNING, rng.avg(1, self:spellCrit(20 + self:combatSpellpower(0.8) * self:getTalentLevel(t)), 3), {type="lightning"})
self:project(tg, a.x, a.y, DamageType.LIGHTNING, rng.avg(1, self:spellCrit(20 + self:combatSpellpower(0.2) * self:getTalentLevel(t)), 3), {type="lightning"})
end
end,
activate = function(self, t)
game.logSeen(self, "#0080FF#A furious lightning storm forms around %s!", self.name)
return {
drain = self:addTemporaryValue("mana_regen", -2),
drain = self:addTemporaryValue("mana_regen", -3 * self:getTalentLevelRaw(t)),
}
end,
deactivate = function(self, t, p)
......@@ -130,6 +130,6 @@ newTalent{
return ([[Conjures a furious raging lightning storm with a radius of 5 that follows you as long as this spell is active.
Each turn a random lightning bolt will hit up to %d of your foes for 1 to %0.2f damage.
This powerfull spell will continuously drain mana while active.
The damage will increase with the Magic stat]]):format(self:getTalentLevel(t), 20 + self:combatSpellpower(0.8) * self:getTalentLevel(t))
The damage will increase with the Magic stat]]):format(self:getTalentLevel(t), 20 + self:combatSpellpower(0.2) * self:getTalentLevel(t))
end,
}
......@@ -150,7 +150,7 @@ newTalent{
if weapon.archery == "sling" then st = "shot" end
local o = game.zone:makeEntity(game.level, "object", {type="ammo", subtype=st})
if o and rng.percent(10 + self:getTalentLevel(t) * 10) then
if o and rng.percent(40 + self:getTalentLevel(t) * 10) then
o:identify(true)
o:forAllStack(function(so) so.cost = 0 end)
self:addObject(self.INVEN_INVEN, o)
......
......@@ -15,8 +15,12 @@ newEntity{ define_as = "THE_MASTER",
max_stamina = 145,
stats = { str=19, dex=19, cun=34, mag=25, con=16 },
body = { INVEN = 10, MAINHAND=1, OFFHAND=1, BODY=1 },
equipment = resolvers.equip{ {type="weapon", subtype="greatsword"}, {type="armor", subtype="heavy"}, },
body = { INVEN = 10, MAINHAND=1, OFFHAND=1, BODY=1, NECK=1, },
equipment = resolvers.equip{
{type="weapon", subtype="greatsword"},
{type="armor", subtype="heavy"},
{type="jewelry", subtype="amulet", defined="AMULET_DREAD"},
},
resolvers.drops{chance=100, nb=5, {ego_chance=100} },
resolvers.drops{chance=100, nb=1, {type="weapon", subtype="staff", defined="STAFF_ABSORPTION"} },
......@@ -36,9 +40,14 @@ newEntity{ define_as = "THE_MASTER",
[Talents.T_MANATHRUST]=4,
[Talents.T_FREEZE]=4,
[Talents.T_PHASE_DOOR]=2,
[Talents.T_STRIKE]=3,
[Talents.T_STAMINA_POOL]=1,
[Talents.T_SWORD_MASTERY]=3,
[Talents.T_STUNNING_BLOW]=1,
[Talents.T_RUSH]=4,
[Talents.T_SPELL_SHIELD]=4,
[Talents.T_BLINDING_SPEED]=4,
[Talents.T_PERFECT_STRIKE]=3,
},
autolevel = "warriormage",
......
load("/data/general/objects/objects.lua")
-- Artifact, droped (and used!) by the Shade of Angmar
newEntity{ base = "BASE_STAFF",
define_as = "STAFF_ANGMAR", rarity=false,
name = "Angmar's Fall", unique=true,
desc = [[Made from the bones of of many creatures this staff glows with power. You can feel its evilness as you touch it.]],
require = { stat = { mag=25 }, },
cost = 5,
combat = {
dam = 10,
apr = 0,
physcrit = 1.5,
dammod = {mag=1.1},
},
newEntity{ base = "BASE_AMULET",
define_as = "AMULET_DREAD", rarity=false,
name = "Choker of Dread", unique=true,
unided_name = "dark amulet", color=colors.LIGHT_DARK,
desc = [[The evilness of undeath radiates from this amulet.]],
cost = 5000,
wielder = {
see_invisible = 2,
combat_spellpower = 15,
combat_spellcrit = 8,
see_invisible = 10,
blind_immune = 1,
combat_spellpower = 5,
combat_dam = 5,
},
}
......@@ -7,6 +7,7 @@ local ActorTalents = require "engine.interface.ActorTalents"
local ActorTemporaryEffects = require "engine.interface.ActorTemporaryEffects"
local ActorAI = require "engine.interface.ActorAI"
local ActorInventory = require "engine.interface.ActorInventory"
local ActorLevel = require "engine.interface.ActorLevel"
local Birther = require "engine.Birther"
-- Usefull keybinds
......@@ -59,6 +60,9 @@ ActorStats:defineStat("Constitution", "con", 10, 1, 100, "Constitution defines y
-- Luck is hidden and start at half max value (50) which is considered the standard
ActorStats:defineStat("Luck", "lck", 50, 1, 100, "Luck defines your character's chance when dealing with unknown events. It increases your critical strike chances, your chance for random encounters, ...")
-- Actor leveling
ActorLevel:defineMaxLevel(50)
-- Actor autolevel schemes
dofile("/data/autolevel_schemes.lua")
......
......@@ -15,6 +15,19 @@ function resolvers.calc.equip(t, e)
end
if o then
print("Zone made us an equipment according to filter!", o:getName())
-- Auto alloc some stats to be able to wear it
if filter.autoreq and o.require and o.require.stat then
print("Autorequire stats")
for s, v in pairs(o.require.stat) do
print(s,v)
if e:getStat(s) < v then
e.unused_stats = e.unused_stats - (v - e:getStat(s))
e:incStat(s, v - e:getStat(s))
end
end
end
e:wearObject(o, true, false)
-- Do not drop it unless it is an ego or better
......
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