Method RunAwayFromNearestEnemy
- Namespace
- GrindFest
- Assembly
- GrindFest.dll
RunAwayFromNearestEnemy(float)
Makes the hero run away from the nearest enemy.
public static void RunAwayFromNearestEnemy(float maxDistance = 15)
Parameters
maxDistance
floatMaximum distance to check for enemies. Enemies beyond this range will be ignored.
Remarks
This method is commonly used when the hero needs to retreat, such as when low on health and drinking potions. The hero will move in the opposite direction from the nearest enemy.
if (Hero.Health < Hero.MaxHealth * 0.3f) // Below 30% health
{
Hero.DrinkHealthPotion();
Hero.RunAwayFromNearestEnemy();
}
if (Hero.Health < Hero.MaxHealth * 0.5f && Hero.HasHealthPotion())
{
Hero.DrinkHealthPotion();
Hero.RunAwayFromNearestEnemy(15); // Run from enemies within 15 units
}
else
{
Hero.AttackNearestEnemy();
}