Method AttackNearestEnemy
- Namespace
- GrindFest
- Assembly
- GrindFest.dll
AttackNearestEnemy(float)
Attacks the nearest enemy within range using the hero's basic attack skill.
public 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 (!AttackNearestEnemy())
{
RunAroundInArea(); // Look for enemies
}
if (Health > MaxHealth * 0.3f) // Above 30% health
{
AttackNearestEnemy();
}
else if (HasHealthPotion())
{
{
DrinkHealthPotion();
RunAwayFromNearestEnemy();
}