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