<?xml version="1.0" encoding="utf-8"?><waypoints type="RUN">
<onLoad>

   --== User Option ==--
   RunningSpeed = 100    -- The speed the character runs when not teleporting. 50 is normal. Recommended 100.
   UseTeleporter = true  -- Use Jduratedj's teleport userfunction. Please make sure you have it installed to use this option.

   useGoodie("speed") -- Unbridled Enthusiasm
   
   -- Apply speed hack
   local playerAddress = memoryReadIntPtr(getProc(), addresses.staticbase_char, addresses.charPtr_offset);
   if playerAddress ~= 0 then
      memoryWriteFloat(getProc(), playerAddress + 0x40, RunningSpeed);
   end
   
   -- local teleport function checker
   function portTo(_x, _z, notWaypoint)
      -- Is Teleporter is enabled?
      if not UseTeleporter then
         return
      end

      -- Close enough. Don't teleport (when feeding hens)
      if notWaypoint then
         local dist = distance(player.X, player.Z, _x, _z)
         if 19 > dist then
            return
         end
      end

      teleport(_x, _z)
   end
   
   function hammerTime()
      local __, __,time = EventMonitorCheck("Hammertooth")
      if time ~= nil then
         time=math.floor(time/60)
         printf("time="..tostring(time).."\n");
         if time>16 then
            printf("There is no Hammertooth.\n")
            HammertoothIsInTheHouse=false;
         else
            printf("Hammertooth is here. Hurry up and get a reward!\n")
            HammertoothIsInTheHouse=true;
         end
      end
   end

   if fly == nil or teleport == nil then
      error("You have to install the 'swimhack' and/or 'teleport' userfunction")
   end
   
   function inventory_check()
      player:update()
      local zoneid = RoMScript("GetZoneID()")
      if zoneid == 4 then   
         if 1 > inventory:itemTotalCount(0) then
            cprintf(cli.yellow,"You should get empty inventory spaces.")
            player:sleep()
         end
         if 30 > inventory:itemTotalCount(203038) then
            print("You need to have 30 Phirius Tokens to enter Goblin Mines")
            player:sleep()
         end
      end
   end
   
   function settings.profile.events.onUnstickFailure()
      logInfo("Goblins_Stuck", "We got stuck", true, nil, add)
      RoMScript("LeaveParty()")
      waitForLoadingScreen()
      __WPL:setWaypointIndex(__WPL:findWaypointTag("start"));
   end
   
   teleport_SetStepSize(25)
   
   local function evalClickable(address)
      local chest = memoryReadRepeat("byte", getProc(), address + 0x2F0) or 0
      if chest ~= 0 then
         return true
      else
         return false
      end
   end
   
   function chest()
      local chest
      repeat
         chest = player:findNearestNameOrId(113164,nil,evalClickable)
         if chest then
            yrest(300)
            teleport(chest.X,chest.Z,chest.Y-40)
            keyboardPress(settings.hotkeys.STRAFF_RIGHT.key)
            keyboardPress(settings.hotkeys.STRAFF_LEFT.key)
            repeat
               player:target_Object(chest.Id, nil, nil, true, evalClickable);
            until evalClickable(chest.Address) ~= true
         end
      until chest == nil
      if chest == nil then
         teleport(nil, nil, -50, false)
         yrest(300)
      end
   end   
   
   function speed_buff()
      if Speed then
         if not player:hasBuff("506684") then   
            inventory:useItem(207200);
         end
         yrest(250)
         RoMScript("SetTitleRequest(530427)")
         yrest(250)
      end
   end
   
   --This code below is copid from cot_tele waypoin
   numshells = inventory:getItemCount(240181);
   if numshells > 950 then
      -- Wait for user to use some shells.
      cprintf(cli.yellow,"Reaching the maximum number of Phirius Shells (1000). Please spend some before continuing.\n")
      player:sleep()
      numshells = inventory:getItemCount(240181);
   end


   --Some of the code here is copied from Botromka's script
   zoneid=nil;
   repeat zoneid=RoMScript("GetZoneID()"); until zoneid;
   npcname=nil;
   repeat npcname=RoMScript("TEXT('Sys112651_name')"); until npcname;

   if math.fmod(zoneid,1000) == 4 then
   --   inventory_check()
   --   speed_buff()
   --   player:target_NPC(npcname); yrest(1000);
   --   RoMScript("ChoiceOption(1);"); yrest(1000);
   --   RoMScript("StaticPopup_OnClick(StaticPopup1, 1);");
   --   waitForLoadingScreen(15);
   end

   if zoneid==352 then fly(); end

   function UpThroughFloor()
      local rightheight = 71.5
      local dir = 3.14
      repeat
         if dir == 0 then dir = 3.14 else dir = 0 end -- Alternate direction
         teleport(nil,nil,rightheight) yrest(700)
         player:faceDirection(dir,-1.3) yrest(300)
         keyboardHold(settings.hotkeys.MOVE_FORWARD.key) yrest(300)
         keyboardRelease(settings.hotkeys.MOVE_FORWARD.key) yrest(1000)
         player:update()
      until player.Y > rightheight
   end
   
   EventMonitorStop("Hammertooth");
   EventMonitorStart("Hammertooth", "TIMEKEEPER_START");
   changeProfileOption("TARGET_LEVELDIF_BELOW",50)
   changeProfileOption("LOOT_ALL",true);      
