3 #include "autocvars.qh"
5 #include "bgmscript.qh"
8 #include "../lib/csqcmodel/interpolate.qh"
14 void Ent_Wall_PreDraw(entity this)
22 vector org = getpropertyvec(VF_ORIGIN);
23 if(!checkpvs(org, this))
25 else if(this.fade_start || this.fade_end) {
26 vector offset = '0 0 0';
27 offset_z = this.fade_vertical_offset;
28 float player_dist = vlen(org - this.origin - 0.5 * (this.mins + this.maxs) + offset);
29 if (this.fade_end == this.fade_start)
31 if (player_dist >= this.fade_start)
38 this.alpha = (this.alpha_min + this.alpha_max * bound(0,
39 (this.fade_end - player_dist)
40 / (this.fade_end - this.fade_start), 1)) / 100.0;
51 this.drawmask = MASK_NORMAL;
54 void Ent_Wall_Draw(entity this)
59 if(this.bgmscriptangular)
63 this.(fld) = this.saved;
65 if(this.lodmodelindex1)
67 if(autocvar_cl_modeldetailreduction <= 0)
69 if(this.lodmodelindex2 && autocvar_cl_modeldetailreduction <= -2)
70 this.modelindex = this.lodmodelindex2;
71 else if(autocvar_cl_modeldetailreduction <= -1)
72 this.modelindex = this.lodmodelindex1;
74 this.modelindex = this.lodmodelindex0;
78 float distance = vlen(NearestPointOnBox(this, view_origin) - view_origin);
79 f = (distance * current_viewzoom + 100.0) * autocvar_cl_modeldetailreduction;
80 f *= 1.0 / bound(0.01, view_quality, 1);
81 if(this.lodmodelindex2 && f > this.loddistance2)
82 this.modelindex = this.lodmodelindex2;
83 else if(f > this.loddistance1)
84 this.modelindex = this.lodmodelindex1;
86 this.modelindex = this.lodmodelindex0;
90 InterpolateOrigin_Do(this);
92 this.saved = this.(fld);
94 f = doBGMScript(this);
97 if(this.lip < 0) // < 0: alpha goes from 1 to 1-|lip| when toggled (toggling subtracts lip)
98 this.alpha = 1 + this.lip * f;
99 else // > 0: alpha goes from 1-|lip| to 1 when toggled (toggling adds lip)
100 this.alpha = 1 - this.lip * (1 - f);
101 this.(fld) = this.(fld) + this.movedir * f;
106 if(this.alpha >= ALPHA_MIN_VISIBLE)
107 this.drawmask = MASK_NORMAL;
112 void Ent_Wall_Remove(entity this)
115 strunzone(this.bgmscript);
116 this.bgmscript = string_null;
119 NET_HANDLE(ENT_CLIENT_WALL, bool isnew)
124 InterpolateOrigin_Undo(this);
125 this.iflags = IFLAG_ANGLES | IFLAG_ORIGIN;
127 if(this.bgmscriptangular)
131 this.(fld) = this.saved;
138 this.colormap = ReadShort();
141 this.skin = ReadByte();
146 this.origin_x = ReadCoord();
147 this.origin_y = ReadCoord();
148 this.origin_z = ReadCoord();
149 setorigin(this, this.origin);
156 this.angles_x = ReadAngle();
157 this.angles_y = ReadAngle();
158 this.angles_z = ReadAngle();
161 this.angles = '0 0 0';
168 this.lodmodelindex0 = ReadShort();
169 this.loddistance1 = ReadShort();
170 this.lodmodelindex1 = ReadShort();
171 this.loddistance2 = ReadShort();
172 this.lodmodelindex2 = ReadShort();
176 this.modelindex = ReadShort();
177 this.loddistance1 = 0;
178 this.loddistance2 = 0;
180 this.solid = ReadByte();
181 this.scale = ReadShort() / 256.0;
184 this.mins_x = ReadCoord();
185 this.mins_y = ReadCoord();
186 this.mins_z = ReadCoord();
187 this.maxs_x = ReadCoord();
188 this.maxs_y = ReadCoord();
189 this.maxs_z = ReadCoord();
192 this.mins = this.maxs = '0 0 0';
193 setsize(this, this.mins, this.maxs);
196 strunzone(this.bgmscript);
197 this.bgmscript = ReadString();
198 if(substring(this.bgmscript, 0, 1) == "<")
200 this.bgmscript = strzone(substring(this.bgmscript, 1, -1));
201 this.bgmscriptangular = 1;
205 this.bgmscript = strzone(this.bgmscript);
206 this.bgmscriptangular = 0;
208 if(this.bgmscript != "")
210 this.bgmscriptattack = ReadByte() / 64.0;
211 this.bgmscriptdecay = ReadByte() / 64.0;
212 this.bgmscriptsustain = ReadByte() / 255.0;
213 this.bgmscriptrelease = ReadByte() / 64.0;
214 this.movedir_x = ReadCoord();
215 this.movedir_y = ReadCoord();
216 this.movedir_z = ReadCoord();
217 this.lip = ReadByte() / 255.0;
219 this.fade_start = ReadByte();
220 this.fade_end = ReadByte();
221 this.alpha_max = ReadByte();
222 this.alpha_min = ReadByte();
223 this.inactive = ReadByte();
224 this.fade_vertical_offset = ReadShort();
225 BGMScript_InitEntity(this);
230 InterpolateOrigin_Note(this);
232 this.saved = this.(fld);
234 this.entremove = Ent_Wall_Remove;
235 this.draw = Ent_Wall_Draw;
236 if (isnew) IL_PUSH(g_drawables, this);
237 setpredraw(this, Ent_Wall_PreDraw);