viewing paste OnNPCKillEvent_2.diff | Diff

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
 conf/map/script.conf |  6 ++++++
 src/map/mob.c        | 32 ++++++++++++++++++++------------
 src/map/script.c     |  2 ++
 src/map/script.h     |  1 +
 4 files changed, 29 insertions(+), 12 deletions(-)
 
diff --git a/conf/map/script.conf b/conf/map/script.conf
index 78514e6..ef5bb1f 100644
--- a/conf/map/script.conf
+++ b/conf/map/script.conf
@@ -59,6 +59,12 @@ script_configuration: {
    // Defaults to INT_MAX.
    //input_max_value: 2147483647
    input_max_value: 10000000
+
+   // Allow OnNPCKillEvent: to also run on monster with event labels ?
+   // 0 - No (old behaviour)
+   // 1 - Yes. (unsafe, you must know what you are doing !)
+   // 2 - Only run on the map without 'nosave' mapflag (recommended)
+   kill_mob_event_type: 0
 }
 
 import: "conf/import/script.conf"
diff --git a/src/map/mob.c b/src/map/mob.c
index 6bd7829..bfacd1d 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -2684,18 +2684,26 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) {
                mercenary->kills(sd->md);
        }
 
-       if( md->npc_event[0] && !md->state.npc_killmonster ) {
-           if( sd && battle_config.mob_npc_event_type ) {
-               pc->setparam(sd, SP_KILLERRID, sd->bl.id);
-               npc->event(sd,md->npc_event,0);
-           } else if( mvp_sd ) {
-               pc->setparam(mvp_sd, SP_KILLERRID, sd?sd->bl.id:0);
-               npc->event(mvp_sd,md->npc_event,0);
-           } else
-               npc->event_do(md->npc_event);
-       } else if( mvp_sd && !md->state.npc_killmonster ) {
-           pc->setparam(mvp_sd, SP_KILLEDRID, md->class_);
-           npc->script_event(mvp_sd, NPCE_KILLNPC); // PCKillNPC [Lance]
+       if (!md->state.npc_killmonster) {
+           if (md->npc_event[0]) {
+               if (sd && battle_config.mob_npc_event_type) {
+                   pc->setparam(sd, SP_KILLEDRID, md->class_);
+                   pc->setparam(sd, SP_KILLERRID, sd->bl.id);
+                   npc->event(sd, md->npc_event, 0);
+                   if (script->config.kill_mob_event_type == 1 || (script->config.kill_mob_event_type == 2 && !map->list[m].flag.nosave))
+                       npc->script_event(mvp_sd, NPCE_KILLNPC);
+               } else if (mvp_sd) {
+                   pc->setparam(mvp_sd, SP_KILLEDRID, md->class_);
+                   pc->setparam(mvp_sd, SP_KILLERRID, sd ? sd->bl.id : 0);
+                   npc->event(mvp_sd, md->npc_event, 0);
+                   if (script->config.kill_mob_event_type == 1 || (script->config.kill_mob_event_type == 2 && !map->list[m].flag.nosave))
+                       npc->script_event(mvp_sd, NPCE_KILLNPC);
+               } else
+                   npc->event_do(md->npc_event);
+           } else if (mvp_sd) {
+               pc->setparam(mvp_sd, SP_KILLEDRID, md->class_);
+               npc->script_event(mvp_sd, NPCE_KILLNPC); // PCKillNPC [Lance]
+           }
        }
 
        md->status.hp = 1;
diff --git a/src/map/script.c b/src/map/script.c
index d935008..dbf16ec 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -4804,6 +4804,7 @@ bool script_config_read(const char *filename, bool imported)
    libconfig->setting_lookup_int(setting, "check_gotocount", &script->config.check_gotocount);
    libconfig->setting_lookup_int(setting, "input_min_value", &script->config.input_min_value);
    libconfig->setting_lookup_int(setting, "input_max_value", &script->config.input_max_value);
+   libconfig->setting_lookup_int(setting, "kill_mob_event_type", &script->config.kill_mob_event_type);
 
    if (!HPM->parse_conf(&config, filename, HPCT_SCRIPT, imported))
        retval = false;
@@ -25573,6 +25574,7 @@ void script_defaults(void)
    script->config.check_gotocount = 2048;
    script->config.input_min_value = 0;
    script->config.input_max_value = INT_MAX;
+   script->config.kill_mob_event_type = 0;
    script->config.die_event_name = "OnPCDieEvent";
    script->config.kill_pc_event_name = "OnPCKillEvent";
    script->config.kill_mob_event_name = "OnNPCKillEvent";
diff --git a/src/map/script.h b/src/map/script.h
index a0cfb76..5e81651 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -482,6 +482,7 @@ struct Script_Config {
    int check_gotocount;
    int input_min_value;
    int input_max_value;
+   int kill_mob_event_type;
 
    const char *die_event_name;
    const char *kill_pc_event_name;
 
Viewed 2884 times, submitted by AnnieRuru.