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

events groups

git-svn-id: http://svn.net-core.org/repos/t-engine4@5214 51575b47-30f0-44d4-a5cc-537603b46e54
parent 161025fc
No related branches found
No related tags found
No related merge requests found
......@@ -283,6 +283,16 @@ function table.orderedPairs(t)
return orderedNext, t, nil
end
--- Shuffles the content of a table (list)
function table.shuffle(t)
local n = #t
for i = n, 2, -1 do
local j = rng.range(1, i)
t[i], t[j] = t[j], t[i]
end
return t
end
function string.ordinal(number)
local suffix = "th"
number = tonumber(number)
......
......@@ -1757,13 +1757,29 @@ end
function _M:startEvents()
if not game.zone.events then print("No zone events loaded") return end
local evts = game.zone.events
if not game.zone.assigned_events then
local levels = {}
for i = 1, game.zone.max_level do levels[i] = {} end
-- Generate the events list for this zone, eventually loading from group files
local evts = {}
for i, e in ipairs(game.zone.events) do
if e.name then evts[#evts+1] = e.name
elseif e.group then
local f = loadfile("/data/general/events/groups/"..e..".lua")
setfenv(f, setmetatable({level=game.level, zone=game.zone}, {__index=_G}))
local list = f()
for j, ee in ipairs(list) do
if e.percent_factor and ee.percent then ee.percent = math.floor(ee.percent * e.percent_factor) end
if ee.name then evts[#evts+1] = ee.name end
end
end
end
-- Randomize the order they are checked as
table.shuffle(evts)
for i, e in ipairs(evts) do
-- If we allow it, try to find a level to host it
if e.always or rng.percent(e.percent) then
local lev = nil
if e.one_per_level then
......
-- ToME - Tales of Maj'Eyal
-- Copyright (C) 2009, 2010, 2011, 2012 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
return {
{name="naga-portal", percent=7},
{name="fearscape-portal", percent=7},
}
-- ToME - Tales of Maj'Eyal
-- Copyright (C) 2009, 2010, 2011, 2012 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
return {
{name="damp-cave", percent=10},
}
-- ToME - Tales of Maj'Eyal
-- Copyright (C) 2009, 2010, 2011, 2012 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
return {
{name="tombstones", percent=10},
{name="old-battle-field", percent=5},
}
......@@ -18,6 +18,5 @@
-- darkgod@te4.org
return { one_per_level=true,
{name="naga-portal", percent=10},
{name="fearscape-portal", percent=10},
}
\ No newline at end of file
{group="fareast-generic", percent_factor=1.5},
}
......@@ -18,7 +18,8 @@
-- darkgod@te4.org
return { one_per_level=true,
{name="damp-cave", percent=10},
{name="tombstones", percent=10},
{name="old-battle-field", percent=5},
{group="outdoor-majeyal-gloomy"},
{group="outdoor-majeyal-generic"},
}
\ No newline at end of file
* fearscape invasion portal: demons pouring out: enter the demon gate; end up in orbit on a fearscape bit of land floating in space and destroy the master demon there
* naga invasion portal: nagas pouring out: enter the water portal; end up in a water cave (provide air bubbles) and defeat the naga leader
++ naga invasion portal: nagas pouring out: enter the water portal; end up in a water cave (provide air bubbles) and defeat the naga leader
* 3 pedesrals, stay on each for 3 turns; each time a rare pops; when all 3 dead a portal pops and a randboss pops from it
* 7 neutral cultists are spread on the level with a back stone nearby; when one is killed a timer starts, if all killed before timer is out a stair to a secret cave is revealed with an artifact inside
++ a few tombstones that can be interraced with; if disturbed a random undead (rare or randboss) may pop
......
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