| 1 |
================= |
| 2 |
Modifying Angband |
| 3 |
================= |
| 4 |
|
| 5 |
Angband is not just a great game in its own right, it is really easy to modify. |
| 6 |
Much of the detail of the game is contained in text data files. These can be |
| 7 |
changed using nothing more than a text editor for an immediate change to how |
| 8 |
the game works. |
| 9 |
|
| 10 |
These data files are in lib/gamedata. |
| 11 |
|
| 12 |
Each file has a header which describes the lines which make up entries of the |
| 13 |
file, and for the most part this will make it clear what needs to be done to |
| 14 |
make changes to the files. Below is brief description of each of the files. |
| 15 |
|
| 16 |
Those who want to change the game more than is allowed just by varying the |
| 17 |
data files will need the source code. Below the data file descriptions is a |
| 18 |
brief discussion of where to start on such an endeavour. |
| 19 |
|
| 20 |
|
| 21 |
The data files |
| 22 |
============== |
| 23 |
|
| 24 |
constants.txt |
| 25 |
This file contains game values such as carried item capacity, visual range |
| 26 |
and dungeon level and town dimensions. |
| 27 |
|
| 28 |
object_base.txt |
| 29 |
This file contains the names and common properties of the basic object |
| 30 |
classes - scroll, sword, ring, and so on. All objects have an object base. |
| 31 |
Each object base is assigned a 'tval' - a numeric index. The tvals are |
| 32 |
defined in src/list-tvals.h. While adding new object bases is possible, |
| 33 |
it is unlikely to do much without deeper changes to the game. |
| 34 |
|
| 35 |
object.txt |
| 36 |
This file contains the names, properties and description of all the object |
| 37 |
types that appear in Angband. New object kinds can easily be added to this |
| 38 |
file, or existing ones edited. Each object defined by this file has an |
| 39 |
object base, and is also allocated another numeric index called an 'sval'. |
| 40 |
A tval-sval pair completely identifies an object - since the tval and sval |
| 41 |
are saved to savefiles, removing or adding objects is likely to render |
| 42 |
existing save files unusable. |
| 43 |
|
| 44 |
ego_item.txt |
| 45 |
This file contains the names, properties and description of ego items, which |
| 46 |
are magically enhanced weapons and armour. New ego items can be added or |
| 47 |
removed at will, although removing or changing one with an instance currently |
| 48 |
in the game might cause problems. |
| 49 |
|
| 50 |
artifact.txt |
| 51 |
This file contains the names, properties and description of artifacts, which |
| 52 |
are unique items - only one of each will ever be generated. If you are |
| 53 |
considering major changes, new artifacts are one of the most visible signs of |
| 54 |
a change of theme. Regardless, new artifacts are easy and fun to design. |
| 55 |
|
| 56 |
names.txt |
| 57 |
This file contains lists of words which are used to generate names for |
| 58 |
random character names, random artifacts and scrolls. Again, in the case |
| 59 |
of a change of theme, this is a good way of displaying the new theme. |
| 60 |
|
| 61 |
activation.txt |
| 62 |
Activations are used for artifacts and some regular objects, and could be |
| 63 |
used for ego items (although none currently are). Some standard artifacts |
| 64 |
from artifact.txt have activations, and random artifacts may have any |
| 65 |
activation from this file chosen for them. Activations can be made up of |
| 66 |
any effects (see list-effects.h and effect-handler-*something*.c). |
| 67 |
|
| 68 |
flavor.txt |
| 69 |
Items such as potions and wands are assigned a flavor per object kind, |
| 70 |
different in each game. There need to be at least as many flavors for each |
| 71 |
flavored object base as objects with that base. |
| 72 |
|
| 73 |
monster_base.txt |
| 74 |
Monster bases are the monster equivalent of object bases - classes of monster |
| 75 |
like orc, troll or vampire. This file contains the properties common across |
| 76 |
all monsters in each of these classes. |
| 77 |
|
| 78 |
monster.txt |
| 79 |
This contains the detail of all monster races, each of which will have its |
| 80 |
monster base properties plus additional ones. Some monsters are unique, and |
| 81 |
once killed will never reappear. |
| 82 |
|
| 83 |
monster_spell.txt |
| 84 |
All the spells that can be cast by monsters (and are referred to in the |
| 85 |
'spells:' lines in monster.txt) are defined in this file. As with |
| 86 |
activations, monster spells are built up from effects. |
| 87 |
|
| 88 |
pain.txt |
| 89 |
This file contains the various messages that are given to describe how a |
| 90 |
monster responds to attack. |
| 91 |
|
| 92 |
pit.txt |
| 93 |
Dungeon levels can contain pits - rooms full of a particular selection of |
| 94 |
monsters. This file defines these selections. They can also be used, for |
| 95 |
example, to generate partial or complete dungeon levels with themed monsters. |
| 96 |
|
| 97 |
class.txt |
| 98 |
This file completely defines how player classes work, including all details |
| 99 |
of castable spells. There are some class-specific properties hard-coded, |
| 100 |
which are referred to via the 'flags:' lines, and appear in |
| 101 |
list-player-flags.h. |
| 102 |
|
| 103 |
p_race.txt |
| 104 |
This file defines all player race characteristics. Race-specific code is |
| 105 |
handled as for classes. |
| 106 |
|
| 107 |
body.txt |
| 108 |
Every player race has a body, which defines what equipment they can use. |
| 109 |
Currently there is only one body, which all races use, but this is easily |
| 110 |
changeable for significant effect. |
| 111 |
|
| 112 |
history.txt |
| 113 |
This file is for creating the player background found on the character |
| 114 |
screen. If a new race is introduced, a selection of background information |
| 115 |
for it will need to be added. |
| 116 |
|
| 117 |
hints.txt |
| 118 |
This is simply a list of general pieces of advice that shopkeepers will give |
| 119 |
to their customers. |
| 120 |
|
| 121 |
quest.txt |
| 122 |
This file defines the quest monsters (Sauron and Morgoth) and where they |
| 123 |
appear. This currently can't easily be changed, as there are still |
| 124 |
hard-coded aspects of the quests. |
| 125 |
|
| 126 |
terrain.txt |
| 127 |
This file defines the kind of terrain which can appear in Angband, and its |
| 128 |
properties. Current terrain can be changed (with possibly large effects), |
| 129 |
but removing it without code changes is likely to break the game. Adding |
| 130 |
new terrain will have no effect by itself, because there is no mechanism |
| 131 |
for it to appear. |
| 132 |
|
| 133 |
trap.txt |
| 134 |
This defines all traps, door locks and runes. Actual trap effects appear in |
| 135 |
list-effects.h and effect-handler-*something*.c. |
| 136 |
|
| 137 |
room_template.txt |
| 138 |
This is a list of templates for interesting-shaped rooms which appear in the |
| 139 |
dungeon. These can easily be changed and new ones added. |
| 140 |
|
| 141 |
vault.txt |
| 142 |
Similar to room_template.txt, this handles vaults, which are very dangerous |
| 143 |
and lucrative rooms. |
| 144 |
|
| 145 |
dungeon_profile.txt |
| 146 |
This file contains fairly technical details about the different types of |
| 147 |
dungeon level which can be generated. The actual generation routines are in |
| 148 |
gen-cave.c; the information here consists of parameters for generating |
| 149 |
individual levels, and for how often given level types appear. |
| 150 |
|
| 151 |
store.txt |
| 152 |
This details the shop owners and their relative generosity. |
| 153 |
|
| 154 |
blow_effects.txt |
| 155 |
This defines effects to the player caused by monster attacks. The simplest |
| 156 |
monster attacks just deal damage, but others can affect the player's status, |
| 157 |
stats or inventory. |
| 158 |
|
| 159 |
blow_methods.txt |
| 160 |
This details the different ways monsters can attack (hit, claw, etc.). It |
| 161 |
affects the messages the player gets, and also whether the blow can stun |
| 162 |
or cut the player. |
| 163 |
|
| 164 |
brand.txt |
| 165 |
This details how weapon brands work. |
| 166 |
|
| 167 |
slay.txt |
| 168 |
This details how weapons can be more effective against certain monsters. |
| 169 |
|
| 170 |
curse.txt |
| 171 |
This file contains all the different curses that can be applied to objects. |
| 172 |
It includes what type of object they can be applied to, random effects they |
| 173 |
can cause, and how they change an object's properties. |
| 174 |
|
| 175 |
object_property.txt |
| 176 |
This file gives details about what properties an object can have (apart from |
| 177 |
basic combat and armor class). Every property has a code which is used |
| 178 |
in the game to refer to that property in some way. This means it is not |
| 179 |
possible to add new properties to this file and expect to have any effect, |
| 180 |
but it is possible to change how existing properties work. |
| 181 |
|
| 182 |
player_timed.txt |
| 183 |
This file defines some of the properties of timed effects (such as haste and |
| 184 |
confusion) that can apply to the player. It chiefly contains the messages |
| 185 |
on changes in these effects, and player attributes which prevent the effects. |
| 186 |
To add new timed effects or change the way existing ones operate, you will |
| 187 |
have to alter src/list-player-timed.h and probably other files, and |
| 188 |
re-compile the game. |
| 189 |
|
| 190 |
projection.txt |
| 191 |
This file contains a lot of the defining information about projections - |
| 192 |
effects which can be produced at a distance by player or monsters, and |
| 193 |
affecting player, monsters, objects, and/or terrain. In particular, this |
| 194 |
file defines details of the effects of elemental attacks (such as fire or |
| 195 |
shards) and the effectiveness of corresponding player resistance. New |
| 196 |
projections have to be either included in src/list-elements.h (for elemental |
| 197 |
attacks) or included in src/list-projections.h (for all other projections), |
| 198 |
and the code to implement their effects put in other source files - |
| 199 |
src/project-obj.c for effects on objects, and other similarly-named files. |
| 200 |
|
| 201 |
realm.txt |
| 202 |
This contains a small amount of information about the four current magic |
| 203 |
realms. |
| 204 |
|
| 205 |
summon.txt |
| 206 |
This contains definitions for the types of monsters that can be summoned. |
| 207 |
Adding a new summon type is not yet possible, because the summon spells are |
| 208 |
hard-coded in src/list-mon-spells.h. |
| 209 |
|
| 210 |
ui_entry.txt |
| 211 |
Defines entries that will be displayed in the second part of the character |
| 212 |
sheet and in the knowledge menu's equipable comparison. You can modify |
| 213 |
properties in object_property.txt and project_property.txt to bind them to |
| 214 |
those entries. The intent is to make it possible to add or remove a property |
| 215 |
without having to update ui-player.c or ui-equipcmp.c in addition to the |
| 216 |
changes necessary to have that property affect core gameplay. |
| 217 |
|
| 218 |
ui_entry_base.txt |
| 219 |
Provides templates for use by ui_entry.txt. |
| 220 |
|
| 221 |
ui_entry_renderer.txt |
| 222 |
Defines techniques, referenced in ui_entry.txt, for rendering a property in |
| 223 |
the character sheet or equipable comparison. While it is possible to add |
| 224 |
something that simply uses different palettes of symbols or colors than |
| 225 |
one of the current renderers, the basic rendering techniques are hard-coded |
| 226 |
in list-ui-entry-renderers.h. |
| 227 |
|
| 228 |
ui_knowledge.txt |
| 229 |
Handles some configuration of the knowledge menus, namely the layout of |
| 230 |
the monster categories. |
| 231 |
|
| 232 |
Making Graphical Tilesets |
| 233 |
========================= |
| 234 |
|
| 235 |
You can make new graphical tilesets for Angband or customize existing ones. In |
| 236 |
this section we'll dive into how tilesets are defined and describe how to set |
| 237 |
one up from scratch. First, we'll enumerate the steps required and then we'll |
| 238 |
break down each step in detail. |
| 239 |
|
| 240 |
1. Create a directory to contain the tileset's files: (ex. ``lib/tiles/mytileset``) |
| 241 |
2. Register the tileset in ``lib/tiles/list.txt`` |
| 242 |
3. Create an empty bitmap image large enough to hold your tileset |
| 243 |
4. Store the empty bitmap image in your tileset folder |
| 244 |
5. Author one or more ``.prf`` files to inform Angband how to use your tileset |
| 245 |
6. Create a Makefile in your tileset folder |
| 246 |
|
| 247 |
First you need to create a directory to contain your tileset's files. Put the |
| 248 |
directory in lib/tiles and choose a name for the directory that is lower-case |
| 249 |
and generally matches the naming convention of the other tilesets you see |
| 250 |
there. Once the directory has been created, the next step is to decide how big |
| 251 |
the tiles will be in pixels and then create a blank PNG image large enough to |
| 252 |
hold all of the tiles (be sure to enable alpha transparency). As an example, |
| 253 |
Shockbolt's tileset uses 64x64 pixel tiles. It also uses the special alpha |
| 254 |
blending flag so it can use double-height tiles (64x128) for large or tall |
| 255 |
monsters. Its dimensions are 8192x2048 but the tileset is not completely |
| 256 |
full. More tiles can be added without increasing the size of the image as new |
| 257 |
objects are added to future releases of Angband. This should be kept in mind as |
| 258 |
packing your tileset into the smallest possible image size may not be the most |
| 259 |
maintainable solution. Be sure to name the image file after the tile size, for |
| 260 |
example 64x64.png. Use the base size even if you are enabling double-height |
| 261 |
tiles. |
| 262 |
|
| 263 |
The only file you'll need to edit outside of your tileset's directory is |
| 264 |
lib/tiles/list.txt. list.txt contains a registry of which tilesets to load as |
| 265 |
well as some information about the size of the tiles and any special flags to |
| 266 |
set. The format of the file is documented in list.txt's header. Specifically, |
| 267 |
you will be defining the name of the tileset, which directory contains the |
| 268 |
tileset's files, how big the tiles are in pixels (i.e. 64x64), the name of the |
| 269 |
main preference file for the tileset and some additional flags which have to do |
| 270 |
with alpha blending. Not all tilesets need to set extra flags. |
| 271 |
|
| 272 |
Now that the basic setup is complete you need to tell Angband how to interpret |
| 273 |
your tileset image. You need to map each tile in your image to a specific |
| 274 |
element in the game so that Angband knows which tiles to show for which ASCII |
| 275 |
characters. This process can be done incrementally because Angband will |
| 276 |
continue to show the default character symbols in-game for objects that have |
| 277 |
not yet been mapped. This is especially helpful for verifying that your tileset |
| 278 |
has been setup correctly before beginning to map things out in earnest. It also |
| 279 |
means that if new objects are added to the game that you have not mapped into |
| 280 |
your tileset, the game will still be playable with your tileset, albeit the |
| 281 |
displayed ASCII character may appear incongruous with your styling. Mapping |
| 282 |
tiles to game elements is done in text files called preference files which have |
| 283 |
the extension '.prf'. |
| 284 |
|
| 285 |
The first thing to understand about mapping game elements in preference files |
| 286 |
is that everything that can be displayed in the game has a name, or in the case |
| 287 |
of flavors, an ID number. The names for each type of thing can be referenced |
| 288 |
from the data files as mentioned above. The table below is a quick reference |
| 289 |
for where to find names of things and how to form IDs correctly to reference |
| 290 |
them. |
| 291 |
|
| 292 |
============= ================== ==================== |
| 293 |
Type Data File Example |
| 294 |
============= ================== ==================== |
| 295 |
Terrain terrain.txt ``feat:FLOOR`` |
| 296 |
Trap trap.txt ``trap:pit`` |
| 297 |
Object object.txt ``object:light`` |
| 298 |
Monster monster.txt ``monster:Kobold`` |
| 299 |
Spell Effect monster_spell.txt ``GF:METEOR`` |
| 300 |
Player <see below> ``monster:<player>`` |
| 301 |
============= ================== ==================== |
| 302 |
|
| 303 |
Player pictures are referenced differently than other types of objects. They |
| 304 |
use a special query syntax that checks to see what kind class the player is as |
| 305 |
well as the gender in order to determine which picture to show. The query to |
| 306 |
select which tile to show for a female elf ranger would be:: |
| 307 |
|
| 308 |
?:[AND [EQU $CLASS Ranger] [EQU $RACE Elf] [EQU $GENDER Female] ] |
| 309 |
|
| 310 |
Here, the query is checking to see if the player is a female Half-Elf and would |
| 311 |
use the assignment on the next line of the preference file only if this is |
| 312 |
true. |
| 313 |
|
| 314 |
Some types of objects such as terrain can use different tiles based on their |
| 315 |
state. In the case of terrain, the terrain can have different images for when |
| 316 |
it is lit by a torch, or dark. these are selected by appending another colon |
| 317 |
and a specifier to the name. For example, this would be the name of a torch-lit |
| 318 |
up staircase:: |
| 319 |
|
| 320 |
feat:LESS:torch |
| 321 |
|
| 322 |
It is possible to specify the same tile be used for all possible states of a |
| 323 |
terrain feature by using an asterisk. This example identifies any unknown |
| 324 |
terrain tile (a tile the player hasn't lit or otherwise seen yet):: |
| 325 |
|
| 326 |
feat:NONE:* |
| 327 |
|
| 328 |
Given the full name of an object the last thing to do is to specify which tile |
| 329 |
from the tileset to use. Tile locations are given in a coordinate system using |
| 330 |
pairs of hexadecimal numbers. The coordinates start from 0x80:0x80 and |
| 331 |
increment from there. The pairs translate directly to the top and left most |
| 332 |
pixel of the corresponding tile from the graphics file, so the top left pixel |
| 333 |
of the first tile on the top left of the graphics file would be specified as |
| 334 |
0x80:0x80 (the pixel at x:0 y:0). The next tile immediately to the right of the |
| 335 |
that one would be 0x80:0x81. The tilesheet is sliced into rows and columns |
| 336 |
based on the tile size you specified in list.txt. So given a tile size of 64x64 |
| 337 |
pixels, the tile at 0x80:0x81 would be located in the graphics file at pixel |
| 338 |
x:64 y:0. Remember, the coordinates in the preference files are in hexadecimal, |
| 339 |
so the next number after 0x89 would be 0x8A. The next number after 0x8F would |
| 340 |
be 0x90 and so on. To map an object to your tileset you will add one complete |
| 341 |
line to the file per object. This example maps the tile at 0x81:0x81 to the |
| 342 |
terrain feature 'quartz vein' when the quartz vein is lit by torch light:: |
| 343 |
|
| 344 |
feat:QUARTZ:torch:0x81:0x81 |
| 345 |
|
| 346 |
Before going any further, it is advisable to map a single object in your |
| 347 |
preference file, then start the game up, select your tileset and make sure you |
| 348 |
see your mapped tile in game. If this worked, then you are ready to design and |
| 349 |
map the rest of your tiles. A quick example would be to map a tile for your |
| 350 |
home in the town to the first tile position in your graphics file:: |
| 351 |
|
| 352 |
feat:HOME:*:0x80:0x80 |
| 353 |
|
| 354 |
It's possible to have more than one preference file by using a sort of include |
| 355 |
syntax that causes other preference files referenced from your main preference |
| 356 |
file to also be read. It is also possible to place comments in your preference |
| 357 |
files to help you keep track of where different kinds of objects are |
| 358 |
mapped. Any text on a line after a ``#`` symbol is ignored. Shockbolt's tiles |
| 359 |
make great use of this and define a well organized set of mappings using three |
| 360 |
files with comments for each logical section of objects to be mapped:: |
| 361 |
|
| 362 |
# This is a comment |
| 363 |
%:other-stuff.prf # Load another preference file |
| 364 |
|
| 365 |
The last step to take is to make sure your tileset will be packaged with |
| 366 |
Angband when it is compiled for distribution and that it can be installed |
| 367 |
alongside the other tilesets. to do this you will need to add a file called |
| 368 |
'Makefile' to your tileset directory. Copy and paste an existing Makefile from |
| 369 |
one of the other tileset directories and update the DATA and PACKAGE lines to |
| 370 |
match the filenames you chose for your tileset. |
| 371 |
|
| 372 |
Once you have a working tileset and functional understanding of how tilesets |
| 373 |
are managed and organized, it would be a good idea to study Shockbolt's tileset |
| 374 |
and follow the examples there in order to produce a high-quality tileset that |
| 375 |
you will be proud to share with others. |
| 376 |
|
| 377 |
Larger changes |
| 378 |
============== |
| 379 |
|
| 380 |
If changing data files is not enough for you, you will need to change actual |
| 381 |
game code and recompile it. The first place to look is in the compiled data |
| 382 |
files, some of which have already been mentioned: |
| 383 |
|
| 384 |
===================== ========================= ========================= |
| 385 |
list-dun-profiles.h list-mon-temp-flags.h list-rooms.h |
| 386 |
list-effects.h list-mon-timed.h list-room-flags.h |
| 387 |
list-elements.h list-object-flags.h list-square-flags.h |
| 388 |
list-equip-slots.h list-object-modifiers.h list-stats.h |
| 389 |
list-history-types.h list-options.h list-terrain.h |
| 390 |
list-ignore-types.h list-origins.h list-terrain-flags.h |
| 391 |
list-kind-flags.h list-parser-errors.h list-trap-flags.h |
| 392 |
list-message.h list-player-flags.h list-tvals.h |
| 393 |
list-mon-message.h list-player-timed.h list-ui-entry-renderers.h |
| 394 |
list-mon-race-flags.h list-projections.h |
| 395 |
list-mon-spells.h list-randart-properties.h |
| 396 |
===================== ========================= ========================= |
| 397 |
|
| 398 |
Beyond this, you will have to have some knowledge of the C programming |
| 399 |
language, and can start making changes to the way the game runs or appears. |
| 400 |
Many people have done this - there are over 100 variants of Angband: |
| 401 |
http://angbandplus.github.io/AngbandPlus/ |
| 402 |
Should you get to this point, the best thing to do is to discuss your ideas on |
| 403 |
the Angband forums at http://angband.oook.cz. The people there are typically |
| 404 |
keen to hear new ideas and ways to play. |