summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorLupus <Lupus@54d463be-8e91-2dee-dedb-b68131a5f0ec>2005-02-28 15:32:06 +0000
committerLupus <Lupus@54d463be-8e91-2dee-dedb-b68131a5f0ec>2005-02-28 15:32:06 +0000
commitdccedd13273e68218cca14df599962ef48170f29 (patch)
tree48d85bf62db5820234574d7cbd7a3c99ff6caef9 /src/map
parenta42a5f03ddb865767dbf08c745a247b5c79315aa (diff)
downloadhercules-dccedd13273e68218cca14df599962ef48170f29.tar.gz
hercules-dccedd13273e68218cca14df599962ef48170f29.tar.bz2
hercules-dccedd13273e68218cca14df599962ef48170f29.tar.xz
hercules-dccedd13273e68218cca14df599962ef48170f29.zip
altered once_mobspawn a bit (got from Freya, tested)
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1194 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map')
-rw-r--r--src/map/mob.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/map/mob.c b/src/map/mob.c
index 14d1d9d95..c2702817a 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -121,6 +121,7 @@ int mob_once_spawn(struct map_session_data *sd,char *mapname,
{
struct mob_data *md=NULL;
int m,count,lv=255,r=class_;
+ int c,j=0;
if( sd )
lv=sd->status.base_level;
@@ -152,14 +153,28 @@ int mob_once_spawn(struct map_session_data *sd,char *mapname,
// if(battle_config.etc_log)
// printf("mobclass=%d try=%d\n",class_,i);
}
-
- if(sd){
- if(x<=0) x=sd->bl.x;
- if(y<=0) y=sd->bl.y;
- }else if(x<=0 || y<=0){
+ if (sd) { //even if the coords were wrong, spawn mob anyways (but look for most suitable coords first) Got from Freya [Lupus]
+ if (x <= 0 || y <= 0) {
+ if (x <= 0) x = sd->bl.x + rand() % 3 - 1;
+ if (y <= 0) y = sd->bl.y + rand() % 3 - 1;
+ if ((c = map_getcell(m, x, y)) == 1 || c == 5) {
+ x = sd->bl.x;
+ y = sd->bl.y;
+ }
+ }
+ } else if (x <= 0 || y <= 0) {
printf("mob_once_spawn: %i at %s x:%i y:%i\n ??\n",class_,map[m].name,x,y); //got idea from Freya [Lupus]
+ do {
+ x = rand() % (map[m].xs - 2) + 1;
+ y = rand() % (map[m].ys - 2) + 1;
+ } while (((c = map_getcell(m, x, y)) == 1 || c == 5) && j++ < 64);
+ if (c == 1 || c == 5) { // not solved?
+ x = 0;
+ y = 0;
+ }
}
+
for(count=0;count<amount;count++){
md=(struct mob_data *)aCalloc(1,sizeof(struct mob_data));
memset(md, '\0', sizeof *md);