 |
Crossfire Server, Trunk
1.75.0
|
Go to the documentation of this file.
35 #define CONCENTRATED 1
43 #define LAST_OPTION 64
46 #define NO_PASS_DOORS 0
98 if (!strcmp(treasure_style,
"none")) {
101 if (treasureoptions <= 0) {
106 if ((treasureoptions&
RICH) && (treasureoptions&
SPARSE)) {
108 treasureoptions -= 1;
110 treasureoptions -= 2;
115 if (treasureoptions&
SPARSE) {
117 }
else if (treasureoptions&
RICH) {
123 if (num_treasures <= 0) {
137 for (i = 0; i < RP->
Xsize; i++) {
138 for (j = 0; j < RP->
Ysize; j++) {
148 chest =
place_chest(treasureoptions, i, j, map, num_treasures/tdiv, RP);
169 while (i == -1 && tries < 100) {
178 chest =
place_chest(treasureoptions, i, j, map, num_treasures, RP);
194 for (ti = 0; ti < num_treasures; ti++) {
222 object *the_chest = NULL;
247 if (the_chest == NULL) {
271 the_chest->
stats.
hp = n_treasures;
294 if (new_trap->
level == 0) {
307 if ((treasureoptions&
KEYREQUIRED) && n_treasures > 1) {
310 snprintf(keybuf,
sizeof(keybuf),
"%d", (
int)
RANDOM());
345 if (lx >= 0 && ly >= 0 && lx < RP->Xsize && ly < RP->Ysize)
389 object *the_keymaster;
392 const char *keys[] = {
"key2",
"blue_key",
"brown_key",
"darkgray_key",
"darkgreen_key",
"gray_key",
"green_key",
"magenta_key",
"red_key",
"white_key" };
404 the_keymaster = NULL;
405 while (tries < 15 && the_keymaster == NULL) {
412 if (the_keymaster == NULL) {
416 for (tries = 0; tries < 15 && freeindex == -1; tries++) {
421 if (freeindex != -1) {
435 if (the_keymaster == NULL)
446 while (distance < 5) {
468 if (the_keymaster == NULL) {
497 if (!(x >= 0 && y >= 0 && x < RP->Xsize && y < RP->Ysize)) {
512 return HEAD(the_monster);
518 for (i =
RANDOM()%8, j = 0; j < 8; i++, j++) {
522 if (the_monster != NULL) {
547 object *theMonsterToFind;
549 layout2 = (
char **)calloc(
sizeof(
char *), RP->
Xsize);
551 for (i = 0; i < RP->
Xsize; i++) {
552 layout2[i] = (
char *)calloc(
sizeof(
char), RP->
Ysize);
553 for (j = 0; j < RP->
Ysize; j++) {
562 for (i = 0; i < RP->
Xsize; i++) {
567 return theMonsterToFind;
596 if (!(x >= 0 && y >= 0 && x < RP->Xsize && y < RP->Ysize)) {
612 for (i =
RANDOM()%8, j = 0; j < 8; i++, j++) {
645 layout2 = (
char **)calloc(
sizeof(
char *), RP->
Xsize);
647 for (i = 0; i < RP->
Xsize; i++) {
648 layout2[i] = (
char *)calloc(
sizeof(
char), RP->
Ysize);
649 for (j = 0; j < RP->
Ysize; j++) {
666 for (i = 0; i < RP->
Xsize; i++) {
705 if (sindex == 7 || sindex == 11 || sindex == 13 || sindex == 14) {
721 if (sindex == 3 || sindex == 5 || sindex == 9 || sindex == 6 || sindex == 10 || sindex == 12) {
801 const char *
doors[2];
804 doorlist = (
object **)calloc(9,
sizeof(
object *));
808 doors[0] =
"locked_door2";
809 doors[1] =
"locked_door1";
816 for (i = 1; i < 9; i++) {
820 ||
layout[x1][y1] ==
'>') {
828 doorlist[ndoors_made] = new_door;
876 if (!(x >= 0 && y >= 0 && x < RP->Xsize && y < RP->Ysize)) {
886 if (
layout[x][y] ==
'#') {
890 doorlist[*ndoors] = door;
892 LOG(
llevError,
"find_doors_in_room_recursive:Too many doors for memory allocated!\n");
900 for (i =
RANDOM()%8, j = 0; j < 8; i++, j++) {
927 doorlist = (
object **)calloc(
sizeof(*doorlist), 256);
930 layout2 = (
char **)calloc(
sizeof(
char *), RP->
Xsize);
932 for (i = 0; i < RP->
Xsize; i++) {
933 layout2[i] = (
char *)calloc(
sizeof(
char), RP->
Ysize);
934 for (j = 0; j < RP->
Ysize; j++) {
945 for (i = 0; i < RP->
Xsize; i++) {
968 for (i = 1; i <= 8; i++) {
979 if (tmp->type ==
DOOR) {
1012 for (i = 0, door = doorlist[0]; doorlist[i] != NULL; i++) {
1020 doorlist[i] = new_door;
1023 snprintf(keybuf, 256,
"%d", (
int)
RANDOM());
1028 for (i = 0; doorlist[i] != NULL; i++) {
1035 for (i = 0, door = doorlist[0]; doorlist[i] != NULL; i++) {
1040 if (wallface != NULL) {
#define GET_MAP_OB(M, X, Y)
Gets the bottom object on a map.
int find_spot_in_room(mapstruct *map, int x, int y, int *kx, int *ky, RMParms *RP)
Find a random non-blocked spot in this room to drop a key.
#define FOR_MAP_FINISH()
Finishes FOR_MAP_PREPARE().
#define MOVE_BLOCK_DEFAULT
The normal assumption is that objects are walking/flying.
@ llevError
Error, serious thing.
uint16_t difficulty
What level the player should be to play here.
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
object * retrofit_joined_wall(mapstruct *the_map, int i, int j, int insert_flag, RMParms *RP)
this takes a map, and changes an existing wall to match what's blocked around it, counting only doors...
int * room_free_spots_x
Positions.
#define QUERY_FLAG(xyz, p)
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.
void remove_monsters(int x, int y, mapstruct *map)
Remove living things on specified spot.
struct mapstruct * map
Pointer to the map in which this object is present.
int object_find_first_free_spot(const object *ob, mapstruct *m, int x, int y)
object_find_first_free_spot(archetype, mapstruct, x, y) works like object_find_free_spot(),...
treasurelist * find_treasurelist(const char *name)
Search for the given treasurelist by name.
object * find_monster_in_room(mapstruct *map, int x, int y, RMParms *RP)
Find a monster in a room.
static const flag_definition flags[]
Flag mapping.
mapstruct * find_style(const char *dirname, const char *stylename, int difficulty)
Loads and returns the map requested.
void object_copy_with_inv(const object *src_ob, object *dest_ob, bool update_speed)
Copy an object with an inventory, duplicate the inv too.
object ** find_doors_in_room(mapstruct *map, int x, int y, RMParms *RP)
Gets all doors in a room.
#define P_IS_ALIVE
Something alive is on this space.
int16_t level
Level of creature or object.
object * object_insert_in_ob(object *op, object *where)
This function inserts the object op in the linked list inside the object environment.
#define FLAG_ALIVE
Object can fight (or be fought)
int16_t y
Position in the map for this object.
static event_registration m
void object_free_drop_inventory(object *ob)
Frees everything allocated by an object, removes it from the list of used objects,...
int number_of_free_spots_in_room
Number of positions.
short freearr_y[SIZEOFFREE]
Y offset when searching around a spot.
#define SQUARE_SPIRAL_LAYOUT
treasurelist represents one logical group of items to be generated together.
object clone
An object from which to do object_copy()
sstring add_string(const char *str)
This will add 'str' to the hash table.
#define HEAD(op)
Returns the head part of an object.
TIPS on SURVIVING Crossfire is populated with a wealth of different monsters These monsters can have varying immunities and attack types In some of them can be quite a bit smarter than others It will be important for new players to learn the abilities of different monsters and learn just how much it will take to kill them This section discusses how monsters can interact with players Most monsters in the game are out to mindlessly kill and destroy the players These monsters will help boost a player s after he kills them When fighting a large amount of monsters in a single attempt to find a narrower hallway so that you are not being attacked from all sides Charging into a room full of Beholders for instance would not be open the door and fight them one at a time For there are several maps designed for them Find these areas and clear them out All throughout these a player can find signs and books which they can read by stepping onto them and hitting A to apply the book sign These messages will help the player to learn the system One more always keep an eye on your food If your food drops to your character will soon so BE CAREFUL ! NPCs Non Player Character are special monsters which have intelligence Players may be able to interact with these monsters to help solve puzzles and find items of interest To speak with a monster you suspect to be a simply move to an adjacent square to them and push the double ie Enter your and press< Return > You can also use say if you feel like typing a little extra Other NPCs may not speak to but display intelligence with their movement Some monsters can be and may attack the nearest of your enemies Others can be in that they follow you around and help you in your quest to kill enemies and find treasure SPECIAL ITEMS There are many special items which can be found in of these the most important may be the signs all a player must do is apply the handle In the case of the player must move items over the button to hold it down Some of the larger buttons may need very large items to be moved onto before they can be activated Gates and locked doors
static object * door_in_square(mapstruct *map, int x, int y)
Returns the first door in this square, or NULL if there isn't a door.
const Face * face
Face with colors.
void find_enclosed_spot(mapstruct *map, int *cx, int *cy, RMParms *RP)
Searches the map for a spot with walls around it.
uint8_t type
PLAYER, BULLET, etc.
#define GET_MAP_MOVE_BLOCK(M, X, Y)
Gets the blocking state of a square.
The archetype structure is a set of rules on how to generate and manipulate objects which point to ar...
void place_treasure(mapstruct *map, char **layout, char *treasure_style, int treasureoptions, RMParms *RP)
Place treasures in the map.
object * object_insert_in_map_at(object *op, mapstruct *m, object *originator, int flag, int x, int y)
Same as object_insert_in_map() except it handle separate coordinates and do a clean job preparing mul...
#define FLAG_MONSTER
Will attack players.
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.
#define P_OUT_OF_MAP
This space is outside the map.
object * object_new(void)
Grabs an object from the list of unused objects, makes sure it is initialised, and returns it.
object * create_archetype(const char *name)
Finds which archetype matches the given name, and returns a new object containing a copy of the arche...
void free_string(sstring str)
This will reduce the refcount, and if it has reached 0, str will be freed.
Datastructure needed by find_spot_in_room() and find_spot_in_room_recursive()
void lock_and_hide_doors(object **doorlist, mapstruct *map, int opts, RMParms *RP)
Locks and/or hides all the doors in doorlist, or does nothing if opts doesn't say to lock/hide doors.
#define FOR_MAP_PREPARE(map_, mx_, my_, it_)
Constructs a loop iterating over all objects of a map tile.
#define OUT_OF_REAL_MAP(M, X, Y)
Checks if a square is out of the map.
#define FLAG_REMOVED
Object is not in any map or invenory.
sstring slaying
Which race to do double damage to.
sstring name
The name of the object, obviously...
char cheststyle[RM_SIZE]
Name of the chests style file, in /styles/cheststyles, can be an empty string in which case a random ...
int get_map_flags(mapstruct *oldmap, mapstruct **newmap, int16_t x, int16_t y, int16_t *nx, int16_t *ny)
This rolls up wall, blocks_magic, blocks_view, etc, all into one function that just returns a P_.
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.
long unsigned int total_map_hp
Total hit points of the monsters in the map, used for treasure generation.
#define BC_RANDOM(x)
Macro to get a strongly centered random distribution, from 0 to x, centered at x/2.
archetype * find_archetype(const char *name)
object * pick_random_object(mapstruct *style)
Picks a random object from a style map.
static object ** surround_by_doors(mapstruct *map, char **layout, int x, int y, int opts)
Surrounds the point x,y by doors, so as to enclose something, like a chest.
char dungeon_name[RM_SIZE]
If not empty, will be used in the name of the random keys.
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.
struct treasurelist * randomitems
Items to be generated.
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.
void object_remove(object *op)
This function removes the object op from the linked list of objects which it is currently tied to.
#define GET_MAP_FLAGS(M, X, Y)
Gets map flags.
static void find_spot_in_room_recursive(char **layout, int x, int y, RMParms *RP, free_spots_struct *spots)
the workhorse routine, which finds the free spots in a room: a datastructure of free points is set up...
living stats
Str, Con, Dex, etc.
short freearr_x[SIZEOFFREE]
X offset when searching around a spot.
int surround_flag3(mapstruct *map, int i, int j, RMParms *RP)
Check a map for blocked spots.
static void remove_adjacent_doors(object *door)
This removes any 'normal' doors around the specified door.
object * find_closest_monster(mapstruct *map, int x, int y, RMParms *RP)
finds the closest monster and returns him, regardless of doors or walls
int * room_free_spots_y
Positions.