17#include "../common/defs.h"
20#define NETWORKED_INT(x) int x; int x ##_net;
21#define NETWORKED_FLOAT(x) float x; float x ##_net;
22#define NETWORKED_VECTOR(x) vector x; vector x ##_net;
23#define NETWORKED_ENT(x) entity x; entity x ##_net;
24#define NETWORKED_STRING(x) string x; string x ##_net;
25#define NETWORKED_BOOL(x) bool x; bool x ##_net;
26#define NETWORKED_MODELINDEX(x) float x; float x ##_net;
28#define NETWORKED_INT_N(x) int x ##_net;
29#define NETWORKED_FLOAT_N(x) float x ##_net;
30#define NETWORKED_VECTOR_N(x) vector x ##_net;
31#define NETWORKED_STRING_N(x) string x ##_net;
33#define PREDICTED_INT(x) int x; int x ##_net;
34#define PREDICTED_FLOAT(x) float x; float x ##_net;
35#define PREDICTED_VECTOR(x) vector x; vector x ##_net;
36#define PREDICTED_ENT(x) entity x; entity x ##_net;
37#define PREDICTED_STRING(x) string x; string x ##_net;
38#define PREDICTED_BOOL(x) bool x; bool x ##_net;
40#define PREDICTED_INT_N(x) int x ##_net;
41#define PREDICTED_FLOAT_N(x) float x ##_net;
42#define PREDICTED_VECTOR_N(x) vector x ##_net;
43#define PREDICTED_STRING_N(x) string x ##_net;
46#define NSENTITY_READENTITY(x, y) \
48 local x x ##_e = ( x )self;\
49 local float x ##receivedFlags;\
51 self.classname = strcat("spawnfunc_", #x); \
52 callfunction(self.classname); \
54 x ##receivedFlags = readfloat();\
55 x ##_e.ReceiveEntity( y, x ##receivedFlags );\
57 x ##_e._ReceiveComplete( y, x ##receivedFlags );\
63#define NETWORKED_DEFAULT(x, y) x ##_net = x = y;
65#define ROLL_BACK(x) x = x ##_net;
66#define SAVE_STATE(x) x ##_net = x;
67#define SAVE_STATE_FIELD(x, y) x ##_net[y] = x[y];
68#define ATTR_CHANGED(x) (x ##_net != x)
69#define VEC_CHANGED(x,y) (x ##_net[y] != x[y])
72#define MAX_AMMO_TYPES 16i
75noref
const float SVC_TEMPENTITY = 23;
78string __fullspawndata;
86#include "../gs-entbase/client/defs.h"
88#include "../gs-entbase/server/defs.h"
93#include "../botlib/botinfo.h"
101#include "RenderableEntity.h"
102#include "SurfacePropEntity.h"
105#include "PhysicsConstraint.h"
106#include "PhysicsEntity.h"
107#include "BrushTrigger.h"
108#include "PointTrigger.h"
113#include "SquadMonster.h"
114#include "TalkMonster.h"
115#include "SpawnPoint.h"
116#include "SoundScape.h"
118#include "Projectile.h"
119#include "Spraylogo.h"
125#include "../botlib/Bot.h"
127#include "Spectator.h"
133#include "materials.h"
138#include "surfaceproperties.h"
139#include "decalgroups.h"
144#include "activities.h"
146#define BSPVER_PREREL 28
152#define BSPVER_RTCW 47
155#define CLASSEXPORT(a,b) void a(void) { if (!isfunction(#b)) { self.classname = strcat("spawnfunc_", #b); } else { self.classname = #b; } callfunction(self.classname); }
157const vector VEC_HULL_MIN = [-16,-16,-36];
158const vector VEC_HULL_MAX = [16,16,36];
159const vector VEC_CHULL_MIN = [-16,-16,-18];
160const vector VEC_CHULL_MAX = [16,16,18];
165#define UPDATE_ALL 16777215
167#define clamp(d,min,max) bound(min,d,max)
179.vector m_pmoveBaseVelocity;
191void Util_Destroy(
void);
192string Util_TimeToString(
float fTime);
193bool Util_IsTeamplay(
void);
194bool Util_IsPaused(
void);
200 print(strcat(
"CLIENT: ", m));
202 print(strcat(
"SERVER: ", m));
208precache_model(
string m)
225precache_sound(
string sample)
228 if not(whichpack(strcat(
"sound/", sample))) {
229 ncError(
"SFX sample %S does not exist.", sample);
230 return "misc/missing.wav";
233 return prior(sample);
237noref
float input_sequence;
241 float seed = (float)input_sequence % 5.0f;
242 seed += (float)input_sequence % 8.0f;
243 seed += (float)input_sequence % 4.0f;
244 seed += (float)input_sequence % 13.0f;
245 seed += (float)input_sequence % 70.0f;
248 return bound(0.01, (seed) / 100.0f, 0.99f);
253WriteByte(
float to,
float val)
260WriteChar(
float to,
float val)
267WriteShort(
float to,
float val)
274WriteLong(
float to,
float val)
281WriteCoord(
float to,
float val)
288WriteAngle(
float to,
float val)
295WriteString(
float to,
string val)
302WriteEntity(
float to, entity val)
310setmodel(entity ent,
string mname)
313 if (substring(mname, 0, 1) !=
"*")
314 if not(whichpack(mname))
315 return prior(ent,
"models/error.vvm");
317 return prior(ent, mname);
327 print(sprintf(
"memalloc: %i\n", size));
337 if (target.identity) {
341 if (ent.removed == 0) {
342 ent.OnRemoveEntity();
344 print(sprintf(
"^1WARNING: Entity %d of class %s uncleanly removed!\n", num_for_edict(ent), ent.classname));
354traceline(vector v1, vector v2,
float flags, entity ent)
357 if (autocvar(com_showTracers, 0) == 1) {
358 WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
359 WriteByte(MSG_MULTICAST, EV_TRACEDEBUG);
360 WriteCoord(MSG_MULTICAST, v1[0]);
361 WriteCoord(MSG_MULTICAST, v1[1]);
362 WriteCoord(MSG_MULTICAST, v1[2]);
363 WriteCoord(MSG_MULTICAST, v2[0]);
364 WriteCoord(MSG_MULTICAST, v2[1]);
365 WriteCoord(MSG_MULTICAST, v2[2]);
367 multicast(v1, MULTICAST_PVS_R);
374 prior(v1, v2,
flags, ent);
378string Skill_GetStringValue(
string,
string);
382unpackStringCommand(
string commandString)
386 if (substring(commandString, 0, 6) ==
"skill:") {
387 return Skill_GetStringValue(substring(commandString, 6, -1),
"");
390 if (substring(commandString, 0, 5) ==
"cvar:") {
391 return cvar_string(substring(commandString, 5, -1));
405void(
string cmd) readcmd = #0:readcmd;
414string Util_FixModel(
string mdl)
416 if (!STRING_SET(mdl)) {
419 mdl = strreplace(
"\\",
"/", mdl);
422 mdl = strreplace(
"//",
"/", mdl);
424 int c = tokenizebyseparator(mdl,
"/",
"\\ ",
"!");
427 for (
int i = 0; i < c; i++) {
428 newpath = sprintf(
"%s/%s", newpath, argv(i));
432 newpath = substring(newpath, 1, strlen(newpath)-1);
435 c = tokenizebyseparator(newpath,
"\\/");
437 for (
int i = 0; i < c; i++) {
438 mdl = sprintf(
"%s/%s", mdl, argv(i));
441 mdl = substring(mdl, 1, strlen(mdl)-1);
443 if (substring(mdl, 0, 1) ==
"/")
444 mdl = substring(mdl, 1, -1);
446 mdl = strreplace(
"/ ",
"/", mdl);
455Util_ChangeExtension(
string baseString,
string newExtension)
457 float stringOffset = 0;
458 string tempString =
"";
459 float foundOffset = 0;
461 while ((tempString = substring(baseString, stringOffset, 1))) {
462 if (tempString ==
".")
463 foundOffset = stringOffset;
464 if (tempString ==
"")
473 if (foundOffset == 0) {
474 return strcat(baseString,
".", newExtension);
477 return strcat(substring(baseString, 0, foundOffset),
".", newExtension);
481Util_IsSingleplayer(
void)
485 if (cvar(
"sv_playerslots") == 1)
489 if (cvar(
"coop") == 1 && cvar(
"sv_playerslots") > 1)
500 return ((random() - 0.5f) * 2.0f);
510 int c = tokenizebyseparator(input,
"/",
"\\ ",
"!");
513 for (
int i = 0; i < (c-1); i++) {
514 newpath = sprintf(
"%s/%s", newpath, argv(i));
518 newpath = substring(newpath, 1, strlen(newpath)-1);
524textfile_to_string(
string filename)
526 string fileContents = __NULL__;
528 filestream fileHandle = fopen(filename, FILE_READ);
531 if (fileHandle != -1) {
532 while ((temp = fgets(fileHandle))) {
533 fileContents = strcat(fileContents, temp,
"\n");
536 fileContents = __NULL__;
548 float flHeight, flGravity, flTime, flDistance, flDir;
549 vector vecJump = [0,0,0];
551 if (flGravMod <= 0.0)
554 flGravity = serverkeyfloat(
"phy_gravity") * flGravMod;
555 flHeight = vecTo[2] - vecFrom[2];
559 flHeight = vlen(vecTo - vecFrom);
560 flTime = flHeight / flGravity;
562 flTime = sqrt(flHeight / (flGravity * 0.5f));
568 vecJump = vecTo - vecFrom;
570 flDistance = vlen(normalize(vecJump));
572 flDir = flDistance / flTime;
574 vecJump[2] = flTime * flGravity;
576 vector vecJump = [0,0,0];
577 float flDist = vlen(vecTo - vecFrom);
578 makevectors(vectoangles(vecTo - vecFrom));
579 vecJump = v_forward * flDist;
586DebugBox(vector absPos, vector minSize, vector maxSize, vector boxColor,
float boxAlpha)
591 a[0] = absPos[0] + minSize[0];
592 a[1] = absPos[1] + maxSize[1];
594 b[0] = absPos[0] + maxSize[0];
595 b[1] = absPos[1] + maxSize[1];
597 c[0] = absPos[0] + maxSize[0];
598 c[1] = absPos[1] + minSize[1];
600 d[0] = absPos[0] + minSize[0];
601 d[1] = absPos[1] + minSize[1];
603 a[2] = absPos[2] + maxSize[2];
604 c[2] = absPos[2] + maxSize[2];
605 d[2] = absPos[2] + maxSize[2];
606 b[2] = absPos[2] + maxSize[2];
613 w[2] = absPos[2] + minSize[2];
614 x[2] = absPos[2] + minSize[2];
615 y[2] = absPos[2] + minSize[2];
616 z[2] = absPos[2] + minSize[2];
619 R_BeginPolygon(
"", 0, 0);
620 R_PolygonVertex(a, [1,1], boxColor, boxAlpha);
621 R_PolygonVertex(b, [0,1], boxColor, boxAlpha);
622 R_PolygonVertex(c, [0,0], boxColor, boxAlpha);
623 R_PolygonVertex(d, [1,0], boxColor, boxAlpha);
627 R_BeginPolygon(
"", 0, 0);
628 R_PolygonVertex(d, [1,1], boxColor * 0.9f, boxAlpha);
629 R_PolygonVertex(c, [0,1], boxColor * 0.9f, boxAlpha);
630 R_PolygonVertex(y, [0,0], boxColor * 0.9f, boxAlpha);
631 R_PolygonVertex(z, [1,0], boxColor * 0.9f, boxAlpha);
635 R_BeginPolygon(
"", 0, 0);
636 R_PolygonVertex(w, [1,1], boxColor * 0.9f, boxAlpha);
637 R_PolygonVertex(x, [0,1], boxColor * 0.9f, boxAlpha);
638 R_PolygonVertex(b, [0,0], boxColor * 0.9f, boxAlpha);
639 R_PolygonVertex(a, [1,0], boxColor * 0.9f, boxAlpha);
643 R_BeginPolygon(
"", 0, 0);
644 R_PolygonVertex(a, [1,1], boxColor * 0.8f, boxAlpha);
645 R_PolygonVertex(d, [0,1], boxColor * 0.8f, boxAlpha);
646 R_PolygonVertex(z, [0,0], boxColor * 0.8f, boxAlpha);
647 R_PolygonVertex(w, [1,0], boxColor * 0.8f, boxAlpha);
651 R_BeginPolygon(
"", 0, 0);
652 R_PolygonVertex(c, [1,1], boxColor * 0.8f, boxAlpha);
653 R_PolygonVertex(b, [0,1], boxColor * 0.8f, boxAlpha);
654 R_PolygonVertex(x, [0,0], boxColor * 0.8f, boxAlpha);
655 R_PolygonVertex(y, [1,0], boxColor * 0.8f, boxAlpha);
659 R_BeginPolygon(
"", 0, 0);
660 R_PolygonVertex(z, [1,1], boxColor, boxAlpha);
661 R_PolygonVertex(y, [0,1], boxColor, boxAlpha);
662 R_PolygonVertex(x, [0,0], boxColor, boxAlpha);
663 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:545
float flags
Definition: soundDef.h:114