Finaltwist

Member
ServUO Version
Publish Unknown
Ultima Expansion
None
Hi all, im trying to create an automation system for adventures, and i am having problems searching for trees near the player. ive tried

GetLandTile
GetStaticTiles
and a simple
GetObjectsInRange

but none of the above can find a ID/ItemID that matches with that of a tree.
Does anyone know a good method to achieve this, other than having to manually target the tree?

im trying to find trees without having to manually target
 
I have used tileID. Here is an example:
public static bool IsBamboo (int tileID)
{
for (int i = 0; i < BambooTiles.Length; i += 2)
{
if (tileID >= BambooTiles && tileID <= BambooTiles[i + 1])
return true;
}
return false;
}

Then I compare the tileID to a list:
private static int[] BambooTreeStatics = new int[]
{
0x24bc, 0x2470, // Bamboo
};
It may be that your id numbers, such as the 0x24bc through 0x2470 in my example are not correct.
 
If you are searching for actual items you can use this

C#:
List<Item> items = new List<Item>();
IPooledEnumerable pe = from.GetItemsInRange(p, 3);
foreach (Item item in pe)
{
    if (!items.Contains(item))
        items.Add(item);
}
pe.Free();

foreach (Item item in items)
{
    if (item is Tree)
    {
        Tree tr = item as Tree;
        tr.Name = "MyTree";
    }
}

For static tiles it's a bit more complicated so i just made a command out of it.


C#:
  public class FindTree
    {
        public static void Initialize()
        {
            CommandSystem.Register("FindTree", AccessLevel.Player, new CommandEventHandler(FindTree_OnCommand));
        }
        [Usage("FindTree")]
        [Description("Finds a nerby Tree")]
        public static void FindTree_OnCommand(CommandEventArgs e)
        {
            Mobile from = e.Mobile as Mobile;
            if (from.Alive && !from.Deleted && from != null)
            {
                Map m_Map = from.Map;
                int range = 3;
                var region = new Rectangle2D(from.X - range, from.Y - range, range * 2 + 1, range * 2 + 1);
                for (int y = region.Y; y < region.Y + region.Height; ++y)
                {
                    for (int x = region.X; x < region.X + region.Width; ++x)
                    {

                        StaticTile[] tiles = m_Map.Tiles.GetStaticTiles(x, y);

                        for (int i = 0; i < tiles.Length; ++i)
                        {
                            StaticTile tile = tiles[i];
                            ItemData id = TileData.ItemTable[tile.ID & TileData.MaxItemValue];

                            bool isTree = ((tile.ID == 3277) ||
                                            (tile.ID == 3280) ||
                                            (tile.ID == 3283) ||
                                            (tile.ID == 3290));

                            if (isTree)
                            {
                                from.SendMessage("Found tree: " + id.Name);
                            }
                        }

                    }
                }
            }
        }
    }

Enjoy!
 
thanks all! Just figured it out... the tree IDs in lumberjacking all had + 0x4000 added to the itemID for some really strange reason, so my item ids never matched!
Oddly enough, the static tiles i find have X and Y coords as 0, even though then i props the tree ingame it has proper coords....
 
Last edited:
okay... well got the system working fine now, adventures automations does a ton of new carpal-tunnel-causing tasks completely automatically.

lumberjacking, mining, skinning, milling, fishing...

speak and your char does the action until out of resources. Love it!
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back