Skip to content

API Reference

Player Object

Obtained from local_player() or get_players()

FunctionReturnsDescription
p:get_health()floatCurrent health points
p:get_max_health()floatMaximum health points
p:get_health_percentage()floatHealth as percentage (0-100)
p:get_position()vec3World position of the player
p:get_velocity()vec3Current velocity vector
p:get_view_angles()vec2Player's eye angles as vec2(pitch, yaw). For local player this matches camera.get_view_angles(); for enemies it returns their networked eye direction.
p:get_bone_position(bone)vec3World position of a skeleton bone (use bone enum)
p:get_hero_id()intHero identifier (compare with hero_id enum)
p:get_team()intTeam number
p:get_distance(other?)floatDistance in meters. If other is nil, returns distance to local player.
p:is_alive()boolWhether the player is alive
p:is_visible()boolWhether the player is visible (not occluded)
p:is_valid()boolWhether the player entity is valid
p:is_on_screen()boolWhether the player is within screen bounds
p:is_scoped()boolWhether the player is scoped in
p:is_in_reload()boolWhether the player is reloading
p:is_enemy()boolWhether the player is on the enemy team
p:is_primary_weapon_active()boolWhether the primary weapon is active
p:is_in_melee_attack()boolWhether the player is performing a melee attack
p:is_(player_flag)boolCheck an engine-level entity flag (use player_flag enum)
p:get_modifier_flags()intRaw modifier flag bitmask
p:has_modifier_flag(modifier_flag)boolCheck a gameplay modifier flag (use modifier_flag enum)
p:has_modifier(name)boolCheck for a named modifier, e.g. "modifier_citadel_stunned"
p:get_modifier_names()tableArray of active modifier name strings
p:get_modifier_count()intNumber of active modifiers
p:get_active_projectile_speed()floatProjectile speed of the currently active weapon
p:get_items()tableArray of item tables with fields: name, subclass, bucket, slot, cooldown
p:has_item(name)boolCheck if player owns an item by designer name, e.g. "upgrade_burst_fire"
p:get_item(name)table?Get item by designer name. Returns table with fields: name, subclass, bucket, slot, cooldown. Returns nil if not found.
p:get_item_count()intNumber of items owned
p:has_abilities()boolWhether ability data is available
p:get_ability(slot)table?Get ability info by slot enum (slot.ability1–slot.ability4 for abilities, slot.item1–slot.item4 for active items). Returns table with fields: name, slot, points, learned, cooldown, projectile_speed, range, is_ready, is_cooling_down, is_in_cast_delay, is_casting, is_channeling. Returns nil if slot is empty or abilities unavailable.
p:is_ability_ready(slot)boolCheck if ability at slot is available and off cooldown
p:is_targetable()boolCheck if player can be targeted (alive, valid, visible, not immune/urn/godmode)
p:get_abilities()tableAll abilities keyed by slot enum value. Each value is the same table format as get_ability().

Ability Table

Returned by p:get_ability(slot). Each table has these fields:

FieldTypeDescription
namestringAbility designer name
slotintSlot enum value
pointsintUpgrade points spent
cooldownfloatCooldown percentage (0-100)
projectile_speedfloatProjectile speed
rangefloatRange
is_readyboolCan be cast now
is_cooling_downboolOn cooldown
is_in_cast_delayboolIn cast animation

Item Table

Returned by p:get_items(). Each entry in the table has these fields:

FieldTypeDescription
namestringItem designer name
subclassstringItem subclass name
bucketintItem category (see bucket enum)
slotintInventory slot index
cooldownfloatCooldown percentage (0-100)

Targeting

FunctionReturnsDescription
targeting.find_closest_by_fov(max_fov, max_distance)player?Find the enemy closest to crosshair within FOV and distance limits
targeting.find_closest_by_distance(max_distance)player?Find the nearest enemy within distance limit
targeting.compute_aim_delta(target, bone, projectile_speed?, speed?, target, position, projectile_speed?, speed?, position)vec2Compute mouse delta needed to aim at target bone, with optional projectile leading. Speed (0.01-1.0) enables smoothness compensation to predict target movement during smooth aiming. Compute mouse delta needed to aim at a world position with prediction applied against target (tick comp, smoothness, projectile leading). Compute mouse delta needed to aim at a world position. No prediction is applied.
targeting.get_fov(target, bone)floatGet angular distance (FOV) from crosshair to target bone
targeting.find_all_in_range(max_distance)tableGet all valid, alive enemy players within distance (meters).
targeting.smoothness_compensation(speed)floatCompute smoothness compensation factor for a given smooth speed. Useful for velocity prediction when using smoothed mouse movement.

