2001-02-19 21:15:25 +00:00
|
|
|
/*
|
2001-02-26 20:52:14 +00:00
|
|
|
pr->pr_cmds.c
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
@description@
|
|
|
|
|
|
|
|
Copyright (C) 1996-1997 Id Software, Inc.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
$Id$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
2001-05-09 05:41:34 +00:00
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
# include <string.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_STRINGS_H
|
|
|
|
# include <strings.h>
|
|
|
|
#endif
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/console.h"
|
2001-05-31 05:33:13 +00:00
|
|
|
#include "compat.h"
|
2001-05-31 03:41:35 +00:00
|
|
|
#include "QF/cvar.h"
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/sys.h"
|
|
|
|
#include "QF/cmd.h"
|
|
|
|
#include "QF/va.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
#include "host.h"
|
|
|
|
#include "world.h"
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/msg.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
#include "server.h"
|
2001-03-03 08:31:58 +00:00
|
|
|
#include "sv_progs.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-09 06:05:43 +00:00
|
|
|
#define RETURN_EDICT(p, e) ((p)->pr_globals[OFS_RETURN].integer_var = EDICT_TO_PROG(p, e))
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
BUILT-IN FUNCTIONS
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_error
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-09 06:05:43 +00:00
|
|
|
This is a TERMINAL error, which will kill off the entire server.
|
|
|
|
Dumps self.
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-09 06:05:43 +00:00
|
|
|
error(value)
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_error (progs_t *pr)
|
2001-02-26 06:48:02 +00:00
|
|
|
{
|
2001-07-15 07:04:17 +00:00
|
|
|
const char *s;
|
2001-02-26 06:48:02 +00:00
|
|
|
edict_t *ed;
|
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
s = PF_VarString (pr, 0);
|
2001-02-26 06:48:02 +00:00
|
|
|
Con_Printf ("======SERVER ERROR in %s:\n%s\n",
|
2001-03-04 05:27:29 +00:00
|
|
|
PR_GetString (&sv_pr_state, pr->pr_xfunction->s_name), s);
|
2001-03-03 08:31:58 +00:00
|
|
|
ed = PROG_TO_EDICT (pr, *sv_globals.self);
|
2001-02-26 20:52:14 +00:00
|
|
|
ED_Print (pr, ed);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
Host_Error ("Program error");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_objerror
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-09 06:05:43 +00:00
|
|
|
Dumps out self, then an error message. The program is aborted and self is
|
|
|
|
removed, but the level can continue.
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-09 06:05:43 +00:00
|
|
|
objerror(value)
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_objerror (progs_t *pr)
|
2001-02-26 06:48:02 +00:00
|
|
|
{
|
2001-08-09 06:05:43 +00:00
|
|
|
const char *s;
|
2001-02-26 06:48:02 +00:00
|
|
|
edict_t *ed;
|
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
s = PF_VarString (pr, 0);
|
2001-02-26 06:48:02 +00:00
|
|
|
Con_Printf ("======OBJECT ERROR in %s:\n%s\n",
|
2001-03-04 05:27:29 +00:00
|
|
|
PR_GetString (&sv_pr_state, pr->pr_xfunction->s_name), s);
|
2001-03-03 08:31:58 +00:00
|
|
|
ed = PROG_TO_EDICT (pr, *sv_globals.self);
|
2001-02-26 20:52:14 +00:00
|
|
|
ED_Print (pr, ed);
|
|
|
|
ED_Free (pr, ed);
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
Host_Error ("Program error");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_makevectors
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-09 06:05:43 +00:00
|
|
|
Writes new values for v_forward, v_up, and v_right based on angles
|
|
|
|
makevectors(vector)
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_makevectors (progs_t *pr)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-03-03 08:31:58 +00:00
|
|
|
AngleVectors (G_VECTOR (pr, OFS_PARM0), *sv_globals.v_forward,
|
|
|
|
*sv_globals.v_right, *sv_globals.v_up);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_setorigin
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-09 06:05:43 +00:00
|
|
|
This is the only valid way to move an object without using the physics of the world (setting velocity and waiting). Directly changing origin will not set internal links correctly, so clipping would be messed up. This should be called when an object is spawned, and then only if it is teleported.
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-09 06:05:43 +00:00
|
|
|
setorigin (entity, origin)
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_setorigin (progs_t *pr)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
edict_t *e;
|
|
|
|
float *org;
|
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
e = G_EDICT (pr, OFS_PARM0);
|
|
|
|
org = G_VECTOR (pr, OFS_PARM1);
|
2001-08-08 20:28:53 +00:00
|
|
|
VectorCopy (org, SVvector (e, origin));
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_LinkEdict (e, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
SetMinMaxSize (progs_t *pr, edict_t *e, float *min, float *max,
|
2001-02-26 20:52:14 +00:00
|
|
|
qboolean rotate)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
float *angles;
|
|
|
|
vec3_t rmin, rmax;
|
|
|
|
float bounds[2][3];
|
|
|
|
float xvector[2], yvector[2];
|
|
|
|
float a;
|
|
|
|
vec3_t base, transformed;
|
|
|
|
int i, j, k, l;
|
|
|
|
|
|
|
|
for (i = 0; i < 3; i++)
|
2001-02-19 21:15:25 +00:00
|
|
|
if (min[i] > max[i])
|
2001-02-26 20:52:14 +00:00
|
|
|
PR_RunError (pr, "backwards mins/maxs");
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
rotate = false; // FIXME: implement rotation properly
|
|
|
|
//
|
2001-02-26 20:52:14 +00:00
|
|
|
//
|
2001-02-26 06:48:02 +00:00
|
|
|
// again
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
if (!rotate) {
|
2001-02-19 21:15:25 +00:00
|
|
|
VectorCopy (min, rmin);
|
|
|
|
VectorCopy (max, rmax);
|
2001-02-26 06:48:02 +00:00
|
|
|
} else {
|
|
|
|
// find min / max for rotations
|
2001-08-08 20:28:53 +00:00
|
|
|
angles = SVvector (e, angles);
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
a = angles[1] / 180 * M_PI;
|
|
|
|
|
|
|
|
xvector[0] = cos (a);
|
|
|
|
xvector[1] = sin (a);
|
|
|
|
yvector[0] = -sin (a);
|
|
|
|
yvector[1] = cos (a);
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
VectorCopy (min, bounds[0]);
|
|
|
|
VectorCopy (max, bounds[1]);
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
rmin[0] = rmin[1] = rmin[2] = 9999;
|
|
|
|
rmax[0] = rmax[1] = rmax[2] = -9999;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
for (i = 0; i <= 1; i++) {
|
2001-02-19 21:15:25 +00:00
|
|
|
base[0] = bounds[i][0];
|
2001-02-26 06:48:02 +00:00
|
|
|
for (j = 0; j <= 1; j++) {
|
2001-02-19 21:15:25 +00:00
|
|
|
base[1] = bounds[j][1];
|
2001-02-26 06:48:02 +00:00
|
|
|
for (k = 0; k <= 1; k++) {
|
2001-02-19 21:15:25 +00:00
|
|
|
base[2] = bounds[k][2];
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
// transform the point
|
|
|
|
transformed[0] =
|
|
|
|
xvector[0] * base[0] + yvector[0] * base[1];
|
|
|
|
transformed[1] =
|
|
|
|
xvector[1] * base[0] + yvector[1] * base[1];
|
2001-02-19 21:15:25 +00:00
|
|
|
transformed[2] = base[2];
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
for (l = 0; l < 3; l++) {
|
2001-02-19 21:15:25 +00:00
|
|
|
if (transformed[l] < rmin[l])
|
|
|
|
rmin[l] = transformed[l];
|
|
|
|
if (transformed[l] > rmax[l])
|
|
|
|
rmax[l] = transformed[l];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
// set derived values
|
2001-08-08 20:28:53 +00:00
|
|
|
VectorCopy (rmin, SVvector (e, mins));
|
|
|
|
VectorCopy (rmax, SVvector (e, maxs));
|
|
|
|
VectorSubtract (max, min, SVvector (e, size));
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_LinkEdict (e, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_setsize
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-09 06:05:43 +00:00
|
|
|
the size box is rotated by the current angle
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-09 06:05:43 +00:00
|
|
|
setsize (entity, minvector, maxvector)
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_setsize (progs_t *pr)
|
2001-02-26 06:48:02 +00:00
|
|
|
{
|
|
|
|
edict_t *e;
|
|
|
|
float *min, *max;
|
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
e = G_EDICT (pr, OFS_PARM0);
|
|
|
|
min = G_VECTOR (pr, OFS_PARM1);
|
|
|
|
max = G_VECTOR (pr, OFS_PARM2);
|
|
|
|
SetMinMaxSize (pr, e, min, max, false);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_setmodel
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-09 06:05:43 +00:00
|
|
|
setmodel(entity, model)
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_setmodel (progs_t *pr)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
edict_t *e;
|
2001-08-09 06:05:43 +00:00
|
|
|
const char *m, **check;
|
2001-02-26 06:48:02 +00:00
|
|
|
model_t *mod;
|
|
|
|
int i;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
e = G_EDICT (pr, OFS_PARM0);
|
|
|
|
m = G_STRING (pr, OFS_PARM1);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// check to see if model was properly precached
|
2001-02-26 06:48:02 +00:00
|
|
|
for (i = 0, check = sv.model_precache; *check; i++, check++)
|
|
|
|
if (!strcmp (*check, m))
|
2001-02-19 21:15:25 +00:00
|
|
|
break;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
if (!*check)
|
2001-02-26 20:52:14 +00:00
|
|
|
PR_RunError (pr, "no precache: %s\n", m);
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-08 20:28:53 +00:00
|
|
|
SVstring (e, model) = PR_SetString (pr, m);
|
|
|
|
SVfloat (e, modelindex) = i; // SV_ModelIndex (m);
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-08-08 20:28:53 +00:00
|
|
|
mod = sv.models[(int) SVfloat (e, modelindex)]; // Mod_ForName (m, true);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (mod)
|
2001-02-26 20:52:14 +00:00
|
|
|
SetMinMaxSize (pr, e, mod->mins, mod->maxs, true);
|
2001-02-19 21:15:25 +00:00
|
|
|
else
|
2001-02-26 20:52:14 +00:00
|
|
|
SetMinMaxSize (pr, e, vec3_origin, vec3_origin, true);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_bprint
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-09 06:05:43 +00:00
|
|
|
broadcast print to everyone on server
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-09 06:05:43 +00:00
|
|
|
bprint(value)
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_bprint (progs_t *pr)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-07-15 07:04:17 +00:00
|
|
|
const char *s;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
s = PF_VarString (pr, 0);
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_BroadcastPrintf ("%s", s);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_sprint
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-09 06:05:43 +00:00
|
|
|
single print to a specific client
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-09 06:05:43 +00:00
|
|
|
sprint(clientent, value)
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_sprint (progs_t *pr)
|
2001-02-26 06:48:02 +00:00
|
|
|
{
|
2001-07-15 07:04:17 +00:00
|
|
|
const char *s;
|
2001-02-26 06:48:02 +00:00
|
|
|
client_t *client;
|
|
|
|
int entnum;
|
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
entnum = G_EDICTNUM (pr, OFS_PARM0);
|
|
|
|
s = PF_VarString (pr, 1);
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
if (entnum < 1 || entnum > svs.maxclients) {
|
2001-02-19 21:15:25 +00:00
|
|
|
Con_Printf ("tried to sprint to a non-client\n");
|
|
|
|
return;
|
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
client = &svs.clients[entnum - 1];
|
|
|
|
|
|
|
|
MSG_WriteChar (&client->message, svc_print);
|
|
|
|
MSG_WriteString (&client->message, s);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_centerprint
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-09 06:05:43 +00:00
|
|
|
single print to a specific client
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-09 06:05:43 +00:00
|
|
|
centerprint(clientent, value)
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_centerprint (progs_t *pr)
|
2001-02-26 06:48:02 +00:00
|
|
|
{
|
2001-07-15 07:04:17 +00:00
|
|
|
const char *s;
|
2001-02-26 06:48:02 +00:00
|
|
|
client_t *client;
|
|
|
|
int entnum;
|
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
entnum = G_EDICTNUM (pr, OFS_PARM0);
|
|
|
|
s = PF_VarString (pr, 1);
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
if (entnum < 1 || entnum > svs.maxclients) {
|
2001-02-19 21:15:25 +00:00
|
|
|
Con_Printf ("tried to sprint to a non-client\n");
|
|
|
|
return;
|
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
client = &svs.clients[entnum - 1];
|
|
|
|
|
|
|
|
MSG_WriteChar (&client->message, svc_centerprint);
|
|
|
|
MSG_WriteString (&client->message, s);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_particle
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-09 06:05:43 +00:00
|
|
|
particle(origin, color, count)
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_particle (progs_t *pr)
|
2001-02-26 06:48:02 +00:00
|
|
|
{
|
|
|
|
float *org, *dir;
|
|
|
|
float color;
|
|
|
|
float count;
|
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
org = G_VECTOR (pr, OFS_PARM0);
|
|
|
|
dir = G_VECTOR (pr, OFS_PARM1);
|
|
|
|
color = G_FLOAT (pr, OFS_PARM2);
|
|
|
|
count = G_FLOAT (pr, OFS_PARM3);
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_StartParticle (org, dir, color, count);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_ambientsound
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_ambientsound (progs_t *pr)
|
2001-02-26 06:48:02 +00:00
|
|
|
{
|
2001-07-15 07:04:17 +00:00
|
|
|
const char **check;
|
|
|
|
const char *samp;
|
2001-02-26 06:48:02 +00:00
|
|
|
float *pos;
|
|
|
|
float vol, attenuation;
|
|
|
|
int i, soundnum;
|
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
pos = G_VECTOR (pr, OFS_PARM0);
|
|
|
|
samp = G_STRING (pr, OFS_PARM1);
|
|
|
|
vol = G_FLOAT (pr, OFS_PARM2);
|
|
|
|
attenuation = G_FLOAT (pr, OFS_PARM3);
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
// check to see if samp was properly precached
|
2001-02-26 06:48:02 +00:00
|
|
|
for (soundnum = 0, check = sv.sound_precache; *check; check++, soundnum++)
|
|
|
|
if (!strcmp (*check, samp))
|
2001-02-19 21:15:25 +00:00
|
|
|
break;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
if (!*check) {
|
2001-02-19 21:15:25 +00:00
|
|
|
Con_Printf ("no precache: %s\n", samp);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// add an svc_spawnambient command to the level signon packet
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
MSG_WriteByte (&sv.signon, svc_spawnstaticsound);
|
|
|
|
for (i = 0; i < 3; i++)
|
|
|
|
MSG_WriteCoord (&sv.signon, pos[i]);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
MSG_WriteByte (&sv.signon, soundnum);
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
MSG_WriteByte (&sv.signon, vol * 255);
|
|
|
|
MSG_WriteByte (&sv.signon, attenuation * 64);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_sound
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-09 06:05:43 +00:00
|
|
|
Each entity can have eight independant sound sources, like voice,
|
|
|
|
weapon, feet, etc.
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-09 06:05:43 +00:00
|
|
|
Channel 0 is an auto-allocate channel, the others override anything
|
|
|
|
already running on that entity/channel pair.
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-09 06:05:43 +00:00
|
|
|
An attenuation of 0 will play full volume everywhere in the level.
|
|
|
|
Larger attenuations will drop off.
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_sound (progs_t *pr)
|
2001-02-26 06:48:02 +00:00
|
|
|
{
|
2001-07-15 07:04:17 +00:00
|
|
|
const char *sample;
|
2001-02-26 06:48:02 +00:00
|
|
|
int channel;
|
|
|
|
edict_t *entity;
|
|
|
|
int volume;
|
|
|
|
float attenuation;
|
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
entity = G_EDICT (pr, OFS_PARM0);
|
|
|
|
channel = G_FLOAT (pr, OFS_PARM1);
|
|
|
|
sample = G_STRING (pr, OFS_PARM2);
|
|
|
|
volume = G_FLOAT (pr, OFS_PARM3) * 255;
|
|
|
|
attenuation = G_FLOAT (pr, OFS_PARM4);
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
if (volume < 0 || volume > 255)
|
|
|
|
Sys_Error ("SV_StartSound: volume = %i", volume);
|
|
|
|
|
|
|
|
if (attenuation < 0 || attenuation > 4)
|
|
|
|
Sys_Error ("SV_StartSound: attenuation = %f", attenuation);
|
|
|
|
|
|
|
|
if (channel < 0 || channel > 7)
|
|
|
|
Sys_Error ("SV_StartSound: channel = %i", channel);
|
|
|
|
|
|
|
|
SV_StartSound (entity, channel, sample, volume, attenuation);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_traceline
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-09 06:05:43 +00:00
|
|
|
Used for use tracing and shot targeting
|
|
|
|
Traces are blocked by bbox and exact bsp entityes, and also slide box entities
|
|
|
|
if the tryents flag is set.
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-09 06:05:43 +00:00
|
|
|
traceline (vector1, vector2, tryents)
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_traceline (progs_t *pr)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
float *v1, *v2;
|
|
|
|
trace_t trace;
|
|
|
|
int nomonsters;
|
|
|
|
edict_t *ent;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
v1 = G_VECTOR (pr, OFS_PARM0);
|
|
|
|
v2 = G_VECTOR (pr, OFS_PARM1);
|
|
|
|
nomonsters = G_FLOAT (pr, OFS_PARM2);
|
|
|
|
ent = G_EDICT (pr, OFS_PARM3);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
trace = SV_Move (v1, vec3_origin, vec3_origin, v2, nomonsters, ent);
|
|
|
|
|
2001-03-03 08:31:58 +00:00
|
|
|
*sv_globals.trace_allsolid = trace.allsolid;
|
|
|
|
*sv_globals.trace_startsolid = trace.startsolid;
|
|
|
|
*sv_globals.trace_fraction = trace.fraction;
|
|
|
|
*sv_globals.trace_inwater = trace.inwater;
|
|
|
|
*sv_globals.trace_inopen = trace.inopen;
|
|
|
|
VectorCopy (trace.endpos, *sv_globals.trace_endpos);
|
|
|
|
VectorCopy (trace.plane.normal, *sv_globals.trace_plane_normal);
|
|
|
|
*sv_globals.trace_plane_dist = trace.plane.dist;
|
2001-02-19 21:15:25 +00:00
|
|
|
if (trace.ent)
|
2001-03-03 08:31:58 +00:00
|
|
|
*sv_globals.trace_ent = EDICT_TO_PROG (pr, trace.ent);
|
2001-02-19 21:15:25 +00:00
|
|
|
else
|
2001-03-03 08:31:58 +00:00
|
|
|
*sv_globals.trace_ent = EDICT_TO_PROG (pr, sv.edicts);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef QUAKE2
|
|
|
|
extern trace_t SV_Trace_Toss (edict_t *ent, edict_t *ignore);
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_TraceToss (progs_t *pr)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
trace_t trace;
|
|
|
|
edict_t *ent;
|
|
|
|
edict_t *ignore;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
ent = G_EDICT (pr, OFS_PARM0);
|
|
|
|
ignore = G_EDICT (pr, OFS_PARM1);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
trace = SV_Trace_Toss (ent, ignore);
|
|
|
|
|
2001-03-03 08:31:58 +00:00
|
|
|
*sv_globals.trace_allsolid = trace.allsolid;
|
|
|
|
*sv_globals.trace_startsolid = trace.startsolid;
|
|
|
|
*sv_globals.trace_fraction = trace.fraction;
|
|
|
|
*sv_globals.trace_inwater = trace.inwater;
|
|
|
|
*sv_globals.trace_inopen = trace.inopen;
|
|
|
|
VectorCopy (trace.endpos, *sv_globals.trace_endpos);
|
|
|
|
VectorCopy (trace.plane.normal, *sv_globals.trace_plane_normal);
|
|
|
|
*sv_globals.trace_plane_dist = trace.plane.dist;
|
2001-02-19 21:15:25 +00:00
|
|
|
if (trace.ent)
|
2001-03-03 08:31:58 +00:00
|
|
|
*sv_globals.trace_ent = EDICT_TO_PROG (pr, trace.ent);
|
2001-02-19 21:15:25 +00:00
|
|
|
else
|
2001-03-03 08:31:58 +00:00
|
|
|
*sv_globals.trace_ent = EDICT_TO_PROG (pr, sv.edicts);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_checkpos
|
|
|
|
|
|
|
|
Returns true if the given entity can move to the given position from it's
|
|
|
|
current position by walking or rolling.
|
|
|
|
FIXME: make work...
|
|
|
|
scalar checkpos (entity, vector)
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_checkpos (progs_t *pr)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
byte checkpvs[MAX_MAP_LEAFS / 8];
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
int
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_newcheckclient (progs_t *pr, int check)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
int i;
|
|
|
|
byte *pvs;
|
|
|
|
edict_t *ent;
|
|
|
|
mleaf_t *leaf;
|
|
|
|
vec3_t org;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// cycle to the next one
|
|
|
|
|
|
|
|
if (check < 1)
|
|
|
|
check = 1;
|
|
|
|
if (check > svs.maxclients)
|
|
|
|
check = svs.maxclients;
|
|
|
|
|
|
|
|
if (check == svs.maxclients)
|
|
|
|
i = 1;
|
|
|
|
else
|
|
|
|
i = check + 1;
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
for (;; i++) {
|
|
|
|
if (i == svs.maxclients + 1)
|
2001-02-19 21:15:25 +00:00
|
|
|
i = 1;
|
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
ent = EDICT_NUM (pr, i);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (i == check)
|
2001-02-26 06:48:02 +00:00
|
|
|
break; // didn't find anything else
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (ent->free)
|
|
|
|
continue;
|
2001-08-08 20:28:53 +00:00
|
|
|
if (SVfloat (ent, health) <= 0)
|
2001-02-19 21:15:25 +00:00
|
|
|
continue;
|
2001-08-08 20:28:53 +00:00
|
|
|
if ((int) SVfloat (ent, flags) & FL_NOTARGET)
|
2001-02-19 21:15:25 +00:00
|
|
|
continue;
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
// anything that is a client, or has a client as an enemy
|
2001-02-19 21:15:25 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// get the PVS for the entity
|
2001-08-08 20:28:53 +00:00
|
|
|
VectorAdd (SVvector (ent, origin), SVvector (ent, view_ofs), org);
|
2001-02-19 21:15:25 +00:00
|
|
|
leaf = Mod_PointInLeaf (org, sv.worldmodel);
|
|
|
|
pvs = Mod_LeafPVS (leaf, sv.worldmodel);
|
2001-02-26 06:48:02 +00:00
|
|
|
memcpy (checkpvs, pvs, (sv.worldmodel->numleafs + 7) >> 3);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_checkclient
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-09 06:05:43 +00:00
|
|
|
Returns a client (or object that has a client enemy) that would be a
|
|
|
|
valid target.
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-09 06:05:43 +00:00
|
|
|
If there are more than one valid options, they are cycled each frame
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-09 06:05:43 +00:00
|
|
|
If (self.origin + self.viewofs) is not in the PVS of the current target,
|
|
|
|
it is not returned at all.
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-09 06:05:43 +00:00
|
|
|
name checkclient ()
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
|
|
|
#define MAX_CHECK 16
|
2001-02-26 06:48:02 +00:00
|
|
|
int c_invis, c_notvis;
|
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_checkclient (progs_t *pr)
|
2001-02-26 06:48:02 +00:00
|
|
|
{
|
|
|
|
edict_t *ent, *self;
|
|
|
|
mleaf_t *leaf;
|
|
|
|
int l;
|
|
|
|
vec3_t view;
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
// find a new check if on a new frame
|
2001-02-26 06:48:02 +00:00
|
|
|
if (sv.time - sv.lastchecktime >= 0.1) {
|
2001-02-26 20:52:14 +00:00
|
|
|
sv.lastcheck = PF_newcheckclient (pr, sv.lastcheck);
|
2001-02-19 21:15:25 +00:00
|
|
|
sv.lastchecktime = sv.time;
|
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
// return check if it might be visible
|
2001-02-26 20:52:14 +00:00
|
|
|
ent = EDICT_NUM (pr, sv.lastcheck);
|
2001-08-08 20:28:53 +00:00
|
|
|
if (ent->free || SVfloat (ent, health) <= 0) {
|
2001-02-26 20:52:14 +00:00
|
|
|
RETURN_EDICT (pr, sv.edicts);
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
// if current entity can't possibly see the check entity, return 0
|
2001-03-03 08:31:58 +00:00
|
|
|
self = PROG_TO_EDICT (pr, *sv_globals.self);
|
2001-08-08 20:28:53 +00:00
|
|
|
VectorAdd (SVvector (self, origin), SVvector (self, view_ofs), view);
|
2001-02-19 21:15:25 +00:00
|
|
|
leaf = Mod_PointInLeaf (view, sv.worldmodel);
|
|
|
|
l = (leaf - sv.worldmodel->leafs) - 1;
|
2001-02-26 06:48:02 +00:00
|
|
|
if ((l < 0) || !(checkpvs[l >> 3] & (1 << (l & 7)))) {
|
|
|
|
c_notvis++;
|
2001-02-26 20:52:14 +00:00
|
|
|
RETURN_EDICT (pr, sv.edicts);
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
// might be able to see it
|
2001-02-26 06:48:02 +00:00
|
|
|
c_invis++;
|
2001-02-26 20:52:14 +00:00
|
|
|
RETURN_EDICT (pr, ent);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_stuffcmd
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-09 06:05:43 +00:00
|
|
|
Sends text over to the client's execution buffer
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-09 06:05:43 +00:00
|
|
|
stuffcmd (clientent, value)
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_stuffcmd (progs_t *pr)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
int entnum;
|
2001-07-15 07:04:17 +00:00
|
|
|
const char *str;
|
2001-02-26 06:48:02 +00:00
|
|
|
client_t *old;
|
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
entnum = G_EDICTNUM (pr, OFS_PARM0);
|
2001-02-19 21:15:25 +00:00
|
|
|
if (entnum < 1 || entnum > svs.maxclients)
|
2001-02-26 20:52:14 +00:00
|
|
|
PR_RunError (pr, "Parm 0 not a client");
|
|
|
|
str = G_STRING (pr, OFS_PARM1);
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
old = host_client;
|
2001-02-26 06:48:02 +00:00
|
|
|
host_client = &svs.clients[entnum - 1];
|
2001-02-19 21:15:25 +00:00
|
|
|
Host_ClientCommands ("%s", str);
|
|
|
|
host_client = old;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_localcmd
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-09 06:05:43 +00:00
|
|
|
Sends text over to the client's execution buffer
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-09 06:05:43 +00:00
|
|
|
localcmd (string)
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_localcmd (progs_t *pr)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-07-15 07:04:17 +00:00
|
|
|
const char *str;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
str = G_STRING (pr, OFS_PARM0);
|
2001-02-19 21:15:25 +00:00
|
|
|
Cbuf_AddText (str);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_findradius
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-09 06:05:43 +00:00
|
|
|
Returns a chain of entities that have origins within a spherical area
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-09 06:05:43 +00:00
|
|
|
findradius (origin, radius)
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_findradius (progs_t *pr)
|
2001-02-26 06:48:02 +00:00
|
|
|
{
|
|
|
|
edict_t *ent, *chain;
|
|
|
|
float rad;
|
|
|
|
float *org;
|
|
|
|
vec3_t eorg;
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
chain = (edict_t *) sv.edicts;
|
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
org = G_VECTOR (pr, OFS_PARM0);
|
|
|
|
rad = G_FLOAT (pr, OFS_PARM1);
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
ent = NEXT_EDICT (pr, sv.edicts);
|
|
|
|
for (i = 1; i < sv.num_edicts; i++, ent = NEXT_EDICT (pr, ent)) {
|
2001-02-19 21:15:25 +00:00
|
|
|
if (ent->free)
|
|
|
|
continue;
|
2001-08-08 20:28:53 +00:00
|
|
|
if (SVfloat (ent, solid) == SOLID_NOT)
|
2001-02-19 21:15:25 +00:00
|
|
|
continue;
|
2001-02-26 06:48:02 +00:00
|
|
|
for (j = 0; j < 3; j++)
|
|
|
|
eorg[j] =
|
2001-08-08 20:28:53 +00:00
|
|
|
org[j] - (SVvector (ent, origin)[j] +
|
|
|
|
(SVvector (ent, mins)[j] + SVvector (ent, maxs)[j]) * 0.5);
|
2001-02-26 06:48:02 +00:00
|
|
|
if (Length (eorg) > rad)
|
2001-02-19 21:15:25 +00:00
|
|
|
continue;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-08-08 20:28:53 +00:00
|
|
|
SVentity (ent, chain) = EDICT_TO_PROG (pr, chain);
|
2001-02-19 21:15:25 +00:00
|
|
|
chain = ent;
|
|
|
|
}
|
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
RETURN_EDICT (pr, chain);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef QUAKE2
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_etos (progs_t *pr)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
snprintf (pr_string_temp, sizeof (pr_string_temp), "entity %i",
|
2001-02-26 20:52:14 +00:00
|
|
|
G_EDICTNUM (pr, OFS_PARM0));
|
2001-03-04 05:27:29 +00:00
|
|
|
G_INT (pr, OFS_RETURN) = PR_SetString (pr, pr_string_temp);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_Spawn (progs_t *pr)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
edict_t *ed;
|
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
ed = ED_Alloc (pr);
|
|
|
|
RETURN_EDICT (pr, ed);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_Remove (progs_t *pr)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
edict_t *ed;
|
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
ed = G_EDICT (pr, OFS_PARM0);
|
|
|
|
ED_Free (pr, ed);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PR_CheckEmptyString (progs_t *pr, const char *s)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
|
|
|
if (s[0] <= ' ')
|
2001-02-26 20:52:14 +00:00
|
|
|
PR_RunError (pr, "Bad string");
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_precache_file (progs_t *pr)
|
2001-02-26 06:48:02 +00:00
|
|
|
{ // precache_file is only used to copy
|
|
|
|
//
|
2001-02-26 20:52:14 +00:00
|
|
|
//
|
2001-02-26 06:48:02 +00:00
|
|
|
// files with qcc, it does nothing
|
2001-02-26 20:52:14 +00:00
|
|
|
G_INT (pr, OFS_RETURN) = G_INT (pr, OFS_PARM0);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_precache_sound (progs_t *pr)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-07-15 07:04:17 +00:00
|
|
|
const char *s;
|
2001-02-26 06:48:02 +00:00
|
|
|
int i;
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
if (sv.state != ss_loading)
|
2001-02-26 06:48:02 +00:00
|
|
|
PR_RunError
|
2001-02-26 20:52:14 +00:00
|
|
|
(pr, "PF_Precache_*: Precache can only be done in spawn functions");
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
s = G_STRING (pr, OFS_PARM0);
|
|
|
|
G_INT (pr, OFS_RETURN) = G_INT (pr, OFS_PARM0);
|
|
|
|
PR_CheckEmptyString (pr, s);
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
for (i = 0; i < MAX_SOUNDS; i++) {
|
|
|
|
if (!sv.sound_precache[i]) {
|
2001-02-19 21:15:25 +00:00
|
|
|
sv.sound_precache[i] = s;
|
|
|
|
return;
|
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
if (!strcmp (sv.sound_precache[i], s))
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-02-26 20:52:14 +00:00
|
|
|
PR_RunError (pr, "PF_precache_sound: overflow");
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_precache_model (progs_t *pr)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-07-15 07:04:17 +00:00
|
|
|
const char *s;
|
2001-02-26 06:48:02 +00:00
|
|
|
int i;
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
if (sv.state != ss_loading)
|
2001-02-26 06:48:02 +00:00
|
|
|
PR_RunError
|
2001-02-26 20:52:14 +00:00
|
|
|
(pr, "PF_Precache_*: Precache can only be done in spawn functions");
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
s = G_STRING (pr, OFS_PARM0);
|
|
|
|
G_INT (pr, OFS_RETURN) = G_INT (pr, OFS_PARM0);
|
|
|
|
PR_CheckEmptyString (pr, s);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
for (i = 0; i < MAX_MODELS; i++) {
|
|
|
|
if (!sv.model_precache[i]) {
|
2001-02-19 21:15:25 +00:00
|
|
|
sv.model_precache[i] = s;
|
|
|
|
sv.models[i] = Mod_ForName (s, true);
|
|
|
|
return;
|
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
if (!strcmp (sv.model_precache[i], s))
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-02-26 20:52:14 +00:00
|
|
|
PR_RunError (pr, "PF_precache_model: overflow");
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_walkmove
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-09 06:05:43 +00:00
|
|
|
float(float yaw, float dist) walkmove
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_walkmove (progs_t *pr)
|
2001-02-26 06:48:02 +00:00
|
|
|
{
|
|
|
|
edict_t *ent;
|
|
|
|
float yaw, dist;
|
|
|
|
vec3_t move;
|
|
|
|
dfunction_t *oldf;
|
|
|
|
int oldself;
|
|
|
|
|
2001-03-03 08:31:58 +00:00
|
|
|
ent = PROG_TO_EDICT (pr, *sv_globals.self);
|
2001-02-26 20:52:14 +00:00
|
|
|
yaw = G_FLOAT (pr, OFS_PARM0);
|
|
|
|
dist = G_FLOAT (pr, OFS_PARM1);
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-08-08 20:28:53 +00:00
|
|
|
if (!((int) SVfloat (ent, flags) & (FL_ONGROUND | FL_FLY | FL_SWIM))) {
|
2001-02-26 20:52:14 +00:00
|
|
|
G_FLOAT (pr, OFS_RETURN) = 0;
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
yaw = yaw * M_PI * 2 / 360;
|
|
|
|
|
|
|
|
move[0] = cos (yaw) * dist;
|
|
|
|
move[1] = sin (yaw) * dist;
|
2001-02-19 21:15:25 +00:00
|
|
|
move[2] = 0;
|
|
|
|
|
|
|
|
// save program state, because SV_movestep may call other progs
|
2001-02-26 20:52:14 +00:00
|
|
|
oldf = pr->pr_xfunction;
|
2001-03-03 08:31:58 +00:00
|
|
|
oldself = *sv_globals.self;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
G_FLOAT (pr, OFS_RETURN) = SV_movestep (ent, move, true);
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
// restore program state
|
2001-02-26 20:52:14 +00:00
|
|
|
pr->pr_xfunction = oldf;
|
2001-03-03 08:31:58 +00:00
|
|
|
*sv_globals.self = oldself;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_droptofloor
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-09 06:05:43 +00:00
|
|
|
void() droptofloor
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_droptofloor (progs_t *pr)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
edict_t *ent;
|
|
|
|
vec3_t end;
|
|
|
|
trace_t trace;
|
|
|
|
|
2001-03-03 08:31:58 +00:00
|
|
|
ent = PROG_TO_EDICT (pr, *sv_globals.self);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-08 20:28:53 +00:00
|
|
|
VectorCopy (SVvector (ent, origin), end);
|
2001-02-19 21:15:25 +00:00
|
|
|
end[2] -= 256;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
trace =
|
2001-08-08 20:28:53 +00:00
|
|
|
SV_Move (SVvector (ent, origin), SVvector (ent, mins), SVvector (ent, maxs), end, false,
|
2001-02-26 20:52:14 +00:00
|
|
|
ent);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (trace.fraction == 1 || trace.allsolid)
|
2001-02-26 20:52:14 +00:00
|
|
|
G_FLOAT (pr, OFS_RETURN) = 0;
|
2001-02-26 06:48:02 +00:00
|
|
|
else {
|
2001-08-08 20:28:53 +00:00
|
|
|
VectorCopy (trace.endpos, SVvector (ent, origin));
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_LinkEdict (ent, false);
|
2001-08-08 20:28:53 +00:00
|
|
|
SVfloat (ent, flags) = (int) SVfloat (ent, flags) | FL_ONGROUND;
|
|
|
|
SVentity (ent, groundentity) = EDICT_TO_PROG (pr, trace.ent);
|
2001-02-26 20:52:14 +00:00
|
|
|
G_FLOAT (pr, OFS_RETURN) = 1;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_lightstyle
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-09 06:05:43 +00:00
|
|
|
void(float style, string value) lightstyle
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_lightstyle (progs_t *pr)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
int style;
|
|
|
|
char *val;
|
|
|
|
client_t *client;
|
|
|
|
int j;
|
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
style = G_FLOAT (pr, OFS_PARM0);
|
|
|
|
val = G_STRING (pr, OFS_PARM1);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// change the string in sv
|
|
|
|
sv.lightstyles[style] = val;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
// send message to all clients on this server
|
|
|
|
if (sv.state != ss_active)
|
|
|
|
return;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
for (j = 0, client = svs.clients; j < svs.maxclients; j++, client++)
|
|
|
|
if (client->active || client->spawned) {
|
2001-02-19 21:15:25 +00:00
|
|
|
MSG_WriteChar (&client->message, svc_lightstyle);
|
2001-02-26 06:48:02 +00:00
|
|
|
MSG_WriteChar (&client->message, style);
|
2001-02-19 21:15:25 +00:00
|
|
|
MSG_WriteString (&client->message, val);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_checkbottom
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_checkbottom (progs_t *pr)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
edict_t *ent;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
ent = G_EDICT (pr, OFS_PARM0);
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
G_FLOAT (pr, OFS_RETURN) = SV_CheckBottom (ent);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_pointcontents
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_pointcontents (progs_t *pr)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
float *v;
|
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
v = G_VECTOR (pr, OFS_PARM0);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
G_FLOAT (pr, OFS_RETURN) = SV_PointContents (v);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_aim
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-09 06:05:43 +00:00
|
|
|
Pick a vector for the player to shoot along
|
|
|
|
vector aim(entity, missilespeed)
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
cvar_t *sv_aim;
|
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_aim (progs_t *pr)
|
2001-02-26 06:48:02 +00:00
|
|
|
{
|
|
|
|
edict_t *ent, *check, *bestent;
|
|
|
|
vec3_t start, dir, end, bestdir;
|
|
|
|
int i, j;
|
|
|
|
trace_t tr;
|
|
|
|
float dist, bestdist;
|
|
|
|
float speed;
|
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
ent = G_EDICT (pr, OFS_PARM0);
|
|
|
|
speed = G_FLOAT (pr, OFS_PARM1);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-08 20:28:53 +00:00
|
|
|
VectorCopy (SVvector (ent, origin), start);
|
2001-02-19 21:15:25 +00:00
|
|
|
start[2] += 20;
|
|
|
|
|
|
|
|
// try sending a trace straight
|
2001-03-03 08:31:58 +00:00
|
|
|
VectorCopy (*sv_globals.v_forward, dir);
|
2001-02-19 21:15:25 +00:00
|
|
|
VectorMA (start, 2048, dir, end);
|
|
|
|
tr = SV_Move (start, vec3_origin, vec3_origin, end, false, ent);
|
2001-08-08 20:28:53 +00:00
|
|
|
if (tr.ent && SVfloat (tr.ent, takedamage) == DAMAGE_AIM
|
|
|
|
&& (!teamplay->int_val || SVfloat (ent, team) <= 0
|
|
|
|
|| SVfloat (ent, team) != SVfloat (tr.ent, team))) {
|
2001-03-03 08:31:58 +00:00
|
|
|
VectorCopy (*sv_globals.v_forward, G_VECTOR (pr, OFS_RETURN));
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
// try all possible entities
|
|
|
|
VectorCopy (dir, bestdir);
|
|
|
|
bestdist = sv_aim->value;
|
|
|
|
bestent = NULL;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
check = NEXT_EDICT (pr, sv.edicts);
|
|
|
|
for (i = 1; i < sv.num_edicts; i++, check = NEXT_EDICT (pr, check)) {
|
2001-08-08 20:28:53 +00:00
|
|
|
if (SVfloat (check, takedamage) != DAMAGE_AIM)
|
2001-02-19 21:15:25 +00:00
|
|
|
continue;
|
|
|
|
if (check == ent)
|
|
|
|
continue;
|
2001-08-08 20:28:53 +00:00
|
|
|
if (teamplay->int_val && SVfloat (ent, team) > 0
|
|
|
|
&& SVfloat (ent, team) == SVfloat (check, team)) continue; // don't aim at
|
2001-02-26 06:48:02 +00:00
|
|
|
// teammate
|
|
|
|
for (j = 0; j < 3; j++)
|
2001-08-08 20:28:53 +00:00
|
|
|
end[j] = SVvector (check, origin)[j]
|
|
|
|
+ 0.5 * (SVvector (check, mins)[j] + SVvector (check, maxs)[j]);
|
2001-02-19 21:15:25 +00:00
|
|
|
VectorSubtract (end, start, dir);
|
|
|
|
VectorNormalize (dir);
|
2001-03-03 08:31:58 +00:00
|
|
|
dist = DotProduct (dir, *sv_globals.v_forward);
|
2001-02-19 21:15:25 +00:00
|
|
|
if (dist < bestdist)
|
2001-02-26 06:48:02 +00:00
|
|
|
continue; // to far to turn
|
2001-02-19 21:15:25 +00:00
|
|
|
tr = SV_Move (start, vec3_origin, vec3_origin, end, false, ent);
|
2001-02-26 06:48:02 +00:00
|
|
|
if (tr.ent == check) { // can shoot at this one
|
2001-02-19 21:15:25 +00:00
|
|
|
bestdist = dist;
|
|
|
|
bestent = check;
|
|
|
|
}
|
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
if (bestent) {
|
2001-08-08 20:28:53 +00:00
|
|
|
VectorSubtract (SVvector (bestent, origin), SVvector (ent, origin), dir);
|
2001-03-03 08:31:58 +00:00
|
|
|
dist = DotProduct (dir, *sv_globals.v_forward);
|
|
|
|
VectorScale (*sv_globals.v_forward, dist, end);
|
2001-02-19 21:15:25 +00:00
|
|
|
end[2] = dir[2];
|
|
|
|
VectorNormalize (end);
|
2001-02-26 20:52:14 +00:00
|
|
|
VectorCopy (end, G_VECTOR (pr, OFS_RETURN));
|
2001-02-26 06:48:02 +00:00
|
|
|
} else {
|
2001-02-26 20:52:14 +00:00
|
|
|
VectorCopy (bestdir, G_VECTOR (pr, OFS_RETURN));
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_changeyaw
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-09 06:05:43 +00:00
|
|
|
This was a major timewaster in progs, so it was converted to C
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_changeyaw (progs_t *pr)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
edict_t *ent;
|
|
|
|
float ideal, current, move, speed;
|
|
|
|
|
2001-03-03 08:31:58 +00:00
|
|
|
ent = PROG_TO_EDICT (pr, *sv_globals.self);
|
2001-08-08 20:28:53 +00:00
|
|
|
current = anglemod (SVvector (ent, angles)[1]);
|
|
|
|
ideal = SVfloat (ent, ideal_yaw);
|
|
|
|
speed = SVfloat (ent, yaw_speed);
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
if (current == ideal)
|
|
|
|
return;
|
|
|
|
move = ideal - current;
|
2001-02-26 06:48:02 +00:00
|
|
|
if (ideal > current) {
|
2001-02-19 21:15:25 +00:00
|
|
|
if (move >= 180)
|
|
|
|
move = move - 360;
|
2001-02-26 06:48:02 +00:00
|
|
|
} else {
|
2001-02-19 21:15:25 +00:00
|
|
|
if (move <= -180)
|
|
|
|
move = move + 360;
|
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
if (move > 0) {
|
2001-02-19 21:15:25 +00:00
|
|
|
if (move > speed)
|
|
|
|
move = speed;
|
2001-02-26 06:48:02 +00:00
|
|
|
} else {
|
2001-02-19 21:15:25 +00:00
|
|
|
if (move < -speed)
|
|
|
|
move = -speed;
|
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-08-08 20:28:53 +00:00
|
|
|
SVvector (ent, angles)[1] = anglemod (current + move);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef QUAKE2
|
|
|
|
/*
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_changepitch
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_changepitch (progs_t *pr)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
edict_t *ent;
|
|
|
|
float ideal, current, move, speed;
|
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
ent = G_EDICT (pr, OFS_PARM0);
|
2001-08-08 20:28:53 +00:00
|
|
|
current = anglemod (SVvector (ent, angles)[0]);
|
|
|
|
ideal = SVfloat (ent, idealpitch);
|
|
|
|
speed = SVfloat (ent, pitch_speed);
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
if (current == ideal)
|
|
|
|
return;
|
|
|
|
move = ideal - current;
|
2001-02-26 06:48:02 +00:00
|
|
|
if (ideal > current) {
|
2001-02-19 21:15:25 +00:00
|
|
|
if (move >= 180)
|
|
|
|
move = move - 360;
|
2001-02-26 06:48:02 +00:00
|
|
|
} else {
|
2001-02-19 21:15:25 +00:00
|
|
|
if (move <= -180)
|
|
|
|
move = move + 360;
|
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
if (move > 0) {
|
2001-02-19 21:15:25 +00:00
|
|
|
if (move > speed)
|
|
|
|
move = speed;
|
2001-02-26 06:48:02 +00:00
|
|
|
} else {
|
2001-02-19 21:15:25 +00:00
|
|
|
if (move < -speed)
|
|
|
|
move = -speed;
|
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-08-08 20:28:53 +00:00
|
|
|
SVvector (ent, angles)[0] = anglemod (current + move);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
===============================================================================
|
|
|
|
|
|
|
|
MESSAGE WRITING
|
|
|
|
|
|
|
|
===============================================================================
|
|
|
|
*/
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
#define MSG_BROADCAST 0 // unreliable to all
|
|
|
|
#define MSG_ONE 1 // reliable to one (msg_entity)
|
|
|
|
#define MSG_ALL 2 // reliable to all
|
|
|
|
#define MSG_INIT 3 // write to the init string
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
sizebuf_t *
|
2001-08-09 06:05:43 +00:00
|
|
|
WriteDest (progs_t *pr)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
int entnum;
|
|
|
|
int dest;
|
|
|
|
edict_t *ent;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
dest = G_FLOAT (pr, OFS_PARM0);
|
2001-02-26 06:48:02 +00:00
|
|
|
switch (dest) {
|
|
|
|
case MSG_BROADCAST:
|
2001-02-19 21:15:25 +00:00
|
|
|
return &sv.datagram;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
case MSG_ONE:
|
2001-03-03 08:31:58 +00:00
|
|
|
ent = PROG_TO_EDICT (pr, *sv_globals.msg_entity);
|
2001-02-26 20:52:14 +00:00
|
|
|
entnum = NUM_FOR_EDICT (pr, ent);
|
2001-02-19 21:15:25 +00:00
|
|
|
if (entnum < 1 || entnum > svs.maxclients)
|
2001-02-26 20:52:14 +00:00
|
|
|
PR_RunError (pr, "WriteDest: not a client");
|
2001-02-26 06:48:02 +00:00
|
|
|
return &svs.clients[entnum - 1].message;
|
|
|
|
|
|
|
|
case MSG_ALL:
|
2001-02-19 21:15:25 +00:00
|
|
|
return &sv.reliable_datagram;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
case MSG_INIT:
|
2001-02-19 21:15:25 +00:00
|
|
|
return &sv.signon;
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
default:
|
2001-02-26 20:52:14 +00:00
|
|
|
PR_RunError (pr, "WriteDest: bad destination");
|
2001-02-19 21:15:25 +00:00
|
|
|
break;
|
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_WriteByte (progs_t *pr)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 20:52:14 +00:00
|
|
|
MSG_WriteByte (WriteDest (pr), G_FLOAT (pr, OFS_PARM1));
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_WriteChar (progs_t *pr)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 20:52:14 +00:00
|
|
|
MSG_WriteChar (WriteDest (pr), G_FLOAT (pr, OFS_PARM1));
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_WriteShort (progs_t *pr)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 20:52:14 +00:00
|
|
|
MSG_WriteShort (WriteDest (pr), G_FLOAT (pr, OFS_PARM1));
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_WriteLong (progs_t *pr)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 20:52:14 +00:00
|
|
|
MSG_WriteLong (WriteDest (pr), G_FLOAT (pr, OFS_PARM1));
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_WriteAngle (progs_t *pr)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 20:52:14 +00:00
|
|
|
MSG_WriteAngle (WriteDest (pr), G_FLOAT (pr, OFS_PARM1));
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_WriteCoord (progs_t *pr)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 20:52:14 +00:00
|
|
|
MSG_WriteCoord (WriteDest (pr), G_FLOAT (pr, OFS_PARM1));
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_WriteString (progs_t *pr)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 20:52:14 +00:00
|
|
|
MSG_WriteString (WriteDest (pr), G_STRING (pr, OFS_PARM1));
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_WriteEntity (progs_t *pr)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 20:52:14 +00:00
|
|
|
MSG_WriteShort (WriteDest (pr), G_EDICTNUM (pr, OFS_PARM1));
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_makestatic (progs_t *pr)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
edict_t *ent;
|
|
|
|
int i;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
ent = G_EDICT (pr, OFS_PARM0);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
MSG_WriteByte (&sv.signon, svc_spawnstatic);
|
|
|
|
|
2001-08-08 20:28:53 +00:00
|
|
|
MSG_WriteByte (&sv.signon, SV_ModelIndex (PR_GetString (pr, SVstring (ent, model))));
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-08 20:28:53 +00:00
|
|
|
MSG_WriteByte (&sv.signon, SVfloat (ent, frame));
|
|
|
|
MSG_WriteByte (&sv.signon, SVfloat (ent, colormap));
|
|
|
|
MSG_WriteByte (&sv.signon, SVfloat (ent, skin));
|
2001-02-26 06:48:02 +00:00
|
|
|
for (i = 0; i < 3; i++) {
|
2001-08-08 20:28:53 +00:00
|
|
|
MSG_WriteCoord (&sv.signon, SVvector (ent, origin)[i]);
|
|
|
|
MSG_WriteAngle (&sv.signon, SVvector (ent, angles)[i]);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// throw the entity away now
|
2001-02-26 20:52:14 +00:00
|
|
|
ED_Free (pr, ent);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
/*
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_setspawnparms
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_setspawnparms (progs_t *pr)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
edict_t *ent;
|
|
|
|
int i;
|
|
|
|
client_t *client;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
ent = G_EDICT (pr, OFS_PARM0);
|
|
|
|
i = NUM_FOR_EDICT (pr, ent);
|
2001-02-19 21:15:25 +00:00
|
|
|
if (i < 1 || i > svs.maxclients)
|
2001-02-26 20:52:14 +00:00
|
|
|
PR_RunError (pr, "Entity is not a client");
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// copy spawn parms out of the client_t
|
2001-02-26 06:48:02 +00:00
|
|
|
client = svs.clients + (i - 1);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
for (i = 0; i < NUM_SPAWN_PARMS; i++)
|
2001-03-03 08:31:58 +00:00
|
|
|
sv_globals.parms[i] = client->spawn_parms[i];
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_changelevel
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_changelevel (progs_t *pr)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
|
|
|
#ifdef QUAKE2
|
2001-02-26 06:48:02 +00:00
|
|
|
char *s1, *s2;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (svs.changelevel_issued)
|
|
|
|
return;
|
|
|
|
svs.changelevel_issued = true;
|
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
s1 = G_STRING (pr, OFS_PARM0);
|
|
|
|
s2 = G_STRING (pr, OFS_PARM1);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-03-03 08:31:58 +00:00
|
|
|
if ((int) *sv_globals.
|
2001-02-26 20:52:14 +00:00
|
|
|
serverflags & (SFL_NEW_UNIT | SFL_NEW_EPISODE))
|
|
|
|
Cbuf_AddText (va ("changelevel %s %s\n", s1, s2));
|
2001-02-19 21:15:25 +00:00
|
|
|
else
|
2001-02-26 06:48:02 +00:00
|
|
|
Cbuf_AddText (va ("changelevel2 %s %s\n", s1, s2));
|
2001-02-19 21:15:25 +00:00
|
|
|
#else
|
2001-02-26 06:48:02 +00:00
|
|
|
char *s;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// make sure we don't issue two changelevels
|
|
|
|
if (svs.changelevel_issued)
|
|
|
|
return;
|
|
|
|
svs.changelevel_issued = true;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
s = G_STRING (pr, OFS_PARM0);
|
2001-02-26 06:48:02 +00:00
|
|
|
Cbuf_AddText (va ("changelevel %s\n", s));
|
2001-02-19 21:15:25 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef QUAKE2
|
|
|
|
|
|
|
|
#define CONTENT_WATER -3
|
|
|
|
#define CONTENT_SLIME -4
|
|
|
|
#define CONTENT_LAVA -5
|
|
|
|
|
|
|
|
#define FL_IMMUNE_WATER 131072
|
|
|
|
#define FL_IMMUNE_SLIME 262144
|
|
|
|
#define FL_IMMUNE_LAVA 524288
|
|
|
|
|
|
|
|
#define CHAN_VOICE 2
|
|
|
|
#define CHAN_BODY 4
|
|
|
|
|
|
|
|
#define ATTN_NORM 1
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_WaterMove (progs_t *pr)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
edict_t *self;
|
|
|
|
int flags;
|
|
|
|
int waterlevel;
|
|
|
|
int watertype;
|
|
|
|
float drownlevel;
|
|
|
|
float damage = 0.0;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-03-03 08:31:58 +00:00
|
|
|
self = PROG_TO_EDICT (pr, *sv_globals.self);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-08 20:28:53 +00:00
|
|
|
if (SVfloat (self, movetype) == MOVETYPE_NOCLIP) {
|
|
|
|
SVfloat (self, air_finished) = sv.time + 12;
|
2001-02-26 20:52:14 +00:00
|
|
|
G_FLOAT (pr, OFS_RETURN) = damage;
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-08-08 20:28:53 +00:00
|
|
|
if (SVfloat (self, health) < 0) {
|
2001-02-26 20:52:14 +00:00
|
|
|
G_FLOAT (pr, OFS_RETURN) = damage;
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-08-08 20:28:53 +00:00
|
|
|
if (SVfloat (self, deadflag) == DEAD_NO)
|
2001-02-19 21:15:25 +00:00
|
|
|
drownlevel = 3;
|
|
|
|
else
|
|
|
|
drownlevel = 1;
|
|
|
|
|
2001-08-08 20:28:53 +00:00
|
|
|
flags = (int) SVfloat (self, flags);
|
|
|
|
waterlevel = (int) SVfloat (self, waterlevel);
|
|
|
|
watertype = (int) SVfloat (self, watertype);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (!(flags & (FL_IMMUNE_WATER + FL_GODMODE)))
|
2001-02-26 06:48:02 +00:00
|
|
|
if (((flags & FL_SWIM) && (waterlevel < drownlevel))
|
|
|
|
|| (waterlevel >= drownlevel)) {
|
2001-08-08 20:28:53 +00:00
|
|
|
if (SVfloat (self, air_finished) < sv.time)
|
|
|
|
if (SVfloat (self, pain_finished) < sv.time) {
|
|
|
|
SVfloat (self, dmg) = SVfloat (self, dmg) + 2;
|
|
|
|
if (SVfloat (self, dmg) > 15)
|
|
|
|
SVfloat (self, dmg) = 10;
|
2001-02-26 06:48:02 +00:00
|
|
|
// T_Damage (self, world, world, self.dmg, 0, FALSE);
|
2001-08-08 20:28:53 +00:00
|
|
|
damage = SVfloat (self, dmg);
|
|
|
|
SVfloat (self, pain_finished) = sv.time + 1.0;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
} else {
|
2001-08-08 20:28:53 +00:00
|
|
|
if (SVfloat (self, air_finished) < sv.time)
|
2001-02-26 06:48:02 +00:00
|
|
|
// sound (self, CHAN_VOICE, "player/gasp2.wav", 1, ATTN_NORM);
|
|
|
|
SV_StartSound (self, CHAN_VOICE, "player/gasp2.wav", 255,
|
|
|
|
ATTN_NORM);
|
2001-08-08 20:28:53 +00:00
|
|
|
else if (SVfloat (self, air_finished) < sv.time + 9)
|
2001-02-26 06:48:02 +00:00
|
|
|
// sound (self, CHAN_VOICE, "player/gasp1.wav", 1, ATTN_NORM);
|
|
|
|
SV_StartSound (self, CHAN_VOICE, "player/gasp1.wav", 255,
|
|
|
|
ATTN_NORM);
|
2001-08-08 20:28:53 +00:00
|
|
|
SVfloat (self, air_finished) = sv.time + 12.0;
|
|
|
|
SVfloat (self, dmg) = 2;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
if (!waterlevel) {
|
|
|
|
if (flags & FL_INWATER) {
|
2001-02-19 21:15:25 +00:00
|
|
|
// play leave water sound
|
2001-02-26 06:48:02 +00:00
|
|
|
// sound (self, CHAN_BODY, "misc/outwater.wav", 1, ATTN_NORM);
|
|
|
|
SV_StartSound (self, CHAN_BODY, "misc/outwater.wav", 255,
|
|
|
|
ATTN_NORM);
|
2001-08-08 20:28:53 +00:00
|
|
|
SVfloat (self, flags) = (float) (flags & ~FL_INWATER);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2001-08-08 20:28:53 +00:00
|
|
|
SVfloat (self, air_finished) = sv.time + 12.0;
|
2001-02-26 20:52:14 +00:00
|
|
|
G_FLOAT (pr, OFS_RETURN) = damage;
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
if (watertype == CONTENT_LAVA) { // do damage
|
2001-02-19 21:15:25 +00:00
|
|
|
if (!(flags & (FL_IMMUNE_LAVA + FL_GODMODE)))
|
2001-08-08 20:28:53 +00:00
|
|
|
if (SVfloat (self, dmgtime) < sv.time) {
|
|
|
|
if (SVfloat (self, radsuit_finished) < sv.time)
|
|
|
|
SVfloat (self, dmgtime) = sv.time + 0.2;
|
2001-02-19 21:15:25 +00:00
|
|
|
else
|
2001-08-08 20:28:53 +00:00
|
|
|
SVfloat (self, dmgtime) = sv.time + 1.0;
|
2001-02-26 06:48:02 +00:00
|
|
|
// T_Damage (self, world, world, 10*self.waterlevel, 0, TRUE);
|
|
|
|
damage = (float) (10 * waterlevel);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
} else if (watertype == CONTENT_SLIME) { // do damage
|
2001-02-19 21:15:25 +00:00
|
|
|
if (!(flags & (FL_IMMUNE_SLIME + FL_GODMODE)))
|
2001-08-08 20:28:53 +00:00
|
|
|
if (SVfloat (self, dmgtime) < sv.time
|
|
|
|
&& SVfloat (self, radsuit_finished) < sv.time) {
|
|
|
|
SVfloat (self, dmgtime) = sv.time + 1.0;
|
2001-02-26 06:48:02 +00:00
|
|
|
// T_Damage (self, world, world, 4*self.waterlevel, 0, TRUE);
|
|
|
|
damage = (float) (4 * waterlevel);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
if (!(flags & FL_INWATER)) {
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// player enter water sound
|
|
|
|
if (watertype == CONTENT_LAVA)
|
2001-02-26 06:48:02 +00:00
|
|
|
// sound (self, CHAN_BODY, "player/inlava.wav", 1, ATTN_NORM);
|
|
|
|
SV_StartSound (self, CHAN_BODY, "player/inlava.wav", 255,
|
|
|
|
ATTN_NORM);
|
2001-02-19 21:15:25 +00:00
|
|
|
if (watertype == CONTENT_WATER)
|
2001-02-26 06:48:02 +00:00
|
|
|
// sound (self, CHAN_BODY, "player/inh2o.wav", 1, ATTN_NORM);
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_StartSound (self, CHAN_BODY, "player/inh2o.wav", 255, ATTN_NORM);
|
|
|
|
if (watertype == CONTENT_SLIME)
|
2001-02-26 06:48:02 +00:00
|
|
|
// sound (self, CHAN_BODY, "player/slimbrn2.wav", 1, ATTN_NORM);
|
|
|
|
SV_StartSound (self, CHAN_BODY, "player/slimbrn2.wav", 255,
|
|
|
|
ATTN_NORM);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-08 20:28:53 +00:00
|
|
|
SVfloat (self, flags) = (float) (flags | FL_INWATER);
|
|
|
|
SVfloat (self, dmgtime) = 0;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
if (!(flags & FL_WATERJUMP)) {
|
|
|
|
// self.velocity = self.velocity - 0.8*self.waterlevel*frametime*self.velocity;
|
2001-08-08 20:28:53 +00:00
|
|
|
VectorMA (SVvector (self, velocity),
|
|
|
|
-0.8 * SVfloat (self, waterlevel) * host_frametime,
|
|
|
|
SVvector (self, velocity), SVvector (self, velocity));
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
G_FLOAT (pr, OFS_RETURN) = damage;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_sin (progs_t *pr)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 20:52:14 +00:00
|
|
|
G_FLOAT (pr, OFS_RETURN) = sin (G_FLOAT (pr, OFS_PARM0));
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_cos (progs_t *pr)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 20:52:14 +00:00
|
|
|
G_FLOAT (pr, OFS_RETURN) = cos (G_FLOAT (pr, OFS_PARM0));
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-09 06:05:43 +00:00
|
|
|
PF_sqrt (progs_t *pr)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 20:52:14 +00:00
|
|
|
G_FLOAT (pr, OFS_RETURN) = sqrt (G_FLOAT (pr, OFS_PARM0));
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
#endif
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-08-02 23:27:45 +00:00
|
|
|
PF_Fixme (progs_t *pr)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 20:52:14 +00:00
|
|
|
PR_RunError (pr, "unimplemented bulitin");
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-07 10:22:51 +00:00
|
|
|
void
|
|
|
|
PF_checkextension (progs_t *pr)
|
|
|
|
{
|
|
|
|
G_FLOAT(pr, OFS_RETURN) = 0; //FIXME make this function actually useful :P
|
|
|
|
}
|
|
|
|
|
2001-08-03 06:40:28 +00:00
|
|
|
void
|
|
|
|
SV_PR_Cmds_Init ()
|
|
|
|
{
|
2001-08-22 03:24:25 +00:00
|
|
|
PR_Cmds_Init (&sv_pr_state);
|
|
|
|
|
2001-08-03 06:40:28 +00:00
|
|
|
PR_AddBuiltin (&sv_pr_state, "makevectors", PF_makevectors, 1); // void(entity e) makevectors = #1
|
|
|
|
PR_AddBuiltin (&sv_pr_state, "setorigin", PF_setorigin, 2); // void(entity e, vector o) setorigin = #2
|
|
|
|
PR_AddBuiltin (&sv_pr_state, "setmodel", PF_setmodel, 3); // void(entity e, string m) setmodel = #3
|
|
|
|
PR_AddBuiltin (&sv_pr_state, "setsize", PF_setsize, 4); // void(entity e, vector min, vector max) setsize = #4
|
2001-08-04 22:14:45 +00:00
|
|
|
PR_AddBuiltin (&sv_pr_state, "fixme", PF_Fixme, 5); // void(entity e, vector min, vector max) setabssize = #5
|
2001-08-03 06:40:28 +00:00
|
|
|
PR_AddBuiltin (&sv_pr_state, "sound", PF_sound, 8); // void(entity e, float chan, string samp) sound = #8
|
|
|
|
PR_AddBuiltin (&sv_pr_state, "error", PF_error, 10); // void(string e) error = #10
|
|
|
|
PR_AddBuiltin (&sv_pr_state, "objerror", PF_objerror, 11); // void(string e) objerror = #11
|
2001-08-04 22:14:45 +00:00
|
|
|
PR_AddBuiltin (&sv_pr_state, "spawn", PF_Spawn, 14); // entity() spawn = #14
|
|
|
|
PR_AddBuiltin (&sv_pr_state, "remove", PF_Remove, 15); // void(entity e) remove = #15
|
2001-08-03 06:40:28 +00:00
|
|
|
PR_AddBuiltin (&sv_pr_state, "traceline", PF_traceline, 16); // float(vector v1, vector v2, float tryents) traceline = #16
|
|
|
|
PR_AddBuiltin (&sv_pr_state, "checkclient", PF_checkclient, 17); // entity() clientlist = #17
|
|
|
|
PR_AddBuiltin (&sv_pr_state, "precache_sound", PF_precache_sound, 19); // void(string s) precache_sound = #19
|
|
|
|
PR_AddBuiltin (&sv_pr_state, "precache_model", PF_precache_model, 20); // void(string s) precache_model = #20
|
|
|
|
PR_AddBuiltin (&sv_pr_state, "stuffcmd", PF_stuffcmd, 21); // void(entity client, string s) stuffcmd = #21
|
|
|
|
PR_AddBuiltin (&sv_pr_state, "findradius", PF_findradius, 22); // entity(vector org, float rad) findradius = #22
|
|
|
|
PR_AddBuiltin (&sv_pr_state, "bprint", PF_bprint, 23); // void(string s) bprint = #23
|
|
|
|
PR_AddBuiltin (&sv_pr_state, "sprint", PF_sprint, 24); // void(entity client, string s) sprint = #24
|
|
|
|
PR_AddBuiltin (&sv_pr_state, "walkmove", PF_walkmove, 32); // float(float yaw, float dist) walkmove = #32
|
|
|
|
// 33
|
|
|
|
PR_AddBuiltin (&sv_pr_state, "droptofloor", PF_droptofloor, 34); // float() droptofloor = #34
|
|
|
|
PR_AddBuiltin (&sv_pr_state, "lightstyle", PF_lightstyle, 35); // void(float style, string value) lightstyle = #35
|
|
|
|
// 39
|
|
|
|
PR_AddBuiltin (&sv_pr_state, "checkbottom", PF_checkbottom, 40); // float(entity e) checkbottom = #40
|
|
|
|
PR_AddBuiltin (&sv_pr_state, "pointcontents", PF_pointcontents, 41); // float(vector v) pointcontents = #41
|
|
|
|
// 42
|
|
|
|
PR_AddBuiltin (&sv_pr_state, "aim", PF_aim, 44); // vector(entity e, float speed) aim = #44
|
|
|
|
PR_AddBuiltin (&sv_pr_state, "localcmd", PF_localcmd, 46); // void(string s) localcmd = #46
|
|
|
|
PR_AddBuiltin (&sv_pr_state, "particle", PF_particle, 48);
|
|
|
|
PR_AddBuiltin (&sv_pr_state, "changeyaw", PF_changeyaw, 49); // void() ChangeYaw = #49
|
|
|
|
// 50
|
|
|
|
|
2001-08-04 22:14:45 +00:00
|
|
|
PR_AddBuiltin (&sv_pr_state, "writebyte", PF_WriteByte, 52); // void(float to, float f) WriteByte = #52
|
|
|
|
PR_AddBuiltin (&sv_pr_state, "writechar", PF_WriteChar, 53); // void(float to, float f) WriteChar = #53
|
|
|
|
PR_AddBuiltin (&sv_pr_state, "writeshort", PF_WriteShort, 54); // void(float to, float f) WriteShort = #54
|
|
|
|
PR_AddBuiltin (&sv_pr_state, "writelong", PF_WriteLong, 55); // void(float to, float f) WriteLong = #55
|
|
|
|
PR_AddBuiltin (&sv_pr_state, "writecoord", PF_WriteCoord, 56); // void(float to, float f) WriteCoord = #56
|
|
|
|
PR_AddBuiltin (&sv_pr_state, "writeangle", PF_WriteAngle, 57); // void(float to, float f) WriteAngle = #57
|
|
|
|
PR_AddBuiltin (&sv_pr_state, "writestring", PF_WriteString, 58); // void(float to, string s) WriteString = #58
|
|
|
|
PR_AddBuiltin (&sv_pr_state, "writeentity", PF_WriteEntity, 59); // void(float to, entity s) WriteEntity = #59
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
#ifdef QUAKE2
|
2001-08-03 06:40:28 +00:00
|
|
|
/* PF_sin,
|
2001-02-26 06:48:02 +00:00
|
|
|
PF_cos,
|
|
|
|
PF_sqrt,
|
|
|
|
PF_changepitch,
|
|
|
|
PF_TraceToss,
|
|
|
|
PF_etos,
|
2001-08-03 06:40:28 +00:00
|
|
|
PF_WaterMove, */
|
2001-02-19 21:15:25 +00:00
|
|
|
#endif
|
|
|
|
|
2001-08-03 06:40:28 +00:00
|
|
|
PR_AddBuiltin (&sv_pr_state, "movetogoal", SV_MoveToGoal, 67); // void(float step) movetogoal = #67
|
|
|
|
PR_AddBuiltin (&sv_pr_state, "precache_file", PF_precache_file, 68); // string(string s) precache_file = #68
|
|
|
|
PR_AddBuiltin (&sv_pr_state, "makestatic", PF_makestatic, 69); // void(entity e) makestatic = #69
|
|
|
|
|
|
|
|
PR_AddBuiltin (&sv_pr_state, "changelevel", PF_changelevel, 70); // void(string s) changelevel = #70
|
|
|
|
// 71
|
|
|
|
|
|
|
|
PR_AddBuiltin (&sv_pr_state, "centerprint", PF_centerprint, 73); // void(...) centerprint = #73
|
|
|
|
|
|
|
|
PR_AddBuiltin (&sv_pr_state, "ambientsound", PF_ambientsound, 74); // void(vector pos, string samp, float vol, float atten) ambientsound = #74
|
|
|
|
|
|
|
|
PR_AddBuiltin (&sv_pr_state, "precache_model", PF_precache_model, 75); // string(string s) precache_model2 = #75
|
|
|
|
PR_AddBuiltin (&sv_pr_state, "precache_sound", PF_precache_sound, 76); // string(string s) precache_sound2 = #76 precache_sound2 is different only for qcc
|
|
|
|
PR_AddBuiltin (&sv_pr_state, "precache_file", PF_precache_file, 77); // string(string s) precache_file2 = #77
|
|
|
|
|
|
|
|
PR_AddBuiltin (&sv_pr_state, "setspawnparms", PF_setspawnparms, 78); // void(entity e) setspawnparms = #78
|
|
|
|
|
|
|
|
PR_AddBuiltin (&sv_pr_state, "checkextension", PF_checkextension, 99); // = #99
|
|
|
|
}
|