Nuclide
Software Development Kit for id Technology
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/entityDef.h"
20#include "NSOutput.h"
21#include "NSGameRules.h"
22#include "skill.h"
23#include "logging.h"
24#include "../nav/defs.h"
25#include "spawn.h"
26#include "plugins.h"
27#include "lament.h"
28#include "vote.h"
29#include "mapcycle.h"
30#include "maptweaks.h"
31#include "scripts.h"
32
33/* helper macros */
34#define EVALUATE_FIELD(fieldname, changedflag) {\
35 if (ATTR_CHANGED(fieldname)) {\
36 SetSendFlags(changedflag);\
37 }\
38 SAVE_STATE(fieldname);\
39}
40
41#define EVALUATE_VECTOR(fieldname, idx, changedflag) {\
42 if (VEC_CHANGED(fieldname, idx)) {\
43 SetSendFlags(changedflag);\
44 }\
45 SAVE_STATE_FIELD(fieldname, idx);\
46}
47
48#define SENDENTITY_BYTE(field, changedflag) {\
49 if (flChanged & changedflag)\
50 WriteByte(MSG_ENTITY, field);\
51}
52
53#define SENDENTITY_SHORT(field, changedflag) {\
54 if (flChanged & changedflag)\
55 WriteShort(MSG_ENTITY, field);\
56}
57
58#define SENDENTITY_INT(field, changedflag) {\
59 if (flChanged & changedflag)\
60 WriteInt(MSG_ENTITY, field);\
61}
62
63#define SENDENTITY_FLOAT(field, changedflag) {\
64 if (flChanged & changedflag)\
65 WriteFloat(MSG_ENTITY, field);\
66}
67
68#define SENDENTITY_STRING(field, changedflag) {\
69 if (flChanged & changedflag)\
70 WriteString(MSG_ENTITY, field);\
71}
72
73#define SENDENTITY_COORD(field, changedflag) {\
74 if (flChanged & changedflag)\
75 WriteCoord(MSG_ENTITY, field);\
76}
77
78#define SENDENTITY_ANGLE(field, changedflag) {\
79 if (flChanged & changedflag)\
80 WriteAngle(MSG_ENTITY, field);\
81}
82
83#define SENDENTITY_ENTITY(field, changedflag) {\
84 if (flChanged & changedflag)\
85 WriteEntity(MSG_ENTITY, field);\
86}
87
88#define SENDENTITY_COLOR(field, changedflag) {\
89 if (flChanged & changedflag)\
90 WriteByte(MSG_ENTITY, field * 255.0);\
91}
92
93#define SENDENTITY_MODELINDEX(field, changedflag) {\
94 if (flChanged & changedflag)\
95 WriteShort(MSG_ENTITY, field);\
96}
97
98var bool g_isloading = false;
99
100var bool autocvar_mp_flashlight = true;
101
102void Client_FixAngle(entity, vector);
103void Client_ShakeOnce(vector, float, float, float, float);
104
105void Mapcycle_Load(string);
106
107NSEntity eActivator;
108
109/* Generic entity fields */
110.void(void) PlayerUse;
111.void(void) PlayerUseUnpressed;
112.bool iBleeds;
113.entity eUser;
114.float material;
115.float deaths;
116.float botinfo;
117
118/* in idTech the .owner field causes collisions to fail against set entity,
119 * we don't want this all of the time. so use this as a fallback */
120.entity real_owner;
121
122int trace_surfaceflagsi;
123string startspot;
124string __fullspawndata;
125
126var bool g_ents_initialized = FALSE;
127
128/* main is a qcc leftover */
129void main(void)
130{
131}
132
133#define SAVE_DECIMAL(x,y,z) fputs(x, sprintf("%S \"%d\" ", y, z))
134#define SAVE_INTEGER(x,y,z) fputs(x, sprintf("%S \"%i\" ", y, z))
135#define SAVE_FLOAT(x,y,z) fputs(x, sprintf("%S \"%f\" ", y, z))
136#define SAVE_VECTOR(x,y,z) fputs(x, sprintf("%S \"%v\" ", y, z))
137#define SAVE_STRING(x,y,z) fputs(x, sprintf("%S \"%s\" ", y, z))
138#define SAVE_HEX(x,y,z) fputs(x, sprintf("%S \"%x\" ", y, z))
139
140
146NSEntity EntityDef_SpawnClassname(string className);
147
148
152NSEntity EntityDef_CreateClassname(string className);
153
164NSEntity Entity_CreateClass(string className);
165
171bool EntityDef_HasSpawnClass(string className);
172
173
178string EntityDef_GetKeyValue(string className, string keyName);
179
180void
181WriteEntityEvent(float to, entity targetEntity, float eventType)
182{
183 WriteByte(to, SVC_CGAMEPACKET);
184 WriteByte(to, EV_ENTITYEVENT);
185 WriteEntity(to, targetEntity);
186 WriteFloat(to, eventType);
187}
NSEntity is the lowest of the user-accessible entity class.
Definition: NSEntity.h:54
float botinfo
Definition: botinfo.h:41
string EntityDef_GetKeyValue(string, string)
Retrieves the value of a specific key defined within an EntityDef.
Definition: entityDef.qc:283
bool EntityDef_HasSpawnClass(string className)
Checks if an entity class was defined in an EntityDef.
Definition: entityDef.qc:618
NSEntity Entity_CreateClass(string className)
Always returns a valid entity.
Definition: entityDef.qc:604
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