1 #include "modeleffects.qh"
3 REGISTER_NET_LINKED(ENT_CLIENT_MODELEFFECT)
9 bool modeleffect_SendEntity(entity this, entity to, int sf)
12 WriteHeader(MSG_ENTITY, ENT_CLIENT_MODELEFFECT);
15 if(this.velocity != '0 0 0')
17 if(this.angles != '0 0 0')
19 if(this.avelocity != '0 0 0')
22 WriteByte(MSG_ENTITY, f);
23 WriteShort(MSG_ENTITY, this.modelindex);
24 WriteByte(MSG_ENTITY, this.skin);
25 WriteByte(MSG_ENTITY, this.frame);
26 WriteCoord(MSG_ENTITY, this.origin.x);
27 WriteCoord(MSG_ENTITY, this.origin.y);
28 WriteCoord(MSG_ENTITY, this.origin.z);
31 WriteCoord(MSG_ENTITY, this.velocity.x);
32 WriteCoord(MSG_ENTITY, this.velocity.y);
33 WriteCoord(MSG_ENTITY, this.velocity.z);
37 WriteCoord(MSG_ENTITY, this.angles.x);
38 WriteCoord(MSG_ENTITY, this.angles.y);
39 WriteCoord(MSG_ENTITY, this.angles.z);
43 WriteCoord(MSG_ENTITY, this.avelocity.x);
44 WriteCoord(MSG_ENTITY, this.avelocity.y);
45 WriteCoord(MSG_ENTITY, this.avelocity.z);
47 WriteShort(MSG_ENTITY, this.scale * 256.0);
48 WriteShort(MSG_ENTITY, this.scale2 * 256.0);
49 WriteByte(MSG_ENTITY, this.teleport_time * 100.0);
50 WriteByte(MSG_ENTITY, this.fade_time * 100.0);
51 WriteByte(MSG_ENTITY, this.alpha * 255.0);
56 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)
58 entity e = new(modeleffect);
70 e.scale = s0 / max6(-e.mins.x, -e.mins.y, -e.mins.z, e.maxs.x, e.maxs.y, e.maxs.z);
74 e.scale2 = s2 / max6(-e.mins.x, -e.mins.y, -e.mins.z, e.maxs.x, e.maxs.y, e.maxs.z);
77 float sz = max(e.scale, e.scale2);
78 setsize(e, e.mins * sz, e.maxs * sz);
79 Net_LinkEntity(e, false, 0.1, modeleffect_SendEntity);
86 entityclass(ModelEffect);
87 class(ModelEffect) .float frame1time;
88 class(ModelEffect) .float lifetime, fadetime;
89 class(ModelEffect) .float teleport_time;
90 class(ModelEffect) .float scale1, scale2;
96 void ModelEffect_Draw(entity this)
98 this.angles = this.angles + frametime * this.avelocity;
99 setorigin(this, this.origin + frametime * this.velocity);
100 this.scale = this.scale1 + (this.scale2 - this.scale1) * (time - this.teleport_time) / (this.lifetime + this.fadetime - this.teleport_time);
101 this.alpha = this.cnt * bound(0, 1 - (time - this.lifetime) / this.fadetime, 1);
102 if(this.alpha < ALPHA_MIN_VISIBLE)
107 this.drawmask = MASK_NORMAL;
115 NET_HANDLE(ENT_CLIENT_MODELEFFECT, bool isnew)
121 entity e = new(modeleffect);
122 e.model = "from network";
123 e.modelindex = ReadShort();
125 e.frame = ReadByte();
127 e.origin_x = ReadCoord();
128 e.origin_y = ReadCoord();
129 e.origin_z = ReadCoord();
130 setorigin(e, e.origin);
133 e.velocity_x = ReadCoord();
134 e.velocity_y = ReadCoord();
135 e.velocity_z = ReadCoord();
139 e.angles_x = ReadAngle();
140 e.angles_y = ReadAngle();
141 e.angles_z = ReadAngle();
145 e.avelocity_x = ReadAngle();
146 e.avelocity_y = ReadAngle();
147 e.avelocity_z = ReadAngle();
149 e.scale1 = ReadShort() / 256.0;
150 e.scale2 = ReadShort() / 256.0;
151 e.lifetime = time + ReadByte() * 0.01;
152 e.fadetime = ReadByte() * 0.01;
153 e.teleport_time = time;
154 e.cnt = ReadByte() / 255.0; // actually alpha
156 e.draw = ModelEffect_Draw;
157 if (isnew) IL_PUSH(g_drawables, e);
159 if (!isnew) delete(e); // yes, this IS stupid, but I don't need to duplicate all the read* stuff then