get_bot_index_by_name - ryzom/ryzomcore GitHub Wiki


title: Get Bot Index by Name description: published: true date: 2023-03-13T03:57:00.683Z tags: editor: markdown dateCreated: 2023-03-13T03:56:57.614Z

getBotIndexByName

The getBotIndexByName native AI script function is used to get the index of a bot in a group by its name, or return -1 if the bot is not found. This function is mainly useful for scripted bosses.

The bot index begins at zero for the first member of the group.

Syntax

(botIndex: f)getBotIndexByName(botName: s)

Arguments

  • botName (string): The name of the bot to search for.

Return Value

  • botIndex (float): The index of the bot member of the current group.

Examples

(botIndex)getBotIndexByName("boss_random_aggro");
($playerId)getRandomPlayerAggroListTarget(botIndex);
()setAggroListTarget(botIndex, $playerId);

This example code uses getBotIndexByName to retrieve the index of the bot named "boss_random_aggro", stores it in a variable called botIndex, and uses that variable in two other functions.

⚠️ **GitHub.com Fallback** ⚠️