Table of Contents

Method RunAwayFromNearestEnemy

Namespace
GrindFest
Assembly
GrindFest.dll

RunAwayFromNearestEnemy(float)

Makes the hero run away from the nearest enemy.

public void RunAwayFromNearestEnemy(float maxDistance = 15)

Parameters

maxDistance float

Maximum 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.

Basic retreat pattern when health is low:
if (Health < MaxHealth * 0.3f) // Below 30% health
{
    DrinkHealthPotion();
    RunAwayFromNearestEnemy();
}
Advanced kiting pattern:
if (Health < MaxHealth * 0.5f && HasHealthPotion())
{
    DrinkHealthPotion();
    RunAwayFromNearestEnemy(15); // Run from enemies within 15 units
}
else
{
    AttackNearestEnemy();
}