Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
models.qc File Reference
Include dependency graph for models.qc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void g_clientmodel_dropbyspawnflags (entity this)
bool g_clientmodel_genericsendentity (entity this, entity to, int sf)
void g_clientmodel_init (entity ent, float sol)
void g_clientmodel_setcolormaptoactivator (entity this, entity actor, entity trigger)
void g_clientmodel_think (entity this)
void g_clientmodel_use (entity this, entity actor, entity trigger)
void g_model_dropbyspawnflags (entity this)
void g_model_init (entity ent, float sol)
void g_model_setcolormaptoactivator (entity this, entity actor, entity trigger)
 spawnfunc (func_clientillusionary)
 spawnfunc (func_clientwall)
 spawnfunc (func_illusionary)
 spawnfunc (func_static)
 spawnfunc (func_wall)
 spawnfunc (misc_clientmodel)
 spawnfunc (misc_gamemodel)
 spawnfunc (misc_models)

Function Documentation

◆ g_clientmodel_dropbyspawnflags()

void g_clientmodel_dropbyspawnflags ( entity this)

Definition at line 92 of file models.qc.

93{
94 vector o0;
95 o0 = this.origin;
97 if(this.origin != o0)
98 this.SendFlags |= BIT(1);
99}
#define BIT(n)
Only ever assign into the first 24 bits in QC (so max is BIT(23)).
Definition bits.qh:8
vector origin
int SendFlags
Definition net.qh:118
void g_model_dropbyspawnflags(entity this)
Definition models.qc:65
vector
Definition self.qh:92

References BIT, entity(), g_model_dropbyspawnflags(), origin, SendFlags, and vector.

Referenced by g_clientmodel_init().

◆ g_clientmodel_genericsendentity()

bool g_clientmodel_genericsendentity ( entity this,
entity to,
int sf )

Definition at line 101 of file models.qc.

102{
103 sf = sf & 0x0F;
104 if(this.angles != '0 0 0')
105 sf |= 0x10;
106 if(this.mins != '0 0 0' || this.maxs != '0 0 0')
107 sf |= 0x20;
108 if(this.colormap != 0)
109 sf |= 0x40;
110 if(this.lodmodelindex1)
111 sf |= 0x80;
112
113 WriteHeader(MSG_ENTITY, ENT_CLIENT_WALL);
115
116 if(sf & BIT(0))
117 {
118 if(sf & 0x40)
121 }
122
123 if(sf & BIT(1))
124 {
125 WriteVector(MSG_ENTITY, this.origin);
126 }
127
128 if(sf & BIT(2))
129 {
130 if(sf & 0x10)
131 WriteAngleVector(MSG_ENTITY, this.angles);
132 }
133
134 if(sf & BIT(3))
135 {
136 if(sf & 0x80)
137 {
139 WriteShort(MSG_ENTITY, bound(0, this.loddistance1, 32767));
141 WriteShort(MSG_ENTITY, bound(0, this.loddistance2, 32767));
143 }
144 else
147 WriteShort(MSG_ENTITY, floor(this.scale * 256));
148 if(sf & 0x20)
149 {
150 WriteVector(MSG_ENTITY, this.mins);
151 WriteVector(MSG_ENTITY, this.maxs);
152 }
153 WriteString(MSG_ENTITY, this.bgmscript);
154 if(this.bgmscript != "")
155 {
156 WriteByte(MSG_ENTITY, floor(this.bgmscriptattack * 64));
157 WriteByte(MSG_ENTITY, floor(this.bgmscriptdecay * 64));
158 WriteByte(MSG_ENTITY, floor(this.bgmscriptsustain * 255));
159 WriteByte(MSG_ENTITY, floor(this.bgmscriptrelease * 64));
160 WriteVector(MSG_ENTITY, this.movedir);
161 WriteByte(MSG_ENTITY, floor(this.lip * 255));
162 }
163 WriteShort(MSG_ENTITY, bound(0, this.fade_start, 32767));
164 WriteShort(MSG_ENTITY, bound(0, this.fade_end, 32767));
165 WriteByte(MSG_ENTITY, floor(this.alpha_max * 256));
166 WriteByte(MSG_ENTITY, floor(this.alpha_min * 256));
169 }
170
171 return true;
172}
float fade_start
Definition item.qh:86
float fade_end
Definition item.qh:87
float modelindex
vector mins
float skin
vector maxs
float colormap
int lodmodelindex2
float loddistance2
int lodmodelindex1
float loddistance1
int lodmodelindex0
ent angles
Definition ent_cs.qc:121
solid
Definition ent_cs.qc:165
const int MSG_ENTITY
Definition net.qh:115
#define WriteHeader(to, id)
Definition net.qh:221
vector movedir
Definition viewloc.qh:18
float bound(float min, float value, float max)
void WriteString(string data, float dest, float desto)
void WriteShort(float data, float dest, float desto)
void WriteByte(float data, float dest, float desto)
float floor(float f)
float alpha_min
Definition models.qh:20
float fade_vertical_offset
Definition models.qh:23
bool inactive
Definition models.qh:19
float alpha_max
Definition models.qh:20
float scale
Definition projectile.qc:14
float lip
Definition subs.qh:40

