version 1.22 | | version 1.23 |
---|
| | |
/* | | /* |
* static char *rcsid_treasure_c = | | * static char *rcsid_treasure_c = |
* "$Id: treasure.c,v 1.22 2005/11/01 20:52:04 akirschbaum Exp $"; | | * "$Id: treasure.c,v 1.23 2005/11/16 08:16:08 mwedel Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
| | |
int wall_blocked(mapstruct *m, int x, int y) { | | int wall_blocked(mapstruct *m, int x, int y) { |
int r; | | int r; |
| | |
if(OUT_OF_REAL_MAP(m,x,y)) | | if(OUT_OF_REAL_MAP(m,x,y)) |
return 1; | | return 1; |
r = GET_MAP_FLAGS(m,x,y) & (P_NO_PASS ); | | r = GET_MAP_MOVE_BLOCK(m,x,y) & ~MOVE_BLOCK_DEFAULT; |
return r; | | return r; |
} | | } |
| | |
| | |
object *the_chest; | | object *the_chest; |
int i,xl,yl; | | int i,xl,yl; |
| | |
| | the_chest = get_archetype("chest"); /* was "chest_2" */ |
| | |
/* first, find a place to put the chest. */ | | /* first, find a place to put the chest. */ |
i = find_first_free_spot(find_archetype("chest"),map,x,y); | | i = find_first_free_spot(the_chest,map,x,y); |
if (i == -1) | | if (i == -1) { |
| | free_object(the_chest); |
return NULL; | | return NULL; |
| | } |
xl = x + freearr_x[i]; yl = y + freearr_y[i]; | | xl = x + freearr_x[i]; yl = y + freearr_y[i]; |
| | |
/* if the placement is blocked, return a fail. */ | | /* if the placement is blocked, return a fail. */ |
if(wall_blocked(map,xl,yl)) return 0; | | if(wall_blocked(map,xl,yl)) return 0; |
| | |
| | |
/* use the nicer container-chests for multiple treasures... Allows locking. */ | | |
if(n_treasures > 1) | | |
the_chest = get_archetype("chest"); /* was "chest_2" */ | | |
else | | |
the_chest = get_archetype("chest"); | | |
| | |
| | |
/* put the treasures in the chest. */ | | /* put the treasures in the chest. */ |
/* if(style_map) { */ | | /* if(style_map) { */ |
if(0) { /* don't use treasure style maps for now! */ | | if(0) { /* don't use treasure style maps for now! */ |
| | |
for(tries = 0; tries < 15 && freeindex == -1; tries++) { | | for(tries = 0; tries < 15 && freeindex == -1; tries++) { |
kx = (RANDOM()%(RP->Xsize-2))+1; | | kx = (RANDOM()%(RP->Xsize-2))+1; |
ky = (RANDOM()%(RP->Ysize-2))+1; | | ky = (RANDOM()%(RP->Ysize-2))+1; |
freeindex = find_first_free_spot(the_key->arch,map,kx,ky); | | freeindex = find_first_free_spot(the_key,map,kx,ky); |
} | | } |
if(freeindex != -1) { | | if(freeindex != -1) { |
kx += freearr_x[freeindex]; | | kx += freearr_x[freeindex]; |
| | |
} | | } |
} | | } |
/* give up and return the closest free spot. */ | | /* give up and return the closest free spot. */ |
i = find_first_free_spot(find_archetype("chest"),map,x,y); | | i = find_first_free_spot(&find_archetype("chest")->clone,map,x,y); |
if(i!=-1&&i<SIZEOFFREE) { | | if(i!=-1&&i<SIZEOFFREE) { |
*cx = x +freearr_x[i]; | | *cx = x +freearr_x[i]; |
*cy = y +freearr_y[i]; | | *cy = y +freearr_y[i]; |