3 #include "bgmscript.qh"
6 #include "../lib/csqcmodel/interpolate.qh"
12 void Ent_Wall_PreDraw(entity this)
20 vector org = getpropertyvec(VF_ORIGIN);
21 if(!checkpvs(org, this))
23 else if(this.fade_start || this.fade_end) {
24 vector offset = '0 0 0';
25 offset_z = this.fade_vertical_offset;
26 float player_dist = vlen(org - this.origin - 0.5 * (this.mins + this.maxs) + offset);
27 if (this.fade_end == this.fade_start)
29 if (player_dist >= this.fade_start)
36 this.alpha = (this.alpha_min + this.alpha_max * bound(0,
37 (this.fade_end - player_dist)
38 / (this.fade_end - this.fade_start), 1)) / 100.0;
49 this.drawmask = MASK_NORMAL;
52 void Ent_Wall_Draw(entity this)
57 if(this.bgmscriptangular)
61 this.(fld) = this.saved;
63 if(this.lodmodelindex1)
65 if(autocvar_cl_modeldetailreduction <= 0)
67 if(this.lodmodelindex2 && autocvar_cl_modeldetailreduction <= -2)
68 this.modelindex = this.lodmodelindex2;
69 else if(autocvar_cl_modeldetailreduction <= -1)
70 this.modelindex = this.lodmodelindex1;
72 this.modelindex = this.lodmodelindex0;
76 float distance = vlen(NearestPointOnBox(this, view_origin) - view_origin);
77 f = (distance * current_viewzoom + 100.0) * autocvar_cl_modeldetailreduction;
78 f *= 1.0 / bound(0.01, view_quality, 1);
79 if(this.lodmodelindex2 && f > this.loddistance2)
80 this.modelindex = this.lodmodelindex2;
81 else if(f > this.loddistance1)
82 this.modelindex = this.lodmodelindex1;
84 this.modelindex = this.lodmodelindex0;
88 InterpolateOrigin_Do(this);
90 this.saved = this.(fld);
92 f = doBGMScript(this);
95 if(this.lip < 0) // < 0: alpha goes from 1 to 1-|lip| when toggled (toggling subtracts lip)
96 this.alpha = 1 + this.lip * f;
97 else // > 0: alpha goes from 1-|lip| to 1 when toggled (toggling adds lip)
98 this.alpha = 1 - this.lip * (1 - f);
99 this.(fld) = this.(fld) + this.movedir * f;
104 if(this.alpha >= ALPHA_MIN_VISIBLE)
105 this.drawmask = MASK_NORMAL;
110 void Ent_Wall_Remove(entity this)
113 strunzone(this.bgmscript);
114 this.bgmscript = string_null;
117 NET_HANDLE(ENT_CLIENT_WALL, bool isnew)
122 InterpolateOrigin_Undo(this);
123 this.iflags = IFLAG_ANGLES | IFLAG_ORIGIN;
125 if(this.bgmscriptangular)
129 this.(fld) = this.saved;
136 this.colormap = ReadShort();
143 this.origin_x = ReadCoord();
144 this.origin_y = ReadCoord();
145 this.origin_z = ReadCoord();
146 setorigin(this, this.origin);
153 this.angles_x = ReadAngle();
154 this.angles_y = ReadAngle();
155 this.angles_z = ReadAngle();
158 this.angles = '0 0 0';
165 this.lodmodelindex0 = ReadShort();
166 this.loddistance1 = ReadShort();
167 this.lodmodelindex1 = ReadShort();
168 this.loddistance2 = ReadShort();
169 this.lodmodelindex2 = ReadShort();
173 this.modelindex = ReadShort();
174 this.loddistance1 = 0;
175 this.loddistance2 = 0;
177 this.solid = ReadByte();
178 this.scale = ReadShort() / 256.0;
181 this.mins_x = ReadCoord();
182 this.mins_y = ReadCoord();
183 this.mins_z = ReadCoord();
184 this.maxs_x = ReadCoord();
185 this.maxs_y = ReadCoord();
186 this.maxs_z = ReadCoord();
189 this.mins = this.maxs = '0 0 0';
190 setsize(this, this.mins, this.maxs);
193 strunzone(this.bgmscript);
194 this.bgmscript = ReadString();
195 if(substring(this.bgmscript, 0, 1) == "<")
197 this.bgmscript = strzone(substring(this.bgmscript, 1, -1));
198 this.bgmscriptangular = 1;
202 this.bgmscript = strzone(this.bgmscript);
203 this.bgmscriptangular = 0;
205 if(this.bgmscript != "")
207 this.bgmscriptattack = ReadByte() / 64.0;
208 this.bgmscriptdecay = ReadByte() / 64.0;
209 this.bgmscriptsustain = ReadByte() / 255.0;
210 this.bgmscriptrelease = ReadByte() / 64.0;
211 this.movedir_x = ReadCoord();
212 this.movedir_y = ReadCoord();
213 this.movedir_z = ReadCoord();
214 this.lip = ReadByte() / 255.0;
216 this.fade_start = ReadShort();
217 this.fade_end = ReadShort();
218 this.alpha_max = ReadShort();
219 this.alpha_min = ReadShort();
220 this.inactive = ReadShort();
221 this.fade_vertical_offset = ReadShort();
222 BGMScript_InitEntity(this);
227 InterpolateOrigin_Note(this);
229 this.saved = this.(fld);
231 this.entremove = Ent_Wall_Remove;
232 this.draw = Ent_Wall_Draw;
233 setpredraw(this, Ent_Wall_PreDraw);