References alpha_max, alpha_min, angles, BIT, bound(), colormap, entity(), fade_end, fade_start, fade_vertical_offset, floor(), inactive, lip, loddistance1, loddistance2, lodmodelindex0, lodmodelindex1, lodmodelindex2, maxs, mins, modelindex, movedir, MSG_ENTITY, origin, scale, skin, solid, WriteByte(), WriteHeader, WriteShort(), and WriteString().

Referenced by g_clientmodel_init().

◆ g_clientmodel_init()

void g_clientmodel_init ( entity ent,
float sol )

Definition at line 187 of file models.qc.

188{
189 if(ent.geomtype && autocvar_physics_ode && checkextension("DP_PHYSICS_ODE")) set_movetype(ent, MOVETYPE_PHYSICS);
190 if(!ent.scale) ent.scale = ent.modelscale;
191
192 if(!ent.solid) ent.solid = (sol);
193 else if(ent.solid < 0) ent.solid = SOLID_NOT;
194 SetBrushEntityModel(ent,true); // called after setting .solid to ensure correct area grid linking/unlinking
195
196 ent.use = g_clientmodel_use;
198 ent.nextthink = time;
199 ent.oldorigin = ent.origin; // don't run an initial double update
201 if(!ent.bgmscriptsustain) ent.bgmscriptsustain = 1;
202 else if(ent.bgmscriptsustain < 0) ent.bgmscriptsustain = 0;
204 ent.default_solid = sol;
205}
const int INITPRIO_DROPTOFLOOR
Definition constants.qh:97
const float SOLID_NOT
float time
void Net_LinkEntity(entity e, bool docull, float dt, bool(entity this, entity to, int sendflags) sendfunc)
Definition net.qh:123
float checkextension(string ext)
void g_clientmodel_think(entity this)
Definition models.qc:84
void g_clientmodel_dropbyspawnflags(entity this)
Definition models.qc:92
bool g_clientmodel_genericsendentity(entity this, entity to, int sf)
Definition models.qc:101
void g_clientmodel_use(entity this, entity actor, entity trigger)
Definition models.qc:37
void set_movetype(entity this, int mt)
Definition movetypes.qc:4
const int MOVETYPE_PHYSICS
Definition movetypes.qh:142
bool autocvar_physics_ode
Definition movetypes.qh:5
#define setthink(e, f)
void SetBrushEntityModel(entity this, bool with_lod)
Definition subs.qc:420
void InitializeEntity(entity e, void(entity this) func, int order)
Definition world.qc:2209

References autocvar_physics_ode, checkextension(), entity(), g_clientmodel_dropbyspawnflags(), g_clientmodel_genericsendentity(), g_clientmodel_think(), g_clientmodel_use(), InitializeEntity(), INITPRIO_DROPTOFLOOR, MOVETYPE_PHYSICS, Net_LinkEntity(), set_movetype(), SetBrushEntityModel(), setthink, SOLID_NOT, and time.