Input

FunctionReturnsDescription
input.is_key_held(key)boolCheck if a key is currently held down
input.press_key(key)voidSend a key press and release
input.key_down(key)voidSend a key down event (hold)
input.key_up(key)voidSend a key up event (release)
input.is_mouse_key(key)boolCheck if a virtual key code is a mouse button
input.move_mouse(delta, speed?, detach_factor?)boolMove mouse by pixel delta. With no extra args: raw movement. With speed (0.01-1.0, lower = smoother): smoothed. With detach_factor: controls smoothing curve aggressiveness.
input.snap_to(target, bone, projectile_speed?)voidInstantly move crosshair to target bone

Keybinds

Read the user's configured keybinds

lua
keybinds.ability1_key()
keybinds.ability2_key()
keybinds.ability3_key()
keybinds.ability4_key()
keybinds.item1_key()
keybinds.item2_key()
keybinds.item3_key()
keybinds.item4_key()
keybinds.reload_key()
keybinds.parry_key()
keybinds.dash_key()
keybinds.jump_key()

Global Functions

FunctionReturnsDescription
local_player()player?Get the local player object, or nil if unavailable
get_players()tableGet array of valid enemy player objects
left_click()voidSimulate a left mouse click (press + 25ms + release)
right_click()voidSimulate a right mouse click (press + 25ms + release)
clock()floatHigh-resolution timer in seconds since first call
lock_aim(target, opts?)voidLock aim onto a target. Options table fields: bone (int), projectile_velocity (float), speed (float, 0.1-1.0, default 0.5).
unlock_aim()voidRelease the current aim lock
slot_to_key(slot)intConvert a slot enum value to its configured virtual key
print(...)voidPrint to the script log with the script name prefix

Config

Per-script configuration accessed via the config table

FunctionReturnsDescription
config.get_bool(key)boolGet a boolean config value by key
config.set_bool(key, value)voidSet a boolean config value
config.get_int(key)intGet an integer config value by key
config.set_int(key, value)voidSet an integer config value
config.get_float(key)floatGet a float config value by key
config.set_float(key, value)voidSet a float config value

Vector Types

vec2

2D vector type. Construct with vec2() or vec2(x, y). Supports +, -, *, / operators with both vec2 and float operands.

Field/MethodTypeDescription
xfloatX component
yfloatY component
vec2:dot(other)floatDot product with another vec2
vec2:angle_to(other)floatAngle in degrees from this vector to another (atan2-based)
vec2:empty()boolCheck if zero vector
vec2:length()floatVector magnitude
vec2:length_sqr()floatSquared magnitude (faster than length)
vec2:distance(other)floatDistance to another vec2
vec2:normalized()vec2Return unit-length copy

vec3

3D vector type. Construct with vec3() or vec3(x, y, z). Supports +, -, *, / operators with both vec3 and float operands.

Field/MethodTypeDescription
xfloatX component
yfloatY component
zfloatZ component
vec3:dot(other)floatDot product with another vec3
vec3:cross(other)vec3Cross product with another vec3
vec3:angle_to(other)floatAngle in degrees between this vector and another
vec3:empty()boolCheck if zero vector
vec3:length()floatVector magnitude
vec3:length_sqr()floatSquared magnitude (faster than length)
vec3:length_2d()floatMagnitude of XY components only
vec3:distance(other)floatDistance to another vec3
vec3:normalized()vec3Return unit-length copy

Camera

Camera state, coordinate conversion, and screen information

FunctionReturnsDescription
camera.get_position()vec3Camera origin in world space
camera.get_view_angles()vec2Current view angles as vec2(pitch, yaw)
camera.get_forward()vec3Unit forward direction vector derived from view angles
camera.get_fov()floatCurrent screen field-of-view in degrees
camera.get_screen_size()vec2Screen resolution as vec2(width, height)
camera.world_to_screen(pos)vec2?Project a world position to screen coordinates. Returns vec2(x, y) or nil if behind camera.