Game

Effects

A temporary effect is something the game draws for a moment and forgets: a beam, a shockwave, an explosion, sparks, a light, blood. Each effect is a function of effects, its options are the effect's arguments, and the second argument says who sees it.

const 
shock
=
server
.
precache
("sprites/shockwave.spr");
const
trail
=
server
.
precache
("sprites/laserbeam.spr");
function blast(
here
: number[]) {
effects
.
beamCylinder
({
at
:
here
,
radius
: 385,
sprite
:
shock
,
life
: 0.4,
width
: 60,
color
: "#0096ff",
alpha
: 200 }, {
near
:
here
});
effects
.
sparks
({
at
:
here
});
} function thrown(
grenade
: Entity,
thrower
: Player) {
effects
.
beamFollow
({
entity
:
grenade
,
sprite
:
trail
,
life
: 1,
width
: 5,
color
: "#0096ff" }, {
to
:
thrower
});
}

Sprites and models

An effect draws a sprite or a model the game has precached. server.precache returns it as a Resource, and that is what an effect's sprite or model takes:

const 
shock
=
server
.
precache
("sprites/shockwave.spr"); // at the top level of the file
server
.
addEventListener
("precache", () => {
const
gibs
=
server
.
precache
("models/glassgibs.mdl"); // or in the "precache" event
});

A file asked for at the top level of the plugin is precached when the map loads; in the "precache" event it is precached at once. A plugin reloaded in the middle of a map runs its top level again: the file is not precached a second time, and the Resource finds the index the map gave it.

resource.path is the path it was given, resource.index the index a native takes (0 while it is not precached).

Only while the map loads
The game precaches a file only while the map loads. Asked for later - in a command, in "init" - a file no plugin precached is said in the console, and an effect that draws it is not sent, with a line of its own.

Who sees it

Second argumentWho sees the effect
left outeveryone
{ near: point }the players who can see that point
{ to: player }that player alone

An effect is sent the way the game sends its own: a player whose connection drops it simply misses it.

Units

  • Times - life - are in seconds: life: 0.4.
  • A colour is CSS hex, "#0096ff" or "#09f"; alpha is the brightness, 0 to 255.
  • Points, sizes and velocities are the world's units, as entity.origin is.
  • A few sizes are the effect's own numbers, 0 to 255, which each option's description explains: a beam's width (10 is one unit), its noise (100 is one unit), a sprite's scale (10 is its own size).
  • palette is a colour of the game's palette, 0 to 255: blood red is 247.

The effects

Required options first; the rest have defaults.

FunctionWhat it drawsOptions
beamPointsa beam between two pointsstart, end, sprite, life, width; color, alpha, noise, frame, frameRate, speed
beamEntityPointa beam from an entity to a pointstart (an entity), end, and the beam's options
beamEntitiesa beam between two entitiesstart, end (entities), and the beam's options
beamRinga ring of beam, two entities its diameteras beamEntities
beamCylindera cylinder growing to radius - a shockwaveat, radius, and the beam's options
beamDiska disk growing to radiusas beamCylinder
beamTorusa ring facing the viewer, growing to radiusas beamCylinder
beamFollowa trail behind a moving entityentity, sprite, life, width; color, alpha
beamSpritea beam with a sprite at its endstart, end, sprite, endSprite
lightninga bolt between two pointsstart, end, sprite, life, width; noise
killBeamstakes away an entity's beamsentity
explosionan explosion: sprite, light, particles, soundat, sprite; scale, frameRate, additive, lights, sound, particles
tarExplosiona burst of dark particlesat
particleExplosiona burst of particles in palette coloursat; palette, colors
smokea puff of smokeat, sprite; scale, frameRate
implosiontracers flying into a pointat, radius, count, life
gunshota bullet's hitat
sparkssparks falling from a pointat
armorRicocheta bullet off armourat; scale
lavaSplash, teleporta splash of particlesat
tracera tracer from one point to anotherstart, end
showLinea line of particles for 30 secondsstart, end
streakSplasha shower of tracers in a directionat, direction, count, speed; randomness, palette
spritea glowing sprite that plays onceat, sprite; scale, alpha
glowSpritea glowing sprite that staysat, sprite, life; scale, alpha
spriteTrailglowing sprites flying off a linestart, end, sprite, count, life; scale, speed, randomness
spriteSpraya spray of spritesat, velocity, sprite, count, speed; noise
largeFunnela funnel of spritesat, sprite; reverse
fizzbubbles inside a brush entityentity, sprite, density
bubbles, bubbleTrailbubbles rising from a box, from a linestart, end, height, sprite, count, speed
dynamicLighta light on the world around a pointat, radius, life; color, decay
entityLighta light on an entity, lighting entities onlyentity, at, radius, life; color, decay
linea coloured linestart, end, life; color
boxa box's edgesmins, maxs, life; color
blood, bloodStreama spray, a stream of bloodat, direction, speed; palette
bloodSpriteblood as the game draws a hitat, spray, drop; scale, palette
modela model thrown that bounces - a shellat, velocity, model, life; yaw, sound
explodeModelpieces of a model in every directionat, speed, model, count, life
breakModelpieces out of a box - something brokenat, size, velocity, model, count, life; randomness, material, smoke, transparent
projectilea model flying like a nailat, velocity, model, life; owner
spraya shower of models or spritesat, direction, model, count, speed; noise, renderMode
playerSpritessprites out of a player's bodyplayer, sprite, count; variance
particleBursta burst of particles in one colourat, radius, life; palette
fireFielda square of fire spritesat, radius, sprite, count, life; rise, blend, loop, flat
playerAttachmenta model above a player, going where he goesplayer, model, life; offset
killPlayerAttachmentstakes away a player's attached modelsplayer

The beam's options are sprite, life and width, then color (white), alpha (255), noise (0, straight), frame and frameRate (the sprite's animation) and speed (how fast the sprite scrolls along it). Each option's own description - in the editor - gives its range and default.

A text on the screen is player.showHud. A decal - a bullet hole, a spray on a wall - is not an effect yet: send it with the natives, message_begin and write_* (limitations).