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

mage apprentice quest with a reward for mage (a ring)

and non mages (access to angolwen)


git-svn-id: http://svn.net-core.org/repos/t-engine4@573 51575b47-30f0-44d4-a5cc-537603b46e54
parent c32a6f3f
No related branches found
No related tags found
No related merge requests found
......@@ -100,8 +100,9 @@ function _M:computeRarities(type, list, level, filter)
if e.egos and not level:getEntitiesList(type.."/"..e.egos) then
local egos = self:getEgosList(level, type, e.egos, e.__CLASSNAME)
if egos then
egos = self:computeRarities(type, egos, level, filter)
level:setEntitiesList(type.."/"..e.egos, egos)
local egos_prob = self:computeRarities(type, egos, level, filter)
level:setEntitiesList(type.."/"..e.egos, egos_prob)
level:setEntitiesList(type.."/base/"..e.egos, egos)
end
end
......@@ -167,8 +168,9 @@ end
--- Picks and resolve an entity
-- @return the fully resolved entity, ready to be used on a level. Or nil if a filter was given an nothing found
function _M:makeEntity(level, type, filter)
function _M:makeEntity(level, type, filter, force_level)
resolvers.current_level = self.base_level + level.level - 1
if force_level then resolvers.current_level = force_level end
local list = level:getEntitiesList(type)
local e
......@@ -181,6 +183,8 @@ function _M:makeEntity(level, type, filter)
end
if tries == 0 then return nil end
if filter then e.force_ego = filter.force_ego end
e = self:finishEntity(level, type, e, filter and filter.ego_chance)
return e
......@@ -212,9 +216,20 @@ function _M:finishEntity(level, type, e, ego_chance)
e:resolve()
-- Add "ego" properties, sometimes
if not e.unique and e.egos and e.egos_chance and rng.percent(util.bound(e.egos_chance + (ego_chance or 0), 0, 100)) then
local egos = self:getEgosList(level, type, e.egos, e.__CLASSNAME)
local ego = self:pickEntity(egos)
if not e.unique and e.egos and (e.force_ego or (e.egos_chance and rng.percent(util.bound(e.egos_chance + (ego_chance or 0), 0, 100)))) then
local ego
if not e.force_ego then
local egos = level:getEntitiesList(type.."/"..e.egos)
ego = self:pickEntity(egos)
else
local name = e.force_ego
if _G.type(name) == "table" then name = rng.table(name) end
print("Forcing ego", name)
local egos = level:getEntitiesList(type.."/base/"..e.egos)
ego = egos[name]
e.force_ego = nil
end
if ego then
print("ego", ego.__CLASSNAME, ego.name, getmetatable(ego))
ego = ego:clone()
......
......@@ -66,24 +66,27 @@ function _M:use()
print("[CHAT] selected", a[1], a.action, a.jump)
if a.jump then
self.cur_id = a.jump
self:generateList()
self.sel = 1
self.scroll = 1
self:regen()
else
game:unregisterDialog(self)
end
if a.action then
local id = a.action(self.npc, self.player)
local id = a.action(self.npc, self.player, self)
if id then
self.cur_id = id
self:generateList()
self.sel = 1
self.scroll = 1
self:regen()
return
end
end
end
function _M:regen()
self.changed = true
self:generateList()
self.sel = 1
self.scroll = 1
end
function _M:generateList()
-- Makes up the list
local list = {}
......
......@@ -27,7 +27,8 @@ _M.quest_class = "engine.Quest"
--- Grants a quest to an actor from the given quest definition
function _M:grantQuest(quest)
if type(quest) == "string" then
local f = loadfile("/data/quests/"..quest..".lua")
local f, err = loadfile("/data/quests/"..quest..".lua")
if not f and err then error(err) end
local ret = {}
setfenv(f, setmetatable(ret, {__index=_G}))
f()
......@@ -52,6 +53,7 @@ end
function _M:setQuestStatus(quest, status, sub)
print("[QUEST] try update status on", self.name, quest, status, sub)
if not self.quests then return end
if type(quest) == "table" then quest = quest.id end
local q = self.quests[quest]
if not q then return end
if q:setStatus(status, sub, self) then
......@@ -69,6 +71,7 @@ end
-- If the actor does not have the quest, does nothing
function _M:isQuestStatus(quest, status, sub)
if not self.quests then return end
if type(quest) == "table" then quest = quest.id end
local q = self.quests[quest]
if not q then return end
return q:isStatus(status, sub)
......
......@@ -22,7 +22,21 @@ newChat{ id="welcome",
Good day to you fellow traveller!]],
answers = {
{"What brings an apprentice mage in the wilds?", jump="quest", cond=function(npc, player) return not player:hasQuest("mage-apprentice") end},
{"I have a staff for you!", jump="offer", cond=function(npc, player) return player:hasQuest("mage-apprentice") and player:hasQuest("mage-apprentice"):can_offer(player) end},
{"I have a staff for you!",
jump="welcome",
cond=function(npc, player) return player:hasQuest("mage-apprentice") and player:hasQuest("mage-apprentice"):can_offer(player) end,
action=function(npc, player, dialog) player:hasQuest("mage-apprentice"):collect_staff(player, dialog) end
},
-- Reward for non-mages: access to Angolwen
{"So you have enough staves now?",
jump="thanks",
cond=function(npc, player) return player:hasQuest("mage-apprentice") and player:hasQuest("mage-apprentice"):isCompleted() and player.descriptor.class ~= "Mage" end,
},
-- Reward for mages: upgrade a talent mastery
{"So you have enough staves now?",
jump="thanks_mage",
cond=function(npc, player) return player:hasQuest("mage-apprentice") and player:hasQuest("mage-apprentice"):isCompleted() and player.descriptor.class == "Mage" end,
},
-- {"Do you have any items to sell?", jump="store"},
{"Sorry I have to go!"},
}
......@@ -39,7 +53,8 @@ newChat{ id="quest2",
text = [[Well if you insist...
I am a novice mage, as you might have noticed, and my goal is to be accepted by the elves of Angolwen to be taugth the secrets of the arcane.]],
answers = {
{"Who are the elves of Angolwen?", jump="quest3"},
{"Who are the elves of Angolwen?", jump="quest3", cond=function(npc, player) return player.descriptor.class ~= "Mage" end,},
{"Ah yes Angolwen, this place I called home for many years...", jump="quest3_mage", cond=function(npc, player) return player.descriptor.class == "Mage" end,},
{"Well good luck, bye!"},
}
}
......@@ -51,11 +66,41 @@ Anyway, I must collect 15 magic staves and I have yet to find one. If you could
{"No way, bye!"},
}
}
newChat{ id="quest3_mage",
text = [[I hope I will too ...
Anyway, I must collect 15 magic staves and I have yet to find one. If you could bring me some should you find any, I would be grateful]],
answers = {
{"I will keep that in mind", action=function(npc, player) player:grantQuest("mage-apprentice") end},
{"No way, bye!"},
}
}
newChat{ id="thanks",
text = [[Ah yes! I am so glad! I will be able to go back to Angolw..err. Oh well I just I can tell you, you deserve it for helping me.
During the late years of Sauron, more than one hundred years ago, Gandalf the Grey worried that magic could disappear with him and would be lost to mortals should they need it again.
So he set a secret plan into action and taught a small group of elves and men into its usage with a specific task: to build a secret place where magic would be kept alive.
His plan worked and the group built a town called Angolwen in the Blue Mountains #LIGHT_GREEN#*he marks it on your map, along with a portal to access it*#WHITE#.
Not many people are accepted there but I will arrange for you to be allowed inside.]],
answers = {
{"Oh! How could such a place be kept secret for so long.. This is interresting indeed, thanks for your trust.",
action = function(npc, player)
player:hasQuest("mage-apprentice"):access_angolwen()
npc:die()
end,
},
}
}
newChat{ id="offer",
text = [[Thank you!]],
newChat{ id="thanks_mage",
text = [[Ah yes! I am so glad! I will be able to go back to Angolwen now, maybe we will meet there.
Oh and take this ring, it has served me well.]],
answers = {
{"Bye!"},
{"Thanks, and best luck for you studies!",
action = function(npc, player)
player:hasQuest("mage-apprentice"):ring_gift(player)
npc:die()
end,
},
}
}
......
......@@ -168,7 +168,7 @@ newEntity{
inc_stats = { [Stats.STAT_DEX] = resolvers.mbonus(8, 2) },
},
}
newEntity{
newEntity{ define_as = "RING_MAGIC",
name = " of magic (#STATBONUS#)",
level_range = {1, 50},
rarity = 6,
......@@ -197,7 +197,7 @@ newEntity{
inc_damage = { [DamageType.PHYSICAL] = resolvers.mbonus(15, 5) },
},
}
newEntity{
newEntity{ define_as = "RING_ARCANE_POWER",
name = " of arcane power (#DAMBONUS#)",
level_range = {6, 50},
rarity = 4,
......@@ -206,7 +206,7 @@ newEntity{
inc_damage = { [DamageType.ARCANE] = resolvers.mbonus(15, 5) },
},
}
newEntity{
newEntity{ define_as = "RING_BURNING",
name = " of burning (#DAMBONUS#)",
level_range = {6, 50},
rarity = 4,
......@@ -215,7 +215,7 @@ newEntity{
inc_damage = { [DamageType.FIRE] = resolvers.mbonus(15, 5) },
},
}
newEntity{
newEntity{ define_as = "RING_FREEZING",
name = " of freezing (#DAMBONUS#)",
level_range = {6, 50},
rarity = 4,
......@@ -224,7 +224,7 @@ newEntity{
inc_damage = { [DamageType.COLD] = resolvers.mbonus(15, 5) },
},
}
newEntity{
newEntity{ define_as = "RING_NATURE_BLESSING",
name = " of nature's blessing (#DAMBONUS#)",
level_range = {6, 50},
rarity = 4,
......@@ -233,7 +233,7 @@ newEntity{
inc_damage = { [DamageType.NATURE] = resolvers.mbonus(15, 5) },
},
}
newEntity{
newEntity{ define_as = "RING_BLIGHT",
name = " of blight (#DAMBONUS#)",
level_range = {6, 50},
rarity = 4,
......@@ -242,7 +242,7 @@ newEntity{
inc_damage = { [DamageType.BLIGHT] = resolvers.mbonus(15, 5) },
},
}
newEntity{
newEntity{ define_as = "RING_SHOCK",
name = " of shock (#DAMBONUS#)",
level_range = {6, 50},
rarity = 4,
......@@ -251,7 +251,7 @@ newEntity{
inc_damage = { [DamageType.LIGHTNING] = resolvers.mbonus(15, 5) },
},
}
newEntity{
newEntity{ define_as = "RING_CORROSION",
name = " of corrosion (#DAMBONUS#)",
level_range = {6, 50},
rarity = 4,
......
game/modules/tome/data/gfx/terrain/grass_teleport.png

965 B

......@@ -85,7 +85,7 @@ return [[
======........bb...h........._vvv.hh...._.._...mm.....~..uuuuuuuu...._......_....................tt
=====E........bb............._.v...h...._._..mmmmm..._~..uuuuuuuu....._......_..................ttt
=====.........bb............._........._.._..mmmm____.~~.uuuuuuuu......_.._._..................tttt
======........bb...Cb......._.........._._...mmmm.....~~.uuuuu.u........._.._.................ttttt
======.......bbb...Cb......._.........._._...mmmm.....~~.uuuuu.u........._.._.................ttttt
=======.....ubbb..bbbb....._..........._....mmmmm....~~...uuuu.............._...............ttttttt
==========..ubbbu........._..........._.....mmmm.....~~...uuuu..............._...._.......ttttttttt
==========..uuubbubb....._........____.....hmmmm....~~....uuuuuuu............._.__._ ...ttttttttttt
......
......@@ -29,24 +29,64 @@ desc = function(self, who)
return table.concat(desc, "\n")
end
on_status_change = function(self, who, status, sub)
if self:isCompleted() then
end
end
on_grant = function(self, who)
self.nb_collect = 0
self.nb_collect = 14
end
collect_staff = function(self, who, o)
self.nb_collect = self.nb_collect + 1
if self.nb_collect > 15 then who:setQuestStatus(self, self.COMPLETED) end
collect_staff = function(self, who, dialog)
who:showEquipInven("Offer which staff?",
function(o) return o.type == "weapon" and o.subtype == "staff" end,
function(o, inven, item)
self.nb_collect = self.nb_collect + 1
if self.nb_collect >= 15 then who:setQuestStatus(self, self.COMPLETED) end
who:removeObject(who:getInven(inven), item)
game.log("You have no more %s", o:getName{no_count=true, do_color=true})
who:sortInven(who:getInven(inven))
dialog:regen()
return true
end
)
end
can_offer = function(self, who)
if self.nb_collect >= 15 then return end
for inven_id, inven in pairs(who.inven) do
for item, o in ipairs(inven) do
if o.type == "weapon" and o.subtype == "staff" then return true end
end
end
end
access_angolwen = function(self)
local g = mod.class.Grid.new{
show_tooltip=true,
name="Angolwen, the hidden city of magic",
desc="Secret place of magic, set apart from the world to protect it.",
display='*', color=colors.WHITE, image="terrain/town1.png",
notice = true,
change_level=1, change_zone="town-angolwen"
}
local p = mod.class.Grid.new{
show_tooltip=true,
name="Portal to Angolwen",
desc="The city of magic lies inside the mountains to the west, either a spell or a portal is needed to access it.",
display='*', color=colors.VIOLET, image="terrain/grass_teleport.png",
notice = true,
change_level=1, change_zone="town-angolwen"
}
g:resolve() g:resolve(nil, true)
p:resolve() p:resolve(nil, true)
game.zone:addEntity(game.level, g, "terrain", 14, 27)
game.zone:addEntity(game.level, p, "terrain", 16, 27)
end
ring_gift = function(self, player)
local o = game.zone:makeEntity(game.level, "object", {type="jewelry", subtype="ring", force_ego={"RING_ARCANE_POWER","RING_BURNING","RING_FREEZING","RING_SHOCK","RING_MAGIC"}}, player.level + 3)
if o then
o:identify(true)
player:addObject(player.INVEN_INVEN, o)
game.zone:addEntity(game.level, o, "object")
game.logPlayer(player, "You receive: %s", o:getName{do_color=true})
end
end
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