Modding:Tutorial/Building an Episode/Source

From DoomRL Wiki

Revision as of 04:58, 25 January 2012 by Game Hunter (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
-- module.lua
 
module = {
    id = "classic",
    name = "Classic Mode",
    author = "Kornel Kisielewicz",
    webpage = "http://chaosforge.org/",
    version = {0,2,0},
    drlver = {0,9,9,5},
    type = "episode",
    description = "Episodic MOD example.",
    difficulty = true,
}
-- main.lua
 
core.declare( "classic", {} )
 
require "classic:data/phobos_arena"
 
function classic.OnMortemPrint(killedby)
    if killedby == "defeated the Mastermind" then
        killedby = "defeated the Cyberdemon"
    elseif killedby == nil then
        killedby = "played through the classics"
    end
    player:mortem_print( " "..player.name..", level "..player.explevel.." "..klasses[player.klass].name..", "..killedby )
end
 
function classic.OnCreateEpisode()
	local BOSS_LEVEL = 10
	player.episode = {}
 
	player.episode[1]     = { style = 1, script = "intro" }
	for i=2,BOSS_LEVEL-1 do
		player.episode[i] = { style = 1, number = i, name = "Phobos", danger = i}
	end
	player.episode[10]    = { style = 3, script = "phobos_arena" }
 
	statistics.bonus_levels_count = 0
end
 
function classic.OnGenerate()
	Generator.reset()
	Generator.generate_tiled_dungeon()
end
 
function classic.OnWinGame()
	ui.plot_screen([[
Once you beat the Cyberdemon and clean out the moon
base you're supposed to win, aren't you? Aren't you?
Where's your fat reward and ticket back home? What
the hell is this? It's not supposed to end this way!
 
It stinks like rotten meat but it looks like the
lost Deimos base. Looks like you're stuck on
The Shores of Hell. And the only way out is through...
]])
end
-- phobos_arena.lua
 
Levels("phobos_arena",{
  name = "Phobos Arena",
  entry = "Then at last he found the Phobos Arena!",
  welcome = "You enter a big arena. There's blood everywhere. You hear heavy mechanical footsteps...",
 
  Create = function ()
    Level.fill("wall")
    Level.fill("floor", area.FULL_SHRINKED )
    local scatter_area = area.new( 5,3,68,15 )
    local translation = {
        ['.'] = "blood",
        ['#'] = "gwall",
        ['>'] = "stairs",
    }
    Level.scatter_put(scatter_area,translation, [[
      .....
      .###.
      .###.
      .###.
      .....
    ]],"floor",12)
 
    Level.flags[ LF_NOHOMING ] = true
    Level.scatter(area.FULL_SHRINKED,"floor","blood",100)
    Generator.set_permanence( area.FULL )
    player.flags[ BF_ENTERBOSS1 ] = true
  end,
 
  OnEnter = function ()
    local boss = Level.summon("cyberdemon")
    boss.flags[ BF_BOSS ] = true
  end,
 
})
Personal tools