Chaosforge Forum

DoomRL => Discussion => Topic started by: Kornel Kisielewicz on January 29, 2008, 06:15

Title: Sanity check : Special level format
Post by: Kornel Kisielewicz on January 29, 2008, 06:15
Modding is steadily on it's way. I plan to make it as painless as possible. As a teaser, and sanity check, I post here the complete code for Halls of Carnage. Please comment on it... is it readable? What could be done better?

Code: (lua) [Select]

Levels("SPEC2",{
  name = "Halls of Carnage",
  entry = "On level @1 he ventured into the Halls of Carnage.",
  welcome = "Suddenly you feel a lust for blood...",
  level = {11,14},

  Create = function ()
    Level.fill(CELL_PRWALL)
    Level.tile(".",CELL_FLOOR)
    Level.tile("W",CELL_PRWALL)
    Level.tile("X",CELL_RWALL)
    Level.tile("#",CELL_WALL)
    Level.tile("%",CELL_BWALL)
    Level.tile(",",CELL_BLOOD)
    Level.tile("+",CELL_DOOR)
    Level.tile(">",CELL_STAIRS)
    Level.tile("3",CELL_FLOOR,{ being = NPC_SEREGANT })
    Level.tile("5",CELL_FLOOR,{ being = NPC_IMP })
    Level.tile("7",CELL_FLOOR,{ being = NPC_SKULL })
    Level.tile("6",CELL_FLOOR,{ being = NPC_DEMON })
    Level.tile("8",CELL_FLOOR,{ being = NPC_CACODEMON })
    Level.tile("9",CELL_FLOOR,{ being = NPC_BARON })

    if DIFFICULTY == 1 then
      Level.tile("8",CELL_FLOOR,{ being = NPC_DEMON })
      Level.tile("9",CELL_FLOOR,{ being = NPC_CACODEMON})
    end
    if DIFFICULTY > 2 then
      Level.tile("8",CELL_FLOOR,{ being = NPC_KNIGHT })
    end
    if DIFFICULTY > 3 then
      Level.tile("7",CELL_FLOOR,{ being = NPC_CACODEMON })
    end


    Level.tile("Z",CELL_FLOOR,{ item = ITEM_AMMO })
    Level.tile("!",CELL_FLOOR,{ item = ITEM_BFG9000 })
    Level.tile("^",CELL_FLOOR,{ item = ITEM_SCGLOBE })
    Level.tile("=",CELL_LAVA)
    Level.tile("|",CELL_FLOOR,{ item = ITEM_ROCKET })
    Level.tile("[",CELL_LDOOR)
   
    Level.put(2,2,{
      ".................................#.|..|..|.#...#..===..X.......6............",
      "........................................3..%...#,.===7.X..XXXXXXXXX.XXXXXXX.",
      "...#%%##+##........#...###%%##...........,,%...[,.===..[..X.........6.......",
      "...#.,,...#........#.......,,#..........,,,#...#,.===..X..X.XXXX.XXXXXXXX.X.",
      "...#..........3....#.3.......#...#####+#%%##...#..===..X..X6X.8.........X.X.",
      "...+...............#.........#.................#..===..X..X.X.XXXXXXX.X.X.X.",
      "...#,..3...........+...,,,...#.........#.......#.7===..X..X.X.X...9...X...X6",
      "...#%#........######..#%%##............#...#...#,.===..X..X.X.X.WWWWW.X.X.X|",
      ".,,,..................#......#......3.,%...#...[,.=^=..[..X.X.X.W|!|W.X.X..^",
      "......................#...,,.%.......,,%...%,..#,.===..X6.X.X.X.W...W.X.X.X|",
      "...##%%+######........#..3,,,%......,,.#..,%,..#..===..X..X.X.X.W[WWW.X.X.X.",
      "...#..,......+...........,,..#...##%%%##...%...#..===..X..X.X.X.....9.X...X.",
      "...#......,3.#..........##%%%#.............#...#,.===7.X..X.X.XXXXXXXXX.X...",
      "...#.....##%%#........................######...[,.===..[..X.X8.......8..X.X.",
      "......................................#........#,.===..X..X.XXXXXX.XXXXXX.X.",
      ".,,######..........####%%%##+###......+...3....#.7===..X..X6..............X6",
      ".,,+^|..#......3...#,,,,,.3...........#........#..===..X..XXXXX.XXXXX.XXXXX.",
      ".,,#>|..#..........#.,,,................3......#..===..X.........6..........",
    })
    Level.visited(3)
    Level.player(8,18)
  end,
})


