18#define NETWORKED_INT(x) int x; int x ##_net;
19#define NETWORKED_FLOAT(x) float x; float x ##_net;
20#define NETWORKED_VECTOR(x) vector x; vector x ##_net;
21#define NETWORKED_ENT(x) entity x; entity x ##_net;
22#define NETWORKED_STRING(x) string x; string x ##_net;
23#define NETWORKED_BOOL(x) bool x; bool x ##_net;
25#define NETWORKED_INT_N(x) int x ##_net;
26#define NETWORKED_FLOAT_N(x) float x ##_net;
27#define NETWORKED_VECTOR_N(x) vector x ##_net;
28#define NETWORKED_STRING_N(x) string x ##_net;
30#define PREDICTED_INT(x) int x; int x ##_net;
31#define PREDICTED_FLOAT(x) float x; float x ##_net;
32#define PREDICTED_VECTOR(x) vector x; vector x ##_net;
33#define PREDICTED_ENT(x) entity x; entity x ##_net;
34#define PREDICTED_STRING(x) string x; string x ##_net;
35#define PREDICTED_BOOL(x) bool x; bool x ##_net;
37#define PREDICTED_INT_N(x) int x ##_net;
38#define PREDICTED_FLOAT_N(x) float x ##_net;
39#define PREDICTED_VECTOR_N(x) vector x ##_net;
40#define PREDICTED_STRING_N(x) string x ##_net;
43#define NSENTITY_READENTITY(x, y) \
45 local x x ##_e = ( x )self;\
47 self.classname = strcat("spawnfunc_", #x); \
48 callfunction(self.classname); \
50 x ##_e.ReceiveEntity( y, readfloat() );\
57#define NETWORKED_DEFAULT(x, y) x ##_net = x = y;
59#define ROLL_BACK(x) x = x ##_net;
60#define SAVE_STATE(x) x ##_net = x;
61#define SAVE_STATE_FIELD(x, y) x ##_net[y] = x[y];
62#define ATTR_CHANGED(x) (x ##_net != x)
63#define VEC_CHANGED(x,y) (x ##_net[y] != x[y])
78#include "../gs-entbase/client/defs.h"
80#include "../gs-entbase/server/defs.h"
83#include "../botlib/botinfo.h"
108#include "../xr/defs.h"
109#include "../botlib/NSBot.h"
133#define BSPVER_PREREL 28
139#define BSPVER_RTCW 47
142#define CLASSEXPORT(a,b) void a(void) { if (!isfunction(#b)) { self.classname = strcat("spawnfunc_", #b); } else { self.classname = #b; } callfunction(self.classname); }
150#define INPUT_BUTTON0 0x00000001
151#define INPUT_BUTTON2 0x00000002
152#define INPUT_BUTTON3 0x00000004
153#define INPUT_BUTTON4 0x00000008
154#define INPUT_BUTTON5 0x00000010
155#define INPUT_BUTTON6 0x00000020
156#define INPUT_BUTTON7 0x00000040
157#define INPUT_BUTTON8 0x00000080
159#define INPUT_PRIMARY INPUT_BUTTON0
160#define INPUT_JUMP INPUT_BUTTON2
161#define INPUT_PRONE INPUT_BUTTON3
162#define INPUT_RELOAD INPUT_BUTTON4
163#define INPUT_SECONDARY INPUT_BUTTON6
164#define INPUT_USE INPUT_BUTTON5
165#define INPUT_SPRINT INPUT_BUTTON7
166#define INPUT_CROUCH INPUT_BUTTON8
169#define UPDATE_ALL 16777215
171#define clamp(d,min,max) bound(min,d,max)
202 if (cvar(
"developer") == 1)
210 print(strcat(
"CLIENT: ", m));
212 print(strcat(
"SERVER: ", m));
218precache_model(
string m)
238 if not(whichpack(strcat(
"sound/", sample))) {
239 NSError(
"SFX sample %S does not exist.", sample);
240 return "misc/missing.wav";
243 return prior(sample);
258 return bound(0.01, (seed) / 100.0f, 0.99f);
265 if (substring(mname, 0, 1) !=
"*")
266 if not(whichpack(mname))
267 return prior(ent,
"models/error.vvm");
269 return prior(ent, mname);
279 print(sprintf(
"memalloc: %i\n", size));
294 if (ent.removed == 0) {
297 print(sprintf(
"^1WARNING: Entity %d of class %s uncleanly removed!\n", num_for_edict(ent), ent.classname));
310 if (autocvar(com_showTracers, 0) == 1) {
311 WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
313 WriteCoord(MSG_MULTICAST, v1[0]);
314 WriteCoord(MSG_MULTICAST, v1[1]);
315 WriteCoord(MSG_MULTICAST, v1[2]);
316 WriteCoord(MSG_MULTICAST, v2[0]);
317 WriteCoord(MSG_MULTICAST, v2[1]);
318 WriteCoord(MSG_MULTICAST, v2[2]);
320 multicast(v1, MULTICAST_PVS_R);
327 prior(v1, v2,
flags, ent);
333 for (
int i = 0;
i < 16;
i++) {
336 if (!trace_startsolid) {
343 setorigin(
target, testorg);
353void(
string cmd) readcmd = #0:readcmd;
368 int c = tokenizebyseparator(mdl,
"/",
"\\ ",
"!");
371 for (
int i = 0;
i < c;
i++) {
372 newpath = sprintf(
"%s/%s", newpath, argv(
i));
376 newpath = substring(newpath, 1, strlen(newpath)-1);
379 c = tokenizebyseparator(newpath,
"\\/");
381 for (
int i = 0;
i < c;
i++) {
382 mdl = sprintf(
"%s/%s", mdl, argv(
i));
385 mdl = substring(mdl, 1, strlen(mdl)-1);
387 if (substring(mdl, 0, 1) ==
"/")
388 mdl = substring(mdl, 1, -1);
398 float stringOffset = 0;
399 string tempString =
"";
400 float foundOffset = 0;
402 while ((tempString = substring(baseString, stringOffset, 1))) {
403 if (tempString ==
".")
404 foundOffset = stringOffset;
405 if (tempString ==
"")
413 return strcat(substring(baseString, 0, foundOffset),
".", newExtension);
421 if (cvar(
"sv_playerslots") == 1)
425 if (cvar(
"coop") == 1 && cvar(
"sv_playerslots") > 1)
436 return ((random() - 0.5f) * 2.0f);
446 int c = tokenizebyseparator(input,
"/",
"\\ ",
"!");
449 for (
int i = 0;
i < (c-1);
i++) {
450 newpath = sprintf(
"%s/%s", newpath, argv(
i));
454 newpath = substring(newpath, 1, strlen(newpath)-1);
462 string fileContents = __NULL__;
467 if (fileHandle != -1) {
468 while ((temp = fgets(fileHandle))) {
469 fileContents = strcat(fileContents, temp,
"\n");
472 fileContents = __NULL__;
484 float flHeight, flGravity, flTime, flDistance, flDir;
487 if (flGravMod <= 0.0)
490 flGravity = serverkeyfloat(
"phy_gravity") * flGravMod;
491 flHeight = vecTo[2] - vecFrom[2];
495 flHeight = vlen(vecTo - vecFrom);
496 flTime = flHeight / flGravity;
498 flTime = sqrt(flHeight / (flGravity * 0.5f));
504 vecJump = vecTo - vecFrom;
506 flDistance = vlen(normalize(vecJump));
508 flDir = flDistance / flTime;
510 vecJump[2] = flTime * flGravity;
513 float flDist = vlen(vecTo - vecFrom);
525 if not(whichpack(filePath))
537 a[0] = absPos[0] + minSize[0];
538 a[1] = absPos[1] + maxSize[1];
540 b[0] = absPos[0] + maxSize[0];
541 b[1] = absPos[1] + maxSize[1];
543 c[0] = absPos[0] + maxSize[0];
544 c[1] = absPos[1] + minSize[1];
546 d[0] = absPos[0] + minSize[0];
547 d[1] = absPos[1] + minSize[1];
549 a[2] = absPos[2] + maxSize[2];
550 c[2] = absPos[2] + maxSize[2];
551 d[2] = absPos[2] + maxSize[2];
552 b[2] = absPos[2] + maxSize[2];
559 w[2] = absPos[2] + minSize[2];
560 x[2] = absPos[2] + minSize[2];
561 y[2] = absPos[2] + minSize[2];
562 z[2] = absPos[2] + minSize[2];
565 R_BeginPolygon(
"", 0, 0);
566 R_PolygonVertex(
a, [1,1], boxColor, boxAlpha);
567 R_PolygonVertex(b, [0,1], boxColor, boxAlpha);
568 R_PolygonVertex(c, [0,0], boxColor, boxAlpha);
569 R_PolygonVertex(d, [1,0], boxColor, boxAlpha);
573 R_BeginPolygon(
"", 0, 0);
574 R_PolygonVertex(d, [1,1], boxColor * 0.9f, boxAlpha);
575 R_PolygonVertex(c, [0,1], boxColor * 0.9f, boxAlpha);
576 R_PolygonVertex(y, [0,0], boxColor * 0.9f, boxAlpha);
577 R_PolygonVertex(z, [1,0], boxColor * 0.9f, boxAlpha);
581 R_BeginPolygon(
"", 0, 0);
582 R_PolygonVertex(w, [1,1], boxColor * 0.9f, boxAlpha);
583 R_PolygonVertex(x, [0,1], boxColor * 0.9f, boxAlpha);
584 R_PolygonVertex(b, [0,0], boxColor * 0.9f, boxAlpha);
585 R_PolygonVertex(
a, [1,0], boxColor * 0.9f, boxAlpha);
589 R_BeginPolygon(
"", 0, 0);
590 R_PolygonVertex(
a, [1,1], boxColor * 0.8f, boxAlpha);
591 R_PolygonVertex(d, [0,1], boxColor * 0.8f, boxAlpha);
592 R_PolygonVertex(z, [0,0], boxColor * 0.8f, boxAlpha);
593 R_PolygonVertex(w, [1,0], boxColor * 0.8f, boxAlpha);
597 R_BeginPolygon(
"", 0, 0);
598 R_PolygonVertex(c, [1,1], boxColor * 0.8f, boxAlpha);
599 R_PolygonVertex(b, [0,1], boxColor * 0.8f, boxAlpha);
600 R_PolygonVertex(x, [0,0], boxColor * 0.8f, boxAlpha);
601 R_PolygonVertex(y, [1,0], boxColor * 0.8f, boxAlpha);
605 R_BeginPolygon(
"", 0, 0);
606 R_PolygonVertex(z, [1,1], boxColor, boxAlpha);
607 R_PolygonVertex(y, [0,1], boxColor, boxAlpha);
608 R_PolygonVertex(x, [0,0], boxColor, boxAlpha);
609 R_PolygonVertex(w, [1,0], boxColor, boxAlpha);
NSEntity is the lowest of the user-accessible entity class.
Definition: NSEntity.h:52
virtual void OnRemoveEntity(void)
Handles what happens before the entity gets removed from the client game.
Definition: NSEntity.qc:1126
@ EV_TRACEDEBUG
Definition: events.h:61
__variant(float table, string name, optional __variant deflt, optional float requiretype, optional float index) hash_get
const float FILE_READ
Definition: fteextensions.qc:1423
#define filestream
Definition: fteextensions.qc:271
get __int i
Definition: fteextensions.qc:3826
get jsonnode a[__int key]
Definition: fteextensions.qc:3828
int *string filename
Definition: fteextensions.qc:2729
#define NSError(...)
Logs an error message, with timestamp.
Definition: global.h:75
#define enumflags
Doxygen doesn't know what enumflags (aka bitfields) are, used as e.g.
Definition: global.h:24
string target
Definition: defs.h:23
Vector Math Helper Functions.
#define vectoangles
Definition: math.h:37
vector v_forward
Definition: math.h:39
void makevectors(vector angles)
Definition: math.h:42
float(float modidx, string framename) frameforname
string __fullspawndata
Definition: defs.h:131
vector Route_GetJumpVelocity(vector vecFrom, vector vecTo, float flGravMod)
Definition: defs.h:481
const vector VEC_HULL_MIN
Definition: defs.h:144
noref float input_sequence
Definition: defs.h:247
__wrap void remove(entity target)
Definition: defs.h:287
__wrap void dprint(string m)
Definition: defs.h:200
float identity
Definition: defs.h:284
void DebugBox(vector absPos, vector minSize, vector maxSize, vector boxColor, float boxAlpha)
Definition: defs.h:532
noref const float SVC_TEMPENTITY
Definition: defs.h:65
__wrap void setmodel(entity ent, string mname)
Definition: defs.h:262
float pseudorandom()
Definition: defs.h:249
float gflags
Definition: defs.h:186
float teleport_time
Definition: defs.h:184
bool FileExists(string filePath)
Definition: defs.h:522
void crossprint(string m)
Definition: defs.h:207
__wrap __variant * memalloc(int size)
Definition: defs.h:273
const vector VEC_CHULL_MAX
Definition: defs.h:147
bool Util_IsSingleplayer(void)
Definition: defs.h:417
__wrap string precache_sound(string sample)
Definition: defs.h:235
string Util_FixModel(string mdl)
Definition: defs.h:362
float crandom(void)
Definition: defs.h:434
bool Util_IsTeamplay(void)
Definition: util.qc:56
float removed
Definition: defs.h:285
__wrap void traceline(vector v1, vector v2, float flags, entity ent)
Definition: defs.h:307
const vector VEC_HULL_MAX
Definition: defs.h:145
string textfile_to_string(string filename)
Definition: defs.h:460
float jumptime
Definition: defs.h:183
void Empty(void)
Definition: defs.h:189
@ SEARCH_MULTISEARCH
Definition: defs.h:179
@ SEARCH_FORCESEARCH
Definition: defs.h:178
@ SEARCH_NAMESORT
Definition: defs.h:180
@ SEARCH_FULLPACKAGE
Definition: defs.h:176
@ SEARCH_INSENSITIVE
Definition: defs.h:175
@ SEARCH_ALLOWDUPES
Definition: defs.h:177
vector basevelocity
Definition: defs.h:185
const vector VEC_CHULL_MIN
Definition: defs.h:146
void setorigin_safe(entity target, vector testorg)
Definition: defs.h:331
void Util_Destroy(void)
Definition: util.qc:28
string Util_TimeToString(float fTime)
Definition: util.qc:34
bool Util_IsPaused(void)
Definition: util.qc:18
string Util_ChangeExtension(string baseString, string newExtension)
Returns a string (usually filename) with only the file extension at the end replaced with a given,...
Definition: defs.h:396
string dirname(string input)
Definition: defs.h:440
SoundDef system functions.
float flags
Definition: sound.h:29