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

Most zones can now have all existing NPCs, but non-native ones are rare, to...

Most zones can now have all existing NPCs, but non-native ones are rare, to spice things up a little
The scribe in Minas Tirith and Gates of Morning and the Staves & Wands store in Angolwen can now recharge charged objects


git-svn-id: http://svn.net-core.org/repos/t-engine4@943 51575b47-30f0-44d4-a5cc-537603b46e54
parent 010ff58d
No related branches found
No related tags found
No related merge requests found
Showing
with 145 additions and 32 deletions
......@@ -326,7 +326,7 @@ end
-- @param res the table to load into, defaults to a new one
-- @param mod an optional function to which will be passed each entity as they are created. Can be used to adjust some values on the fly
-- @usage MyEntityClass:loadList("/data/my_entities_def.lua")
function _M:loadList(file, no_default, res, mod)
function _M:loadList(file, no_default, res, mod, loaded)
if type(file) == "table" then
res = res or {}
for i, f in ipairs(file) do
......@@ -353,10 +353,15 @@ function _M:loadList(file, no_default, res, mod)
end
if err then error(err) end
loaded = loaded or {}
loaded[f] = true
setfenv(f, setmetatable({
class = self,
loaded = loaded,
resolvers = resolvers,
DamageType = require "engine.DamageType",
entity_mod = mod,
newEntity = function(t)
-- Do we inherit things ?
if t.base then
......@@ -389,10 +394,10 @@ function _M:loadList(file, no_default, res, mod)
if t.define_as then res[t.define_as] = e end
end,
load = function(f, new_mod)
self:loadList(f, no_default, res, new_mod or mod)
self:loadList(f, no_default, res, new_mod or mod, loaded)
end,
loadList = function(f, new_mod)
return self:loadList(f, no_default, nil, new_mod or mod)
return self:loadList(f, no_default, nil, new_mod or mod, loaded)
end,
}, {__index=_G}))
f()
......
......@@ -78,6 +78,7 @@ function _M:useObject(who)
return ret
elseif self.use_talent then
if not self.use_talent.power or self.power >= self.use_talent.power then
self.power = self.power - self.use_talent.power
return self:useTalent(self.use_talent.id, who, self.use_talent.level)
else
if self.power_regen and self.power_regen ~= 0 then
......
-- ToME - Tales of Middle-Earth
-- Copyright (C) 2009, 2010 Nicolas Casalini
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-- Nicolas Casalini "DarkGod"
-- darkgod@te4.org
local function recharge(npc, player)
player:showEquipInven("Select the item to recharge", function(o) return o.recharge_cost and o.power and o.max_power and o.power < o.max_power end, function(o, inven, item)
local cost = math.ceil(o.recharge_cost * (o.max_power / o.use_talent.power))
if cost > player.money then require("engine.Dialog"):simplePopup("Not enough money", "This costs "..cost.." gold.") return true end
require("engine.Dialog"):yesnoPopup("Recharge?", "This will cost you "..cost.." gold.", function(ok) if ok then
o.power = o.max_power
player.money = player.money - cost
player.changed = true
end end)
return true
end)
end
newChat{ id="welcome",
text = [[Welcome @playername@ to my shop.]],
answers = {
{"Let me see your wares.", action=function(npc, player)
npc.store:loadup(game.level, game.zone)
npc.store:interact(player)
end},
{"I want to recharge some of my equipment.", action=recharge},
{"Sorry I have to go!"},
}
}
return "welcome"
-- ToME - Tales of Middle-Earth
-- Copyright (C) 2009, 2010 Nicolas Casalini
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-- Nicolas Casalini "DarkGod"
-- darkgod@te4.org
local loadIfNot = function(f)
if loaded[f] then return end
load(f, entity_mod)
end
-- Load all NPCs anyway but with higher rarity
loadIfNot("/data/general/npcs/ant.lua")
--loadIfNot("/data/general/npcs/aquatic_critter.lua")
--loadIfNot("/data/general/npcs/aquatic_demon.lua")
loadIfNot("/data/general/npcs/bear.lua")
--loadIfNot("/data/general/npcs/bone-giant.lua")
loadIfNot("/data/general/npcs/canine.lua")
loadIfNot("/data/general/npcs/cold-drake.lua")
--loadIfNot("/data/general/npcs/faeros.lua")
loadIfNot("/data/general/npcs/fire-drake.lua")
loadIfNot("/data/general/npcs/ghoul.lua")
loadIfNot("/data/general/npcs/jelly.lua")
loadIfNot("/data/general/npcs/minotaur.lua")
loadIfNot("/data/general/npcs/molds.lua")
--loadIfNot("/data/general/npcs/mummy.lua")
loadIfNot("/data/general/npcs/ooze.lua")
loadIfNot("/data/general/npcs/orc-grushnak.lua")
loadIfNot("/data/general/npcs/orc.lua")
loadIfNot("/data/general/npcs/orc-rak-shor.lua")
loadIfNot("/data/general/npcs/orc-vor.lua")
loadIfNot("/data/general/npcs/plant.lua")
--loadIfNot("/data/general/npcs/ritch.lua")
loadIfNot("/data/general/npcs/rodent.lua")
loadIfNot("/data/general/npcs/sandworm.lua")
loadIfNot("/data/general/npcs/skeleton.lua")
loadIfNot("/data/general/npcs/snake.lua")
loadIfNot("/data/general/npcs/snow-giant.lua")
loadIfNot("/data/general/npcs/spider.lua")
--loadIfNot("/data/general/npcs/sunwall-town.lua")
loadIfNot("/data/general/npcs/swarm.lua")
loadIfNot("/data/general/npcs/thieve.lua")
loadIfNot("/data/general/npcs/troll.lua")
loadIfNot("/data/general/npcs/vampire.lua")
loadIfNot("/data/general/npcs/vermin.lua")
loadIfNot("/data/general/npcs/wight.lua")
loadIfNot("/data/general/npcs/xorn.lua")
......@@ -26,7 +26,7 @@ quickEntity(' ', {name='grass', display='.', color=colors.LIGHT_GREEN, image="te
quickEntity('2', {show_tooltip=true, name="Jewelry", display='2', color=colors.BLUE, resolvers.store("ANGOLWEN_JEWELRY"), image="terrain/wood_store_gem.png"})
quickEntity('4', {show_tooltip=true, name="Alchemist", display='4', color=colors.LIGHT_BLUE, resolvers.store("POTION"), image="terrain/wood_store_potion.png"})
quickEntity('5', {show_tooltip=true, name="Scribe", display='5', color=colors.WHITE, resolvers.store("SCROLL"), image="terrain/wood_store_book.png"})
quickEntity('6', {show_tooltip=true, name="Staves & Wands", display='6', color=colors.RED, resolvers.store("ANGOLWEN_STAFF_WAND"), image="terrain/wood_store_closed.png"})
quickEntity('6', {show_tooltip=true, name="Staves & Wands", display='6', color=colors.RED, resolvers.store("ANGOLWEN_STAFF_WAND"), resolvers.chatfeature("magic-store"), image="terrain/wood_store_closed.png"})
startx = 46
starty = 43
......
......@@ -37,7 +37,7 @@ quickEntity('1', {show_tooltip=true, name="Closed store", display='1', color=col
quickEntity('2', {show_tooltip=true, name="Armour Smith", display='2', color=colors.UMBER, resolvers.store("ARMOR"), image="terrain/wood_store_armor.png"})
quickEntity('3', {show_tooltip=true, name="Weapon Smith", display='3', color=colors.UMBER, resolvers.store("WEAPON"), resolvers.chatfeature("minas-tirith-weapon-store"), image="terrain/wood_store_weapon.png"})
quickEntity('4', {show_tooltip=true, name="Alchemist", display='4', color=colors.LIGHT_BLUE, resolvers.store("POTION"), image="terrain/wood_store_potion.png"})
quickEntity('5', {show_tooltip=true, name="Scribe", display='5', color=colors.WHITE, resolvers.store("SCROLL"), image="terrain/wood_store_book.png"})
quickEntity('5', {show_tooltip=true, name="Scribe", display='5', color=colors.WHITE, resolvers.store("SCROLL"), resolvers.chatfeature("magic-store"), image="terrain/wood_store_book.png"})
quickEntity('6', {show_tooltip=true, name="Closed store", display='6', color=colors.LIGHT_UMBER, block_move=true, block_sight=true, image="terrain/wood_store_closed.png"})
quickEntity('7', {show_tooltip=true, name="Closed store", display='7', color=colors.LIGHT_UMBER, block_move=true, block_sight=true, image="terrain/wood_store_closed.png"})
quickEntity('8', {show_tooltip=true, name="Closed store", display='8', color=colors.LIGHT_UMBER, block_move=true, block_sight=true, image="terrain/wood_store_closed.png"})
......
......@@ -23,6 +23,8 @@ load("/data/general/npcs/molds.lua")
load("/data/general/npcs/mummy.lua")
load("/data/general/npcs/skeleton.lua")
load("/data/general/npcs/all.lua", function(e) if e.rarity then e.rarity = e.rarity * 20 end end)
local Talents = require("engine.interface.ActorTalents")
-- The boss , no "rarity" field means it will not be randomly generated
......
......@@ -19,6 +19,8 @@
load("/data/general/npcs/spider.lua")
load("/data/general/npcs/all.lua", function(e) if e.rarity then e.rarity = e.rarity * 10 end end)
local Talents = require("engine.interface.ActorTalents")
newEntity{ define_as = "UNGOLE", base = "BASE_NPC_SPIDER",
......
......@@ -22,6 +22,8 @@ load("/data/general/npcs/canine.lua", function(e) if e.rarity then e.rarity = e.
load("/data/general/npcs/snow-giant.lua")
load("/data/general/npcs/cold-drake.lua")
load("/data/general/npcs/all.lua", function(e) if e.rarity then e.rarity = e.rarity * 20 end end)
local Talents = require("engine.interface.ActorTalents")
-- The boss of trollshaws, no "rarity" field means it will not be randomly generated
......
......@@ -21,6 +21,8 @@ load("/data/general/npcs/sandworm.lua")
load("/data/general/npcs/ritch.lua")
load("/data/general/npcs/orc.lua")
load("/data/general/npcs/all.lua", function(e) if e.rarity then e.rarity = e.rarity * 20 end end)
local Talents = require("engine.interface.ActorTalents")
newEntity{ define_as = "SUN_PALADIN_GUREN",
......
......@@ -20,6 +20,8 @@
load("/data/general/npcs/orc.lua", function(e) if e.rarity then e.rarity = e.rarity * 3 end e.make_escort = nil end)
load("/data/general/npcs/orc-grushnak.lua")
load("/data/general/npcs/all.lua", function(e) if e.rarity then e.rarity = e.rarity * 20 end end)
local Talents = require("engine.interface.ActorTalents")
newEntity{ base="BASE_NPC_ORC_GRUSHNAK", define_as = "GRUSHNAK",
......@@ -42,7 +44,7 @@ newEntity{ base="BASE_NPC_ORC_GRUSHNAK", define_as = "GRUSHNAK",
ai = "dumb_talented_simple", ai_state = { talent_in=1, ai_move="move_astar", },
body = { INVEN = 10, MAINHAND=1, OFFHAND=1, BODY=1, HEAD=1, FEET=1 },
resolvers.equip{
{type="weapon", subtype="waraxe", ego_change=100, autoreq=true},
{type="armor", subtype="shield", ego_change=100, autoreq=true},
......
......@@ -23,4 +23,6 @@ load("/data/general/npcs/molds.lua")
load("/data/general/npcs/skeleton.lua")
load("/data/general/npcs/snake.lua")
load("/data/general/npcs/all.lua", function(e) if e.rarity then e.rarity = e.rarity * 20 end end)
local Talents = require("engine.interface.ActorTalents")
......@@ -17,29 +17,4 @@
-- Nicolas Casalini "DarkGod"
-- darkgod@te4.org
load("/data/general/npcs/ant.lua")
load("/data/general/npcs/bear.lua")
load("/data/general/npcs/canine.lua")
load("/data/general/npcs/cold-drake.lua")
load("/data/general/npcs/fire-drake.lua")
load("/data/general/npcs/faeros.lua")
load("/data/general/npcs/ghoul.lua")
load("/data/general/npcs/jelly.lua")
load("/data/general/npcs/minotaur.lua")
load("/data/general/npcs/molds.lua")
load("/data/general/npcs/ooze.lua")
load("/data/general/npcs/orc.lua")
load("/data/general/npcs/plant.lua")
load("/data/general/npcs/rodent.lua")
load("/data/general/npcs/sandworm.lua")
load("/data/general/npcs/skeleton.lua")
load("/data/general/npcs/snake.lua")
load("/data/general/npcs/snow-giant.lua")
load("/data/general/npcs/spider.lua")
load("/data/general/npcs/swarm.lua")
load("/data/general/npcs/thieve.lua")
load("/data/general/npcs/troll.lua")
load("/data/general/npcs/vampire.lua")
load("/data/general/npcs/vermin.lua")
load("/data/general/npcs/wight.lua")
load("/data/general/npcs/xorn.lua")
load("/data/general/npcs/all.lua")
......@@ -27,6 +27,8 @@ load("/data/general/npcs/ant.lua")
load("/data/general/npcs/thieve.lua")
load("/data/general/npcs/minotaur.lua")
load("/data/general/npcs/all.lua", function(e) if e.rarity then e.rarity = e.rarity * 20 end end)
local Talents = require("engine.interface.ActorTalents")
-- The boss of the maze, no "rarity" field means it will not be randomly generated
......
......@@ -20,6 +20,8 @@
load("/data/general/npcs/orc.lua")
load("/data/general/npcs/troll.lua")
load("/data/general/npcs/all.lua", function(e) if e.rarity then e.rarity = e.rarity * 20 end end)
local Talents = require("engine.interface.ActorTalents")
-- The boss of Moria, no "rarity" field means it will not be randomly generated
......
......@@ -25,6 +25,8 @@ load("/data/general/npcs/swarm.lua")
load("/data/general/npcs/plant.lua")
load("/data/general/npcs/ant.lua")
load("/data/general/npcs/all.lua", function(e) if e.rarity then e.rarity = e.rarity * 20 end end)
local Talents = require("engine.interface.ActorTalents")
-- The boss of trollshaws, no "rarity" field means it will not be randomly generated
......
......@@ -23,6 +23,8 @@ load("/data/general/npcs/skeleton.lua", function(e) if e.rarity then e.rarity =
load("/data/general/npcs/orc.lua", function(e) if e.rarity then e.rarity = e.rarity * 3 end e.make_escort = nil end)
load("/data/general/npcs/orc-rak-shor.lua")
load("/data/general/npcs/all.lua", function(e) if e.rarity then e.rarity = e.rarity * 20 end end)
local Talents = require("engine.interface.ActorTalents")
newEntity{ base="BASE_NPC_ORC_RAK_SHOR", define_as = "RAK_SHOR",
......
......@@ -23,6 +23,8 @@ load("/data/general/npcs/ooze.lua", function(e) if e.rarity then e.rarity = e.ra
load("/data/general/npcs/jelly.lua", function(e) if e.rarity then e.rarity = e.rarity * 6 end end)
load("/data/general/npcs/sandworm.lua")
load("/data/general/npcs/all.lua", function(e) if e.rarity then e.rarity = e.rarity * 20 end end)
local Talents = require("engine.interface.ActorTalents")
-- They make the tunnels, temporarily
......
......@@ -22,6 +22,8 @@ load("/data/general/npcs/ghoul.lua")
load("/data/general/npcs/wight.lua")
load("/data/general/npcs/vampire.lua")
load("/data/general/npcs/all.lua", function(e) if e.rarity then e.rarity = e.rarity * 20 end end)
local Talents = require("engine.interface.ActorTalents")
-- The boss of Tol Falas, no "rarity" field means it will not be randomly generated
......
......@@ -23,6 +23,8 @@ load("/data/general/npcs/molds.lua")
load("/data/general/npcs/skeleton.lua")
load("/data/general/npcs/snake.lua")
load("/data/general/npcs/all.lua", function(e) if e.rarity then e.rarity = e.rarity * 20 end end)
local Talents = require("engine.interface.ActorTalents")
-- The boss of Amon Sul, no "rarity" field means it will not be randomly generated
......
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