]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/client/wall.qc
sync dpextensions with darkplaces (uri_post stuff)
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / wall.qc
1 .float lip;
2 .float bgmscriptangular;
3 .float lodmodelindex0, lodmodelindex1, lodmodelindex2;
4 .float loddistance1, loddistance2;
5 .vector saved;
6
7 void Ent_Wall_Draw()
8 {
9         float f;
10         float d;
11         var .vector fld;
12
13         if(self.bgmscriptangular)
14                 self.angles = self.saved;
15         else
16                 self.origin = self.saved;
17
18         if(self.lodmodelindex1)
19         {
20                 d = cvar("loddebug");
21                 if(d > 0)
22                 {
23                         if(d == 1)
24                                 self.modelindex = self.lodmodelindex0;
25                         else if(d == 2 || !self.lodmodelindex2)
26                                 self.modelindex = self.lodmodelindex1;
27                         else // if(d == 3)
28                                 self.modelindex = self.lodmodelindex2;
29                 }
30                 else
31                 {
32                         d = vlen(NearestPointOnBox(self, view_origin) - view_origin);
33                         if(d < self.loddistance1)
34                                 self.modelindex = self.lodmodelindex0;
35                         else if(!self.lodmodelindex2 || d < self.loddistance2)
36                                 self.modelindex = self.lodmodelindex1;
37                         else
38                                 self.modelindex = self.lodmodelindex2;
39                 }
40         }
41
42         InterpolateOrigin_Do();
43
44         if(self.bgmscriptangular)
45                 self.saved = self.angles;
46         else
47                 self.saved = self.origin;
48
49         f = BGMScript(self);
50         if(f >= 0)
51         {
52                 if(self.lip < 0) // < 0: alpha goes from 1 to 1-|lip| when toggled (toggling subtracts lip)
53                         self.alpha = 1 + self.lip * f;
54                 else // > 0: alpha goes from 1-|lip| to 1 when toggled (toggling adds lip)
55                         self.alpha = 1 - self.lip * (1 - f);
56                 self.fld = self.fld + self.movedir * f;
57         }
58         else
59                 self.alpha = 1;
60
61         if(self.alpha >= ALPHA_MIN_VISIBLE)
62                 self.drawmask = MASK_NORMAL;
63         else
64                 self.drawmask = 0;
65 }
66
67 void Ent_Wall_Remove()
68 {
69         if(self.bgmscript)
70                 strunzone(self.bgmscript);
71         self.bgmscript = string_null;
72 }
73
74 void Ent_Wall()
75 {
76         float f;
77         InterpolateOrigin_Undo();
78         self.iflags = IFLAG_ANGLES;
79
80         if(self.bgmscriptangular)
81                 self.angles = self.saved;
82         else
83                 self.origin = self.saved;
84
85         f = ReadByte();
86
87         if(f & 1)
88         {
89                 if(f & 0x40)
90                         self.colormap = ReadShort();
91                 else
92                         self.colormap = 0;
93         }
94
95         if(f & 2)
96         {
97                 self.origin_x = ReadCoord();
98                 self.origin_y = ReadCoord();
99                 self.origin_z = ReadCoord();
100         }
101
102         if(f & 4)
103         {
104                 if(f & 0x10)
105                 {
106                         self.angles_x = ReadAngle();
107                         self.angles_y = ReadAngle();
108                         self.angles_z = ReadAngle();
109                 }
110                 else
111                         self.angles = '0 0 0';
112         }
113
114         if(f & 8)
115         {
116                 if(f & 0x80)
117                 {
118                         self.lodmodelindex0 = ReadShort();
119                         self.loddistance1 = ReadShort();
120                         self.lodmodelindex1 = ReadShort();
121                         self.loddistance2 = ReadShort();
122                         self.lodmodelindex2 = ReadShort();
123                 }
124                 else
125                 {
126                         self.modelindex = ReadShort();
127                         self.loddistance1 = 0;
128                         self.loddistance2 = 0;
129                 }
130                 self.solid = ReadByte();
131                 self.scale = ReadShort() / 256.0;
132                 if(f & 0x20)
133                 {
134                         self.mins_x = ReadCoord();
135                         self.mins_y = ReadCoord();
136                         self.mins_z = ReadCoord();
137                         self.maxs_x = ReadCoord();
138                         self.maxs_y = ReadCoord();
139                         self.maxs_z = ReadCoord();
140                 }
141                 else
142                         self.mins = self.maxs = '0 0 0';
143
144                 if(self.bgmscript)
145                         strunzone(self.bgmscript);
146                 self.bgmscript = ReadString();
147                 if(substring(self.bgmscript, 0, 1) == "<")
148                 {
149                         self.bgmscript = strzone(substring(self.bgmscript, 1, -1));
150                         self.bgmscriptangular = 1;
151                 }
152                 else
153                 {
154                         self.bgmscript = strzone(self.bgmscript);
155                         self.bgmscriptangular = 0;
156                 }
157                 if(self.bgmscript != "")
158                 {
159                         self.bgmscriptattack = ReadByte() / 64.0;
160                         self.bgmscriptdecay = ReadByte() / 64.0;
161                         self.bgmscriptsustain = ReadByte() / 255.0;
162                         self.bgmscriptrelease = ReadByte() / 64.0;
163                         self.movedir_x = ReadCoord();
164                         self.movedir_y = ReadCoord();
165                         self.movedir_z = ReadCoord();
166                         self.lip = ReadByte() / 255.0;
167                 }
168                 BGMScript_InitEntity(self);
169         }
170
171         InterpolateOrigin_Note();
172
173         if(self.bgmscriptangular)
174                 self.saved = self.angles;
175         else
176                 self.saved = self.origin;
177
178         self.entremove = Ent_Wall_Remove;
179         self.draw = Ent_Wall_Draw;
180 }