summaryrefslogtreecommitdiff
path: root/src/map/script.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/script.c')
-rw-r--r--src/map/script.c120
1 files changed, 112 insertions, 8 deletions
diff --git a/src/map/script.c b/src/map/script.c
index 9788edf3b..c218e98a6 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -12779,6 +12779,76 @@ BUILDIN(setmapflagnosave) {
return true;
}
+enum mapinfo_info {
+ MAPINFO_NAME,
+ MAPINFO_ID,
+ MAPINFO_SIZE_X,
+ MAPINFO_SIZE_Y,
+ MAPINFO_ZONE
+};
+
+BUILDIN(getmapinfo)
+{
+ enum mapinfo_info mode = script_getnum(st, 2);
+ int16 m;
+
+ if (script_hasdata(st, 3)) {
+ if (script_isstringtype(st, 3)) {
+ const char *str = script_getstr(st, 3);
+ m = map->mapname2mapid(str);
+ } else {
+ m = script_getnum(st, 3);
+ }
+ } else {
+ struct block_list *bl = NULL;
+
+ if (st->oid) {
+ bl = map->id2bl(st->oid);
+ } else if (st->rid) {
+ bl = map->id2bl(st->rid);
+ }
+
+ if (bl == NULL) {
+ ShowError("script:getmapinfo: map not supplied and NPC/PC not attached!\n");
+ script_pushint(st, -3);
+ return false;
+ }
+
+ m = bl->m;
+ }
+
+ if (m < 0) {
+ // here we don't throw an error, so the command can be used
+ // to detect whether or not a map exists
+ script_pushint(st, -1);
+ return true;
+ }
+
+ switch (mode) {
+ case MAPINFO_NAME:
+ script_pushconststr(st, map->list[m].name);
+ break;
+ case MAPINFO_ID:
+ script_pushint(st, m);
+ break;
+ case MAPINFO_SIZE_X:
+ script_pushint(st, map->list[m].xs);
+ break;
+ case MAPINFO_SIZE_Y:
+ script_pushint(st, map->list[m].ys);
+ break;
+ case MAPINFO_ZONE:
+ script_pushstrcopy(st, map->list[m].zone->name);
+ break;
+ default:
+ ShowError("script:getmapinfo: unknown option in second argument (%u).\n", mode);
+ script_pushint(st, -2);
+ return false;
+ }
+
+ return true;
+}
+
BUILDIN(getmapflag)
{
int16 m,i;
@@ -12841,6 +12911,7 @@ BUILDIN(getmapflag)
case MF_RESET: script_pushint(st,map->list[m].flag.reset); break;
case MF_NOTOMB: script_pushint(st,map->list[m].flag.notomb); break;
case MF_NOCASHSHOP: script_pushint(st,map->list[m].flag.nocashshop); break;
+ case MF_NOAUTOLOOT: script_pushint(st, map->list[m].flag.noautoloot); break;
case MF_NOVIEWID: script_pushint(st,map->list[m].flag.noviewid); break;
}
}
@@ -12965,6 +13036,7 @@ BUILDIN(setmapflag) {
case MF_RESET: map->list[m].flag.reset = 1; break;
case MF_NOTOMB: map->list[m].flag.notomb = 1; break;
case MF_NOCASHSHOP: map->list[m].flag.nocashshop = 1; break;
+ case MF_NOAUTOLOOT: map->list[m].flag.noautoloot = 1; break;
case MF_NOVIEWID: map->list[m].flag.noviewid = (val <= 0) ? EQP_NONE : val; break;
}
}
@@ -13052,6 +13124,7 @@ BUILDIN(removemapflag) {
case MF_RESET: map->list[m].flag.reset = 0; break;
case MF_NOTOMB: map->list[m].flag.notomb = 0; break;
case MF_NOCASHSHOP: map->list[m].flag.nocashshop = 0; break;
+ case MF_NOAUTOLOOT: map->list[m].flag.noautoloot = 0; break;
case MF_NOVIEWID: map->list[m].flag.noviewid = EQP_NONE; break;
}
}
@@ -15790,19 +15863,38 @@ BUILDIN(getmapxy)
return true;
}
+enum logmes_type {
+ LOGMES_NPC,
+ LOGMES_ATCOMMAND
+};
+
/*==========================================
- * Allows player to write NPC logs (i.e. Bank NPC, etc) [Lupus]
+ * Allows player to write logs (i.e. Bank NPC, etc) [Lupus]
*------------------------------------------*/
BUILDIN(logmes)
{
- const char *str;
+ const char *str = script_getstr(st, 2);
struct map_session_data *sd = script->rid2sd(st);
+ enum logmes_type type = LOGMES_NPC;
+ nullpo_retr(false, sd);
- if (sd == NULL)
- return true;
+ if (script_hasdata(st, 3)) {
+ type = script_getnum(st, 3);
+ }
+
+ switch (type) {
+ case LOGMES_ATCOMMAND:
+ logs->atcommand(sd, str);
+ break;
+ case LOGMES_NPC:
+ logs->npc(sd, str);
+ break;
+ default:
+ ShowError("script:logmes: Unknown log type!\n");
+ st->state = END;
+ return false;
+ }
- str = script_getstr(st,2);
- logs->npc(sd,str);
return true;
}
@@ -23419,7 +23511,7 @@ BUILDIN(dressroom)
clif->dressroom_open(sd, 0);
break;
default:
- ShowWarning("script:dressroom: unknown mode (%i).\n", mode);
+ ShowWarning("script:dressroom: unknown mode (%u).\n", mode);
script_pushint(st, 0);
return false;
}
@@ -23999,6 +24091,7 @@ void script_parse_builtin(void) {
BUILDIN_DEF(isloggedin,"i?"),
BUILDIN_DEF(setmapflagnosave,"ssii"),
BUILDIN_DEF(getmapflag,"si"),
+ BUILDIN_DEF(getmapinfo,"i?"),
BUILDIN_DEF(setmapflag,"si?"),
BUILDIN_DEF(removemapflag,"si"),
BUILDIN_DEF(pvpon,"s"),
@@ -24075,7 +24168,7 @@ void script_parse_builtin(void) {
BUILDIN_DEF(checkoption2,"i?"),
BUILDIN_DEF(guildgetexp,"i"),
BUILDIN_DEF(guildchangegm,"is"),
- BUILDIN_DEF(logmes,"s"), //this command actls as MES but rints info into LOG file either SQL/TXT [Lupus]
+ BUILDIN_DEF(logmes,"s?"), //this command actls as MES but rints info into LOG file either SQL/TXT [Lupus]
BUILDIN_DEF(summon,"si??"), // summons a slave monster [Celest]
BUILDIN_DEF(isnight,""), // check whether it is night time [Celest]
BUILDIN_DEF(isequipped,"i*"), // check whether another item/card has been equipped [Celest]
@@ -24602,6 +24695,10 @@ void script_hardcoded_constants(void)
script->set_constant("DATATYPE_VAR", DATATYPE_VAR, false, false);
script->set_constant("DATATYPE_LABEL", DATATYPE_LABEL, false, false);
+ script->constdb_comment("Logmes types");
+ script->set_constant("LOGMES_NPC", LOGMES_NPC, false, false);
+ script->set_constant("LOGMES_ATCOMMAND", LOGMES_ATCOMMAND, false, false);
+
script->constdb_comment("Item Subtypes (Weapon types)");
script->set_constant("W_FIST", W_FIST, false, false);
script->set_constant("W_DAGGER", W_DAGGER, false, false);
@@ -24653,6 +24750,13 @@ void script_hardcoded_constants(void)
script->set_constant("DRESSROOM_OPEN", DRESSROOM_OPEN, false, false);
script->set_constant("DRESSROOM_CLOSE", DRESSROOM_CLOSE, false, false);
+ script->constdb_comment("getmapinfo options");
+ script->set_constant("MAPINFO_NAME", MAPINFO_NAME, false, false);
+ script->set_constant("MAPINFO_ID", MAPINFO_ID, false, false);
+ script->set_constant("MAPINFO_SIZE_X", MAPINFO_SIZE_X, false, false);
+ script->set_constant("MAPINFO_SIZE_Y", MAPINFO_SIZE_Y, false, false);
+ script->set_constant("MAPINFO_ZONE", MAPINFO_ZONE, false, false);
+
script->constdb_comment("Renewal");
#ifdef RENEWAL
script->set_constant("RENEWAL", 1, false, false);