Referenced by spawnfunc(), spawnfunc(), and spawnfunc().

◆ g_clientmodel_setcolormaptoactivator()

void g_clientmodel_setcolormaptoactivator ( entity this,
entity actor,
entity trigger )

Definition at line 31 of file models.qc.

32{
33 g_model_setcolormaptoactivator(this, actor, trigger);
34 this.SendFlags |= (BIT(3) | BIT(0));
35}
void g_model_setcolormaptoactivator(entity this, entity actor, entity trigger)
Definition models.qc:17

References BIT, entity(), g_model_setcolormaptoactivator(), and SendFlags.

Referenced by g_clientmodel_use().

◆ g_clientmodel_think()

void g_clientmodel_think ( entity this)

Definition at line 84 of file models.qc.

85{
86 this.nextthink = time;
87 if(this.oldorigin != this.origin)
88 this.SendFlags |= BIT(1);
89 this.oldorigin = this.origin;
90}
float nextthink
vector oldorigin

References BIT, entity(), nextthink, oldorigin, origin, SendFlags, and time.

Referenced by g_clientmodel_init().

◆ g_clientmodel_use()

void g_clientmodel_use ( entity this,
entity actor,
entity trigger )

Definition at line 37 of file models.qc.

38{
39 // Flag to set func_clientwall state
40 // 1 == deactivate, 2 == activate, 0 == do nothing
41 if(this.classname == "func_clientwall" || this.classname == "func_clientillusionary")
42 this.antiwall_flag = trigger.antiwall_flag;
43
44 if (this.antiwall_flag == 1)
45 {
46 this.inactive = 1;
47 if (this.solid != SOLID_NOT)
48 {
49 this.solid = SOLID_NOT;
50 setorigin(this, this.origin); // unlink
51 }
52 }
53 else if (this.antiwall_flag == 2)
54 {
55 this.inactive = 0;
56 if (this.solid != this.default_solid)
57 {
58 this.solid = this.default_solid;
59 setorigin(this, this.origin); // link
60 }
61 }
62 g_clientmodel_setcolormaptoactivator(this, actor, trigger);
63}
string classname
void g_clientmodel_setcolormaptoactivator(entity this, entity actor, entity trigger)
Definition models.qc:31
float default_solid
Definition models.qh:24
float antiwall_flag
Definition triggers.qh:6

References antiwall_flag, classname, default_solid, entity(), g_clientmodel_setcolormaptoactivator(), inactive, origin, solid, and SOLID_NOT.

Referenced by g_clientmodel_init().

◆ g_model_dropbyspawnflags()

void g_model_dropbyspawnflags ( entity this)

Definition at line 65 of file models.qc.

66{
67 if((this.spawnflags & 3) == 1) // ALIGN_ORIGIN
68 {
69 traceline(this.origin, this.origin - '0 0 4096', MOVE_NOMONSTERS, this);
70 setorigin(this, trace_endpos);
71 }
72 else if((this.spawnflags & 3) == 2) // ALIGN_BOTTOM
73 {
74 tracebox(this.origin, this.mins, this.maxs, this.origin - '0 0 4096', MOVE_NOMONSTERS, this);
75 setorigin(this, trace_endpos);
76 }
77 else if((this.spawnflags & 3) == 3) // ALIGN_ORIGIN | ALIGN_BOTTOM
78 {
79 traceline(this.origin, this.origin - '0 0 4096', MOVE_NOMONSTERS, this);
80 setorigin(this, trace_endpos - '0 0 1' * this.mins.z);
81 }
82}
int spawnflags
Definition ammo.qh:15
const float MOVE_NOMONSTERS
vector trace_endpos

References entity(), maxs, mins, MOVE_NOMONSTERS, origin, spawnflags, and trace_endpos.

Referenced by g_clientmodel_dropbyspawnflags(), and g_model_init().

◆ g_model_init()

void g_model_init ( entity ent,
float sol )

Definition at line 174 of file models.qc.

