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

New random quests: Escorts, you will find them randomly in some zones

git-svn-id: http://svn.net-core.org/repos/t-engine4@1081 51575b47-30f0-44d4-a5cc-537603b46e54
parent e0272fc8
No related branches found
No related tags found
No related merge requests found
......@@ -127,7 +127,7 @@ function _M:newGame()
local quickbirth = save:loadQuickBirth()
save:close()
local birth = Birther.new(self.player, {"base", "difficulty", "world", "race", "subrace", "sex", "class", "subclass" }, function()
local birth; birth = Birther.new(self.player, {"base", "difficulty", "world", "race", "subrace", "sex", "class", "subclass" }, function()
-- Save for quick birth
local save = Savefile.new(self.save_name)
save:saveQuickBirth(self.player.descriptor)
......@@ -150,6 +150,7 @@ function _M:newGame()
self:registerDialog(require("mod.dialogs.IntroDialog").new(self.player))
self.player:resetToFull()
self.player:registerCharacterPlayed()
self.player:onBirth(birth)
end)
end, quickbirth)
self:registerDialog(birth)
......@@ -341,6 +342,8 @@ function _M:changeLevel(lev, zone, keep_old_lev)
self.zone.on_enter(lev, old_lev, zone)
end
self.player:onEnterLevel(self.zone, self.level)
if self.level.data.ambiant_music then
if self.level.data.ambiant_music ~= "last" then
self:playMusic(self.level.data.ambiant_music)
......
......@@ -79,6 +79,29 @@ function _M:init(t, no_default)
self.descriptor = {}
end
function _M:onBirth(birther)
-- Make a list of random escort levels
local race_def = birther.birth_descriptor_def.race[self.descriptor.race]
if race_def.random_escort_possibilities then
local zones = {}
for i, zd in ipairs(race_def.random_escort_possibilities) do for j = zd[2], zd[3] do zones[#zones+1] = {zd[1], j} end end
self.random_escort_levels = {}
for i = 1, 9 do
local z = rng.tableRemove(zones)
print("Random escort on", z[1], z[2])
self.random_escort_levels[z[1]] = self.random_escort_levels[z[1]] or {}
self.random_escort_levels[z[1]][z[2]] = true
end
end
end
function _M:onEnterLevel(zone, level)
-- Fire random escort quest
if self.random_escort_levels and self.random_escort_levels[zone.short_name] and self.random_escort_levels[zone.short_name][level.level] then
self:grantQuest("escort-duty")
end
end
function _M:move(x, y, force)
local moved = mod.class.Actor.move(self, x, y, force)
if moved then
......
......@@ -47,6 +47,7 @@ newBirthDescriptor{
faction = "reunited-kingdom",
type = "humanoid", subtype="human",
},
random_escort_possibilities = { {"trollshaws", 1, 5}, {"tower-amon-sul", 1, 4}, {"carn-dum", 1, 7}, {"old-forest", 1, 7}, {"tol-falas", 1, 8}, {"moria", 1, 1}, {"eruan", 1, 3}, },
}
---------------------------------------------------------
......
......@@ -44,7 +44,7 @@ local name_rules = {
}
local possible_types = {
{ name="lost warrior", random="male",
{ name="lost warrior", random="male", chance=70,
actor = {
type = "humanoid", subtype = "human",
display = "@", color=colors.UMBER,
......@@ -69,7 +69,7 @@ local possible_types = {
reward_type = "warrior",
},
},
{ name="injured seer", random="female",
{ name="injured seer", random="female", chance=70,
actor = {
name = "%s, the injured seer",
type = "humanoid", subtype = "elf", female=true,
......@@ -94,18 +94,18 @@ local possible_types = {
reward_type = "divination",
},
},
{ name="repented thief", random="male",
{ name="repented thief", random="male", chance=70,
actor = {
name = "%s, the repented thief",
type = "humanoid", subtype = "hobbit",
display = "@", color=colors.BLUE,
desc = [[She looks tired and wounded.]],
desc = [[He looks tired and wounded.]],
autolevel = "rogue",
ai = "summoned", ai_real = "escort_quest", ai_state = { talent_in=4, },
stats = { str=8, dex=7, mag=18, con=12 },
body = { INVEN = 10, MAINHAND=1, OFFHAND=1, BODY=1, QUIVER=1 },
resolvers.equip{ {type="weapon", subtype="staff", autoreq=true} },
resolvers.equip{ {type="weapon", subtype="dagger", autoreq=true}, {type="weapon", subtype="dagger", autoreq=true} },
resolvers.talents{ [Talents.T_DIRTY_FIGHTING]=1, },
lite = 4,
rank = 2,
......@@ -119,6 +119,106 @@ local possible_types = {
reward_type = "survival",
},
},
{ name="lone alchemist", random="male", chance=70,
actor = {
name = "%s, the lone alchemist",
type = "humanoid", subtype = "human",
display = "@", color=colors.AQUAMARINE,
desc = [[He looks tired and wounded.]],
autolevel = "rogue",
ai = "summoned", ai_real = "escort_quest", ai_state = { talent_in=4, },
stats = { str=8, dex=7, mag=18, con=12 },
body = { INVEN = 10, MAINHAND=1, OFFHAND=1, BODY=1, QUIVER=1 },
resolvers.equip{ {type="weapon", subtype="staff", autoreq=true} },
resolvers.talents{ [Talents.T_HEAT]=1, },
lite = 4,
rank = 2,
exp_worth = 0,
max_life = 50, life_regen = 0,
life_rating = 6,
combat_armor = 3, combat_def = 3,
inc_damage = {all=-50},
reward_type = "alchemy",
},
},
{ name="lost sun paladin", random="female", chance=70,
actor = {
name = "%s, the lost sun paladin",
type = "humanoid", subtype = "human", female=true,
display = "@", color=colors.GOLD,
desc = [[She looks tired and wounded.]],
autolevel = "warriormage",
ai = "summoned", ai_real = "escort_quest", ai_state = { talent_in=4, },
stats = { str=18, dex=7, mag=18, con=12 },
body = { INVEN = 10, MAINHAND=1, OFFHAND=1, BODY=1, QUIVER=1 },
resolvers.equip{ {type="weapon", subtype="mace", autoreq=true} },
resolvers.talents{ [Talents.T_CHANT_OF_FORTRESS]=1, },
lite = 4,
rank = 2,
exp_worth = 0,
max_life = 50, life_regen = 0,
life_rating = 6,
combat_armor = 3, combat_def = 3,
inc_damage = {all=-50},
reward_type = "sun_paladin",
},
},
{ name="lost anorithil", random="female", chance=70,
actor = {
name = "%s, the lost anorithil",
type = "humanoid", subtype = "human", female=true,
display = "@", color=colors.YELLOW,
desc = [[She looks tired and wounded.]],
autolevel = "caster",
ai = "summoned", ai_real = "escort_quest", ai_state = { talent_in=4, },
stats = { str=8, dex=7, mag=18, con=12 },
body = { INVEN = 10, MAINHAND=1, OFFHAND=1, BODY=1, QUIVER=1 },
resolvers.equip{ {type="weapon", subtype="staff", autoreq=true} },
resolvers.talents{ [Talents.T_HYMN_OF_PERSEVERANCE]=1, },
lite = 4,
rank = 2,
exp_worth = 0,
max_life = 50, life_regen = 0,
life_rating = 6,
combat_armor = 3, combat_def = 3,
inc_damage = {all=-50},
reward_type = "anorithil",
},
},
{ name="worried loremaster", random="female", chance=30,
actor = {
name = "%s, the worried loremaster",
type = "humanoid", subtype = "human", female=true,
display = "@", color=colors.LIGHT_GREEN,
desc = [[She looks tired and wounded.]],
autolevel = "wildcaster",
ai = "summoned", ai_real = "escort_quest", ai_state = { talent_in=4, },
stats = { str=8, dex=7, mag=18, con=12 },
body = { INVEN = 10, MAINHAND=1, OFFHAND=1, BODY=1, QUIVER=1 },
resolvers.equip{ {type="weapon", subtype="staff", autoreq=true} },
resolvers.talents{ [Talents.T_MIND_SEAR]=1, },
lite = 4,
rank = 2,
exp_worth = 0,
max_life = 50, life_regen = 0,
life_rating = 5,
combat_armor = 3, combat_def = 3,
inc_damage = {all=-50},
reward_type = "exotic",
},
},
}
......@@ -168,7 +268,10 @@ end
on_grant = function(self, who)
self.on_grant = nil
self.kind = rng.table(possible_types)
while true do
self.kind = rng.table(possible_types)
if rng.percent(self.kind.chance) then break end
end
local ng = NameGenerator.new(name_rules[self.kind.random])
......@@ -192,8 +295,7 @@ on_grant = function(self, who)
self.kind.actor = nil
-- Spawn the portal, far enough from the escort
-- local gx, gy = getPortalSpot(npc, 150, (game.level.map.w + game.level.map.h) / 2 / 2)
local gx, gy = x+1, y
local gx, gy = getPortalSpot(npc, 150, (game.level.map.w + game.level.map.h) / 2 / 2)
if not gx then return end
local g = mod.class.Grid.new{
show_tooltip=true,
......
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