ulin

Untitled

Oct 13th, 2013
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 51.81 KB | None | 0 0
  1. //-------------------------------------------------------------------------
  2. //Toasty Warper 1.32
  3. // by ToastOfDoom
  4. //-------------------------------------------------------------------------
  5. //Changelog:
  6. //1.32 --------------------------------------------------------------------
  7. //- Changed default 'Upper' value to allow for 3rd class. (Thanks Annie)
  8. //1.31 --------------------------------------------------------------------
  9. //- Reverted BaseJob check back to jobLookup method but uses BaseJob instead
  10. //  of Class. Best of both methods. Saves on post processing calculations
  11. //  but still allows for an elegant way of writing script (don't need a
  12. //  bunch of exceptions)
  13. //1.3 ---------------------------------------------------------------------
  14. //- Changed OnStart labels to OnStartNPC to prevent mystery errors.
  15. //- Removed jobLookup and replaced with BaseJob check with simple
  16. //  adjustment for dancers. (Cheers to AnnieRuru for reminding me)
  17. //- Changed the way Upper status was checked.
  18. //- Changed the way WoE status was checked.
  19. //- Commented out defaultly missing moc_filds.
  20. //- Modified mapserver console output when script loads.
  21. //1.2 ---------------------------------------------------------------------
  22. //- Added a index lookup for maps (.map_<mapname> = index)
  23. //- Implemented user count for nodes (stored in .userCount_#[%])
  24. //- Added settings to turn on/off user count for nodes and maps
  25. //  (in OnInit: .showNodeUserCount, .showMapUserCount)
  26. //- Optimised the overflow test function so it wouldn't sleep so much
  27. //  (ie..no longer takes so much time to execute)
  28. //1.1 ---------------------------------------------------------------------
  29. //- Renamed some NPCs cause 'warper' was too common and was causing problems
  30. //- Chucked out the old cost system and replaced with a new multi-
  31. //  modification structure. Thus old bug with cost not passing on pass 1st
  32. //  sub menu no longer exists.
  33. //- Now can dynamically adjusts available maps/menus according to:
  34. //     - "gm": 0: allows everyone
  35. //             0+: only allows people above or equal to set gmlevel
  36. //             0-: only allows people below or equal to set gmlevel
  37. //     - "woe": 1:active when woe inactive
  38. //              2:active when woe active
  39. //              3:active regardless of woe setting
  40. //     - "job": works exactly the same as the 'job' setting in item_db
  41. //     - "upper": same as 'upper' setting in item_db
  42. //     - "gender": same as 'sex' setting in item_db
  43. //     - "blvl": works the same as 'gm' but with base level instead
  44. //     - "flag": when passed a variable name, it check if variable is
  45. //               empty as the condition to allow access.
  46. //     - "function": like with 'flag' but instead of a variable, it uses a
  47. //                   function name. Will pass the following parameters:
  48. //                      Node: "Node", <nodeID>, <nodeName>  
  49. //                      Map: "Map", <mapID>, <mapTitle>, <mapName>, <mapX>, <mapY>, <mapCost>
  50. //- Other modifiers added: "zeny", "mapUsers"
  51. //- Shortened some of the map names to get them to fit better
  52. //1.0 ---------------------------------------------------------------------
  53. //- Added menu check in OnInit that checks if a menu may exceed maximum
  54. //  menu length. Hardcoded to print a warning at 2000 characters to
  55. //  compensate for changes in length due to number of map users. Client
  56. //  will crash if exceeds 2047.
  57. //0.3 ---------------------------------------------------------------------
  58. //- Fixed npc duplication problem
  59. //- Added last warp functionality (edit .numLastWarps in OnInit to adjust
  60. //  number of listed warps)
  61. //- Colour-coded some things in the menu
  62. //0.2 ---------------------------------------------------------------------
  63. //- Fixed bad lookup names for x/y coords for warp (thanks BrianL)
  64. //- Removed 'Back' option for root node
  65. //- Added ablilty to define basic zeny cost to individual nodes and/or maps
  66. //0.1 ---------------------------------------------------------------------
  67. //- Initial Release
  68. //-------------------------------------------------------------------------
  69. -   script  toastywarperbase    -1,{
  70.  
  71.     function StartNode;
  72.     function EndNode;
  73.     function AddMap;
  74.     function SetArrayValue;
  75.     function GetArrayValue;
  76.     function WipeArray; //can't use cleararray =P
  77.     function ComputeMenu;
  78.     function ShowMenu;
  79.     function SelectMap;
  80.     function AddLastWarpsNode;
  81.     function ConvertStringToChrArray;
  82.     function GenerateMapSaveString;
  83.     function AddMapToList;
  84.     function ListMaps;
  85.     function InitialiseMapData;
  86.     function PrepLastWarpsMenu;
  87.     function TestMenus;
  88.     function CountAllUsers;
  89.    
  90. OnStartNPC:
  91.     set @gotoCount, 0;  //make sure it doesn't overflow and crash later on.
  92.     if(getgmlevel() >= .gmAccessLvl) {
  93.         mes "Would to like to test all the menus for overflow error?";
  94.         next;
  95.         if(prompt("Yes:No") == 1) {
  96.             TestMenus();
  97.         }
  98.     }
  99.  
  100.     mes "Welcome!!";
  101.    
  102.     if(.showNodeUserCount)
  103.         CountAllUsers();
  104.    
  105.     next;
  106.  
  107.     set .@selectedMap, ShowMenu();
  108.     SelectMap(.@selectedMap);
  109.  
  110.     end;
  111.  
  112.     function ShowMenu {
  113.         setarray .@stack$[0], ".menu_0$";   //traversed menu stack
  114.  
  115.         while(1) {
  116.             set .@currentMenu$, .@stack$[getarraysize(.@stack$) - 1];
  117.             set .@menuStr$, ComputeMenu(.@currentMenu$);
  118.  
  119.             if(getstrlen(.@menuStr$) >= 2047) { //graceful close if menu string overflows(2047)
  120.                 debugmes "TOASTYWARPER - ERROR: Menu (" + getd(.@currentMenu$ + "[0]") + ") has overflowed: " + getstrlen(.@menuStr$) + " chars.";
  121.                 mes "An error has occurred. Please notify the GMs";
  122.                 close;
  123.             }
  124.             set .@menu, select(.@menuStr$);
  125.             set .@selectedItem, atoi(getd(.@currentMenu$ + "[" + (.@menu + 1) + "]"));
  126.  
  127.             if(.@selectedItem == 0) {
  128.                 //back
  129.                 if(getarraysize(.@stack$) <= 1) {
  130.                     set .@i, -1;
  131.                     break;
  132.                 }
  133.                 setarray .@stack$[getarraysize(.@stack$) - 1], "";
  134.             } else
  135.                 if(.@selectedItem <= .mapOffset) {
  136.                     setarray .@stack$[getarraysize(.@stack$)], ((.@selectedItem == .mapOffset)?"@menu_lastwarps$":".menu_" + .@selectedItem + "$");
  137.                 } else {
  138.                     //leaf node - map
  139.                     set .@i, .@selectedItem - .mapOffset;
  140.                     break;
  141.                 }
  142.         }
  143.         return .@i;
  144.     }
  145.  
  146.     function CountAllUsers {
  147.         //".userCount_#[%]"
  148.         set .@i, .nodeCount;
  149.  
  150.         while(.@i > 0) {
  151.             set .@nodePtr$, ".menu_" + .@i + "$";
  152.             set .@userCount, 0;
  153.             set .@k, 2;
  154.             while(getd(.@nodePtr$ + "[" + .@k + "]") != "") {
  155.                 set .@selectedItem, atoi(getd(.@nodePtr$ + "[" + .@k + "]"));
  156.                 if(.@selectedItem <= .mapOffset) {
  157.                     //node
  158.                     set .@userCount, .@userCount + ((.@selectedItem != .mapOffset)?
  159.                             (getd(".userCount_" + (.@selectedItem / 128) + "[" + (.@selectedItem % 128))):
  160.                             0); //make sure it's not the lastwarp menu
  161.                 } else {
  162.                     //map
  163.                     set .@selectedItem, .@selectedItem - .mapOffset;
  164.  
  165.                     set .@a$, "_" + (.@selectedItem / 128) + "$[" + (.@selectedItem % 128) + "]";
  166.                     set .@mapMap$, getd(".maps_map" + .@a$);
  167.                     set .@mapUsers$, getd(".maps_mapUsers" + .@a$);
  168.  
  169.                     set .@userCount, .@userCount + getmapusers((.@mapUsers$ == "")?.@mapMap$:.@mapUsers$);
  170.                 }
  171.                 set .@k, .@k + 1;
  172.             }
  173.             setd(".userCount_" + (.@i / 128) + "[" + (.@i % 128) + "]", .@userCount);
  174.             set .@i, .@i - 1;
  175.         }
  176.     }
  177.    
  178.     //Dynamic generation of menus happens in here!!!
  179.     function ComputeMenu { //menu_pointer
  180.         //default precomputed string (here for memory's sake)
  181.         //return getd(getarg(0) + "[1]");
  182.         set .@i, 2;
  183.         set @gotoCount, @gotoCount + 3;
  184.        
  185.         while(getd(getarg(0) + "[" + .@i + "]") != "") {
  186.             set .@selectedItem, atoi(getd(getarg(0) + "[" + .@i + "]"));
  187.  
  188.             set .@player_job, getd(".jobLookUp_" + BaseJob);
  189.            
  190.             set @gotoCount, @gotoCount + 1;
  191.             if(.@selectedItem <= .mapOffset) {
  192.                 //node - category
  193.                 set @gotoCount, @gotoCount + 1;
  194.                 if(.@selectedItem == .mapOffset) {
  195.                     //lastwarp
  196.                     set .@output$, .@output$ + "Last Warp";
  197.                 } else {
  198.                     set .@enable, 1;
  199.                     set .@a$, "_" + (.@selectedItem / 128) + "[" + (.@selectedItem % 128) + "]";
  200.                     set .@b$, "_" + (.@selectedItem / 128) + "$[" + (.@selectedItem % 128) + "]";
  201.  
  202.                     set .@nodeName$, getd(".menu_" + .@selectedItem + "$[0]");
  203.                     set .@gm, getd(".menus_gm" + .@a$);
  204.                     set .@woe, getd(".menus_woe" + .@a$);
  205.                     set .@job, getd(".menus_job" + .@a$);
  206.                     set .@upper, getd(".menus_upper" + .@a$);
  207.                     set .@gender, getd(".menus_gender" + .@a$);
  208.                     set .@blvl, getd(".menus_blvl" + .@a$);
  209.                     set .@flag$, getd(".menus_flag" + .@b$);
  210.                     set .@function$, getd(".menus_function" + .@b$);
  211.  
  212.                     set .@enable, .@enable && ((.@gm >= 0)?(getgmlevel() >= .@gm):((getgmlevel() + .@gm) <= 0));
  213.                     set .@enable, .@enable && (.@woe & ((agitcheck() || agitcheck2()) + 1) > 0);
  214.                     set .@enable, .@enable && ((.@job & (1 << .@player_job)) > 0);
  215.                     set .@enable, .@enable && ((.@upper & pow(2, Upper)) > 0);
  216.                     set .@enable, .@enable && (.@gender == Sex || .@gender == 2);
  217.                     set .@enable, .@enable && ((.@blvl >= 0)?(BaseLevel >= .@blvl):(BaseLevel + .@blvl <= 0));
  218.                     set .@enable, .@enable && ((.@flag$ != "")?getd(.@flag$):1);
  219.                     if(.@function$ != "")   //used if here cause logical operators won't shortcircuit and thus will execute really bad code
  220.                         set .@enable, .@enable && callfunc(.@function$, "Node", .@selectedItem, .@nodeName$);
  221.  
  222.                     set .@userCount, getd(".userCount" + .@a$);
  223.                        
  224.                     set .@output$, .@output$ + ((.@enable)?(.@nodeName$ +
  225.                             ((.showNodeUserCount)?(" [^0000FF" + .@userCount + "^000000]"):"")):"");
  226.                            
  227.                     set @gotoCount, @gotoCount + 2;
  228.                 }
  229.  
  230.                 set .@output$, .@output$ + ":";
  231.             } else {
  232.                 //leaf node - map
  233.                 set .@selectedItem, .@selectedItem - .mapOffset;
  234.  
  235.                 set .@enable, 1;
  236.                 set .@a$, "_" + (.@selectedItem / 128) + "[" + (.@selectedItem % 128) + "]";
  237.                 set .@b$, "_" + (.@selectedItem / 128) + "$[" + (.@selectedItem % 128) + "]";
  238.  
  239.                 set .@mapName$, getd(".maps_name" + .@b$);
  240.                 set .@mapMap$, getd(".maps_map" + .@b$);
  241.  
  242.                 set .@zeny, getd(".maps_zeny" + .@a$);
  243.                 set .@gm, getd(".maps_gm" + .@a$);
  244.                 set .@woe, getd(".maps_woe" + .@a$);
  245.                 set .@job, getd(".maps_job" + .@a$);
  246.                 set .@upper, getd(".maps_upper" + .@a$);
  247.                 set .@gender, getd(".maps_gender" + .@a$);
  248.                 set .@blvl, getd(".maps_blvl" + .@a$);
  249.                 set .@mapUsers$, getd(".maps_mapUsers" + .@b$);
  250.                 set .@flag$, getd(".maps_flag" + .@b$);
  251.                 set .@function$, getd(".maps_function" + .@b$);
  252.                
  253.                 set .@enable, .@enable && ((.@gm >= 0)?(getgmlevel() >= .@gm):((getgmlevel() + .@gm) <= 0));
  254.                 set .@enable, .@enable && (.@woe & ((agitcheck() || agitcheck2()) + 1) > 0);
  255.                 set .@enable, .@enable && ((.@job & (1 << .@player_job)) > 0);
  256.                 set .@enable, .@enable && ((.@upper & pow(2, Upper)) > 0);
  257.                 set .@enable, .@enable && (.@gender == Sex || .@gender == 2);
  258.                 set .@enable, .@enable && ((.@blvl >= 0)?(BaseLevel >= .@blvl):(BaseLevel + .@blvl <= 0));
  259.                 set .@enable, .@enable && ((.@flag$ != "")?getd(.@flag$):1);
  260.                 if(.@function$ != "") { //used if here cause logical operators won't shortcircuit and thus will execute really bad code
  261.                     set .@mapX, getd(".maps_x" + .@a$);
  262.                     set .@mapY, getd(".maps_y" + .@a$);
  263.                     set .@enable, .@enable && callfunc(.@function$, "Map", .@selectedItem, .@mapName$, .@mapMap$, .@mapX, .@mapY, .@zeny);
  264.                 }
  265.                
  266.                 set .@numUsers, getmapusers((.@mapUsers$ == "")?.@mapMap$:.@mapUsers$);            
  267.                
  268.                 set .@output$, .@output$ + ((.@enable)?
  269.                     ("- " + .@mapName$ +
  270.                     ((.showMapUserCount)?(" [^0000FF" + .@numUsers + "^000000]"):"") +
  271.                     ((.@zeny > 0)?(" - " + .@zeny + "z"):"")):"") + ":";
  272.                    
  273.                 set @gotoCount, @gotoCount + 2;
  274.             }
  275.             set .@i, .@i + 1;
  276.             set @gotoCount, @gotoCount + 1;
  277.         }
  278.         return .@output$ + ((getarg(0) != ".menu_0$") ? "Back" : "");
  279.     }
  280.    
  281.     function SelectMap { // <mapID>
  282.         set .@name$, GetArrayValue(".maps_name", getarg(0), 1);
  283.         set .@map$, GetArrayValue(".maps_map", getarg(0), 1);
  284.         set .@x, GetArrayValue(".maps_x", getarg(0));
  285.         set .@y, GetArrayValue(".maps_y", getarg(0));
  286.         set .@users, getmapusers(.@map$);
  287.         set .@cost, GetArrayValue(".maps_zeny", getarg(0));
  288.  
  289.         mes "^0000FF" + .@name$ + "^000000 has ^0000FF" + .@users + "^000000 player" + ((.@users != 1)?"s":"") + " at the moment.";
  290.         if(.@cost > 0) {
  291.             mes "It costs ^0000FF" + .@cost + "z^000000 to warp here.";
  292.             if(Zeny < .@cost) {
  293.                 mes " ";
  294.                 mes "^FF0000You do not have enough zeny to warp here.^000000";
  295.                 mes "Please come back when you do.";
  296.                 close2;
  297.                 return;
  298.             }
  299.         }
  300.  
  301.         mes "Would you like to warp there now?";
  302.  
  303.         set .@menu, select("Yes:No");
  304.         close2;
  305.  
  306.         if(.@menu == 1) {
  307.             AddMapToList(getarg(0) + 1);
  308.             PrepLastWarpsMenu();
  309.  
  310.             set Zeny, Zeny - .@cost;
  311. -           warp .@map$, .@x, .@y;
  312. +           //warp .@map$, .@x, .@y;
  313. +           warpportal 152, 182,.@map$,.@x,.@y;
  314.         }
  315.  
  316.         return;
  317.     }
  318.  
  319.     OnPCLoginEvent:
  320.         set @toasty_stackStart, 0;
  321.         ConvertStringToChrArray(toasty_mapSave$, "@toasty_savedMaps");
  322.         InitialiseMapData();
  323.         end;
  324.  
  325.     OnInit:
  326.         set .gotoLimit, 2000;   //lower this if you get infinite loop errors
  327.         set .numLastWarps, 10;  //max 64
  328.         set .gmAccessLvl, 80;
  329.  
  330.         set .mapOffset, 1000; //increase if total number of nodes exceed
  331.  
  332.         set .showNodeUserCount, 1;  //enables|disables display of number of users on nodes
  333.         set .showMapUserCount, 1;   //enables|disables display of number of users on maps
  334.        
  335.         //used for data compression in last warp storage (DON'T TOUCH)
  336.         setarray .char$[0],
  337.             "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
  338.             "A", "B", "C", "D", "E", "F", "G", "H", "I",
  339.             "J", "K", "L", "M", "N", "O", "P", "Q", "R",
  340.             "S", "T", "U", "V", "W", "X", "Y", "Z",
  341.             "a", "b", "c", "d", "e", "f", "g", "h", "i",
  342.             "j", "k", "l", "m", "n", "o", "p", "q", "r",
  343.             "s", "t", "u", "v", "w", "x", "y", "z",
  344.             "{", "|";
  345.  
  346.         setarray .mapModifiers$[0], "", "zeny", "gm", "woe", "job", "upper", "gender", "blvl", "mapUsers", "flag", "function";
  347.         setarray .tempModPtrs$[0], ".@badData$", ".@node_zeny", ".@node_gm", ".@node_woe", ".@node_job", ".@node_upper", ".@node_gender", ".@node_blvl", ".@node_mapUsers$", ".@node_flag$", ".@node_function$";
  348.  
  349.         //define index lookups for modifiers
  350.         while(.@i < getarraysize(.mapModifiers$)) {
  351.             setd(".modifier_" + .mapModifiers$[.@i], .@i);
  352.             set .@i, .@i + 1;
  353.         }
  354.  
  355.         //define index lookups for jobs
  356.         setarray .@jobLookup_0[0], Job_Novice, Job_SuperNovice;
  357.         setarray .@jobLookup_1[0], Job_Swordman;
  358.         setarray .@jobLookup_2[0], Job_Mage;
  359.         setarray .@jobLookup_3[0], Job_Archer;
  360.         setarray .@jobLookup_4[0], Job_Acolyte;
  361.         setarray .@jobLookup_5[0], Job_Merchant;
  362.         setarray .@jobLookup_6[0], Job_Thief;
  363.         setarray .@jobLookup_7[0], Job_Knight;
  364.         setarray .@jobLookup_8[0], Job_Priest;
  365.         setarray .@jobLookup_9[0], Job_Wizard;
  366.         setarray .@jobLookup_10[0], Job_Blacksmith;
  367.         setarray .@jobLookup_11[0], Job_Hunter;
  368.         setarray .@jobLookup_12[0], Job_Assassin;
  369.         setarray .@jobLookup_14[0], Job_Crusader;
  370.         setarray .@jobLookup_15[0], Job_Monk;
  371.         setarray .@jobLookup_16[0], Job_Sage;
  372.         setarray .@jobLookup_18[0], Job_Alchemist;
  373.         setarray .@jobLookup_19[0], Job_Bard, Job_Dancer;
  374.         setarray .@jobLookup_21[0], Job_Taekwon;
  375.         setarray .@jobLookup_22[0], Job_Star_Gladiator;
  376.         setarray .@jobLookup_23[0], Job_Soul_Linker;
  377.         setarray .@jobLookup_24[0], Job_Gunslinger;
  378.         setarray .@jobLookup_25[0], Job_Ninja;
  379.  
  380.         set .@i, 0;
  381.         while(.@i < 25) {
  382.             set .@jobsPtr$, ".@jobLookup_" + .@i;
  383.             set .@k, getarraysize(getd(.@jobsPtr$));
  384.             while(.@k > 0) {
  385.                 set .@k, .@k - 1;
  386.                 setd(".jobLookUp_" + getd(.@jobsPtr$ + "[" + .@k + "]"), .@i);
  387.             }
  388.             set .@i, .@i + 1;
  389.         }
  390.        
  391.         callsub(LoadData);
  392.     end;
  393.  
  394.     LoadData:
  395.         //reset data;
  396.         set .nodeCount, 0;
  397.         set .mapCount, 1;
  398.         cleararray(.buildStack$[0], "", 128);
  399.         setarray .buildStack$[0], ".menu_0$";
  400.  
  401.         //default mod values
  402.         setarray .stack_zeny[0], 0;
  403.         setarray .stack_gm[0], 0;
  404.         setarray .stack_woe[0], 3;
  405.         setarray .stack_job[0], 0x03FFFFFF;
  406.         setarray .stack_upper[0], 119;
  407.         setarray .stack_gender[0], 2;
  408.         setarray .stack_blvl[0], 0;
  409.         setarray .stack_mapUsers$[0], "";
  410.         setarray .stack_flag$[0], "";
  411.         setarray .stack_function$[0], "";
  412.  
  413.         set .stackLevel, 1;
  414.  
  415.         set .gotoCount, 0;
  416.         sleep(1);
  417.         set .@startLoadTime, gettimetick(0);
  418.  
  419.         AddLastWarpsNode();
  420.         StartNode("Towns");
  421.             AddMap("Alberta", "alberta", 28, 234);
  422.             AddMap("Aldebaran", "aldebaran", 140, 131);
  423.             AddMap("Amatsu", "amatsu", 198, 84);
  424.             AddMap("Ayothaya", "ayothaya", 150, 163);
  425.             AddMap("Comodo", "comodo", 209, 143);
  426.             AddMap("Einbech (Mining Village);", "einbech", 70, 95);
  427.             AddMap("Einbroch", "einbroch", 64, 200);
  428.             AddMap("Geffen", "geffen", 119, 59);
  429.             AddMap("Gonryun", "gonryun", 160, 121);
  430.             AddMap("Hugel", "hugel", 96, 145);
  431.             AddMap("Izlude", "izlude", 128, 114);
  432.             AddMap("Jawaii", "jawaii", 213, 230);
  433.             AddMap("Lighthalzen", "lighthalzen", 158, 92);
  434.             AddMap("Louyang", "louyang", 210, 108);
  435.             AddMap("Lutie", "xmas", 147, 134);
  436.             AddMap("Moscovia", "moscovia", 214, 183);
  437.             AddMap("Morroc", "morocc", 156, 93);
  438.             AddMap("Nameless Island", "nameless_n", 256, 215);
  439.             AddMap("Niflheim", "niflheim", 85, 154);
  440.             AddMap("Payon", "payon", 152, 75);
  441.             AddMap("Prontera", "prontera", 155, 183);
  442.             AddMap("Rachel", "rachel", 130, 137);
  443.             AddMap("Thor Camp", "thor_camp", 254, 90);
  444.             AddMap("Veins", "veins", 216, 123);
  445.             AddMap("Yuno", "yuno", 157, 51);
  446.             AddMap("Umbala", "umbala", 145, 155);
  447.         EndNode();
  448.         StartNode("Fields");
  449.             StartNode("Amatsu Fields");
  450.                 AddMap("Amatsu Field 1", "ama_fild01", 190, 197);
  451.             EndNode();
  452.             StartNode("Ayothaya Fields");
  453.                 AddMap("Ayothaya Field 1", "ayo_fild01", 173, 134);
  454.                 AddMap("Ayothaya Field 2", "ayo_fild02", 212, 150);
  455.             EndNode();
  456.             StartNode("Comodo Fields");
  457.                 AddMap("Comodo Field 1", "cmd_fild01", 180, 178);
  458.                 AddMap("Comodo Field 2", "cmd_fild02", 231, 160);
  459.                 AddMap("Comodo Field 3", "cmd_fild03", 191, 172);
  460.                 AddMap("Comodo Field 4", "cmd_fild04", 228, 194);
  461.                 AddMap("Comodo Field 5", "cmd_fild05", 224, 203);
  462.                 AddMap("Comodo Field 6", "cmd_fild06", 190, 223);
  463.                 AddMap("Comodo Field 7", "cmd_fild07", 234, 177);
  464.                 AddMap("Comodo Field 8", "cmd_fild08", 194, 175);
  465.                 AddMap("Comodo Field 9", "cmd_fild09", 172, 172);
  466.             EndNode();
  467.             StartNode("Einbroch Fields");
  468.                 AddMap("Einbroch Field 1", "ein_fild01", 142, 225);
  469.                 AddMap("Einbroch Field 2", "ein_fild02", 182, 141);
  470.                 AddMap("Einbroch Field 3", "ein_fild03", 187, 228);
  471.                 AddMap("Einbroch Field 4", "ein_fild04", 185, 173);
  472.                 AddMap("Einbroch Field 5", "ein_fild05", 216, 173);
  473.                 AddMap("Einbroch Field 6", "ein_fild06", 195, 148);
  474.                 AddMap("Einbroch Field 7", "ein_fild07", 272, 220);
  475.                 AddMap("Einbroch Field 8", "ein_fild08", 173, 214);
  476.                 AddMap("Einbroch Field 9", "ein_fild09", 207, 174);
  477.                 AddMap("Einbroch Field 10", "ein_fild10", 196, 200);
  478.             EndNode();
  479.             StartNode("Geffen Fields");
  480.                 AddMap("Geffen Field 0", "gef_fild00", 46, 199);
  481.                 AddMap("Geffen Field 1", "gef_fild01", 213, 204);
  482.                 AddMap("Geffen Field 2", "gef_fild02", 195, 212);
  483.                 AddMap("Geffen Field 3", "gef_fild03", 257, 192);
  484.                 AddMap("Geffen Field 4", "gef_fild04", 188, 171);
  485.                 AddMap("Geffen Field 5", "gef_fild05", 166, 263);
  486.                 AddMap("Geffen Field 6", "gef_fild06", 248, 158);
  487.                 AddMap("Geffen Field 7", "gef_fild07", 195, 191);
  488.                 AddMap("Geffen Field 8", "gef_fild08", 186, 183);
  489.                 AddMap("Geffen Field 9", "gef_fild09", 221, 117);
  490.                 AddMap("Geffen Field 10", "gef_fild10", 178, 218);
  491.                 AddMap("Geffen Field 11", "gef_fild11", 136, 328);
  492.                 AddMap("Geffen Field 12", "gef_fild12", 240, 181);
  493.                 AddMap("Geffen Field 13", "gef_fild13", 235, 235);
  494.                 AddMap("Geffen Field 14", "gef_fild14", 211, 185);
  495.             EndNode();
  496.             StartNode("Gonryun Fields");
  497.                 AddMap("Gonryun Field 1", "gon_fild01", 220, 227);
  498.             EndNode();
  499.             StartNode("Hugel Fields");
  500.                 AddMap("Hugel Field 1", "hu_fild01", 268, 101);
  501.                 AddMap("Hugel Field 2", "hu_fild02", 222, 193);
  502.                 AddMap("Hugel Field 3", "hu_fild03", 232, 185);
  503.                 AddMap("Hugel Field 4", "hu_fild04", 252, 189);
  504.                 AddMap("Hugel Field 5", "hu_fild05", 196, 106);
  505.                 AddMap("Hugel Field 6", "hu_fild06", 216, 220);
  506.                 AddMap("Hugel Field 7", "hu_fild07", 227, 197);
  507.             EndNode();
  508.             StartNode("Lighthalzen Fields");
  509.                 AddMap("Lighthalzen Field 1", "lhz_fild01", 240, 179);
  510.                 AddMap("Lighthalzen Field 2", "lhz_fild02", 185, 235);
  511.                 AddMap("Lighthalzen Field 3", "lhz_fild03", 240, 226);
  512.             EndNode();
  513.             StartNode("Louyang Field");
  514.                 AddMap("Louyang Field 1", "lou_fild01", 229, 187);
  515.             EndNode();
  516.             StartNode("Lutie Field");
  517.                 AddMap("Lutie Field 1", "xmas_fild01", 115, 145);
  518.             EndNode();
  519.             StartNode("Manuk Fields");
  520.                 AddMap("Manuk Field 1", "man_fild01", 200, 210);
  521.                 AddMap("Manuk Field 2", "man_fild02", 206, 219);
  522.             EndNode();
  523.             StartNode("Mjolnir Fields");
  524.                 AddMap("Mjolnir Field 1", "mjolnir_01", 204, 120);
  525.                 AddMap("Mjolnir Field 2", "mjolnir_02", 175, 193);
  526.                 AddMap("Mjolnir Field 3", "mjolnir_03", 208, 213);
  527.                 AddMap("Mjolnir Field 4", "mjolnir_04", 179, 180);
  528.                 AddMap("Mjolnir Field 5", "mjolnir_05", 181, 240);
  529.                 AddMap("Mjolnir Field 6", "mjolnir_06", 195, 270);
  530.                 AddMap("Mjolnir Field 7", "mjolnir_07", 235, 202);
  531.                 AddMap("Mjolnir Field 8", "mjolnir_08", 188, 215);
  532.                 AddMap("Mjolnir Field 9", "mjolnir_09", 205, 144);
  533.                 AddMap("Mjolnir Field 10", "mjolnir_10", 245, 223);
  534.                 AddMap("Mjolnir Field 11", "mjolnir_11", 180, 206);
  535.                 AddMap("Mjolnir Field 12", "mjolnir_12", 196, 208);
  536.             EndNode();
  537.             StartNode("Moscovia Fields");
  538.                 AddMap("Okrestnosti of Moscovia Field 1", "mosk_fild01", 82, 104);
  539.                 AddMap("Okrestnosti of Moscovia 2", "mosk_fild02", 131, 147);
  540.             EndNode();
  541.             StartNode("Niflheim Fields");
  542.                 AddMap("Niflheim Field 1", "nif_fild01", 215, 229);
  543.                 AddMap("Niflheim Field 2", "nif_fild02", 167, 234);
  544.             EndNode();
  545.             StartNode("Odin Temple");
  546.                 AddMap("Odin Temple 1", "odin_tem01", 298, 167);
  547.                 AddMap("Odin Temple 2", "odin_tem02", 224, 149);
  548.                 AddMap("Odin Temple 3", "odin_tem03", 266, 280);
  549.             EndNode();
  550.             StartNode("Payon Forests");
  551.                 AddMap("Payon Forest 1", "pay_fild01", 158, 206);
  552.                 AddMap("Payon Forest 2", "pay_fild02", 151, 219);
  553.                 AddMap("Payon Forest 3", "pay_fild03", 205, 148);
  554.                 AddMap("Payon Forest 4", "pay_fild04", 186, 247);
  555.                 AddMap("Payon Forest 5", "pay_fild05", 134, 204);
  556.                 AddMap("Payon Forest 6", "pay_fild06", 193, 235);
  557.                 AddMap("Payon Forest 7", "pay_fild07", 200, 177);
  558.                 AddMap("Payon Forest 8", "pay_fild08", 137, 189);
  559.                 AddMap("Payon Forest 9", "pay_fild09", 201, 224);
  560.                 AddMap("Payon Forest 10", "pay_fild10", 160, 205);
  561.                 AddMap("Payon Forest 11", "pay_fild11", 194, 150);
  562.             EndNode();
  563.             StartNode("Prontera Fields");
  564.                 AddMap("Prontera Field 0", "prt_fild00", 184, 235);
  565.                 AddMap("Prontera Field 1", "prt_fild01", 190, 206);
  566.                 AddMap("Prontera Field 2", "prt_fild02", 240, 206);
  567.                 AddMap("Prontera Field 3", "prt_fild03", 190, 143);
  568.                 AddMap("Prontera Field 4", "prt_fild04", 307, 252);
  569.                 AddMap("Prontera Field 5", "prt_fild05", 239, 213);
  570.                 AddMap("Prontera Field 6", "prt_fild06", 185, 188);
  571.                 AddMap("Prontera Field 7", "prt_fild07", 193, 194);
  572.                 AddMap("Prontera Field 8", "prt_fild08", 187, 218);
  573.                 AddMap("Prontera Field 9", "prt_fild09", 210, 183);
  574.                 AddMap("Prontera Field 10", "prt_fild10", 195, 149);
  575.                 AddMap("Prontera Field 11", "prt_fild11", 198, 164);
  576.             EndNode();
  577.             StartNode("Rachel Fields");
  578.                 AddMap("Rachel Field 1", "ra_fild01", 192, 162);
  579.                 AddMap("Rachel Field 2", "ra_fild02", 235, 166);
  580.                 AddMap("Rachel Field 3", "ra_fild03", 202, 206);
  581.                 AddMap("Rachel Field 4", "ra_fild04", 202, 208);
  582.                 AddMap("Rachel Field 5", "ra_fild05", 225, 202);
  583.                 AddMap("Rachel Field 6", "ra_fild06", 202, 214);
  584.                 AddMap("Rachel Field 7", "ra_fild07", 263, 196);
  585.                 AddMap("Rachel Field 8", "ra_fild08", 217, 201);
  586.                 AddMap("Rachel Field 9", "ra_fild09", 87, 121);
  587.                 AddMap("Rachel Field 10", "ra_fild10", 277, 181);
  588.                 AddMap("Rachel Field 11", "ra_fild11", 221, 185);
  589.                 AddMap("Rachel Field 12", "ra_fild12", 175, 200);
  590.                 AddMap("Rachel Field 13", "ra_fild13", 174, 197);
  591.             EndNode();
  592.             StartNode("Sograt Deserts");
  593.                 AddMap("Sograt Desert 1", "moc_fild01", 219, 205);
  594.                 AddMap("Sograt Desert 2", "moc_fild02", 177, 206);
  595.                 AddMap("Sograt Desert 3", "moc_fild03", 194, 182);
  596.                 //AddMap("Sograt Desert 4", "moc_fild04", 184, 217);
  597.                 //AddMap("Sograt Desert 5", "moc_fild05", 203, 213);
  598.                 //AddMap("Sograt Desert 6", "moc_fild06", 213, 208);
  599.                 AddMap("Sograt Desert 7", "moc_fild07", 224, 170);
  600.                 //AddMap("Sograt Desert 8", "moc_fild08", 229, 177);
  601.                 //AddMap("Sograt Desert 9", "moc_fild09", 195, 198);
  602.                 //AddMap("Sograt Desert 10", "moc_fild10", 209, 168);
  603.                 AddMap("Sograt Desert 11", "moc_fild11", 198, 216);
  604.                 AddMap("Sograt Desert 12", "moc_fild12", 156, 187);
  605.                 AddMap("Sograt Desert 13", "moc_fild13", 185, 263);
  606.                 //AddMap("Sograt Desert 14", "moc_fild14", 209, 219);
  607.                 //AddMap("Sograt Desert 15", "moc_fild15", 223, 188);
  608.                 AddMap("Sograt Desert 16", "moc_fild16", 206, 228);
  609.                 AddMap("Sograt Desert 17", "moc_fild17", 208, 238);
  610.                 AddMap("Sograt Desert 18", "moc_fild18", 209, 223);
  611.                 AddMap("Sograt Desert 19", "moc_fild19", 85, 97);
  612.                 AddMap("Sograt Desert 20", "moc_fild20", 85, 97);
  613.                 AddMap("Sograt Desert 21", "moc_fild21", 85, 97);
  614.                 AddMap("Sograt Desert 22", "moc_fild22", 85, 97);
  615.             EndNode();
  616.             StartNode("Splendide Fields");
  617.                 AddMap("Splendide Field 1", "spl_fild01", 175, 186);
  618.                 AddMap("Splendide Field 2", "spl_fild02", 236, 184);
  619.                 AddMap("Splendide Field 3", "spl_fild03", 188, 204);
  620.             EndNode();
  621.             StartNode("Umbala Fields");
  622.                 AddMap("Umbala Field 1", "um_fild01", 217, 206);
  623.                 AddMap("Umbala Field 2", "um_fild02", 223, 221);
  624.                 AddMap("Umbala Field 3", "um_fild03", 237, 215);
  625.                 AddMap("Umbala Field 4", "um_fild04", 202, 197);
  626.             EndNode();
  627.             StartNode("Veins Fields");
  628.                 AddMap("Veins Field 1", "ve_fild01", 186, 175);
  629.                 AddMap("Veins Field 2", "ve_fild02", 196, 370);
  630.                 AddMap("Veins Field 3", "ve_fild03", 222, 45);
  631.                 AddMap("Veins Field 4", "ve_fild04", 51, 250);
  632.                 AddMap("Veins Field 5", "ve_fild05", 202, 324);
  633.                 AddMap("Veins Field 6", "ve_fild06", 150, 223);
  634.                 AddMap("Veins Field 7", "ve_fild07", 149, 307);
  635.             EndNode();
  636.             StartNode("Yuno Fields");
  637.                 AddMap("Yuno Field 1", "yuno_fild01", 189, 224);
  638.                 AddMap("Yuno Field 2", "yuno_fild02", 192, 207);
  639.                 AddMap("Yuno Field 3", "yuno_fild03", 221, 157);
  640.                 AddMap("Yuno Field 4", "yuno_fild04", 226, 199);
  641.                 AddMap("Yuno Field 5", "yuno_fild05", 223, 177);
  642.                 AddMap("Yuno Field 6", "yuno_fild06", 187, 232);
  643.                 AddMap("Yuno Field 7", "yuno_fild07", 231, 174);
  644.                 AddMap("Yuno Field 8", "yuno_fild08", 196, 203);
  645.                 AddMap("Yuno Field 9", "yuno_fild09", 183, 214);
  646.                 AddMap("Yuno Field 10", "yuno_fild10", 200, 124);
  647.                 AddMap("Yuno Field 11", "yuno_fild11", 195, 226);
  648.                 AddMap("Yuno Field 12", "yuno_fild12", 210, 304);
  649.             EndNode();
  650.         EndNode();
  651.         StartNode("Dungeons");
  652.             StartNode("Abbey, Cursed Monastery");
  653.                 AddMap("Abbey, Cursed Monastery - Lvl 1", "abbey01", 51, 14);
  654.                 AddMap("Abbey, Cursed Monastery - Lvl 2", "abbey02", 150, 11);
  655.                 AddMap("Abbey, Cursed Monastery - Lvl 3", "abbey03", 120, 10);
  656.             EndNode();
  657.             StartNode("Abyss Lakes");
  658.                 AddMap("Abyss Lakes - Lvl 1", "abyss_01", 192, 207);
  659.                 AddMap("Abyss Lakes - Lvl 2", "abyss_02", 275, 270);
  660.                 AddMap("Abyss Lakes - Lvl 3", "abyss_03", 116, 27);
  661.             EndNode();
  662.             StartNode("Amatsu Dungeon");
  663.                 AddMap("Amatsu Dungeon - Lvl 1", "ama_dun01", 228, 11);
  664.                 AddMap("Amatsu Dungeon - Lvl 2", "ama_dun02", 34, 41);
  665.                 AddMap("Amatsu Dungeon - Lvl 3", "ama_dun03", 119, 14);
  666.             EndNode();
  667.             StartNode("Anthell");
  668.                 AddMap("Anthell - Lvl 1", "anthell01", 35, 262);
  669.                 AddMap("Anthell - Lvl 2", "anthell02", 168, 170);
  670.             EndNode();
  671.             StartNode("Beach Dungeon");
  672.                 AddMap("Beach Dungeon - Lvl 1", "beach_dun", 266, 67);
  673.                 AddMap("Beach Dungeon - Lvl 2", "beach_dun2", 255, 244);
  674.                 AddMap("Beach Dungeon - Lvl 3", "beach_dun3", 23, 260);
  675.             EndNode();
  676.             StartNode("Ayothaya Dungeons");
  677.                 AddMap("Ancient Shrine Maze", "ayo_dun01", 275, 19);
  678.                 AddMap("Inside Ancient Shrine", "ayo_dun02", 24, 26);
  679.             EndNode();
  680.             StartNode("Byalan Dungeon");
  681.                 AddMap("Byalan Dungeon - Lvl 1", "iz_dun00", 168, 168);
  682.                 AddMap("Byalan Dungeon - Lvl 2", "iz_dun01", 253, 252);
  683.                 AddMap("Byalan Dungeon - Lvl 3", "iz_dun02", 236, 204);
  684.                 AddMap("Byalan Dungeon - Lvl 4", "iz_dun03", 32, 63);
  685.                 AddMap("Byalan Dungeon - Lvl 5", "iz_dun04", 26, 27);
  686.             EndNode();
  687.             StartNode("Clock Tower");
  688.                 AddMap("Clock Tower - Lvl 1", "c_tower1", 199, 159);
  689.                 AddMap("Clock Tower - Lvl 2", "c_tower2", 148, 283);
  690.                 AddMap("Clock Tower - Lvl 3", "c_tower3", 65, 147);
  691.                 AddMap("Clock Tower - Lvl 4", "c_tower4", 56, 155);
  692.                 AddMap("Clock Tower - Basement 1", "alde_dun01", 297, 25);
  693.                 AddMap("Clock Tower - Basement 2", "alde_dun02", 127, 169);
  694.                 AddMap("Clock Tower - Basement 3", "alde_dun03", 277, 178);
  695.                 AddMap("Clock Tower - Basement 4", "alde_dun04", 268, 74);
  696.             EndNode();
  697.             StartNode("Coal Mines");
  698.                 AddMap("Coal Mines - Lvl 1", "mjo_dun01", 52, 17);
  699.                 AddMap("Coal Mines - Lvl 2", "mjo_dun02", 381, 343);
  700.                 AddMap("Coal Mines - Lvl 3", "mjo_dun03", 302, 262);
  701.             EndNode();
  702.             StartNode("Culverts");
  703.                 AddMap("Culverts - Lvl 1", "prt_sewb1", 131, 247);
  704.                 AddMap("Culverts - Lvl 2", "prt_sewb2", 19, 19);
  705.                 AddMap("Culverts - Lvl 3", "prt_sewb3", 180, 169);
  706.                 AddMap("Culverts - Lvl 4", "prt_sewb4", 100, 92);
  707.             EndNode();
  708.             StartNode("Einbroch Dungeons");
  709.                 AddMap("Einbroch Dungeons - Lvl 1", "ein_dun01", 22, 14);
  710.                 AddMap("Einbroch Dungeons - Lvl 2", "ein_dun02", 292, 290);
  711.             EndNode();
  712.             StartNode("Gefenia");
  713.                 AddMap("Gefenia - Lvl 1", "gefenia01", 40, 103);
  714.                 AddMap("Gefenia - Lvl 2", "gefenia02", 203, 34);
  715.                 AddMap("Gefenia - Lvl 3", "gefenia03", 266, 168);
  716.                 AddMap("Gefenia - Lvl 4", "gefenia04", 130, 272);
  717.             EndNode();
  718.             StartNode("Geffen Dungeon");
  719.                 AddMap("Geffen Dungeon - Lvl 1", "gef_dun00", 104, 99);
  720.                 AddMap("Geffen Dungeon - Lvl 2", "gef_dun01", 115, 236);
  721.                 AddMap("Geffen Dungeon - Lvl 3", "gef_dun02", 106, 132);
  722.                 AddMap("Geffen Dungeon - Lvl 4", "gef_dun03", 203, 200);
  723.             EndNode();
  724.             StartNode("Glast Heim");
  725.                 AddMap("Glast Heim - Entrance", "glast_01", 375, 304);
  726.                 AddMap("Glast Heim - Castle 1", "gl_cas01", 199, 29);
  727.                 AddMap("Glast Heim - Castle 2", "gl_cas02", 104, 25);
  728.                 AddMap("Glast Heim - Chivalry 1", "gl_knt01", 150, 15);
  729.                 AddMap("Glast Heim - Chivalry 2", "gl_knt02", 157, 287);
  730.                 AddMap("Glast Heim - Churchyard", "gl_chyard", 147, 15);
  731.                 AddMap("Glast Heim - Culvert 1", "gl_sew01", 258, 255);
  732.                 AddMap("Glast Heim - Culvert 2", "gl_sew02", 108, 291);
  733.                 AddMap("Glast Heim - Culvert 3", "gl_sew03", 171, 283);
  734.                 AddMap("Glast Heim - Culvert 4", "gl_sew04", 68, 277);
  735.                 AddMap("Glast Heim - St.Abbey", "gl_church", 156, 7);
  736.                 AddMap("Glast Heim - Staircase Dungeon", "gl_step", 12, 7);
  737.                 AddMap("Glast Heim - UG Cave 1", "gl_dun01", 133, 271);
  738.                 AddMap("Glast Heim - UG Cave 2", "gl_dun02", 224, 274);
  739.                 AddMap("Glast Heim - UG Prison 1", "gl_prison", 14, 70);
  740.                 AddMap("Glast Heim - UG Prison 2", "gl_prison1", 150, 14);
  741.             EndNode();
  742.             StartNode("Gonryun Dungeon");
  743.                 AddMap("Gonryun Dungeon - Lvl 1", "gon_dun01", 153, 53);
  744.                 AddMap("Gonryun Dungeon - Lvl 2", "gon_dun02", 28, 113);
  745.                 AddMap("Gonryun Dungeon - Lvl 3", "gon_dun03", 68, 16);
  746.             EndNode();
  747.             StartNode("Hidden Dungeon");
  748.                 AddMap("Hidden Dungeon - Lvl 1", "prt_maze01", 176, 7);
  749.                 AddMap("Hidden Dungeon - Lvl 2", "prt_maze02", 94, 9);
  750.                 AddMap("Hidden Dungeon - Lvl 3", "prt_maze03", 23, 8);
  751.             EndNode();
  752.             StartNode("Ice Dungeon");
  753.                 AddMap("Ice Dungeon - Lvl 1", "ice_dun01", 157, 14);
  754.                 AddMap("Ice Dungeon - Lvl 2", "ice_dun02", 151, 155);
  755.                 AddMap("Ice Dungeon - Lvl 3", "ice_dun03", 149, 22);
  756.                 AddMap("Ice Dungeon - Lvl 4", "ice_dun04", 33, 158);
  757.             EndNode();
  758.             StartNode("Juperos Dungeons");
  759.                 AddMap("Juperos Dungeons - Lvl 1", "juperos_01", 53, 247);
  760.                 AddMap("Juperos Dungeons - Lvl 2", "juperos_02", 37, 63);
  761.                 AddMap("Juperos Dungeons - Core", "jupe_core", 150, 285);
  762.             EndNode();
  763.             StartNode("Kiel Dungeons");
  764.                 AddMap("Kiel Dungeons - Lvl 1", "kh_dun01", 28, 226);
  765.                 AddMap("Kiel Dungeons - Lvl 2", "kh_dun02", 41, 198);
  766.             EndNode();
  767.             StartNode("Lighthalzen Dungeons");
  768.                 AddMap("Lighthalzen Dungeons - Lvl 1", "lhz_dun01", 150, 288);
  769.                 AddMap("Lighthalzen Dungeons - Lvl 2", "lhz_dun02", 150, 18);
  770.                 AddMap("Lighthalzen Dungeons - Lvl 3", "lhz_dun03", 140, 130);
  771.             EndNode();
  772.             StartNode("Louyang Dungeons");
  773.                 AddMap("The Royal Tomb", "lou_dun01", 218, 196);
  774.                 AddMap("Inside the Royal Tomb", "lou_dun02", 282, 20);
  775.                 AddMap("Suei Long Gon", "lou_dun03", 165, 38);
  776.             EndNode();
  777.             StartNode("Magma Dungeon");
  778.                 AddMap("Magma Dungeon - Lvl 1", "mag_dun01", 126, 68);
  779.                 AddMap("Magma Dungeon - Lvl 2", "mag_dun02", 47, 30);
  780.             EndNode();
  781.             StartNode("Moscovia Dungeons");
  782.                 AddMap("Les Forest", "mosk_dun01", 132, 124);
  783.                 AddMap("Temny Forest", "mosk_dun02", 155, 123);
  784.                 AddMap("Dremuci Forest", "mosk_dun03", 122, 130);
  785.             EndNode();
  786.             StartNode("Orc Dungeon");
  787.                 AddMap("Orc Dungeon - Lvl 1", "orcsdun01", 32, 170);
  788.                 AddMap("Orc Dungeon - Lvl 2", "orcsdun02", 21, 185);
  789.             EndNode();
  790.             StartNode("Payon Dungeon");
  791.                 AddMap("Payon Dungeon - Lvl 1", "pay_dun00", 21, 183);
  792.                 AddMap("Payon Dungeon - Lvl 2", "pay_dun01", 19, 33);
  793.                 AddMap("Payon Dungeon - Lvl 3", "pay_dun02", 19, 63);
  794.                 AddMap("Payon Dungeon - Lvl 4", "pay_dun03", 155, 159);
  795.                 AddMap("Payon Dungeon - Lvl 5", "pay_dun04", 201, 204);
  796.             EndNode();
  797.             StartNode("Pyramids");
  798.                 AddMap("Pyramids - Lvl 1", "moc_pryd01", 192, 9);
  799.                 AddMap("Pyramids - Lvl 2", "moc_pryd02", 10, 192);
  800.                 AddMap("Pyramids - Lvl 3", "moc_pryd03", 100, 92);
  801.                 AddMap("Pyramids - Lvl 4", "moc_pryd04", 181, 11);
  802.                 AddMap("Pyramids - Basement 1", "moc_pryd05", 94, 96);
  803.                 AddMap("Pyramids - Basement 2", "moc_pryd06", 192, 8);
  804.             EndNode();
  805.             StartNode("Rachel Sanctuary");
  806.                 AddMap("Rachel Sanctuary - Lvl 1", "ra_san01", 140, 11);
  807.                 AddMap("Rachel Sanctuary - Lvl 2", "ra_san02", 32, 21);
  808.                 AddMap("Rachel Sanctuary - Lvl 3", "ra_san03", 4, 149);
  809.                 AddMap("Rachel Sanctuary - Lvl 4", "ra_san04", 204, 218);
  810.                 AddMap("Rachel Sanctuary - Lvl 5", "ra_san05", 150, 9);
  811.             EndNode();
  812.             StartNode("Sphinx");
  813.                 AddMap("Sphinx - Lvl 1", "in_sphinx1", 288, 9);
  814.                 AddMap("Sphinx - Lvl 2", "in_sphinx2", 149, 81);
  815.                 AddMap("Sphinx - Lvl 3", "in_sphinx3", 210, 54);
  816.                 AddMap("Sphinx - Lvl 4", "in_sphinx4", 10, 222);
  817.                 AddMap("Sphinx - Lvl 5", "in_sphinx5", 100, 99);
  818.             EndNode();
  819.             StartNode("Sunken Ship");
  820.                 AddMap("Sunken Ship - Lvl 1", "treasure01", 69, 24);
  821.                 AddMap("Sunken Ship - Lvl 2", "treasure02", 102, 27);
  822.             EndNode();
  823.             StartNode("Thanatos Tower");
  824.                 AddMap("Thanatos Tower - Lvl 1", "tha_t01", 150, 39);
  825.                 AddMap("Thanatos Tower - Lvl 2", "tha_t02", 150, 136);
  826.                 AddMap("Thanatos Tower - Lvl 3", "tha_t03", 220, 158);
  827.                 AddMap("Thanatos Tower - Lvl 4", "tha_t04", 59, 143);
  828.                 AddMap("Thanatos Tower - Lvl 5", "tha_t05", 62, 11);
  829.                 AddMap("Thanatos Tower - Lvl 6", "tha_t06", 89, 221);
  830.                 AddMap("Thanatos Tower - Lvl 7", "tha_t07", 35, 166);
  831.                 AddMap("Thanatos Tower - Lvl 8", "tha_t08", 93, 148);
  832.                 AddMap("Thanatos Tower - Lvl 9", "tha_t09", 29, 107);
  833.                 AddMap("Thanatos Tower - Lvl 10", "tha_t10", 159, 138);
  834.                 AddMap("Thanatos Tower - Lvl 11", "tha_t11", 19, 20);
  835.                 AddMap("Thanatos Tower - Lvl 12", "tha_t12", 130, 52);
  836.             EndNode();
  837.             StartNode("Thor Volcano");
  838.                 AddMap("Thor Volcano - Lvl 1", "thor_v01", 21, 228);
  839.                 AddMap("Thor Volcano - Lvl 2", "thor_v02", 75, 205);
  840.                 AddMap("Thor Volcano - Lvl 3", "thor_v03", 34, 272);
  841.             EndNode();
  842.             StartNode("Toy Factory");
  843.                 AddMap("Toy Factory - Lvl 1", "xmas_dun01", 205, 15);
  844.                 AddMap("Toy Factory - Lvl 2", "xmas_dun02", 129, 133);
  845.             EndNode();
  846.             StartNode("Turtle Dungeon");
  847.                 AddMap("Turtle Dungeon - Entrance", "tur_dun01", 154, 49);
  848.                 AddMap("Turtle Dungeon - Lvl 1", "tur_dun02", 148, 261);
  849.                 AddMap("Turtle Dungeon - Lvl 2", "tur_dun03", 132, 189);
  850.                 AddMap("Turtle Dungeon - Lvl 3", "tur_dun04", 100, 192);
  851.             EndNode();
  852.             StartNode("Umbala Dungeons");
  853.                 AddMap("Carpenter's Shop in the Tree", "um_dun01", 42, 31);
  854.                 AddMap("Passage to a Foreign World", "um_dun01", 48, 30);
  855.                 AddMap("Hvergermil's Fountain", "yggdrasil01", 204, 78);
  856.             EndNode();
  857.         EndNode();
  858.         StartNode("Guild Dungeons");
  859.             AddMap("Baldur Guild Dungeon", "gld_dun01", 119, 93);
  860.             AddMap("Luina Guild Dungeon", "gld_dun02", 39, 161);
  861.             AddMap("Valkyrie Guild Dungeon", "gld_dun03", 50, 44);
  862.             AddMap("Britoniah Guild Dungeon", "gld_dun04", 116, 45);
  863.         EndNode();
  864.         StartNode("Castles");
  865.             StartNode("Aldebaran Castles");
  866.                 AddMap("Neuschwanstein(Aldebaran)", "alde_gld", 48, 83, "mapUsers", "aldeg_cas01");
  867.                 AddMap("Hohenschwangau(Aldebaran)", "alde_gld", 95, 249, "mapUsers", "aldeg_cas02");
  868.                 AddMap("Nuenberg(Aldebaran)", "alde_gld", 142, 85, "mapUsers", "aldeg_cas03");
  869.                 AddMap("Wuerzburg(Aldebaran)", "alde_gld", 239, 242, "mapUsers", "aldeg_cas04");
  870.                 AddMap("Rothenburg(Aldebaran)", "alde_gld", 264, 90, "mapUsers", "aldeg_cas05");
  871.             EndNode();
  872.             StartNode("Geffen Castles");
  873.                 AddMap("Repherion(Geffen)", "gef_fild13", 214, 75, "mapUsers", "gefg_cas01");
  874.                 AddMap("Eeyolbriggar(Geffen)", "gef_fild13", 308, 240, "mapUsers", "gefg_cas02");
  875.                 AddMap("Yesnelph(Geffen)", "gef_fild13", 143, 240, "mapUsers", "gefg_cas03");
  876.                 AddMap("Bergel(Geffen)", "gef_fild13", 193, 278, "mapUsers", "gefg_cas04");
  877.                 AddMap("Mersetzdeitz(Geffen)", "gef_fild13", 305, 87, "mapUsers", "gefg_cas05");
  878.             EndNode();
  879.             StartNode("Payon Castles");
  880.                 AddMap("Bright Arbor(Payon)", "pay_gld", 121, 233, "mapUsers", "payg_cas01");
  881.                 AddMap("Scarlet Palace(Payon)", "pay_gld", 295, 116, "mapUsers", "payg_cas02");
  882.                 AddMap("Holy Shadow(Payon)", "pay_gld", 317, 293, "mapUsers", "payg_cas03");
  883.                 AddMap("Sacred Altar(Payon)", "pay_gld", 140, 160, "mapUsers", "payg_cas04");
  884.                 AddMap("Bamboo Grove Hill(Payon)", "pay_gld", 204, 266, "mapUsers", "payg_cas05");
  885.             EndNode();
  886.             StartNode("Prontera Castles");
  887.                 AddMap("Kriemhild(Prontera)", "prt_gld", 134, 65, "mapUsers", "prtg_cas01");
  888.                 AddMap("Swanhild(Prontera)", "prt_gld", 240, 128, "mapUsers", "prtg_cas02");
  889.                 AddMap("Fadhgridh(Prontera)", "prt_gld", 153, 137, "mapUsers", "prtg_cas03");
  890.                 AddMap("Skoegul(Prontera)", "prt_gld", 111, 240, "mapUsers", "prtg_cas04");
  891.                 AddMap("Gondul(Prontera)", "prt_gld", 208, 240, "mapUsers", "prtg_cas05");
  892.             EndNode();
  893.             StartNode("Schwaltzvalt Castles");
  894.                 AddMap("Himinn(Schwaltzvalt)", "sch_gld", 293, 100, "mapUsers", "schg_cas01");
  895.                 AddMap("Andlangr(Schwaltzvalt)", "sch_gld", 288, 252, "mapUsers", "schg_cas02");
  896.                 AddMap("Viblainn(Schwaltzvalt)", "sch_gld", 97, 196, "mapUsers", "schg_cas03");
  897.                 AddMap("Hljod(Schwaltzvalt)", "sch_gld", 137, 90, "mapUsers", "schg_cas04");
  898.                 AddMap("Skidbladnir(Schwaltzvalt)", "sch_gld", 71, 315, "mapUsers", "schg_cas05");
  899.             EndNode();
  900.             StartNode("Arunafeltz Castles");
  901.                 AddMap("Mardol(Arunafeltz)", "aru_gld", 158, 272, "mapUsers", "arug_cas01");
  902.                 AddMap("Cyr(Arunafeltz)", "aru_gld", 83, 47, "mapUsers", "arug_cas02");
  903.                 AddMap("Horn(Arunafeltz)", "aru_gld", 68, 155, "mapUsers", "arug_cas03");
  904.                 AddMap("Gefn(Arunafeltz)", "aru_gld", 299, 345, "mapUsers", "arug_cas04");
  905.                 AddMap("Bandis(Arunafeltz)", "aru_gld", 292, 107, "mapUsers", "arug_cas05");
  906.             EndNode();
  907.         StartNode("Other");
  908.             AddMap("Casino", "cmd_in02", 179, 129);
  909.         EndNode();
  910.  
  911.         debugmes "TOASTYWARPER - Map Data Loaded: " + .mapCount + " maps, " + (gettimetick(0) - .@startLoadTime) + "ms";
  912.         cleararray(.buildStack$[0], "", 128);
  913.         //debugmes "gotos: " + .gotoCount;
  914.         sleep(1);
  915.     end;
  916.  
  917.     //-----------------------------------------------------------
  918.     //TEST FUNCTIONS
  919.     //-----------------------------------------------------------
  920.     function TestMenus {
  921.         sleep2(1);
  922.         set @gotoCount, 1;
  923.         while(.@i < .nodeCount) {
  924.            
  925.             set .@nodePtr$, ".menu_" + .@i + "$";
  926.             set .@menu$, ComputeMenu(.@nodePtr$);
  927.             if(getstrlen(.@menu$) >= 2000) {
  928.                 set .@check, 1;
  929.                 mes "Menu (" + getd(.@nodePtr$ + "[0]") + ") may overflow (" + getstrlen(.@menu$) + " chars)";
  930.             }
  931.             set .@i, .@i + 1;
  932.  
  933.             set @gotoCount, @gotoCount + 2;
  934.             sleep2(@gotoCount >= .gotoLimit);
  935.             set @gotoCount, @gotoCount * (@gotoCount < .gotoLimit);
  936.         }
  937.         if(.@check == 0)
  938.             mes "No overflows detected";
  939.  
  940.         next;
  941.     }
  942.  
  943.     //-----------------------------------------------------------
  944.     //TREE MAPPING FUNCTIONS
  945.     //-----------------------------------------------------------
  946.  
  947.     function AddLastWarpsNode {
  948.         set .@parentNodePtr$, .buildStack$[.stackLevel - 1];
  949.        
  950.         //add to parent node
  951.         setd(.@parentNodePtr$ + "[1]", getd(.@parentNodePtr$ + "[1]") + "Last Warp" + ":");
  952.         setd(.@parentNodePtr$ + "[" + getarraysize(getd(.@parentNodePtr$)) + "]", .mapOffset);
  953.  
  954.         //infinte loop check
  955.         set .gotoCount, .gotoCount + 3;
  956.         sleep(.gotoCount >= .gotoLimit);
  957.         set .gotoCount, .gotoCount * (.gotoCount < .gotoLimit);
  958.     }
  959.  
  960.     function StartNode {
  961.         set .@header$, getarg(0, "");
  962.  
  963.         set .nodeCount, .nodeCount + 1;
  964.         set .@nodePtr$, ".menu_" + .nodeCount + "$";
  965.  
  966.         set .@parentNodePtr$, .buildStack$[.stackLevel - 1];
  967.  
  968.         //clear the node just in case there was something in it
  969.         cleararray(getd(.@nodePtr$), "", 128);
  970.  
  971.         //add to parent node
  972.         setd(.@parentNodePtr$ + "[1]", getd(.@parentNodePtr$ + "[1]") + .@header$ + ":");
  973.         setd(.@parentNodePtr$ + "[" + getarraysize(getd(.@parentNodePtr$)) + "]", .nodeCount);
  974.         setd(.@nodePtr$ + "[0]", .@header$);
  975.  
  976.         //carry down node data
  977.         set .@node_zeny, .stack_zeny[.stackLevel - 1];
  978.         set .@node_gm, .stack_gm[.stackLevel - 1];
  979.         set .@node_woe, .stack_woe[.stackLevel - 1];
  980.         set .@node_job, .stack_job[.stackLevel - 1];
  981.         set .@node_upper, .stack_upper[.stackLevel - 1];
  982.         set .@node_gender, .stack_gender[.stackLevel - 1];
  983.         set .@node_blvl, .stack_blvl[.stackLevel - 1];
  984.         set .@node_mapUsers$, .stack_mapUsers$[.stackLevel - 1];
  985.         set .@node_flag$, .stack_flag$[.stackLevel - 1];
  986.         set .@node_function$, .stack_function$[.stackLevel - 1];
  987.  
  988.         //check for modifiers
  989.         set .@i, 1;
  990.         while((getarg(.@i, "") + "") != "" && (getarg(.@i + 1, "") + "") != "") {
  991.             set .@modIndex, getd(".modifier_" + getarg(.@i));
  992.             setd(.tempModPtrs$[.@modIndex], getarg(.@i + 1));
  993.            
  994.             set .@i, .@i + 2;
  995.             set .gotoCount, .gotoCount + 1;
  996.         }
  997.         set .gotoCount, .gotoCount + 1;
  998.        
  999.         setarray .buildStack$[.stackLevel], .@nodePtr$; //add to stack
  1000.  
  1001.         //push data to stack
  1002.         setarray .stack_zeny[.stackLevel], .@node_zeny;
  1003.         setarray .stack_gm[.stackLevel], .@node_gm;
  1004.         setarray .stack_woe[.stackLevel], .@node_woe;
  1005.         setarray .stack_job[.stackLevel], .@node_job;
  1006.         setarray .stack_upper[.stackLevel], .@node_upper;
  1007.         setarray .stack_gender[.stackLevel], .@node_gender;
  1008.         setarray .stack_blvl[.stackLevel], .@node_blvl;
  1009.         setarray .stack_mapUsers$[.stackLevel], .@node_mapUsers$;
  1010.         setarray .stack_flag$[.stackLevel], .@node_flag$;
  1011.         setarray .stack_function$[.stackLevel], .@node_function$;
  1012.  
  1013.         //store node applicable mods
  1014.         set .@a$, "_" + (.nodeCount / 128) + "[" + (.nodeCount % 128) + "]";
  1015.         set .@b$, "_" + (.nodeCount / 128) + "$[" + (.nodeCount % 128) + "]";
  1016.         setd(".menus_gm" + .@a$, .@node_gm);
  1017.         setd(".menus_woe" + .@a$, .@node_woe);
  1018.         setd(".menus_job" + .@a$, .@node_job);
  1019.         setd(".menus_upper" + .@a$, .@node_upper);
  1020.         setd(".menus_gender" + .@a$, .@node_gender);
  1021.         setd(".menus_blvl" + .@a$, .@node_blvl);
  1022.         setd(".menus_flag" + .@b$, .@node_flag$);
  1023.         setd(".menus_function" + .@b$, .@node_function$);
  1024.  
  1025.         set .stackLevel, .stackLevel + 1;
  1026.  
  1027.         //infinte loop check
  1028.         set .gotoCount, .gotoCount + 3;
  1029.         sleep(.gotoCount >= .gotoLimit);
  1030.         set .gotoCount, .gotoCount * (.gotoCount < .gotoLimit);
  1031.     }
  1032.  
  1033.     function EndNode {
  1034.         set .stackLevel, .stackLevel - 1;
  1035.         set .@nodePtr$, .buildStack$[.stackLevel];
  1036.         setd(.@nodePtr$ + "[1]", getd(.@nodePtr$ + "[1]") + "Back");    //add back option to menu
  1037.  
  1038.         setarray .buildStack$[.stackLevel], ""; //remove from stack
  1039.  
  1040.         //pop the stack
  1041.         setarray .stack_zeny[.stackLevel], .@node_zeny;
  1042.         setarray .stack_gm[.stackLevel], 0;
  1043.         setarray .stack_woe[.stackLevel], 0;
  1044.         setarray .stack_job[.stackLevel], 0x0FFFFFFF;
  1045.         setarray .stack_upper[.stackLevel], 8;
  1046.         setarray .stack_gender[.stackLevel], 2;
  1047.         setarray .stack_blvl[.stackLevel], 0;
  1048.         setarray .stack_mapUsers$[.stackLevel], "";
  1049.         setarray .stack_flag$[.stackLevel], "";
  1050.         setarray .stack_function$[.stackLevel], "";
  1051.  
  1052.         //infinte loop check
  1053.         set .gotoCount, .gotoCount + 2;
  1054.         sleep(.gotoCount >= .gotoLimit);
  1055.         set .gotoCount, .gotoCount * (.gotoCount < .gotoLimit);
  1056.     }
  1057.  
  1058.     function AddMap {
  1059.         set .@nodePtr$, .buildStack$[.stackLevel - 1];
  1060.  
  1061.         if(getmapusers(getarg(1)) >= 0) { //makes sure it's a real map
  1062.             //add to map arrays (basically 4x SetArrayValue calls..but put inline to prevent infinite loop error)
  1063.             set .@a$, "_" + (.mapCount / 128) + "[" + (.mapCount % 128) + "]";
  1064.             set .@b$, "_" + (.mapCount / 128) + "$[" + (.mapCount % 128) + "]";
  1065.  
  1066.             setd ".maps_name" + .@b$, getarg(0);
  1067.             setd ".maps_map" + .@b$, getarg(1);
  1068.             setd ".maps_x" + .@a$, getarg(2);
  1069.             setd ".maps_y" + .@a$, getarg(3);
  1070.  
  1071.             //carry down node data
  1072.             set .@node_zeny, .stack_zeny[.stackLevel - 1];
  1073.             set .@node_gm, .stack_gm[.stackLevel - 1];
  1074.             set .@node_woe, .stack_woe[.stackLevel - 1];
  1075.             set .@node_job, .stack_job[.stackLevel - 1];
  1076.             set .@node_upper, .stack_upper[.stackLevel - 1];
  1077.             set .@node_gender, .stack_gender[.stackLevel - 1];
  1078.             set .@node_blvl, .stack_blvl[.stackLevel - 1];
  1079.             set .@node_mapUsers$, .stack_mapUsers$[.stackLevel - 1];
  1080.             set .@node_flag$, .stack_flag$[.stackLevel - 1];
  1081.             set .@node_function$, .stack_function$[.stackLevel - 1];
  1082.  
  1083.             //check for modifiers
  1084.             set .@i, 4;
  1085.             while((getarg(.@i, "") + "") != "" && (getarg(.@i + 1, "") + "") != "") {
  1086.                 set .@modIndex, getd(".modifier_" + getarg(.@i));
  1087.                 setd(.tempModPtrs$[.@modIndex], getarg(.@i + 1));
  1088.                 set .@i, .@i + 2;
  1089.                 set .gotoCount, .gotoCount + 1;
  1090.             }
  1091.             set .gotoCount, .gotoCount + 1;
  1092.            
  1093.             //store map applicable modifiers
  1094.             setd(".maps_zeny" + .@a$, .@node_zeny);
  1095.             setd(".maps_gm" + .@a$, .@node_gm);
  1096.             setd(".maps_woe" + .@a$, .@node_woe);
  1097.             setd(".maps_job" + .@a$, .@node_job);
  1098.             setd(".maps_upper" + .@a$, .@node_upper);
  1099.             setd(".maps_gender" + .@a$, .@node_gender);
  1100.             setd(".maps_blvl" + .@a$, .@node_blvl);
  1101.             setd(".maps_mapUsers" + .@b$, .@node_mapUsers$);
  1102.             setd(".maps_flag" + .@b$, .@node_flag$);
  1103.             setd(".maps_function" + .@b$, .@node_function$);
  1104.  
  1105.             //add to parent node
  1106.             setd(.@nodePtr$ + "[1]", getd(.@nodePtr$ + "[1]") + "- " + getarg(0) + ":");
  1107.             setd(.@nodePtr$ + "[" + getarraysize(getd(.@nodePtr$)) + "]", .mapCount + .mapOffset);
  1108.  
  1109.             //set index lookup for map
  1110.             setd(".map_" + getarg(1), .mapCount);
  1111.            
  1112.             set .mapCount, .mapCount + 1;
  1113.         } else {
  1114.             debugmes("TOASTYWARPER - BADMAP: " + getarg(0) + " - " + getarg(1));
  1115.         }
  1116.  
  1117.         //infinte loop check
  1118.         set .gotoCount, .gotoCount + 3;
  1119.         sleep(.gotoCount >= .gotoLimit);
  1120.         set .gotoCount, .gotoCount * (.gotoCount < .gotoLimit);
  1121.     }
  1122.  
  1123.     //-----------------------------------------------------------
  1124.     //INFINITE ARRAY FUNCTIONS
  1125.     //-----------------------------------------------------------
  1126.     function SetArrayValue {// <arrayname>, <index>, <value>{, <isString> = 0}
  1127.         //debugmes("setarrayvalue: " + (getarg(0) + "_" + (getarg(1) / 128) + "[" + (getarg(1) % 128) + "]"));
  1128.         setd getarg(0) + "_" + (getarg(1) / 128) + (getarg(3, 0)?"$":"") + "[" + (getarg(1) % 128) + "]", getarg(2);
  1129.         return;
  1130.     }
  1131.  
  1132.     function GetArrayValue {    // <arrayname>, <index>{, <isString> = 0}
  1133.         //debugmes("getarrayvalue: " + getarg(0) + "_" + (getarg(1) / 128) + (getarg(2, 0)?"$":"") + "[" + (getarg(1) % 128) + "]");
  1134.         return getd(getarg(0) + "_" + (getarg(1) / 128) + (getarg(2, 0)?"$":"") + "[" + (getarg(1) % 128) + "]");
  1135.     }
  1136.  
  1137.     function WipeArray {        //<arrayname>, <num_indices>{{, <value> = 0}, <isString> = 0}
  1138.         set .@count, getarg(1) / 128 + 1;
  1139.         for(set .@i, 0; .@i < .@count; set .@i, .@i + 1)
  1140.             cleararray(getd(getarg(0) + "_" + .@i + (getarg(3, 0)?"$":"") + "[0]"), getarg(2, 0), 128);
  1141.         return;
  1142.     }
  1143.  
  1144.     //-----------------------------------------------------------
  1145.     //LAST WARPS STORAGE FUNCTIONS
  1146.     //-----------------------------------------------------------
  1147.  
  1148.     function PrepLastWarpsMenu {
  1149.         set @menu_lastwarps$[0], "Last Warps";
  1150.  
  1151.         while(.@i < 128 && .@count < .numLastWarps) {
  1152.             set .@map, @toasty_savedMaps[(@toasty_stackStart + .@i) % 128] - 1;
  1153.             if(.@map > 0 && .@map < .mapCount) {
  1154.                 set .@mapName$, getd(".maps_name_" + (.@map / 128) + "$" + "[" + (.@map % 128) + "]");
  1155.                 set @menu_lastwarps$[.@count + 2], .@map + .mapOffset;
  1156.  
  1157.                 set .@count, .@count + 1;
  1158.                 set .@menu$, .@menu$ + .@mapName$ + ":";
  1159.             }
  1160.             set .@i, .@i + 1;
  1161.         }
  1162.         set @menu_lastwarps$[1], .@menu$ + "Back";
  1163.         return;
  1164.     }
  1165.  
  1166.     function InitialiseMapData {
  1167.         while(.@i < getarraysize(@toasty_savedMaps)) {
  1168.             setd("@toasty_map" + @toasty_savedMaps[.@i], (@toasty_savedMaps[.@i] > 0)?.@i + 1:0);
  1169.             set .@i, .@i + 1;
  1170.         }
  1171.         PrepLastWarpsMenu();
  1172.         return;
  1173.     }
  1174.  
  1175.     function AddMapToList { //<mapIndex>
  1176.         set .@map, getarg(0);
  1177.  
  1178.         if(getd("@toasty_map" + .@map) > 0) {
  1179.             if(@toasty_savedMaps[getd("@toasty_map" + .@map) - 1] == .@map) { //double checking
  1180.                 set @toasty_savedMaps[getd("@toasty_map" + .@map) - 1], 0;
  1181.             }
  1182.         }
  1183.         set @toasty_stackStart, (@toasty_stackStart + 127) % 128;
  1184.  
  1185.         set @toasty_savedMaps[@toasty_stackStart], .@map;
  1186.         setd("@toasty_map" + .@map, @toasty_stackStart + 1);
  1187.  
  1188.         set toasty_mapSave$, GenerateMapSaveString();
  1189.         return;
  1190.     }
  1191.  
  1192.     function ListMaps { //debug
  1193.         while(.@i < 128 && .@count < .numLastWarps) {
  1194.             if( @toasty_savedMaps[(@toasty_stackStart + .@i) % 128] > 0) {
  1195.                 set .@count, .@count + 1;
  1196.                 set .@out$, .@out$ + @toasty_savedMaps[(@toasty_stackStart + .@i) % 128] + ", ";
  1197.             }
  1198.             set .@i, .@i + 1;
  1199.         }
  1200.         return .@out$;
  1201.     }
  1202.  
  1203.     function GenerateMapSaveString {
  1204.         while(.@i < 128 && .@count < .numLastWarps) {
  1205.             set .@index, (@toasty_stackStart + .@i) % 128;
  1206.             if( @toasty_savedMaps[(@toasty_stackStart + .@i) % 128] > 0) {
  1207.                 set .@count, .@count + 1;
  1208.                 set .@out$, .@out$ + .char$[(@toasty_savedMaps[.@index] % 64)] + .char$[(@toasty_savedMaps[.@index] / 64)];
  1209.             }
  1210.             set .@i, .@i + 1;
  1211.         }
  1212.         return .@out$;
  1213.     }
  1214.  
  1215.     function ConvertStringToChrArray {
  1216.         if ( getstrlen( getarg(0) ) > 128 ) return 0;
  1217.             set .@charsize, getarraysize(.char$);
  1218.             set .@str$, getarg(0);
  1219.             set .@len, getstrlen(.@str$);
  1220.  
  1221.             sleep2 1;
  1222.  
  1223.             do {
  1224.                 set .@range[0], .@charsize;
  1225.                 set .@range[1], 0;
  1226.  
  1227.                 //ignore repetiton, it keeps the gotos down
  1228.                 set .@range[(.@str$ > (.@temp$ + .char$[(.@range[0] + .@range[1]) / 2] + "?"))], (.@range[0] + .@range[1]) / 2;
  1229.                 set .@range[(.@str$ > (.@temp$ + .char$[(.@range[0] + .@range[1]) / 2] + "?"))], (.@range[0] + .@range[1]) / 2;
  1230.                 set .@range[(.@str$ > (.@temp$ + .char$[(.@range[0] + .@range[1]) / 2] + "?"))], (.@range[0] + .@range[1]) / 2;
  1231.                 set .@range[(.@str$ > (.@temp$ + .char$[(.@range[0] + .@range[1]) / 2] + "?"))], (.@range[0] + .@range[1]) / 2;
  1232.                 set .@range[(.@str$ > (.@temp$ + .char$[(.@range[0] + .@range[1]) / 2] + "?"))], (.@range[0] + .@range[1]) / 2;
  1233.                 set .@range[(.@str$ > (.@temp$ + .char$[(.@range[0] + .@range[1]) / 2] + "?"))], (.@range[0] + .@range[1]) / 2;
  1234.                 set .@range[(.@str$ > (.@temp$ + .char$[(.@range[0] + .@range[1]) / 2] + "?"))], (.@range[0] + .@range[1]) / 2;
  1235.  
  1236.                 set .@charIndex, (.@range[0] + .@range[1]) / 2 + (.@str$ > (.@temp$ + .char$[(.@range[0] + .@range[1]) / 2] + "?"));
  1237.  
  1238.                 set .@temp$, .@temp$ + .char$[.@charIndex];
  1239.                 set .@arr[.@i / 2], .@arr[.@i / 2] + .@charIndex * (1 + 63 * (.@i % 2));
  1240.  
  1241.                 set .@i, .@i + 1;
  1242.             } while( .@i < .@len );
  1243.  
  1244.             sleep2 1; //used alot of gotos..sleep for good measure
  1245.  
  1246.             deletearray getd(getarg(1));
  1247.             copyarray getd(getarg(1)), .@arr, .@len / 2;
  1248.  
  1249.             return .@len / 2;
  1250.     }
  1251.     end;
  1252. }
  1253.  
  1254. prontera,151,186,5  script  Warper#toasty   721,{
  1255.     doevent "toastywarperbase::OnStartNPC";
  1256. }
Advertisement
Add Comment
Please, Sign In to add comment