ScriptUO

Official ScriptUO EasyUO Scripts => Script Snippets => Topic started by: TrailMyx on March 29, 2009, 10:01:22 AM

Title: TrailMyx's Locate Tree sub
Post by: TrailMyx on March 29, 2009, 10:01:22 AM
Just has one argument. 

%1 = Radius to search
returns #TRUE if a tree is found, otherwise #FALSE

Sub sets up the #LTARGET information so you can just event macro 22 (use last target)

Code: easyuo
  1. sub TM_LocateTree
  2.   namespace push
  3.   namespace local LT
  4.   if !init = N/A
  5.   {
  6.     tile init
  7.     set !init #TRUE
  8.   }
  9.   set !radius %1
  10.   set !xmin #CHARPOSX - !radius
  11.   set !xmax #CHARPOSX + !radius
  12.   set !ymin #CHARPOSY - !radius
  13.   set !ymax #CHARPOSY + !radius
  14.   for !x !xmin !xmax
  15.   {
  16.     for !y !ymin !ymax
  17.     {
  18.       tile cnt !x !y #CURSKIND
  19.       if #TILECNT > 0
  20.       {
  21.         for !i 1 #TILECNT
  22.         {
  23.           tile get !x !y !i #CURSKIND
  24.           if tree in #TILENAME
  25.           {
  26.             set #LTARGETX !x
  27.             set #LTARGETY !y
  28.             set #LTARGETZ #TILEZ
  29.             set #LTARGETTILE #TILETYPE
  30.             set #LTARGETKIND 3
  31.             namespace pop
  32.             return #TRUE
  33.           }
  34.         }
  35.       }
  36.     }
  37.   }
  38.   namespace pop
  39. return #FALSE
  40.  

If anything, hopefully this will de-mystify the TILE stuff.
Title: Re: TrailMyx's Locate Tree sub
Post by: camotbik on December 25, 2009, 08:04:03 PM
Good work. Thank you.
Title: Re: TrailMyx's Locate Tree sub
Post by: Coragin on December 25, 2009, 09:00:36 PM
*starts jumping up and down pointing* Mwinc, MWINC, LOOK LOOK!!
Title: Re: TrailMyx's Locate Tree sub
Post by: TrailMyx on December 26, 2009, 10:34:19 AM
*starts jumping up and down pointing* Mwinc, MWINC, LOOK LOOK!!

This probably won't work since this sub also relies on the tile stack.