![]() |
#1 |
Veteran
Join Date: May 2012
Location: Adelaide, Australia
Posts: 2,432
![]() |
Kennels and Other Rooms
This is a dog kennel from fcpb:
Code:
N:Kennel T:ROOM:NORMAL W:10:*:4 L:C:MON(HOUND, DEPTH+5) M:%%%%%%%%%%%%%%%%%%%%% M:%...................% M:%.#################.% M:%.#C#C#C#C#C#C#C#C#.% M:%.#+#+#+#+#+#+#+#+#.% M:%.+...............#.% M:%.#+#+#+#+#+#+#+#+#.% M:%.#C#C#C#C#C#C#C#C#.% M:%.#################.% M:%...................% M:%%%%%%%%%%%%%%%%%%%%% These are room stacks, they actually go up to 6: Code:
N:Room Stack I T:ROOM:NORMAL W:20:*:2 L:M:MON(*, DEPTH+5) L:$:OBJ(*) M:%%%%%%%%%%%%%%%%%%%%%%%%% M:%.......................% M:%.#####################.% M:%.#......M..#..M......#.% M:%.+.....M..$#$..M.....+.% M:%.#......M..#..M......#.% M:%.#####################.% M:%.......................% M:%%%%%%%%%%%%%%%%%%%%%%%%% N:Room Stack II T:ROOM:NORMAL W:20:*:4 L:M:MON(*, DEPTH+5) L:$:OBJ(*) M:%%%%%%%%%%%%%%%%%%%%%%%%% M:%.......................% M:%.+###################+.% M:%.#......M..#..M......#.% M:%.#......M.$#$.M......#.% M:%.#####################.% M:%.#......M.$#$.M......#.% M:%.#......M..#..M......#.% M:%.+###################+.% M:%.......................% M:%%%%%%%%%%%%%%%%%%%%%%%%% Anyway I'm curious if anyone has any thoughts on:
I plan to do the kennel for the reasons above, the rest I'm putting off till I decide whether it's worth it. |
![]() |
![]() |
![]() |
#2 |
Veteran
Join Date: May 2012
Location: Adelaide, Australia
Posts: 2,432
![]() |
Turns out kennels are tricky if you want different layouts & orientations. I'm not sure if this is right:
Code:
/** * Build cells on the north wall. * \param c the current chunk * \param x1 inclusive room boundaries * \param x2 inclusive room boundaries * \param y1 inclusive room boundaries * \param y2 inclusive room boundaries * \param flag the SQUARE_* flag we are marking with */ static void cells_n(struct chunk *c, int x1, int x2, int y1, int y2, int flag) { fill_xrange(c, y2, x1, x2, FEAT_GRANITE, flag, false); fill_yrange(c, x1, y1, y2, FEAT_GRANITE, flag, false); fill_yrange(c, x2, y1, y2, FEAT_GRANITE, flag, false); int x, y; for (y = y1; y <= y2 - 1; y++) { for (x = x1 + 2; x <= x2 - 2; x += 2) { struct loc grid = loc(x, y); square_set_feat(c, grid, FEAT_GRANITE); sqinfo_on(square(c, grid).info, SQUARE_WALL_INNER); } } for (x = x1 + 1; x <= x2 - 1; x += 2) { struct loc grid = loc(x, y1); square_set_feat(c, grid, FEAT_CLOSED); } } |
![]() |
![]() |
![]() |
#3 | |
Adept
Join Date: Aug 2019
Posts: 115
![]() |
Quote:
Declarations within the for() statement itself, Code:
for (int i = ....) |
|
![]() |
![]() |
![]() |
#4 |
Veteran
Join Date: May 2012
Location: Adelaide, Australia
Posts: 2,432
![]() |
Thanks. A lot of this stuff is still confusing to me. I had to go through a bunch of my code & fix some randint0s because I'd messed up. Apparently Randint0(1) is 0 <= x < 1 rather then 0 - 1. Glad I found that out before getting much further. Anway it's working, at least as far as building the rooms, still need to place the occupants. Currently its handling the different layouts with a bunch of if/else & I notice elsewhere in the code its using switch instead. Is there an advantage to switch? Or is this about readability?
Last edited by wobbly; April 4, 2020 at 06:56. |
![]() |
![]() |
![]() |
#5 | |
Adept
Join Date: Aug 2019
Posts: 115
![]() |
Quote:
Both will be awkward with enough separate cases. |
|
![]() |
![]() |
![]() |
#6 |
Knight
Join Date: Apr 2009
Location: Pisa / DL0
Posts: 960
![]() |
Isn't there a compiler warning that can be enabled to catch this? At least in GCC.
__________________
Dive fast, die young, leave a high-CHA corpse. -- You read a scroll labeled 'lol gtfo' of Teleport Level. |
![]() |
![]() |
![]() |
#7 |
Veteran
Join Date: May 2012
Location: Adelaide, Australia
Posts: 2,432
![]() |
Thanks again! Yeah I suspect what ever I do it's going to end up a long list of cases just because it's got a type & an orientation.
Code:
} else if (t == 3) { if (o == 0 ) { cells_n(c, x1 - 1, x2 + 1, y2 - 1, y2 + 1, SQUARE_WALL_SOLID); cells_s(c, x1 - 1, x2 + 1, y1 - 1, y1 + 1, SQUARE_WALL_SOLID); cells_e(c, x1 + 1, x1 + 3, y1 + 3, y2 - 3, SQUARE_WALL_INNER); cells_w(c, x2 - 3, x2 - 1, y1 + 3, y2 - 3, SQUARE_WALL_INNER); cells_monsters_xrange(c, y2, x1, x2, depth, race, zoo); cells_monsters_xrange(c, y1, x1, x2, depth, race, zoo); cells_monsters_yrange(c, x1 + 2, y1 + 4, y2 - 4, depth, race, zoo); cells_monsters_yrange(c, x2 - 2, y1 + 4, y2 - 4, depth, race, zoo); } else { cells_w(c, x1 - 1, x1 + 1, y1 - 1, y2 + 1, SQUARE_WALL_SOLID); cells_e(c, x2 - 1, x2 + 1, y1 - 1, y2 + 1, SQUARE_WALL_SOLID); cells_n(c, x1 + 3, x2 - 3, y1 + 1, y1 + 3, SQUARE_WALL_INNER); cells_s(c, x1 + 3, x2 - 3, y2 - 3, y2 - 1, SQUARE_WALL_INNER); cells_monsters_yrange(c, x1, y1, y2, depth, race, zoo); cells_monsters_yrange(c, x2, y1, y2, depth, race, zoo); cells_monsters_xrange(c, y1 + 2, x1 + 4, x2 - 4, depth, race, zoo); cells_monsters_xrange(c, y2 - 2, x1 + 4, x2 - 4, depth, race, zoo); } |
![]() |
![]() |
![]() |
#8 |
Prophet
Join Date: Apr 2007
Location: Seattle, WA
Posts: 5,982
Donated: $40
![]() |
I disagree with this design. You are breaking code/configuration separation for no apparent reason.
|
![]() |
![]() |
![]() |
#9 |
Veteran
Join Date: May 2012
Location: Adelaide, Australia
Posts: 2,432
![]() |
Well I can potentially rearrange it, but I'm not sure what you actually mean.
|
![]() |
![]() |
![]() |
#10 | |
Prophet
Join Date: Dec 2009
Posts: 9,024
![]() |
Quote:
I can see the appeal of "these rooms are all just variations on each other, we could have a generator that produces the variations", but then you want to be exposing, like, some kind of configuration for the generator so people can still modify its behavior without recompiling. And that all starts to sound like it gets complicated fast... |
|
![]() |
![]() |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Adding color rooms to Angband | droof | Vanilla | 63 | April 8, 2020 11:07 |
Comments on themed level gen part 1 - interesting rooms | wobbly | Vanilla | 9 | November 8, 2018 22:30 |
Angband color rooms | t4nk | Development | 3 | December 10, 2016 02:36 |
Why I love Ironman rooms | Therem Harth | AAR | 0 | April 18, 2012 04:02 |
In what order to explore rooms | fph | Vanilla | 5 | December 7, 2010 18:10 |