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);
204 if (cvar(
"developer") == 1)
212 print(strcat(
"CLIENT: ", m));
214 print(strcat(
"SERVER: ", m));
220precache_model(
string m)
237precache_sound(
string sample)
240 if not(whichpack(strcat(
"sound/", sample))) {
241 NSError(
"SFX sample %S does not exist.", sample);
242 return "misc/missing.wav";
245 return prior(sample);
249noref
float input_sequence;
253 float seed = (float)input_sequence % 5.0f;
254 seed += (float)input_sequence % 8.0f;
255 seed += (float)input_sequence % 4.0f;
256 seed += (float)input_sequence % 13.0f;
257 seed += (float)input_sequence % 70.0f;
260 return bound(0.01, (seed) / 100.0f, 0.99f);
265WriteByte(
float to,
float val)
272WriteChar(
float to,
float val)
279WriteShort(
float to,
float val)
286WriteLong(
float to,
float val)
293WriteCoord(
float to,
float val)
300WriteAngle(
float to,
float val)
307WriteString(
float to,
string val)
314WriteEntity(
float to, entity val)
322setmodel(entity ent,
string mname)
325 if (substring(mname, 0, 1) !=
"*")
326 if not(whichpack(mname))
327 return prior(ent,
"models/error.vvm");
329 return prior(ent, mname);
339 print(sprintf(
"memalloc: %i\n", size));
349 if (target.identity) {
353 if (ent.removed == 0) {
354 ent.OnRemoveEntity();
356 print(sprintf(
"^1WARNING: Entity %d of class %s uncleanly removed!\n", num_for_edict(ent), ent.classname));
366traceline(vector v1, vector v2,
float flags, entity ent)
369 if (autocvar(com_showTracers, 0) == 1) {
370 WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
371 WriteByte(MSG_MULTICAST, EV_TRACEDEBUG);
372 WriteCoord(MSG_MULTICAST, v1[0]);
373 WriteCoord(MSG_MULTICAST, v1[1]);
374 WriteCoord(MSG_MULTICAST, v1[2]);
375 WriteCoord(MSG_MULTICAST, v2[0]);
376 WriteCoord(MSG_MULTICAST, v2[1]);
377 WriteCoord(MSG_MULTICAST, v2[2]);
379 multicast(v1, MULTICAST_PVS_R);
386 prior(v1, v2,
flags, ent);
390string Skill_GetStringValue(
string,
string);
394unpackStringCommand(
string commandString)
398 if (substring(commandString, 0, 6) ==
"skill:") {
399 return Skill_GetStringValue(substring(commandString, 6, -1),
"");
402 if (substring(commandString, 0, 5) ==
"cvar:") {
403 return cvar_string(substring(commandString, 5, -1));
417void(
string cmd) readcmd = #0:readcmd;
426string Util_FixModel(
string mdl)
428 if (!STRING_SET(mdl)) {
431 mdl = strreplace(
"\\",
"/", mdl);
433 int c = tokenizebyseparator(mdl,
"/",
"\\ ",
"!");
436 for (
int i = 0; i < c; i++) {
437 newpath = sprintf(
"%s/%s", newpath, argv(i));
441 newpath = substring(newpath, 1, strlen(newpath)-1);
444 c = tokenizebyseparator(newpath,
"\\/");
446 for (
int i = 0; i < c; i++) {
447 mdl = sprintf(
"%s/%s", mdl, argv(i));
450 mdl = substring(mdl, 1, strlen(mdl)-1);
452 if (substring(mdl, 0, 1) ==
"/")
453 mdl = substring(mdl, 1, -1);
462Util_ChangeExtension(
string baseString,
string newExtension)
464 float stringOffset = 0;
465 string tempString =
"";
466 float foundOffset = 0;
468 while ((tempString = substring(baseString, stringOffset, 1))) {
469 if (tempString ==
".")
470 foundOffset = stringOffset;
471 if (tempString ==
"")
480 if (foundOffset == 0) {
481 return strcat(baseString,
".", newExtension);
484 return strcat(substring(baseString, 0, foundOffset),
".", newExtension);
488Util_IsSingleplayer(
void)
492 if (cvar(
"sv_playerslots") == 1)
496 if (cvar(
"coop") == 1 && cvar(
"sv_playerslots") > 1)
507 return ((random() - 0.5f) * 2.0f);
517 int c = tokenizebyseparator(input,
"/",
"\\ ",
"!");
520 for (
int i = 0; i < (c-1); i++) {
521 newpath = sprintf(
"%s/%s", newpath, argv(i));
525 newpath = substring(newpath, 1, strlen(newpath)-1);
531textfile_to_string(
string filename)
533 string fileContents = __NULL__;
535 filestream fileHandle = fopen(filename, FILE_READ);
538 if (fileHandle != -1) {
539 while ((temp = fgets(fileHandle))) {
540 fileContents = strcat(fileContents, temp,
"\n");
543 fileContents = __NULL__;
555 float flHeight, flGravity, flTime, flDistance, flDir;
556 vector vecJump = [0,0,0];
558 if (flGravMod <= 0.0)
561 flGravity = serverkeyfloat(
"phy_gravity") * flGravMod;
562 flHeight = vecTo[2] - vecFrom[2];
566 flHeight = vlen(vecTo - vecFrom);
567 flTime = flHeight / flGravity;
569 flTime = sqrt(flHeight / (flGravity * 0.5f));
575 vecJump = vecTo - vecFrom;
577 flDistance = vlen(normalize(vecJump));
579 flDir = flDistance / flTime;
581 vecJump[2] = flTime * flGravity;
583 vector vecJump = [0,0,0];
584 float flDist = vlen(vecTo - vecFrom);
585 makevectors(vectoangles(vecTo - vecFrom));
586 vecJump = v_forward * flDist;
593DebugBox(vector absPos, vector minSize, vector maxSize, vector boxColor,
float boxAlpha)
598 a[0] = absPos[0] + minSize[0];
599 a[1] = absPos[1] + maxSize[1];
601 b[0] = absPos[0] + maxSize[0];
602 b[1] = absPos[1] + maxSize[1];
604 c[0] = absPos[0] + maxSize[0];
605 c[1] = absPos[1] + minSize[1];
607 d[0] = absPos[0] + minSize[0];
608 d[1] = absPos[1] + minSize[1];
610 a[2] = absPos[2] + maxSize[2];
611 c[2] = absPos[2] + maxSize[2];
612 d[2] = absPos[2] + maxSize[2];
613 b[2] = absPos[2] + maxSize[2];
620 w[2] = absPos[2] + minSize[2];
621 x[2] = absPos[2] + minSize[2];
622 y[2] = absPos[2] + minSize[2];
623 z[2] = absPos[2] + minSize[2];
626 R_BeginPolygon(
"", 0, 0);
627 R_PolygonVertex(a, [1,1], boxColor, boxAlpha);
628 R_PolygonVertex(b, [0,1], boxColor, boxAlpha);
629 R_PolygonVertex(c, [0,0], boxColor, boxAlpha);
630 R_PolygonVertex(d, [1,0], boxColor, boxAlpha);
634 R_BeginPolygon(
"", 0, 0);
635 R_PolygonVertex(d, [1,1], boxColor * 0.9f, boxAlpha);
636 R_PolygonVertex(c, [0,1], boxColor * 0.9f, boxAlpha);
637 R_PolygonVertex(y, [0,0], boxColor * 0.9f, boxAlpha);
638 R_PolygonVertex(z, [1,0], boxColor * 0.9f, boxAlpha);
642 R_BeginPolygon(
"", 0, 0);
643 R_PolygonVertex(w, [1,1], boxColor * 0.9f, boxAlpha);
644 R_PolygonVertex(x, [0,1], boxColor * 0.9f, boxAlpha);
645 R_PolygonVertex(b, [0,0], boxColor * 0.9f, boxAlpha);
646 R_PolygonVertex(a, [1,0], boxColor * 0.9f, boxAlpha);
650 R_BeginPolygon(
"", 0, 0);
651 R_PolygonVertex(a, [1,1], boxColor * 0.8f, boxAlpha);
652 R_PolygonVertex(d, [0,1], boxColor * 0.8f, boxAlpha);
653 R_PolygonVertex(z, [0,0], boxColor * 0.8f, boxAlpha);
654 R_PolygonVertex(w, [1,0], boxColor * 0.8f, boxAlpha);
658 R_BeginPolygon(
"", 0, 0);
659 R_PolygonVertex(c, [1,1], boxColor * 0.8f, boxAlpha);
660 R_PolygonVertex(b, [0,1], boxColor * 0.8f, boxAlpha);
661 R_PolygonVertex(x, [0,0], boxColor * 0.8f, boxAlpha);
662 R_PolygonVertex(y, [1,0], boxColor * 0.8f, boxAlpha);
666 R_BeginPolygon(
"", 0, 0);
667 R_PolygonVertex(z, [1,1], boxColor, boxAlpha);
668 R_PolygonVertex(y, [0,1], boxColor, boxAlpha);
669 R_PolygonVertex(x, [0,0], boxColor, boxAlpha);
670 R_PolygonVertex(w, [1,0], boxColor, boxAlpha);
ncEntity is the lowest of the user-accessible entity class.
Definition: Entity.h:54
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:552
float flags
Definition: sound.h:114