summaryrefslogtreecommitdiff
path: root/world
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2022-10-25 22:21:14 -0300
committerJesusaves <cpntb1@ymail.com>2022-10-25 22:21:14 -0300
commit05e6ffa722923ad7b587273e6326dcd644900915 (patch)
tree2c18ccf1d3c3168c9f97dcf254fa29a506bee28e /world
parent937fe930c2e316a5f7fdc36a92f555ff2343f86b (diff)
downloadserverdata-05e6ffa722923ad7b587273e6326dcd644900915.tar.gz
serverdata-05e6ffa722923ad7b587273e6326dcd644900915.tar.bz2
serverdata-05e6ffa722923ad7b587273e6326dcd644900915.tar.xz
serverdata-05e6ffa722923ad7b587273e6326dcd644900915.zip
Take advantage of a TMWA bug and use it to export data.
This allows TMW Legacy to make near full use of the Mirror Lake Protocol.
Diffstat (limited to 'world')
-rw-r--r--world/map/db/const.txt6
-rw-r--r--world/map/npc/functions/vault.txt61
2 files changed, 67 insertions, 0 deletions
diff --git a/world/map/db/const.txt b/world/map/db/const.txt
index f4625294..54df1324 100644
--- a/world/map/db/const.txt
+++ b/world/map/db/const.txt
@@ -499,3 +499,9 @@ SMSG_LEGAL 6
SMSG_MOTD 7
SMSG_AUTOMATIC 8
SMSG_EVENT 9
+
+// API Export Protocols
+API_VAULT 607
+API_SENDMAIL 501
+//API_DISCORD 301
+//API_PINCODE 302
diff --git a/world/map/npc/functions/vault.txt b/world/map/npc/functions/vault.txt
index 25e6d263..1c08dba1 100644
--- a/world/map/npc/functions/vault.txt
+++ b/world/map/npc/functions/vault.txt
@@ -39,6 +39,8 @@ S_Preset:
set #X21, (#X21 & ~(BYTE_3_MASK)) | (##PRESET << BYTE_3_SHIFT);
// Each preset is 5 levels (Preset 1 = Lv 5, Preset 10 = Lv 50, Max Preset 20 - hard limit is 127)
+ // TODO: Give more ammo, iron powder, sulphur powder, etc. instead of equips
+ // Give also some bug legs and maggot slime if applicable?
/* Handle weapons */
if (##PRESET >= 1 && @last_preset < 1)
getitem "SharpKnife",1;
@@ -109,3 +111,62 @@ S_Preset:
return;
}
+
+// Remember: ##VAULT_EXP, ##VAULT_GOTO, ##VAULT_MLTO for Mirror Lake Protocol
+// However, without kick(7), it is not really worth anything
+// Remember: Quote symbols are illegal, simple or double, except for parameter
+// To reset the database:
+// cleararray $EXPORT_DATA$[0], "", 254;
+// set $EXPORT_MAX_ID, 0;
+
+// Schemas:
+//API_VAULT: "UID", ##VAULT, "GID", getcharid(3)
+//API_SENDMAIL: "UID": ##VAULT, "MSG": "message", "TITLE": "subject line"
+//
+// Using the API_EXPORT hack for TMWA:
+//
+// set $@API_PROTOCOL, API_SENDMAIL;
+// set $@API_DATA$, "'UID': 0, 'TITLE': 'About TMWA', 'MSG': 'I hate it!'";
+// callfunc "FlushAPI";
+//
+// (The curly brace is added to DATA on its own)
+function|script|FlushAPI
+{
+ // Function called improperly
+ // DATA cannot be null or the array order will crash
+ if ($@API_PROTO <= 0) goto L_Dumb;
+ if ($@API_DATA$ == "") goto L_Dumb;
+
+ // Save it to mapreg
+ // The script will strip "##"
+ // and convert the part after to a JSON dict
+ set $EXPORT_DATA$[$EXPORT_MAX_ID], $@API_PROTO + "##" + $@API_DATA$;
+ set $@API_PROTO, "";
+ set $@API_DATA$, "";
+
+ // Update TMWA tracker
+ set $EXPORT_MAX_ID, $EXPORT_MAX_ID + 1;
+
+ // Keep in mind an array can only go up to 255
+ // Trying to go past that, causes a SIGSEGV and map server dies
+ // So we periodically truncate the table when it's full
+ if ($EXPORT_MAX_ID > 240) goto L_Flush;
+ if ($EXPORT_MAX_ID == 120) goto L_Flush2;
+ return;
+
+L_Dumb:
+ debugmes "FlushAPI called without enough arguments";
+ debugmes " - $@API_PROTO, API_* constant";
+ debugmes " - $@API_DATA$, json dict without curly braces";
+ return;
+
+L_Flush:
+ cleararray $EXPORT_DATA$[0], "", 220;
+ set $EXPORT_MAX_ID, 0;
+ return;
+
+L_Flush2:
+ cleararray $EXPORT_DATA$[220], "", 25;
+ return;
+}
+