Sticking in ACS
What a script can do with sticky projectiles and stuck actors: stick an actor to
another and let it go, ask what holds it and how, find everything stuck to an actor, and change
StickHostAlpha at runtime.
Availability
ZandroX only. Elsewhere the functions do nothing and return 0, and the property reads 0.
| Number | Function | Returns |
|---|---|---|
| 24100 | fua_Stick(int h, int host [, int flags [, fixed x, fixed y, fixed z]]) |
true when it stuck |
| 24101 | fua_Unstick(int h) |
true when it was stuck |
| 24102 | fua_StickHost(int h) |
the handle of the actor it is stuck to, 0 for none or for a wall, floor or ceiling |
| 24103 | fua_StickInfo(int h, int what) |
the answer below |
| Property | Id | Meaning |
|---|---|---|
APROP_FUA_StickHostAlpha |
61 | StickHostAlpha, fixed point, 0.0 to 1.0 |
The functions take actor handles. Neither fua.acs nor zt-bcc's
zcommon.bcs declares them yet, so a script declares them itself, after including either. With ACC:
special
-24100:fua_Stick(2,6),
-24101:fua_Unstick(1),
-24102:fua_StickHost(1),
-24103:fua_StickInfo(2);
With zt-bcc:
special
-24100:fua_Stick(int, int; int, fixed, fixed, fixed):bool,
-24101:fua_Unstick(int):bool,
-24102:fua_StickHost(int):int,
-24103:fua_StickInfo(int, int):int;
And the constants this page uses, for either:
#define APROP_FUA_StickHostAlpha 61
#define FUA_STICK_OFFSET 1
#define FUA_STICK_RELATIVE 2
#define FUA_STICK_TURNS 4
#define FUA_STICK_STATES 8
#define FUA_STUCK_NONE 0
#define FUA_STUCK_ACTOR 1
#define FUA_STUCK_WALL 2
#define FUA_STUCK_FLOOR 3
#define FUA_STUCK_CEILING 4
#define FUA_STICKINFO_STUCKTO 0
#define FUA_STICKINFO_TICS 1
#define FUA_STICKINFO_LINE 2
#define FUA_STICKINFO_SECTOR 3
#define FUA_STICKINFO_OFFSETX 4
#define FUA_STICKINFO_OFFSETY 5
#define FUA_STICKINFO_OFFSETZ 6
#define FUA_STICKINFO_COUNT 7
#define FUA_STICKINFO_POLYOBJ 8
#define FQ_FUA_STUCKTO 64
The sticky flags read and change through CheckFlag and SetActorFlag by name ("STICKY",
"STICKTOWALLS").
fua_Stick
bool fua_Stick(int h, int host [, int flags [, fixed x, fixed y, fixed z]])
Sticks actor h to actor host, as A_fua_Stick does, with the same
flags: FUA_STICK_OFFSET puts it at (x, y, z) from the host first, FUA_STICK_RELATIVE reads them
as forward, right and up of the host, FUA_STICK_TURNS turns it with the host, and FUA_STICK_STATES enters
its Stick.Actor state. Without FUA_STICK_OFFSET it sticks where it is.
- Any actor but a player's body can be stuck. It is refused when either handle names no actor, or
hostis stuck, through any chain of hosts, toh. An actor already stuck moves to the new host. - Only the machine that decides the actor sticks it: the server, or a client for its own client-side actor. The server tells its clients.
fua_Unstick
bool fua_Unstick(int h)
Lets actor h go where it is, at rest, as A_fua_Unstick does. Only where the
actor is decided, as for fua_Stick.
fua_StickHost
int fua_StickHost(int h)
The handle of the actor h is stuck to, or 0 when it is stuck to nothing or to a wall, floor or ceiling. Each
machine answers from its own copy.
fua_StickInfo
int fua_StickInfo(int h, int what)
what |
Answer |
|---|---|
FUA_STICKINFO_STUCKTO |
what holds it: FUA_STUCK_NONE, _ACTOR, _WALL, _FLOOR or _CEILING |
FUA_STICKINFO_TICS |
how many tics it has been stuck |
FUA_STICKINFO_LINE |
the line it stuck to, by number, -1 for none |
FUA_STICKINFO_SECTOR |
the sector whose floor or ceiling carries it, -1 for none; for a 3D floor, its control sector |
FUA_STICKINFO_OFFSETX, _OFFSETY, _OFFSETZ |
its offset, fixed point, as StuckOffsetX and the rest |
FUA_STICKINFO_COUNT |
how many actors are stuck to h |
FUA_STICKINFO_POLYOBJ |
the polyobject that carries it, -1 for none |
Finding what is stuck to an actor
The query filter FQ_FUA_STUCKTO (64) keeps the actors stuck to a handle's actor:
int q = fua_QueryCreate();
fua_QueryFilter(q, FQ_FUA_STUCKTO, fua_GetActorHandle(0));
int n = fua_FindActors(q, GetActorX(0), GetActorY(0), GetActorZ(0), 256.0);
for (int i = 0; i < n; i++)
fua_Unstick(fua_FoundActor(q, i));
fua_QueryFree(q);
This shakes off everything stuck to the activator.
Examples
A pickup that sticks a marker 64 over whoever takes it, turning with them, faint on their own screen:
script "MarkCarrier" (void)
{
int marker = UniqueTID();
SpawnForced("CarrierMarker", GetActorX(0), GetActorY(0), GetActorZ(0), marker, 0);
int h = fua_GetActorHandle(marker);
fua_Stick(h, fua_GetActorHandle(0), FUA_STICK_OFFSET | FUA_STICK_TURNS, 0, 0, 64.0);
SetActorProperty(marker, APROP_FUA_StickHostAlpha, 0.25);
}