diff options
author | Jesusaves <cpntb1@ymail.com> | 2021-04-13 18:36:47 -0300 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2021-04-13 18:36:47 -0300 |
commit | 2d3024a574858935aac4c4a4fa078b357498531a (patch) | |
tree | f9cf68862c9f5312896aa5eda171d84588b46ff3 /npc/functions/location.txt | |
parent | f7df9a9a2d612a5fad24f871ba507e47de2c8083 (diff) | |
download | serverdata-2d3024a574858935aac4c4a4fa078b357498531a.tar.gz serverdata-2d3024a574858935aac4c4a4fa078b357498531a.tar.bz2 serverdata-2d3024a574858935aac4c4a4fa078b357498531a.tar.xz serverdata-2d3024a574858935aac4c4a4fa078b357498531a.zip |
Add LOCATION$ support (but it is not being saved yet)
Diffstat (limited to 'npc/functions/location.txt')
-rw-r--r-- | npc/functions/location.txt | 143 |
1 files changed, 143 insertions, 0 deletions
diff --git a/npc/functions/location.txt b/npc/functions/location.txt new file mode 100644 index 00000000..093764af --- /dev/null +++ b/npc/functions/location.txt @@ -0,0 +1,143 @@ +// TMW2 Script +// Author: Jesusalva +// Location Config + +- script loc_config 32767,{ + end; + +OnInit: + // TP_FORT TP_BOSSR + setarray $@LOCMASTER_TP, TP_CANDOR,TP_TULIM,TP_HURNS,TP_NIVAL; + setarray $@LOCMASTER_LOC$, "Candor", "Tulim", "Hurns", "Nival"; + setarray $@LOCMASTER_MAP$, "029-1", "001-1", "009-1", "020-1"; + setarray $@LOCMASTER_X, 46, 51, 52, 75; + setarray $@LOCMASTER_Y, 97, 78, 41, 85; + + //debugmes "Locmaster: Index 0: %s [%s.gat (%d, %d)]", $@LOCMASTER_LOC$[0], $@LOCMASTER_MAP$[0], $@LOCMASTER_X[0], $@LOCMASTER_Y[0]; + //debugmes "Locmaster: Index 2: %s [%s.gat (%d, %d)]", $@LOCMASTER_LOC$[2], $@LOCMASTER_MAP$[2], $@LOCMASTER_X[2], $@LOCMASTER_Y[2]; + //debugmes "Locmaster: Index 5: %s [%s.gat (%d, %d)]", $@LOCMASTER_LOC$[5], $@LOCMASTER_MAP$[5], $@LOCMASTER_X[5], $@LOCMASTER_Y[5]; + end; +} + +// Resaves your respawn point +function script ResaveRespawn { + .@i=array_find($@LOCMASTER_LOC$, LOCATION$); + savepoint $@LOCMASTER_MAP$[.@i], $@LOCMASTER_X[.@i], $@LOCMASTER_Y[.@i]; + return; +} + +// Warps you to last visited town +function script ReturnTown { + .@i=array_find($@LOCMASTER_LOC$, LOCATION$); + warp $@LOCMASTER_MAP$[.@i], $@LOCMASTER_X[.@i], $@LOCMASTER_Y[.@i]; + return; +} + +// Convert map name to location id +// LocToMap( LocName ) +function script LocToMap { + // Fill variable + .@v$=getarg(0); + + // Error code + if (playerattached()) + .@err=RB_DEFAULT; + else + .@err=RB_DEBUGMES; + + // Validade variable, see npc/config/location.txt first + .@lx=array_find($@LOCMASTER_LOC$, .@v$); + if (.@lx < 0) + return Exception("Invalid location passed to LocToMap: "+.@v$, .@err); + + return $@LOCMASTER_MAP$[.@lx]; +} + +// Convert map name to location id +// MapToLoc( MapName ) +function script MapToLoc { + // Fill variable + .@v$=getarg(0); + + // Error code + if (playerattached()) + .@err=RB_DEFAULT; + else + .@err=RB_DEBUGMES; + + // Validade variable, see npc/config/location.txt first + .@lx=array_find($@LOCMASTER_MAP$, .@v$); + if (.@lx < 0) + return Exception("Invalid map passed to MapToLoc: "+.@v$, .@err); + + return $@LOCMASTER_LOC$[.@lx]; +} + +// Gets the location code for TP code +function script TPToLoc { + .@i=array_find($@LOCMASTER_TP, getarg(0)); + return $@LOCMASTER_MAP$[.@i]; + return; +} + +// Convert LOC (uppercase) to a TP variable +// POL_LocToTP( {TOWNCODE} ) +function script POL_LocToTP { + .@tw$=strtoupper(getarg(0, LOCATION$)); + + if (.@tw$ == "TULIM") + return TP_TULIM; + + if (.@tw$ == "HALIN") + return TP_HALIN; + + if (.@tw$ == "HURNS") + return TP_HURNS; + + if (.@tw$ == "LOF") + return TP_LOF; + + if (.@tw$ == "NIVAL") + return TP_NIVAL; + + if (.@tw$ == "ARTIS") + return TP_ARTIS; + + if (.@tw$ == "CANDOR") + return TP_CANDOR; + + if (.@tw$ == "LILIT") + return TP_LILIT; + + // TODO: Change this to use npc/config/location.txt instead + if (.@tw$ == "FROSTIA") + return TP_FROST; + + return Exception("Invalid town requested / POL_LocToTP", RB_DEFAULT|RB_SPEECH, -1); +} + +// Upon entering a town +// EnterTown( LocName ) +function script EnterTown { + // Fill variable + .@v$=getarg(0); + + // Validade variable, see npc/config/location.txt first + if (array_find($@LOCMASTER_LOC$, .@v$) < 0) + return Exception("Invalid location passed to EnterTown: "+.@v$); + + LOCATION$=.@v$; + return; +} + +// Warps home and updates LOCATION$ +function script teleporthome { + warp "Save", 0, 0; + .@i=array_find($@LOCMASTER_MAP$, getmap()); + if (.@i >= 0) + EnterTown($@LOCMASTER_LOC$[.@i]); + else + debugmes("[ERROR] Invalid Town Map for Time Flask: %s", getmap()); + return; +} + |