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/cloader.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"
99#include "system/Dict.h"
100#include "audio/SoundDict.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/XRSpace.h"
128#include "input/XRInput.h"
129#include "input/XRManager.h"
130#include "../botlib/Bot.h"
131#include "game/Client.h"
132#include "game/Spectator.h"
133#include "physics/pmove.h"
134#include "game/Player.h"
136#include "physics/Vehicle.h"
138#include "environment/materials.h"
139#include "environment/damage.h"
140#include "game/entities.h"
141#include "game/hitmesh.h"
142#include "environment/propdata.h"
143#include "environment/surfaceproperties.h"
144#include "environment/decalgroups.h"
145#include "environment/bodyque.h"
146#include "game/motd.h"
147#include "system/util.h"
148#include "game/ammo.h"
149#include "system/activities.h"
151#define BSPVER_PREREL 28
157#define BSPVER_RTCW 47
160#define CLASSEXPORT(a,b) void a(void) { if (!isfunction(#b)) { self.classname = strcat("spawnfunc_", #b); } else { self.classname = #b; } callfunction(self.classname); }
162const vector VEC_HULL_MIN = [-16,-16,-36];
163const vector VEC_HULL_MAX = [16,16,36];
164const vector VEC_CHULL_MIN = [-16,-16,-18];
165const vector VEC_CHULL_MAX = [16,16,18];
167#include "input/input.h"
170#define UPDATE_ALL 16777215
172#define clamp(d,min,max) bound(min,d,max)
184.vector m_pmoveBaseVelocity;
197void Util_Destroy(
void);
198string Util_TimeToString(
float fTime);
199bool Util_IsTeamplay(
void);
200bool Util_IsPaused(
void);
206 print(strcat(
"CLIENT: ", m));
208 print(strcat(
"SERVER: ", m));
214precache_model(
string m)
216 if (!STRING_SET(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);
325 if (target.identity) {
329 if (ent.removed == 0) {
330 ent.OnRemoveEntity();
332 print(sprintf(
"^1WARNING: Entity %d of class %s uncleanly removed!\n", num_for_edict(ent), ent.classname));
341traceline(vector v1, vector v2,
float flags, entity ent)
344 if (autocvar(com_showTracers, 0) == 1) {
345 WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
346 WriteByte(MSG_MULTICAST, EV_TRACEDEBUG);
347 WriteCoord(MSG_MULTICAST, v1[0]);
348 WriteCoord(MSG_MULTICAST, v1[1]);
349 WriteCoord(MSG_MULTICAST, v1[2]);
350 WriteCoord(MSG_MULTICAST, v2[0]);
351 WriteCoord(MSG_MULTICAST, v2[1]);
352 WriteCoord(MSG_MULTICAST, v2[2]);
354 multicast(v1, MULTICAST_PVS_R);
361 prior(v1, v2,
flags, ent);
365string Skill_GetStringValue(
string,
string);
369unpackStringCommand(
string commandString)
373 if (substring(commandString, 0, 6) ==
"skill:") {
374 return Skill_GetStringValue(substring(commandString, 6, -1),
"");
377 if (substring(commandString, 0, 5) ==
"cvar:") {
378 return cvar_string(substring(commandString, 5, -1));
392void(
string cmd) readcmd = #0:readcmd;
401string Util_FixModel(
string mdl)
403 if (!STRING_SET(mdl)) {
406 mdl = strreplace(
"\\",
"/", mdl);
409 mdl = strreplace(
"//",
"/", mdl);
411 int c = tokenizebyseparator(mdl,
"/",
"\\ ",
"!");
414 for (
int i = 0; i < c; i++) {
415 newpath = sprintf(
"%s/%s", newpath, argv(i));
419 newpath = substring(newpath, 1, strlen(newpath)-1);
422 c = tokenizebyseparator(newpath,
"\\/");
424 for (
int i = 0; i < c; i++) {
425 mdl = sprintf(
"%s/%s", mdl, argv(i));
428 mdl = substring(mdl, 1, strlen(mdl)-1);
430 if (substring(mdl, 0, 1) ==
"/")
431 mdl = substring(mdl, 1, -1);
433 mdl = strreplace(
"/ ",
"/", mdl);
442Util_ChangeExtension(
string baseString,
string newExtension)
444 float stringOffset = 0;
445 string tempString =
"";
446 float foundOffset = 0;
448 while ((tempString = substring(baseString, stringOffset, 1))) {
449 if (tempString ==
".")
450 foundOffset = stringOffset;
451 if (tempString ==
"")
460 if (foundOffset == 0) {
461 return strcat(baseString,
".", newExtension);
464 return strcat(substring(baseString, 0, foundOffset),
".", newExtension);
468Util_IsSingleplayer(
void)
472 if (cvar(
"sv_playerslots") == 1)
476 if (cvar(
"coop") == 1 && cvar(
"sv_playerslots") > 1)
487 return ((random() - 0.5f) * 2.0f);
497 int c = tokenizebyseparator(input,
"/",
"\\ ",
"!");
500 for (
int i = 0; i < (c-1); i++) {
501 newpath = sprintf(
"%s/%s", newpath, argv(i));
505 newpath = substring(newpath, 1, strlen(newpath)-1);
511textfile_to_string(
string filename)
513 string fileContents = __NULL__;
515 filestream fileHandle = fopen(filename, FILE_READ);
518 if (fileHandle != -1) {
519 while ((temp = fgets(fileHandle))) {
520 fileContents = strcat(fileContents, temp,
"\n");
523 fileContents = __NULL__;
535 float flHeight, flGravity, flTime, flDistance, flDir;
536 vector vecJump = [0,0,0];
538 if (flGravMod <= 0.0)
541 flGravity = serverkeyfloat(
"phy_gravity") * flGravMod;
542 flHeight = vecTo[2] - vecFrom[2];
546 flHeight = vlen(vecTo - vecFrom);
547 flTime = flHeight / flGravity;
549 flTime = sqrt(flHeight / (flGravity * 0.5f));
555 vecJump = vecTo - vecFrom;
557 flDistance = vlen(normalize(vecJump));
559 flDir = flDistance / flTime;
561 vecJump[2] = flTime * flGravity;
563 vector vecJump = [0,0,0];
564 float flDist = vlen(vecTo - vecFrom);
565 makevectors(vectoangles(vecTo - vecFrom));
566 vecJump = v_forward * flDist;
573DebugBox(vector absPos, vector minSize, vector maxSize, vector boxColor,
float boxAlpha)
578 a[0] = absPos[0] + minSize[0];
579 a[1] = absPos[1] + maxSize[1];
581 b[0] = absPos[0] + maxSize[0];
582 b[1] = absPos[1] + maxSize[1];
584 c[0] = absPos[0] + maxSize[0];
585 c[1] = absPos[1] + minSize[1];
587 d[0] = absPos[0] + minSize[0];
588 d[1] = absPos[1] + minSize[1];
590 a[2] = absPos[2] + maxSize[2];
591 c[2] = absPos[2] + maxSize[2];
592 d[2] = absPos[2] + maxSize[2];
593 b[2] = absPos[2] + maxSize[2];
600 w[2] = absPos[2] + minSize[2];
601 x[2] = absPos[2] + minSize[2];
602 y[2] = absPos[2] + minSize[2];
603 z[2] = absPos[2] + minSize[2];
606 R_BeginPolygon(
"", 0, 0);
607 R_PolygonVertex(a, [1,1], boxColor, boxAlpha);
608 R_PolygonVertex(b, [0,1], boxColor, boxAlpha);
609 R_PolygonVertex(c, [0,0], boxColor, boxAlpha);
610 R_PolygonVertex(d, [1,0], boxColor, boxAlpha);
614 R_BeginPolygon(
"", 0, 0);
615 R_PolygonVertex(d, [1,1], boxColor * 0.9f, boxAlpha);
616 R_PolygonVertex(c, [0,1], boxColor * 0.9f, boxAlpha);
617 R_PolygonVertex(y, [0,0], boxColor * 0.9f, boxAlpha);
618 R_PolygonVertex(z, [1,0], boxColor * 0.9f, boxAlpha);
622 R_BeginPolygon(
"", 0, 0);
623 R_PolygonVertex(w, [1,1], boxColor * 0.9f, boxAlpha);
624 R_PolygonVertex(x, [0,1], boxColor * 0.9f, boxAlpha);
625 R_PolygonVertex(b, [0,0], boxColor * 0.9f, boxAlpha);
626 R_PolygonVertex(a, [1,0], boxColor * 0.9f, boxAlpha);
630 R_BeginPolygon(
"", 0, 0);
631 R_PolygonVertex(a, [1,1], boxColor * 0.8f, boxAlpha);
632 R_PolygonVertex(d, [0,1], boxColor * 0.8f, boxAlpha);
633 R_PolygonVertex(z, [0,0], boxColor * 0.8f, boxAlpha);
634 R_PolygonVertex(w, [1,0], boxColor * 0.8f, boxAlpha);
638 R_BeginPolygon(
"", 0, 0);
639 R_PolygonVertex(c, [1,1], boxColor * 0.8f, boxAlpha);
640 R_PolygonVertex(b, [0,1], boxColor * 0.8f, boxAlpha);
641 R_PolygonVertex(x, [0,0], boxColor * 0.8f, boxAlpha);
642 R_PolygonVertex(y, [1,0], boxColor * 0.8f, boxAlpha);
646 R_BeginPolygon(
"", 0, 0);
647 R_PolygonVertex(z, [1,1], boxColor, boxAlpha);
648 R_PolygonVertex(y, [0,1], boxColor, boxAlpha);
649 R_PolygonVertex(x, [0,0], boxColor, boxAlpha);
650 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
vector Route_GetJumpVelocity(vector, vector, float)
Definition defs.h:532
float flags
Definition soundDef.h:114