summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/init.c4
-rw-r--r--src/map/mapd.c1
-rw-r--r--src/map/mapdext.h1
-rw-r--r--src/map/script.c65
-rw-r--r--src/map/script.h4
-rw-r--r--src/map/scriptdefines.h17
6 files changed, 90 insertions, 2 deletions
diff --git a/src/map/init.c b/src/map/init.c
index cd0a5ed..019f53c 100644
--- a/src/map/init.c
+++ b/src/map/init.c
@@ -74,6 +74,10 @@ HPExport void plugin_init (void)
addScriptCommand("rif", "is*", rif);
addScriptCommand("countitemcolor", "v*", countItemColor);
addScriptCommand("misceffect", "i*", miscEffect);
+ addScriptCommand("setmapmask", "si", setMapMask);
+ addScriptCommand("addmapmask", "si", addMapMask);
+ addScriptCommand("removemapmask", "si", removeMapMask);
+ addScriptCommand("getmapmask", "s", getMapMask);
do_init_langs();
diff --git a/src/map/mapd.c b/src/map/mapd.c
index 2783f83..d47015c 100644
--- a/src/map/mapd.c
+++ b/src/map/mapd.c
@@ -33,6 +33,7 @@ struct MapdExt *mapd_create(void)
CREATE(data, struct MapdExt, 1);
if (!data)
return NULL;
+ data->mask = 0;
data->invisible = false;
return data;
}
diff --git a/src/map/mapdext.h b/src/map/mapdext.h
index 77d56f9..0c3c03a 100644
--- a/src/map/mapdext.h
+++ b/src/map/mapdext.h
@@ -6,6 +6,7 @@
struct MapdExt
{
+ unsigned int mask;
bool invisible;
};
diff --git a/src/map/script.c b/src/map/script.c
index ca6907c..93ca052 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -20,6 +20,8 @@
#include "map/script.h"
#include "map/clif.h"
#include "map/lang.h"
+#include "map/mapd.h"
+#include "map/mapdext.h"
#include "map/scriptdefines.h"
#include "map/send.h"
#include "map/session.h"
@@ -431,3 +433,66 @@ BUILDIN(miscEffect)
clif->specialeffect(bl, type, AREA);
return true;
}
+
+BUILDIN(setMapMask)
+{
+ const char *const mapName = script_getstr(st, 2);
+ if (!mapName)
+ return true;
+ const int m = map->mapname2mapid(mapName);
+ if (m < 0)
+ return false;
+ getMapData(m);
+
+ const int val = script_getnum(st, 3);
+ mapData->mask = val;
+ return true;
+}
+
+BUILDIN(getMapMask)
+{
+ const char *const mapName = script_getstr(st, 2);
+ if (!mapName)
+ {
+ script_pushint(st, 0);
+ return true;
+ }
+ const int m = map->mapname2mapid(mapName);
+ if (m < 0)
+ {
+ script_pushint(st, 0);
+ return false;
+ }
+ getMapDataReturn(m, 0);
+ script_pushint(st, mapData->mask);
+ return true;
+}
+
+BUILDIN(addMapMask)
+{
+ const char *const mapName = script_getstr(st, 2);
+ if (!mapName)
+ return true;
+ const int m = map->mapname2mapid(mapName);
+ if (m < 0)
+ return false;
+ getMapData(m);
+ const int val = script_getnum(st, 3);
+ mapData->mask |= val;
+ return true;
+}
+
+BUILDIN(removeMapMask)
+{
+ const char *const mapName = script_getstr(st, 2);
+ if (!mapName)
+ return true;
+ const int m = map->mapname2mapid(mapName);
+ if (m < 0)
+ return false;
+ getMapData(m);
+ const int val = script_getnum(st, 3);
+ mapData->mask |= val;
+ mapData->mask ^= val;
+ return true;
+}
diff --git a/src/map/script.h b/src/map/script.h
index 15efc00..3210cca 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -20,5 +20,9 @@ BUILDIN(setNpcDir);
BUILDIN(rif);
BUILDIN(countItemColor);
BUILDIN(miscEffect);
+BUILDIN(setMapMask);
+BUILDIN(getMapMask);
+BUILDIN(addMapMask);
+BUILDIN(removeMapMask);
#endif // EVOL_MAP_SCRIPT
diff --git a/src/map/scriptdefines.h b/src/map/scriptdefines.h
index 7d2b115..1a6cf14 100644
--- a/src/map/scriptdefines.h
+++ b/src/map/scriptdefines.h
@@ -4,7 +4,7 @@
#ifndef EVOL_MAP_SCRIPTDEFINES
#define EVOL_MAP_SCRIPTDEFINES
-#define getDataReturn(def) \
+#define getSessionDataReturn(def) \
if (!st->rid) \
{ \
script_pushint(st, def); \
@@ -18,7 +18,7 @@
} \
struct SessionExt *data = session_get(sd->fd)
-#define getData() \
+#define getSessionData() \
if (!st->rid) \
return true; \
TBL_PC *sd = script->rid2sd(st); \
@@ -26,6 +26,19 @@
return true; \
struct SessionExt *data = session_get(sd->fd)
+#define getMapData(m) \
+ struct MapdExt *mapData = mapd_get(m); \
+ if (!mapData) \
+ return true;
+
+#define getMapDataReturn(m, def) \
+ struct MapdExt *mapData = mapd_get(m); \
+ if (!mapData) \
+ { \
+ script_pushint(st, def); \
+ return true; \
+ }
+
#define getSD() \
TBL_PC *sd = script->rid2sd(st); \
if (!sd) \