Nuclide
Software Development Kit for id Technology (BETA)
defs.h
1/*
2 * Copyright (c) 2016-2021 Marco Cawthorne <marco@icculus.org>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
13 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
14 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#include "api_func.h"
18#include "../shared/api.h"
19#include "../shared/system/entityDef.h"
20#include "ServerGame.h"
21#include "Output.h"
22#include "GameRules.h"
23#include "GameRules_Editor.h"
24#include "GameRules_Home.h"
25#include "GameRules_SinglePlayer.h"
26#include "GameRules_DevShutterbug.h"
27#include "SkillManager.h"
28#include "Stats.h"
29
30#include "../nav/linkflags.h"
31#include "../nav/nodes.h"
32#include "../nav/route.h"
33#include "../nav/NodeEditor.h"
34#include "../nav/way_convert.h"
35#include "../nav/NavInfo.h"
36#include "../nav/Hint.h"
37
38#include "SpawnManager.h"
39#include "AddonDelegate.h"
40#include "AddonManager.h"
41#include "MapDelegate.h"
42#include "AntiCheat.h"
43#include "VoteManager.h"
44#include "MapCycle.h"
45#include "MapTweaks.h"
46#include "Schedule.h"
47#include "SessionManager.h"
48
49#include "CapturePoint.h"
50#include "CaptureItem.h"
51#include "Auth.h"
52
53/* helper macros */
54#define EVALUATE_FIELD(fieldname, changedflag) {\
55 if (ATTR_CHANGED(fieldname)) {\
56 SetSendFlags(changedflag);\
57 }\
58 SAVE_STATE(fieldname);\
59}
60
61#define EVALUATE_VECTOR(fieldname, idx, changedflag) {\
62 if (VEC_CHANGED(fieldname, idx)) {\
63 SetSendFlags(changedflag);\
64 }\
65 SAVE_STATE_FIELD(fieldname, idx);\
66}
67
68#define SENDENTITY_BYTE(field, changedflag) {\
69 if (flChanged & changedflag)\
70 WriteByte(MSG_ENTITY, field);\
71}
72
73#define SENDENTITY_SHORT(field, changedflag) {\
74 if (flChanged & changedflag)\
75 WriteShort(MSG_ENTITY, field);\
76}
77
78#define SENDENTITY_INT(field, changedflag) {\
79 if (flChanged & changedflag)\
80 WriteInt(MSG_ENTITY, field);\
81}
82
83#define SENDENTITY_FLOAT(field, changedflag) {\
84 if (flChanged & changedflag)\
85 WriteFloat(MSG_ENTITY, field);\
86}
87
88#define SENDENTITY_STRING(field, changedflag) {\
89 if (flChanged & changedflag)\
90 WriteString(MSG_ENTITY, field);\
91}
92
93#define SENDENTITY_COORD(field, changedflag) {\
94 if (flChanged & changedflag)\
95 WriteCoord(MSG_ENTITY, field);\
96}
97
98#define SENDENTITY_ANGLE(field, changedflag) {\
99 if (flChanged & changedflag)\
100 WriteAngle(MSG_ENTITY, field);\
101}
102
103#define SENDENTITY_ENTITY(field, changedflag) {\
104 if (flChanged & changedflag)\
105 WriteEntity(MSG_ENTITY, field);\
106}
107
108#define SENDENTITY_COLOR(field, changedflag) {\
109 if (flChanged & changedflag)\
110 WriteByte(MSG_ENTITY, field * 255.0);\
111}
112
113#define SENDENTITY_MODELINDEX(field, changedflag) {\
114 if (flChanged & changedflag)\
115 WriteShort(MSG_ENTITY, field);\
116}
117
118var bool g_isloading = false;
119
120var bool autocvar_mp_flashlight = true;
121
122void Client_FixAngle(entity, vector);
123void Client_ShakeOnce(vector, float, float, float, float);
124
125void Mapcycle_Load(string);
126
127ncEntity eActivator;
128
129/* Generic entity fields */
130.void(void) PlayerUse;
131.void(void) PlayerUseUnpressed;
132.bool iBleeds;
133.bool ruleSendInventory;
134.entity eUser;
135.float material;
136.float deaths;
137
138/* in idTech the .owner field causes collisions to fail against set entity,
139 * we don't want this all of the time. so use this as a fallback */
140.entity real_owner;
141
142int trace_surfaceflagsi;
143string startspot;
144string __fullspawndata;
145
146var bool g_ents_initialized = false;
147
148/* main is a qcc leftover */
149void main(void)
150{
151}
152
153#define SAVE_DECIMAL(x,y,z) fputs(x, sprintf("%S \"%d\" ", y, z))
154#define SAVE_INTEGER(x,y,z) fputs(x, sprintf("%S \"%i\" ", y, z))
155#define SAVE_FLOAT(x,y,z) fputs(x, sprintf("%S \"%f\" ", y, z))
156#define SAVE_VECTOR(x,y,z) fputs(x, sprintf("%S \"%v\" ", y, z))
157#define SAVE_STRING(x,y,z) fputs(x, sprintf("%S \"%s\" ", y, z))
158#define SAVE_HEX(x,y,z) fputs(x, sprintf("%S \"%x\" ", y, z))
159
160
166ncEntity EntityDef_SpawnClassname(string className);
167
168
172ncEntity EntityDef_CreateClassname(string className);
173
184ncEntity Entity_CreateClass(string className);
185
191bool EntityDef_HasSpawnClass(string className);
192
193
198string EntityDef_GetKeyValue(string className, string keyName);
199
200void
201WriteEntityEvent(float to, entity targetEntity, float eventType)
202{
203 WriteByte(to, SVC_CGAMEPACKET);
204 WriteByte(to, EV_ENTITYEVENT);
205 WriteEntity(to, targetEntity);
206 WriteFloat(to, eventType);
207}
208
209void
210CallFunctionAsEntity(entity targetEntity, void(void) functionToCall)
211{
212 if (!functionToCall) {
213 breakpoint();
214 ncError("Invalid function call");
215 return;
216 }
217
218 if (!targetEntity) {
219 breakpoint();
220 ncError("Invalid target entity");
221 return;
222 }
223
224 entity oldSelf = self;
225 self = targetEntity;
226 functionToCall();
227 self = oldSelf;
228}
229
ncEntity is the lowest of the user-accessible entity class.
Definition: Entity.h:75
var materialAPI_t material
Access atlasPicAPI_t functions using this variable.
Definition: api_func.h:569
string EntityDef_GetKeyValue(string, string)
Retrieves the value of a specific key defined within an EntityDef.
Definition: entityDef.qc:275
bool EntityDef_HasSpawnClass(string className)
Checks if an entity class was defined in an EntityDef.
Definition: entityDef.qc:682
ncEntity Entity_CreateClass(string className)
Always returns a valid entity.
Definition: entityDef.qc:668
void Mapcycle_Load(string)
Can be called by the server game to override the current mapcycle with that of a custom mapcycle file...
Definition: MapCycle.qc:18