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

aze

git-svn-id: http://svn.net-core.org/repos/t-engine4@148 51575b47-30f0-44d4-a5cc-537603b46e54
parent e55c3398
No related branches found
No related tags found
No related merge requests found
Showing
with 164 additions and 29 deletions
......@@ -128,8 +128,8 @@ end
-- @param file the file to load from
-- @param no_default if true then no default values will be assigned
-- @usage MyEntityClass:loadList("/data/my_entities_def.lua")
function _M:loadList(file, no_default)
local res = {}
function _M:loadList(file, no_default, res)
res = res or {}
print("Loading entities file", file)
local f, err = loadfile(file)
......@@ -157,8 +157,7 @@ function _M:loadList(file, no_default)
if t.define_as then res[t.define_as] = e end
end,
load = function(f)
local ret = self:loadList(f, no_default)
for i, e in ipairs(ret) do res[#res+1] = e end
self:loadList(f, no_default, res)
end,
loadList = function(f)
return self:loadList(f, no_default)
......
......@@ -4,8 +4,8 @@
newAI("dumb_talented", function(self)
-- Find available talents
local avail = {}
local target_dist = core.fov.distance(self.x, self.y, self.ai_target.actor.x, self.ai_target.actor.y)
for i, tid in ipairs(self.talents) do
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
avail[#avail+1] = tid
......
......@@ -93,3 +93,8 @@ end
function _M:runAI(ai)
return _M.ai_def[ai](self)
end
--- Returns the current target
function _M:getTarget(typ)
return self.ai_target.actor.x, self.ai_target.actor.y, self.ai_target.actor
end
......@@ -58,6 +58,7 @@ function _M:newTalent(t)
table.insert(self.talents_def, t)
t.id = #self.talents_def
self["T_"..t.short_name] = #self.talents_def
print("[TALENT]", t.name, t.short_name, #self.talents_def)
-- Register in the type
table.insert(self.talents_types_def[t.type[1]].talents, t)
......@@ -175,7 +176,7 @@ function _M:learnTalent(t_id, force)
end
-- Auto assign to hotkey
if t.mode ~= "passive" then
if t.mode ~= "passive" and self.hotkey then
for i = 1, 12 do
if not self.hotkey[i] then
self.hotkey[i] = t_id
......@@ -197,8 +198,10 @@ end
function _M:unlearnTalent(t_id)
local t = _M.talents_def[t_id]
for i, known_t_id in pairs(self.hotkey) do
if known_t_id == t_id then self.hotkey[i] = nil end
if self.hotkey then
for i, known_t_id in pairs(self.hotkey) do
if known_t_id == t_id then self.hotkey[i] = nil end
end
end
if t.on_unlearn then t.on_unlearn(self, t) end
......
......@@ -25,3 +25,13 @@ end
function resolvers.calc.mbonus(t)
return rng.mbonus(t[1], resolvers.current_level, 50) + (t[2] or 0)
end
--- Talents resolver
function resolvers.talents(list)
return {__resolver="talents", list}
end
function resolvers.calc.talents(t, e)
local ts = {}
for i, tid in ipairs(t[1]) do ts[tid] = true end
return ts
end
......@@ -31,9 +31,3 @@ function _M:tooltip()
local str = mod.class.Actor.tooltip(self)
return str..("\nTarget: %s\nUID: %d"):format(self.ai_target.actor and self.ai_target.actor.name or "none", self.uid)
end
--- Tries to get a target from the NPC
-- This simple returns current AI target for NPCs
function _M:getTarget(typ)
return self.ai_target.actor.x, self.ai_target.actor.y
end
......@@ -112,7 +112,7 @@ function _M:getTarget(typ)
game:targetMode("exclusive", msg, coroutine.running(), typ)
return coroutine.yield()
end
return game.target.target.x, game.target.target.y
return game.target.target.x, game.target.target.y, game.level.map(game.target.target.x, game.target.target.y, Map.ACTOR)
end
--- Quick way to check if the player can see the target
......
......@@ -38,14 +38,16 @@ The ToME combat system has the following attributes:
- armor penetration: reduction of target's armor
- damage: raw damage done
]]
function _M:attackTarget(target)
function _M:attackTarget(target, damtype, mult)
damtype = damtype or DamageType.PHYSICAL
mult = mult or 1
local speed = nil
-- All weaponsin main hands
if self:getInven(self.INVEN_MAINHAND) then
for i, o in ipairs(self:getInven(self.INVEN_MAINHAND)) do
if o.combat then
local s = self:attackTargetWith(target, o.combat)
local s = self:attackTargetWith(target, o.combat, damtype, mult)
speed = math.max(speed or 0, s)
end
end
......@@ -54,7 +56,7 @@ function _M:attackTarget(target)
if self:getInven(self.INVEN_OFFHAND) then
for i, o in ipairs(self:getInven(self.INVEN_OFFHAND)) do
if o.combat then
local s = self:attackTargetWith(target, o.combat)
local s = self:attackTargetWith(target, o.combat, damtype, mult)
speed = math.max(speed or 0, s)
end
end
......@@ -62,7 +64,7 @@ function _M:attackTarget(target)
-- Barehanded ?
if not speed then
speed = self:attackTargetWith(target, self.combat)
speed = self:attackTargetWith(target, self.combat, damtype, mult)
end
-- We use up our own energy
......@@ -90,9 +92,7 @@ print("=> chance to hit", hit)
end
--- Attacks with one weapon
function _M:attackTargetWith(target, weapon)
local damtype = DamageType.PHYSICAL
function _M:attackTargetWith(target, weapon, damtype, mult)
-- Does the blow connect? yes .. complex :/
local atk, def = self:combatAttack(weapon), target:combatDefense()
local dam, apr, armor = self:combatDamage(weapon), self:combatAPR(weapon), target:combatArmor()
......@@ -100,6 +100,7 @@ function _M:attackTargetWith(target, weapon)
-- If hit is over 0 it connects, if it is 0 we still have 50% chance
if self:checkHit(atk, def) then
local dam = dam - math.max(0, armor - apr)
dam = dam * mult
dam = self:physicalCrit(dam, weapon)
DamageType:get(damtype).projector(self, target.x, target.y, damtype, math.max(0, dam))
else
......
......@@ -117,3 +117,17 @@ newDamageType{
end
end,
}
-- Poisoning damage
newDamageType{
name = "poison", type = "POISON",
projector = function(src, x, y, type, dam)
DamageType:get(DamageType.NATURE).projector(src, x, y, DamageType.NATURE, dam / 6)
dam = dam - dam / 6
local target = game.level.map(x, y, Map.ACTOR)
if target then
-- Set on fire!
target:setEffect(target.EFF_POISONED, 5, {src=src, power=dam / 5})
end
end,
}
local Talents = require("engine.interface.ActorTalents")
newEntity{
define_as = "BASE_NPC_VERMIN",
group = "vermins",
display = "w", color=colors.WHITE,
can_multiply = 2,
body = { INVEN = 10 },
}
newEntity{ base = "BASE_NPC_VERMIN",
name = "white worm mass", color=colors.WHITE,
level_range = {1, 15}, exp_worth = 1,
rarity = 4,
autolevel = "warrior",
ai = "dumb_talented_simple", ai_state = { talent_in=3, },
max_life = resolvers.rngavg(5,9),
energy = { mod=0.9 },
combat = { dam=5, atk=15, apr=10 },
stats = { str=10, dex=15, mag=3, con=3 },
combat_armor = 1, combat_def = 1,
talents = resolvers.talents{ Talents.T_CRAWL_POISON },
}
newEntity{ base = "BASE_NPC_VERMIN",
name = "green worm mass", color=colors.GREEN,
level_range = {2, 15}, exp_worth = 1,
rarity = 5,
autolevel = "warrior",
ai = "dumb_talented_simple", ai_state = { talent_in=3, },
max_life = resolvers.rngavg(5,9),
energy = { mod=0.9 },
combat = { dam=5, atk=15, apr=10 },
stats = { str=10, dex=15, mag=3, con=3 },
combat_armor = 1, combat_def = 1,
talents = resolvers.talents{ Talents.T_CRAWL_POISON },
}
load("/data/general/staves.lua")
load("/data/general/swords.lua")
load("/data/general/shields.lua")
load("/data/general/massive-armor.lua")
load("/data/general/objects/staves.lua")
load("/data/general/objects/swords.lua")
load("/data/general/objects/shields.lua")
load("/data/general/objects/massive-armor.lua")
newEntity{
name = "& Staff of Olorin",
......
......@@ -6,7 +6,7 @@ newEntity{
encumber = 5,
rarity = 3,
desc = [[Staves designed for wielders of magic, by the greats of the art.]],
egos = "/data/general/egos.lua", egos_chance = resolvers.mbonus(40, 5),
egos = "/data/general/objects/egos.lua", egos_chance = resolvers.mbonus(40, 5),
}
newEntity{ base = "BASE_STAFF",
......
......@@ -6,7 +6,7 @@ newEntity{
encumber = 3,
rarity = 3,
desc = [[Sharp, long, and deadly.]],
egos = "/data/general/egos.lua", egos_chance = resolvers.mbonus(40, 5),
egos = "/data/general/objects/egos.lua", egos_chance = resolvers.mbonus(40, 5),
}
newEntity{ base = "BASE_LONGSWORD",
......
load("/data/talents/misc/misc.lua")
load("/data/talents/spells/spells.lua")
load("/data/talents/physical/physical.lua")
load("/data/talents/misc/npcs.lua")
-- race & classes
newTalentType{ type="physical/other", name = "other", hide = true, description = "Talents of the various entities of the world." }
newTalentType{ type="spell/other", name = "other", hide = true, description = "Talents of the various entities of the world." }
newTalentType{ type="other/other", name = "other", hide = true, description = "Talents of the various entities of the world." }
-- Multiply!!!
newTalent{
name = "Multiply",
type = {"other/other", 1},
cooldown = 3,
range = 20,
action = function(self, t)
print("Multiply *****BROKEN***** Fix it!")
return nil
--[[
if not self.can_multiply or self.can_multiply <= 0 then return nil end
-- Find a place around to clone
for i = -1, 1 do for j = -1, 1 do
if not game.level.map:checkAllEntities(self.x + i, self.y + j, "block_move") then
self.can_multiply = self.can_multiply - 1
local a = self:clone()
a.energy.val = 0
a.exp_worth = 0.1
a.inven = {}
if a.can_multiply <= 0 then a:unlearnTalent(t.id) end
print("multiplied", a.can_multiply, "uids", self.uid,"=>",a.uid, "::", self.player, a.player)
a:move(self.x + i, self.y + j, true)
game.level:addEntity(a)
return true
end
end end
return nil
]]
end,
info = function(self)
return ([[Multiply yourself!]])
end,
}
newTalent{
short_name = "CRAWL_POISON",
name = "Poisonous Crawl",
type = {"physical/other", 1},
cooldown = 2,
range = 1,
action = function(self, t)
local x, y, target = self:getTarget()
if math.floor(core.fov.distance(self.x, self.y, x, y)) > 1 then return nil end
self:attackTarget(target, DamageType.POISON, 1)
return true
end,
info = function(self)
return ([[Multiply yourself!]])
end,
}
......@@ -56,6 +56,19 @@ newEffect{
end,
}
newEffect{
name = "POISONED",
desc = "Poisoned",
type = "magical",
status = "detrimental",
parameters = { power=10 },
on_gain = function(self, err) return "#Target# is poisoned!", "+Poison" end,
on_lose = function(self, err) return "#Target# stops beign poisoned.", "-Poison" end,
on_timeout = function(self, eff)
DamageType:get(DamageType.NATURE).projector(eff.src, self.x, self.y, DamageType.NATURE, eff.power)
end,
}
newEffect{
name = "FROZEN",
desc = "Frozen",
......
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