diff --git a/game/engine/Entity.lua b/game/engine/Entity.lua index 97d93b9e7cbaba2b6345e29e2c6d3bb60ed602c6..3c22beda91bf2c330047968cc0f49bf884f01ea5 100644 --- a/game/engine/Entity.lua +++ b/game/engine/Entity.lua @@ -5,6 +5,7 @@ module(..., package.seeall, class.make) local next_uid = 1 +local entities_load_functions = {} -- Setup the uids repository as a weak value table, when the entities are no more used anywhere else they disappear from there too setmetatable(__uids, {__mode="v"}) @@ -106,7 +107,7 @@ function _M:resolve(t) for k, e in pairs(t) do if type(e) == "table" and e.__resolver then t[k] = resolvers.calc[e.__resolver](e, self) - elseif type(e) == "table" then + elseif type(e) == "table" and not e.__CLASSNAME then self:resolve(e) end end @@ -163,10 +164,19 @@ end -- @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, res) + no_default = no_default and true or false res = res or {} - print("Loading entities file", file) - local f, err = loadfile(file) + local f, err = nil, nil + if entities_load_functions[file] and entities_load_functions[file][no_default] then + print("Loading entities file from memory", file) + f = entities_load_functions[file][no_default] + else + f, err = loadfile(file) + print("Loading entities file from file", file) + entities_load_functions[file] = entities_load_functions[file] or {} + entities_load_functions[file][no_default] = f + end if err then error(err) end setfenv(f, setmetatable({ @@ -176,17 +186,19 @@ function _M:loadList(file, no_default, res) -- Do we inherit things ? if t.base then for k, e in pairs(res[t.base]) do - if not t[k] then - t[k] = e - elseif type(t[k]) == "table" and type(e) == "table" then - copy_recurs(t[k], e) + if k ~= "define_as" then + if not t[k] then + t[k] = e + elseif type(t[k]) == "table" and type(e) == "table" then + copy_recurs(t[k], e) + end end end t.base = nil end local e = self.new(t, no_default) - print("loaded", e.name, no_default) + res[#res+1] = e if t.define_as then res[t.define_as] = e end end, diff --git a/game/modules/tome/class/Actor.lua b/game/modules/tome/class/Actor.lua index ddaffd6e650aa4124518a3f853e6d9540bfa61d5..5bfad5d12c9912aa3f3708dddd45d685640b49d1 100644 --- a/game/modules/tome/class/Actor.lua +++ b/game/modules/tome/class/Actor.lua @@ -55,9 +55,9 @@ function _M:init(t, no_default) t.mana_rating = t.mana_rating or 10 t.stamina_rating = t.stamina_rating or 10 - t.esp = {range=10} + t.esp = t.esp or {range=10} - t.on_melee_hit = {} + t.on_melee_hit = t.on_melee_hit or {} -- Resistances t.resists = t.resists or {} diff --git a/game/modules/tome/class/interface/Combat.lua b/game/modules/tome/class/interface/Combat.lua index d937547fcefa60b5365bb4f6e62430bc7cdacb9f..bd692b2868d1f3095465f2b645f1df928af6ba2c 100644 --- a/game/modules/tome/class/interface/Combat.lua +++ b/game/modules/tome/class/interface/Combat.lua @@ -76,7 +76,7 @@ function _M:attackTarget(target, damtype, mult, noenergy) end -- Barehanded ? - if not speed then + if not speed and self.combat then local s, h = self:attackTargetWith(target, self.combat, damtype, mult) speed = math.max(speed or 0, s) hit = hit or h diff --git a/game/modules/tome/data/general/npcs/skeleton.lua b/game/modules/tome/data/general/npcs/skeleton.lua index a66837ce2bd601d1347af26bca1a452b710a966f..9ec13fe67ab2c17def15e0673eb5492ad61cf4bc 100644 --- a/game/modules/tome/data/general/npcs/skeleton.lua +++ b/game/modules/tome/data/general/npcs/skeleton.lua @@ -29,6 +29,7 @@ newEntity{ base = "BASE_NPC_SKELETON", rarity = 4, max_life = resolvers.rngavg(40,50), combat_armor = 5, combat_def = 1, + talents = resolvers.talents{ [Talents.T_SUMMON]=1 }, } newEntity{ base = "BASE_NPC_SKELETON", @@ -38,6 +39,7 @@ newEntity{ base = "BASE_NPC_SKELETON", max_life = resolvers.rngavg(90,100), combat_armor = 5, combat_def = 1, talents = resolvers.talents{ [Talents.T_STAMINA_POOL]=1, [Talents.T_STUNNING_BLOW]=1, [Talents.T_DEATH_BLOW]=1 }, + ai_state = { talent_in=1, }, } newEntity{ base = "BASE_NPC_SKELETON", diff --git a/game/modules/tome/data/general/npcs/swarm.lua b/game/modules/tome/data/general/npcs/swarm.lua new file mode 100644 index 0000000000000000000000000000000000000000..ea722f05f94f3cdc00cf031b8fee1b86f57b3eed --- /dev/null +++ b/game/modules/tome/data/general/npcs/swarm.lua @@ -0,0 +1,58 @@ +local Talents = require("engine.interface.ActorTalents") + +newEntity{ + define_as = "BASE_NPC_INSECT", + type = "insect", subtype = "swarms", + display = "I", color=colors.WHITE, + can_multiply = 2, + desc = "Buzzzzzzzzzzzzzzzzzzzzzzzzzzz.", + body = { INVEN = 1 }, + autolevel = "warrior", + ai = "dumb_talented_simple", ai_state = { talent_in=1, }, + stats = { str=1, dex=20, mag=3, con=1 }, + energy = { mod=2 }, + combat_armor = 1, combat_def = 10, +} + +newEntity{ base = "BASE_NPC_INSECT", + name = "midge swarm", color=colors.UMBER, + desc = "A swarm of midges, they want blood.", + level_range = {1, 25}, exp_worth = 1, + rarity = 4, + max_life = resolvers.rngavg(1,2), + combat = { dam=1, atk=15, apr=20 }, +} + +newEntity{ base = "BASE_NPC_INSECT", + name = "bee swarm", color=colors.GOLD, + desc = "They buzz at you threateningly, as you have gotten too close to their hive.", + level_range = {2, 25}, exp_worth = 1, + rarity = 4, + max_life = resolvers.rngavg(1,3), + combat = { dam=2, atk=15, apr=20 }, + + talents = resolvers.talents{ [Talents.T_SPORE_POISON]=1 }, +} + +newEntity{ base = "BASE_NPC_INSECT", + name = "hornet swarm", color=colors.YELLOW, + desc = "You have intruded on their grounds, they will defend it at all costs.", + level_range = {3, 25}, exp_worth = 1, + rarity = 7, + max_life = resolvers.rngavg(3,5), + combat = { dam=5, atk=15, apr=20 }, + + talents = resolvers.talents{ [Talents.T_SPORE_POISON]=2 }, +} + +newEntity{ base = "BASE_NPC_INSECT", + name = "hummerhorn", color=colors.YELLOW, + desc = "A giant buzzing wasp, its stinger drips venom. ", + level_range = {16, 50}, exp_worth = 1, + rarity = 7, + max_life = resolvers.rngavg(5,7), + combat = { dam=10, atk=15, apr=20 }, + can_multiply = 4, + + talents = resolvers.talents{ [Talents.T_SPORE_POISON]=3 }, +} diff --git a/game/modules/tome/data/talents/misc/npcs.lua b/game/modules/tome/data/talents/misc/npcs.lua index d56f88b8d8dc5dde06e4cfa4e8afc7dfd36e6fdb..cf451fb402fe00bd419f574467530c7236c4e46a 100644 --- a/game/modules/tome/data/talents/misc/npcs.lua +++ b/game/modules/tome/data/talents/misc/npcs.lua @@ -205,3 +205,44 @@ newTalent{ return ([[Bites the target, infecting ti with poison.]]) end, } + +newTalent{ + name = "Summon", + type = {"other/other", 1}, + cooldown = 4, + range = 20, + action = function(self, t) + local filters = self.summon or {{type=self.type, subtype=self.subtype, number=1, hasxp=true, lastfor=20}} + if #filters == 0 then return end + local filter = rng.table(filters) + + for i = 1, filter.number do + -- Find space + local x, y = util.findFreeGrid(self.x, self.y, 10, true, {[Map.ACTOR]=true}) + if not x then + game.logPlayer(self, "Not enough space to summon!") + break + end + + -- Find an actor with that filter + local m = game.zone:makeEntity(game.level, "actor", filter) + if m then + if not filter.hasxp then m.exp_worth = 0 end + m:resolve() + + m.summoner = self + m.summon_time = filter.lastfor + + m:move(x, y, true) + game.level:addEntity(m) + m:added() + + game.logSeen(self, "%s summons %s!", self.name:capitalize(), m.name) + end + end + return true + end, + info = function(self) + return ([[Summon allies.]]) + end, +} diff --git a/game/modules/tome/data/talents/techniques/combat-training.lua b/game/modules/tome/data/talents/techniques/combat-training.lua index 51bfdd39799c74dcd6ca4e583fdc6bb8dec7ea2b..07b745df7f529f13bc5203e237834824fdd2f1c7 100644 --- a/game/modules/tome/data/talents/techniques/combat-training.lua +++ b/game/modules/tome/data/talents/techniques/combat-training.lua @@ -89,6 +89,6 @@ newTalent{ require = { stat = { dex=function(level) return 10 + level * 3 end }, }, mode = "passive", info = function(self, t) - return [[Increases damage with knifes.]] + return [[Increases damage with knives.]] end, } diff --git a/game/modules/tome/data/talents/techniques/dualweapon.lua b/game/modules/tome/data/talents/techniques/dualweapon.lua index c1eba16c1ab492b41cefdfc53da81176af844a9e..dafeda4d7c3f031ff9aed7900fd54cfcdf131ef6 100644 --- a/game/modules/tome/data/talents/techniques/dualweapon.lua +++ b/game/modules/tome/data/talents/techniques/dualweapon.lua @@ -118,7 +118,7 @@ newTalent{ return true end, info = function(self, t) - return ([[Lashes out a flurry of blows, hiting your target three times with each weapons for %d%% damage.]]):format(100 * (1.8 + self:getTalentLevel(t) / 10)) + return ([[Lashes out a flurry of blows, hitting your target three times with each weapons for %d%% damage.]]):format(100 * (1.8 + self:getTalentLevel(t) / 10)) end, } @@ -147,7 +147,7 @@ newTalent{ return true end, info = function(self, t) - return ([[Lashes out a flurry of blows, hiting your target three times with each weapons for %d%% damage.]]):format(100 * (1.8 + self:getTalentLevel(t) / 10)) + return ([[Lashes out a flurry of blows, hitting your target three times with each weapons for %d%% damage.]]):format(100 * (1.8 + self:getTalentLevel(t) / 10)) end, } diff --git a/game/modules/tome/data/zones/old-forest/npcs.lua b/game/modules/tome/data/zones/old-forest/npcs.lua index 02f0aa1ca6d5bafaa3e9f4e4dadf8aaff2a71be6..c6483659345ee7776e0da3eef39641deebf40fca 100644 --- a/game/modules/tome/data/zones/old-forest/npcs.lua +++ b/game/modules/tome/data/zones/old-forest/npcs.lua @@ -2,6 +2,7 @@ load("/data/general/npcs/bear.lua") load("/data/general/npcs/vermin.lua") load("/data/general/npcs/wolf.lua") load("/data/general/npcs/snake.lua") +load("/data/general/npcs/swarm.lua") local Talents = require("engine.interface.ActorTalents") diff --git a/game/modules/tome/data/zones/tower-amon-sul/npcs.lua b/game/modules/tome/data/zones/tower-amon-sul/npcs.lua index 54e3da8472a2a979d9d3244c4fa6fbcb18eb43be..0d54782231a1101a2f04bbc01c70fe5e64746cbc 100644 --- a/game/modules/tome/data/zones/tower-amon-sul/npcs.lua +++ b/game/modules/tome/data/zones/tower-amon-sul/npcs.lua @@ -1,8 +1,8 @@ -load("/data/general/npcs/rodent.lua") -load("/data/general/npcs/vermin.lua") -load("/data/general/npcs/molds.lua") +--load("/data/general/npcs/rodent.lua") +--load("/data/general/npcs/vermin.lua") +--load("/data/general/npcs/molds.lua") load("/data/general/npcs/skeleton.lua") -load("/data/general/npcs/snake.lua") +--load("/data/general/npcs/snake.lua") local Talents = require("engine.interface.ActorTalents")