[Server] DP_QC_TRACEBOX
Moderator: InsideQC Admins
4 posts
• Page 1 of 1
[Server] DP_QC_TRACEBOX
Just a quicky to show how simple some ommisions can be...
Tracebox, that awesome builtin that lets you trace a box through the world instead of a single tiny line.
Internally the engine already supports all this stuff for monster movement etc.
tracebox has this QC prototype:
void(vector start, vector min, vector max, vector end, float nomonsters, entity forent) tracebox = #90;
Open up pr_cmds.c
Find PF_traceline.
Add the following function below it.
There's our new builtin. Note that the only differences from the regular traceline is the extra two parameters (inserted between start/end), which are passed to the SV_Move function. There are no other changes.
Now we need to add it to the list, which is also easy.
Find the definition of pr_builtin below, pretty much right at the bottom, its the array.
At the end, you should see PF_setspawnparms as the last entry. This particular builtin is actually #78.
After that entry, we need to add some padding, so that entry #90 is our builtin. There's a special dummy builtin that can be used for his purpose, imaginitively called PF_Fixme.
So add 11 lines of PF_Fixme, followed by a single PF_tracebox line.
Mods using your engine can now use tracebox, although they can't query support for it.
Tracebox, that awesome builtin that lets you trace a box through the world instead of a single tiny line.
Internally the engine already supports all this stuff for monster movement etc.
tracebox has this QC prototype:
void(vector start, vector min, vector max, vector end, float nomonsters, entity forent) tracebox = #90;
Open up pr_cmds.c
Find PF_traceline.
Add the following function below it.
- Code: Select all
void PF_tracebox (void)
{
float *v1, *v2, *mins, *maxs;
trace_t trace;
int nomonsters;
edict_t *ent;
v1 = G_VECTOR(OFS_PARM0);
mins = G_VECTOR(OFS_PARM1);
maxs = G_VECTOR(OFS_PARM2);
v2 = G_VECTOR(OFS_PARM3);
nomonsters = G_FLOAT(OFS_PARM4);
ent = G_EDICT(OFS_PARM5);
trace = SV_Move (v1, mins, maxs, v2, nomonsters, ent);
pr_global_struct->trace_allsolid = trace.allsolid;
pr_global_struct->trace_startsolid = trace.startsolid;
pr_global_struct->trace_fraction = trace.fraction;
pr_global_struct->trace_inwater = trace.inwater;
pr_global_struct->trace_inopen = trace.inopen;
VectorCopy (trace.endpos, pr_global_struct->trace_endpos);
VectorCopy (trace.plane.normal, pr_global_struct->trace_plane_normal);
pr_global_struct->trace_plane_dist = trace.plane.dist;
if (trace.ent)
pr_global_struct->trace_ent = EDICT_TO_PROG(trace.ent);
else
pr_global_struct->trace_ent = EDICT_TO_PROG(sv.edicts);
}
There's our new builtin. Note that the only differences from the regular traceline is the extra two parameters (inserted between start/end), which are passed to the SV_Move function. There are no other changes.
Now we need to add it to the list, which is also easy.
Find the definition of pr_builtin below, pretty much right at the bottom, its the array.
At the end, you should see PF_setspawnparms as the last entry. This particular builtin is actually #78.
After that entry, we need to add some padding, so that entry #90 is our builtin. There's a special dummy builtin that can be used for his purpose, imaginitively called PF_Fixme.
So add 11 lines of PF_Fixme, followed by a single PF_tracebox line.
Mods using your engine can now use tracebox, although they can't query support for it.
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
Does this built-in let a QuakeC coder check for a space allocation?
For example, to see if at x, y, z there is enough space for a Shambler to be spawned there?
For example, to see if at x, y, z there is enough space for a Shambler to be spawned there?
The night is young. How else can I annoy the world before sunsrise?
Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
-

Baker - Posts: 3666
- Joined: Tue Mar 14, 2006 5:15 am
if the mins/maxs match the shambler's size, yes.
traceboxing with the start and end points the same will work as a test to see if its empty. check the trace_startsolid as the return value in that case (fraction is generally 1 if startsolid is set, so meaningless).
alternatively droptofloor can permit you to test if its empty, if you want to avoid engine extensions.
as can walkmove, but note that walkmove touches triggers on success.
traceboxing with the start and end points the same will work as a test to see if its empty. check the trace_startsolid as the return value in that case (fraction is generally 1 if startsolid is set, so meaningless).
alternatively droptofloor can permit you to test if its empty, if you want to avoid engine extensions.
as can walkmove, but note that walkmove touches triggers on success.
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
Spike wrote:...but note that walkmove touches triggers on success.
Noted! I should stop suggesting that to people then.
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
- Sajt
- Posts: 1215
- Joined: Sat Oct 16, 2004 3:39 am
4 posts
• Page 1 of 1
Return to Programming Tutorials
Who is online
Users browsing this forum: No registered users and 1 guest