Burrowing in ACS
What a script can do with burrowing projectiles: ask whether there is a way through a wall, read which textures a burrow goes in and comes out by, end a burrow, and change the four burrow properties at runtime.
Availability
ZandroX only. Elsewhere the functions do nothing and return 0, and the properties read 0.
| Number | Function | Returns |
|---|---|---|
| 24090 | fua_BurrowProbe(int h, fixed distance [, fixed angle [, fixed pitch [, int surfaces]]]) |
the solid's thickness, or a code below |
| 24091 | fua_BurrowTexture(int h, int face) |
a texture name, "" for none |
| 24092 | fua_BurrowAbort(int h [, int how]) |
true when it ended a burrow |
| Property | Id | Meaning |
|---|---|---|
APROP_FUA_BurrowDistance |
57 | BurrowDistance, fixed point (96.0) |
APROP_FUA_BurrowEnterTime |
58 | BurrowEnterTime, tics |
APROP_FUA_BurrowExitTime |
59 | BurrowExitTime, tics |
APROP_FUA_BurrowCount |
60 | BurrowCount |
The functions take an actor handle. Neither fua.acs nor zt-bcc's
zcommon.bcs declares them yet, so a script declares them itself, after including either. With ACC:
special
-24090:fua_BurrowProbe(2,5),
-24091:fua_BurrowTexture(2),
-24092:fua_BurrowAbort(1,2);
With zt-bcc:
special
-24090:fua_BurrowProbe(int, fixed; fixed, fixed, int):fixed,
-24091:fua_BurrowTexture(int, int):str,
-24092:fua_BurrowAbort(int; int):bool;
And the constants this page uses, for either:
#define APROP_FUA_BurrowDistance 57
#define APROP_FUA_BurrowEnterTime 58
#define APROP_FUA_BurrowExitTime 59
#define APROP_FUA_BurrowCount 60
#define FUA_BURROW_WALLS 1
#define FUA_BURROW_FLOORS 2
#define FUA_BURROW_CEILINGS 4
#define FUA_BURROW_3DFLOORS 8
#define FUA_BURROW_ALL 15
#define FUA_BURROW_DEADEND -1.0
#define FUA_BURROW_REFUSED -2.0
#define FUA_BURROW_ENTRY 0
#define FUA_BURROW_EXIT 1
#define FUA_BURROW_DIE 0
#define FUA_BURROW_COMEOUT 1
The DECORATE expressions (BurrowPhase, BurrowDepth, BurrowSurface, BurrowExitX, BurrowExitY,
BurrowExitZ, BurrowsDone) read through fua_GetField, and the burrow flags through
CheckFlag and SetActorFlag by name ("CANBURROWWALLS").
fua_BurrowProbe
fixed fua_BurrowProbe(int h, fixed distance [, fixed angle [, fixed pitch [, int surfaces]]])
Moves the actor's box, as it stands, along angle and pitch (default: its own) and says what a burrow
would meet there. It works on any actor, so a player's ability or a monster's AI can ask "is there a way
through this wall?" before firing anything.
| Answer | Meaning |
|---|---|
| greater than 0 | a way through: the solid's thickness face to face, in map units |
0 |
nothing solid within distance |
FUA_BURROW_DEADEND (-1.0) |
solid with no way out within distance |
FUA_BURROW_REFUSED (-2.0) |
a face it may not burrow: a surface left out of surfaces, a burrow-proof line, the sky |
distancebounds both how far ahead the face may be and how thick the solid may be.0means the trace's cap of 4096.surfacesis any ofFUA_BURROW_WALLS(1),FUA_BURROW_FLOORS(2),FUA_BURROW_CEILINGS(4) andFUA_BURROW_3DFLOORS(8); the default is all four. Both faces count, as for a projectile.- The path is straight, and the box is the actor's own: a probe from a player asks whether a box the player's size would fit through, so a script asking on a projectile's behalf should probe from the projectile or a stand-in of its size.
- It changes nothing, so it runs on any machine against its own copy of the map.
// A drill gun that only fires where there's a way through within 96 units.
script "CanDrill" (void)
{
int t = fua_BurrowProbe( fua_GetActorHandle( 0 ), 96.0 );
if ( t == FUA_BURROW_DEADEND )
Print( s:"Too thick." );
SetResultValue( t > 0 );
}
Fire:
DRLG A 0 A_JumpIf(ACS_NamedExecuteWithResult("CanDrill") == 0, "Ready")
DRLG B 4 A_FireCustomMissile("Drill")
Goto Ready
fua_BurrowTexture
str fua_BurrowTexture(int h, int face)
The texture of the face the actor's last burrow went in by (FUA_BURROW_ENTRY, 0) or comes out by
(FUA_BURROW_EXIT, 1): the wall's texture where its box meets it, a floor's or ceiling's flat, or a 3D
floor's side, top or bottom. "" for none: never burrowed, a dead end's way out, or the outside of the
map.
The texture is known from the moment the burrow starts, so a Burrow state can call a script to choose
its debris:
script "DrillChips" (void)
{
str tex = StrLeft( fua_BurrowTexture( fua_GetActorHandle( 0 ), FUA_BURROW_ENTRY ), 4 );
SetResultValue( StrICmp( tex, "META" ) == 0 || StrICmp( tex, "SUPP" ) == 0 ); // 1 sparks, 0 rock
}
Burrow:
DRIL A 0 A_JumpIf(ACS_NamedExecuteWithResult("DrillChips") == 1, "Sparks")
DRIL A 2 A_SpawnItemEx("RockChip", -BurrowDepth, 0, 4, -2, frandom(-2, 2), 3)
Loop
Clients trace the faces themselves from the server's burrow, so a CLIENTSIDE script reads the same
names.
fua_BurrowAbort
bool fua_BurrowAbort(int h [, int how])
Ends a running burrow now.
how |
Does |
|---|---|
FUA_BURROW_DIE (0, default) |
it dies where it is, in its Burrow.DeadEnd state (else Death) |
FUA_BURROW_COMEOUT (1) |
it comes out at its way out at once and flies on, through its Burrow.Exit state if it has one |
A projectile told to come out from a dead end, or whose way out a door has closed since, dies instead. Returns false, doing nothing, when the actor isn't burrowing, and on a client for the server's projectile: only the machine that decides a burrow ends it, and the server tells every client.
The properties
SetActorProperty changes one projectile's property from then on: its next burrow uses it. A running
burrow keeps the path it was given. In a netgame the server's change reaches every client, joiners
included, so a client's copy of a bouncing burrower decides as the server's does:
// Overcharged: this shot digs through twice as much and grinds in slowly.
SetActorProperty( tid, APROP_FUA_BurrowDistance, 256.0 );
SetActorProperty( tid, APROP_FUA_BurrowEnterTime, 12 );
BurrowCount lowered to what it has already used, or below, spends it at once; raised, it gets more.
See also
- Burrowing and its flags, properties and states
- Actor handles · Actor fields