World and combat
Map traces, smokes, grenades and combat.
world
The map: visibility and bullet traces against the collision mesh, wallbang damage, smokes, grenade arcs and the minimap. Read-only.
Everything here needs Allow game scripting in Scripts > Security (on by default).
world.ready() -> booleanTrue once the map's collision mesh is loaded (world_physics; props, doors, players and smoke do not block).
boolean
if not world.ready() then return endworld.visible(from, to) -> boolean | nil, stringNo map triangle between the two points (the last 0.1 u at the target and the first 1 u at the start ignored). nil without a map; one world ray: nil, "ray budget" past 256 a logic pass.
| Name | Type | Description |
|---|---|---|
from | vec3 | |
to | vec3 |
boolean | nil, string
if world.visible(me.eye_pos, p.eye_pos) then endworld.trace(from, to) -> table | nil, stringThe first surface entered: {hit, pos, normal, dist, fraction 0..1, surface = material name}; hit = false (pos = to, fraction 1) when clear. nil without a map; one world ray.
| Name | Type | Description |
|---|---|---|
from | vec3 | |
to | vec3 |
table | nil, string
local t = world.trace(cam.origin, cam.origin + fwd * 4096)world.penetration(from, to, target [, hitgroup]) -> table | nil, stringThe local weapon's bullet through the map to target (the native wallbang model, after the target's armour): {ok, damage, walls, thickness, reason}. nil without a map; nil, "penetration budget" past 32 a logic pass.
| Name | Type | Default | Description |
|---|---|---|---|
from | vec3 | ||
to | vec3 | ||
target | Player | ||
hitgroupoptional | integer | 1 |
table | nil, string
local r = world.penetration(me.eye_pos, p:hitbox(1).a, p, hitgroup.head)world.smokes() -> table[]Active smokes as the world visuals model them: {center, radii = vec3, density 0..1}.
table[]
for _, s in ipairs(world.smokes()) do endworld.through_smoke(from, to) -> boolean | nil, stringThe segment crosses an active smoke (the check aim and trigger use). One world ray.
| Name | Type | Description |
|---|---|---|
from | vec3 | |
to | vec3 |
boolean | nil, string
if world.through_smoke(me.eye_pos, p.eye_pos) then endworld.predict_grenade(origin, velocity, kind [, remaining]) -> table | nil, stringA grenade arc as the native prediction simulates it (64 tick, bounces off the map mesh; free flight without one): {points = vec3[] per tick, bounces = vec3[], end_pos, duration seconds}. kind: "he", "flash", "smoke", "molotov", "incendiary", "decoy"; remaining = fuse seconds left (a grenade in flight). nil, "prediction budget" past 4 a logic pass.
| Name | Type | Description |
|---|---|---|
origin | vec3 | |
velocity | vec3 | |
kind | string | |
remainingoptional | number |
table | nil, string
local arc = world.predict_grenade(g.origin, g.velocity, g.kind, g.remaining)world.overview() -> table | nilCS2's minimap for the map: {map, x, y = world of the image's top-left, scale = world units per pixel of the 1024 px image, has_lower, split_z, image, lower_image = draw.image ids}. Pixel (u, v) = ((wx - x) / scale, (y - wy) / scale). nil while loading (the first call starts it) or without one. The images count against the 4 images from memory a script holds.
table | nil
local ov = world.overview() if ov then draw.image(ov.image, 0, 0, 256, 256) endEverything here needs Allow game scripting in Scripts > Security (on by default).
combat.aim_state() -> table | nilWhat the native aim decided this logic pass: {active (key held and allowed to aim), target = controller index | nil, hitbox, hitgroup, point, fov, damage, penetrated, sent (mouse moved), blocked = reason or ""}.
table | nil
local a = combat.aim_state() if a and a.target then endcombat.trigger_state() -> table | nilWhat the native trigger decided this logic pass: {state ("key up", "holding", "fired", ...), target = controller index | nil, hitgroup, damage, fire_in_ms, hit_chance, fired, penetrated, reject, presses}.
table | nil
local t = combat.trigger_state()