Global AI API - ModDota/Dota2AIFramework GitHub Wiki
Global AI Functions
These functions are globally accessible from within all AI in the framework, these functions give access to parts of the global dota 2 API plus some extra functions.
Table of contents
- AI_BuyItem
- AI_DebugDrawBox
- AI_DebugDrawCircle
- AI_DebugDrawLine
- AI_DebugDrawSphere
- AI_DebugDrawText
- AI_EntIndexToHScript
- AI_ExecuteOrderFromTable
- AI_FindUnitsInRadius
- AI_GetGameTime
- AI_Log
- AI_MinimapEvent
- AI_Say
#Function List
AI_BuyItem(unit, itemName)
Description
Buy an item on a unit.
Parameters
- unit - The unit to buy the item on.
- itemName - The item to buy.
Modification
Does not exist in the original AI.
AI_DebugDrawBox(origin, min, max, r, g, b, a, duration)
Description
Draw a box.
Parameters
- origin - The origin vector.
- min - A vector relative to the origin with the minimal coordinate corner.
- max - A vector relative to the origin with the maximal coordinate corner.
- r - The red component in the RGBA color (0-255).
- g - The green component in the RGBA color (0-255).
- b - The blue component in the RGBA color (0-255).
- a - The alpha component in the RGBA color (0-255).
- duration - The duration of the drawing in seconds.
Modification
Only works if AIManager.AllowDebugDrawing. Forces a certain color if AIManager.ForceDrawColor.
AI_DebugDrawCircle(center, vRgb, a, rad, ztest, duration)
Description
Draw a circle.
Parameters
- center - The center of the circle
- vRgba - The color vector for the circle
- a - The alpha channel of the color.
- rad - The radius of the circle.
- ztest - Disable ztest?
- duration - The duration of the drawing
Modification
Only works if AIManager.AllowDebugDrawing. Forces a certain color if AIManager.ForceDrawColor.
AI_DebugDrawLine(origin, target, r, g, b, ztest, duration)
Description
Draw a line.
Parameters
- origin - The origin vector (from).
- target - The target vector (to).
- r - The red component in the RGBA color (0-255).
- g - The green component in the RGBA color (0-255).
- b - The blue component in the RGBA color (0-255).
- ztest - Disable ztest?
- duration - The duration of the drawing in seconds.
Modification
Only works if AIManager.AllowDebugDrawing. Forces a certain color if AIManager.ForceDrawColor.
AI_DebugDrawSphere(center, vRgb, a, rad, ztest, duration)
Description
Draw a sphere.
Parameters
- center - The center of the circle
- vRgba - The color vector for the circle
- a - The alpha channel of the color.
- rad - The radius of the circle.
- ztest - Disable ztest?
- duration - The duration of the drawing
Modification
Only works if AIManager.AllowDebugDrawing. Forces a certain color if AIManager.ForceDrawColor.
AI_DebugDrawText(origin, text, viewCheck, duration)
Description
Draw text.
Parameters
- origin - The origin vector (from).
- text - The text to display.
- viewCheck - Is the text aligned with the viewport?
- duration - The duration of the drawing in seconds.
Modification
Only works if AIManager.AllowDebugDrawing. Forces a certain color if AIManager.ForceDrawColor.
AI_EntIndexToHScript(ent_index)
Description
Return the entity by its entity index.
Parameters
- ent_index - The entity index of a unit or ability.
Modification
Returns wrapped units/abilities.
AI_ExecuteOrderFromTable(ent_index)
Description
Execute an order from a table
Parameters
- table - The order table, contains the following parameters: * UnitIndex - The entity index of the unit the order is given to. * OrderType - The type of unit given. * TargetIndex - (OPTIONAL) The entity index of the target unit. * AbilityIndex - (OPTIONAL) The entity index of the target unit. * Position - (OPTIONAL) The (vector) position of the order. * Queue - (OPTIONAL) Queue the order or not (boolean).
Modification
Only works for units of the AI, and the target entity is not in fog.
AI_FindUnitsInRadius(position, radius, teamFilter, typeFilter, flagFilter, order, canGrowCache)
Description
Finds units in a radius with some parameters.
Parameters
- Position - The center of the circle to search in
- Radius - The radius to search in
- TeamFilter - DOTA_UNIT_TARGET_TEAM_* filter.
- TypeFilter - DOTA_UNIT_TARGET_TYPE_* filter.
- FlagFilter - DOTA_UNIT_TARGET_FLAG_* filter.
- Order - The order to return results in.
- CanGrowCache - Can the search grow the cache.
Modification
Can only find units visible by the AI's team.
Return value
Type: integer Description: a
AI_GetGameTime()
Description
Get the current game time.
Modification
-
AI_Log(message)
Description
Log functionality for AI.
Parameters
- message - The message to log
Modification
-
AI_MinimapEvent(entity, xCoord, yCoord, eventType, eventDuration)
Description
Fire an event on the minimap.
Parameters
- entity - Entity the event was fired on ( can be nil ).
- xCoord - The x-coordinate of the event.
- yCoord - The y-coordinate of the event.
- eventType - The type of the event, DOTA_MINIMAP_EVENT_*.
- eventDuration - The duration of the minimap event.
Modification
Removed team parameter, limited to entities in vision.
AI_Say(player, message, teamOnly)
Description
Make a player say something in chat.
Parameters
- playerID - The id of the player doing the talking.
- message - The message.
- teamOnly - Is the message in team chat or not (boolean).
Modification
Only works for players owned by the AI, uses player ID instead of player.