diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-11-05 17:18:59 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-11-05 17:18:59 +0300 |
commit | 49f8efc63324fdb1db8fd7110508988370ddfe01 (patch) | |
tree | e345ad5d7ac12c8341157612e0addf298aaea6b8 /src/emap/map.c | |
parent | 79fd3bacf40f3496dcc8e952fa9f84c8dbbb23ca (diff) | |
download | plugin-49f8efc63324fdb1db8fd7110508988370ddfe01.tar.gz plugin-49f8efc63324fdb1db8fd7110508988370ddfe01.tar.bz2 plugin-49f8efc63324fdb1db8fd7110508988370ddfe01.tar.xz plugin-49f8efc63324fdb1db8fd7110508988370ddfe01.zip |
Add pseudo npc varibale .alwaysVisible for show npc from any range on map.
Diffstat (limited to 'src/emap/map.c')
-rw-r--r-- | src/emap/map.c | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/src/emap/map.c b/src/emap/map.c index 0a81291..67d279d 100644 --- a/src/emap/map.c +++ b/src/emap/map.c @@ -11,21 +11,25 @@ #include "common/HPMi.h" #include "common/memmgr.h" #include "common/mmo.h" +#include "common/nullpo.h" #include "common/socket.h" #include "common/strlib.h" #include "common/timer.h" #include "map/battle.h" #include "map/itemdb.h" #include "map/map.h" +#include "map/npc.h" #include "map/pc.h" #include "emap/permission.h" #include "emap/send.h" #include "emap/data/itemd.h" +#include "emap/data/mapd.h" #include "emap/data/mobd.h" #include "emap/data/npcd.h" #include "emap/data/session.h" #include "emap/struct/itemdext.h" +#include "emap/struct/mapdext.h" #include "emap/struct/mobdext.h" #include "emap/struct/npcdext.h" #include "emap/struct/sessionext.h" @@ -478,3 +482,83 @@ bool emap_iwall_set2(int m, int layer, int x1, int y1, int x2, int y2, int mask, map->list[m].iwall_num++; return true; } + +void map_alwaysVisible_add(const struct block_list *bl) +{ + if (!bl) + return; + struct MapdExt *data = mapd_get(bl->m); + if (!data) + return; + int f; + for (f = 0; f < VECTOR_LENGTH(data->npcs); f ++) + { + if (VECTOR_INDEX(data->npcs, f) == bl->id) + return; + } + VECTOR_ENSURE(data->npcs, 1, 1); + VECTOR_PUSH(data->npcs, bl->id); +} + +bool map_alwaysVisible_find(const struct block_list *bl) +{ + if (!bl) + return false; + struct MapdExt *data = mapd_get(bl->m); + if (!data) + return false; + int f; + for (f = 0; f < VECTOR_LENGTH(data->npcs); f ++) + { + if (VECTOR_INDEX(data->npcs, f) == bl->id) + return true; + } + return false; +} + +void map_alwaysVisible_delete(const struct block_list *bl) +{ + if (!bl) + return; + struct MapdExt *data = mapd_get(bl->m); + if (!data) + return; + int f; + for (f = 0; f < VECTOR_LENGTH(data->npcs); f ++) + { + if (VECTOR_INDEX(data->npcs, f) == bl->id) + { + VECTOR_ERASE(data->npcs, f); + return; + } + } +} + +void map_alwaysVisible_send(TBL_PC *sd) +{ + if (!sd) + return; + int f; + struct MapdExt *data = mapd_get(sd->bl.m); + if (!data) + return; + + for (f = 0; f < VECTOR_LENGTH(data->npcs); f ++) + { + const int id = VECTOR_INDEX(data->npcs, f); + TBL_NPC *npc = map->id2nd(id); + clif->set_unit_idle(&npc->bl, sd, SELF); + clif->charnameack(sd->fd, &npc->bl); + } +} + +void edo_final_maps(void) +{ + int f; + for (f = 0; f < map->count; f++) + { + struct MapdExt *data = mapd_get(f); + if (data) + VECTOR_CLEAR(data->npcs); + } +} |