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