--- deliantra/server/random_maps/treasure.C 2006/08/13 17:16:03 1.1 +++ deliantra/server/random_maps/treasure.C 2006/09/03 00:18:41 1.3 @@ -1,6 +1,6 @@ /* * static char *rcsid_treasure_c = - * "$Id: treasure.C,v 1.1 2006/08/13 17:16:03 elmex Exp $"; + * "$Id: treasure.C,v 1.3 2006/09/03 00:18:41 root Exp $"; */ /* @@ -59,7 +59,7 @@ int r; if(OUT_OF_REAL_MAP(m,x,y)) - return 1; + return 1; r = GET_MAP_MOVE_BLOCK(m,x,y) & ~MOVE_BLOCK_DEFAULT; return r; } @@ -168,8 +168,8 @@ /* 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 */ + 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 */ object * place_chest(int treasureoptions,int x, int y,mapstruct *map, mapstruct *style_map,int n_treasures,RMParms *RP) { object *the_chest; @@ -237,7 +237,7 @@ if((treasureoptions & KEYREQUIRED)&&n_treasures>1) { char keybuf[256]; sprintf(keybuf,"%d",(int)RANDOM()); - the_chest->slaying = add_string(keybuf); + the_chest->slaying = keybuf; keyplace(map,x,y,keybuf,PASS_DOORS,1,RP); } @@ -249,7 +249,7 @@ /* finds the closest monster and returns him, regardless of doors - or walls */ + or walls */ object *find_closest_monster(mapstruct *map,int x,int y,RMParms *RP) { int i; for(i=0;i1, it will place 2-4 keys: - it will place 2-4 keys regardless of what nkeys is provided nkeys > 1. + keycode is the key's code, + door_flag is either PASS_DOORS or NO_PASS_DOORS. + NO_PASS_DOORS won't cross doors or walls to keyplace, PASS_DOORS will. + if n_keys is 1, it will place 1 key. if n_keys >1, it will place 2-4 keys: + it will place 2-4 keys regardless of what nkeys is provided nkeys > 1. - 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. + 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. */ - + int keyplace(mapstruct *map,int x,int y,char *keycode,int door_flag,int n_keys,RMParms *RP) { int i,j; int kx,ky; @@ -290,8 +290,7 @@ /* get a key and set its keycode */ the_key = get_archetype("key2"); - the_key->slaying = add_string(keycode); - + the_key->slaying = keycode; if(door_flag==PASS_DOORS) { int tries=0; @@ -308,13 +307,13 @@ freeindex = -1; for(tries = 0; tries < 15 && freeindex == -1; tries++) { - kx = (RANDOM()%(RP->Xsize-2))+1; - ky = (RANDOM()%(RP->Ysize-2))+1; - freeindex = find_first_free_spot(the_key,map,kx,ky); + kx = (RANDOM()%(RP->Xsize-2))+1; + ky = (RANDOM()%(RP->Ysize-2))+1; + freeindex = find_first_free_spot(the_key,map,kx,ky); } if(freeindex != -1) { - kx += freearr_x[freeindex]; - ky += freearr_y[freeindex]; + kx += freearr_x[freeindex]; + ky += freearr_y[freeindex]; } } } @@ -496,8 +495,8 @@ /* 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.*/ + walls the better, but it'll settle for 1 wall, or even 0, but + it'll return 0 if no FREE spots are found.*/ void find_enclosed_spot(mapstruct *map, int *cx, int *cy,RMParms *RP) { int x,y; @@ -569,8 +568,8 @@ /* 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.*/ + a chest. It only goes as far as the 8 squares surrounding, and + it'll remove any monsters it finds.*/ object ** surround_by_doors(mapstruct *map,char **layout,int x,int y,int opts) { int i; @@ -684,7 +683,7 @@ /* locks and/or hides all the doors in doorlist, or does nothing if - opts doesn't say to lock/hide doors. */ + opts doesn't say to lock/hide doors. */ void lock_and_hide_doors(object **doorlist,mapstruct *map,int opts,RMParms *RP) { object *door; @@ -704,7 +703,7 @@ doorlist[i]=new_door; insert_ob_in_map(new_door,map,NULL,0); sprintf(keybuf,"%d",(int)RANDOM()); - new_door->slaying = add_string(keybuf); + new_door->slaying = keybuf; keyplace(map,new_door->x,new_door->y,keybuf,NO_PASS_DOORS,2,RP); } }