Ask about anything you want :)
Title: Re: Sanity check : Special level format
Post by: chalup on January 29, 2008, 06:29
All is clear except for some magical entries like:
Code: [Select]
level = {11,14},
Level.visited(3)
Level.player(8,18)
Level.put(2,2,
I suppose that {11,14} means that stairs to this level can appear as a special level between 11th and 14th phobos base level, but i have no clue about other three.
Title: Re: Sanity check : Special level format
Post by: Kornel Kisielewicz on January 29, 2008, 06:35
Yeah, level is the level range.

Level.visited will be removed and replaced with something more readable -- it is a legacy feature for handling the level found info in the beginning of the mortem.

Level.player(8,18) places the player at x=8, y=18 :P

Level.put(2,2, means that the following map will be placed at x=2, y=2.
Title: Re: Sanity check : Special level format
Post by: Silhar on January 29, 2008, 06:56
Seems clear enough, even for someone who doesn't know how to program...
About making modding easier, right now nothing comes to my head.
Title: Re: Sanity check : Special level format
Post by: Styro on January 29, 2008, 10:21
Looks great! It is very easy to understand.

I am really looking forward to the mod ability. I want to try making an X-Com based mod using the DoomRL engine. :D
Title: Re: Sanity check : Special level format
Post by: Rola on January 29, 2008, 10:29
Well, comments always make reading code easier... that's why programmers never add them: removing the aura of obscurity would make them look less omnipotent in the eyes of the users... ;)

I infer that the top and bottom walls are never present in the editor but added automatically by game?

My guesswork:
CELL_BWALL - b...loody wall? ? ?
CELL_RWALL - red wall?
CELL_PRWALL - permament (indestructible) wall?

PS: Kornel, did you get my PM?

Title: Re: Sanity check : Special level format
Post by: tisiphone on January 29, 2008, 15:34
Very nice! I recon I got the gist of it, more or less. As for suggestion for improvements... It would be good to have a table of reference to know just what CELL_whatever means. Also some things could be made a bit clearer. Like, for example, level could be enterlevel or something.
Anyway, it’s looking good :)
Title: Re: Sanity check : Special level format
Post by: Kornel Kisielewicz on January 29, 2008, 15:36
Well, there's no need for a reference -- if you make a cell with ID = "floor", you'll have CELL_FLOOR defined :). Of course I'll publish the current cells along with it.
Title: Re: Sanity check : Special level format
Post by: Cyber Killer on January 29, 2008, 20:27
@Rola: it's said, that "if your code requires comments to be understandable, rewrite it so that it doesn't" :-)

as for the code it's quite cool. the Level.put() with the need to draw the whole level in ASCII looks frightening though, but I can't come up with anything more useful right now.
Title: Re: Sanity check : Special level format
Post by: Malek Deneith on January 30, 2008, 04:01
One question - what are the " signs along left and right boarder of the map - they aren't defined anywhere as cells... same for ' signs that appear in some places...
Title: Re: Sanity check : Special level format
Post by: Kornel Kisielewicz on January 30, 2008, 04:30
the " signs are language parts a "blah" is a string of content blah. Each string represents a separate map line. As for the ' signs I think you mistook them for , signs, and those are defined :P

Ah come on, that's basic programming Malek :P
Title: Re: Sanity check : Special level format
Post by: tisiphone on January 31, 2008, 15:01
Well, there's no need for a reference -- if you make a cell with ID = "floor", you'll have CELL_FLOOR defined :). Of course I'll publish the current cells along with it.
Heh, well that just went over of my head...
Em, I’m just going to take your word for it :)
Title: Re: Sanity check : Special level format
Post by: Cora on February 05, 2008, 16:07
very edible)
thnx

anyway, will world see a complete manual?
heh... and what about AI modification? scripting? SDF variables? console.writeln?