ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/random_maps/treasure.C
(Generate patch)

Comparing deliantra/server/random_maps/treasure.C (file contents):
Revision 1.1 by elmex, Sun Aug 13 17:16:03 2006 UTC vs.
Revision 1.2 by root, Tue Aug 29 08:01:36 2006 UTC

1/* 1/*
2 * static char *rcsid_treasure_c = 2 * static char *rcsid_treasure_c =
3 * "$Id: treasure.C,v 1.1 2006/08/13 17:16:03 elmex Exp $"; 3 * "$Id: treasure.C,v 1.2 2006/08/29 08:01:36 root Exp $";
4 */ 4 */
5 5
6/* 6/*
7 CrossFire, A Multiplayer game for X-windows 7 CrossFire, A Multiplayer game for X-windows
8 8
57 57
58int wall_blocked(mapstruct *m, int x, int y) { 58int wall_blocked(mapstruct *m, int x, int y) {
59 int r; 59 int r;
60 60
61 if(OUT_OF_REAL_MAP(m,x,y)) 61 if(OUT_OF_REAL_MAP(m,x,y))
62 return 1; 62 return 1;
63 r = GET_MAP_MOVE_BLOCK(m,x,y) & ~MOVE_BLOCK_DEFAULT; 63 r = GET_MAP_MOVE_BLOCK(m,x,y) & ~MOVE_BLOCK_DEFAULT;
64 return r; 64 return r;
65} 65}
66 66
67/* place treasures in the map, given the 67/* place treasures in the map, given the
166} 166}
167 167
168 168
169 169
170/* put a chest into the map, near x and y, with the treasure style 170/* put a chest into the map, near x and y, with the treasure style
171 determined (may be null, or may be a treasure list from lib/treasures, 171 determined (may be null, or may be a treasure list from lib/treasures,
172 if the global variable "treasurestyle" is set to that treasure list's name */ 172 if the global variable "treasurestyle" is set to that treasure list's name */
173 173
174object * place_chest(int treasureoptions,int x, int y,mapstruct *map, mapstruct *style_map,int n_treasures,RMParms *RP) { 174object * place_chest(int treasureoptions,int x, int y,mapstruct *map, mapstruct *style_map,int n_treasures,RMParms *RP) {
175 object *the_chest; 175 object *the_chest;
176 int i,xl,yl; 176 int i,xl,yl;
177 177
247 return the_chest; 247 return the_chest;
248} 248}
249 249
250 250
251/* finds the closest monster and returns him, regardless of doors 251/* finds the closest monster and returns him, regardless of doors
252 or walls */ 252 or walls */
253object *find_closest_monster(mapstruct *map,int x,int y,RMParms *RP) { 253object *find_closest_monster(mapstruct *map,int x,int y,RMParms *RP) {
254 int i; 254 int i;
255 for(i=0;i<SIZEOFFREE;i++) { 255 for(i=0;i<SIZEOFFREE;i++) {
256 int lx,ly; 256 int lx,ly;
257 lx=x+freearr_x[i]; 257 lx=x+freearr_x[i];
270} 270}
271 271
272 272
273 273
274/* places keys in the map, preferably in something alive. 274/* places keys in the map, preferably in something alive.
275 keycode is the key's code, 275 keycode is the key's code,
276 door_flag is either PASS_DOORS or NO_PASS_DOORS. 276 door_flag is either PASS_DOORS or NO_PASS_DOORS.
277 NO_PASS_DOORS won't cross doors or walls to keyplace, PASS_DOORS will. 277 NO_PASS_DOORS won't cross doors or walls to keyplace, PASS_DOORS will.
278 if n_keys is 1, it will place 1 key. if n_keys >1, it will place 2-4 keys: 278 if n_keys is 1, it will place 1 key. if n_keys >1, it will place 2-4 keys:
279 it will place 2-4 keys regardless of what nkeys is provided nkeys > 1. 279 it will place 2-4 keys regardless of what nkeys is provided nkeys > 1.
280 280
281 The idea is that you call keyplace on x,y where a door is, and it'll make 281 The idea is that you call keyplace on x,y where a door is, and it'll make
282 sure a key is placed on both sides of the door. 282 sure a key is placed on both sides of the door.
283*/ 283*/
284 284
285int keyplace(mapstruct *map,int x,int y,char *keycode,int door_flag,int n_keys,RMParms *RP) { 285int keyplace(mapstruct *map,int x,int y,char *keycode,int door_flag,int n_keys,RMParms *RP) {
286 int i,j; 286 int i,j;
287 int kx,ky; 287 int kx,ky;
288 object *the_keymaster; /* the monster that gets the key. */ 288 object *the_keymaster; /* the monster that gets the key. */
289 object *the_key; 289 object *the_key;
306 if(the_keymaster==NULL) { 306 if(the_keymaster==NULL) {
307 int freeindex; 307 int freeindex;
308 308
309 freeindex = -1; 309 freeindex = -1;
310 for(tries = 0; tries < 15 && freeindex == -1; tries++) { 310 for(tries = 0; tries < 15 && freeindex == -1; tries++) {
311 kx = (RANDOM()%(RP->Xsize-2))+1; 311 kx = (RANDOM()%(RP->Xsize-2))+1;
312 ky = (RANDOM()%(RP->Ysize-2))+1; 312 ky = (RANDOM()%(RP->Ysize-2))+1;
313 freeindex = find_first_free_spot(the_key,map,kx,ky); 313 freeindex = find_first_free_spot(the_key,map,kx,ky);
314 } 314 }
315 if(freeindex != -1) { 315 if(freeindex != -1) {
316 kx += freearr_x[freeindex]; 316 kx += freearr_x[freeindex];
317 ky += freearr_y[freeindex]; 317 ky += freearr_y[freeindex];
318 } 318 }
319 } 319 }
320 } 320 }
321 else { /* NO_PASS_DOORS --we have to work harder.*/ 321 else { /* NO_PASS_DOORS --we have to work harder.*/
322 /* don't try to keyplace if we're sitting on a blocked square and 322 /* don't try to keyplace if we're sitting on a blocked square and
494 free(room_free_spots_y); 494 free(room_free_spots_y);
495} 495}
496 496
497 497
498/* searches the map for a spot with walls around it. The more 498/* searches the map for a spot with walls around it. The more
499 walls the better, but it'll settle for 1 wall, or even 0, but 499 walls the better, but it'll settle for 1 wall, or even 0, but
500 it'll return 0 if no FREE spots are found.*/ 500 it'll return 0 if no FREE spots are found.*/
501 501
502void find_enclosed_spot(mapstruct *map, int *cx, int *cy,RMParms *RP) { 502void find_enclosed_spot(mapstruct *map, int *cx, int *cy,RMParms *RP) {
503 int x,y; 503 int x,y;
504 int i; 504 int i;
505 x = *cx;y=*cy; 505 x = *cx;y=*cy;
567 }; 567 };
568} 568}
569 569
570 570
571/* surrounds the point x,y by doors, so as to enclose something, like 571/* surrounds the point x,y by doors, so as to enclose something, like
572 a chest. It only goes as far as the 8 squares surrounding, and 572 a chest. It only goes as far as the 8 squares surrounding, and
573 it'll remove any monsters it finds.*/ 573 it'll remove any monsters it finds.*/
574 574
575object ** surround_by_doors(mapstruct *map,char **layout,int x,int y,int opts) { 575object ** surround_by_doors(mapstruct *map,char **layout,int x,int y,int opts) {
576 int i; 576 int i;
577 char *doors[2]; 577 char *doors[2];
578 object **doorlist; 578 object **doorlist;
682} 682}
683 683
684 684
685 685
686/* locks and/or hides all the doors in doorlist, or does nothing if 686/* locks and/or hides all the doors in doorlist, or does nothing if
687 opts doesn't say to lock/hide doors. */ 687 opts doesn't say to lock/hide doors. */
688 688
689void lock_and_hide_doors(object **doorlist,mapstruct *map,int opts,RMParms *RP) { 689void lock_and_hide_doors(object **doorlist,mapstruct *map,int opts,RMParms *RP) {
690 object *door; 690 object *door;
691 int i; 691 int i;
692 /* lock the doors and hide the keys. */ 692 /* lock the doors and hide the keys. */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines