get_aggro_list_element - ryzom/ryzomcore GitHub Wiki


title: Get Aggro List Element description: published: true date: 2023-03-13T13:45:07.053Z tags: editor: markdown dateCreated: 2023-03-13T13:45:07.053Z

getAggroListElement

The getAggroListElement native AI script function retrieves the Entity ID (as a string) of a player from the aggro list of a bot based on the player's aggro list index.

Syntax

(playerEidAsString: s)getAggroListElement(botIndex: f, aggroListIndex: f)

Arguments

  • botIndex (float): The index of the bot member of the current group.
  • aggroListIndex (float): The index of the aggroable player in the bot's aggro list.

Return value

  • playerEidAsString (string): The Entity ID (as a string) of the player with the specified aggro list index in the bot's aggro list. Returns an empty string if no bot is identified by the bot index or if the aggro list index is invalid.

Examples

(aggroSize)getAggroListSize(0);
// too many players are attacking the boss
if (aggroSize > 10)
{
    ($player1)getAggroListElement(0, 0);
    ($player2)getAggroListElement(0, 1);
    ($player3)getAggroListElement(0, 2);
    // the boss teleports 3 players from its aggro list to the end of the world
    teleportPlayer($player1, 14233, 123123, 0, 0);
    teleportPlayer($player2, 14233, 123123, 0, 0);
    teleportPlayer($player3, 14233, 123123, 0, 0);
    clearAggroList();
}

This example code gets the size of the aggro list for the bot at index 0 in the current group. If the aggro list size is greater than 10, it retrieves the Entity ID of the first three players in the bot's aggro list using the getAggroListElement function and stores them in the $player1, $player2, and $player3 variables. The boss then teleports the three players to the coordinates (14233, 123123, 0) and the aggro list is cleared.

Notes

A bot index is used to identify the bot. If there is only one spawned bot in a group, then the index value is 0. If the bot index of a specific bot is needed, the getBotIndexByName function can be used. The getBotCount function can be used to determine the number of bots in a group. The isGroupAlived or isBotAlived functions can be used to verify if the bot index is valid.

An aggro list index is used to identify the player in the aggro list. The size of the aggro list can be obtained using the getAggroListSize function.

If no bot is identified by the bot index (or if the bot is not spawned), the function returns an empty string and displays a warning message. The isBotAlived function can be used to ensure that the bot index is still a valid value. If the aggro list index is invalid, the function also returns an empty string.

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