-
Notifications
You must be signed in to change notification settings - Fork 94
get_aggro_list_size
title: Get Aggro List Size description: published: true date: 2023-03-16T23:06:53.477Z tags: editor: markdown dateCreated: 2023-03-16T22:23:24.000Z
The getAggroListSize native AI script function returns the size of the aggro list of a bot, which is a list of aggroable players.
(sizeOfAggroList: f)getAggroListSize(botIndex: f)
- botIndex (float): The index of the bot member of the current group.
- sizeOfAggroList (float): The size of the aggro list.
(aggroSize)getAggroListSize(0);
// Too many players are attacking the boss
if (aggroSize > 10) {
($player1)getAggroListElement(0);
($player2)getAggroListElement(1);
($player3)getAggroListElement(2);
// So the boss teleports 3 people 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 of the bot at index 0 in the current group. If there are more than 10 players attacking the bot, the Entity IDs of the first three players in the aggro list are stored in the $player1
, $player2
, and $player3
variables using the getAggroListElement
function. The boss then teleports these three players to the end of the world using the teleportPlayer
function, and the aggro list is cleared using the clearAggroList
function.
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.
If no bot is identified by the bot index (or if the bot is not spawned), the function returns 0 and displays a warning message. The isBotAlived
function can be used to ensure that the bot index is still a valid value.