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);
}
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.