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

Go to the source code of this file.

Functions

 classfield (ModelEffect) .float frame1time
 entityclass (ModelEffect)
void ModelEffect_Draw (entity this)
bool modeleffect_SendEntity (entity this, entity to, int sf)
void modeleffect_spawn (string m, float s, float f, vector o, vector v, vector ang, vector angv, float s0, float s2, float a, float t1, float t2)
 NET_HANDLE (ENT_CLIENT_MODELEFFECT, bool isnew)

Variables

float alpha
float cnt
 fadetime
float scale
float scale2

Function Documentation

◆ classfield()

classfield ( ModelEffect )

References frame1time.

◆ entityclass()

entityclass ( ModelEffect )

◆ ModelEffect_Draw()

void ModelEffect_Draw ( entity this)

Definition at line 88 of file modeleffects.qc.

89{
90 this.angles = this.angles + frametime * this.avelocity;
91 setorigin(this, this.origin + frametime * this.velocity);
92 this.scale = this.scale1 + (this.scale2 - this.scale1) * (time - this.teleport_time) / (this.lifetime + this.fadetime - this.teleport_time);
93 this.alpha = this.cnt * bound(0, 1 - (time - this.lifetime) / this.fadetime, 1);
94 if(this.alpha < ALPHA_MIN_VISIBLE)
95 {
96 delete(this);
97 return;
98 }
99 this.drawmask = MASK_NORMAL;
100 if(this.scale <= 0)
101 {
102 this.drawmask = 0;
103 return;
104 }
105}
float lifetime
Definition powerups.qc:23
float cnt
Definition powerups.qc:24
float alpha
Definition items.qc:13
const float ALPHA_MIN_VISIBLE
Definition main.qh:158
float teleport_time
Definition player.qh:216
float drawmask
vector avelocity
float frametime
const float MASK_NORMAL
vector velocity
float time
vector origin
ent angles
Definition ent_cs.qc:121
float bound(float min, float value, float max)
float scale2
fadetime
float scale
Definition projectile.qc:14

References alpha, ALPHA_MIN_VISIBLE, angles, avelocity, bound(), cnt, drawmask, entity(), frametime, lifetime, MASK_NORMAL, origin, scale, teleport_time, time, and velocity.

Referenced by NET_HANDLE().

◆ modeleffect_SendEntity()

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

Definition at line 9 of file modeleffects.qc.

10{
11 float f;
12 WriteHeader(MSG_ENTITY, ENT_CLIENT_MODELEFFECT);
13
14 f = 0;
15 if(this.velocity != '0 0 0')
16 f |= 1;
17 if(this.angles != '0 0 0')
18 f |= 2;
19 if(this.avelocity != '0 0 0')
20 f |= 4;
21
26 WriteVector(MSG_ENTITY, this.origin);
27 if(f & 1)
28 {
29 WriteVector(MSG_ENTITY, this.velocity);
30 }
31 if(f & 2)
32 {
33 WriteAngleVector(MSG_ENTITY, this.angles);
34 }
35 if(f & 4)
36 {
37 WriteAngleVector(MSG_ENTITY, this.avelocity);
38 }
39 WriteShort(MSG_ENTITY, this.scale * 256.0);
40 WriteShort(MSG_ENTITY, this.scale2 * 256.0);
41 WriteByte(MSG_ENTITY, this.teleport_time * 100.0);
42 WriteByte(MSG_ENTITY, this.fade_time * 100.0);
43 WriteByte(MSG_ENTITY, this.alpha * 255.0);
44
45 return true;
46}
float frame
primary framegroup animation (strength = 1 - lerpfrac - lerpfrac3 - lerpfrac4)
Definition anim.qh:6
float modelindex
float skin
const int MSG_ENTITY
Definition net.qh:115
#define WriteHeader(to, id)
Definition net.qh:221
void WriteShort(float data, float dest, float desto)
void WriteByte(float data, float dest, float desto)
float fade_time
Definition common.qh:23

References alpha, angles, avelocity, entity(), fade_time, frame, modelindex, MSG_ENTITY, origin, scale, scale2, skin, teleport_time, velocity, WriteByte(), WriteHeader, and WriteShort().

Referenced by modeleffect_spawn().

