diff options
Diffstat (limited to 'npc/functions/vault.txt')
-rw-r--r-- | npc/functions/vault.txt | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/npc/functions/vault.txt b/npc/functions/vault.txt new file mode 100644 index 00000000..4ef97470 --- /dev/null +++ b/npc/functions/vault.txt @@ -0,0 +1,97 @@ +// TMW-2 Script +// Author: +// Jesusalva +// Description: +// Vault Utilities + +function script getvaultid { + // FIXME: Make this False + if (debug || !debug) + return ##VAULT; + else + return 0; +} + +function script getvaultexp { + .@exp=getarg(0); + if (.@exp > 100) + Exception("ILLEGAL VAULT EXPERIENCE, FIXME URGENTLY. STOPPING SCRIPT BY FORCE WHILE DOING NOTHING.", + RB_DEBUGMES | RB_IRCBROADCAST | RB_GLOBALANNOUNCE | RB_ISFATAL); + if (getvaultid()) { + ##VAULT_EXP+=.@exp; + debugmes("Granting %d Soul Exp to %d under Jande's authority.", + .@exp, ##VAULT); + } + return; +} + +function script vaultOnLogin { + // Mirror Lake functionality + if (getvaultid() && !getstatus(SC_JAILED)) { + .@gto=get_byte(##00_INFO, 3); + .@mlp=get_nibble(##00_INFO, 5); + // Work only on new chars, or chars which cleared Tulimshar. + if (.@gto == WORLD_ID) { + // Warp to the proper Mirror Lake + switch (.@mlp) { + //case 1: somewhere + default: warp "013-2", 37, 23; LOCATION$ = "Hurns"; break; + } + + // Send debug information + debugmes("Vault User %d moved to lake %d.", getvaultid(), .@mlp); + + // Handle new user (non-native) accounts - automatic tutorial skip + if (QL_BEGIN < 8) { + if (!TUT_var) { + callfunc "GameRules"; + next; + closeclientdialog; + adddefaultskills(); + getitem Knife, 1; + getitem SlingShot, 1; + getitem SlingBullet, 500; + getitem HitchhikersTowel, 1; + getitem CottonShirt, 1; + getitem RaggedShorts, 1; + set Zeny, Zeny + 35; // tanisha gives 5 Zeny + equip(CottonShirt); + equip(RaggedShorts); + equip(Knife); + } + QL_BEGIN = 8; + dispbottom l("Mirror Lake : Obtain help with Sorfina in Candor."); + } + + // Unset the target lake/world + set_byte(##00_INFO, 0, 3); + set_nibble(##00_INFO, 0, 5); + } else if (.@gto) { + // Heading somewhere which is not here! + mesc l("WARNING: If you use any Mirror Lake feature on this world, the current Mirror Lake Quest will be marked as \"Failed\"."), 1; + mesc l("If this is undesired, select the correct world, and if needed create a new char on it."), 1; + next; + closeclientdialog; + } + } + return; +} + +function script vaultOnLogout { + // Send updates to Vault API + if (getvaultid()) { + .@api$=json_encode("UID", ##VAULT, + "GID", getcharid(3), + "VAR1N", "TMWQUEST", + "VAR1V", ##02_TMWQUEST, + "VEXP", ##VAULT_EXP, + "GOTO", ##VAULT_GOTO, + "MLTO", ##VAULT_MLTO); + ##VAULT_EXP=0; + ##VAULT_GOTO=0; + ##VAULT_MLTO=0; + api_send(API_FLUSHVAULT, .@api$); + } + return; +} + |