Angband
Functions | Variables
gen-monster.c File Reference

Dungeon monster generation. More...

#include "angband.h"
#include "cave.h"
#include "math.h"
#include "game-event.h"
#include "generate.h"
#include "init.h"
#include "monster.h"
#include "mon-make.h"
#include "mon-spell.h"

Functions

pit_profilelookup_pit_profile (const char *name)
 Return the pit profile matching the given name.
static bool mon_select (monster_race *race)
 This function selects monsters by monster base symbol (may be any of the characters allowed)
bool mon_restrict (const char *monster_type, int depth, bool unique_ok)
 Accept characters representing a race or group of monsters and an (adjusted) depth, and use these to set values for required monster base symbol.
void spread_monsters (struct chunk *c, const char *type, int depth, int num, int y0, int x0, int dy, int dx, byte origin)
 Place monsters, up to the number asked for, in a rectangle centered on y0, x0.
void get_vault_monsters (struct chunk *c, char racial_symbol[], byte vault_type, const char *data, int y1, int y2, int x1, int x2)
 To avoid rebuilding the monster list too often (which can quickly get expensive), we handle monsters of a specified race separately.
void get_chamber_monsters (struct chunk *c, int y1, int x1, int y2, int x2, char *name, int area)
 Funtion for placing appropriate monsters in a room of chambers.

Variables

static bool allow_unique
 Restrictions on monsters, used in pits, vaults, and chambers.
static char base_d_char [15]

Detailed Description

Dungeon monster generation.

Copyright (c) 2013 Nick McConnell, Leon Marrick, Ben Harrison, James E. Wilson, Robert A. Koeneke

This work is free software; you can redistribute it and/or modify it under the terms of either:

a) the GNU General Public License as published by the Free Software Foundation, version 2, or

b) the "Angband licence": This software may be copied and distributed for educational, research, and not for profit purposes provided that this copyright and statement are included in all such copies. Other copyrights may also apply.

Code for selecting appropriate monsters for levels when generated. The intent is to enable easy theming of monsters in sections of the dungeon level, or even whole levels.

Function Documentation

void get_chamber_monsters ( struct chunk c,
int  y1,
int  x1,
int  y2,
int  x2,
char *  name,
int  area 
)

Funtion for placing appropriate monsters in a room of chambers.

Parameters
cthe current chunk being generated
y1
x1
y2
x2the limits of the vault
namethe name of the monster type for use in mon_select()
areathe total room area, used for scaling monster quantity

References ABS, chunk::depth, dun, FALSE, generate_mark(), get_mon_num(), i, mon_restrict(), my_strcpy(), pit_profile::name, one_in_, pick_and_place_monster(), dun_data::pit_type, randint0, set_pit_type(), square_isempty(), TRUE, and void().

Referenced by build_room_of_chambers().

void get_vault_monsters ( struct chunk c,
char  racial_symbol[],
byte  vault_type,
const char *  data,
int  y1,
int  y2,
int  x1,
int  x2 
)

To avoid rebuilding the monster list too often (which can quickly get expensive), we handle monsters of a specified race separately.

Parameters
cthe current chunk being generated
racial_symbolthe allowable monster_base symbols
vault_typethe type of vault, which affects monster selection depth
datathe vault text description, which contains the racial symbol
y1
y2
x1
x2the limits of the vault

References allow_unique, base_d_char, player::depth, FALSE, get_mon_num(), get_mon_num_prep(), i, mon_select(), pick_and_place_monster(), and TRUE.

Referenced by build_vault().

pit_profile* lookup_pit_profile ( const char *  name)

Return the pit profile matching the given name.

Parameters
namethe pit profile name
Returns
the pit profile

References pit_profile::name, pit_profile::next, pit_info, angband_constants::pit_max, profile, streq, and z_info.

Referenced by mon_restrict().

bool mon_restrict ( const char *  monster_type,
int  depth,
bool  unique_ok 
)

Accept characters representing a race or group of monsters and an (adjusted) depth, and use these to set values for required monster base symbol.

Parameters
monster_typethe monster type to be selected, as described below
depththe native depth to choose monsters
unique_okwhether to allow uniques to be chosen
Returns
success if the monster allocation table has been rebuilt

This code has been adapted from Oangband code to make use of monster bases.

This function is called to set restrictions, point the monster allocation function to mon_select() or mon_pit_hook(), and remake monster allocation. It undoes all of this things when called with monster_type NULL. If called with a pit profile name, it will get monsters from that profile. If called with monster_type "random", it will get a random monster base and describe the monsters by its name (for use by cheat_room).

References ABS, allow_unique, base_d_char, monster_race::d_char, player::depth, dun, FALSE, flags, get_mon_num_prep(), i, level, lookup_pit_profile(), mon_pit_hook(), mon_select(), dun_data::pit_type, profile, r_info, angband_constants::r_max, randint1, rf_has, streq, TRUE, and z_info.

Referenced by gauntlet_gen(), get_chamber_monsters(), lair_gen(), modified_gen(), moria_gen(), and spread_monsters().

static bool mon_select ( monster_race race)
static

This function selects monsters by monster base symbol (may be any of the characters allowed)

Parameters
racethe monster race being tested for suitability
Returns
TRUE if the race is accepted

Uniques may be forbidden, or allowed on rare occasions.

This is a hook called as an argument to get_mon_num_prep()

References allow_unique, monster_race::base, base_d_char, monster_base::d_char, player::depth, FALSE, monster_race::flags, randint0, rf_has, and TRUE.

Referenced by get_vault_monsters(), and mon_restrict().

void spread_monsters ( struct chunk c,
const char *  type,
int  depth,
int  num,
int  y0,
int  x0,
int  dy,
int  dx,
byte  origin 
)

Place monsters, up to the number asked for, in a rectangle centered on y0, x0.

Accept values for monster depth, symbol, and maximum vertical and horizontal displacement. Call monster restriction functions if needed.

Parameters
cthe current chunk being generated
typethe type of monster (see comments to mon_restrict())
depthselection depth
numthe number of monsters to try and place - inexact due to groups
y0
x0the centre of the rectangle for monster placement
dy
dxthe dimensions of the rectangle
originthe origin for monster drops

Return prematurely if the code starts looping too much (this may happen if y0 or x0 are out of bounds, or the area is already occupied).

References get_mon_num(), i, chunk::mon_max, mon_restrict(), num, pick_and_place_monster(), rand_spread, square_in_bounds(), square_isempty(), TRUE, and void().

Referenced by gauntlet_gen(), and lair_gen().

Variable Documentation

bool allow_unique
static

Restrictions on monsters, used in pits, vaults, and chambers.

Referenced by get_vault_monsters(), mon_restrict(), and mon_select().

char base_d_char[15]
static