version 1.5 | | version 1.6 |
---|
| | |
/* | | /* |
* static char *rcsid_monster_c = | | * static char *rcsid_monster_c = |
* "$Id: monster.c,v 1.5 2000/06/19 01:34:31 cvs Exp $"; | | * "$Id: monster.c,v 1.6 2000/12/15 03:09:19 peterm Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
| | |
#include <global.h> | | #include <global.h> |
#include <random_map.h> | | #include <random_map.h> |
| | #include <rproto.h> |
| | |
/* some monsters are multisquare, and these guys require special | | /* some monsters are multisquare, and these guys require special |
handling. */ | | handling. */ |
| | |
| | |
| | |
/* place some monsters into the map. */ | | /* place some monsters into the map. */ |
void place_monsters(mapstruct *map, char *monsterstyle, int difficulty) { | | void place_monsters(mapstruct *map, char *monsterstyle, int difficulty,RMParms *RP) { |
char styledirname[256]; | | char styledirname[256]; |
mapstruct *style_map=0; | | mapstruct *style_map=0; |
long unsigned int total_experience; /* used for matching difficulty */ | | long unsigned int total_experience; /* used for matching difficulty */ |
| | |
failed_placements = 0; | | failed_placements = 0; |
exp_per_sq = 0; | | exp_per_sq = 0; |
while(exp_per_sq <= level_exp(difficulty,1.0) && failed_placements < 100 | | while(exp_per_sq <= level_exp(difficulty,1.0) && failed_placements < 100 |
&& number_monsters < (Xsize * Ysize)/8) { | | && number_monsters < (RP->Xsize * RP->Ysize)/8) { |
object *this_monster=pick_random_object(style_map); | | object *this_monster=pick_random_object(style_map); |
int x,y,freeindex; | | int x,y,freeindex; |
if(this_monster == NULL) return; /* no monster?? */ | | if(this_monster == NULL) return; /* no monster?? */ |
x = RANDOM() % Xsize; | | x = RANDOM() % RP->Xsize; |
y = RANDOM() % Ysize; | | y = RANDOM() % RP->Ysize; |
freeindex = find_first_free_spot(this_monster->arch,map,x,y); | | freeindex = find_first_free_spot(this_monster->arch,map,x,y); |
if(freeindex!=-1) { | | if(freeindex!=-1) { |
object *new_monster = arch_to_object(this_monster->arch); | | object *new_monster = arch_to_object(this_monster->arch); |
| | |
insert_multisquare_ob_in_map(new_monster,map); | | insert_multisquare_ob_in_map(new_monster,map); |
total_experience+= this_monster->stats.exp; | | total_experience+= this_monster->stats.exp; |
number_monsters++; | | number_monsters++; |
total_map_hp+=new_monster->stats.hp; /* a global count */ | | RP->total_map_hp+=new_monster->stats.hp; /* a global count */ |
} | | } |
else { | | else { |
failed_placements++; | | failed_placements++; |