diff options
author | gepard1984 <gepard1984@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2012-01-31 15:15:32 +0000 |
---|---|---|
committer | gepard1984 <gepard1984@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2012-01-31 15:15:32 +0000 |
commit | 2a3063c4e48c78fc4f778a06349a6e87dae89f50 (patch) | |
tree | 0007a689861982201c8c162dfd8bed44069eb634 /src/map | |
parent | efe35d69e31918c87c1b56528ca1c574b5b86b0d (diff) | |
download | hercules-2a3063c4e48c78fc4f778a06349a6e87dae89f50.tar.gz hercules-2a3063c4e48c78fc4f778a06349a6e87dae89f50.tar.bz2 hercules-2a3063c4e48c78fc4f778a06349a6e87dae89f50.tar.xz hercules-2a3063c4e48c78fc4f778a06349a6e87dae89f50.zip |
Merged `getmapmobs` script function into `mobcount` (bugreport:244). See script commands documentation for details.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@15530 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/script.c | 64 |
1 files changed, 18 insertions, 46 deletions
diff --git a/src/map/script.c b/src/map/script.c index 0e71a0c97..0a92ae835 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -10489,7 +10489,7 @@ static int buildin_mobcount_sub(struct block_list *bl,va_list ap) // Added by Ro { char *event=va_arg(ap,char *); struct mob_data *md = ((struct mob_data *)bl); - if(strcmp(event,md->npc_event)==0 && md->status.hp > 0) + if( md->status.hp > 0 && (!event || strcmp(event,md->npc_event) == 0) ) return 1; return 0; } @@ -10500,9 +10500,22 @@ BUILDIN_FUNC(mobcount) // Added by RoVeRT int m; mapname=script_getstr(st,2); event=script_getstr(st,3); - check_event(st, event); - if( (m = map_mapname2mapid(mapname)) < 0 ) { + if( strcmp(event, "all") == 0 ) + event = NULL; + else + check_event(st, event); + + if( strcmp(mapname, "this") == 0 ) { + struct map_session_data *sd = script_rid2sd(st); + if( sd ) + m = sd->bl.m; + else { + script_pushint(st,-1); + return 0; + } + } + else if( (m = map_mapname2mapid(mapname)) < 0 ) { script_pushint(st,-1); return 0; } @@ -10517,6 +10530,7 @@ BUILDIN_FUNC(mobcount) // Added by RoVeRT return 0; } + BUILDIN_FUNC(marriage) { const char *partner=script_getstr(st,2); @@ -11860,47 +11874,6 @@ BUILDIN_FUNC(jump_zero) } /*========================================== - * GetMapMobs - returns mob counts on a set map: - e.g. GetMapMobs("prontera") - use "this" - for player's map - *------------------------------------------*/ -BUILDIN_FUNC(getmapmobs) -{ - const char *str=NULL; - int m=-1,bx,by; - int count=0; - struct block_list *bl; - - str=script_getstr(st,2); - - if(strcmp(str,"this")==0){ - TBL_PC *sd=script_rid2sd(st); - if(sd) - m=sd->bl.m; - else{ - script_pushint(st,-1); - return 0; - } - }else - m=map_mapname2mapid(str); - - if(m < 0){ - script_pushint(st,-1); - return 0; - } - - for(by=0;by<=(map[m].ys-1)/BLOCK_SIZE;by++) - for(bx=0;bx<=(map[m].xs-1)/BLOCK_SIZE;bx++) - for( bl = map[m].block_mob[bx+by*map[m].bxs] ; bl != NULL ; bl = bl->next ) - if(bl->x>=0 && bl->x<=map[m].xs-1 && bl->y>=0 && bl->y<=map[m].ys-1) - count++; - - script_pushint(st,count); - return 0; -} - -/*========================================== * movenpc [MouseJstr] *------------------------------------------*/ BUILDIN_FUNC(movenpc) @@ -16236,8 +16209,7 @@ struct script_function buildin_func[] = { BUILDIN_DEF(getmercinfo,"i?"), BUILDIN_DEF(checkequipedcard,"i"), BUILDIN_DEF(jump_zero,"il"), //for future jA script compatibility - BUILDIN_DEF(globalmes,"s?"), - BUILDIN_DEF(getmapmobs,"s"), //end jA addition + BUILDIN_DEF(globalmes,"s?"), //end jA addition BUILDIN_DEF(unequip,"i"), // unequip command [Spectre] BUILDIN_DEF(getstrlen,"s"), //strlen [Valaris] BUILDIN_DEF(charisalpha,"si"), //isalpha [Valaris] |