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

Comparing deliantra/server/random_maps/monster.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_monster_c = 2 * static char *rcsid_monster_c =
3 * "$Id: monster.C,v 1.1 2006/08/13 17:16:03 elmex Exp $"; 3 * "$Id: monster.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
29#include <global.h> 29#include <global.h>
30#include <random_map.h> 30#include <random_map.h>
31#include <rproto.h> 31#include <rproto.h>
32 32
33/* some monsters are multisquare, and these guys require special 33/* some monsters are multisquare, and these guys require special
34 handling. */ 34 handling. */
35 35
36void insert_multisquare_ob_in_map(object *new_obj,mapstruct *map) { 36void insert_multisquare_ob_in_map(object *new_obj,mapstruct *map) {
37 int x,y; 37 int x,y;
38 archetype *at; 38 archetype *at;
39 object *old_seg; 39 object *old_seg;
58 } 58 }
59 old_seg->more = NULL; 59 old_seg->more = NULL;
60 60
61 61
62} 62}
63 63
64 64
65/* place some monsters into the map. */ 65/* place some monsters into the map. */
66void place_monsters(mapstruct *map, char *monsterstyle, int difficulty,RMParms *RP) { 66void place_monsters(mapstruct *map, char *monsterstyle, int difficulty,RMParms *RP) {
67 char styledirname[256]; 67 char styledirname[256];
68 mapstruct *style_map=0; 68 mapstruct *style_map=0;
79 79
80 total_experience = 0; 80 total_experience = 0;
81 failed_placements = 0; 81 failed_placements = 0;
82 exp_per_sq = 0; 82 exp_per_sq = 0;
83 while(exp_per_sq <= level_exp(difficulty,1.0) && failed_placements < 100 83 while(exp_per_sq <= level_exp(difficulty,1.0) && failed_placements < 100
84 && number_monsters < (RP->Xsize * RP->Ysize)/8) { 84 && number_monsters < (RP->Xsize * RP->Ysize)/8) {
85 object *this_monster=pick_random_object(style_map); 85 object *this_monster=pick_random_object(style_map);
86 int x,y,freeindex; 86 int x,y,freeindex;
87 if(this_monster == NULL) return; /* no monster?? */ 87 if(this_monster == NULL) return; /* no monster?? */
88 x = RANDOM() % RP->Xsize; 88 x = RANDOM() % RP->Xsize;
89 y = RANDOM() % RP->Ysize; 89 y = RANDOM() % RP->Ysize;
90 freeindex = find_first_free_spot(this_monster,map,x,y); 90 freeindex = find_first_free_spot(this_monster,map,x,y);
91 if(freeindex!=-1) { 91 if(freeindex!=-1) {
92 object *new_monster = arch_to_object(this_monster->arch); 92 object *new_monster = arch_to_object(this_monster->arch);
93 x += freearr_x[freeindex]; 93 x += freearr_x[freeindex];
94 y += freearr_y[freeindex]; 94 y += freearr_y[freeindex];
95 copy_object_with_inv(this_monster,new_monster); 95 copy_object_with_inv(this_monster,new_monster);
96 new_monster->x = x; 96 new_monster->x = x;
97 new_monster->y = y; 97 new_monster->y = y;
98 insert_multisquare_ob_in_map(new_monster,map); 98 insert_multisquare_ob_in_map(new_monster,map);
99 total_experience+= this_monster->stats.exp; 99 total_experience+= this_monster->stats.exp;
100 for(at = new_monster->arch; at != NULL; at = at->more) 100 for(at = new_monster->arch; at != NULL; at = at->more)
101 number_monsters++; 101 number_monsters++;
102 RP->total_map_hp+=new_monster->stats.hp; /* a global count */ 102 RP->total_map_hp+=new_monster->stats.hp; /* a global count */
103 } 103 }
104 else { 104 else {
105 failed_placements++; 105 failed_placements++;
106 } 106 }
107 exp_per_sq=(sint64)(((double)1000*total_experience)/(MAP_WIDTH(map)*MAP_HEIGHT(map)+1)); 107 exp_per_sq=(sint64)(((double)1000*total_experience)/(MAP_WIDTH(map)*MAP_HEIGHT(map)+1));
108 } 108 }
109} 109}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines