Method AttackNearestEnemy
- Namespace
- GrindFest
- Assembly
- GrindFest.dll
AttackNearestEnemy(float)
Attacks the nearest enemy within range using the hero's basic attack skill.
public static bool AttackNearestEnemy(float maxDistance = 15)
Parameters
maxDistance
floatMaximum distance to look for enemies. Default is 15 units.
Returns
- bool
True if an enemy was found and attacked, false if no valid target was found.
Remarks
This method handles both finding a target and attacking it:
- Looks for the nearest enemy using FindNearestEnemy
- Moves within attack range if the target is too far
- Uses the hero's basic attack skill when in range
- Maintains target lock until the enemy dies or moves out of range
if (!Hero.AttackNearestEnemy())
{
Hero.RunAroundInArea(); // Look for enemies
}
if (Hero.Health > Hero.MaxHealth * 0.3f) // Above 30% health
{
Hero.AttackNearestEnemy();
}
else if (Hero.HasHealthPotion())
{
{
Hero.DrinkHealthPotion();
Hero.RunAwayFromNearestEnemy();
}