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;\
50 self.classname = strcat("spawnfunc_", #x); \
51 callfunction(self.classname); \
53 x ##_e.ReceiveEntity( y, readfloat() );\
60#define NETWORKED_DEFAULT(x, y) x ##_net = x = y;
62#define ROLL_BACK(x) x = x ##_net;
63#define SAVE_STATE(x) x ##_net = x;
64#define SAVE_STATE_FIELD(x, y) x ##_net[y] = x[y];
65#define ATTR_CHANGED(x) (x ##_net != x)
66#define VEC_CHANGED(x,y) (x ##_net[y] != x[y])
69#define MAX_AMMO_TYPES 16i
85#include "../gs-entbase/client/defs.h"
87#include "../gs-entbase/server/defs.h"
92#include "../botlib/botinfo.h"
121#include "../xr/defs.h"
122#include "../botlib/NSBot.h"
147#define BSPVER_PREREL 28
153#define BSPVER_RTCW 47
156#define CLASSEXPORT(a,b) void a(void) { if (!isfunction(#b)) { self.classname = strcat("spawnfunc_", #b); } else { self.classname = #b; } callfunction(self.classname); }
164#define INPUT_BUTTON0 0x00000001
165#define INPUT_BUTTON2 0x00000002
166#define INPUT_BUTTON3 0x00000004
167#define INPUT_BUTTON4 0x00000008
168#define INPUT_BUTTON5 0x00000010
169#define INPUT_BUTTON6 0x00000020
170#define INPUT_BUTTON7 0x00000040
171#define INPUT_BUTTON8 0x00000080
173#define INPUT_PRIMARY INPUT_BUTTON0
174#define INPUT_JUMP INPUT_BUTTON2
175#define INPUT_PRONE INPUT_BUTTON3
176#define INPUT_RELOAD INPUT_BUTTON4
177#define INPUT_SECONDARY INPUT_BUTTON6
178#define INPUT_USE INPUT_BUTTON5
179#define INPUT_SPRINT INPUT_BUTTON7
180#define INPUT_CROUCH INPUT_BUTTON8
183#define UPDATE_ALL 16777215
185#define clamp(d,min,max) bound(min,d,max)
216 if (cvar(
"developer") == 1)
224 print(strcat(
"CLIENT: ", m));
226 print(strcat(
"SERVER: ", m));
232precache_model(
string m)
252 if not(whichpack(strcat(
"sound/", sample))) {
253 NSError(
"SFX sample %S does not exist.", sample);
254 return "misc/missing.wav";
257 return prior(sample);
272 return bound(0.01, (seed) / 100.0f, 0.99f);
277WriteByte(
float to,
float val)
284WriteChar(
float to,
float val)
291WriteShort(
float to,
float val)
298WriteLong(
float to,
float val)
305WriteCoord(
float to,
float val)
312WriteAngle(
float to,
float val)
319WriteString(
float to,
string val)
326WriteEntity(
float to, entity val)
337 if (substring(mname, 0, 1) !=
"*")
338 if not(whichpack(mname))
339 return prior(ent,
"models/error.vvm");
341 return prior(ent, mname);
351 print(sprintf(
"memalloc: %i\n", size));
366 if (ent.removed == 0) {
369 print(sprintf(
"^1WARNING: Entity %d of class %s uncleanly removed!\n", num_for_edict(ent), ent.classname));
382 if (autocvar(com_showTracers, 0) == 1) {
383 WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
385 WriteCoord(MSG_MULTICAST, v1[0]);
386 WriteCoord(MSG_MULTICAST, v1[1]);
387 WriteCoord(MSG_MULTICAST, v1[2]);
388 WriteCoord(MSG_MULTICAST, v2[0]);
389 WriteCoord(MSG_MULTICAST, v2[1]);
390 WriteCoord(MSG_MULTICAST, v2[2]);
392 multicast(v1, MULTICAST_PVS_R);
399 prior(v1, v2,
flags, ent);
405 for (
int i = 0; i < 16; i++) {
408 if (!trace_startsolid) {
415 setorigin(
target, testorg);
425void(
string cmd) readcmd = #0:readcmd;
440 int c = tokenizebyseparator(mdl,
"/",
"\\ ",
"!");
443 for (
int i = 0; i < c; i++) {
444 newpath = sprintf(
"%s/%s", newpath, argv(i));
448 newpath = substring(newpath, 1, strlen(newpath)-1);
451 c = tokenizebyseparator(newpath,
"\\/");
453 for (
int i = 0; i < c; i++) {
454 mdl = sprintf(
"%s/%s", mdl, argv(i));
457 mdl = substring(mdl, 1, strlen(mdl)-1);
459 if (substring(mdl, 0, 1) ==
"/")
460 mdl = substring(mdl, 1, -1);
470 float stringOffset = 0;
471 string tempString =
"";
472 float foundOffset = 0;
474 while ((tempString = substring(baseString, stringOffset, 1))) {
475 if (tempString ==
".")
476 foundOffset = stringOffset;
477 if (tempString ==
"")
485 return strcat(substring(baseString, 0, foundOffset),
".", newExtension);
493 if (cvar(
"sv_playerslots") == 1)
497 if (cvar(
"coop") == 1 && cvar(
"sv_playerslots") > 1)
508 return ((random() - 0.5f) * 2.0f);
518 int c = tokenizebyseparator(input,
"/",
"\\ ",
"!");
521 for (
int i = 0; i < (c-1); i++) {
522 newpath = sprintf(
"%s/%s", newpath, argv(i));
526 newpath = substring(newpath, 1, strlen(newpath)-1);
534 string fileContents = __NULL__;
536 filestream fileHandle = fopen(filename, FILE_READ);
539 if (fileHandle != -1) {
540 while ((temp = fgets(fileHandle))) {
541 fileContents = strcat(fileContents, temp,
"\n");
544 fileContents = __NULL__;
556 float flHeight, flGravity, flTime, flDistance, flDir;
557 vector vecJump = [0,0,0];
559 if (flGravMod <= 0.0)
562 flGravity = serverkeyfloat(
"phy_gravity") * flGravMod;
563 flHeight = vecTo[2] - vecFrom[2];
567 flHeight = vlen(vecTo - vecFrom);
568 flTime = flHeight / flGravity;
570 flTime = sqrt(flHeight / (flGravity * 0.5f));
576 vecJump = vecTo - vecFrom;
578 flDistance = vlen(normalize(vecJump));
580 flDir = flDistance / flTime;
582 vecJump[2] = flTime * flGravity;
584 vector vecJump = [0,0,0];
585 float flDist = vlen(vecTo - vecFrom);
597 if not(whichpack(filePath))
604DebugBox(vector absPos, vector minSize, vector maxSize, vector boxColor,
float boxAlpha)
609 a[0] = absPos[0] + minSize[0];
610 a[1] = absPos[1] + maxSize[1];
612 b[0] = absPos[0] + maxSize[0];
613 b[1] = absPos[1] + maxSize[1];
615 c[0] = absPos[0] + maxSize[0];
616 c[1] = absPos[1] + minSize[1];
618 d[0] = absPos[0] + minSize[0];
619 d[1] = absPos[1] + minSize[1];
621 a[2] = absPos[2] + maxSize[2];
622 c[2] = absPos[2] + maxSize[2];
623 d[2] = absPos[2] + maxSize[2];
624 b[2] = absPos[2] + maxSize[2];
631 w[2] = absPos[2] + minSize[2];
632 x[2] = absPos[2] + minSize[2];
633 y[2] = absPos[2] + minSize[2];
634 z[2] = absPos[2] + minSize[2];
637 R_BeginPolygon(
"", 0, 0);
638 R_PolygonVertex(a, [1,1], boxColor, boxAlpha);
639 R_PolygonVertex(b, [0,1], boxColor, boxAlpha);
640 R_PolygonVertex(c, [0,0], boxColor, boxAlpha);
641 R_PolygonVertex(d, [1,0], boxColor, boxAlpha);
645 R_BeginPolygon(
"", 0, 0);
646 R_PolygonVertex(d, [1,1], boxColor * 0.9f, boxAlpha);
647 R_PolygonVertex(c, [0,1], boxColor * 0.9f, boxAlpha);
648 R_PolygonVertex(y, [0,0], boxColor * 0.9f, boxAlpha);
649 R_PolygonVertex(z, [1,0], boxColor * 0.9f, boxAlpha);
653 R_BeginPolygon(
"", 0, 0);
654 R_PolygonVertex(w, [1,1], boxColor * 0.9f, boxAlpha);
655 R_PolygonVertex(x, [0,1], boxColor * 0.9f, boxAlpha);
656 R_PolygonVertex(b, [0,0], boxColor * 0.9f, boxAlpha);
657 R_PolygonVertex(a, [1,0], boxColor * 0.9f, boxAlpha);
661 R_BeginPolygon(
"", 0, 0);
662 R_PolygonVertex(a, [1,1], boxColor * 0.8f, boxAlpha);
663 R_PolygonVertex(d, [0,1], boxColor * 0.8f, boxAlpha);
664 R_PolygonVertex(z, [0,0], boxColor * 0.8f, boxAlpha);
665 R_PolygonVertex(w, [1,0], boxColor * 0.8f, boxAlpha);
669 R_BeginPolygon(
"", 0, 0);
670 R_PolygonVertex(c, [1,1], boxColor * 0.8f, boxAlpha);
671 R_PolygonVertex(b, [0,1], boxColor * 0.8f, boxAlpha);
672 R_PolygonVertex(x, [0,0], boxColor * 0.8f, boxAlpha);
673 R_PolygonVertex(y, [1,0], boxColor * 0.8f, boxAlpha);
677 R_BeginPolygon(
"", 0, 0);
678 R_PolygonVertex(z, [1,1], boxColor, boxAlpha);
679 R_PolygonVertex(y, [0,1], boxColor, boxAlpha);
680 R_PolygonVertex(x, [0,0], boxColor, boxAlpha);
681 R_PolygonVertex(w, [1,0], boxColor, boxAlpha);
NSEntity is the lowest of the user-accessible entity class.
Definition: NSEntity.h:54
virtual void OnRemoveEntity(void)
Handles what happens before the entity gets removed from the client game.
Definition: NSEntity.qc:1145
@ EV_TRACEDEBUG
Definition: events.h:62
#define NSError(...)
Logs an error message, with timestamp.
Definition: global.h:85
#define enumflags
Doxygen doesn't know what enumflags (aka bitfields) are, used as e.g.
Definition: global.h:34
#define vectoangles
Definition: math.h:43
vector v_forward
Definition: math.h:45
void makevectors(vector angles)
Definition: math.h:48
float flags
Definition: sound.h:113
string target
Definition: defs.h:23
Vector Math Helper Functions.
float(float modidx, string framename) frameforname
string __fullspawndata
Definition: defs.h:121
vector Route_GetJumpVelocity(vector vecFrom, vector vecTo, float flGravMod)
Definition: defs.h:553
const vector VEC_HULL_MIN
Definition: defs.h:158
noref float input_sequence
Definition: defs.h:261
@ SEARCH_MULTISEARCH
Definition: defs.h:193
@ SEARCH_FORCESEARCH
Definition: defs.h:192
@ SEARCH_NAMESORT
Definition: defs.h:194
@ SEARCH_FULLPACKAGE
Definition: defs.h:190
@ SEARCH_INSENSITIVE
Definition: defs.h:189
@ SEARCH_ALLOWDUPES
Definition: defs.h:191
__wrap void remove(entity target)
Definition: defs.h:359
__wrap void dprint(string m)
Definition: defs.h:214
float identity
Definition: defs.h:356
void DebugBox(vector absPos, vector minSize, vector maxSize, vector boxColor, float boxAlpha)
Definition: defs.h:604
noref const float SVC_TEMPENTITY
Definition: defs.h:72
__wrap void setmodel(entity ent, string mname)
Definition: defs.h:334
float pseudorandom()
Definition: defs.h:263
float gflags
Definition: defs.h:200
float teleport_time
Definition: defs.h:198
bool FileExists(string filePath)
Definition: defs.h:594
void crossprint(string m)
Definition: defs.h:221
__wrap __variant * memalloc(int size)
Definition: defs.h:345
const vector VEC_CHULL_MAX
Definition: defs.h:161
bool Util_IsSingleplayer(void)
Definition: defs.h:489
__wrap string precache_sound(string sample)
Definition: defs.h:249
string Util_FixModel(string mdl)
Definition: defs.h:434
float crandom(void)
Definition: defs.h:506
bool Util_IsTeamplay(void)
Definition: util.qc:56
float removed
Definition: defs.h:357
__wrap void traceline(vector v1, vector v2, float flags, entity ent)
Definition: defs.h:379
const vector VEC_HULL_MAX
Definition: defs.h:159
string textfile_to_string(string filename)
Definition: defs.h:532
float jumptime
Definition: defs.h:197
void Empty(void)
Definition: defs.h:203
vector basevelocity
Definition: defs.h:199
const vector VEC_CHULL_MIN
Definition: defs.h:160
void setorigin_safe(entity target, vector testorg)
Definition: defs.h:403
void Util_Destroy(void)
Definition: util.qc:28
string Util_TimeToString(float fTime)
Definition: util.qc:34
entity id
Definition: defs.h:17
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:468
string dirname(string input)
Definition: defs.h:512