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 "skill.h"
24#include "Stats.h"
25
26#include "../nav/linkflags.h"
27#include "../nav/nodes.h"
28#include "../nav/route.h"
29#include "../nav/NodeEditor.h"
30#include "../nav/way_convert.h"
31#include "../nav/NavInfo.h"
32#include "../nav/Hint.h"
33
34#include "spawn.h"
35#include "AddonDelegate.h"
36#include "AddonManager.h"
37#include "MapDelegate.h"
38#include "plugins.h"
39#include "lament.h"
40#include "vote.h"
41#include "mapcycle.h"
42#include "maptweaks.h"
43#include "Schedule.h"
44#include "SessionManager.h"
45
46#include "CapturePoint.h"
47#include "CaptureItem.h"
48#include "Auth.h"
49
50/* helper macros */
51#define EVALUATE_FIELD(fieldname, changedflag) {\
52 if (ATTR_CHANGED(fieldname)) {\
53 SetSendFlags(changedflag);\
54 }\
55 SAVE_STATE(fieldname);\
56}
57
58#define EVALUATE_VECTOR(fieldname, idx, changedflag) {\
59 if (VEC_CHANGED(fieldname, idx)) {\
60 SetSendFlags(changedflag);\
61 }\
62 SAVE_STATE_FIELD(fieldname, idx);\
63}
64
65#define SENDENTITY_BYTE(field, changedflag) {\
66 if (flChanged & changedflag)\
67 WriteByte(MSG_ENTITY, field);\
68}
69
70#define SENDENTITY_SHORT(field, changedflag) {\
71 if (flChanged & changedflag)\
72 WriteShort(MSG_ENTITY, field);\
73}
74
75#define SENDENTITY_INT(field, changedflag) {\
76 if (flChanged & changedflag)\
77 WriteInt(MSG_ENTITY, field);\
78}
79
80#define SENDENTITY_FLOAT(field, changedflag) {\
81 if (flChanged & changedflag)\
82 WriteFloat(MSG_ENTITY, field);\
83}
84
85#define SENDENTITY_STRING(field, changedflag) {\
86 if (flChanged & changedflag)\
87 WriteString(MSG_ENTITY, field);\
88}
89
90#define SENDENTITY_COORD(field, changedflag) {\
91 if (flChanged & changedflag)\
92 WriteCoord(MSG_ENTITY, field);\
93}
94
95#define SENDENTITY_ANGLE(field, changedflag) {\
96 if (flChanged & changedflag)\
97 WriteAngle(MSG_ENTITY, field);\
98}
99
100#define SENDENTITY_ENTITY(field, changedflag) {\
101 if (flChanged & changedflag)\
102 WriteEntity(MSG_ENTITY, field);\
103}
104
105#define SENDENTITY_COLOR(field, changedflag) {\
106 if (flChanged & changedflag)\
107 WriteByte(MSG_ENTITY, field * 255.0);\
108}
109
110#define SENDENTITY_MODELINDEX(field, changedflag) {\
111 if (flChanged & changedflag)\
112 WriteShort(MSG_ENTITY, field);\
113}
114
115var bool g_isloading = false;
116
117var bool autocvar_mp_flashlight = true;
118
119void Client_FixAngle(entity, vector);
120void Client_ShakeOnce(vector, float, float, float, float);
121
122void Mapcycle_Load(string);
123
124ncEntity eActivator;
125
126/* Generic entity fields */
127.void(void) PlayerUse;
128.void(void) PlayerUseUnpressed;
129.bool iBleeds;
130.bool ruleSendInventory;
131.entity eUser;
132.float material;
133.float deaths;
134
135/* in idTech the .owner field causes collisions to fail against set entity,
136 * we don't want this all of the time. so use this as a fallback */
137.entity real_owner;
138
139int trace_surfaceflagsi;
140string startspot;
141string __fullspawndata;
142
143var bool g_ents_initialized = false;
144
145/* main is a qcc leftover */
146void main(void)
147{
148}
149
150#define SAVE_DECIMAL(x,y,z) fputs(x, sprintf("%S \"%d\" ", y, z))
151#define SAVE_INTEGER(x,y,z) fputs(x, sprintf("%S \"%i\" ", y, z))
152#define SAVE_FLOAT(x,y,z) fputs(x, sprintf("%S \"%f\" ", y, z))
153#define SAVE_VECTOR(x,y,z) fputs(x, sprintf("%S \"%v\" ", y, z))
154#define SAVE_STRING(x,y,z) fputs(x, sprintf("%S \"%s\" ", y, z))
155#define SAVE_HEX(x,y,z) fputs(x, sprintf("%S \"%x\" ", y, z))
156
157
163ncEntity EntityDef_SpawnClassname(string className);
164
165
169ncEntity EntityDef_CreateClassname(string className);
170
181ncEntity Entity_CreateClass(string className);
182
188bool EntityDef_HasSpawnClass(string className);
189
190
195string EntityDef_GetKeyValue(string className, string keyName);
196
197void
198WriteEntityEvent(float to, entity targetEntity, float eventType)
199{
200 WriteByte(to, SVC_CGAMEPACKET);
201 WriteByte(to, EV_ENTITYEVENT);
202 WriteEntity(to, targetEntity);
203 WriteFloat(to, eventType);
204}
205
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:566
string EntityDef_GetKeyValue(string, string)
Retrieves the value of a specific key defined within an EntityDef.
Definition: entityDef.qc:278
bool EntityDef_HasSpawnClass(string className)
Checks if an entity class was defined in an EntityDef.
Definition: entityDef.qc:679
ncEntity Entity_CreateClass(string className)
Always returns a valid entity.
Definition: entityDef.qc:665
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