Added support for killmonster to fire OnMyMobDead optionally.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@12876 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
sketchyphoenix 2008-06-22 14:22:08 +00:00
parent 6fb09d253c
commit d218e11636
5 changed files with 36 additions and 5 deletions

View File

@ -7,7 +7,7 @@ IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
* Extended script command 'set' to return the variable reference (topic:190602). [FlavioJS] * Extended script command 'set' to return the variable reference (topic:190602). [FlavioJS]
* Fixed a bug where the "OnMyMobDead" event wouldn't trigger if the mob was killed and never attacked. (bugreport:1725) [SketchyPhoenix] * Fixed a bug where the "OnMyMobDead" event wouldn't trigger if the mob was killed and never attacked. (bugreport:1725) [SketchyPhoenix]
* Reworded a comment in can_copy to make more sense. * Reworded a comment in can_copy to make more sense.
* Modified *killmonsterall to support a new argument that will allow it to kill monsters using the new OnMyMobDead behavior (in order to avoid breaking older scripts). * Modified *killmonster and *killmonsterall to support a new argument that will allow it to kill monsters using the new OnMyMobDead behavior (in order to avoid breaking older scripts) (bugreport:1734)
2008/06/19 2008/06/19
* Added Sirius_White's fix for sense working on emperium. (bugreport: 1679) [SketchyPhoenix] * Added Sirius_White's fix for sense working on emperium. (bugreport: 1679) [SketchyPhoenix]
* Fixed SC_CHANGEUNDEAD behavior: Blessing and Increase AGI deals 1 damage and does not apply buffs to those inflicted by it. * Fixed SC_CHANGEUNDEAD behavior: Blessing and Increase AGI deals 1 damage and does not apply buffs to those inflicted by it.

View File

@ -4609,7 +4609,7 @@ For more good examples see just about any official 2-1 or 2-2 job quest script.
--------------------------------------- ---------------------------------------
*killmonster "<map name>","<event label>"; *killmonster "<map name>","<event label>"{,<type>};
This command will kill all monsters that were spawned with 'monster' or This command will kill all monsters that were spawned with 'monster' or
'addmonster' and have a specified event label attached to them. Commonly used to 'addmonster' and have a specified event label attached to them. Commonly used to
@ -4621,6 +4621,10 @@ command, and all monsters summoned with GM commands, but no other ones - that
is, all non-permanent monsters) on the specified map will be killed regardless is, all non-permanent monsters) on the specified map will be killed regardless
of the event label value. of the event label value.
As of r12876 killmonster now supports an optional argument type. Using 1 for type
will make the command fire "OnMyMobDead" events from any monsters that do die
as a result of this command.
--------------------------------------- ---------------------------------------
*killmonsterall "<map name>"{,<type>}; *killmonsterall "<map name>"{,<type>};

View File

@ -2532,7 +2532,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
if(md->nd) if(md->nd)
mob_script_callback(md, src, CALLBACK_DEAD); mob_script_callback(md, src, CALLBACK_DEAD);
else else
if(md->npc_event[0]) if(md->npc_event[0] && !md->npc_killmonster)
{ {
md->status.hp = 0; //So that npc_event invoked functions KNOW that I am dead. md->status.hp = 0; //So that npc_event invoked functions KNOW that I am dead.
if(src) if(src)

View File

@ -141,6 +141,7 @@ struct mob_data {
short skillidx; short skillidx;
unsigned int skilldelay[MAX_MOBSKILL]; unsigned int skilldelay[MAX_MOBSKILL];
char npc_event[50]; char npc_event[50];
int npc_killmonster; //for new killmonster behavior
}; };

View File

@ -7468,6 +7468,24 @@ BUILDIN_FUNC(areamonster)
/*========================================== /*==========================================
* *
*------------------------------------------*/ *------------------------------------------*/
static int buildin_killmonster_sub_strip(struct block_list *bl,va_list ap)
{ //same fix but with killmonster instead - stripping events from mobs.
TBL_MOB* md = (TBL_MOB*)bl;
char *event=va_arg(ap,char *);
int allflag=va_arg(ap,int);
md->npc_killmonster = 1;
if(!allflag){
if(strcmp(event,md->npc_event)==0)
status_kill(bl);
}else{
if(!md->spawn)
status_kill(bl);
}
md->npc_killmonster = 0;
return 0;
}
static int buildin_killmonster_sub(struct block_list *bl,va_list ap) static int buildin_killmonster_sub(struct block_list *bl,va_list ap)
{ {
TBL_MOB* md = (TBL_MOB*)bl; TBL_MOB* md = (TBL_MOB*)bl;
@ -7496,7 +7514,15 @@ BUILDIN_FUNC(killmonster)
if( (m=map_mapname2mapid(mapname))<0 ) if( (m=map_mapname2mapid(mapname))<0 )
return 0; return 0;
map_foreachinmap(buildin_killmonster_sub, m, BL_MOB, event ,allflag);
if( script_hasdata(st,4) ) {
if ( script_getnum(st,4) == 1 ) {
map_foreachinmap(buildin_killmonster_sub, m, BL_MOB, event ,allflag);
return 0;
}
}
map_foreachinmap(buildin_killmonster_sub_strip, m, BL_MOB, event ,allflag);
return 0; return 0;
} }
@ -13456,7 +13482,7 @@ struct script_function buildin_func[] = {
BUILDIN_DEF(produce,"i"), BUILDIN_DEF(produce,"i"),
BUILDIN_DEF(monster,"siisii*"), BUILDIN_DEF(monster,"siisii*"),
BUILDIN_DEF(areamonster,"siiiisii*"), BUILDIN_DEF(areamonster,"siiiisii*"),
BUILDIN_DEF(killmonster,"ss"), BUILDIN_DEF(killmonster,"ss?"),
BUILDIN_DEF(killmonsterall,"s?"), BUILDIN_DEF(killmonsterall,"s?"),
BUILDIN_DEF(clone,"siisi*"), BUILDIN_DEF(clone,"siisi*"),
BUILDIN_DEF(doevent,"s"), BUILDIN_DEF(doevent,"s"),