Method Idle
- Namespace
- GrindFest
- Assembly
- GrindFest.dll
Idle(string)
A simple bot that handles basic combat, looting, and survival in a specified area. Call this method repeatedly to make your hero automatically fight and survive.
public static void Idle(string area = "Stony Plains")
Parameters
area
stringThe area where the bot should operate. Defaults to "Stony Plains".
Remarks
See the following tutorials for more information:
This bot will:
- Navigate to the specified area if not already there
- Use health potions in two scenarios:
- When below 30% health during combat
- When health is not full and no enemies are around
- Attack nearest enemies when health is good
- Pick up nearby items when no enemies around
- Run around exploring when nothing else to do
// Just call Hero.Idle() to use the basic bot
Hero.Idle();
// Hero.Idle in specific area
Hero.Idle("Crimson Meadows");
Copying the source code of this method to your own script is a good starting point for creating your own bot.
// Ensure hero is in the "Stony Plains"
if (Hero.CurrentArea?.Root.Name != "Stony Plains")
{
Hero.GoToArea("Stony Plains");
return;
}
// Hero.Health management - drink potions if health is low, only if we have potions
if (Hero.HasHealthPotion())
{
// if there are no enemies around and health is not full, drink potions
if (Hero.Health < Hero.MaxHealth && Hero.FindNearestEnemy(5) == null)
{
Hero.DrinkHealthPotion();
Hero.RunAwayFromNearestEnemy();
return; // Drinking potions to full health is a priority
}
// drink potions if below 30% or continue drinking until full
if (Hero.Health < Hero.MaxHealth * 0.3f)
{
Hero.DrinkHealthPotion();
Hero.RunAwayFromNearestEnemy();
return; // Drinking potions is a priority
}
}
// Combat - attack enemies if health is good
if (Hero.AttackNearestEnemy())
{
return; // Currently fighting an enemy
}
// Looting - pick up nearby items when not fighting
var item = Hero.FindNearestItemOnGround();
if (item != null)
{
if (Hero.PickUp(item)) // go to and pick up the item, return false until the item is picked up
{
Hero.Say($"Found {(item.Amount > 1 ? item.Amount + " " : "")} {item.name}!"); // make the hero say what they found and how many, taking into account stackable items like gold coins
return;
}
return; // Currently moving to item
}
// Exploration - run around when nothing else to do
Hero.RunAroundInArea();