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 = this.origin;
96 if(this.origin != o0)
97 this.SendFlags |= BIT(1);
98}
#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:159
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 100 of file models.qc.

101{
102 sf &= 0x0F;
103 if(this.angles != '0 0 0')
104 sf |= 0x10;
105 if(this.mins != '0 0 0' || this.maxs != '0 0 0')
106 sf |= 0x20;
107 if(this.colormap != 0)
108 sf |= 0x40;
109 if(this.lodmodelindex1)
110 sf |= 0x80;
111
112 WriteHeader(MSG_ENTITY, ENT_CLIENT_WALL);
114
115 if(sf & BIT(0))
116 {
117 if(sf & 0x40)
120 }
121
122 if(sf & BIT(1))
123 {
124 WriteVector(MSG_ENTITY, this.origin);
125 }
126
127 if(sf & BIT(2))
128 {
129 if(sf & 0x10)
130 WriteAngleVector(MSG_ENTITY, this.angles);
131 }
132
133 if(sf & BIT(3))
134 {
135 if(sf & 0x80)
136 {
138 WriteShort(MSG_ENTITY, bound(0, this.loddistance1, 32767));
140 WriteShort(MSG_ENTITY, bound(0, this.loddistance2, 32767));
142 }
143 else
146 WriteShort(MSG_ENTITY, floor(this.scale * 256));
147 if(sf & 0x20)
148 {
149 WriteVector(MSG_ENTITY, this.mins);
150 WriteVector(MSG_ENTITY, this.maxs);
151 }
152 WriteString(MSG_ENTITY, this.bgmscript);
153 if(this.bgmscript != "")
154 {
155 WriteByte(MSG_ENTITY, floor(this.bgmscriptattack * 64));
156 WriteByte(MSG_ENTITY, floor(this.bgmscriptdecay * 64));
157 WriteByte(MSG_ENTITY, floor(this.bgmscriptsustain * 255));
158 WriteByte(MSG_ENTITY, floor(this.bgmscriptrelease * 64));
159 WriteVector(MSG_ENTITY, this.movedir);
160 WriteByte(MSG_ENTITY, floor(this.lip * 255));
161 }
162 WriteShort(MSG_ENTITY, bound(0, this.fade_start, 32767));
163 WriteShort(MSG_ENTITY, bound(0, this.fade_end, 32767));
164 WriteByte(MSG_ENTITY, floor(this.alpha_max * 256));
165 WriteByte(MSG_ENTITY, floor(this.alpha_min * 256));
168 }
169
170 return true;
171}
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:156
#define WriteHeader(to, id)
Definition net.qh:265
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 186 of file models.qc.

187{
188 if(ent.geomtype && autocvar_physics_ode && checkextension("DP_PHYSICS_ODE")) set_movetype(ent, MOVETYPE_PHYSICS);
189 if(!ent.scale) ent.scale = ent.modelscale;
190
191 if(!ent.solid) ent.solid = (sol);
192 else if(ent.solid < 0) ent.solid = SOLID_NOT;
193 SetBrushEntityModel(ent,true); // called after setting .solid to ensure correct area grid linking/unlinking
194
195 ent.use = g_clientmodel_use;
197 ent.nextthink = time;
198 ent.oldorigin = ent.origin; // don't run an initial double update
200 if(!ent.bgmscriptsustain) ent.bgmscriptsustain = 1;
201 else if(ent.bgmscriptsustain < 0) ent.bgmscriptsustain = 0;
203 ent.default_solid = sol;
204}
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:167
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:100
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:419
void InitializeEntity(entity e, void(entity this) func, int order)
Definition world.qc:2230

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 173 of file models.qc.

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

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 213 of file models.qc.

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

References g_clientmodel_init(), and SOLID_NOT.

◆ spawnfunc() [2/8]

spawnfunc ( func_clientwall )

Definition at line 217 of file models.qc.

217{ 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 212 of file models.qc.

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

References g_model_init(), and SOLID_NOT.

◆ spawnfunc() [4/8]

spawnfunc ( func_static )

Definition at line 218 of file models.qc.

218{ 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 216 of file models.qc.

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

References g_model_init(), and SOLID_BSP.

◆ spawnfunc() [6/8]

spawnfunc ( misc_clientmodel )

Definition at line 208 of file models.qc.

208{ 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 207 of file models.qc.

207{ 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 209 of file models.qc.

209{ 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.