Chaosforge Forum

  • April 25, 2024, 02:04
  • Welcome, Guest
Please login or register.



Login with username, password and session length
Pages: [1]

Author Topic: Sanity check : Special level format  (Read 5450 times)

Kornel Kisielewicz

  • God Hand
  • Apostle
  • *
  • *
  • Offline Offline
  • Posts: 4562
    • View Profile
    • http://chaosforge.org/
Sanity check : Special level format
« 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 :)
Logged
at your service,
Kornel Kisielewicz

chalup

  • Private FC
  • *
  • Offline Offline
  • Posts: 10
    • View Profile
Re: Sanity check : Special level format
« Reply #1 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.
Logged

Kornel Kisielewicz

  • God Hand
  • Apostle
  • *
  • *
  • Offline Offline
  • Posts: 4562
    • View Profile
    • http://chaosforge.org/
Re: Sanity check : Special level format
« Reply #2 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.
Logged
at your service,
Kornel Kisielewicz

Silhar

  • AliensRL Beta Tester
  • Brigadier General
  • *
  • Offline Offline
  • Posts: 667
  • Get psyched!
    • View Profile
Re: Sanity check : Special level format
« Reply #3 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.

Styro

  • Elder
  • Second Lieutenant
  • *
  • *
  • Offline Offline
  • Posts: 166
    • View Profile
Re: Sanity check : Special level format
« Reply #4 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
Logged
Arch-Vile Mjr General
[19/19/12/7/3]

Rola

  • Sergeant
  • *
  • Offline Offline
  • Posts: 91
    • View Profile
Re: Sanity check : Special level format
« Reply #5 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?

Logged

tisiphone

  • Sergeant
  • *
  • Offline Offline
  • Posts: 87
    • View Profile
Re: Sanity check : Special level format
« Reply #6 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 :)
Logged
I want my games for entertainment and escapism, not ethics education, thank you very much.

Kornel Kisielewicz

  • God Hand
  • Apostle
  • *
  • *
  • Offline Offline
  • Posts: 4562
    • View Profile
    • http://chaosforge.org/
Re: Sanity check : Special level format
« Reply #7 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.
Logged
at your service,
Kornel Kisielewicz

Cyber Killer

  • Elder
  • Sergeant
  • *
  • *
  • Offline Offline
  • Posts: 98
  • cyberpunk
    • View Profile
    • CK's site
Re: Sanity check : Special level format
« Reply #8 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.
Logged

Malek Deneith

  • Grand Inquisitor Emeritus
  • Grand Inquisitor
  • Lieutenant General
  • *
  • *
  • Offline Offline
  • Posts: 1256
    • View Profile
Re: Sanity check : Special level format
« Reply #9 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...
Logged
Inquisition - saving your soul, one bolter shell at a time.
Spoiler: "Hackmaster Kills" (click to show/hide)

Kornel Kisielewicz

  • God Hand
  • Apostle
  • *
  • *
  • Offline Offline
  • Posts: 4562
    • View Profile
    • http://chaosforge.org/
Re: Sanity check : Special level format
« Reply #10 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
Logged
at your service,
Kornel Kisielewicz

tisiphone

  • Sergeant
  • *
  • Offline Offline
  • Posts: 87
    • View Profile
Re: Sanity check : Special level format
« Reply #11 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 :)
Logged
I want my games for entertainment and escapism, not ethics education, thank you very much.

Cora

  • Private FC
  • *
  • Offline Offline
  • Posts: 15
    • View Profile
Re: Sanity check : Special level format
« Reply #12 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?
« Last Edit: February 06, 2008, 08:38 by Cora »
Logged
Pages: [1]