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;
25#define NETWORKED_ENTITY(x) entity x; entity x ##_net;
27#define NETWORKED_INT_N(x) int x ##_net;
28#define NETWORKED_FLOAT_N(x) float x ##_net;
29#define NETWORKED_VECTOR_N(x) vector x ##_net;
30#define NETWORKED_ENT_N(x) entity x ##_net;
31#define NETWORKED_STRING_N(x) string x ##_net;
32#define NETWORKED_BOOL_N(x) bool x ##_net;
33#define NETWORKED_MODELINDEX_N(x) float x ##_net;
34#define NETWORKED_ENTITY_N(x) entity x ##_net;
37var
bool autocvar_net_showArrivals =
false;
39#define NSENTITY_READENTITY(x, y) \
41 local x x ##_e = ( x )self;\
42 local float x ##receivedFlags;\
44 self.classname = strcat("spawnfunc_", #x); \
45 callfunction(self.classname); \
46 if (autocvar_net_showArrivals)\
47 ncError("New entity appeared to client: %S", self.classname);\
50 x ##receivedFlags = readfloat();\
51 x ##_e.ReceiveEntity( y, x ##receivedFlags );\
53 x ##_e._ReceiveComplete( y, x ##receivedFlags );\
59#define NETWORKED_DEFAULT(x, y) x ##_net = x = y;
61#define ROLL_BACK(x) x = x ##_net;
62#define SAVE_STATE(x) x ##_net = x;
63#define SAVE_STATE_FIELD(x, y) x ##_net[y] = x[y];
64#define ATTR_CHANGED(x) (x ##_net != x)
65#define VEC_CHANGED(x,y) (x ##_net[y] != x[y])
66#define OUTPUT_ALLOC(x) if (STRING_SET(x)) { x = CreateOutput(x); }
69#define MAX_AMMO_TYPES 16i
72noref
const float SVC_TEMPENTITY = 23;
75string __fullspawndata;
78#include "system/ConstantManager.h"
79#include "audio/soundDef.h"
80#include "environment/effects.h"
83#include "../gs-entbase/client/defs.h"
85#include "../gs-entbase/server/defs.h"
88#include "environment/Decal.h"
90#include "audio/sentences.h"
92#include "system/Dict.h"
93#include "audio/SoundDict.h"
95#include "system/Trigger.h"
96#include "system/Entity.h"
97#include "system/Timer.h"
98#include "system/RenderableEntity.h"
99#include "environment/SurfacePropEntity.h"
100#include "physics/Ragdoll.h"
101#include "environment/Mover.h"
102#include "physics/PhysicsConstraint.h"
103#include "physics/PhysicsEntity.h"
104#include "triggers/BrushTrigger.h"
105#include "triggers/PointTrigger.h"
106#include "environment/Zone.h"
107#include "environment/ZoneManager.h"
108#include "game/Item.h"
109#include "game/Dispenser.h"
110#include "game/Weapon.h"
111#include "system/AnimationManager.h"
112#include "game/Actor.h"
113#include "system/AnimationSkeleton.h"
114#include "ai/Monster.h"
115#include "ai/SquadMonster.h"
116#include "ai/TalkMonster.h"
117#include "game/SpawnPoint.h"
118#include "audio/SoundScape.h"
119#include "game/Attack.h"
120#include "game/Projectile.h"
121#include "user/UserEntity_Graffiti.h"
122#include "physics/Portal.h"
123#include "audio/Sound.h"
124#include "physics/Debris.h"
125#include "input/XRSpace.h"
126#include "input/XRInput.h"
127#include "input/XRManager.h"
128#include "../botlib/Bot.h"
129#include "game/Client.h"
130#include "game/Spectator.h"
131#include "physics/PMoveVars.h"
132#include "game/Player.h"
133#include "physics/Vehicle.h"
134#include "environment/materials.h"
135#include "environment/damage.h"
136#include "game/entities.h"
137#include "game/hitmesh.h"
138#include "environment/propdata.h"
139#include "environment/surfaceproperties.h"
140#include "environment/decalgroups.h"
141#include "environment/DeadBody.h"
142#include "game/motd.h"
143#include "system/util.h"
144#include "game/AmmoManager.h"
145#include "system/ActivityManager.h"
146#include "environment/BreakableBrushManager.h"
147#include "electronics/MediaSource.h"
148#include "electronics/MediaSurface.h"
149#include "electronics/XTerminal.h"
150#include "electronics/ComputerDesktop.h"
151#include "input/InteractiveSurface.h"
152#include "electronics/AVTransmitter.h"
153#include "electronics/AVReceiver.h"
154#include "electronics/VideoDisplay.h"
155#include "electronics/Camera.h"
156#include "electronics/SecurityCamera.h"
157#include "electronics/AudioDict.h"
158#include "electronics/VideoDict.h"
159#include "electronics/MailDict.h"
160#include "electronics/InputDevice.h"
161#include "user/UserEntityManager.h"
162#include "user/UserEntity.h"
163#include "user/UserEntity_Video.h"
164#include "user/UserEntity_Audio.h"
165#include "user/UserEntity_Picture.h"
166#include "user/UserEntity_URL.h"
167#include "user/UserEntity_GameEntity.h"
168#include "user/UserEntity_Object.h"
170#define BSPVER_PREREL 28
176#define BSPVER_RTCW 47
179#define CLASSEXPORT(a,b) void a(void) { if (!isfunction(#b)) { self.classname = strcat("spawnfunc_", #b); } else { self.classname = #b; } callfunction(self.classname); }
181const vector VEC_HULL_MIN = [-16,-16,-36];
182const vector VEC_HULL_MAX = [16,16,36];
183const vector VEC_CHULL_MIN = [-16,-16,-18];
184const vector VEC_CHULL_MAX = [16,16,18];
186#include "input/input.h"
189#define UPDATE_ALL 16777215
191#define clamp(d,min,max) bound(min,d,max)
203.vector m_pmoveBaseVelocity;
216void Util_Destroy(
void);
217string Util_TimeToString(
float fTime);
218bool Util_IsTeamplay(
void);
219bool Util_IsPaused(
void);
225 print(strcat(
"CLIENT: ", m));
227 print(strcat(
"SERVER: ", m));
233precache_model(
string m)
235 if (!STRING_SET(m)) {
244precache_sound(
string sample)
247 if not(whichpack(strcat(
"sound/", sample))) {
248 ncError(
"SFX sample %S does not exist.", sample);
249 return "misc/missing.wav";
252 return prior(sample);
256noref
float input_sequence;
260 float seed = (float)input_sequence % 5.0f;
261 seed += (float)input_sequence % 8.0f;
262 seed += (float)input_sequence % 4.0f;
263 seed += (float)input_sequence % 13.0f;
264 seed += (float)input_sequence % 70.0f;
267 return bound(0.01, (seed) / 100.0f, 0.99f);
272randomWithSeed(
int seedVa)
274 float seed = (float)seedVa % 5.0f;
275 seed += (float)seedVa % 8.0f;
276 seed += (float)seedVa % 4.0f;
277 seed += (float)seedVa % 13.0f;
278 seed += (float)seedVa % 70.0f;
281 return bound(0.01, (seed) / 100.0f, 0.99f);
286WriteByte(
float to,
float val)
293WriteChar(
float to,
float val)
300WriteShort(
float to,
float val)
307WriteLong(
float to,
float val)
314WriteCoord(
float to,
float val)
321WriteAngle(
float to,
float val)
328WriteString(
float to,
string val)
335WriteEntity(
float to, entity val)
343setmodel(entity ent,
string mname)
346 if (substring(mname, 0, 1) !=
"*")
347 if not(whichpack(mname))
348 return prior(ent,
"models/error.vvm");
350 return prior(ent, mname);
358 if (target.identity) {
362 if (ent.removed == 0) {
363 ent.OnRemoveEntity();
365 print(sprintf(
"^1WARNING: Entity %d of class %s uncleanly removed!\n", num_for_edict(ent), ent.classname));
374traceline(vector v1, vector v2,
float flags, entity ent)
377 if (autocvar(com_showTracers, 0) == 1) {
378 WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
379 WriteByte(MSG_MULTICAST, EV_TRACEDEBUG);
380 WriteCoord(MSG_MULTICAST, v1[0]);
381 WriteCoord(MSG_MULTICAST, v1[1]);
382 WriteCoord(MSG_MULTICAST, v1[2]);
383 WriteCoord(MSG_MULTICAST, v2[0]);
384 WriteCoord(MSG_MULTICAST, v2[1]);
385 WriteCoord(MSG_MULTICAST, v2[2]);
387 multicast(v1, MULTICAST_PVS_R);
394 prior(v1, v2,
flags, ent);
398string Skill_GetStringValue(
string,
string);
402unpackStringCommand(
string commandString)
406 if (substring(commandString, 0, 6) ==
"skill:") {
407 return Skill_GetStringValue(substring(commandString, 6, -1),
"");
410 if (substring(commandString, 0, 5) ==
"cvar:") {
411 return cvar_string(substring(commandString, 5, -1));
415 return ncConstantManager::LookUp(commandString, commandString);
425void(
string cmd) readcmd = #0:readcmd;
434string Util_FixModel(
string mdl)
436 if (!STRING_SET(mdl)) {
439 mdl = strreplace(
"\\",
"/", mdl);
442 mdl = strreplace(
"//",
"/", mdl);
444 int c = tokenizebyseparator(mdl,
"/",
"\\ ",
"!");
447 for (
int i = 0; i < c; i++) {
448 newpath = sprintf(
"%s/%s", newpath, argv(i));
452 newpath = substring(newpath, 1, strlen(newpath)-1);
455 c = tokenizebyseparator(newpath,
"\\/");
457 for (
int i = 0; i < c; i++) {
458 mdl = sprintf(
"%s/%s", mdl, argv(i));
461 mdl = substring(mdl, 1, strlen(mdl)-1);
463 if (substring(mdl, 0, 1) ==
"/")
464 mdl = substring(mdl, 1, -1);
466 mdl = strreplace(
"/ ",
"/", mdl);
475Util_ChangeExtension(
string baseString,
string newExtension)
477 float stringOffset = 0;
478 string tempString =
"";
479 float foundOffset = 0;
481 while ((tempString = substring(baseString, stringOffset, 1))) {
482 if (tempString ==
".")
483 foundOffset = stringOffset;
484 if (tempString ==
"")
492 if (!STRING_SET(newExtension)) {
493 if (foundOffset == 0) {
494 return strcat(baseString);
497 return strcat(substring(baseString, 0, foundOffset));
501 if (foundOffset == 0) {
502 return strcat(baseString,
".", newExtension);
505 return strcat(substring(baseString, 0, foundOffset),
".", newExtension);
509Util_IsSingleplayer(
void)
513 if (cvar(
"sv_playerslots") == 1)
517 if (cvar(
"coop") == 1 && cvar(
"sv_playerslots") > 1)
526textfile_to_string(
string filename)
528 string fileContents = __NULL__;
530 filestream fileHandle = fopen(filename, FILE_READ);
533 if (fileHandle != -1) {
534 while ((temp = fgets(fileHandle))) {
535 fileContents = strcat(fileContents, temp,
"\n");
538 fileContents = __NULL__;
550 float flHeight, flGravity, flTime, flDistance, flDir;
551 vector vecJump = [0,0,0];
553 if (flGravMod <= 0.0)
556 flGravity = 800 * flGravMod;
557 flHeight = vecTo[2] - vecFrom[2];
561 flHeight = vlen(vecTo - vecFrom);
562 flTime = flHeight / flGravity;
564 flTime = sqrt(flHeight / (flGravity * 0.5f));
570 vecJump = vecTo - vecFrom;
572 flDistance = vlen(normalize(vecJump));
574 flDir = flDistance / flTime;
576 vecJump[2] = flTime * flGravity;
578 vector vecJump = [0,0,0];
579 float flDist = vlen(vecTo - vecFrom);
580 makevectors(vectoangles(vecTo - vecFrom));
581 vecJump = v_forward * flDist;
588DebugBox(vector absPos, vector minSize, vector maxSize, vector boxColor,
float boxAlpha)
593 a[0] = absPos[0] + minSize[0];
594 a[1] = absPos[1] + maxSize[1];
596 b[0] = absPos[0] + maxSize[0];
597 b[1] = absPos[1] + maxSize[1];
599 c[0] = absPos[0] + maxSize[0];
600 c[1] = absPos[1] + minSize[1];
602 d[0] = absPos[0] + minSize[0];
603 d[1] = absPos[1] + minSize[1];
605 a[2] = absPos[2] + maxSize[2];
606 c[2] = absPos[2] + maxSize[2];
607 d[2] = absPos[2] + maxSize[2];
608 b[2] = absPos[2] + maxSize[2];
615 w[2] = absPos[2] + minSize[2];
616 x[2] = absPos[2] + minSize[2];
617 y[2] = absPos[2] + minSize[2];
618 z[2] = absPos[2] + minSize[2];
621 R_BeginPolygon(
"", 0, 0);
622 R_PolygonVertex(a, [1,1], boxColor, boxAlpha);
623 R_PolygonVertex(b, [0,1], boxColor, boxAlpha);
624 R_PolygonVertex(c, [0,0], boxColor, boxAlpha);
625 R_PolygonVertex(d, [1,0], boxColor, boxAlpha);
629 R_BeginPolygon(
"", 0, 0);
630 R_PolygonVertex(d, [1,1], boxColor * 0.9f, boxAlpha);
631 R_PolygonVertex(c, [0,1], boxColor * 0.9f, boxAlpha);
632 R_PolygonVertex(y, [0,0], boxColor * 0.9f, boxAlpha);
633 R_PolygonVertex(z, [1,0], boxColor * 0.9f, boxAlpha);
637 R_BeginPolygon(
"", 0, 0);
638 R_PolygonVertex(w, [1,1], boxColor * 0.9f, boxAlpha);
639 R_PolygonVertex(x, [0,1], boxColor * 0.9f, boxAlpha);
640 R_PolygonVertex(b, [0,0], boxColor * 0.9f, boxAlpha);
641 R_PolygonVertex(a, [1,0], boxColor * 0.9f, boxAlpha);
645 R_BeginPolygon(
"", 0, 0);
646 R_PolygonVertex(a, [1,1], boxColor * 0.8f, boxAlpha);
647 R_PolygonVertex(d, [0,1], boxColor * 0.8f, boxAlpha);
648 R_PolygonVertex(z, [0,0], boxColor * 0.8f, boxAlpha);
649 R_PolygonVertex(w, [1,0], boxColor * 0.8f, boxAlpha);
653 R_BeginPolygon(
"", 0, 0);
654 R_PolygonVertex(c, [1,1], boxColor * 0.8f, boxAlpha);
655 R_PolygonVertex(b, [0,1], boxColor * 0.8f, boxAlpha);
656 R_PolygonVertex(x, [0,0], boxColor * 0.8f, boxAlpha);
657 R_PolygonVertex(y, [1,0], boxColor * 0.8f, boxAlpha);
661 R_BeginPolygon(
"", 0, 0);
662 R_PolygonVertex(z, [1,1], boxColor, boxAlpha);
663 R_PolygonVertex(y, [0,1], boxColor, boxAlpha);
664 R_PolygonVertex(x, [0,0], boxColor, boxAlpha);
665 R_PolygonVertex(w, [1,0], boxColor, boxAlpha);
ncEntity is the lowest of the user-accessible entity class.
Definition: Entity.h:75
typedef enumflags
Defines the valid alignment flags for text fields.
Definition: font.h:37
vector Route_GetJumpVelocity(vector, vector, float)
Definition: defs.h:547
float flags
Definition: soundDef.h:114