</onLoad>
   <!-- #  1 --><waypoint x="-5852" z="3326" y="572" tag="start">      
      inventory_check()
      speed_buff()
      repeat
         player:target_NPC("112651");         -- Mahler Palo
         yrest(1000)
         sendMacro("ChoiceOption(1);");
         yrest(1000)
         RoMScript("StaticPopup_OnClick(StaticPopup1, 1);");
         waitForLoadingScreen(15)
         local zoneid = RoMScript("GetZoneID()")
      until zoneid == 352
   </waypoint>

   <!-- #  1 --><waypoint x="1862" z="2222" y="309">
   fly();   
   </waypoint>
   <!-- #  2 --><waypoint x="1932" z="2231" y="308">
      fly()
      yrest(100)
      teleportToWP()
      yrest(300)
   </waypoint>   
   <!-- #  3 --><waypoint x="1960" z="2231" y="328">
      teleportToWP()
      yrest(300)   
   </waypoint>
   <!-- #  4 --><waypoint x="1996" z="2231" y="355">
      teleportToWP()
      yrest(300)   
   </waypoint>
   <!-- #  5 --><waypoint x="2015" z="2232" y="369">
      teleportToWP()
      yrest(300)   
   </waypoint>
   <!-- #  6 --><waypoint x="2036" z="2235" y="379">
      teleportToWP()
      yrest(500)   
   </waypoint>
   <!-- #  7 --><waypoint x="2062" z="2237" y="378">hammerTime()   </waypoint>
   <!-- #  8 --><waypoint x="2255" z="2247" y="334">
      repeat
         yrest(1000)
      until RoMScript("TimeKeeperFrame:IsVisible()")      
   </waypoint>
   <!-- #  9 --><waypoint x="2250" z="2385" y="469">   </waypoint>
   <!-- # 10 --><waypoint x="2389" z="2423" y="331">   </waypoint>
   <!-- # 11 --><waypoint x="2284" z="2469" y="222">   </waypoint>
   <!-- # 12 --><waypoint x="1782" z="2763" y="222">   </waypoint>
   <!-- # 13 --><waypoint x="1691" z="2804" y="253">
      chest()
      hammerTime()
   </waypoint> 
   <!-- # 14 --><waypoint x="2502" z="2997" y="222">   </waypoint>
   <!-- # 15 --><waypoint x="2606" z="2981" y="239">
      chest()
   </waypoint>
   <!-- # 16 --><waypoint x="2446" z="3289" y="41">hammerTime()   </waypoint>
   <!-- # 17 --><waypoint x="2471" z="3445" y="41">   </waypoint>
   <!-- # 18 --><waypoint x="2487" z="3502" y="43">
      chest()
   </waypoint>
   <!-- # 19 --><waypoint x="2480" z="3365" y="41">   </waypoint>
   <!-- # 20 --><waypoint x="2843" z="3419" y="41">   </waypoint>
   <!-- # 21 --><waypoint x="4282" z="4259" y="41">   </waypoint>
   <!-- # 22 --><waypoint x="4400" z="4322" y="182">
      chest()
   </waypoint>
   <!-- # 23 --><waypoint x="4389" z="4158" y="41">   </waypoint>
   <!-- # 24 --><waypoint x="4500" z="3471" y="41">   </waypoint>
   <!-- # 25 --><waypoint x="4386" z="3460" y="149">
      chest()
   </waypoint>   
   <!-- #  26 --><waypoint x="3368" z="2950" y="30">   </waypoint>
   <!-- #  27 --><waypoint x="3308" z="2940" y="85">
      UpThroughFloor()
   </waypoint>
   <!-- #  28 --><waypoint x="3335" z="2977" y="185">
      UpThroughFloor()
   </waypoint>
   <!-- #  29--><waypoint x="3362" z="2812" y="241">      
   </waypoint>
   <!-- #  30 --><waypoint x="3440" z="2879" y="339"></waypoint>   
   <!-- #  31 --><waypoint x="3352" z="2976" y="249">   </waypoint>
   <!-- #  32 --><waypoint x="3230" z="3101" y="270">   </waypoint>
   <!-- #  33 --><waypoint x="3156" z="3247" y="267">   </waypoint>
   <!-- #  34 --><waypoint x="3137" z="3278" y="248">      
   EventMonitorStop("Hammertooth");
   loadPaths("Mini_gobsEnd");
   __WPL:setWaypointIndex(__WPL:findWaypointTag("start"));
   </waypoint>
</waypoints>