X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fclient%2Fwall.qc;h=64916ad8c17d05251f940ed0ae9e02e340ffb8bf;hb=451e02a2857d8c671f6dcf6a0639ea7c609b3ba9;hp=f591268d358919420adcbd57851bf6e98f8b0356;hpb=9eb82dd6fc682e3ddecd471835f9047816236342;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/client/wall.qc b/qcsrc/client/wall.qc index f591268d3..64916ad8c 100644 --- a/qcsrc/client/wall.qc +++ b/qcsrc/client/wall.qc @@ -1,187 +1,235 @@ #include "wall.qh" -#include "_all.qh" #include "bgmscript.qh" -#include "../common/util.qh" -#include "../csqcmodellib/interpolate.qh" +#include "../lib/csqcmodel/interpolate.qh" .float alpha; .float scale; .vector movedir; -void Ent_Wall_Draw() +void Ent_Wall_PreDraw(entity this) +{ + if (this.inactive) + { + this.alpha = 0; + } + else + { + vector org = getpropertyvec(VF_ORIGIN); + if(!checkpvs(org, this)) + this.alpha = 0; + else if(this.fade_start || this.fade_end) { + vector offset = '0 0 0'; + offset_z = this.fade_vertical_offset; + float player_dist = vlen(org - this.origin - 0.5 * (this.mins + this.maxs) + offset); + if (this.fade_end == this.fade_start) + { + if (player_dist >= this.fade_start) + this.alpha = 0; + else + this.alpha = 1; + } + else + { + this.alpha = (this.alpha_min + this.alpha_max * bound(0, + (this.fade_end - player_dist) + / (this.fade_end - this.fade_start), 1)) / 100.0; + } + } + else + { + this.alpha = 1; + } + } + if(this.alpha <= 0) + this.drawmask = 0; + else + this.drawmask = MASK_NORMAL; +} + +void Ent_Wall_Draw(entity this) { float f; var .vector fld; - if(self.bgmscriptangular) + if(this.bgmscriptangular) fld = angles; else fld = origin; - self.(fld) = self.saved; + this.(fld) = this.saved; - if(self.lodmodelindex1) + if(this.lodmodelindex1) { if(autocvar_cl_modeldetailreduction <= 0) { - if(self.lodmodelindex2 && autocvar_cl_modeldetailreduction <= -2) - self.modelindex = self.lodmodelindex2; + if(this.lodmodelindex2 && autocvar_cl_modeldetailreduction <= -2) + this.modelindex = this.lodmodelindex2; else if(autocvar_cl_modeldetailreduction <= -1) - self.modelindex = self.lodmodelindex1; + this.modelindex = this.lodmodelindex1; else - self.modelindex = self.lodmodelindex0; + this.modelindex = this.lodmodelindex0; } else { - float distance = vlen(NearestPointOnBox(self, view_origin) - view_origin); + float distance = vlen(NearestPointOnBox(this, view_origin) - view_origin); f = (distance * current_viewzoom + 100.0) * autocvar_cl_modeldetailreduction; f *= 1.0 / bound(0.01, view_quality, 1); - if(self.lodmodelindex2 && f > self.loddistance2) - self.modelindex = self.lodmodelindex2; - else if(f > self.loddistance1) - self.modelindex = self.lodmodelindex1; + if(this.lodmodelindex2 && f > this.loddistance2) + this.modelindex = this.lodmodelindex2; + else if(f > this.loddistance1) + this.modelindex = this.lodmodelindex1; else - self.modelindex = self.lodmodelindex0; + this.modelindex = this.lodmodelindex0; } } - InterpolateOrigin_Do(); + InterpolateOrigin_Do(this); - self.saved = self.(fld); + this.saved = this.(fld); - f = doBGMScript(self); + f = doBGMScript(this); if(f >= 0) { - if(self.lip < 0) // < 0: alpha goes from 1 to 1-|lip| when toggled (toggling subtracts lip) - self.alpha = 1 + self.lip * f; + if(this.lip < 0) // < 0: alpha goes from 1 to 1-|lip| when toggled (toggling subtracts lip) + this.alpha = 1 + this.lip * f; else // > 0: alpha goes from 1-|lip| to 1 when toggled (toggling adds lip) - self.alpha = 1 - self.lip * (1 - f); - self.(fld) = self.(fld) + self.movedir * f; + this.alpha = 1 - this.lip * (1 - f); + this.(fld) = this.(fld) + this.movedir * f; } else - self.alpha = 1; + this.alpha = 1; - if(self.alpha >= ALPHA_MIN_VISIBLE) - self.drawmask = MASK_NORMAL; + if(this.alpha >= ALPHA_MIN_VISIBLE) + this.drawmask = MASK_NORMAL; else - self.drawmask = 0; + this.drawmask = 0; } -void Ent_Wall_Remove() +void Ent_Wall_Remove(entity this) { - if(self.bgmscript) - strunzone(self.bgmscript); - self.bgmscript = string_null; + if(this.bgmscript) + strunzone(this.bgmscript); + this.bgmscript = string_null; } -void Ent_Wall() +NET_HANDLE(ENT_CLIENT_WALL, bool isnew) { int f; var .vector fld; - InterpolateOrigin_Undo(); - self.iflags = IFLAG_ANGLES | IFLAG_ORIGIN; + InterpolateOrigin_Undo(this); + this.iflags = IFLAG_ANGLES | IFLAG_ORIGIN; - if(self.bgmscriptangular) + if(this.bgmscriptangular) fld = angles; else fld = origin; - self.(fld) = self.saved; + this.(fld) = this.saved; f = ReadByte(); if(f & 1) { if(f & 0x40) - self.colormap = ReadShort(); + this.colormap = ReadShort(); else - self.colormap = 0; + this.colormap = 0; } if(f & 2) { - self.origin_x = ReadCoord(); - self.origin_y = ReadCoord(); - self.origin_z = ReadCoord(); - setorigin(self, self.origin); + this.origin_x = ReadCoord(); + this.origin_y = ReadCoord(); + this.origin_z = ReadCoord(); + setorigin(this, this.origin); } if(f & 4) { if(f & 0x10) { - self.angles_x = ReadAngle(); - self.angles_y = ReadAngle(); - self.angles_z = ReadAngle(); + this.angles_x = ReadAngle(); + this.angles_y = ReadAngle(); + this.angles_z = ReadAngle(); } else - self.angles = '0 0 0'; + this.angles = '0 0 0'; } if(f & 8) { if(f & 0x80) { - self.lodmodelindex0 = ReadShort(); - self.loddistance1 = ReadShort(); - self.lodmodelindex1 = ReadShort(); - self.loddistance2 = ReadShort(); - self.lodmodelindex2 = ReadShort(); + this.lodmodelindex0 = ReadShort(); + this.loddistance1 = ReadShort(); + this.lodmodelindex1 = ReadShort(); + this.loddistance2 = ReadShort(); + this.lodmodelindex2 = ReadShort(); } else { - self.modelindex = ReadShort(); - self.loddistance1 = 0; - self.loddistance2 = 0; + this.modelindex = ReadShort(); + this.loddistance1 = 0; + this.loddistance2 = 0; } - self.solid = ReadByte(); - self.scale = ReadShort() / 256.0; + this.solid = ReadByte(); + this.scale = ReadShort() / 256.0; if(f & 0x20) { - self.mins_x = ReadCoord(); - self.mins_y = ReadCoord(); - self.mins_z = ReadCoord(); - self.maxs_x = ReadCoord(); - self.maxs_y = ReadCoord(); - self.maxs_z = ReadCoord(); + this.mins_x = ReadCoord(); + this.mins_y = ReadCoord(); + this.mins_z = ReadCoord(); + this.maxs_x = ReadCoord(); + this.maxs_y = ReadCoord(); + this.maxs_z = ReadCoord(); } else - self.mins = self.maxs = '0 0 0'; - setsize(self, self.mins, self.maxs); + this.mins = this.maxs = '0 0 0'; + setsize(this, this.mins, this.maxs); - if(self.bgmscript) - strunzone(self.bgmscript); - self.bgmscript = ReadString(); - if(substring(self.bgmscript, 0, 1) == "<") + if(this.bgmscript) + strunzone(this.bgmscript); + this.bgmscript = ReadString(); + if(substring(this.bgmscript, 0, 1) == "<") { - self.bgmscript = strzone(substring(self.bgmscript, 1, -1)); - self.bgmscriptangular = 1; + this.bgmscript = strzone(substring(this.bgmscript, 1, -1)); + this.bgmscriptangular = 1; } else { - self.bgmscript = strzone(self.bgmscript); - self.bgmscriptangular = 0; + this.bgmscript = strzone(this.bgmscript); + this.bgmscriptangular = 0; } - if(self.bgmscript != "") + if(this.bgmscript != "") { - self.bgmscriptattack = ReadByte() / 64.0; - self.bgmscriptdecay = ReadByte() / 64.0; - self.bgmscriptsustain = ReadByte() / 255.0; - self.bgmscriptrelease = ReadByte() / 64.0; - self.movedir_x = ReadCoord(); - self.movedir_y = ReadCoord(); - self.movedir_z = ReadCoord(); - self.lip = ReadByte() / 255.0; + this.bgmscriptattack = ReadByte() / 64.0; + this.bgmscriptdecay = ReadByte() / 64.0; + this.bgmscriptsustain = ReadByte() / 255.0; + this.bgmscriptrelease = ReadByte() / 64.0; + this.movedir_x = ReadCoord(); + this.movedir_y = ReadCoord(); + this.movedir_z = ReadCoord(); + this.lip = ReadByte() / 255.0; } - BGMScript_InitEntity(self); + this.fade_start = ReadByte(); + this.fade_end = ReadByte(); + this.alpha_max = ReadByte(); + this.alpha_min = ReadByte(); + this.inactive = ReadByte(); + this.fade_vertical_offset = ReadShort(); + BGMScript_InitEntity(this); } - InterpolateOrigin_Note(); + return = true; + + InterpolateOrigin_Note(this); - self.saved = self.(fld); + this.saved = this.(fld); - self.entremove = Ent_Wall_Remove; - self.draw = Ent_Wall_Draw; + this.entremove = Ent_Wall_Remove; + this.draw = Ent_Wall_Draw; + if (isnew) IL_PUSH(g_drawables, this); + setpredraw(this, Ent_Wall_PreDraw); }