Crossfire Server, Trunk
|
#include "global.h"
#include <stdlib.h>
#include <string.h>
#include "random_map.h"
#include "rproto.h"
Go to the source code of this file.
Classes | |
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. */ |
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, 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.cpp.
Definition at line 35 of file treasure.cpp.
Definition at line 38 of file treasure.cpp.
Definition at line 42 of file treasure.cpp.
Definition at line 37 of file treasure.cpp.
Definition at line 43 of file treasure.cpp.
#define NO_PASS_DOORS 0 |
Definition at line 46 of file treasure.cpp.
#define PASS_DOORS 1 |
Definition at line 47 of file treasure.cpp.
#define RICH 64 /* 2x as much treasure as default */ |
Definition at line 41 of file treasure.cpp.
#define SPARSE 32 /* 1/2 as much treasure as default */ |
Definition at line 40 of file treasure.cpp.
Definition at line 39 of file treasure.cpp.
Returns the first door in this square, or NULL if there isn't a door.
map | |
x | |
y | where to look. |
Definition at line 846 of file treasure.cpp.
References DOOR, FOR_MAP_FINISH, FOR_MAP_PREPARE, LOCKED_DOOR, disinfect::map, Ice::tmp, diamondslots::x, and diamondslots::y.
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 335 of file treasure.cpp.
References FLAG_MONSTER, FOR_MAP_FINISH, FOR_MAP_PREPARE, freearr_x, freearr_y, GET_MAP_FLAGS, disinfect::map, P_IS_ALIVE, QUERY_FLAG, SIZEOFFREE, diamondslots::x, and diamondslots::y.
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 920 of file treasure.cpp.
References find_doors_in_room_recursive(), disinfect::map, wall_blocked(), diamondslots::x, RMParms::Xsize, diamondslots::y, 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 870 of file treasure.cpp.
References door_in_square(), freearr_x, freearr_y, llevError, LOG(), disinfect::map, RANDOM, diamondslots::x, and diamondslots::y.
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 691 of file treasure.cpp.
References archininventory::arch, find_archetype(), freearr_x, freearr_y, disinfect::map, object_find_first_free_spot(), SIZEOFFREE1, surround_flag3(), diamondslots::x, and diamondslots::y.
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 543 of file treasure.cpp.
References find_monster_in_room_recursive(), disinfect::map, wall_blocked(), diamondslots::x, RMParms::Xsize, diamondslots::y, 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 492 of file treasure.cpp.
References FLAG_ALIVE, FOR_MAP_FINISH, FOR_MAP_PREPARE, freearr_x, freearr_y, GET_MAP_FLAGS, HEAD, disinfect::map, P_IS_ALIVE, QUERY_FLAG, RANDOM, diamondslots::x, and diamondslots::y.
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 635 of file treasure.cpp.
References find_spot_in_room_recursive(), disinfect::map, free_spots_struct::number_of_free_spots_in_room, RANDOM, free_spots_struct::room_free_spots_x, free_spots_struct::room_free_spots_y, wall_blocked(), diamondslots::x, RMParms::Xsize, diamondslots::y, 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 591 of file treasure.cpp.
References freearr_x, freearr_y, free_spots_struct::number_of_free_spots_in_room, RANDOM, free_spots_struct::room_free_spots_x, free_spots_struct::room_free_spots_y, diamondslots::x, and diamondslots::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 385 of file treasure.cpp.
References add_string(), create_archetype(), RMParms::dungeon_level, RMParms::dungeon_name, find_closest_monster(), find_monster_in_room(), find_spot_in_room(), free_string(), freearr_x, freearr_y, hall_of_fame::keys, disinfect::map, object::name, NO_PASS_DOORS, object_find_first_free_spot(), object_insert_in_map_at(), object_insert_in_ob(), PASS_DOORS, RANDOM, object::slaying, wall_blocked(), diamondslots::x, RMParms::Xsize, diamondslots::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 1005 of file treasure.cpp.
References add_string(), create_archetype(), DOORED, object::face, FLAG_REMOVED, HIDDEN, keyplace(), disinfect::map, NO_PASS_DOORS, object_free_drop_inventory(), object_insert_in_map_at(), object_remove(), QUERY_FLAG, RANDOM, remove_adjacent_doors(), retrofit_joined_wall(), object::slaying, object::x, and object::y.
Referenced by place_treasure().
object* place_chest | ( | int | treasureoptions, |
int | x, | ||
int | y, | ||
mapstruct * | map, | ||
int | n_treasures, | ||
RMParms * | RP | ||
) |
Put a chest into the map, near x and y, with a chest from the styles/cheststyles map.
treasureoptions | options. |
x | |
y | around which spot to put treasure. |
map | map to put on. |
n_treasures | ? |
RP | parameters the map was generated from. |
Definition at line 220 of file treasure.cpp.
References add_string(), BC_RANDOM, living::Cha, RMParms::cheststyle, create_archetype(), RMParms::difficulty, find_style(), find_treasurelist(), freearr_x, freearr_y, living::hp, keyplace(), KEYREQUIRED, object::level, disinfect::map, MIMIC, object_copy_with_inv(), object_find_first_free_spot(), object_free_drop_inventory(), object_insert_in_map_at(), object_insert_in_ob(), object_new(), PASS_DOORS, pick_random_object(), RANDOM, object::randomitems, object::slaying, object::stats, TRAPPED, TREASURE, object::type, wall_blocked(), diamondslots::x, object::x, diamondslots::y, and object::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 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 NULL or "none" for no treasures, any other value to put treasures. |
treasureoptions | treasure options. |
RP | random map parameters. |
Definition at line 92 of file treasure.cpp.
References BC_RANDOM, CONCENTRATED, RMParms::difficulty, DOORED, find_doors_in_room(), find_enclosed_spot(), HIDDEN, LAST_OPTION, lock_and_hide_doors(), disinfect::map, RMParms::map_layout_style, ONION_LAYOUT, place_chest(), RANDOM, RICH, SPARSE, SPIRAL_LAYOUT, SQUARE_SPIRAL_LAYOUT, surround_by_doors(), RMParms::symmetry_used, RMParms::total_map_hp, wall_blocked(), object::x, RMParms::Xsize, object::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 961 of file treasure.cpp.
References DOOR, flags, FOR_MAP_FINISH, FOR_MAP_PREPARE, freearr_x, freearr_y, get_map_flags(), m, object::map, object_free_drop_inventory(), object_remove(), P_IS_ALIVE, P_OUT_OF_MAP, Ice::tmp, diamondslots::x, object::x, diamondslots::y, and object::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 764 of file treasure.cpp.
References FLAG_ALIVE, FOR_MAP_FINISH, FOR_MAP_PREPARE, GET_MAP_OB, HEAD, disinfect::map, object_free_drop_inventory(), object_remove(), QUERY_FLAG, Ice::tmp, diamondslots::x, and diamondslots::y.
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 798 of file treasure.cpp.
References create_archetype(), DOORED, doors, freearr_x, freearr_y, disinfect::map, object_insert_in_map_at(), remove_monsters(), wall_blocked(), diamondslots::x, guild_entry::x1, diamondslots::y, and guild_entry::y1.
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 62 of file treasure.cpp.
References GET_MAP_MOVE_BLOCK, m, MOVE_BLOCK_DEFAULT, OUT_OF_REAL_MAP, ring_occidental_mages::r, diamondslots::x, and diamondslots::y.
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().