Nuclide
Software Development Kit for id Tech
defs.h
Go to the documentation of this file.
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 "../shared/entityDef.h"
18#include "NSOutput.h"
19#include "NSGameRules.h"
20#include "skill.h"
21#include "logging.h"
22#include "../nav/defs.h"
23#include "spawn.h"
24#include "plugins.h"
25#include "lament.h"
26#include "vote.h"
27#include "mapcycle.h"
28#include "maptweaks.h"
29
30/* helper macros */
31#define EVALUATE_FIELD(fieldname, changedflag) {\
32 if (ATTR_CHANGED(fieldname)) {\
33 SetSendFlags(changedflag);\
34 }\
35 SAVE_STATE(fieldname);\
36}
37
38#define EVALUATE_VECTOR(fieldname, idx, changedflag) {\
39 if (VEC_CHANGED(fieldname, idx)) {\
40 SetSendFlags(changedflag);\
41 }\
42 SAVE_STATE_FIELD(fieldname, idx);\
43}
44
45#define SENDENTITY_BYTE(field, changedflag) {\
46 if (flChanged & changedflag)\
47 WriteByte(MSG_ENTITY, field);\
48}
49
50#define SENDENTITY_SHORT(field, changedflag) {\
51 if (flChanged & changedflag)\
52 WriteShort(MSG_ENTITY, field);\
53}
54
55#define SENDENTITY_INT(field, changedflag) {\
56 if (flChanged & changedflag)\
57 WriteInt(MSG_ENTITY, field);\
58}
59
60#define SENDENTITY_FLOAT(field, changedflag) {\
61 if (flChanged & changedflag)\
62 WriteFloat(MSG_ENTITY, field);\
63}
64
65#define SENDENTITY_STRING(field, changedflag) {\
66 if (flChanged & changedflag)\
67 WriteString(MSG_ENTITY, field);\
68}
69
70#define SENDENTITY_COORD(field, changedflag) {\
71 if (flChanged & changedflag)\
72 WriteCoord(MSG_ENTITY, field);\
73}
74
75#define SENDENTITY_ANGLE(field, changedflag) {\
76 if (flChanged & changedflag)\
77 WriteAngle(MSG_ENTITY, field);\
78}
79
80#define SENDENTITY_ENTITY(field, changedflag) {\
81 if (flChanged & changedflag)\
82 WriteEntity(MSG_ENTITY, field);\
83}
84
85#define SENDENTITY_COLOR(field, changedflag) {\
86 if (flChanged & changedflag)\
87 WriteByte(MSG_ENTITY, field * 255.0);\
88}
89
90#define SENDENTITY_MODELINDEX(field, changedflag) {\
91 if (flChanged & changedflag)\
92 WriteShort(MSG_ENTITY, field);\
93}
94
95var bool g_isloading = false;
96
97var bool autocvar_mp_flashlight = true;
98
99void Client_FixAngle(entity, vector);
100void Client_ShakeOnce(vector, float, float, float, float);
101
102void Mapcycle_Load(string);
103
105
106/* Generic entity fields */
107.void(void) PlayerUse;
108.void(void) PlayerUseUnpressed;
110.entity eUser;
111.float material;
112.float deaths;
113.float botinfo;
114
115/* in idTech the .owner field causes collisions to fail against set entity,
116 * we don't want this all of the time. so use this as a fallback */
118
122
123/* damage related tempglobals, like trace_* */
131
132var bool g_ents_initialized = FALSE;
133
134/* main is a qcc leftover */
135void main(void)
136{
137}
138
139#define SAVE_DECIMAL(x,y,z) fputs(x, sprintf("%S \"%d\" ", y, z))
140#define SAVE_INTEGER(x,y,z) fputs(x, sprintf("%S \"%i\" ", y, z))
141#define SAVE_FLOAT(x,y,z) fputs(x, sprintf("%S \"%f\" ", y, z))
142#define SAVE_VECTOR(x,y,z) fputs(x, sprintf("%S \"%v\" ", y, z))
143#define SAVE_STRING(x,y,z) fputs(x, sprintf("%S \"%s\" ", y, z))
144#define SAVE_HEX(x,y,z) fputs(x, sprintf("%S \"%x\" ", y, z))
145
146
152NSEntity EntityDef_SpawnClassname(string className);
153
154
158NSEntity EntityDef_CreateClassname(string className);
159
170NSEntity Entity_CreateClass(string className);
171
177bool EntityDef_HasSpawnClass(string className);
178
179
184string EntityDef_GetKeyValue(string className, string keyName);
185
186void
187WriteEntityEvent(float to, entity targetEntity, float eventType)
188{
189 WriteByte(to, SVC_CGAMEPACKET);
190 WriteByte(to, EV_ENTITYEVENT);
191 WriteEntity(to, targetEntity);
192 WriteFloat(to, eventType);
193}
Gamerule top level class.
NSEntity is the lowest of the user-accessible entity class.
Definition: NSEntity.h:54
@ EV_ENTITYEVENT
Definition: events.h:23
bodyType_t
Hitmesh types that models can support.
Definition: hitmesh.h:21
Server-Plugin APIs, similar to MetaMod.
NSEntity g_dmg_eTarget
Definition: defs.h:125
NSEntity EntityDef_SpawnClassname(string className)
When called will turn the entity 'self' into the specified classname.
Definition: entityDef.qc:513
string startspot
Definition: defs.h:120
string __fullspawndata
Definition: defs.h:121
int g_dmg_iWeapon
Definition: defs.h:129
string EntityDef_GetKeyValue(string className, string keyName)
Retrieves the value of a specific key defined within an EntityDef.
Definition: entityDef.qc:282
var bool g_ents_initialized
Definition: defs.h:132
void WriteEntityEvent(float to, entity targetEntity, float eventType)
Definition: defs.h:187
bool iBleeds
Definition: defs.h:109
var bool g_isloading
Definition: defs.h:95
void main(void)
Definition: defs.h:135
entity real_owner
Definition: defs.h:117
entity eUser
Definition: defs.h:110
void Client_ShakeOnce(vector, float, float, float, float)
Definition: NSClient.qc:215
void Client_FixAngle(entity, vector)
Definition: NSClient.qc:195
NSEntity eActivator
Definition: defs.h:104
int trace_surfaceflagsi
Definition: defs.h:119
bool EntityDef_HasSpawnClass(string className)
Checks if an entity class was defined in an EntityDef.
Definition: entityDef.qc:576
vector g_dmg_vecLocation
Definition: defs.h:130
NSEntity EntityDef_CreateClassname(string className)
Spawns an entity of a specific class.
Definition: entityDef.qc:532
float botinfo
Definition: defs.h:113
var bool autocvar_mp_flashlight
Definition: defs.h:97
NSEntity g_dmg_eAttacker
Definition: defs.h:124
float deaths
Definition: defs.h:112
void Mapcycle_Load(string)
Definition: mapcycle.qc:18
float material
Definition: defs.h:111
int g_dmg_iFlags
Definition: defs.h:128
bodyType_t g_dmg_iHitBody
Definition: defs.h:127
NSEntity Entity_CreateClass(string className)
Spawns an entity of a class, guaranteed to be valid.
Definition: entityDef.qc:562
int g_dmg_iDamage
Definition: defs.h:126