diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-11-30 19:27:14 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-11-30 19:27:14 +0300 |
commit | 50a97b0ef2a8365d87a8a57047caccb0c050c56b (patch) | |
tree | fb16dc736890604e468ed379786f45989763f4dd /src/map | |
parent | c3c009a7e2c3ad40048935de0d0538081cf613be (diff) | |
download | evol-hercules-50a97b0ef2a8365d87a8a57047caccb0c050c56b.tar.gz evol-hercules-50a97b0ef2a8365d87a8a57047caccb0c050c56b.tar.bz2 evol-hercules-50a97b0ef2a8365d87a8a57047caccb0c050c56b.tar.xz evol-hercules-50a97b0ef2a8365d87a8a57047caccb0c050c56b.zip |
add map flag what prevent from attacking mobs.
New map flag: nopve
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/data/mapd.c | 1 | ||||
-rw-r--r-- | src/map/init.c | 1 | ||||
-rw-r--r-- | src/map/npc.c | 7 | ||||
-rw-r--r-- | src/map/pc.c | 20 | ||||
-rw-r--r-- | src/map/pc.h | 2 | ||||
-rw-r--r-- | src/map/struct/mapdext.h | 4 |
6 files changed, 35 insertions, 0 deletions
diff --git a/src/map/data/mapd.c b/src/map/data/mapd.c index a1d8f11..a557dc9 100644 --- a/src/map/data/mapd.c +++ b/src/map/data/mapd.c @@ -35,5 +35,6 @@ struct MapdExt *mapd_create(void) return NULL; data->mask = 1; data->invisible = false; + data->flag.nopve = 0; return data; } diff --git a/src/map/init.c b/src/map/init.c index a67ddba..c8f2ad3 100644 --- a/src/map/init.c +++ b/src/map/init.c @@ -102,6 +102,7 @@ HPExport void plugin_init (void) addHookPre("pc->setregistry", epc_setregistry); addHookPre("pc->equipitem_pos", epc_equipitem_pos); addHookPre("pc->unequipitem_pos", epc_unequipitem_pos); + addHookPre("pc->can_attack", epc_can_attack); addHookPre("npc->checknear", enpc_checknear); addHookPre("npc->parse_unknown_mapflag", enpc_parse_unknown_mapflag); addHookPre("clif->quest_send_list", eclif_quest_send_list); diff --git a/src/map/npc.c b/src/map/npc.c index 62dccfe..8ad68af 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -85,6 +85,13 @@ void enpc_parse_unknown_mapflag(const char *name, char *w3, char *w4, const char if (data) data->mask = atoi(w4); } + else if (!strcmpi(w3, "nopve")) + { + int16 m = map->mapname2mapid(name); + struct MapdExt *data = mapd_get(m); + if (data) + data->flag.nopve = 1; + } else { ShowError("npc_parse_mapflag: unrecognized mapflag '%s' in file '%s', line '%d'.\n", w3, filepath, strline(buffer,start-buffer)); diff --git a/src/map/pc.c b/src/map/pc.c index 524c130..fddcdea 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -14,7 +14,9 @@ #include "../../../map/pc.h" #include "map/pc.h" +#include "map/data/mapd.h" #include "map/data/session.h" +#include "map/struct/mapdext.h" #include "map/struct/sessionext.h" int langScriptId; @@ -122,3 +124,21 @@ void epc_unequipitem_pos(struct map_session_data *sd, int *nPtr, int *posPtr) #undef unequipPos #undef unequipPos2 + +bool epc_can_attack (struct map_session_data *sd, int *target_id) +{ + if (!sd) + return false; + + struct MapdExt *data = mapd_get(sd->bl.m); + if (!data) + return true; + if (data->flag.nopve) + { + if (map->id2md(*target_id)) + { + hookStop(); + return false; + } + } +} diff --git a/src/map/pc.h b/src/map/pc.h index 104e8d5..ac6d723 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -17,4 +17,6 @@ void epc_equipitem_pos(struct map_session_data *sd, struct item_data *id, int *p void epc_unequipitem_pos(struct map_session_data *sd, int *nPtr, int *posPtr); +bool epc_can_attack (struct map_session_data *sd, int *target_id); + #endif // EVOL_MAP_PC diff --git a/src/map/struct/mapdext.h b/src/map/struct/mapdext.h index 0c3c03a..15fee7f 100644 --- a/src/map/struct/mapdext.h +++ b/src/map/struct/mapdext.h @@ -8,6 +8,10 @@ struct MapdExt { unsigned int mask; bool invisible; + struct MapdExtFlag + { + unsigned nopve : 1; + } flag; }; #endif // EVOL_MAP_MAPDEXT |