Table of Contents

Method FindNearestItem

Namespace
GrindFest.BotApi
Assembly
GrindFest.dll

FindNearestItem(string, string, string, float)

Finds the nearest item on the ground that matches the specified name criteria.

public ItemBehaviour FindNearestItem(string name1 = "", string name2 = null, string name3 = null, float maxDistance = 15)

Parameters

name1 string

Primary name to search for. Item name must contain this string. If empty, matches any name.

name2 string

Optional secondary name to search for. If provided, item name must contain either this or name1.

name3 string

Optional tertiary name to search for. If provided, item name must contain either this, name2, or name1.

maxDistance float

Maximum search distance from the hero. Defaults to 15 units.

Returns

ItemBehaviour

The nearest ItemBehaviour that matches the criteria, or null if no matching item is found.

Remarks

The method searches for items in a box-shaped area around the hero. Items must be:

  • Within the specified maxDistance
  • Not already in an inventory
  • Not currently equipped
  • Not being carried by a player
  • Reachable by the hero's navigation system
Find the nearest potion:
var potion = FindNearestItem("Vial of Health");
if (potion != null)
{
    PickUp(potion);
}
Find any weapon (sword or axe):
var weapon = FindNearestItem("sword", "axe");
if (weapon != null)
{
    Say($"Found a {weapon.name}!");
}