From 2a3063c4e48c78fc4f778a06349a6e87dae89f50 Mon Sep 17 00:00:00 2001 From: gepard1984 Date: Tue, 31 Jan 2012 15:15:32 +0000 Subject: 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 --- src/map/script.c | 64 ++++++++++++++++---------------------------------------- 1 file changed, 18 insertions(+), 46 deletions(-) (limited to 'src/map') 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); @@ -11859,47 +11873,6 @@ BUILDIN_FUNC(jump_zero) return 0; } -/*========================================== - * 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] *------------------------------------------*/ @@ -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] -- cgit v1.2.3-70-g09d2