Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Vanilla

Reply
 
Thread Tools Display Modes
Old December 6, 2016, 12:37   #1
droof
Apprentice
 
Join Date: Dec 2013
Posts: 71
droof is on a distinguished road
Adding color rooms to Angband

I see Angband has room_template.txt for rooms. Nice! And Angband supports 256 colors in ASCII, got that working too.

Is it possible to use colors for rooms in room_template.txt? Not really for gameplay purposes, but for aesthetics and so I can experiment with room diversity in subtle color gradients aside from architecture and shape?

I think discovering rooms with other subtle gradients might be just as exciting as discovering different shaped rooms and hopefully won't get it the way of gameplay, confuse anyone or be missed when not having colors or using tiles instead.
droof is offline   Reply With Quote
Old December 6, 2016, 16:12   #2
redlumf
Scout
 
Join Date: Aug 2015
Posts: 25
redlumf is on a distinguished road
Quote:
Originally Posted by droof View Post
I see Angband has room_template.txt for rooms. Nice! And Angband supports 256 colors in ASCII, got that working too.
Ummm, 28 colors are defined in code. ( https://github.com/angband/angband/b.../src/z-color.h )
redlumf is offline   Reply With Quote
Old December 6, 2016, 16:27   #3
Derakon
Prophet
 
Derakon's Avatar
 
Join Date: Dec 2009
Posts: 8,313
Derakon is on a distinguished road
Quote:
Originally Posted by redlumf View Post
Ummm, 28 colors are defined in code. ( https://github.com/angband/angband/b.../src/z-color.h )
But they aren't accessible to room templates, because those templates are only able to declare things like walls and doors, not specific types of walls. More generally, Angband "bakes" the color of a wall into information about what kind of wall it is. So a "green wall" would need to be a different wall type from the standard granite wall, and have different stats.

Assuming you were willing to add all these different types of walls that are just cosmetic variations on granite walls, you could probably do what you want right now. But I don't believe there's an easy way otherwise to say "I want a granite wall, but make it a different color".
Derakon is offline   Reply With Quote
Old December 6, 2016, 16:29   #4
t4nk
Swordsman
 
Join Date: May 2016
Posts: 263
t4nk is on a distinguished road
Quote:
And Angband supports 256 colors in ASCII, got that working too.
I don't know what you mean by "ASCII"... ncurses client? That one also depends on the number of color pairs (combinations of font glyph color and background color).

Quote:
Is it possible to use colors for rooms in room_template.txt? Not really for gameplay purposes, but for aesthetics and so I can experiment with room diversity in subtle color gradients aside from architecture and shape?
You mean colors of floor and walls? See lib/gamedata/terrain.txt; note that there is only one sort of floor.

Quote:
Originally Posted by redlumf View Post
Ummm, 28 colors are defined in code
MAX_COLORS is 256 (and a color is uint8_t), so it's possible to define some more.
t4nk is offline   Reply With Quote
Old December 6, 2016, 21:03   #5
droof
Apprentice
 
Join Date: Dec 2013
Posts: 71
droof is on a distinguished road
Yes, I mean the ncurses client. And probably the X11 "text" client too, though the colors are a different shade in X11. Don't both clients use the same color palette?

I was thinking of simply coloring the room, adding different colored light sources for different moods. Like light sources, but hardcoded in room_template.txt so no coding is required.

So I can't define colors for rooms in the text file. And I could add new types of floors and walls, but I'd need to modify the level generation algorithm to be picked up. There's no way around the code

I could think of simple reasons for new colored types of floors and walls. If trees would pass through the dungeon it would have dark brown wooden walls with passable small brown tree roots on the floor. Parts of walls covered with dark green moss and floor with a lighter green moss. Moisty rooms have passable dark blue water puddles or icy light blue floors. Some treasure is found in bright red, blue and green crystals in walls. These are all just color variations of # hashes, . dots and * stars without modifying gameplay. They'd have to be consistent in parts of dungeon levels, not mixed around.

I hope the generation algorithm isn't the most difficult part of the Angband code.
droof is offline   Reply With Quote
Old December 6, 2016, 21:43   #6
t4nk
Swordsman
 
Join Date: May 2016
Posts: 263
t4nk is on a distinguished road
Quote:
Originally Posted by droof View Post
Yes, I mean the ncurses client. And probably the X11 "text" client too, though the colors are a different shade in X11. Don't both clients use the same color palette?
They do it completely differently. Ncurses is (or, rather, terminal emulators are) very limited in many respects. The main difference is that X11 doesn't try to emulate hardware that was already obsolete when dinosaurs ruled the Earth

Quote:
So I can't define colors for rooms in the text file. And I could add new types of floors and walls, but I'd need to modify the level generation algorithm to be picked up. There's no way around the code
This is correct. Currently, Angband doesn't handle that. Looking at code, the main problem is on the line 1824 of gen_room.c:
Code:
    square_set_feat(c, y, x, FEAT_FLOOR);
It just unconditionally marks any empty space as floor, and there is only one kind of floor.
That's not an insurmountable obstacle, but it would indeed require some more code to do what you want. Currently, the template room builder is rather "hardcoded".

Quote:
I could think of simple reasons for new colored types of floors and walls. If trees would pass through the dungeon it would have dark brown wooden walls with passable small brown tree roots on the floor. Parts of walls covered with dark green moss and floor with a lighter green moss. Moisty rooms have passable dark blue water puddles or icy light blue floors. Some treasure is found in bright red, blue and green crystals in walls. These are all just color variations of # hashes, . dots and * stars without modifying gameplay. They'd have to be consistent in parts of dungeon levels, not mixed around.
I actually think thats a great idea. However, Angband's playerbase is in general very conservative. You should be prepared to deal with naysayers
t4nk is offline   Reply With Quote
Old December 6, 2016, 22:50   #7
droof
Apprentice
 
Join Date: Dec 2013
Posts: 71
droof is on a distinguished road
Okay, that's a great starting point.

So gen_room.c:1824 has code: square_set_feat(c, y, x, FEAT_FLOOR);

And cave.c:95 does this: FEAT_FLOOR = lookup_feat("open floor");

I take it that's the hardcoded name of the terrain in terrain.txt?

Then the easiest route would be themed dungeon levels. The default mostly chosen "iron prison" theme, and rare theme levels like a tree theme, moss theme, swamp theme, crystal theme? Each "theme" would use a different predefined set of themed terrain for FEAT_FLOOR, FEAT_GRANITE, FEAT_QUARTZ_K etc defined in terrain.txt.

Not necessarily the best route, this way the theme would be obvious from the first step into the next level. It might be more fun and surprising to discover a rare themed room on a level.

Or going all-out, some levels might have a theme and specific rooms per theme. Rooms have a type, now they're all 1. So there could be other types too? But then I'm probably going into variant territory. Tangband, the themed angband
droof is offline   Reply With Quote
Old December 7, 2016, 00:21   #8
t4nk
Swordsman
 
Join Date: May 2016
Posts: 263
t4nk is on a distinguished road
Now that I think of it, some rough outline of how it could be done:
Struct square (cave.h:132) would get additional member, "byte attr" (actually, it should be uint32_t, but whatever ).
Rooms in room_template.txt (and vaults, I guess) would get a "color map", like so:
Code:
D:%%#%#%%
D:%.(.(.%
D:#(#3#(#
D:%.492.%
D:#(#1#(#
D:%.(.(.%
D:%%#%#%%

C:yyyyyyy
C:yyyyyyy
C:yyyyyyy
C:.......
C:rrrrrrr
C:rrrrrrr
C:rrrrrrr
So that means: top of the room is yellow, bottom is red, and the stripe in the middle is the feature's color as defined in terrain.txt (letters for colors are described in object.txt). Yeah, that would be a pretty awful looking room, but that's just an example
Then the room builder would read the D lines, construct the room, then read the C lines (color map), and apply colors to room's squares.
After that there are just some small enhancements to map_info() and grid_data_as_text(), so that this stuff could be displayed. And also saving/loading functions should be updated to handle colorized terrain.
That doesn't looks like a ton of work... want to do it?
t4nk is offline   Reply With Quote
Old December 7, 2016, 00:56   #9
t4nk
Swordsman
 
Join Date: May 2016
Posts: 263
t4nk is on a distinguished road
And, btw... how are going to handle darkened terrain? (like, squares that are out of LOS and are drawn as grey instead of white). That would require more colors than just the basic ones.
t4nk is offline   Reply With Quote
Old December 7, 2016, 01:33   #10
takkaria
Veteran
 
takkaria's Avatar
 
Join Date: Apr 2007
Posts: 1,849
Donated: $40
takkaria is on a distinguished road
Quote:
Originally Posted by t4nk View Post
And, btw... how are going to handle darkened terrain? (like, squares that are out of LOS and are drawn as grey instead of white). That would require more colors than just the basic ones.
I'd suggest some kind of themeing, where you set triads of colours for unlit/torch/self-lit so that the game can brighten/darken between them.
__________________
"Physician, heal thyself."
takkaria is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Why I love Ironman rooms Therem Harth AAR 0 April 18, 2012 03:02
In what order to explore rooms fph Vanilla 5 December 7, 2010 17:10
Adding a new shop to Angband 3.1.1 Kyle Development 9 October 30, 2010 20:56
Adding Effects to Angband PaulBlay Development 0 March 28, 2009 12:08
3.1.0 beta - minor bug? - green lit floor tiles in prelit rooms vorondil Vanilla 2 January 8, 2009 18:12


All times are GMT +1. The time now is 12:52.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.