summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-11-05 17:18:59 +0300
committerAndrei Karas <akaras@inbox.ru>2015-11-05 17:18:59 +0300
commit49f8efc63324fdb1db8fd7110508988370ddfe01 (patch)
treee345ad5d7ac12c8341157612e0addf298aaea6b8
parent79fd3bacf40f3496dcc8e952fa9f84c8dbbb23ca (diff)
downloadevol-hercules-49f8efc63324fdb1db8fd7110508988370ddfe01.tar.gz
evol-hercules-49f8efc63324fdb1db8fd7110508988370ddfe01.tar.bz2
evol-hercules-49f8efc63324fdb1db8fd7110508988370ddfe01.tar.xz
evol-hercules-49f8efc63324fdb1db8fd7110508988370ddfe01.zip
Add pseudo npc varibale .alwaysVisible for show npc from any range on map.
-rw-r--r--src/emap/clif.c2
-rw-r--r--src/emap/data/mapd.c1
-rw-r--r--src/emap/init.c1
-rw-r--r--src/emap/map.c84
-rw-r--r--src/emap/map.h5
-rw-r--r--src/emap/script.c16
-rw-r--r--src/emap/struct/mapdext.h5
7 files changed, 113 insertions, 1 deletions
diff --git a/src/emap/clif.c b/src/emap/clif.c
index 5e6d7e4..b04b3b5 100644
--- a/src/emap/clif.c
+++ b/src/emap/clif.c
@@ -23,6 +23,7 @@
#include "emap/clif.h"
#include "emap/lang.h"
+#include "emap/map.h"
#include "emap/send.h"
#include "emap/data/mapd.h"
#include "emap/data/session.h"
@@ -530,6 +531,7 @@ void eclif_parse_LoadEndAck_post(int *fdPtr __attribute__ ((unused)),
{ // some messages not sent if map not changed
map->iwall_get(sd);
}
+ map_alwaysVisible_send(sd);
}
void eclif_changelook2(struct block_list *bl, int type, int val,
diff --git a/src/emap/data/mapd.c b/src/emap/data/mapd.c
index feaabaf..e7f7ee4 100644
--- a/src/emap/data/mapd.c
+++ b/src/emap/data/mapd.c
@@ -38,5 +38,6 @@ struct MapdExt *mapd_create(void)
data->mask = 1;
data->invisible = false;
data->flag.nopve = 0;
+ VECTOR_INIT(data->npcs);
return data;
}
diff --git a/src/emap/init.c b/src/emap/init.c
index fbe18d6..5b3352e 100644
--- a/src/emap/init.c
+++ b/src/emap/init.c
@@ -190,6 +190,7 @@ HPExport void plugin_init (void)
addHookPre("unit->can_move", eunit_can_move);
addHookPre("unit->walktoxy", eunit_walktoxy);
addHookPre("mail->invalid_operation", email_invalid_operation);
+ addHookPre("map->list_final", edo_final_maps);
addHookPre("map->cell2gat", emap_cell2gat);
addHookPre("map->gat2cell", emap_gat2cell);
addHookPre("map->getcellp", emap_getcellp);
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);
+ }
+}
diff --git a/src/emap/map.h b/src/emap/map.h
index 1e57749..1813d57 100644
--- a/src/emap/map.h
+++ b/src/emap/map.h
@@ -39,5 +39,10 @@ bool emap_iwall_set2(int m,
int x2, int y2,
int mask,
const char *name);
+void map_alwaysVisible_add(const struct block_list *bl);
+void map_alwaysVisible_delete(const struct block_list *bl);
+bool map_alwaysVisible_find(const struct block_list *bl);
+void map_alwaysVisible_send(TBL_PC *sd);
+void edo_final_maps(void);
#endif // EVOL_MAP_MAP
diff --git a/src/emap/script.c b/src/emap/script.c
index b8f54a0..0cadc03 100644
--- a/src/emap/script.c
+++ b/src/emap/script.c
@@ -177,6 +177,15 @@ void eset_reg_npcscope_num(struct script_state* st, struct reg_db *n, int64 *num
ext->walkMask = *val;
hookStop();
}
+ else if (!strcmp(name, ".alwaysVisible"))
+ {
+ getExt1();
+ if (*val)
+ map_alwaysVisible_add(&nd->bl);
+ else
+ map_alwaysVisible_delete(&nd->bl);
+ hookStop();
+ }
}
int eget_val_npcscope_num(struct script_state* st, struct reg_db *n, struct script_data* data)
@@ -254,6 +263,13 @@ int eget_val_npcscope_num(struct script_state* st, struct reg_db *n, struct scri
hookStop();
return ext->walkMask;
}
+ else if (!strcmp(name, ".alwaysVisible"))
+ {
+ getExt1Return(0);
+ bool res = map_alwaysVisible_find(&nd->bl);
+ hookStop();
+ return res;
+ }
return 0;
}
diff --git a/src/emap/struct/mapdext.h b/src/emap/struct/mapdext.h
index fb75dd3..c352221 100644
--- a/src/emap/struct/mapdext.h
+++ b/src/emap/struct/mapdext.h
@@ -4,14 +4,17 @@
#ifndef EVOL_MAP_MAPDEXT
#define EVOL_MAP_MAPDEXT
+#include "common/db.h"
+
struct MapdExt
{
unsigned int mask;
- bool invisible;
+ VECTOR_DECL(int) npcs;
struct MapdExtFlag
{
unsigned nopve : 1;
} flag;
+ bool invisible;
};
#endif // EVOL_MAP_MAPDEXT