Skip to content

Core#

Defined in Core.hpp. Logging, time, input, screen info, and world-to-screen projection.

Log#

void Log(const char* msg);

Prints a message to the Xenon console. This is the only way to output text for debugging since printf is not available.

Log("Plugin loaded!");
Log("Something happened");

Note

There is no format string support. To log numbers, convert them to a string manually (see FAQ).

LogDebug#

void LogDebug(const char* msg);

Prints a debug-level message to the Xenon console.

LogWarning#

void LogWarning(const char* msg);

Prints a warning-level message to the Xenon console.

LogError#

void LogError(const char* msg);

Prints an error-level message to the Xenon console.


IsIngame#

bool IsIngame();

Returns true if the local player is currently in a match.

if (!IsIngame()) return;

GetMapId#

uint32_t GetMapId();

Returns the current map identifier. The value is game-internal; useful for map-specific logic.

uint32_t map = GetMapId();

GetSensitivity#

float GetSensitivity();

Returns the player's in-game mouse sensitivity setting.

float sens = GetSensitivity();

GetCurrentHero#

uint64_t GetCurrentHero();

Returns the hero pool ID of the local player's current hero. Compare with HeroId constants.

if (GetCurrentHero() == HeroId::Widowmaker)
    Log("Playing Widowmaker");

GetTime#

float GetTime();

Returns the current time in seconds since the application started. Useful for animations and timers.

float t = GetTime();

IsKeyDown#

bool IsKeyDown(int vkey);

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#

bool IsKeyPressed(int vkey);

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)
if (IsKeyPressed(VK::F1))
    g_enabled = !g_enabled;

IsKeyReleased#

bool IsKeyReleased(int vkey);

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)
if (IsKeyReleased(VK::LButton))
    Log("Left mouse button released");

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:

void on_menu() {
    aimKey.Render("Aim Key");
    toggleKey.Render("Toggle ESP");
}

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#

Vector2 ScreenSize();

Returns the current screen resolution as a Vector2.

Vector2 size = ScreenSize();
// size.x = width, size.y = height

ScreenCenter#

Vector2 ScreenCenter();

Returns the center of the screen. Equivalent to ScreenSize() * 0.5f.

Vector2 center = ScreenCenter();
Draw::Circle(center, 10.f, Color::White());

WorldToScreen#

Converts a 3D world position to 2D screen coordinates.

Overload 1: Bool return#

bool WorldToScreen(const Vector3& worldPos, Vector2& screenPos);

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#

Vector2 WorldToScreen(const Vector3& worldPos);

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#

bool WorldToScreenUnclamped(const Vector3& worldPos, Vector2& screenPos);

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#

Returns the camera's world-space position, extracted from the view-projection matrix.

Overload 1: Bool return#

bool GetCameraPosition(Vector3& out);

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#

Vector3 GetCameraPosition();

Returns the camera position directly. Returns {0, 0, 0} if unavailable.

Vector3 cam = GetCameraPosition();
float dist = (enemy.GetPosition() - cam).Length();

GetCameraForward#

Returns the camera's normalized forward direction, derived from the view-projection matrix.

Overload 1: Bool return#

bool GetCameraForward(Vector3& out);

Returns true if the forward direction is available. The result is written to out.

Overload 2: Direct return#

Vector3 GetCameraForward();

Returns the forward direction directly. Returns {0, 0, 0} if unavailable.

Vector3 fwd = GetCameraForward();
Vector3 toEnemy = (enemy.GetPosition() - GetCameraPosition()).Normalized();
float dot = fwd.Dot(toEnemy); // 1.0 = directly ahead, 0.0 = perpendicular

GetViewMatrix#

bool GetViewMatrix(float* out16);

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#

float GetUltCharge();

Returns the local player's ultimate charge percentage (0–100).

float charge = GetUltCharge();

IsUltReady#

bool IsUltReady();

Returns true if ultimate charge is at 100%.

IsUltActive#

bool IsUltActive();

Returns true if the ultimate ability is currently active.

IsSkill1Active#

bool IsSkill1Active();

Returns true if Skill 1 (Shift) is currently active.

IsSkill2Active#

bool IsSkill2Active();

Returns true if Skill 2 (E) is currently active.

IsSkill3Active#

bool IsSkill3Active();

Returns true if Skill 3 is currently active.

GetHeroState#

uint32_t 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

    bool IsOnCooldown() const;  // enabled && current > 0
    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.

GetSkill1Cooldown#

SkillCooldown GetSkill1Cooldown();

Returns the cooldown state for Skill 1 (Shift) of the local player. Hero-specific — the cooldown variable is looked up per-hero.

GetSkill2Cooldown#

SkillCooldown GetSkill2Cooldown();

Returns the cooldown state for Skill 2 (E) of the local player.

GetSkill3Cooldown#

SkillCooldown GetSkill3Cooldown();

Returns the cooldown state for Skill 3 (Ultimate) of the local player.

GetUltCooldown#

SkillCooldown GetUltCooldown();

Returns the cooldown state for the Ultimate ability of the local player.

auto cd = GetSkill1Cooldown();
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#

SkillCooldown GetSkill1Duration();

Returns the duration state for Skill 1 (Shift) of the local player. Only populated while the ability is active.

GetSkill2Duration#

SkillCooldown GetSkill2Duration();

Returns the duration state for Skill 2 (E) of the local player.

GetSkill3Duration#

SkillCooldown 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#

float GetRailgunCharge();

Returns Sojourn's railgun charge level. Only meaningful when playing Sojourn.

GetIllariCharge#

float GetIllariCharge();

Returns Illari's solar rifle charge level. Only meaningful when playing Illari.

GetHanzoCharge#

float GetHanzoCharge();

Returns Hanzo's bow draw charge level. Only meaningful when playing Hanzo.

GetWidowCharge#

float GetWidowCharge();

Returns Widowmaker's sniper scope charge level. Only meaningful when playing Widowmaker.

GetLookupSkill#

float GetLookupSkill(uint16_t lookupId);

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 view direction. These use the same mechanism as the internal aimbot: writing the direction vector directly into game memory.

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#

void AimSetDirection(const Vector3& dir);

Sets the view 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#

Vector3 AimGetDirection();
bool AimGetDirection(Vector3& out);

Returns the local player's current view direction vector.

Vector3 fwd = AimGetDirection();

AimSetAngles#

void AimSetAngles(float pitch, float yaw);

Sets the view angles in radians (instant, no smoothing). 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
Vector3 angles = CalcAngle(GetCameraPosition(), enemy.GetHeadPos());
AimSetAngles(angles.x, angles.z);  // .x = pitch, .z = yaw

AimGetAngles#

Vector2 AimGetAngles();
bool AimGetAngles(float& pitch, float& yaw);

Returns the current view angles as (pitch, yaw) in radians.

Vector2 angles = AimGetAngles();  // .x = pitch, .y = yaw
float pitch, yaw;
AimGetAngles(pitch, yaw);

AimAtPosition#

void AimAtPosition(const Vector3& target, float stiffness = 0.f);

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);

AimAtBone#

void AimAtBone(int entityIndex, int boneId, float stiffness = 0.f);

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);

AimResetSmoothing#

void 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#

int AimHitsHitbox(int entityIndex, float hitboxScale = 1.0f);

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.

Parameter Type Description
entityIndex int Player array index
hitboxScale float Hitbox radius multiplier (1.0 = exact, >1.0 = forgiving)
Returns Description
>= 0 BodySlot index of the first 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);
}