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

more generous hit formula

git-svn-id: http://svn.net-core.org/repos/t-engine4@150 51575b47-30f0-44d4-a5cc-537603b46e54
parent fe7d6f34
No related branches found
No related tags found
No related merge requests found
......@@ -147,6 +147,23 @@ function _M:makeEntity(level, type, filter)
return e
end
--- Find a given entity and resolve it
-- @return the fully resolved entity, ready to be used on a level. Or nil if a filter was given an nothing found
function _M:makeEntityByName(level, type, name)
resolvers.current_level = self.base_level + level.level - 1
local e
if type == "actor" then e = self.npc_list[name]
elseif type == "object" then e = self.object_list[name]
elseif type == "grid" then e = self.grid_list[name]
end
if not e then return nil end
e = self:finishEntity(level, type, e)
return e
end
--- Finishes generating an entity
function _M:finishEntity(level, type, e, ego_chance)
e = e:clone()
......@@ -250,7 +267,8 @@ function _M:newLevel(level_data, lev, old_lev, game)
self.grid_list,
level_data.generator.map
)
local startx, starty = generator:generate(lev, old_lev)
local startx, starty, spots = generator:generate(lev, old_lev)
spots = spots or {}
local level = self.level_class.new(lev, map)
level.start = {x=startx, y=starty}
......@@ -266,7 +284,8 @@ function _M:newLevel(level_data, lev, old_lev, game)
local generator = require(level_data.generator.object.class).new(
self,
map,
level
level,
spots
)
generator:generate()
end
......@@ -276,7 +295,8 @@ function _M:newLevel(level_data, lev, old_lev, game)
local generator = require(level_data.generator.actor.class).new(
self,
map,
level
level,
spots
)
generator:generate()
end
......
......@@ -7,7 +7,7 @@ newAI("dumb_talented", function(self)
local target_dist = math.floor(core.fov.distance(self.x, self.y, self.ai_target.actor.x, self.ai_target.actor.y))
for tid, _ in pairs(self.talents) do
local t = self:getTalentFromId(tid)
if not self:isTalentCoolingDown(t) and target_dist <= self:getTalentRange(t) and self:preUseTalent(t, true) then
if t.mode == "activated" and not self:isTalentCoolingDown(t) and target_dist <= self:getTalentRange(t) and self:preUseTalent(t, true) then
avail[#avail+1] = tid
print(self.name, self.uid, "dumb ai talents can use", t.name, tid)
end
......
......@@ -15,6 +15,7 @@ function _M:init(zone, map, level)
self.adjust_level = {base=zone.base_level, min=data.adjust_level[1], max=data.adjust_level[2]}
end
self.nb_npc = data.nb_npc or {10, 20}
self.guardian = data.guardian
end
function _M:generate()
......@@ -39,4 +40,31 @@ function _M:generate()
end
end
end
-- if self.level.level <= self.zone.max_level then return end
if self.guardian then
local m = self.zone:makeEntityByName(self.level, "actor", self.guardian)
if m then
local x, y = rng.range(0, self.map.w), rng.range(0, self.map.h)
local tries = 0
while not m:canMove(x, y) and tries < 100 do
x, y = rng.range(0, self.map.w), rng.range(0, self.map.h)
tries = tries + 1
end
if tries < 100 then
m:move(x, y, true)
self.level:addEntity(m)
-- Levelup ?
if self.adjust_level then
local newlevel = self.adjust_level.base + rng.avg(self.adjust_level.min, self.adjust_level.max)
m:forceLevelup(newlevel)
end
print("Guardian allocated: ", self.guardian, m.uid, m.name)
end
else
print("WARNING: Guardian not found: ", self.guardian)
end
end
end
......@@ -200,14 +200,16 @@ end
-- @param ab the talent (not the id, the table)
-- @return true to continue, false to stop
function _M:preUseTalent(ab, silent)
if not self:enoughEnergy() then return end
if not self:enoughEnergy() then print("fail energy") return false end
if ab.mana and self:getMana() < ab.mana * (100 + self.fatigue) / 100 then
game.logPlayer(self, "You do not have enough mana to cast %s.", ab.name)
return
print("fail mana", self:getMana(), ab.mana, ab.mana * (100 + self.fatigue) / 100)
return false
end
if ab.stamina and self:getStamina() < ab.stamina * (100 + self.fatigue) / 100 then
print("fail stam")
game.logPlayer(self, "You do not have enough stamina to use %s.", ab.name)
return
return false
end
if not silent then
......
......@@ -82,9 +82,11 @@ print("checkHit", atk, def)
local hit = nil
factor = factor or 5
if atk > def then
hit = math.log10(1 + 5 * (atk - def) / atk) * 100 + 50
local d = atk - def
hit = math.log10(1 + 5 * d / 50) * 100 + 50
else
hit = -math.log10(1 + 5 * (def - atk) / atk) * 100 + 50
local d = def - atk
hit = -math.log10(1 + 5 * d / 50) * 100 + 50
end
hit = util.bound(hit, min or 5, max or 95)
print("=> chance to hit", hit)
......
......@@ -18,3 +18,13 @@ Autolevel:registerScheme{ name = "caster", levelup = function(self)
-- 2 MAG for 1 WIL
learnStats(self, { self.STAT_MAG, self.STAT_MAG, self.STAT_WIL })
end}
Autolevel:registerScheme{ name = "warriormage", levelup = function(self)
if self.level % 2 == 0 then
-- 2 MAG for 1 WIL
learnStats(self, { self.STAT_MAG, self.STAT_MAG, self.STAT_WIL })
else
-- 2 STR for 1 DEX
learnStats(self, { self.STAT_STR, self.STAT_STR, self.STAT_DEX })
end
end}
......@@ -41,7 +41,7 @@ newEntity{ base = "BASE_NPC_SKELETON",
max_mana = resolvers.rngavg(40,50),
combat_armor = 3, combat_def = 1,
stats = { str=10, dex=12, cun=14, mag=14, con=10 },
talents = resolvers.talents{ Talents.T_FLAME, Talents.T_MANATHRUST },
talents = resolvers.talents{ Talents.T_MANA_POOL, Talents.T_FLAME, Talents.T_MANATHRUST },
autolevel = "caster",
ai = "dumb_talented_simple", ai_state = { talent_in=6, },
......
......@@ -47,7 +47,7 @@ newTalent{
action = function(self, t)
local duration = 5 + self:combatSpellpower(0.05)
local radius = 1
local dam = 12 + self:combatSpellpower(0.5)
local dam = 5 + self:combatSpellpower(0.4)
-- Add a lasting map effect
game.level.map:addEffect(self,
self.x, self.y, duration,
......@@ -65,7 +65,7 @@ newTalent{
require = { stat = { mag=34 }, level=25 },
info = function(self)
return ([[A furious ice storm rages around the caster doing %0.2f cold damage in a radius of 3 each turns for %d turns.
The damage and duration will increase with the Magic stat]]):format(12 + self:combatSpellpower(0.5), 5 + self:combatSpellpower(0.05))
The damage and duration will increase with the Magic stat]]):format(5 + self:combatSpellpower(0.4), 5 + self:combatSpellpower(0.05))
end,
}
......@@ -80,7 +80,7 @@ newTalent{
action = function(self, t)
local duration = 5 + self:combatSpellpower(0.25)
local radius = 3
local dam = 12 + self:combatSpellpower(0.8)
local dam = 5 + self:combatSpellpower(0.8)
-- Add a lasting map effect
game.level.map:addEffect(self,
self.x, self.y, duration,
......@@ -99,6 +99,6 @@ newTalent{
require = { stat = { mag=34 }, level=25 },
info = function(self)
return ([[A furious ice storm rages around the caster doing %0.2f cold damage in a radius of 3 each turns for %d turns.
The damage and duration will increase with the Magic stat]]):format(12 + self:combatSpellpower(0.8), 5 + self:combatSpellpower(0.25))
The damage and duration will increase with the Magic stat]]):format(5 + self:combatSpellpower(0.8), 5 + self:combatSpellpower(0.25))
end,
}
load("/data/general/npcs/vermin.lua")
load("/data/general/npcs/molds.lua")
load("/data/general/npcs/skeleton.lua")
--load("/data/general/npcs/.lua")
--[[
local Talents = require("engine.interface.ActorTalents")
newEntity{
group = "dragon",
name = "dragon of death",
display = "D", color_r=255,
level_range = {3, 10}, exp_worth = 1,
rarity = 4,
autolevel = "warrior",
ai = "simple",
max_life = 100,
life_rating = 10,
max_mana = 1000,
max_stamina = 1000,
energy = { mod=0.5 },
has_blood = true,
stats = { str=15, dex=8, mag=12, con=14 },
combat = { dam=8, atk=10, apr=2, def=4, armor=6},
}
newEntity{
group = "icky things",
name = "white icky",
display = "i", color=colors.YELLOW,
level_range = {1, 7}, exp_worth = 1,
rarity = 1,
autolevel = "caster",
ai = "dumb_talented_simple",
ai_state = { talent_in=12, },
max_life = resolvers.rngavg(10,20),
max_mana = resolvers.rngavg(50,60),
energy = { mod=0.3 },
has_blood = {nb=3, color={50,255,120}},
combat = { dam=5, atk=6, def=2, apr=1, armor=2 },
stats = { str=10, dex=7, mag=14, con=10 },
talents = { Talents.T_MANATHRUST, Talents.T_FREEZE, Talents.T_FLAME }
}
newEntity{
group = "goblin",
name = "small goblin",
display = "g", color=colors.GREEN,
level_range = {1, 7}, exp_worth = 1,
rarity = 1,
autolevel = "warrior",
ai = "dumb_talented_simple",
ai_state = { talent_in=6, },
max_life = resolvers.rngavg(10,20),
max_stamina = resolvers.rngavg(50,60),
energy = { mod=0.3 },
has_blood = true,
-- The boss of Amon Sul, no "rarity" field means it will not be randomly generated
newEntity{ base = "BASE_NPC_SKELETON", define_as = "SHADE_OF_ANGMAR",
unique = true,
name = "The Shade of Angmar", color=colors.VIOLET,
desc = [[This skeleton looks nasty. There is red flames in its empty eye sockets. It wield a nasty sword and towers toward you, throwing spells.]],
level_range = {6, 10}, exp_worth = 1,
max_life = 150, fixed_rating = true,
max_mana = 85,
combat_armor = 3, combat_def = 1,
stats = { str=10, dex=12, cun=14, mag=14, con=10 },
body = {
INVEN = 1000, MAINHAND = 1, OFFHAND = 1,
FINGER = 2, NECK = 1, LITE = 1,
BODY = 1, HEAD = 1, HANDS = 1, FEET = 1,
TOOL = 1,
},
equipment = resolvers.equip{ {type="weapon", subtype="longsword"}, {type="armor", subtype="massive"}, {type="armor", subtype="shield"}, },
drops = resolvers.drops{chance=100, nb=3, {ego_chance=100} },
talents = resolvers.talents{ Talents.T_MANA_POOL, Talents.T_FREEZE, Talents.T_TIDAL_WAVE },
stats = { str=14, dex=12, mag=8, con=13 },
talents = { },
autolevel = "warriormage",
ai = "dumb_talented_simple", ai_state = { talent_in=1, },
}
]]
......@@ -23,6 +23,7 @@ return {
nb_npc = {20, 30},
ood = {chance=5, range={1, 10}},
adjust_level = {-1, 2},
guardian = "SHADE_OF_ANGMAR",
},
object = {
class = "engine.generator.object.Random",
......
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