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 | |
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
-rw-r--r-- | doc/script_commands.txt | 26 | ||||
-rw-r--r-- | src/map/script.c | 64 |
2 files changed, 29 insertions, 61 deletions
diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 68b62816e..c9bc08bf1 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -3087,15 +3087,6 @@ Example: --------------------------------------- -*getmapmobs("<map name>") - -This function will return the total count of monsters currently located on the -specified map. If the map name is given as "this", the map the invoking -character is on will be used. If the map is not found, or the invoker is not a -character while the map is "this", it will return -1. - ---------------------------------------- - *skillpointcount() Returns the total amount of skill points a character possesses (SkillPoint+SP's used in skills) @@ -5012,14 +5003,19 @@ per 'db/mob_db.txt'. Type is the kind of information returned. Valid types are: This function will count all the monsters on the specified map that have a given event label and return the number or 0 if it can't find any. Naturally, only -monsters spawned with 'monster' and 'areamonster' script commands can be like -this. - -However, apparently, if you pass this function an empty string for the event -label, it should return the total count of normal permanently respawning -monsters instead. With the current dynamic mobs system, where mobs are not kept +monsters spawned with 'monster' and 'areamonster' script commands can have non-empty +event label. +If you pass this function an empty string for the event label, it will return +the total count of monster without event label, including permanently spawning monsters. +With the dynamic mobs system enabled, where mobs are not kept in memory for maps with no actual people playing on them, this will return a 0 for any such map. +If the event label is given as "all", all monsters will be counted, regardless of +having any event label attached. + +If the map name is given as "this", the map the invoking character is on will +be used. If the map is not found, or the invoker is not a character while the map +is "this", it will return -1. --------------------------------------- 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] |