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;
24#define NETWORKED_MODELINDEX(x) float x; float x ##_net;
26#define NETWORKED_INT_N(x) int x ##_net;
27#define NETWORKED_FLOAT_N(x) float x ##_net;
28#define NETWORKED_VECTOR_N(x) vector x ##_net;
29#define NETWORKED_STRING_N(x) string x ##_net;
31#define PREDICTED_INT(x) int x; int x ##_net;
32#define PREDICTED_FLOAT(x) float x; float x ##_net;
33#define PREDICTED_VECTOR(x) vector x; vector x ##_net;
34#define PREDICTED_ENT(x) entity x; entity x ##_net;
35#define PREDICTED_STRING(x) string x; string x ##_net;
36#define PREDICTED_BOOL(x) bool x; bool x ##_net;
38#define PREDICTED_INT_N(x) int x ##_net;
39#define PREDICTED_FLOAT_N(x) float x ##_net;
40#define PREDICTED_VECTOR_N(x) vector x ##_net;
41#define PREDICTED_STRING_N(x) string x ##_net;
44var
bool autocvar_net_showArrivals =
false;
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); \
53 if (autocvar_net_showArrivals)\
54 ncError("New entity appeared to client: %S", 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;
84#include "system/ConstantManager.h"
85#include "audio/soundDef.h"
86#include "environment/effects.h"
89#include "../gs-entbase/client/defs.h"
91#include "../gs-entbase/server/defs.h"
94#include "environment/Decal.h"
96#include "audio/sentences.h"
98#include "system/Dict.h"
99#include "audio/SoundDict.h"
100#include "system/IO.h"
101#include "system/Trigger.h"
102#include "system/Entity.h"
103#include "system/Timer.h"
104#include "system/RenderableEntity.h"
105#include "environment/SurfacePropEntity.h"
106#include "physics/Ragdoll.h"
107#include "environment/Mover.h"
108#include "physics/PhysicsConstraint.h"
109#include "physics/PhysicsEntity.h"
110#include "triggers/BrushTrigger.h"
111#include "triggers/PointTrigger.h"
112#include "game/Item.h"
113#include "game/Dispenser.h"
114#include "game/Weapon.h"
115#include "game/Actor.h"
116#include "ai/Monster.h"
117#include "ai/SquadMonster.h"
118#include "ai/TalkMonster.h"
119#include "game/SpawnPoint.h"
120#include "audio/SoundScape.h"
121#include "game/Attack.h"
122#include "game/Projectile.h"
123#include "environment/Spraylogo.h"
124#include "physics/Portal.h"
125#include "audio/Sound.h"
126#include "physics/Debris.h"
127#include "input/InteractiveSurface.h"
128#include "input/XRSpace.h"
129#include "input/XRInput.h"
130#include "input/XRManager.h"
131#include "../botlib/Bot.h"
132#include "game/Client.h"
133#include "game/Spectator.h"
134#include "physics/pmove.h"
135#include "game/Player.h"
136#include "physics/Vehicle.h"
137#include "environment/materials.h"
138#include "environment/damage.h"
139#include "game/entities.h"
140#include "game/hitmesh.h"
141#include "environment/propdata.h"
142#include "environment/surfaceproperties.h"
143#include "environment/decalgroups.h"
144#include "environment/DeadBody.h"
145#include "game/motd.h"
146#include "system/util.h"
147#include "game/AmmoManager.h"
148#include "system/ActivityManager.h"
149#include "environment/BreakableBrushManager.h"
150#include "electronics/AVTransmitter.h"
151#include "electronics/AVReceiver.h"
152#include "electronics/VideoDisplay.h"
153#include "electronics/SecurityCamera.h"
155#define BSPVER_PREREL 28
161#define BSPVER_RTCW 47
164#define CLASSEXPORT(a,b) void a(void) { if (!isfunction(#b)) { self.classname = strcat("spawnfunc_", #b); } else { self.classname = #b; } callfunction(self.classname); }
166const vector VEC_HULL_MIN = [-16,-16,-36];
167const vector VEC_HULL_MAX = [16,16,36];
168const vector VEC_CHULL_MIN = [-16,-16,-18];
169const vector VEC_CHULL_MAX = [16,16,18];
171#include "input/input.h"
174#define UPDATE_ALL 16777215
176#define clamp(d,min,max) bound(min,d,max)
188.vector m_pmoveBaseVelocity;
201void Util_Destroy(
void);
202string Util_TimeToString(
float fTime);
203bool Util_IsTeamplay(
void);
204bool Util_IsPaused(
void);
210 print(strcat(
"CLIENT: ", m));
212 print(strcat(
"SERVER: ", m));
218precache_model(
string m)
220 if (!STRING_SET(m)) {
229precache_sound(
string sample)
232 if not(whichpack(strcat(
"sound/", sample))) {
233 ncError(
"SFX sample %S does not exist.", sample);
234 return "misc/missing.wav";
237 return prior(sample);
241noref
float input_sequence;
245 float seed = (float)input_sequence % 5.0f;
246 seed += (float)input_sequence % 8.0f;
247 seed += (float)input_sequence % 4.0f;
248 seed += (float)input_sequence % 13.0f;
249 seed += (float)input_sequence % 70.0f;
252 return bound(0.01, (seed) / 100.0f, 0.99f);
257WriteByte(
float to,
float val)
264WriteChar(
float to,
float val)
271WriteShort(
float to,
float val)
278WriteLong(
float to,
float val)
285WriteCoord(
float to,
float val)
292WriteAngle(
float to,
float val)
299WriteString(
float to,
string val)
306WriteEntity(
float to, entity val)
314setmodel(entity ent,
string mname)
317 if (substring(mname, 0, 1) !=
"*")
318 if not(whichpack(mname))
319 return prior(ent,
"models/error.vvm");
321 return prior(ent, mname);
329 if (target.identity) {
333 if (ent.removed == 0) {
334 ent.OnRemoveEntity();
336 print(sprintf(
"^1WARNING: Entity %d of class %s uncleanly removed!\n", num_for_edict(ent), ent.classname));
345traceline(vector v1, vector v2,
float flags, entity ent)
348 if (autocvar(com_showTracers, 0) == 1) {
349 WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
350 WriteByte(MSG_MULTICAST, EV_TRACEDEBUG);
351 WriteCoord(MSG_MULTICAST, v1[0]);
352 WriteCoord(MSG_MULTICAST, v1[1]);
353 WriteCoord(MSG_MULTICAST, v1[2]);
354 WriteCoord(MSG_MULTICAST, v2[0]);
355 WriteCoord(MSG_MULTICAST, v2[1]);
356 WriteCoord(MSG_MULTICAST, v2[2]);
358 multicast(v1, MULTICAST_PVS_R);
365 prior(v1, v2,
flags, ent);
369string Skill_GetStringValue(
string,
string);
373unpackStringCommand(
string commandString)
377 if (substring(commandString, 0, 6) ==
"skill:") {
378 return Skill_GetStringValue(substring(commandString, 6, -1),
"");
381 if (substring(commandString, 0, 5) ==
"cvar:") {
382 return cvar_string(substring(commandString, 5, -1));
396void(
string cmd) readcmd = #0:readcmd;
405string Util_FixModel(
string mdl)
407 if (!STRING_SET(mdl)) {
410 mdl = strreplace(
"\\",
"/", mdl);
413 mdl = strreplace(
"//",
"/", mdl);
415 int c = tokenizebyseparator(mdl,
"/",
"\\ ",
"!");
418 for (
int i = 0; i < c; i++) {
419 newpath = sprintf(
"%s/%s", newpath, argv(i));
423 newpath = substring(newpath, 1, strlen(newpath)-1);
426 c = tokenizebyseparator(newpath,
"\\/");
428 for (
int i = 0; i < c; i++) {
429 mdl = sprintf(
"%s/%s", mdl, argv(i));
432 mdl = substring(mdl, 1, strlen(mdl)-1);
434 if (substring(mdl, 0, 1) ==
"/")
435 mdl = substring(mdl, 1, -1);
437 mdl = strreplace(
"/ ",
"/", mdl);
446Util_ChangeExtension(
string baseString,
string newExtension)
448 float stringOffset = 0;
449 string tempString =
"";
450 float foundOffset = 0;
452 while ((tempString = substring(baseString, stringOffset, 1))) {
453 if (tempString ==
".")
454 foundOffset = stringOffset;
455 if (tempString ==
"")
464 if (foundOffset == 0) {
465 return strcat(baseString,
".", newExtension);
468 return strcat(substring(baseString, 0, foundOffset),
".", newExtension);
472Util_IsSingleplayer(
void)
476 if (cvar(
"sv_playerslots") == 1)
480 if (cvar(
"coop") == 1 && cvar(
"sv_playerslots") > 1)
491 return ((random() - 0.5f) * 2.0f);
501 int c = tokenizebyseparator(input,
"/",
"\\ ",
"!");
504 for (
int i = 0; i < (c-1); i++) {
505 newpath = sprintf(
"%s/%s", newpath, argv(i));
509 newpath = substring(newpath, 1, strlen(newpath)-1);
515textfile_to_string(
string filename)
517 string fileContents = __NULL__;
519 filestream fileHandle = fopen(filename, FILE_READ);
522 if (fileHandle != -1) {
523 while ((temp = fgets(fileHandle))) {
524 fileContents = strcat(fileContents, temp,
"\n");
527 fileContents = __NULL__;
539 float flHeight, flGravity, flTime, flDistance, flDir;
540 vector vecJump = [0,0,0];
542 if (flGravMod <= 0.0)
545 flGravity = 800 * flGravMod;
546 flHeight = vecTo[2] - vecFrom[2];
550 flHeight = vlen(vecTo - vecFrom);
551 flTime = flHeight / flGravity;
553 flTime = sqrt(flHeight / (flGravity * 0.5f));
559 vecJump = vecTo - vecFrom;
561 flDistance = vlen(normalize(vecJump));
563 flDir = flDistance / flTime;
565 vecJump[2] = flTime * flGravity;
567 vector vecJump = [0,0,0];
568 float flDist = vlen(vecTo - vecFrom);
569 makevectors(vectoangles(vecTo - vecFrom));
570 vecJump = v_forward * flDist;
577DebugBox(vector absPos, vector minSize, vector maxSize, vector boxColor,
float boxAlpha)
582 a[0] = absPos[0] + minSize[0];
583 a[1] = absPos[1] + maxSize[1];
585 b[0] = absPos[0] + maxSize[0];
586 b[1] = absPos[1] + maxSize[1];
588 c[0] = absPos[0] + maxSize[0];
589 c[1] = absPos[1] + minSize[1];
591 d[0] = absPos[0] + minSize[0];
592 d[1] = absPos[1] + minSize[1];
594 a[2] = absPos[2] + maxSize[2];
595 c[2] = absPos[2] + maxSize[2];
596 d[2] = absPos[2] + maxSize[2];
597 b[2] = absPos[2] + maxSize[2];
604 w[2] = absPos[2] + minSize[2];
605 x[2] = absPos[2] + minSize[2];
606 y[2] = absPos[2] + minSize[2];
607 z[2] = absPos[2] + minSize[2];
610 R_BeginPolygon(
"", 0, 0);
611 R_PolygonVertex(a, [1,1], boxColor, boxAlpha);
612 R_PolygonVertex(b, [0,1], boxColor, boxAlpha);
613 R_PolygonVertex(c, [0,0], boxColor, boxAlpha);
614 R_PolygonVertex(d, [1,0], boxColor, boxAlpha);
618 R_BeginPolygon(
"", 0, 0);
619 R_PolygonVertex(d, [1,1], boxColor * 0.9f, boxAlpha);
620 R_PolygonVertex(c, [0,1], boxColor * 0.9f, boxAlpha);
621 R_PolygonVertex(y, [0,0], boxColor * 0.9f, boxAlpha);
622 R_PolygonVertex(z, [1,0], boxColor * 0.9f, boxAlpha);
626 R_BeginPolygon(
"", 0, 0);
627 R_PolygonVertex(w, [1,1], boxColor * 0.9f, boxAlpha);
628 R_PolygonVertex(x, [0,1], boxColor * 0.9f, boxAlpha);
629 R_PolygonVertex(b, [0,0], boxColor * 0.9f, boxAlpha);
630 R_PolygonVertex(a, [1,0], boxColor * 0.9f, boxAlpha);
634 R_BeginPolygon(
"", 0, 0);
635 R_PolygonVertex(a, [1,1], boxColor * 0.8f, boxAlpha);
636 R_PolygonVertex(d, [0,1], boxColor * 0.8f, boxAlpha);
637 R_PolygonVertex(z, [0,0], boxColor * 0.8f, boxAlpha);
638 R_PolygonVertex(w, [1,0], boxColor * 0.8f, boxAlpha);
642 R_BeginPolygon(
"", 0, 0);
643 R_PolygonVertex(c, [1,1], boxColor * 0.8f, boxAlpha);
644 R_PolygonVertex(b, [0,1], boxColor * 0.8f, boxAlpha);
645 R_PolygonVertex(x, [0,0], boxColor * 0.8f, boxAlpha);
646 R_PolygonVertex(y, [1,0], boxColor * 0.8f, boxAlpha);
650 R_BeginPolygon(
"", 0, 0);
651 R_PolygonVertex(z, [1,1], boxColor, boxAlpha);
652 R_PolygonVertex(y, [0,1], boxColor, boxAlpha);
653 R_PolygonVertex(x, [0,0], boxColor, boxAlpha);
654 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: ConstantManager.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:536
float flags
Definition: soundDef.h:114