Crossfire Server, Branches 1.12
R18729
|
Go to the source code of this file.
Data Structures | |
struct | free_spots_struct |
Macros | |
#define | CONCENTRATED 1 /* all the treasure is at the C's for onions. */ |
#define | DOORED 8 /* treasure has doors around it. */ |
#define | FILLED 128 /* Fill/tile the entire map with treasure */ |
#define | HIDDEN 2 /* doors to treasure are hidden. */ |
#define | KEYREQUIRED 4 /* chest has a key, which is placed randomly in the map. */ |
#define | LAST_OPTION 64 /* set this to the last real option, for random */ |
#define | NO_PASS_DOORS 0 |
#define | PASS_DOORS 1 |
#define | RICH 64 /* 2x as much treasure as default */ |
#define | SPARSE 32 /* 1/2 as much treasure as default */ |
#define | TRAPPED 16 /* trap dropped in same location as chest. */ |
Typedefs | |
typedef struct free_spots_struct | free_spots_struct |
Functions | |
static object * | door_in_square (mapstruct *map, int x, int y) |
object * | find_closest_monster (mapstruct *map, int x, int y, RMParms *RP) |
object ** | find_doors_in_room (mapstruct *map, int x, int y, RMParms *RP) |
void | find_doors_in_room_recursive (char **layout, mapstruct *map, int x, int y, object **doorlist, int *ndoors, RMParms *RP) |
void | find_enclosed_spot (mapstruct *map, int *cx, int *cy, RMParms *RP) |
object * | find_monster_in_room (mapstruct *map, int x, int y, RMParms *RP) |
object * | find_monster_in_room_recursive (char **layout, mapstruct *map, int x, int y, RMParms *RP) |
int | find_spot_in_room (mapstruct *map, int x, int y, int *kx, int *ky, RMParms *RP) |
static void | find_spot_in_room_recursive (char **layout, int x, int y, RMParms *RP, free_spots_struct *spots) |
int | keyplace (mapstruct *map, int x, int y, char *keycode, int door_flag, int n_keys, RMParms *RP) |
void | lock_and_hide_doors (object **doorlist, mapstruct *map, int opts, RMParms *RP) |
object * | place_chest (int treasureoptions, int x, int y, mapstruct *map, mapstruct *style_map, int n_treasures, RMParms *RP) |
void | place_treasure (mapstruct *map, char **layout, char *treasure_style, int treasureoptions, RMParms *RP) |
static void | remove_adjacent_doors (object *door) |
void | remove_monsters (int x, int y, mapstruct *map) |
static object ** | surround_by_doors (mapstruct *map, char **layout, int x, int y, int opts) |
int | wall_blocked (mapstruct *m, int x, int y) |
This deals with inserting treasures in random maps.
Definition in file treasure.c.
#define NO_PASS_DOORS 0 |
Definition at line 57 of file treasure.c.
Referenced by keyplace(), and lock_and_hide_doors().
#define PASS_DOORS 1 |
Definition at line 58 of file treasure.c.
Referenced by keyplace(), and place_chest().
typedef struct free_spots_struct free_spots_struct |
Datastructure needed by find_spot_in_room() and find_spot_in_room_recursive()
Returns the first door in this square, or NULL if there isn't a door.
map | |
x | |
y | where to look. |
Definition at line 801 of file treasure.c.
References obj::above, DOOR, GET_MAP_OB, LOCKED_DOOR, and obj::type.
Referenced by find_doors_in_room_recursive().
finds the closest monster and returns him, regardless of doors or walls
map | |
x | |
y | where to look from. |
RP | parameters for random map. |
Definition at line 311 of file treasure.c.
References obj::above, FLAG_MONSTER, freearr_x, freearr_y, GET_MAP_FLAGS, GET_MAP_OB, P_IS_ALIVE, QUERY_FLAG, and SIZEOFFREE.
Referenced by keyplace().
Gets all doors in a room.
map | map to look into. |
x | |
y | point of a room to find door for. |
RP | map parameters. |
Definition at line 871 of file treasure.c.
References find_doors_in_room_recursive(), wall_blocked(), RMParms::Xsize, and RMParms::Ysize.
Referenced by place_treasure().
void find_doors_in_room_recursive | ( | char ** | layout, |
mapstruct * | map, | ||
int | x, | ||
int | y, | ||
object ** | doorlist, | ||
int * | ndoors, | ||
RMParms * | RP | ||
) |
The workhorse routine, which finds the doors in a room
layout | |
map | |
x | |
y | random map to look into. |
doorlist | list of doors. |
ndoors | number of found doors. |
RP | map parameters. |
Definition at line 824 of file treasure.c.
References door_in_square(), freearr_x, freearr_y, llevError, and LOG().
Referenced by find_doors_in_room().
Searches the map for a spot with walls around it. The more walls the better, but it'll settle for 1 wall, or even 0, but it'll return 0 if no FREE spots are found.
map | where to look. |
cx | |
cy | where to look, and coordinates of found spot. -1 if no spot found. |
RP | parameters of the random map. |
Definition at line 653 of file treasure.c.
References find_archetype(), find_first_free_spot(), freearr_x, freearr_y, SIZEOFFREE1, and surround_flag3().
Referenced by place_treasure().
Find a monster in a room. Real work is done by find_monster_in_room_recursive().
map | generated map. |
x | |
y | where to look from. |
RP | random map parameters. |
Definition at line 513 of file treasure.c.
References find_monster_in_room_recursive(), wall_blocked(), RMParms::Xsize, and RMParms::Ysize.
Referenced by keyplace().
object* find_monster_in_room_recursive | ( | char ** | layout, |
mapstruct * | map, | ||
int | x, | ||
int | y, | ||
RMParms * | RP | ||
) |
A recursive routine which will return a monster, eventually, if there is one. One should really call find_monster_in_room().
layout | map layout. |
map | generated map. |
x | |
y | where to look from. |
RP | random map parameters. |
Definition at line 465 of file treasure.c.
References obj::above, FLAG_ALIVE, freearr_x, freearr_y, GET_MAP_FLAGS, GET_MAP_OB, P_IS_ALIVE, and QUERY_FLAG.
Referenced by find_monster_in_room().
Find a random non-blocked spot in this room to drop a key. Returns 1 if success, 0 else.
map | map to look into. | |
x | ||
y | where to look from. | |
[out] | kx | |
[out] | ky | found spot if 1 is returned. |
RP | random map parameters. |
Definition at line 600 of file treasure.c.
References find_spot_in_room_recursive(), free_spots_struct::number_of_free_spots_in_room, free_spots_struct::room_free_spots_x, free_spots_struct::room_free_spots_y, wall_blocked(), RMParms::Xsize, and RMParms::Ysize.
Referenced by keyplace().
|
static |
the workhorse routine, which finds the free spots in a room: a datastructure of free points is set up, and a position chosen from that datastructure.
layout | map layout. |
x | |
y | where to look from. |
RP | random map parameters. |
spots | currently found free spots. |
Definition at line 559 of file treasure.c.
References freearr_x, freearr_y, free_spots_struct::number_of_free_spots_in_room, free_spots_struct::room_free_spots_x, and free_spots_struct::room_free_spots_y.
Referenced by find_spot_in_room().
int keyplace | ( | mapstruct * | map, |
int | x, | ||
int | y, | ||
char * | keycode, | ||
int | door_flag, | ||
int | n_keys, | ||
RMParms * | RP | ||
) |
Places keys in the map, preferably in something alive.
The idea is that you call keyplace on x,y where a door is, and it'll make sure a key is placed on both sides of the door.
map | |
x | |
y | where to put a key. |
keycode | keycode is the key's code. |
door_flag | if NO_PASS_DOORS won't cross doors or walls to keyplace, PASS_DOORS will. if PASS_DOORS is set, the x & y values that are passed in are basically meaningless - IMO, it is a bit of misnomer, as when it is set, it just randomly chooses spaces on the map, ideally finding a close monster, to put the key in. In fact, if PASS_DOORS is set, there is no guarantee that the keys will be on both sides of the door - it may happen by randomness, but the code doesn't work to make sure it happens. |
n_keys | number of keys to place. If 1, it will place 1 key. Else, it will place 2-4 keys. |
RP | random map parameters. |
Definition at line 361 of file treasure.c.
References add_string(), create_archetype(), distance(), RMParms::dungeon_level, RMParms::dungeon_name, find_closest_monster(), find_first_free_spot(), find_monster_in_room(), find_spot_in_room(), free_string(), freearr_x, freearr_y, insert_ob_in_map(), insert_ob_in_ob(), obj::name, NO_PASS_DOORS, PASS_DOORS, obj::slaying, snprintf(), wall_blocked(), obj::x, RMParms::Xsize, obj::y, and RMParms::Ysize.
Referenced by lock_and_hide_doors(), and place_chest().
Locks and/or hides all the doors in doorlist, or does nothing if opts doesn't say to lock/hide doors. Note that some doors can be not locked if no good spot to put a key was found.
doorlist | doors to list. NULL-terminated. |
map | map we're working on. |
opts | options. |
RP | map parameters. |
Definition at line 952 of file treasure.c.
References add_string(), create_archetype(), DOORED, obj::face, FLAG_REMOVED, free_object(), HIDDEN, insert_ob_in_map(), keyplace(), NO_PASS_DOORS, QUERY_FLAG, remove_adjacent_doors(), remove_ob(), retrofit_joined_wall(), obj::slaying, snprintf(), obj::x, and obj::y.
Referenced by place_treasure().
object* place_chest | ( | int | treasureoptions, |
int | x, | ||
int | y, | ||
mapstruct * | map, | ||
mapstruct * | style_map, | ||
int | n_treasures, | ||
RMParms * | RP | ||
) |
Put a chest into the map. near x and y, with the treasure style determined (may be null, or may be a treasure list from lib/treasures, if the global variable "treasurestyle" is set to that treasure list's name
treasureoptions | options. |
x | |
y | around which spot to put treasure. |
map | map to put on. |
style_map | unused. |
n_treasures | ? |
RP | parameters the map was generated from. |
Definition at line 232 of file treasure.c.
References add_string(), obj::arch, arch_to_object(), BC_RANDOM, liv::Cha, copy_object(), create_archetype(), RMParms::difficulty, find_first_free_spot(), find_style(), find_treasurelist(), free_object(), freearr_x, freearr_y, liv::hp, insert_ob_in_map(), insert_ob_in_ob(), keyplace(), KEYREQUIRED, obj::level, PASS_DOORS, pick_random_object(), obj::randomitems, obj::slaying, snprintf(), obj::stats, TRAPPED, wall_blocked(), obj::x, and obj::y.
Referenced by place_treasure().
void place_treasure | ( | mapstruct * | map, |
char ** | layout, | ||
char * | treasure_style, | ||
int | treasureoptions, | ||
RMParms * | RP | ||
) |
Place treasures in the map. map, (required) layout, (required) treasure style (may be empty or NULL, or "none" to cause no treasure.) treasureoptions (may be 0 for random choices or positive)
map | where to insert to. |
layout | layout the map was generated from. |
treasure_style | treasure style. May be empty or NULL for random style, or "none" for no treasures. |
treasureoptions | treasure options. |
RP | random map parameters. |
Definition at line 101 of file treasure.c.
References BC_RANDOM, CONCENTRATED, RMParms::difficulty, DOORED, find_doors_in_room(), find_enclosed_spot(), find_style(), HIDDEN, LAST_OPTION, lock_and_hide_doors(), RMParms::map_layout_style, ONION_LAYOUT, place_chest(), RICH, snprintf(), SPARSE, SPIRAL_LAYOUT, SQUARE_SPIRAL_LAYOUT, surround_by_doors(), RMParms::symmetry_used, RMParms::total_map_hp, wall_blocked(), obj::x, RMParms::Xsize, obj::y, and RMParms::Ysize.
Referenced by generate_random_map().
|
static |
This removes any 'normal' doors around the specified door. This is used for lock_and_hide_doors() below - it doesn't make sense to have a locked door right behind a normal door, so lets remove the normal ones. It also fixes key placement issues.
door | door around which to remove unlocked doors. |
Definition at line 910 of file treasure.c.
References obj::above, DOOR, flags, free_object(), freearr_x, freearr_y, get_map_flags(), GET_MAP_OB, obj::map, P_IS_ALIVE, P_OUT_OF_MAP, remove_ob(), obj::type, obj::x, and obj::y.
Referenced by lock_and_hide_doors().
void remove_monsters | ( | int | x, |
int | y, | ||
mapstruct * | map | ||
) |
Remove living things on specified spot.
x | |
y | |
map | where to remove. |
Definition at line 722 of file treasure.c.
References obj::above, FLAG_ALIVE, free_object(), GET_MAP_OB, obj::head, QUERY_FLAG, and remove_ob().
Referenced by surround_by_doors().
|
static |
Surrounds the point x,y by doors, so as to enclose something, like a chest. It only goes as far as the 8 squares surrounding, and it'll remove any monsters it finds.
map | map to work on. |
layout | map's layout. |
x | |
y | point to surround. |
opts | flags. |
Definition at line 755 of file treasure.c.
References create_archetype(), DOORED, freearr_x, freearr_y, insert_ob_in_map(), remove_monsters(), wall_blocked(), obj::x, and obj::y.
Referenced by place_treasure().
int wall_blocked | ( | mapstruct * | m, |
int | x, | ||
int | y | ||
) |
Returns true if square x,y has P_NO_PASS set, which is true for walls and doors but not monsters. This function is not map tile aware.
m | |
x | |
y | map and coordinates to check for. |
Definition at line 73 of file treasure.c.
References GET_MAP_MOVE_BLOCK, MOVE_BLOCK_DEFAULT, and OUT_OF_REAL_MAP.
Referenced by find_doors_in_room(), find_monster_in_room(), find_spot_in_room(), keyplace(), place_chest(), place_exits(), place_treasure(), surround_by_doors(), and surround_flag4().