175{
176 if(ent.geomtype && autocvar_physics_ode && checkextension("DP_PHYSICS_ODE")) set_movetype(ent, MOVETYPE_PHYSICS);
177 if(!ent.scale) ent.scale = ent.modelscale;
178
179 if(!ent.solid) ent.solid = (sol);
180 else if(ent.solid < 0) ent.solid = SOLID_NOT;
181 SetBrushEntityModel(ent,true); // called after setting .solid to ensure correct area grid linking/unlinking
182
185}

References autocvar_physics_ode, checkextension(), entity(), g_model_dropbyspawnflags(), g_model_setcolormaptoactivator(), InitializeEntity(), INITPRIO_DROPTOFLOOR, MOVETYPE_PHYSICS, set_movetype(), SetBrushEntityModel(), and SOLID_NOT.

Referenced by spawnfunc(), spawnfunc(), spawnfunc(), spawnfunc(), and spawnfunc().

◆ g_model_setcolormaptoactivator()

void g_model_setcolormaptoactivator ( entity this,
entity actor,
entity trigger )

Definition at line 17 of file models.qc.

18{
19 if(teamplay)
20 {
21 if(actor.team)
22 this.colormap = (actor.team - 1) * 0x11;
23 else
24 this.colormap = 0x00;
25 }
26 else
27 this.colormap = floor(random() * 256);
28 this.colormap |= BIT(10); // RENDER_COLORMAPPED
29}
float random(void)
bool teamplay
Definition teams.qh:59

References BIT, colormap, entity(), floor(), random(), and teamplay.

Referenced by g_clientmodel_setcolormaptoactivator(), and g_model_init().

◆ spawnfunc() [1/8]

spawnfunc ( func_clientillusionary )

Definition at line 214 of file models.qc.

214{ g_clientmodel_init(this, SOLID_NOT); } // brush entity
void g_clientmodel_init(entity ent, float sol)
Definition models.qc:187

References g_clientmodel_init(), and SOLID_NOT.

◆ spawnfunc() [2/8]

spawnfunc ( func_clientwall )

Definition at line 218 of file models.qc.

218{ g_clientmodel_init(this, SOLID_BSP); } // brush entity (WARNING: MISPREDICTED)
const float SOLID_BSP

References g_clientmodel_init(), and SOLID_BSP.

◆ spawnfunc() [3/8]

spawnfunc ( func_illusionary )

Definition at line 213 of file models.qc.

213{ g_model_init(this, SOLID_NOT); } // Q1 name (WARNING: MISPREDICTED)
void g_model_init(entity ent, float sol)
Definition models.qc:174

References g_model_init(), and SOLID_NOT.

◆ spawnfunc() [4/8]

spawnfunc ( func_static )

Definition at line 219 of file models.qc.

219{ g_model_init(this, SOLID_BSP); } // DEPRECATED old alias name from some other game

References g_model_init(), and SOLID_BSP.

◆ spawnfunc() [5/8]

spawnfunc ( func_wall )

Definition at line 217 of file models.qc.

217{ g_model_init(this, SOLID_BSP); } // Q1 name

References g_model_init(), and SOLID_BSP.

◆ spawnfunc() [6/8]

spawnfunc ( misc_clientmodel )

Definition at line 209 of file models.qc.

209{ this.angles_x = -this.angles.x; g_clientmodel_init(this, SOLID_NOT); } // model entity

References angles, g_clientmodel_init(), and SOLID_NOT.

◆ spawnfunc() [7/8]

spawnfunc ( misc_gamemodel )

Definition at line 208 of file models.qc.

208{ this.angles_x = -this.angles.x; g_model_init(this, SOLID_NOT); } // model entity

References angles, g_model_init(), and SOLID_NOT.

◆ spawnfunc() [8/8]

spawnfunc ( misc_models )

Definition at line 210 of file models.qc.

210{ this.angles_x = -this.angles.x; g_model_init(this, SOLID_NOT); } // DEPRECATED old compat entity with confusing name, do not use

References angles, g_model_init(), and SOLID_NOT.