17#include "../common/defs.h"
23#define NETWORKED_INT(x) int x; int x ##_net;
24#define NETWORKED_FLOAT(x) float x; float x ##_net;
25#define NETWORKED_VECTOR(x) vector x; vector x ##_net;
26#define NETWORKED_ENT(x) entity x; entity x ##_net;
27#define NETWORKED_STRING(x) string x; string x ##_net;
28#define NETWORKED_BOOL(x) bool x; bool x ##_net;
29#define NETWORKED_MODELINDEX(x) float x; float x ##_net;
31#define NETWORKED_INT_N(x) int x ##_net;
32#define NETWORKED_FLOAT_N(x) float x ##_net;
33#define NETWORKED_VECTOR_N(x) vector x ##_net;
34#define NETWORKED_STRING_N(x) string x ##_net;
36#define PREDICTED_INT(x) int x; int x ##_net;
37#define PREDICTED_FLOAT(x) float x; float x ##_net;
38#define PREDICTED_VECTOR(x) vector x; vector x ##_net;
39#define PREDICTED_ENT(x) entity x; entity x ##_net;
40#define PREDICTED_STRING(x) string x; string x ##_net;
41#define PREDICTED_BOOL(x) bool x; bool x ##_net;
43#define PREDICTED_INT_N(x) int x ##_net;
44#define PREDICTED_FLOAT_N(x) float x ##_net;
45#define PREDICTED_VECTOR_N(x) vector x ##_net;
46#define PREDICTED_STRING_N(x) string x ##_net;
49#define NSENTITY_READENTITY(x, y) \
51 local x x ##_e = ( x )self;\
52 local float x ##receivedFlags;\
54 self.classname = strcat("spawnfunc_", #x); \
55 callfunction(self.classname); \
57 x ##receivedFlags = readfloat();\
58 x ##_e.ReceiveEntity( y, x ##receivedFlags );\
60 x ##_e._ReceiveComplete( y, x ##receivedFlags );\
66#define NETWORKED_DEFAULT(x, y) x ##_net = x = y;
68#define ROLL_BACK(x) x = x ##_net;
69#define SAVE_STATE(x) x ##_net = x;
70#define SAVE_STATE_FIELD(x, y) x ##_net[y] = x[y];
71#define ATTR_CHANGED(x) (x ##_net != x)
72#define VEC_CHANGED(x,y) (x ##_net[y] != x[y])
75#define MAX_AMMO_TYPES 16i
78noref
const float SVC_TEMPENTITY = 23;
81string __fullspawndata;
89#include "../gs-entbase/client/defs.h"
91#include "../gs-entbase/server/defs.h"
96#include "../botlib/botinfo.h"
104#include "RenderableEntity.h"
105#include "SurfacePropEntity.h"
108#include "PhysicsConstraint.h"
109#include "PhysicsEntity.h"
110#include "BrushTrigger.h"
111#include "PointTrigger.h"
116#include "SquadMonster.h"
117#include "TalkMonster.h"
118#include "SpawnPoint.h"
119#include "SoundScape.h"
121#include "Projectile.h"
122#include "Spraylogo.h"
128#include "../botlib/Bot.h"
130#include "Spectator.h"
136#include "materials.h"
141#include "surfaceproperties.h"
142#include "decalgroups.h"
147#include "activities.h"
149#define BSPVER_PREREL 28
155#define BSPVER_RTCW 47
158#define CLASSEXPORT(a,b) void a(void) { if (!isfunction(#b)) { self.classname = strcat("spawnfunc_", #b); } else { self.classname = #b; } callfunction(self.classname); }
160const vector VEC_HULL_MIN = [-16,-16,-36];
161const vector VEC_HULL_MAX = [16,16,36];
162const vector VEC_CHULL_MIN = [-16,-16,-18];
163const vector VEC_CHULL_MAX = [16,16,18];
168#define UPDATE_ALL 16777215
170#define clamp(d,min,max) bound(min,d,max)
196void Util_Destroy(
void);
197string Util_TimeToString(
float fTime);
198bool Util_IsTeamplay(
void);
199bool Util_IsPaused(
void);
205 print(strcat(
"CLIENT: ", m));
207 print(strcat(
"SERVER: ", m));
213precache_model(
string m)
230precache_sound(
string sample)
233 if not(whichpack(strcat(
"sound/", sample))) {
234 NSError(
"SFX sample %S does not exist.", sample);
235 return "misc/missing.wav";
238 return prior(sample);
242noref
float input_sequence;
246 float seed = (float)input_sequence % 5.0f;
247 seed += (float)input_sequence % 8.0f;
248 seed += (float)input_sequence % 4.0f;
249 seed += (float)input_sequence % 13.0f;
250 seed += (float)input_sequence % 70.0f;
253 return bound(0.01, (seed) / 100.0f, 0.99f);
258WriteByte(
float to,
float val)
265WriteChar(
float to,
float val)
272WriteShort(
float to,
float val)
279WriteLong(
float to,
float val)
286WriteCoord(
float to,
float val)
293WriteAngle(
float to,
float val)
300WriteString(
float to,
string val)
307WriteEntity(
float to, entity val)
315setmodel(entity ent,
string mname)
318 if (substring(mname, 0, 1) !=
"*")
319 if not(whichpack(mname))
320 return prior(ent,
"models/error.vvm");
322 return prior(ent, mname);
332 print(sprintf(
"memalloc: %i\n", size));
342 if (target.identity) {
346 if (ent.removed == 0) {
347 ent.OnRemoveEntity();
349 print(sprintf(
"^1WARNING: Entity %d of class %s uncleanly removed!\n", num_for_edict(ent), ent.classname));
359traceline(vector v1, vector v2,
float flags, entity ent)
362 if (autocvar(com_showTracers, 0) == 1) {
363 WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
364 WriteByte(MSG_MULTICAST, EV_TRACEDEBUG);
365 WriteCoord(MSG_MULTICAST, v1[0]);
366 WriteCoord(MSG_MULTICAST, v1[1]);
367 WriteCoord(MSG_MULTICAST, v1[2]);
368 WriteCoord(MSG_MULTICAST, v2[0]);
369 WriteCoord(MSG_MULTICAST, v2[1]);
370 WriteCoord(MSG_MULTICAST, v2[2]);
372 multicast(v1, MULTICAST_PVS_R);
379 prior(v1, v2,
flags, ent);
383string Skill_GetStringValue(
string,
string);
387unpackStringCommand(
string commandString)
391 if (substring(commandString, 0, 6) ==
"skill:") {
392 return Skill_GetStringValue(substring(commandString, 6, -1),
"");
395 if (substring(commandString, 0, 5) ==
"cvar:") {
396 return cvar_string(substring(commandString, 5, -1));
410void(
string cmd) readcmd = #0:readcmd;
419string Util_FixModel(
string mdl)
421 if (!STRING_SET(mdl)) {
424 mdl = strreplace(
"\\",
"/", mdl);
427 mdl = strreplace(
"//",
"/", mdl);
429 int c = tokenizebyseparator(mdl,
"/",
"\\ ",
"!");
432 for (
int i = 0; i < c; i++) {
433 newpath = sprintf(
"%s/%s", newpath, argv(i));
437 newpath = substring(newpath, 1, strlen(newpath)-1);
440 c = tokenizebyseparator(newpath,
"\\/");
442 for (
int i = 0; i < c; i++) {
443 mdl = sprintf(
"%s/%s", mdl, argv(i));
446 mdl = substring(mdl, 1, strlen(mdl)-1);
448 if (substring(mdl, 0, 1) ==
"/")
449 mdl = substring(mdl, 1, -1);
458Util_ChangeExtension(
string baseString,
string newExtension)
460 float stringOffset = 0;
461 string tempString =
"";
462 float foundOffset = 0;
464 while ((tempString = substring(baseString, stringOffset, 1))) {
465 if (tempString ==
".")
466 foundOffset = stringOffset;
467 if (tempString ==
"")
476 if (foundOffset == 0) {
477 return strcat(baseString,
".", newExtension);
480 return strcat(substring(baseString, 0, foundOffset),
".", newExtension);
484Util_IsSingleplayer(
void)
488 if (cvar(
"sv_playerslots") == 1)
492 if (cvar(
"coop") == 1 && cvar(
"sv_playerslots") > 1)
503 return ((random() - 0.5f) * 2.0f);
513 int c = tokenizebyseparator(input,
"/",
"\\ ",
"!");
516 for (
int i = 0; i < (c-1); i++) {
517 newpath = sprintf(
"%s/%s", newpath, argv(i));
521 newpath = substring(newpath, 1, strlen(newpath)-1);
527textfile_to_string(
string filename)
529 string fileContents = __NULL__;
531 filestream fileHandle = fopen(filename, FILE_READ);
534 if (fileHandle != -1) {
535 while ((temp = fgets(fileHandle))) {
536 fileContents = strcat(fileContents, temp,
"\n");
539 fileContents = __NULL__;
551 float flHeight, flGravity, flTime, flDistance, flDir;
552 vector vecJump = [0,0,0];
554 if (flGravMod <= 0.0)
557 flGravity = serverkeyfloat(
"phy_gravity") * flGravMod;
558 flHeight = vecTo[2] - vecFrom[2];
562 flHeight = vlen(vecTo - vecFrom);
563 flTime = flHeight / flGravity;
565 flTime = sqrt(flHeight / (flGravity * 0.5f));
571 vecJump = vecTo - vecFrom;
573 flDistance = vlen(normalize(vecJump));
575 flDir = flDistance / flTime;
577 vecJump[2] = flTime * flGravity;
579 vector vecJump = [0,0,0];
580 float flDist = vlen(vecTo - vecFrom);
581 makevectors(vectoangles(vecTo - vecFrom));
582 vecJump = v_forward * flDist;
589DebugBox(vector absPos, vector minSize, vector maxSize, vector boxColor,
float boxAlpha)
594 a[0] = absPos[0] + minSize[0];
595 a[1] = absPos[1] + maxSize[1];
597 b[0] = absPos[0] + maxSize[0];
598 b[1] = absPos[1] + maxSize[1];
600 c[0] = absPos[0] + maxSize[0];
601 c[1] = absPos[1] + minSize[1];
603 d[0] = absPos[0] + minSize[0];
604 d[1] = absPos[1] + minSize[1];
606 a[2] = absPos[2] + maxSize[2];
607 c[2] = absPos[2] + maxSize[2];
608 d[2] = absPos[2] + maxSize[2];
609 b[2] = absPos[2] + maxSize[2];
616 w[2] = absPos[2] + minSize[2];
617 x[2] = absPos[2] + minSize[2];
618 y[2] = absPos[2] + minSize[2];
619 z[2] = absPos[2] + minSize[2];
622 R_BeginPolygon(
"", 0, 0);
623 R_PolygonVertex(a, [1,1], boxColor, boxAlpha);
624 R_PolygonVertex(b, [0,1], boxColor, boxAlpha);
625 R_PolygonVertex(c, [0,0], boxColor, boxAlpha);
626 R_PolygonVertex(d, [1,0], boxColor, boxAlpha);
630 R_BeginPolygon(
"", 0, 0);
631 R_PolygonVertex(d, [1,1], boxColor * 0.9f, boxAlpha);
632 R_PolygonVertex(c, [0,1], boxColor * 0.9f, boxAlpha);
633 R_PolygonVertex(y, [0,0], boxColor * 0.9f, boxAlpha);
634 R_PolygonVertex(z, [1,0], boxColor * 0.9f, boxAlpha);
638 R_BeginPolygon(
"", 0, 0);
639 R_PolygonVertex(w, [1,1], boxColor * 0.9f, boxAlpha);
640 R_PolygonVertex(x, [0,1], boxColor * 0.9f, boxAlpha);
641 R_PolygonVertex(b, [0,0], boxColor * 0.9f, boxAlpha);
642 R_PolygonVertex(a, [1,0], boxColor * 0.9f, boxAlpha);
646 R_BeginPolygon(
"", 0, 0);
647 R_PolygonVertex(a, [1,1], boxColor * 0.8f, boxAlpha);
648 R_PolygonVertex(d, [0,1], boxColor * 0.8f, boxAlpha);
649 R_PolygonVertex(z, [0,0], boxColor * 0.8f, boxAlpha);
650 R_PolygonVertex(w, [1,0], boxColor * 0.8f, boxAlpha);
654 R_BeginPolygon(
"", 0, 0);
655 R_PolygonVertex(c, [1,1], boxColor * 0.8f, boxAlpha);
656 R_PolygonVertex(b, [0,1], boxColor * 0.8f, boxAlpha);
657 R_PolygonVertex(x, [0,0], boxColor * 0.8f, boxAlpha);
658 R_PolygonVertex(y, [1,0], boxColor * 0.8f, boxAlpha);
662 R_BeginPolygon(
"", 0, 0);
663 R_PolygonVertex(z, [1,1], boxColor, boxAlpha);
664 R_PolygonVertex(y, [0,1], boxColor, boxAlpha);
665 R_PolygonVertex(x, [0,0], boxColor, boxAlpha);
666 R_PolygonVertex(w, [1,0], boxColor, boxAlpha);
ncEntity is the lowest of the user-accessible entity class.
Definition: Entity.h:75
string Constants_LookUp(string constName, string returnValue)
Look up a name and retrieve its value.
Definition: cloader.qc:84
typedef enumflags
Defines the valid alignment flags for text fields.
Definition: font.h:37
vector Route_GetJumpVelocity(vector, vector, float)
Definition: defs.h:548
float flags
Definition: sound.h:114