get_bot_index_by_name - ryzom/ryzomcore GitHub Wiki
title: Get Bot Index by Name description: published: true date: 2023-03-16T23:07:03.219Z tags: editor: markdown dateCreated: 2023-03-16T22:23:36.372Z
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.
(botIndex: f)getBotIndexByName(botName: s)
- botName (string): The name of the bot to search for.
- botIndex (float): The index of the bot member of the current group.
(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.