Table of Contents

Movement

The automation of your hero starts with making it move.

You can make your hero follow your mouse cursor and attack nearby enemies, using the following code:

class MyHero : AutomaticHero
{
    // This is an Update method and it's called by the game all the time (Approximately 60 times per second). Whatever you put here, the bot will be doing it. 
    void Update()
    {
        if (IsBotting) // The Update method is called even if you pause the bot, this check is to make sure the bot is running. I'll be skipping it in tutorials if not relevant.
        {
            FollowCursorAndAttack(); // Makes your hero follow your mouse cursor and attack nearby enemies
        }
    }
}

There is a new keyword here called if. It's a conditional statement that checks if the condition inside the parentheses is true. If it is, the code inside the curly brackets will be executed. If it's false, the code will be skipped. In this method we are checking a where IsBotting is true.

Note: When you click the Play button or press F5 the game will set IsBotting to true.

If you don't include the if statement, the bot will follow your cursor even when you pause it.

Run around in area


class MyHero : AutomaticHero
{
    void Update()
    {
        if (!IsBotting) // alternatively you can check if you are NOT botting
        {
            return; // and use the return statement to exit the method prematurely. The method will stop executing and nothing below this line will be executed.
        }
        
        
        RunAroundInArea();
    }
}

The return statement is used to stop the execution of the method and return to the caller.

Note:This method has a return type void so you don't need to write what value you want to return in the return statement.

Killing monsters in the area

You can use method bool AttackNearestEnemy() to attack nearby enemies. This method has a return type "boolean" which means it returns true/false whether it was able to find some enemy and attack it or not. If you're not able to find the enemy, you will RunAroundInArea() to find the enemy.

The ! symbol in front of the AttackNearestEnemy() call is a logical NOT operator. It inverts the value of the expression. If the expression is true, it will return false and vice versa.

class MyHero : AutomaticHero
{
    void Update()
    {
        if (!AttackNearestEnemy())
        {
            RunAroundInArea();
        }
    }
}

GoTo

Vector3 Location

FindRandomPositionInArea()

FollowStoryPath()

What to do next?