◆ modeleffect_spawn()

void modeleffect_spawn ( string m,
float s,
float f,
vector o,
vector v,
vector ang,
vector angv,
float s0,
float s2,
float a,
float t1,
float t2 )

Definition at line 48 of file modeleffects.qc.

49{
50 entity e = new(modeleffect);
51 _setmodel(e, m);
52 e.frame = f;
53 setorigin(e, o);
54 e.velocity = v;
55 e.angles = ang;
56 e.avelocity = angv;
57 e.alpha = a;
58 e.teleport_time = t1;
59 e.fade_time = t2;
60 e.skin = s;
61 if(s0 >= 0)
62 e.scale = s0 / max6(-e.mins.x, -e.mins.y, -e.mins.z, e.maxs.x, e.maxs.y, e.maxs.z);
63 else
64 e.scale = -s0;
65 if(s2 >= 0)
66 e.scale2 = s2 / max6(-e.mins.x, -e.mins.y, -e.mins.z, e.maxs.x, e.maxs.y, e.maxs.z);
67 else
68 e.scale2 = -s2;
69 float sz = max(e.scale, e.scale2);
70 setsize(e, e.mins * sz, e.maxs * sz);
72}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
void Net_LinkEntity(entity e, bool docull, float dt, bool(entity this, entity to, int sendflags) sendfunc)
Definition net.qh:123
float max(float f,...)
bool modeleffect_SendEntity(entity this, entity to, int sf)
spree_inf s1 s2 s3loc s2 spree_inf s1 s2 s3loc s2 spree_inf s1 s2 s3loc s2 s1 s2loc s1 s2loc s1 s2loc s1 s2loc s1 s2loc s1 s2loc s1 s2 f1points s1 s2
Definition all.inc:469
vector vector ang
Definition self.qh:92

References ang, entity(), max(), modeleffect_SendEntity(), Net_LinkEntity(), s2, and vector.

Referenced by W_Fireball_Explode().

◆ NET_HANDLE()

NET_HANDLE ( ENT_CLIENT_MODELEFFECT ,
bool isnew )

Definition at line 107 of file modeleffects.qc.

108{
109 make_pure(this);
110
111 int f = ReadByte();
112
113 entity e = new(modeleffect);
114 e.model = "from network";
115 e.modelindex = ReadShort();
116 e.skin = ReadByte();
117 e.frame = ReadByte();
118 e.frame1time = time;
119 e.origin = ReadVector();
120 setorigin(e, e.origin);
121 if(f & 1)
122 {
123 e.velocity = ReadVector();
124 }
125 if(f & 2)
126 {
127 e.angles = ReadAngleVector();
128 }
129 if(f & 4)
130 {
131 e.avelocity = ReadAngleVector();
132 }
133 e.scale1 = ReadShort() / 256.0;
134 e.scale2 = ReadShort() / 256.0;
135 e.lifetime = time + ReadByte() * 0.01;
136 e.fadetime = ReadByte() * 0.01;
137 e.teleport_time = time;
138 e.cnt = ReadByte() / 255.0; // actually alpha
139
140 e.draw = ModelEffect_Draw;
141 if (isnew) IL_PUSH(g_drawables, e);
142
143 if (!isnew) delete(e); // yes, this IS stupid, but I don't need to duplicate all the read* stuff then
144 return true;
145}
IntrusiveList g_drawables
Definition main.qh:91
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
#define ReadVector()
Definition net.qh:367
#define ReadAngleVector()
Definition net.qh:369
int ReadByte()
void ModelEffect_Draw(entity this)
#define make_pure(e)
direct use is
Definition oo.qh:13

References entity(), g_drawables, IL_PUSH(), make_pure, ModelEffect_Draw(), ReadAngleVector, ReadByte(), ReadVector, and time.

Variable Documentation

◆ alpha

float alpha

Definition at line 86 of file modeleffects.qc.

◆ cnt

float cnt

Definition at line 84 of file modeleffects.qc.

◆ fadetime

◆ scale

float scale

Definition at line 85 of file modeleffects.qc.

◆ scale2

scale2

Definition at line 7 of file modeleffects.qc.

Referenced by modeleffect_SendEntity().