Custom-Script-Event-ATTACKMOBEVENT.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| From 97c0803f11757cc61cb4496ebfab6c8d38579fc8 Mon Sep 17 00:00:00 2001 | |
| From: Harvin <haruna.epic@gmail.com> | |
| Date: Thu, 12 Nov 2020 16:11:37 +0700 | |
| Subject: [PATCH] Custom Script Event : ATTACKMOBEVENT | |
| --- | |
| src/map/map.hpp | 1 + | |
| src/map/mob.cpp | 3 +++ | |
| src/map/npc.cpp | 2 ++ | |
| src/map/npc.hpp | 1 + | |
| src/map/script.cpp | 1 + | |
| src/map/script.hpp | 1 + | |
| src/map/script_constants.hpp | 1 + | |
| 7 files changed, 10 insertions(+) | |
| diff --git a/src/map/map.hpp b/src/map/map.hpp | |
| index 7e4575046..d35a93bf7 100644 | |
| --- a/src/map/map.hpp | |
| +++ b/src/map/map.hpp | |
| @@ -602,6 +602,7 @@ enum e_mapflag : int16 { | |
| MF_PRIVATEAIRSHIP_SOURCE, | |
| MF_PRIVATEAIRSHIP_DESTINATION, | |
| MF_SKILL_DURATION, | |
| + MF_ATTACKMOBEVENT, | |
| MF_MAX | |
| }; | |
| diff --git a/src/map/mob.cpp b/src/map/mob.cpp | |
| index 97d15eb8d..72bec7421 100644 | |
| --- a/src/map/mob.cpp | |
| +++ b/src/map/mob.cpp | |
| @@ -2289,6 +2289,9 @@ void mob_log_damage(struct mob_data *md, struct block_list *src, int damage) | |
| char_id = sd->status.char_id; | |
| if( damage ) | |
| md->attacked_id = src->id; | |
| + struct map_data *mapdata = map_getmapdata(sd->bl.m); | |
| + if (mapdata->flag[MF_ATTACKMOBEVENT]) | |
| + npc_script_event(sd, NPCE_ATTACKMOBEVENT); | |
| break; | |
| } | |
| case BL_HOM: | |
| diff --git a/src/map/npc.cpp b/src/map/npc.cpp | |
| index 8259a7f8c..bb8ca2055 100644 | |
| --- a/src/map/npc.cpp | |
| +++ b/src/map/npc.cpp | |
| @@ -4624,6 +4624,8 @@ const char *npc_get_script_event_name(int npce_index) | |
| return script_config.kill_pc_event_name; | |
| case NPCE_KILLNPC: | |
| return script_config.kill_mob_event_name; | |
| + case NPCE_ATTACKMOBEVENT: | |
| + return script_config.attack_mob_event_name; | |
| default: | |
| ShowError("npc_get_script_event_name: npce_index is outside the array limits: %d (max: %d).\n", npce_index, NPCE_MAX); | |
| return NULL; | |
| diff --git a/src/map/npc.hpp b/src/map/npc.hpp | |
| index 53e6ba7e8..42cf79c7d 100644 | |
| --- a/src/map/npc.hpp | |
| +++ b/src/map/npc.hpp | |
| @@ -1224,6 +1224,7 @@ enum npce_event : uint8 { | |
| NPCE_DIE, | |
| NPCE_KILLPC, | |
| NPCE_KILLNPC, | |
| + NPCE_ATTACKMOBEVENT, | |
| NPCE_MAX | |
| }; | |
| struct view_data* npc_get_viewdata(int class_); | |
| diff --git a/src/map/script.cpp b/src/map/script.cpp | |
| index b4dceefc3..f5ae203ca 100644 | |
| --- a/src/map/script.cpp | |
| +++ b/src/map/script.cpp | |
| @@ -260,6 +260,7 @@ struct Script_Config script_config = { | |
| // PC related | |
| "OnPCDieEvent", //die_event_name | |
| "OnPCKillEvent", //kill_pc_event_name | |
| + "OnPCAttackMobEvent", //It's executed every attack in a certain map (Zephyr) | |
| "OnNPCKillEvent", //kill_mob_event_name | |
| "OnPCLoginEvent", //login_event_name | |
| "OnPCLogoutEvent", //logout_event_name | |
| diff --git a/src/map/script.hpp b/src/map/script.hpp | |
| index 804d00332..caf25d219 100644 | |
| --- a/src/map/script.hpp | |
| +++ b/src/map/script.hpp | |
| @@ -155,6 +155,7 @@ struct Script_Config { | |
| const char *die_event_name; | |
| const char *kill_pc_event_name; | |
| const char *kill_mob_event_name; | |
| + const char *attack_mob_event_name; | |
| const char *login_event_name; | |
| const char *logout_event_name; | |
| const char *loadmap_event_name; | |
| diff --git a/src/map/script_constants.hpp b/src/map/script_constants.hpp | |
| index df56d305a..d7927319b 100644 | |
| --- a/src/map/script_constants.hpp | |
| +++ b/src/map/script_constants.hpp | |
| @@ -478,6 +478,7 @@ | |
| export_constant(MF_PRIVATEAIRSHIP_SOURCE); | |
| export_constant(MF_PRIVATEAIRSHIP_DESTINATION); | |
| export_constant(MF_SKILL_DURATION); | |
| + export_constant(MF_ATTACKMOBEVENT); | |
| /* setcell types */ | |
| export_constant(CELL_WALKABLE); | |
| -- | |
| 2.29.2.windows.2 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment