Core#
Defined in Core.hpp. Logging, time, input, screen info, and world-to-screen projection.
Log#
Prints a message to the Xenon console. This is the only way to output text for debugging since printf is not available.
Note
There is no format string support. To log numbers, convert them to a string manually (see FAQ).
LogDebug#
Prints a debug-level message to the Xenon console.
LogWarning#
Prints a warning-level message to the Xenon console.
LogError#
Prints an error-level message to the Xenon console.
IsIngame#
Returns true if the local player is currently in a match.
GetMapId#
Returns the current map identifier. The value is game-internal; useful for map-specific logic.
GetSensitivity#
Returns the player's in-game mouse sensitivity setting.
SetSensitivity#
Writes the player's in-game mouse sensitivity setting. Values must be positive finite floats.
GetMouseDelta#
Returns the game's current accumulated mouse delta pair from the InputManager. The value is read-only and comes from the game input pipeline, not from OS cursor position.
GetCurrentHero#
Returns the hero pool ID of the local player's current hero. Compare with HeroId constants.
GetTime#
Returns the current time in seconds since the application started. Useful for animations and timers.
IsKeyDown#
Returns true if the specified key is currently held down.
| Parameter | Type | Description |
|---|---|---|
vkey |
int |
Virtual key code (see VK constants) |
if (IsKeyDown(VK::LButton))
Log("Left mouse button is held");
if (IsKeyDown(VK::Shift))
Log("Shift is held");
Tip
For single-press detection, use IsKeyPressed instead.
IsKeyPressed#
Returns true only on the frame the key transitions from up to down (leading edge). Use this for toggle behavior or single-fire actions.
| Parameter | Type | Description |
|---|---|---|
vkey |
int |
Virtual key code (see VK constants) |
IsKeyReleased#
Returns true only on the frame the key transitions from down to up (trailing edge).
| Parameter | Type | Description |
|---|---|---|
vkey |
int |
Virtual key code (see VK constants) |
Hotkey#
Defined in Hotkey.hpp. A convenience struct that bundles a virtual key code with edge detection, a menu keybind widget, toggle helper, and config persistence.
struct Hotkey {
uint32_t vk = 0;
Hotkey();
Hotkey(uint32_t defaultKey);
void Update(); // call once per frame
bool IsDown() const; // held
bool Pressed() const; // just pressed (edge)
bool Released() const; // just released (edge)
bool Toggle(bool& state); // flip on press
bool Render(const char* label); // menu widget
void Load(const char* key); // config load
void Save(const char* key) const; // config save
};
Update#
Call once per frame (typically at the start of on_frame) to sample key state and compute edge transitions:
static Hotkey aimKey(VK::RButton);
void on_frame(float dt) {
aimKey.Update();
if (aimKey.IsDown()) { /* key is held */ }
if (aimKey.Pressed()) { /* just pressed this frame */ }
if (aimKey.Released()) { /* just released this frame */ }
}
Toggle#
Flips a bool on the press edge. Returns true if the state was toggled:
static Hotkey toggleKey(VK::Insert);
static bool espEnabled = false;
void on_frame(float dt) {
toggleKey.Update();
toggleKey.Toggle(espEnabled);
}
Render#
Renders the Xenon keybind widget in the menu. Returns true if the user changed the binding:
Load / Save#
Persist the bound key to plugin config. Load uses the current vk as the default value:
static Hotkey aimKey(VK::RButton);
void on_load() {
aimKey.Load("aim_key");
}
void on_unload() {
aimKey.Save("aim_key");
}
ScreenSize#
Returns the current screen resolution as a Vector2.
ScreenCenter#
Returns the center of the screen. Equivalent to ScreenSize() * 0.5f.
WorldToScreen#
Render-only
Call from on_render() only. The view-projection matrix is refreshed during the render phase; calling from on_frame() returns false, writes zeros, and logs a warning. If you need projected coordinates in on_frame(), cache the result in on_render() and read the cache.
Converts a 3D world position to 2D screen coordinates.
Overload 1: Bool return#
Returns true if the position is on screen. The result is written to screenPos.
| Parameter | Type | Description |
|---|---|---|
worldPos |
const Vector3& |
World-space position |
screenPos |
Vector2& |
Output: screen-space position |
| Returns | Description |
|---|---|
true |
Position is on screen, screenPos is valid |
false |
Position is behind the camera |
Vector3 headWorld = enemy.GetBonePos(Bone::Head);
Vector2 headScreen;
if (WorldToScreen(headWorld, headScreen))
{
Draw::CircleFilled(headScreen, 5.f, Color::Red());
}
Overload 2: Direct return#
Returns the screen position directly. If the position is behind the camera, returns {0, 0}.
Vector2 pos = WorldToScreen(enemy.GetPosition());
if (pos.IsValid())
Draw::Text(pos, Color::White(), "Here");
Tip
Prefer the bool overload — it explicitly tells you whether the projection succeeded. The direct return overload can't distinguish "behind camera" from "top-left corner of screen".
WorldToScreenUnclamped#
Render-only
Same phase requirement as WorldToScreen — call from on_render() only.
Like WorldToScreen, but does not reject positions outside the screen bounds. Returns coordinates even if they are off-screen (negative or beyond screen width/height). Only returns false if the position is behind the camera.
| Parameter | Type | Description |
|---|---|---|
worldPos |
const Vector3& |
World-space position |
screenPos |
Vector2& |
Output: screen-space position (may be off-screen) |
Use this when projecting bounding box corners for ESP — standard WorldToScreen silently discards off-screen corners, which causes 2D boxes to shrink or distort at screen edges and steep camera angles.
// Project 8 AABB corners to get a correct screen-space bounding box
Vector3 bMin = enemy.GetBoundsMin();
Vector3 bMax = enemy.GetBoundsMax();
Vector3 pos = enemy.GetPosition();
Vector3 corners[8] = { /* all 8 combinations of pos+bMin/bMax */ };
float sMinX = 99999.f, sMinY = 99999.f;
float sMaxX = -99999.f, sMaxY = -99999.f;
for (int i = 0; i < 8; ++i)
{
Vector2 sc;
if (WorldToScreenUnclamped(corners[i], sc))
{
if (sc.x < sMinX) sMinX = sc.x;
if (sc.y < sMinY) sMinY = sc.y;
if (sc.x > sMaxX) sMaxX = sc.x;
if (sc.y > sMaxY) sMaxY = sc.y;
}
}
// Clamp final rect to screen bounds before drawing
GetCameraPosition#
Render-only
Call from on_render() only. The view-projection matrix is refreshed during the render phase; calling from on_frame() returns false, writes {0, 0, 0}, and logs a warning.
Returns the camera's world-space position, extracted from the view-projection matrix.
Overload 1: Bool return#
Returns true if the camera position is available. The result is written to out.
| Parameter | Type | Description |
|---|---|---|
out |
Vector3& |
Output: world-space camera position |
Overload 2: Direct return#
Returns the camera position directly. Returns {0, 0, 0} if unavailable.
GetCameraForward#
Phase-safe
This query works from both on_frame() and on_render(). The render phase
uses the current render snapshot; the frame phase uses the locked update
snapshot. Other matrix APIs remain render-only.
Returns the camera's normalized forward direction, derived from the view-projection matrix.
Overload 1: Bool return#
Returns true if the forward direction is available. The result is written to out.
Overload 2: Direct return#
Returns the forward direction directly. Returns {0, 0, 0} if unavailable.
// GetCameraPosition remains render-only, so this combined example belongs in
// on_render(). GetCameraForward/GetViewDirection alone also work on_frame().
Vector3 fwd = GetCameraForward();
Vector3 toEnemy = (enemy.GetPosition() - GetCameraPosition()).Normalized();
float dot = fwd.Dot(toEnemy); // 1.0 = directly ahead, 0.0 = perpendicular
GetViewDirection alias#
These aliases have the same behavior. The name makes the distinction from
AimGetDirection() explicit: this is rendered-camera direction, while the aim
getter reads command state.
GetViewMatrix#
Render-only
Same phase requirement as GetCameraPosition — call from on_render() only.
Copies the raw 4x4 view-projection matrix into a 16-float buffer (row-major layout).
| Parameter | Type | Description |
|---|---|---|
out16 |
float* |
Output: 16-float buffer for the 4x4 matrix |
| Returns | Description |
|---|---|
true |
Matrix was available and copied |
false |
Not in-game or matrix unavailable |
float vp[16];
if (GetViewMatrix(vp))
{
// vp[0..3] = row 0
// vp[4..7] = row 1
// vp[8..11] = row 2
// vp[12..15] = row 3
}
Note
This is a combined view-projection matrix, not a separate view or projection matrix. Use GetCameraPosition() and GetCameraForward() for the common cases — the raw matrix is for advanced use like custom projection or off-screen indicators.
Ability Queries#
All ability queries return data for the local player only.
GetUltCharge#
Returns the local player's ultimate charge percentage (0–100).
Use HasUltCharge() to distinguish a real 0% value from a temporarily unavailable sample:
IsUltReady#
Returns true if ultimate charge is available and at 100%.
IsUltActive#
Returns true if the ultimate ability is currently active.
GetDvaSelfDestructState#
DvaSelfDestructState state{};
if (GetDvaSelfDestructState(state) && state.IsActive()
&& state.IsTeamKnown() && state.IsEnemy())
{
// state.position is the spawned enemy mech.
}
Self-Destruct is detected from the spawned non-controller mech entity. D.Va's
remote ult charge is not a bomb lifetime or cooldown signal. When
IsTeamKnown() is false, the event is active but must not be assumed friendly
or hostile.
IsSkill1Active#
Returns true if Skill 1 (Shift) is currently active.
IsSkill2Active#
Returns true if Skill 2 (E) is currently active.
IsSkill3Active#
Returns true if Skill 3 is currently active.
GetHeroState#
Returns a bitmask of the local player's current state. See HeroState constants.
uint32_t state = GetHeroState();
if (state & HeroState::Ulting)
Log("Ultimate is active");
if (state & HeroState::Reloading)
Log("Reloading");
Skill Cooldowns#
SkillCooldown#
struct SkillCooldown
{
float current; // Time remaining (cooldown or duration)
float max; // Total time (cooldown length or ability duration)
bool enabled; // True if actively ticking
CooldownStatus status;
bool IsSupported() const;
bool IsAvailable() const;
bool IsOnCooldown() const; // available && enabled && current > 0
bool IsReady() const; // available && !IsOnCooldown()
bool IsActive() const; // Alias for IsOnCooldown — prefer for duration queries
float GetPercent() const; // current / max (0.0 – 1.0)
};
Also used by the Ability Duration API below.
CooldownStatus is Unsupported, Unavailable, or Available. An unavailable
sample is deliberately not ready. Retry on a later update instead of
assuming a zero timer means the ability is usable.
GetAbilityCooldown / GetSecondaryFireCooldown#
Queries by physical input. Use GameButton::RMouse, GameButton::Skill1
(Shift), or GameButton::Skill2 (E). Bastion's Tactical Grenade, for example,
is secondary fire rather than Skill 2.
GetSkill1Cooldown#
Returns the cooldown state for Skill 1 (Shift) of the local player. Hero-specific — the cooldown variable is looked up per-hero.
GetSkill2Cooldown#
Returns the cooldown state for Skill 2 (E) of the local player.
GetSkill3Cooldown() and GetUltCooldown() are deprecated and return
Unsupported: ultimates use charge and active state, not a universal cooldown
timer.
auto cd = GetSkill1Cooldown();
if (!cd.IsAvailable())
return; // retry on a later update
if (cd.IsOnCooldown())
Log("Skill 1 on cooldown: %.1f / %.1f", cd.current, cd.max);
Ability Durations#
Duration tracking for scripted abilities (e.g. Genji Dragonblade, Soldier Visor). Uses the same SkillCooldown struct — current is time remaining, max is total duration, enabled is true while the ability is actively running.
GetSkill1Duration#
Returns the duration state for Skill 1 (Shift) of the local player. Only populated while the ability is active.
GetSkill2Duration#
Returns the duration state for Skill 2 (E) of the local player.
GetSkill3Duration#
Returns the duration state for Skill 3 of the local player.
Tip
All cooldown and duration queries above return data for the local player only.
For per-entity cooldowns (enemies and teammates), use the Entity class methods instead.
Hero-Specific Charges#
GetRailgunCharge#
Returns Sojourn's railgun charge level. Only meaningful when playing Sojourn.
GetIllariCharge#
Returns Illari's solar rifle charge level. Only meaningful when playing Illari.
GetHanzoCharge#
Returns Hanzo's bow draw charge level. Only meaningful when playing Hanzo.
GetWidowCharge#
Returns Widowmaker's sniper scope charge level. Only meaningful when playing Widowmaker.
GetLookupSkill#
Generic skill value lookup by ID. Returns cached values for known IDs, 0.0 for unknown IDs.
| Parameter | Type | Description |
|---|---|---|
lookupId |
uint16_t |
Skill lookup ID (see SkillId constants) |
float charge = GetLookupSkill(SkillId::SojournCharge);
float ult = GetLookupSkill(SkillId::UltCharge);
Note
Only a subset of lookup IDs are currently cached. Unknown IDs return 0.0. See SkillId constants for supported IDs.
Aim Control#
Functions for controlling the local player's command/firing direction. These
use the same mechanism as the internal aimbot: reading and writing the UserCmd
direction vector directly in game memory. The command direction can differ from
the rendered camera during recoil, camera animation, spectator/replay, or
third-person effects; use GetViewDirection() for the latter.
Warning
Using aim functions while the internal aimbot is active will cause conflicts. Disable the built-in aimbot for heroes where your plugin handles aiming.
AimSetDirection#
Sets the command/firing direction vector instantly (no smoothing). The vector is normalized automatically. Resets any active spring smoothing state.
| Parameter | Type | Description |
|---|---|---|
dir |
const Vector3& |
Desired view direction (will be normalized) |
Vector3 toEnemy = (enemy.GetHeadPos() - GetCameraPosition()).Normalized();
AimSetDirection(toEnemy);
AimGetDirection#
Returns the local player's normalized command/firing direction vector. This is phase-safe and survives the transient connection-pointer rebuild used by the update loop.
AimSetAngles#
Sets command angles in radians (instant, no smoothing). World space is Y-up:
yaw 0 points along +X, positive yaw turns toward +Z, positive pitch looks
down, and negative pitch looks up. Pitch is clamped to +/-89 degrees. Resets any
active spring smoothing state.
| Parameter | Type | Description |
|---|---|---|
pitch |
float |
Vertical angle in radians (negative = look up, positive = look down) |
yaw |
float |
Horizontal angle in radians; 0 = +X, positive toward +Z |
Vector3 angles = CalcAngle(GetCameraPosition(), enemy.GetHeadPos());
AimSetAngles(angles.x, angles.y); // .x = pitch, .y = yaw
AimGetAngles#
Returns the current command angles as (pitch, yaw) in radians using the same
axis and sign convention as AimSetAngles().
Vector2 angles = AimGetAngles(); // .x = pitch, .y = yaw
float pitch, yaw;
AimGetAngles(pitch, yaw);
AimAtPosition#
Aims at a world-space position using a critically-damped spring for smooth, human-like motion. Call this every frame while tracking a target.
| Parameter | Type | Description |
|---|---|---|
target |
const Vector3& |
World-space position to aim at |
stiffness |
float |
Spring stiffness: 0 = instant snap, 10-200 = human-like, 500+ = near-instant |
The spring model guarantees no overshoot or oscillation. Higher stiffness values mean faster convergence.
// Smooth aim at enemy head
Entity target = FindBestTargetInFov(100.f, Bone::Head, TargetFlags::Enemy | TargetFlags::Visible);
if (target)
AimAtPosition(target.GetHeadPos(), 80.f);
AimAtPositionEx#
bool AimAtPositionEx(
const Vector3& target,
float stiffness,
float toleranceRad,
AimStepResultV1& out);
Runs the same smooth-aim step as AimAtPosition, but returns versioned convergence telemetry from the direction read back before this step. A successful direction write alone never counts as settled. It is phase-agnostic and is normally advanced from on_frame().
| Field | Type | Description |
|---|---|---|
state |
uint32_t / AimStateV1 |
Invalid, Turning, or Settled |
angularErrorRad |
float |
Observed pre-write angular error in radians |
angularVelocityRadPerSec |
float |
Observed pre-write combined spring angular speed |
commandTick |
uint32_t |
Stable command tick bracketing the direction read, or 0 if it crossed a boundary |
settledCommandTicks |
uint32_t |
Consecutive stable command-tick reads within toleranceRad |
AimStepResultV1 provides IsValid(), IsTurning(), and IsSettled() helpers. The function returns false and leaves out in the Invalid state when the command cannot be evaluated.
The host brackets each direction read with the command counter. A read that crosses a command-tick boundary can still advance the spring, but it cannot advance the settlement streak. Even with stiffness 0 (instant write), Settled therefore requires the target direction to be observed on two later consecutive command ticks.
AimStepResultV1 aim{};
if (AimAtPositionEx(groundPoint, 80.f, 0.01f, aim))
{
if (aim.IsSettled() && aim.settledCommandTicks >= 2)
{
// The view is settled now. Keep calling AimAtPositionEx while any
// cast is pending; input consumption is not projectile spawn.
}
}
commandTick orders command-side events. It does not by itself identify a shot, cast completion, or projectile-spawn frame.
AimAtBone#
Aims at a specific bone on an entity with spring smoothing. Convenience wrapper that resolves the bone position internally.
| Parameter | Type | Description |
|---|---|---|
entityIndex |
int |
Player array index |
boneId |
int |
Skeleton bone ID (see Bone constants) |
stiffness |
float |
Spring stiffness (same as AimAtPosition) |
Entity target = FindBestTargetInFov(100.f, Bone::Head, TargetFlags::Enemy);
if (target)
AimAtBone(target.Index(), Bone::Head, 50.f);
AimAtBoneEx#
bool AimAtBoneEx(
int entityIndex,
int boneId,
float stiffness,
float toleranceRad,
AimStepResultV1& out);
Bone-targeted equivalent of AimAtPositionEx. It is phase-agnostic, returns the same AimStepResultV1 telemetry, and must be called continuously while tracking, including through hero-specific cast/startup windows.
AimStepResultV1 aim{};
if (AimAtBoneEx(target.Index(), Bone::Head, 80.f, 0.01f, aim)
&& aim.IsSettled())
{
// Apply any additional geometric and weapon-state gates before firing.
}
AimResetSmoothing#
Resets the spring smoothing velocity to zero. Call this when switching targets to prevent the spring's momentum from the previous target carrying over and causing a snap.
if (newTarget != lastTarget)
{
AimResetSmoothing();
lastTarget = newTarget;
}
AimAtBone(newTarget.Index(), Bone::Head, 80.f);
AimHitsHitbox#
AimHitsHitbox is phase-agnostic and may be used from on_frame() or on_render().
Checks if the current aim direction passes through any hitbox on the given entity. Use this for fire gating — only fire when the crosshair is actually on the target. At 1.0, the host adds the local hero's bullet-radius padding so the check matches the engine's effective hit zone.
| Parameter | Type | Description |
|---|---|---|
entityIndex |
int |
Player array index |
hitboxScale |
float |
Hitbox radius multiplier before local hero bullet padding (1.0 = engine-effective, >1.0 = forgiving) |
| Returns | Description |
|---|---|
>= 0 |
BodySlot index of the deepest hit hitbox |
-1 |
No hitbox hit |
Entity target = FindBestTargetInFov(100.f, Bone::Head, TargetFlags::Enemy);
if (target)
{
AimAtBone(target.Index(), Bone::Head, 80.f);
int slot = AimHitsHitbox(target.Index());
if (slot == BodySlot::Head)
PressGameButton(GameButton::LMouse);
else
ReleaseGameButton(GameButton::LMouse);
}
AimHitTest#
bool AimHitTest(
int entityIndex,
float hitboxScale,
float safetyMargin,
float bulletPaddingMeters,
const Vector3& predictionOffset,
int bodySlotFilter,
AimHitResultV1& out);
// Convenience overload: scale = 1.0, margin = 0.04 m,
// local primary-fire padding, current pose, all body slots
bool AimHitTest(int entityIndex, AimHitResultV1& out,
float hitboxScale = 1.0f, float safetyMargin = 0.04f,
int bodySlotFilter = -1);
Returns detailed aim-ray geometry for the best candidate hitbox. This query is phase-agnostic. The function returning true means the query was evaluated; use out.HasHit() or out.CanFire() to inspect its result.
bodySlotFilter = -1 accepts all body slots. A non-negative BodySlot filters candidates before deepest-hit selection, which lets strict trigger logic request head-only or another specific region.
predictionOffset translates every hitbox endpoint before the ray test, matching the internal triggerbot's prediction/backtrack gate. Pass predictedPoint - currentPoint (the same world-space delta used by your aim solution). The convenience overload without this parameter tests the entity's current pose with a zero offset.
bulletPaddingMeters < 0 selects the local hero's primary-fire padding, matching the native triggerbot default. Pass 0.0f for melee and thrown actions, or the effective additive collision padding for a plugin-specific projectile, including any weapon/engine epsilon applied to its raw radius. This value is added directly to the scaled hitbox radius and cannot be canceled reliably with hitboxScale.
| Field | Description |
|---|---|
bodySlot |
BodySlot, or -1 when no hitbox qualifies |
hitboxIndex |
Entity hitbox-array index, or -1 |
commandTick |
Stable command tick bracketing the cached-hitbox/current-direction read, or 0 if the query crossed a boundary |
perpendicularDistance |
Shortest distance from the aim ray to the hitbox centerline |
scaledRadius |
Effective radius after hitbox scaling and weapon padding |
gap |
perpendicularDistance - scaledRadius; negative values are inside the hitbox |
hitPos |
Selected sphere center or closest capsule-axis test point |
surfacePoint |
Entry point where the aim ray crosses the selected hitbox surface |
hit |
Nonzero when the ray intersects the effective hitbox |
visible |
Nonzero when the tested path is visible |
fireReady |
Nonzero when the query tick is stable, visible, and gap <= -safetyMargin |
isCapsule |
Nonzero when the selected hitbox is a capsule |
AimHitResultV1 hit{};
Vector3 predictionOffset = target.PredictPosition(0.10f) - target.GetPosition();
if (AimHitTest(target.Index(), 1.0f, 0.04f, 0.0f, predictionOffset,
BodySlot::Head, hit)
&& hit.CanFire())
{
uint64_t requestId = PulseGameButtonTracked(GameButton::Skill2, 50);
// Track requestId with GetInputReceipt. InputConsumed is not proof that
// the weapon fired or that a projectile spawned.
}
fireReady is a geometric/visibility gate at one command tick. It does not confirm weapon readiness, input consumption, a shot, or projectile creation.
When combining it with AimAtPositionEx or AimAtBoneEx, fire only when both calls succeed, aim is settled, fireReady is set, and both results report the same nonzero commandTick. If the counter changes between the two queries, keep aiming and retry on the next update.