UZDoom's ACS functions
Availability
ZandroX behaviour. These are UZDoom's (and GZDoom's) ACS functions and actor properties, at UZDoom's numbers, so a script compiled for UZDoom calls them unchanged. Zandronum 3.3 has none of them: there, each function returns 0 and each property reads 0.
| Function | Number | Returns |
|---|---|---|
GetMaxInventory(tid, item) |
93 | the most of item the actor can carry; "Health" gives its maximum health |
SetSectorDamage(tag, amount [, damagetype [, interval [, leakiness]]]) |
94 | nothing; players in the tagged sectors take amount of damagetype damage |
SpawnParticle(color [, fullbright [, lifetime [, size [, x, y, z [, xvel, yvel, zvel [, accelx, accely, accelz [, startalpha [, fadestep [, endsize]]]]]]]]]) |
96 | nothing; one particle, as UZDoom's (see below) |
SetSectorTerrain(tag, plane, terrain) |
95 | nothing; the tagged sectors' floor (0) or ceiling (1) takes the named TERRAIN, a name no TERRAIN defines giving back the flat's |
CheckProximity(tid, class, distance [, count [, flags [, ptr]]]) |
98 | whether count actors of class stand within distance, by CPXF_ flags |
CheckActorState(tid, state [, exact]) |
99 | whether the actor's class has the state |
CheckClass(class) |
200 | whether an actor class of that name exists |
DamageActor(tid, ptr, inflictor, ptr, amount, damagetype) |
201 | the damage dealt, or -1 when none was |
SetActorFlag(tid, flag, on) |
202 | how many actors have the flag ("SHOOTABLE", "Inventory.UNDROPPABLE"), set or cleared as A_ChangeFlag does |
SetTranslation(tid, name) |
203 | 1; the actors take the named translation (TRNSLATE, Ice, Player1..), "" their class's own |
GetActorFloorTerrain(tid) |
205 | the name of the TERRAIN under the actor |
StrArg(string) |
206 | a name an action special takes, such as a named script for ACS_Execute |
Floor(x), Round(x), Ceil(x) |
207-209 | a fixed-point value made whole |
GetSectorHealth(tag, part) |
212 | the first tagged sector's floor (0), ceiling (1) or controlled 3D floor (2) health, its health group's where it has one; 0 is not destructible |
GetLineHealth(lineid) |
213 | the first line with that id's health, its health group's where it has one |
GetNetID(tid, index [, ptr]) |
215 | the actor's net id, the same on a server and its clients, or 0 |
SetActivatorByNetID(netid [, ptr]) |
216 | 1 after making that actor the activator, else 0 |
GetLineX(lineid, along, offset), GetLineY(...) |
300, 301 | a point along the line (0 to 1.0), moved offset units off its front side |
SetSectorGlow(tag, plane, r, g, b, height) |
400 | nothing; the tagged sectors' floor (0) or ceiling (1) glows that colour up to height units off it, an r of -1 turning the glow off and black (0, 0, 0) giving back the flat's GLDEFS glow |
SetFogDensity(tag, density) |
401 | nothing; the tagged sectors fog at half density (held to 0 to 255) whatever their fog's colour, black included, beating the level's and the outside fog's densities; 0 gives back the level's rules, and DoomLegacy light mode (4) ignores it, as in UZDoom |
| Actor property | Number | |
|---|---|---|
APROP_MaxStepHeight |
44 | fixed; how high the actor steps up |
APROP_MaxDropOffHeight |
45 | fixed; how far a monster walks down |
APROP_DamageType |
46 | string; the damage type the actor deals |
APROP_SoundClass |
47 | string; the sound class a player's sounds come from, a script's own over its skin's and class's, "" giving them back |
APROP_FriendlySeeBlocks |
48 | how many blockmap blocks a friendly monster looks for enemies across; its class's (10) until set |
APROP_WaterDepth |
49 | fixed, read only; how deep in water the actor stands |
A sector's terrain sets its friction, splashes, footclip and floor damage, and what GetActorFloorTerrain
reads, as the flat's TERRAIN does. A UDMF map gives a sector its own with UZDoom's floorterrain and
ceilingterrain keys, which a map restart (ResetMap) gives back after a script's change.
CreateTranslation takes UZDoom's two newer range forms, which zt-bcc and ACC compile to p-codes 383 and 384, and TRNSLATE
and DECORATE's Translation take them too:
#library "fuaembr"
#import "zcommon.bcs"
script "Embers" ( void ) {
// Colourise: each entry's brightness times the colour.
CreateTranslation( 1, 16:48 = #[ 255, 128, 0 ] );
// Tint: each entry 40% of the way to the colour.
CreateTranslation( 2, 16:48 = @40[ 0, 64, 255 ] );
Thing_SetTranslation( 0, 1 );
Log( s: "embers lit" );
}
Unlike the other range forms, these two leave the last index (48 here) unchanged, as UZDoom does. A range naming an index outside 0 to 255 changes nothing and prints a warning. In a netgame the server sends each range to its clients, and to a player who joins later.
SpawnParticle takes its arguments as UZDoom's does, swap included: fadestep sets how fast the particle grows
(fadestep/255 units a tic; the default, -1, shrinks it slowly) and endsize how fast it fades: below 0 it fades over
its lifetime, 0 never, and anything above ends it at once. size is in whole units, not fixed point. In a netgame a
server's script sends each particle to the players near it (up to 64 a tic each); a CLIENTSIDE script's particles
stay on its machine.
#library "fuaspark"
#import "zcommon.bcs"
script "Spark" ( void ) {
// A fullbright orange spark 32 units above the activator, rising, that never fades and grows a unit a tic.
SpawnParticle( 0xFF8000, true, 70, 4, GetActorX( 0 ), GetActorY( 0 ), GetActorZ( 0 ) + 32.0,
0, 0, 1.0, 0, 0, 0, 255, 255, 0 );
Log( s: "spark" );
}
QuakeEx takes UZDoom's arguments past the wave speeds: falloff (12, whole units: past it the shake fades to none at the
tremor radius), highpoint (13, the tic a scaled quake peaks at), rollIntensity and rollWave (14 and 15, fixed: a roll
of the view in degrees, and its waves a second under QF_WAVE), damageMultiplier (16, default 1.0), thrustMultiplier
(17, default 0.5) and damage (18, each hit's damage; 0 rolls the dice as before). Its flags gain QF_3D,
QF_GROUNDONLY, QF_AFFECTACTORS (hit every actor in the damage radius, not only players), QF_SHAKEONLY and
QF_DAMAGEFALLOFF, and DECORATE's A_QuakeEx takes the same. A quake's push is now half its intensity, as in Hexen and
UZDoom; earlier builds threw a player in the damage radius across the room. In a netgame each client's view shakes and
rolls as the server's.
#library "fuaquake"
#import "zcommon.bcs"
script "Tremor" ( void ) {
// Two seconds of waves on the activator, fading past 128 units of a 640-unit tremor, rolling the view, hurting nothing.
QuakeEx( 0, 2, 2, 0, 70, 0, 640, "", QF_WAVE | QF_SHAKEONLY, 1.0, 1.0, 1.0, 128, 0, 3.0, 1.5 );
Log( s: "tremor" );
}
GetPlayerInfo(player, PLAYERINFO_FVIEWBOB) (10) reads the player's fviewbob, UZDoom's userinfo setting: with it
off a flying player neither bobs up and down nor sways its view, as in UZDoom.
ZDaemon's SetTeamScore(team, score) (19621), which earlier builds declared without code, sets the score
GetTeamScore reads: frags in team deathmatch, wins in team LMS, points otherwise, announced as
ChangeTeamScore does. It returns 1 when the score changed, 0 when it didn't or the team doesn't exist.
An action special numbered 256 or more is called by a p-code that carries its whole number. UZDoom numbers it
381, which here is Zandronum's GetTeamPlayerCount, so ForkUnderA runs it as 385: build a library calling such
a special with zt-bcc's -target fua. ACC has no such target, so a library calling a special past 255 needs
zt-bcc. A special used for its value is 382 everywhere. Specials past 255 this build doesn't have yet do nothing
and return 0.
Usage
zt-bcc's zcommon.bcs declares all of them, naming the rounding functions ZDoom_Floor, ZDoom_Round
and ZDoom_Ceil. For ACC, fua.acs declares them all too, the rounding functions under both those
names and ACC's Floor, Round and Ceil (Compiling ACS). Builds of zt-bcc older than its UZDoom declarations lack GetNetID and
SetActivatorByNetID, which a script built with one declares itself:
special -215:GetNetID(int, int; int): int;
special -216:SetActivatorByNetID(int; int): bool;
// The barrel nearest the player becomes its target, then takes 10 fire damage from it.
if (CheckProximity(0, "ExplosiveBarrel", 300.0, 1, CPXF_SETTARGET | CPXF_CLOSEST))
DamageActor(0, AAPTR_TARGET, 0, AAPTR_DEFAULT, 10, "Fire");
SetActorProperty(0, APROP_MaxStepHeight, 40.0);
In a netgame:
- A step or drop-off height a server script sets reaches every client, and players who join later, since a client moves its own player and walking monsters itself.
- A damage type stays on the server, which deals all damage, and so does
APROP_FriendlySeeBlocks, since only the server's monsters look for enemies. - A translation a server script sets reaches every client and players who join later; a clientside
script's
SetTranslationchanges that client's copy alone. - Team scores a server script sets reach every client.
- A sound class a server script gives a player reaches every client, which pick that player's sounds
themselves, and players who join later; it stays through death and respawn, as UZDoom's does, and beats a
player's
cl_skinschoice, since the mod asked for it. - A flag a server script sets reaches every client, as
A_ChangeFlag's do, with the map's kill, item and secret totals; a clientside script'sSetActorFlagchanges that client's copy alone and leaves the totals. - A player's
fviewbobreaches the server with its other userinfo, so the server moves a flying player's pawn as that player's own setting says, and the player's client predicts it the same. - Every machine works out
APROP_WaterDepthfrom its own world. - A net id names the same actor on the server and on each client, so a script can pass one to a clientside script.
Examples
Each example is a whole library: compile it with zt-bcc, add it to LOADACS and run its scripts with
pukename.
The closest barrel within 200 units becomes the player's target and takes fire damage from it:
#library "fuaburn"
#import "zcommon.bcs"
script "BurnNearest" ( void ) {
if ( CheckProximity( 0, "ExplosiveBarrel", 200.0, 1, CPXF_SETTARGET | CPXF_CLOSEST ) ) {
int dealt = DamageActor( 0, AAPTR_TARGET, 0, AAPTR_DEFAULT, 5, "Fire" );
Log( s: "burned for ", d: dealt );
}
else {
Log( s: "nothing to burn" );
}
}
Footsteps by what the player stands on, from TERRAIN:
#library "fuastep"
#import "zcommon.bcs"
script "Footstep" ( void ) {
str terrain = GetActorFloorTerrain( 0 );
if ( StrCmp( terrain, "Water" ) == 0 ) {
Log( s: "splash" );
}
else {
Log( s: "step on ", s: terrain );
}
}
A server script hands an actor to every client's clientside script by its net id, the one name for an actor every machine shares:
#library "fuaflash"
#import "zcommon.bcs"
script "FlashActor" ( int tid ) {
ACS_NamedExecuteAlways( "FlashOnClients", 0, GetNetID( tid, 0 ) );
}
script "FlashOnClients" ( int netid ) clientside {
if ( SetActivatorByNetID( netid ) ) {
// The actor is this script's activator now: spawn a client-only effect at it, change its look.
Log( s: "flashing a ", s: GetActorClass( 0 ) );
}
}
The burning barrel, for ACC, with fua.acs included in place of zcommon.acs:
#library "accburn"
#include "fua.acs"
script "AccBurnNearest" (void)
{
if (CheckProximity(0, "ExplosiveBarrel", 200.0, 1, CPXF_SETTARGET | CPXF_CLOSEST))
Log(s: "burned for ", d: DamageActor(0, AAPTR_TARGET, 0, AAPTR_DEFAULT, 5, "Fire"), s: ", floor ", d: Floor(2.75) >> 16);
else
Log(s: "nothing to burn");
}
The older functions
ZandroX behaviour. The functions and p-codes Zandronum already had answer as UZDoom's too. Zandronum 3.3 answers the old way: the rows below say what changed.
| Call | As UZDoom |
|---|---|
FixedDiv(a, b) |
a quotient past 32 bits, or a zero divisor, gives 0x7FFFFFFF or -0x80000000 by sign, not a wrapped value |
Sin, Cos, VectorAngle |
exact maths: Sin(1) is 6, not the table's 25 |
GetPolyobjX/Y of a missing polyobject |
0x7FFFFFFF |
GetLineRowOffset() |
the mid offset truncated toward zero (-1.5 gives -1) |
SetLineActivation(lineid, activation [, repeat]) |
repeat above 0 makes the line repeatable, 0 one-shot |
SetActorRoll(tid, angle) |
every actor with the tid |
GetPlayerInfo(p, PLAYERINFO_NEVERSWITCH) |
1 only for switchonpickup 0 |
Spawn, SpawnSpot, SpawnForced, ... |
0 for a monster while sv_nomonsters (or the level) has none, and for a class that is no actor's; SpawnSpotFacing faces the spot's exact angle |
DropItem, SetActorTeleFog, MorphActor |
only actor classes; MorphActor/UnmorphActor with a tid change every actor holding it |
TakeInventory(item, n) |
"armor" in any case is the basic armour; taking the last of an item that keeps when out (ammo, armour) leaves it at 0, and Hexen armour loses its slots |
ClearInventory() |
leaves undroppable items and those with +INVENTORY.UNCLEARABLE whole; ammo and armour stay at 0 |
GetArmorInfo(ARMORINFO_ACTUALSAVEAMOUNT) (5) |
the save amount of the armour last put on |
PlayerArmorPoints, GetArmorInfo |
a BasicArmor subclass counts |
GetActorProperty(tid, APROP_SpawnHealth) |
a player class without its own Player.MaxHealth gives Dehacked's maximum |
GetActorProperty(tid, APROP_Damage) |
a damage expression evaluated, as Damage (7) gives 7 |
GetActorProperty(tid, APROP_ViewHeight) |
the player's own pawn's; a pawn with no player gives 0 |
GetUserVariable(tid, name) |
any field by name, "health" among them |
PrintName(PRINTNAME_NEXTLEVEL) (-4), PrintName(PRINTNAME_NEXTSECRET) (-5) |
the next and secret maps; map names come upper-cased |
PrintBold |
the bold colour with GAMEINFO's correctprintbold or a Hexen-style MAPINFO |
HudMessage with HUDMSG_LOG |
logged in any text colour; CR_ICE (22), CR_FIRE, CR_SAPPHIRE, CR_TEAL (25) exist |
SetHUDClipRect(x, y, w, h [, wrap [, aspect]]) |
aspect 0 keeps the rectangle at 4:3 |
SpawnDecal(tid, decal, flags, ...) |
SDF_FIXED_ZOFF (4) and SDF_FIXED_DISTANCE (8) read the offset and distance as fixed point |
PlaySound(tid, sound, channel, volume, loop, atten, local) |
local plays it unplaced for whoever views from the actor alone |
StopSound(tid, channel), SoundVolume(tid, channel, v) |
a channel of -1 means every channel |
SectorDamage(tag, amount, type, protection, flags) |
DAMAGE_NO_ARMOR (16) skips armour |
Warp(tid, x, y, z, angle, flags [, state [, exact [, heightoffset [, radiusoffset [, pitch]]]]]) |
the angle is an ACS angle that turns the offset; WARPF_TOFLOOR takes the floor under the new spot; WARPF_INTERPOLATE keeps the move interpolated (without it the actor snaps); WARPF_COPYVELOCITY, WARPF_COPYPITCH, WARPF_BOB work; a named state is entered without exact |
GetActorFloorTerrain, GetActorLightLevel, CheckActorFloorTexture |
on a 3D floor: its model sector's terrain, its light layer, the floor within a step of the feet |
compat_scriptwait and compat_noacsargcheck (MAPINFO, compatibility.txt) work as in UZDoom.
Best practices
- Deal damage from server scripts. In a clientside script
DamageActoronly hurts actors that exist on that client alone (and returns -1 for the rest), since the server holds every other actor's health. - Pass net ids to clientside scripts, not tids or handles: a tid can name several actors, and each
machine has its own handle table.
GetNetID( tid, 0 )on the server,SetActivatorByNetIDon the client. - Prefer
CheckProximityto a loop over tids for "is there one near": it walks the blockmap around the actor rather than every actor with a tid. - Round only what you show.
ZDoom_Roundand the others drop the fraction a position or speed keeps in its low 16 bits, so movement built on rounded values drifts.
Differences from UZDoom
Ceilof a whole number returns it unchanged. UZDoom's adds one, soCeil(2.0)is 3.0 there.DamageActoron a tid no actor holds returns -1. UZDoom crashes.- The default terrain's name is
Solid; UZDoom spells itSOLID. SetSectorTerrainreaches an actor at once. UZDoom's actors keep the terrain they last moved onto, so one standing still there reads, takes floor damage and steps by the old terrain until it moves.SetSectorDamagesets a sector's own damage beside what its special does, so a nukage floor given 5 more hurts by both; UZDoom's replaces the special's. Only the UDMFdamageamountkey takes the special's place, as in UZDoom.- A friendly monster's search covers 128 blockmap blocks at most, whatever
APROP_FriendlySeeBlocksor its class says, so a script can't make every look scan a whole map; the property reads back what was set. SetTranslationknows noRainPillar1..8, which need tables this engine doesn't have.- A floor or ceiling mark (a decal) refuses liquid by the plane's terrain, but the renderer's screen-space marks still go by the flat's.
SetSkyScrollSpeed(3, ...)does nothing: this engine draws no mist sky.APROP_SoundClasson an actor that is no player reads"player"; UZDoom stops the game.PlayMovieplays the movie; UZDoom's always returns -1.- Hexen's own maps print their English text; UZDoom can show its translations of them.
PlayActorSound(tid, SOUND_Push)plays nothing yet: actors have noPushSoundproperty here.