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