comparison mm7_6.cpp @ 0:9c0607679772

init
author Ritor1
date Sat, 12 Jan 2013 09:45:18 +0600
parents
children 66319a734368
comparison
equal deleted inserted replaced
-1:000000000000 0:9c0607679772
1 #include "MM7.h"
2
3 #include "MapInfo.h"
4 #include "Game.h"
5 #include "GUIWindow.h"
6 #include "GUIFont.h"
7 #include "GUIButton.h"
8 #include "GUIProgressBar.h"
9 #include "Party.h"
10 #include "AudioPlayer.h"
11 #include "Outdoor.h"
12 #include "IndoorCamera.h"
13 #include "Overlays.h"
14 #include "Monsters.h"
15 #include "Arcomage.h"
16 #include "LOD.h"
17 #include "Actor.h"
18 #include "Allocator.h"
19 #include "Events.h"
20 #include "Viewport.h"
21 #include "FrameTableInc.h"
22 #include "Math.h"
23 #include "LayingItem.h"
24 #include "ObjectList.h"
25 #include "Chest.h"
26 #include "PaletteManager.h"
27 #include "DecorationList.h"
28 #include "SaveLoad.h"
29 #include "stru123.h"
30 #include "Time.h"
31 #include "IconFrameTable.h"
32 #include "stru179.h"
33 #include "Awards.h"
34 #include "Autonotes.h"
35 #include "stru160.h"
36 #include "stru279.h"
37 #include "TurnEngine.h"
38 #include "stru277.h"
39 #include "Weather.h"
40 #include "stru272.h"
41 #include "stru298.h"
42 #include "StorylineTextTable.h"
43 #include "Events2D.h"
44
45 #include "mm7_data.h"
46
47
48
49 //----- (00424EE0) --------------------------------------------------------
50 signed int __fastcall sr_424EE0_MakeFanFromTriangle(unsigned int uVertexID)
51 {
52 unsigned int v1; // edx@1
53 double v2; // st7@1
54 signed int v3; // edi@1
55 char *v4; // esi@4
56 char *v5; // ecx@4
57 unsigned int v6; // eax@4
58 char *v7; // edx@4
59 double v8; // st6@10
60 double v9; // st5@10
61 double v10; // st6@11
62 unsigned __int8 v11; // c2@15
63 unsigned __int8 v12; // c3@15
64 void *v13; // edi@22
65 char *v14; // eax@22
66 double v15; // st6@22
67 char *v16; // ecx@22
68 signed int result; // eax@24
69 unsigned int v18; // [sp+8h] [bp-2Ch]@4
70 bool v19; // [sp+Ch] [bp-28h]@6
71 char *v20; // [sp+10h] [bp-24h]@4
72 char *v21; // [sp+14h] [bp-20h]@4
73 signed int v22; // [sp+18h] [bp-1Ch]@1
74 char *v23; // [sp+1Ch] [bp-18h]@4
75 RenderVertexSoft *v24; // [sp+20h] [bp-14h]@4
76 char *v25; // [sp+24h] [bp-10h]@4
77 char *v26; // [sp+28h] [bp-Ch]@4
78 char *v27; // [sp+2Ch] [bp-8h]@4
79 char *v28; // [sp+30h] [bp-4h]@4
80
81 v1 = uVertexID;
82 v2 = (double)pOutdoorCamera->shading_dist_mist;
83 memcpy(&array_50AC10[uVertexID], array_50AC10, sizeof(array_50AC10[uVertexID]));
84 v3 = 0;
85 v22 = 0;
86 if ( array_50AC10[0].vWorldViewPosition.x <= v2 )
87 v3 = 1;
88 if ( (signed int)(uVertexID + 1) <= 1 )
89 return 0;
90 v4 = (char *)&array_507D30[0].vWorldViewPosition.z;
91 v5 = (char *)&array_507D30[0].vWorldViewPosition.y;
92 v6 = v1;
93 v23 = (char *)&array_507D30[0].flt_2C;
94 v26 = (char *)&array_507D30[0].flt_20;
95 v24 = array_507D30;
96 v20 = (char *)&array_507D30[0].vWorldViewPosition.z;
97 v21 = (char *)&array_507D30[0].vWorldViewPosition.y;
98 v25 = (char *)&array_507D30[0].vWorldViewPosition;
99 v27 = (char *)&array_507D30[0].v;
100 v28 = (char *)&array_507D30[0].u;
101 v7 = (char *)&array_50AC10[0].v;
102 v18 = v6;
103 do
104 {
105 v19 = v2 >= *((float *)v7 + 5);
106 if ( v3 != v19 )
107 {
108 if ( v19 )
109 {
110 v8 = (v2 - *((float *)v7 - 7)) / (*((float *)v7 + 5) - *((float *)v7 - 7));
111 *(float *)v5 = (*((float *)v7 + 6) - *((float *)v7 - 6)) * v8 + *((float *)v7 - 6);
112 *(float *)v4 = (*((float *)v7 + 7) - *((float *)v7 - 5)) * v8 + *((float *)v7 - 5);
113 *(float *)v28 = (*((float *)v7 + 11) - *((float *)v7 - 1)) * v8 + *((float *)v7 - 1);
114 v9 = (*((float *)v7 + 12) - *(float *)v7) * v8 + *(float *)v7;
115 }
116 else
117 {
118 v10 = (v2 - *((float *)v7 + 5)) / (*((float *)v7 - 7) - *((float *)v7 + 5));
119 *(float *)v5 = (*((float *)v7 - 6) - *((float *)v7 + 6)) * v10 + *((float *)v7 + 6);
120 *(float *)v4 = (*((float *)v7 - 5) - *((float *)v7 + 7)) * v10 + *((float *)v7 + 7);
121 *(float *)v28 = (*((float *)v7 - 1) - *((float *)v7 + 11)) * v10 + *((float *)v7 + 11);
122 v9 = (*(float *)v7 - *((float *)v7 + 12)) * v10 + *((float *)v7 + 12);
123 }
124 *(float *)v27 = v9;
125 *(float *)v25 = v2;
126 *(float *)v26 = 1.0 / v2;
127 if ( v3 )
128 {
129 if ( v2 == *((float *)v7 - 7) && *(float *)v5 == *((float *)v7 - 6) )
130 {
131 v11 = 0;
132 v12 = *(float *)v4 == *((float *)v7 - 5);
133 goto LABEL_19;
134 }
135 }
136 else
137 {
138 if ( v2 == *((float *)v7 + 5) && *(float *)v5 == *((float *)v7 + 6) )
139 {
140 v11 = 0;
141 v12 = *(float *)v4 == *((float *)v7 + 7);
142 LABEL_19:
143 if ( v12 | v11 )
144 goto LABEL_21;
145 goto LABEL_20;
146 }
147 }
148 LABEL_20:
149 v26 += 48;
150 ++v24;
151 v25 += 48;
152 v27 += 48;
153 v28 += 48;
154 v5 += 48;
155 v4 += 48;
156 ++v22;
157 v23 += 48;
158 v21 = v5;
159 v20 = v4;
160 }
161 LABEL_21:
162 if ( v19 )
163 {
164 v13 = v24;
165 v14 = v26;
166 v21 += 48;
167 v15 = 1.0 / (*((float *)v7 + 5) + 0.0000001);
168 v20 += 48;
169 ++v22;
170 v28 += 48;
171 v27 += 48;
172 v25 += 48;
173 ++v24;
174 v26 += 48;
175 memcpy(v13, v7 + 8, 0x30u);
176 v16 = v23;
177 v23 += 48;
178 v4 = v20;
179 *(float *)v14 = v15;
180 *(int *)v16 = *((int *)v7 + 13);
181 v5 = v21;
182 }
183 v3 = v19;
184 v7 += 48;
185 --v18;
186 }
187 while ( v18 );
188 result = v22;
189 if ( v22 < 3 )
190 return 0;
191 return result;
192 }
193
194 //----- (004250FE) --------------------------------------------------------
195 signed int __fastcall sr_4250FE(unsigned int uVertexID)
196 {
197 unsigned int v1; // edx@1
198 char *v2; // edi@5
199 char *v3; // esi@5
200 char *v4; // ecx@5
201 int v5; // ebx@6
202 double v6; // st6@11
203 double v7; // st5@11
204 double v8; // st6@12
205 unsigned __int8 v9; // c2@16
206 unsigned __int8 v10; // c3@16
207 void *v11; // edi@23
208 double v12; // st6@23
209 char *v13; // ecx@23
210 char v14; // zf@24
211 signed int result; // eax@25
212 unsigned int v16; // [sp+8h] [bp-28h]@5
213 bool v17; // [sp+Ch] [bp-24h]@2
214 bool v18; // [sp+10h] [bp-20h]@7
215 char *v19; // [sp+14h] [bp-1Ch]@5
216 char *v20; // [sp+18h] [bp-18h]@5
217 signed int v21; // [sp+1Ch] [bp-14h]@1
218 RenderVertexSoft *v22; // [sp+20h] [bp-10h]@5
219 char *v23; // [sp+24h] [bp-Ch]@5
220 char *v24; // [sp+28h] [bp-8h]@5
221 char *v25; // [sp+2Ch] [bp-4h]@5
222
223 v1 = uVertexID;
224 memcpy(&array_50AC10[uVertexID], array_50AC10, sizeof(array_50AC10[uVertexID]));
225 v21 = 0;
226 v17 = array_50AC10[0].vWorldViewPosition.x >= 8.0;
227 if ( (signed int)(uVertexID + 1) <= 1 )
228 return 0;
229 v2 = (char *)&array_507D30[0].vWorldViewPosition.z;
230 v3 = (char *)&array_507D30[0].vWorldViewPosition.y;
231 v24 = (char *)&array_507D30[0].flt_20;
232 v22 = array_507D30;
233 v19 = (char *)&array_507D30[0].vWorldViewPosition.z;
234 v20 = (char *)&array_507D30[0].vWorldViewPosition.y;
235 v23 = (char *)&array_507D30[0].vWorldViewPosition;
236 v25 = (char *)&array_507D30[0].flt_2C;
237 v4 = (char *)&array_50AC10[0].vWorldViewPosition;
238 v16 = v1;
239 do
240 {
241 v5 = (int)(v4 + 48);
242 v18 = *((float *)v4 + 12) >= 8.0;
243 if ( v17 != v18 )
244 {
245 if ( v18 )
246 {
247 v6 = (8.0 - *(float *)v4) / (*(float *)v5 - *(float *)v4);
248 *(float *)v3 = (*((float *)v4 + 13) - *((float *)v4 + 1)) * v6 + *((float *)v4 + 1);
249 *(float *)v2 = (*((float *)v4 + 14) - *((float *)v4 + 2)) * v6 + *((float *)v4 + 2);
250 v7 = (*((float *)v4 + 20) - *((float *)v4 + 8)) * v6 + *((float *)v4 + 8);
251 }
252 else
253 {
254 v8 = (8.0 - *(float *)v5) / (*(float *)v4 - *(float *)v5);
255 *(float *)v3 = (*((float *)v4 + 1) - *((float *)v4 + 13)) * v8 + *((float *)v4 + 13);
256 *(float *)v2 = (*((float *)v4 + 2) - *((float *)v4 + 14)) * v8 + *((float *)v4 + 14);
257 v7 = (*((float *)v4 + 8) - *((float *)v4 + 20)) * v8 + *((float *)v4 + 20);
258 }
259 *(float *)v25 = v7;
260 *(float *)v23 = 8.0;
261 *(int *)v24 = 0x3E000000u;
262 if ( v17 )
263 {
264 if ( 8.0 == *(float *)v4 && *(float *)v3 == *((float *)v4 + 1) )
265 {
266 v9 = 0;
267 v10 = *(float *)v2 == *((float *)v4 + 2);
268 goto LABEL_20;
269 }
270 }
271 else
272 {
273 if ( 8.0 == *(float *)v5 && *(float *)v3 == *((float *)v4 + 13) )
274 {
275 v9 = 0;
276 v10 = *(float *)v2 == *((float *)v4 + 14);
277 LABEL_20:
278 if ( v10 | v9 )
279 goto LABEL_22;
280 goto LABEL_21;
281 }
282 }
283 LABEL_21:
284 ++v22;
285 v23 += 48;
286 v25 += 48;
287 v3 += 48;
288 v2 += 48;
289 ++v21;
290 v24 += 48;
291 v20 = v3;
292 v19 = v2;
293 }
294 LABEL_22:
295 if ( v18 )
296 {
297 v11 = v22;
298 v20 += 48;
299 v19 += 48;
300 v12 = 1.0 / (*(float *)v5 + 0.0000001);
301 ++v21;
302 v25 += 48;
303 v23 += 48;
304 ++v22;
305 memcpy(v11, v4 + 36, 0x30u);
306 v13 = v24;
307 v24 += 48;
308 v3 = v20;
309 v2 = v19;
310 *(float *)v13 = v12;
311 }
312 v14 = v16-- == 1;
313 v17 = v18;
314 v4 = (char *)v5;
315 }
316 while ( !v14 );
317 result = v21;
318 if ( v21 < 3 )
319 return 0;
320 return result;
321 }
322
323 //----- (004252E8) --------------------------------------------------------
324 signed int __fastcall sr_4252E8(unsigned int uVertexID)
325 {
326 unsigned int v1; // edx@1
327 double v2; // st7@1
328 char *v3; // edi@5
329 char *v4; // esi@5
330 char *v5; // ecx@5
331 int v6; // ebx@6
332 double v7; // st6@11
333 double v8; // st5@11
334 double v9; // st6@12
335 unsigned __int8 v10; // c2@16
336 unsigned __int8 v11; // c3@16
337 void *v12; // edi@23
338 double v13; // st6@23
339 char *v14; // ecx@23
340 char v15; // zf@24
341 signed int result; // eax@25
342 unsigned int v17; // [sp+8h] [bp-28h]@5
343 bool v18; // [sp+Ch] [bp-24h]@2
344 bool v19; // [sp+10h] [bp-20h]@7
345 char *v20; // [sp+14h] [bp-1Ch]@5
346 char *v21; // [sp+18h] [bp-18h]@5
347 signed int v22; // [sp+1Ch] [bp-14h]@1
348 RenderVertexSoft *v23; // [sp+20h] [bp-10h]@5
349 char *v24; // [sp+24h] [bp-Ch]@5
350 char *v25; // [sp+28h] [bp-8h]@5
351 char *v26; // [sp+2Ch] [bp-4h]@5
352
353 v1 = uVertexID;
354 v2 = (double)pOutdoorCamera->shading_dist_mist;
355 memcpy(&array_50AC10[uVertexID], array_50AC10, sizeof(array_50AC10[uVertexID]));
356 v22 = 0;
357 v18 = array_50AC10[0].vWorldViewPosition.x <= v2;
358 if ( (signed int)(uVertexID + 1) <= 1 )
359 return 0;
360 v3 = (char *)&array_507D30[0].vWorldViewPosition.z;
361 v4 = (char *)&array_507D30[0].vWorldViewPosition.y;
362 v25 = (char *)&array_507D30[0].flt_20;
363 v23 = array_507D30;
364 v20 = (char *)&array_507D30[0].vWorldViewPosition.z;
365 v21 = (char *)&array_507D30[0].vWorldViewPosition.y;
366 v24 = (char *)&array_507D30[0].vWorldViewPosition;
367 v26 = (char *)&array_507D30[0].flt_2C;
368 v5 = (char *)&array_50AC10[0].vWorldViewPosition;
369 v17 = v1;
370 do
371 {
372 v6 = (int)(v5 + 48);
373 v19 = v2 >= *((float *)v5 + 12);
374 if ( v18 != v19 )
375 {
376 if ( v19 )
377 {
378 v7 = (v2 - *(float *)v5) / (*(float *)v6 - *(float *)v5);
379 *(float *)v4 = (*((float *)v5 + 13) - *((float *)v5 + 1)) * v7 + *((float *)v5 + 1);
380 *(float *)v3 = (*((float *)v5 + 14) - *((float *)v5 + 2)) * v7 + *((float *)v5 + 2);
381 v8 = (*((float *)v5 + 20) - *((float *)v5 + 8)) * v7 + *((float *)v5 + 8);
382 }
383 else
384 {
385 v9 = (v2 - *(float *)v6) / (*(float *)v5 - *(float *)v6);
386 *(float *)v4 = (*((float *)v5 + 1) - *((float *)v5 + 13)) * v9 + *((float *)v5 + 13);
387 *(float *)v3 = (*((float *)v5 + 2) - *((float *)v5 + 14)) * v9 + *((float *)v5 + 14);
388 v8 = (*((float *)v5 + 8) - *((float *)v5 + 20)) * v9 + *((float *)v5 + 20);
389 }
390 *(float *)v26 = v8;
391 *(float *)v24 = v2;
392 *(float *)v25 = 1.0 / v2;
393 if ( v18 )
394 {
395 if ( v2 == *(float *)v5 && *(float *)v4 == *((float *)v5 + 1) )
396 {
397 v10 = 0;
398 v11 = *(float *)v3 == *((float *)v5 + 2);
399 goto LABEL_20;
400 }
401 }
402 else
403 {
404 if ( v2 == *(float *)v6 && *(float *)v4 == *((float *)v5 + 13) )
405 {
406 v10 = 0;
407 v11 = *(float *)v3 == *((float *)v5 + 14);
408 LABEL_20:
409 if ( v11 | v10 )
410 goto LABEL_22;
411 goto LABEL_21;
412 }
413 }
414 LABEL_21:
415 ++v23;
416 v24 += 48;
417 v26 += 48;
418 v4 += 48;
419 v3 += 48;
420 ++v22;
421 v25 += 48;
422 v21 = v4;
423 v20 = v3;
424 }
425 LABEL_22:
426 if ( v19 )
427 {
428 v12 = v23;
429 v21 += 48;
430 v20 += 48;
431 v13 = 1.0 / (*(float *)v6 + 0.0000001);
432 ++v22;
433 v26 += 48;
434 v24 += 48;
435 ++v23;
436 memcpy(v12, v5 + 36, 0x30u);
437 v14 = v25;
438 v25 += 48;
439 v4 = v21;
440 v3 = v20;
441 *(float *)v14 = v13;
442 }
443 v15 = v17-- == 1;
444 v18 = v19;
445 v5 = (char *)v6;
446 }
447 while ( !v15 );
448 result = v22;
449 if ( v22 < 3 )
450 return 0;
451 return result;
452 }
453
454
455
456 //----- (004361EF) --------------------------------------------------------
457 IndoorCameraD3D::IndoorCameraD3D()
458 {
459 IndoorCameraD3D *v1; // esi@1
460 double v2; // st7@1
461 double v3; // st6@1
462 double v4; // st5@1
463 double v5; // st7@1
464 double v6; // st6@1
465 double v7; // st5@1
466
467 v1 = this;
468 //IndoorCameraD3D_Vec3::IndoorCameraD3D_Vec3(&this->field_4);
469 //IndoorCameraD3D_Vec3::IndoorCameraD3D_Vec3(&v1->field_14);
470 //IndoorCameraD3D_Vec3::IndoorCameraD3D_Vec3(&v1->field_24);
471 /*_eh_vector_constructor_iterator_(v1->std__vector_000034_prolly_frustrum,
472 24,
473 6,
474 (void (__thiscall *)(void *))IndoorCameraD3D_Vec4::IndoorCameraD3D_Vec4,
475 (void (__thiscall *)(void *))IndoorCameraD3D_Vec4::dtor);*/
476 v2 = 0;//(double)pBLVRenderParams->vPartyPos.z;
477 v3 = 0;//(double)pBLVRenderParams->vPartyPos.y;
478 v4 = 0;//(double)pBLVRenderParams->vPartyPos.x;
479 v1->field_108 = 0.0;
480 v1->field_DC = v4;
481 v1->field_E0 = v3;
482 v1->field_E4 = v2;
483 v5 = 0;//(double)pBLVRenderParams->vPartyPos.z;
484 v6 = 0;//(double)pBLVRenderParams->vPartyPos.y;
485 v7 = 300;//(double)(pBLVRenderParams->vPartyPos.x + 300);
486 v1->field_138 = 0.0;
487 v1->field_10C = v7;
488 v1->field_110 = v6;
489 v1->field_114 = v5;
490 v1->field_168 = 0.0;
491 v1->field_198 = 0.0;
492 v1->field_1C8 = 0.0;
493 v1->field_1F8 = 0.0;
494 v1->field_228 = 0.0;
495 v1->field_258 = 0.0;
496 v1->field_288 = 0.0;
497 v1->field_2B8 = 0.0;
498 v1->field_2E8 = 0.0;
499 v1->field_2BC = 0.0;
500 v1->field_2C0 = 0.0;
501 v1->field_2C4 = 0.0;
502 v1->field_318 = 0.0;
503 v1->field_2EC = 0.0;
504 v1->field_2F0 = 0.0;
505 v1->field_2F4 = 0.0;
506 v1->field_348 = 0.0;
507 v1->field_31C = 0.0;
508 v1->field_320 = 0.0;
509 v1->field_324 = 0.0;
510 v1->field_378 = 0.0;
511 v1->field_34C = 0.0;
512 v1->field_350 = 0.0;
513 v1->field_354 = 0.0;
514 for (uint i = 0; i < 16384; ++i)
515 {
516 list_0037C[i].field_0 = 0;
517 list_0037C[i].flt_30 = 0.0f;
518 }
519
520 list_0037C_size = 0;
521 for (uint i = 0; i < 256; ++i)
522 list_E0380[i].mm7__vector_000004_size = 0;
523 /*v10 = v1->list_E0380;
524 v12 = 256;
525 do
526 {
527 v10->mm7__vector_000004_size = 0;
528 //mm7__vector_constructor(
529 // v10->mm7__vector_000004,
530 // 48,
531 // 64,
532 // (int (__thiscall *)(int))IndoorCameraD3D_stru1::IndoorCameraD3D_stru1);
533 //++v10;
534 --v12;
535 }
536 while ( v12 );*/
537 list_E0380_size = 0;
538 //v1->vdestructor_ptr = &stru8_pvdtor;
539 }
540
541
542 //----- (004254D2) --------------------------------------------------------
543 int __fastcall sr_4254D2(signed int a1)
544 {
545 signed int v1; // ebx@2
546 int v2; // ecx@2
547 int result; // eax@11
548 double v4; // ST74_8@12
549 bool v5; // edi@12
550 char *v6; // esi@13
551 char *v7; // ebx@13
552 double v8; // st7@15
553 double v9; // st7@16
554 double v10; // st6@16
555 double v11; // st7@17
556 float v12; // eax@18
557 double v13; // ST4C_8@19
558 double v14; // ST10_8@19
559 double v15; // ST28_8@20
560 double v16; // ST34_8@20
561 char v17; // zf@20
562 double v18; // ST18_8@21
563 double v19; // ST3C_8@21
564 double v20; // ST44_8@22
565 double v21; // ST54_8@22
566 void *v22; // edi@26
567 double v23; // ST54_8@29
568 bool v24; // esi@29
569 char *v25; // edi@30
570 char *v26; // ebx@30
571 bool v27; // ecx@32
572 double v28; // st7@33
573 double v29; // st7@34
574 double v30; // st6@34
575 double v31; // st7@35
576 double v32; // ST44_8@37
577 double v33; // ST3C_8@37
578 double v34; // ST18_8@38
579 double v35; // ST34_8@38
580 char v36; // zf@38
581 double v37; // ST28_8@39
582 double v38; // ST10_8@39
583 double v39; // ST20_8@40
584 double v40; // ST5C_8@40
585 void *v41; // edi@44
586 double v42; // ST5C_8@47
587 bool v43; // edi@47
588 char *v44; // esi@48
589 char *v45; // ebx@48
590 bool v46; // ecx@49
591 double v47; // st6@50
592 double v48; // st6@51
593 double v49; // st5@51
594 double v50; // st6@52
595 double v51; // ST20_8@54
596 double v52; // ST54_8@54
597 double v53; // ST44_8@55
598 double v54; // ST3C_8@55
599 char v55; // zf@55
600 double v56; // ST18_8@56
601 double v57; // ST34_8@56
602 double v58; // ST28_8@57
603 double v59; // ST10_8@57
604 void *v60; // edi@61
605 double v61; // ST5C_8@64
606 bool v62; // edi@64
607 char *v63; // esi@65
608 char *v64; // ebx@65
609 bool v65; // ecx@66
610 double v66; // st6@67
611 double v67; // st6@68
612 double v68; // st5@68
613 double v69; // st6@69
614 double v70; // ST20_8@71
615 double v71; // ST54_8@71
616 double v72; // ST44_8@72
617 double v73; // ST3C_8@72
618 char v74; // zf@72
619 double v75; // ST18_8@73
620 double v76; // ST34_8@73
621 double v77; // ST28_8@74
622 double v78; // ST10_8@74
623 void *v79; // edi@78
624 int v80; // ebx@81
625 char *v81; // ecx@82
626 signed int v82; // esi@82
627 float v83; // ST78_4@83
628 double v84; // ST5C_8@83
629 float v85; // eax@84
630 double v86; // ST20_8@85
631 double v87; // ST54_8@88
632 float v88; // eax@89
633 double v89; // ST44_8@90
634 unsigned __int8 v90; // sf@94
635 unsigned __int8 v91; // of@94
636 int v92; // edx@97
637 int v93; // esi@97
638 int v94; // edi@97
639 int v95; // eax@97
640 int v96; // eax@104
641 double v97; // [sp+4Ch] [bp-8Ch]@32
642 double v98; // [sp+54h] [bp-84h]@49
643 double v99; // [sp+54h] [bp-84h]@66
644 float v100; // [sp+5Ch] [bp-7Ch]@1
645 float v101; // [sp+60h] [bp-78h]@1
646 float v102; // [sp+64h] [bp-74h]@1
647 double v103; // [sp+6Ch] [bp-6Ch]@14
648 float v104; // [sp+A8h] [bp-30h]@1
649 signed int v105; // [sp+A8h] [bp-30h]@96
650 bool v106; // [sp+ACh] [bp-2Ch]@14
651 bool v107; // [sp+ACh] [bp-2Ch]@32
652 bool v108; // [sp+ACh] [bp-2Ch]@49
653 bool v109; // [sp+ACh] [bp-2Ch]@66
654 signed int v110; // [sp+B0h] [bp-28h]@12
655 char *v111; // [sp+B8h] [bp-20h]@30
656 signed int v112; // [sp+B8h] [bp-20h]@48
657 signed int v113; // [sp+B8h] [bp-20h]@65
658 char *v114; // [sp+BCh] [bp-1Ch]@13
659 signed int v115; // [sp+BCh] [bp-1Ch]@29
660 signed int v116; // [sp+BCh] [bp-1Ch]@64
661 signed int v117; // [sp+C0h] [bp-18h]@1
662 char *v118; // [sp+C0h] [bp-18h]@30
663 char *v119; // [sp+C0h] [bp-18h]@48
664 char *v120; // [sp+C0h] [bp-18h]@65
665 char *v121; // [sp+C4h] [bp-14h]@13
666 char *v122; // [sp+C4h] [bp-14h]@30
667 signed int v123; // [sp+C4h] [bp-14h]@47
668 char *v124; // [sp+C8h] [bp-10h]@30
669 char *v125; // [sp+C8h] [bp-10h]@48
670 char *v126; // [sp+C8h] [bp-10h]@65
671 signed int v127; // [sp+CCh] [bp-Ch]@2
672 char *v128; // [sp+CCh] [bp-Ch]@13
673 char *v129; // [sp+CCh] [bp-Ch]@30
674 RenderVertexSoft *v130; // [sp+CCh] [bp-Ch]@48
675 RenderVertexSoft *v131; // [sp+CCh] [bp-Ch]@65
676 RenderVertexSoft *v132; // [sp+D0h] [bp-8h]@13
677 char *v133; // [sp+D0h] [bp-8h]@30
678 char *v134; // [sp+D0h] [bp-8h]@48
679 char *v135; // [sp+D0h] [bp-8h]@65
680 signed int v136; // [sp+D4h] [bp-4h]@1
681 char *v137; // [sp+D4h] [bp-4h]@13
682 RenderVertexSoft *v138; // [sp+D4h] [bp-4h]@30
683 char *v139; // [sp+D4h] [bp-4h]@48
684 char *v140; // [sp+D4h] [bp-4h]@65
685
686 v101 = (double)(signed int)pViewport->uViewportX;
687 v100 = (double)(signed int)pViewport->uViewportZ;
688 v117 = a1;
689 v136 = 1;
690 v104 = (double)(signed int)pViewport->uViewportY;
691 v102 = (double)(pViewport->uViewportW + 1);
692 if ( a1 <= 0 )
693 return v117;
694 v127 = a1;
695 v1 = a1;
696 memcpy(array_508690, array_50AC10, 4 * ((unsigned int)(48 * a1) >> 2));
697 v2 = 0;
698 do
699 {
700 if ( array_50AC10[v2].vWorldViewProjX < (double)v101 || array_50AC10[v2].vWorldViewProjX > (double)v100 )
701 v136 = 0;
702 if ( *(float *)(v2 * 48 + 5286956) < (double)v104 || *(float *)(v2 * 48 + 5286956) > (double)v102 )
703 v136 = 0;
704 ++v2;
705 --v127;
706 }
707 while ( v127 );
708 if ( v136 )
709 return v117;
710 v110 = 0;
711 memcpy(&array_50AC10[v1], array_50AC10, sizeof(array_50AC10[v1]));
712 v4 = array_50AC10[0].vWorldViewProjX + 6.7553994e15;
713 v5 = SLODWORD(v4) >= (signed int)pViewport->uViewportX;
714 if ( v117 < 1 )
715 goto LABEL_112;
716 v6 = (char *)&array_50A2B0[0].vWorldViewProjY;
717 v132 = array_50A2B0;
718 v137 = (char *)&array_50A2B0[0].vWorldViewProjX;
719 v128 = (char *)&array_50A2B0[0].vWorldViewProjY;
720 v121 = (char *)&array_50A2B0[0].flt_2C;
721 v114 = (char *)&array_50A2B0[0].flt_20;
722 v7 = (char *)&array_50AC10[0].flt_2C;
723 do
724 {
725 v103 = *((float *)v7 + 7) + 6.7553994e15;
726 v106 = SLODWORD(v103) >= (signed int)pViewport->uViewportX;
727 if ( !(v5 ^ v106) )
728 goto LABEL_25;
729 v8 = v101;
730 if ( SLODWORD(v103) >= (signed int)pViewport->uViewportX )
731 {
732 v9 = (v8 - *((float *)v7 - 5)) / (*((float *)v7 + 7) - *((float *)v7 - 5));
733 *(float *)v6 = (*((float *)v7 + 8) - *((float *)v7 - 4)) * v9 + *((float *)v7 - 4);
734 *(float *)v114 = (*((float *)v7 + 9) - *((float *)v7 - 3)) * v9 + *((float *)v7 - 3);
735 v10 = (*((float *)v7 + 12) - *(float *)v7) * v9 + *(float *)v7;
736 }
737 else
738 {
739 v11 = (v8 - *((float *)v7 + 7)) / (*((float *)v7 - 5) - *((float *)v7 + 7));
740 *(float *)v6 = (*((float *)v7 - 4) - *((float *)v7 + 8)) * v11 + *((float *)v7 + 8);
741 *(float *)v114 = (*((float *)v7 - 3) - *((float *)v7 + 9)) * v11 + *((float *)v7 + 9);
742 v10 = (*(float *)v7 - *((float *)v7 + 12)) * v11 + *((float *)v7 + 12);
743 }
744 *(float *)v121 = v10;
745 *(int *)v137 = LODWORD(v101);
746 LODWORD(v12) = *(int *)v6;
747 if ( v5 )
748 {
749 v13 = v12 + 6.7553994e15;
750 v14 = *((float *)v7 - 4) + 6.7553994e15;
751 if ( LODWORD(v13) == LODWORD(v14) )
752 {
753 v15 = *(float *)v137 + 6.7553994e15;
754 v16 = *((float *)v7 - 5) + 6.7553994e15;
755 v17 = LODWORD(v15) == LODWORD(v16);
756 goto LABEL_23;
757 }
758 }
759 else
760 {
761 v18 = v12 + 6.7553994e15;
762 v19 = *((float *)v7 + 8) + 6.7553994e15;
763 if ( LODWORD(v18) == LODWORD(v19) )
764 {
765 v20 = *(float *)v137 + 6.7553994e15;
766 v21 = *((float *)v7 + 7) + 6.7553994e15;
767 v17 = LODWORD(v20) == LODWORD(v21);
768 LABEL_23:
769 if ( v17 )
770 goto LABEL_25;
771 goto LABEL_24;
772 }
773 }
774 LABEL_24:
775 v121 += 48;
776 v114 += 48;
777 v6 += 48;
778 ++v110;
779 ++v132;
780 v128 = v6;
781 v137 += 48;
782 LABEL_25:
783 if ( v106 )
784 {
785 v22 = v132;
786 v128 += 48;
787 ++v110;
788 v114 += 48;
789 v121 += 48;
790 v137 += 48;
791 ++v132;
792 memcpy(v22, v7 + 4, 0x30u);
793 v6 = v128;
794 }
795 v5 = v106;
796 v7 += 48;
797 --v117;
798 }
799 while ( v117 );
800 if ( v110 < 3
801 || (v115 = 0,
802 memcpy(&array_50A2B0[v110], array_50A2B0, sizeof(array_50A2B0[v110])),
803 v23 = array_50A2B0[0].vWorldViewProjX + 6.7553994e15,
804 v24 = SLODWORD(v23) <= (signed int)pViewport->uViewportZ,
805 v110 < 1) )
806 goto LABEL_112;
807 v25 = (char *)&array_509950[0].flt_20;
808 v138 = array_509950;
809 v129 = (char *)&array_50A2B0[0].vWorldViewProjX;
810 v118 = (char *)&array_50A2B0[0].vWorldViewProjY;
811 v133 = (char *)&array_509950[0].vWorldViewProjX;
812 v122 = (char *)&array_509950[0].vWorldViewProjY;
813 v124 = (char *)&array_509950[0].flt_2C;
814 v111 = (char *)&array_509950[0].flt_20;
815 v26 = (char *)&array_50A2B0[0].flt_2C;
816 while ( 2 )
817 {
818 v97 = *((float *)v26 + 7) + 6.7553994e15;
819 v27 = SLODWORD(v97) <= (signed int)pViewport->uViewportZ;
820 v107 = SLODWORD(v97) <= (signed int)pViewport->uViewportZ;
821 if ( v24 != v27 )
822 {
823 v28 = v100;
824 if ( SLODWORD(v97) <= (signed int)pViewport->uViewportZ )
825 {
826 v29 = (v28 - *((float *)v26 - 5)) / (*((float *)v26 + 7) - *((float *)v26 - 5));
827 *(float *)v122 = (*((float *)v26 + 8) - *((float *)v26 - 4)) * v29 + *((float *)v26 - 4);
828 *(float *)v25 = (*((float *)v26 + 9) - *((float *)v26 - 3)) * v29 + *((float *)v26 - 3);
829 v30 = (*((float *)v26 + 12) - *(float *)v26) * v29 + *(float *)v26;
830 }
831 else
832 {
833 v31 = (v28 - *((float *)v26 + 7)) / (*((float *)v26 - 5) - *((float *)v26 + 7));
834 *(float *)v122 = (*((float *)v26 - 4) - *((float *)v26 + 8)) * v31 + *((float *)v26 + 8);
835 *(float *)v25 = (*((float *)v26 - 3) - *((float *)v26 + 9)) * v31 + *((float *)v26 + 9);
836 v30 = (*(float *)v26 - *((float *)v26 + 12)) * v31 + *((float *)v26 + 12);
837 }
838 *(float *)v124 = v30;
839 *(int *)v133 = LODWORD(v100);
840 if ( v24 )
841 {
842 v32 = *(float *)v122 + 6.7553994e15;
843 v33 = *((float *)v26 - 4) + 6.7553994e15;
844 if ( LODWORD(v32) == LODWORD(v33) )
845 {
846 v34 = *(float *)v133 + 6.7553994e15;
847 v35 = *((float *)v26 - 5) + 6.7553994e15;
848 v36 = LODWORD(v34) == LODWORD(v35);
849 goto LABEL_41;
850 }
851 goto LABEL_42;
852 }
853 v37 = *(float *)v118 + 6.7553994e15;
854 v38 = *((float *)v26 + 8) + 6.7553994e15;
855 if ( LODWORD(v37) != LODWORD(v38) )
856 goto LABEL_42;
857 v39 = *(float *)v129 + 6.7553994e15;
858 v40 = *((float *)v26 + 7) + 6.7553994e15;
859 v36 = LODWORD(v39) == LODWORD(v40);
860 LABEL_41:
861 if ( !v36 )
862 {
863 LABEL_42:
864 v129 += 48;
865 v118 += 48;
866 v133 += 48;
867 v122 += 48;
868 v124 += 48;
869 v111 += 48;
870 ++v115;
871 ++v138;
872 }
873 }
874 if ( v27 )
875 {
876 v41 = v138;
877 ++v115;
878 v111 += 48;
879 v124 += 48;
880 v122 += 48;
881 v133 += 48;
882 v118 += 48;
883 v129 += 48;
884 ++v138;
885 memcpy(v41, v26 + 4, 0x30u);
886 }
887 v24 = v107;
888 v26 += 48;
889 --v110;
890 if ( v110 )
891 {
892 v25 = v111;
893 continue;
894 }
895 break;
896 }
897 if ( v115 < 3
898 || (v123 = 0,
899 memcpy(&array_509950[v115], array_509950, sizeof(array_509950[v115])),
900 v42 = array_509950[0].vWorldViewProjY + 6.7553994e15,
901 v43 = SLODWORD(v42) >= (signed int)pViewport->uViewportY,
902 v115 < 1) )
903 goto LABEL_112;
904 v44 = (char *)&array_508FF0[0].vWorldViewProjX;
905 v130 = array_508FF0;
906 v119 = (char *)&array_508FF0[0].vWorldViewProjX;
907 v139 = (char *)&array_508FF0[0].vWorldViewProjY;
908 v125 = (char *)&array_508FF0[0].flt_2C;
909 v134 = (char *)&array_508FF0[0].flt_20;
910 v45 = (char *)&array_509950[0].flt_2C;
911 v112 = v115;
912 while ( 2 )
913 {
914 v98 = *((float *)v45 + 8) + 6.7553994e15;
915 v46 = SLODWORD(v98) >= (signed int)pViewport->uViewportY;
916 v108 = SLODWORD(v98) >= (signed int)pViewport->uViewportY;
917 if ( v43 != v46 )
918 {
919 v47 = v104;
920 if ( SLODWORD(v98) >= (signed int)pViewport->uViewportY )
921 {
922 v48 = (v47 - *((float *)v45 - 4)) / (*((float *)v45 + 8) - *((float *)v45 - 4));
923 *(float *)v44 = (*((float *)v45 + 7) - *((float *)v45 - 5)) * v48 + *((float *)v45 - 5);
924 *(float *)v134 = (*((float *)v45 + 9) - *((float *)v45 - 3)) * v48 + *((float *)v45 - 3);
925 v49 = (*((float *)v45 + 12) - *(float *)v45) * v48 + *(float *)v45;
926 }
927 else
928 {
929 v50 = (v47 - *((float *)v45 + 8)) / (*((float *)v45 - 4) - *((float *)v45 + 8));
930 *(float *)v44 = (*((float *)v45 - 5) - *((float *)v45 + 7)) * v50 + *((float *)v45 + 7);
931 *(float *)v134 = (*((float *)v45 - 3) - *((float *)v45 + 9)) * v50 + *((float *)v45 + 9);
932 v49 = (*(float *)v45 - *((float *)v45 + 12)) * v50 + *((float *)v45 + 12);
933 }
934 *(float *)v125 = v49;
935 *(float *)v139 = v104;
936 if ( v43 )
937 {
938 v51 = v104 + 6.7553994e15;
939 v52 = *((float *)v45 - 4) + 6.7553994e15;
940 if ( LODWORD(v51) == LODWORD(v52) )
941 {
942 v53 = *(float *)v44 + 6.7553994e15;
943 v54 = *((float *)v45 - 5) + 6.7553994e15;
944 v55 = LODWORD(v53) == LODWORD(v54);
945 goto LABEL_58;
946 }
947 goto LABEL_59;
948 }
949 v56 = v104 + 6.7553994e15;
950 v57 = *((float *)v45 + 8) + 6.7553994e15;
951 if ( LODWORD(v56) != LODWORD(v57) )
952 goto LABEL_59;
953 v58 = *(float *)v44 + 6.7553994e15;
954 v59 = *((float *)v45 + 7) + 6.7553994e15;
955 v55 = LODWORD(v58) == LODWORD(v59);
956 LABEL_58:
957 if ( !v55 )
958 {
959 LABEL_59:
960 v139 += 48;
961 v125 += 48;
962 v134 += 48;
963 v44 += 48;
964 ++v123;
965 ++v130;
966 v119 = v44;
967 }
968 }
969 if ( v46 )
970 {
971 v60 = v130;
972 v119 += 48;
973 ++v123;
974 v134 += 48;
975 v125 += 48;
976 v139 += 48;
977 ++v130;
978 memcpy(v60, v45 + 4, 0x30u);
979 v44 = v119;
980 }
981 v43 = v108;
982 v45 += 48;
983 --v112;
984 if ( v112 )
985 continue;
986 break;
987 }
988 if ( v123 < 3
989 || (v116 = 0,
990 memcpy(&array_508FF0[v123], array_508FF0, sizeof(array_508FF0[v123])),
991 v61 = array_508FF0[0].vWorldViewProjY + 6.7553994e15,
992 v62 = SLODWORD(v61) <= (signed int)pViewport->uViewportW,
993 v123 < 1) )
994 goto LABEL_112;
995 v63 = (char *)&array_508690[0].vWorldViewProjX;
996 v131 = array_508690;
997 v120 = (char *)&array_508690[0].vWorldViewProjX;
998 v140 = (char *)&array_508690[0].vWorldViewProjY;
999 v126 = (char *)&array_508690[0].flt_2C;
1000 v135 = (char *)&array_508690[0].flt_20;
1001 v64 = (char *)&array_508FF0[0].flt_2C;
1002 v113 = v123;
1003 while ( 2 )
1004 {
1005 v99 = *((float *)v64 + 8) + 6.7553994e15;
1006 v65 = SLODWORD(v99) <= (signed int)pViewport->uViewportW;
1007 v109 = SLODWORD(v99) <= (signed int)pViewport->uViewportW;
1008 if ( v62 != v65 )
1009 {
1010 v66 = v102;
1011 if ( SLODWORD(v99) <= (signed int)pViewport->uViewportW )
1012 {
1013 v67 = (v66 - *((float *)v64 - 4)) / (*((float *)v64 + 8) - *((float *)v64 - 4));
1014 *(float *)v63 = (*((float *)v64 + 7) - *((float *)v64 - 5)) * v67 + *((float *)v64 - 5);
1015 *(float *)v135 = (*((float *)v64 + 9) - *((float *)v64 - 3)) * v67 + *((float *)v64 - 3);
1016 v68 = (*((float *)v64 + 12) - *(float *)v64) * v67 + *(float *)v64;
1017 }
1018 else
1019 {
1020 v69 = (v66 - *((float *)v64 + 8)) / (*((float *)v64 - 4) - *((float *)v64 + 8));
1021 *(float *)v63 = (*((float *)v64 - 5) - *((float *)v64 + 7)) * v69 + *((float *)v64 + 7);
1022 *(float *)v135 = (*((float *)v64 - 3) - *((float *)v64 + 9)) * v69 + *((float *)v64 + 9);
1023 v68 = (*(float *)v64 - *((float *)v64 + 12)) * v69 + *((float *)v64 + 12);
1024 }
1025 *(float *)v126 = v68;
1026 *(float *)v140 = v102;
1027 if ( v62 )
1028 {
1029 v70 = v102 + 6.7553994e15;
1030 v71 = *((float *)v64 - 4) + 6.7553994e15;
1031 if ( LODWORD(v70) == LODWORD(v71) )
1032 {
1033 v72 = *(float *)v63 + 6.7553994e15;
1034 v73 = *((float *)v64 - 5) + 6.7553994e15;
1035 v74 = LODWORD(v72) == LODWORD(v73);
1036 goto LABEL_75;
1037 }
1038 goto LABEL_76;
1039 }
1040 v75 = v102 + 6.7553994e15;
1041 v76 = *((float *)v64 + 8) + 6.7553994e15;
1042 if ( LODWORD(v75) != LODWORD(v76) )
1043 goto LABEL_76;
1044 v77 = *(float *)v63 + 6.7553994e15;
1045 v78 = *((float *)v64 + 7) + 6.7553994e15;
1046 v74 = LODWORD(v77) == LODWORD(v78);
1047 LABEL_75:
1048 if ( !v74 )
1049 {
1050 LABEL_76:
1051 v140 += 48;
1052 v126 += 48;
1053 v135 += 48;
1054 v63 += 48;
1055 ++v116;
1056 ++v131;
1057 v120 = v63;
1058 }
1059 }
1060 if ( v65 )
1061 {
1062 v79 = v131;
1063 v120 += 48;
1064 ++v116;
1065 v135 += 48;
1066 v126 += 48;
1067 v140 += 48;
1068 ++v131;
1069 memcpy(v79, v64 + 4, 0x30u);
1070 v63 = v120;
1071 }
1072 v62 = v109;
1073 v64 += 48;
1074 --v113;
1075 if ( v113 )
1076 continue;
1077 break;
1078 }
1079 if ( v116 < 3 )
1080 goto LABEL_112;
1081 v80 = v116;
1082 memcpy(&array_508690[v116], array_508690, sizeof(array_508690[v116]));
1083 if ( v116 > 0 )
1084 {
1085 v81 = (char *)&array_508690[0].vWorldViewProjX;
1086 v82 = v116;
1087 do
1088 {
1089 LODWORD(v83) = *(int *)v81;
1090 *((float *)v81 - 3) = 1.0 / *((float *)v81 + 2);
1091 v84 = v83 + 6.7553994e15;
1092 if ( SLODWORD(v84) <= (signed int)pViewport->uViewportZ )
1093 {
1094 v86 = *(float *)v81 + 6.7553994e15;
1095 if ( SLODWORD(v86) >= (signed int)pViewport->uViewportX )
1096 goto LABEL_88;
1097 v85 = v101;
1098 }
1099 else
1100 {
1101 v85 = v100;
1102 }
1103 *(int *)v81 = LODWORD(v85);
1104 LABEL_88:
1105 v87 = *((float *)v81 + 1) + 6.7553994e15;
1106 if ( SLODWORD(v87) > (signed int)pViewport->uViewportW )
1107 {
1108 v88 = v102;
1109 LABEL_92:
1110 *((int *)v81 + 1) = LODWORD(v88);
1111 goto LABEL_93;
1112 }
1113 v89 = *((float *)v81 + 1) + 6.7553994e15;
1114 if ( SLODWORD(v89) < (signed int)pViewport->uViewportY )
1115 {
1116 v88 = v104;
1117 goto LABEL_92;
1118 }
1119 LABEL_93:
1120 v81 += 48;
1121 --v82;
1122 }
1123 while ( v82 );
1124 }
1125 v91 = __OFSUB__(v116, 3);
1126 v90 = v116 - 3 < 0;
1127 if ( v116 > 3 )
1128 {
1129 memcpy(&array_508690[v116 + 1], &array_508690[1], sizeof(array_508690[v116 + 1]));
1130 if ( v116 > 0 )
1131 {
1132 v105 = 1;
1133 do
1134 {
1135 v92 = v105;
1136 v93 = v105 - 1;
1137 v94 = v105 + 1;
1138 v95 = v105 + 1;
1139 if ( v105 - 1 >= v80 )
1140 v93 -= v80;
1141 if ( v105 >= v80 )
1142 v92 = v105 - v80;
1143 if ( v94 >= v80 )
1144 v95 = v94 - v80;
1145 if ( (array_508690[v92].vWorldViewProjX - array_508690[v93].vWorldViewProjX)
1146 * (array_508690[v95].vWorldViewProjY - array_508690[v93].vWorldViewProjY)
1147 - (array_508690[v95].vWorldViewProjX - array_508690[v93].vWorldViewProjX)
1148 * (array_508690[v92].vWorldViewProjY - array_508690[v93].vWorldViewProjY) < 0.0 )
1149 {
1150 ++v105;
1151 }
1152 else
1153 {
1154 v96 = v105;
1155 if ( v105 < v80 || (v96 = v105 - v80, v105 - v80 < v80) )
1156 memcpy(&array_508690[v96], &array_508690[v96 + 1], 4 * ((unsigned int)(48 * v80 - 48 * v96) >> 2));
1157 --v80;
1158 }
1159 }
1160 while ( v105 - 1 < v80 );
1161 }
1162 v91 = __OFSUB__(v80, 3);
1163 v90 = v80 - 3 < 0;
1164 }
1165 if ( v90 ^ v91 )
1166 LABEL_112:
1167 result = 0;
1168 else
1169 result = v80;
1170 return result;
1171 }
1172
1173 //----- (0042620A) --------------------------------------------------------
1174 bool __thiscall sr_42620A(RenderVertexSoft *p)
1175 {
1176 __int16 v1; // fps@1
1177 unsigned __int8 v2; // c0@2
1178 char v3; // c2@2
1179 unsigned __int8 v4; // c3@2
1180 bool result; // eax@2
1181 unsigned __int8 v6; // c0@4
1182 char v7; // c2@4
1183 unsigned __int8 v8; // c3@4
1184 unsigned __int8 v9; // c0@6
1185 char v10; // c2@6
1186 unsigned __int8 v11; // c3@6
1187 double v12; // st6@7
1188 float v13; // ST04_4@7
1189 float v14; // ST00_4@7
1190 double v15; // st7@7
1191 double v16; // st6@8
1192 float v17; // ST04_4@8
1193 float v18; // ST00_4@8
1194 double v19; // st7@8
1195
1196 //UNDEF(v1);
1197 if ( p->vWorldViewPosition.x < 300.0
1198 || (v2 = 300.0 < p[1].vWorldViewPosition.x,
1199 v3 = 0,
1200 v4 = 300.0 == p[1].vWorldViewPosition.x,
1201 BYTE1(result) = HIBYTE(v1),
1202 !(v2 | v4)) )
1203 {
1204 if ( p->vWorldViewPosition.x < 300.0 )
1205 {
1206 v6 = 300.0 < p[1].vWorldViewPosition.x;
1207 v7 = 0;
1208 v8 = 300.0 == p[1].vWorldViewPosition.x;
1209 BYTE1(result) = HIBYTE(v1);
1210 if ( !(v6 | v8) )
1211 {
1212 LOBYTE(result) = 0;
1213 return result;
1214 }
1215 }
1216 v9 = 300.0 < p->vWorldViewPosition.x;
1217 v10 = 0;
1218 v11 = 300.0 == p->vWorldViewPosition.x;
1219 BYTE1(result) = HIBYTE(v1);
1220 if ( v9 | v11 )
1221 {
1222 v16 = 1.0 / (p->vWorldViewPosition.x - p[1].vWorldViewPosition.x);
1223 v17 = (p->vWorldViewPosition.y - p[1].vWorldViewPosition.y) * v16;
1224 v18 = (p->vWorldViewPosition.z - p[1].vWorldViewPosition.z) * v16;
1225 v19 = 300.0 - p[1].vWorldViewPosition.x;
1226 p[1].vWorldViewPosition.x = v19 + p[1].vWorldViewPosition.x;
1227 p[1].vWorldViewPosition.y = v17 * v19 + p[1].vWorldViewPosition.y;
1228 p[1].vWorldViewPosition.z = v19 * v18 + p[1].vWorldViewPosition.z;
1229 }
1230 else
1231 {
1232 v12 = 1.0 / (p[1].vWorldViewPosition.x - p->vWorldViewPosition.x);
1233 v13 = (p[1].vWorldViewPosition.y - p->vWorldViewPosition.y) * v12;
1234 v14 = (p[1].vWorldViewPosition.z - p->vWorldViewPosition.z) * v12;
1235 v15 = 300.0 - p->vWorldViewPosition.x;
1236 p->vWorldViewPosition.x = v15 + p->vWorldViewPosition.x;
1237 p->vWorldViewPosition.y = v13 * v15 + p->vWorldViewPosition.y;
1238 p->vWorldViewPosition.z = v15 * v14 + p->vWorldViewPosition.z;
1239 }
1240 }
1241 LOBYTE(result) = 1;
1242 return result;
1243 }
1244
1245
1246
1247
1248 //----- (004268E3) --------------------------------------------------------
1249 int __fastcall _4268E3_smthn_to_a1r5g5b5(unsigned int uColor)
1250 {
1251 unsigned int v1; // eax@1
1252 unsigned int v2; // edx@1
1253 int v3; // eax@1
1254 int v4; // edx@1
1255 unsigned int v5; // ecx@1
1256
1257 v1 = uColor >> 9;
1258 v2 = uColor >> 6;
1259 LOWORD(v1) = (uColor >> 9) & 0x7C00;
1260 LOWORD(v2) = (uColor >> 6) & 0x3E0;
1261 v3 = v2 | v1;
1262 v4 = (unsigned __int8)uColor >> 3;
1263 v5 = uColor >> 16;
1264 LOWORD(v5) = v5 & 0x8000;
1265 return v5 | v4 | v3;
1266 }
1267
1268 //----- (0042690D) --------------------------------------------------------
1269 int __fastcall _42690D_colors_cvt(unsigned int a1)
1270 {
1271 unsigned int v1; // eax@1
1272 unsigned int v2; // edx@1
1273
1274 v1 = a1 >> 8;
1275 v2 = a1 >> 5;
1276 LOWORD(v1) = (a1 >> 8) & 0xF800;
1277 LOWORD(v2) = (a1 >> 5) & 0x7E0;
1278 return ((unsigned __int8)a1 >> 3) | v2 | v1;
1279 }
1280
1281 //----- (00426947) --------------------------------------------------------
1282 void __cdecl sub_426947()
1283 {
1284 dword_50C968 = 0;
1285 dword_50C994 = 0;
1286 dword_50C998_turnbased_icon_1A = 0;
1287 }
1288 // 50C968: using guessed type int dword_50C968;
1289 // 50C994: using guessed type int dword_50C994;
1290 // 50C998: using guessed type int dword_50C998_turnbased_icon_1A;
1291
1292
1293
1294 //----- (004269A2) --------------------------------------------------------
1295 int __fastcall sub_4269A2_GivePartyExp(unsigned int a1)
1296 {
1297 unsigned __int64 v1; // qax@1
1298 signed int v2; // ecx@1
1299 char *v3; // esi@1
1300 bool v4; // edi@6
1301 char *v5; // edi@10
1302 char *v6; // esi@10
1303 int v7; // eax@13
1304 unsigned __int8 v8; // cf@13
1305 char v10; // [sp+Ch] [bp-14h]@1
1306 int v11; // [sp+1Ch] [bp-4h]@10
1307
1308 v1 = __PAIR__((int)((char *)&pParty + 2620), a1);
1309 v2 = 0;
1310 v3 = &v10;
1311 do
1312 {
1313 v4 = !(*(int *)(HIDWORD(v1) - 4) | *(int *)(HIDWORD(v1) - 8))
1314 && !*(int *)HIDWORD(v1)
1315 && !*(_QWORD *)(HIDWORD(v1) + 8)
1316 && !*(_QWORD *)(HIDWORD(v1) + 16);
1317 *(int *)v3 = v4;
1318 HIDWORD(v1) += 6972;
1319 v2 += v4;
1320 v3 += 4;
1321 }
1322 while ( SHIDWORD(v1) < (signed int)&pParty->pHirelings[1].field_24 );
1323 if ( v2 )
1324 {
1325 LODWORD(v1) = (signed int)v1 / v2;
1326 v5 = &v10;
1327 v6 = (char *)&pParty->pPlayers[0].uExperience;
1328 v11 = v1;
1329 do
1330 {
1331 if ( *(int *)v5 )
1332 {
1333 if ( v11 )
1334 {
1335 LOBYTE(v7) = ((Player *)(v6 - 160))->GetLearningPercent();
1336 v1 = v11 + v11 * v7 / 100;
1337 v8 = __CFADD__((int)v1, *(int *)v6);
1338 *(int *)v6 += v1;
1339 *((int *)v6 + 1) += HIDWORD(v1) + v8;
1340 if ( *(_QWORD *)v6 > 4000000000i64 )
1341 {
1342 *((int *)v6 + 1) = 0;
1343 *(int *)v6 = -294967296;
1344 }
1345 }
1346 }
1347 v6 += 6972;
1348 v5 += 4;
1349 }
1350 while ( (signed int)v6 < (signed int)&pParty->pPickedItem._bonus_strength );
1351 }
1352 return v1;
1353 }
1354
1355 //----- (00426A5A) --------------------------------------------------------
1356 void stru319::LootActor(Actor *pActor)
1357 {
1358 signed int v2; // edi@1
1359 char v3; // zf@1
1360 unsigned int v4; // eax@13
1361 unsigned int v5; // esi@13
1362 int v6; // eax@14
1363 unsigned __int8 v7; // al@30
1364 Party *v8; // esi@34
1365 char *v9; // [sp-4h] [bp-3Ch]@10
1366 char *v10; // [sp-4h] [bp-3Ch]@31
1367 char *v11; // [sp-4h] [bp-3Ch]@38
1368 ItemGen Dst; // [sp+Ch] [bp-2Ch]@1
1369 int v13; // [sp+30h] [bp-8h]@1
1370 int v14; // [sp+34h] [bp-4h]@1
1371
1372 sub_421B2C_PlaceInInventory_or_DropPickedItem();
1373 Dst.Reset();
1374 v2 = 0;
1375 v3 = ((unsigned int)&array_77EC08[1975].pEdgeList1[1] & pActor->uAttributes) == 0;
1376 v13 = 0;
1377 v14 = 0;
1378 if ( v3 )
1379 {
1380 if ( !pActor->pMonsterInfo.uTreasureDiceRolls )
1381 goto LABEL_9;
1382 do
1383 {
1384 ++v2;
1385 v14 += rand() % pActor->pMonsterInfo.uTreasureDiceSides + 1;
1386 }
1387 while ( v2 < pActor->pMonsterInfo.uTreasureDiceRolls );
1388 }
1389 else
1390 {
1391 if ( pItemsTable->pItems[pActor->array_000234[3].uItemID].uEquipType != 18 )
1392 goto LABEL_9;
1393 v14 = pActor->array_000234[3].uAdditionalValue;
1394 pActor->array_000234[3].Reset();
1395 }
1396 if ( v14 )
1397 {
1398 party_finds_gold(v14, 0);
1399 viewparams->bRedrawGameUI = 1;
1400 }
1401 LABEL_9:
1402 if ( pActor->uCarriedItemID )
1403 {
1404 Dst.Reset();
1405 Dst.uItemID = pActor->uCarriedItemID;
1406 v9 = pItemsTable->pItems[Dst.uItemID].pUnidentifiedName;
1407 if ( v14 )
1408 sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[490], v14, v9);
1409 else
1410 sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[471], v9);
1411 ShowStatusBarString(pTmpBuf2, 2u);
1412 v4 = Dst.uItemID;
1413 v5 = Dst.uItemID;
1414 if ( pItemsTable->pItems[Dst.uItemID].uEquipType == 12 )
1415 {
1416 v5 = Dst.uItemID;
1417 v6 = rand() % 6 + pItemsTable->pItems[Dst.uItemID].uDamageMod + 1;
1418 Dst.uNumCharges = v6;
1419 Dst.uMaxCharges = v6;
1420 v4 = Dst.uItemID;
1421 }
1422 if ( pItemsTable->pItems[v5].uEquipType == 14 && v4 != 220 )
1423 Dst._bonus_type = 2 * rand() % 4 + 2;
1424 pItemsTable->SetSpecialBonus(&Dst);
1425 if ( !pParty->AddItem(&Dst) )
1426 pParty->SetHoldingItem(&Dst);
1427 pActor->uCarriedItemID = 0;
1428 if ( pActor->array_000234[0].uItemID )
1429 {
1430 if ( !pParty->AddItem(pActor->array_000234) )
1431 {
1432 sub_421B2C_PlaceInInventory_or_DropPickedItem();
1433 pParty->SetHoldingItem(pActor->array_000234);
1434 }
1435 pActor->array_000234[0].Reset();
1436 }
1437 if ( pActor->array_000234[1].uItemID )
1438 {
1439 if ( !pParty->AddItem(&pActor->array_000234[1]) )
1440 {
1441 sub_421B2C_PlaceInInventory_or_DropPickedItem();
1442 pParty->SetHoldingItem(&pActor->array_000234[1]);
1443 }
1444 pActor->array_000234[1].Reset();
1445 }
1446 LABEL_55:
1447 pActor->Remove();
1448 return;
1449 }
1450 if ( (unsigned int)&array_77EC08[1975].pEdgeList1[1] & pActor->uAttributes )
1451 {
1452 if ( pActor->array_000234[3].uItemID )
1453 {
1454 memcpy(&Dst, &pActor->array_000234[3], sizeof(Dst));
1455 pActor->array_000234[3].Reset();
1456 v11 = pItemsTable->pItems[Dst.uItemID].pUnidentifiedName;
1457 if ( v14 )
1458 sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[490], v14, v11);
1459 else
1460 sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[471], v11);
1461 ShowStatusBarString(pTmpBuf2, 2u);
1462 if ( !pParty->AddItem(&Dst) )
1463 pParty->SetHoldingItem(&Dst);
1464 v13 = 1;
1465 }
1466 goto LABEL_44;
1467 }
1468 if ( rand() % 100 >= pActor->pMonsterInfo.uTreasureDropChance || (v7 = pActor->pMonsterInfo.uTreasureLevel) == 0 )
1469 {
1470 LABEL_44:
1471 v8 = pParty;
1472 goto LABEL_45;
1473 }
1474 pItemsTable->GenerateItem(v7, pActor->pMonsterInfo.uTreasureType, &Dst);
1475 v10 = pItemsTable->pItems[Dst.uItemID].pUnidentifiedName;
1476 if ( v14 )
1477 sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[490], v14, v10);
1478 else
1479 sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[471], v10);
1480 ShowStatusBarString(pTmpBuf2, 2u);
1481 v8 = pParty;
1482 if ( !pParty->AddItem(&Dst) )
1483 pParty->SetHoldingItem(&Dst);
1484 v13 = 1;
1485 LABEL_45:
1486 if ( pActor->array_000234[0].uItemID )
1487 {
1488 if ( !v8->AddItem(pActor->array_000234) )
1489 {
1490 sub_421B2C_PlaceInInventory_or_DropPickedItem();
1491 v8->SetHoldingItem(pActor->array_000234);
1492 v13 = 1;
1493 }
1494 pActor->array_000234[0].Reset();
1495 }
1496 if ( pActor->array_000234[1].uItemID )
1497 {
1498 if ( !v8->AddItem(&pActor->array_000234[1]) )
1499 {
1500 sub_421B2C_PlaceInInventory_or_DropPickedItem();
1501 v8->SetHoldingItem(&pActor->array_000234[1]);
1502 v13 = 1;
1503 }
1504 pActor->array_000234[1].Reset();
1505 }
1506 if ( !v13 || rand() % 100 < 90 )
1507 goto LABEL_55;
1508 }
1509
1510 //----- (00426E10) --------------------------------------------------------
1511 int stru319::which_player_would_attack(Actor *pActor)
1512 {
1513 signed int v2; // ebx@1
1514 int v3; // ecx@2
1515 signed int v4; // edx@3
1516 char v5; // zf@3
1517 unsigned int v6; // eax@3
1518 int v7; // eax@6
1519 int v8; // eax@7
1520 int v9; // eax@8
1521 int v10; // eax@9
1522 int v11; // eax@10
1523 int v12; // eax@11
1524 int v13; // esi@35
1525 signed int v14; // edi@37
1526 enum CHARACTER_RACE v15; // eax@44
1527 Player *v16; // ecx@47
1528 unsigned __int8 v17; // sf@50
1529 unsigned __int8 v18; // of@50
1530 int v19; // esi@52
1531 Player *v20; // ecx@53
1532 int result; // eax@57
1533 int v22[16]; // [sp+8h] [bp-140h]@3
1534 int v23[60]; // [sp+48h] [bp-100h]@48
1535 int v24; // [sp+138h] [bp-10h]@2
1536 int v25; // [sp+13Ch] [bp-Ch]@1
1537 int v26; // [sp+140h] [bp-8h]@1
1538 int v27; // [sp+144h] [bp-4h]@1
1539
1540 v27 = -1;
1541 v26 = -1;
1542 v25 = -1;
1543 v2 = 0;
1544 if ( pActor->pMonsterInfo.uAttackPreference )
1545 {
1546 v3 = 0;
1547 v24 = 0;
1548 do
1549 {
1550 v4 = 1;
1551 v6 = pActor->pMonsterInfo.uAttackPreference & (1 << v3);
1552 v5 = (pActor->pMonsterInfo.uAttackPreference & (1 << v3)) == 0;
1553 v22[v3] = v6;
1554 if ( !v5 )
1555 {
1556 if ( (signed int)v6 > 128 )
1557 {
1558 switch ( v6 )
1559 {
1560 case 0x100u:
1561 v27 = 8;
1562 break;
1563 case 0x200u:
1564 v25 = 0;
1565 break;
1566 case 0x400u:
1567 v25 = 1;
1568 break;
1569 case 0x800u:
1570 v26 = 0;
1571 break;
1572 case 0x1000u:
1573 v26 = 1;
1574 break;
1575 case 0x2000u:
1576 v26 = 3;
1577 break;
1578 case 0x4000u:
1579 v26 = 2;
1580 break;
1581 }
1582 }
1583 else
1584 {
1585 if ( v6 == 128 )
1586 {
1587 v27 = 4;
1588 }
1589 else
1590 {
1591 v7 = v6 - 1;
1592 if ( v7 )
1593 {
1594 v8 = v7 - 1;
1595 if ( v8 )
1596 {
1597 v9 = v8 - 2;
1598 if ( v9 )
1599 {
1600 v10 = v9 - 4;
1601 if ( v10 )
1602 {
1603 v11 = v10 - 8;
1604 if ( v11 )
1605 {
1606 v12 = v11 - 16;
1607 if ( v12 )
1608 {
1609 if ( v12 == 32 )
1610 v27 = 20;
1611 }
1612 else
1613 {
1614 v27 = 32;
1615 }
1616 }
1617 else
1618 {
1619 v27 = 24;
1620 }
1621 }
1622 else
1623 {
1624 v27 = 28;
1625 }
1626 }
1627 else
1628 {
1629 v27 = 16;
1630 }
1631 }
1632 else
1633 {
1634 v27 = 12;
1635 }
1636 }
1637 else
1638 {
1639 v27 = 0;
1640 }
1641 }
1642 }
1643 v2 = 0;
1644 v13 = 0;
1645 while ( 1 )
1646 {
1647 v14 = 0;
1648 if ( v27 != -1 && v27 == pPlayers[v13 + 1]->uClass )
1649 v14 = v4;
1650 if ( v25 != -1 && v25 == pPlayers[v13 + 1]->uSex )
1651 v14 = v4;
1652 if ( v26 != -1 )
1653 {
1654 v15 = pPlayers[v13 + 1]->GetRace();
1655 if ( v26 == v15 )
1656 v14 = 1;
1657 }
1658 if ( v14 == 1 )
1659 {
1660 v16 = pPlayers[v13 + 1];
1661 if ( !(v16->pConditions[12] | v16->pConditions[13] | v16->pConditions[14] | v16->pConditions[15] | v16->pConditions[16]) )
1662 v23[v2++] = v13;
1663 }
1664 ++v13;
1665 if ( v13 >= 4 )
1666 break;
1667 v4 = 1;
1668 }
1669 }
1670 v3 = v24 + 1;
1671 v18 = __OFSUB__(v24 + 1, 15);
1672 v17 = v24++ - 14 < 0;
1673 }
1674 while ( v17 ^ v18 );
1675 if ( v2 )
1676 goto LABEL_61;
1677 }
1678 v19 = 0;
1679 do
1680 {
1681 v20 = pPlayers[v19 + 1];
1682 if ( !(v20->pConditions[12] | v20->pConditions[13] | v20->pConditions[14] | v20->pConditions[15] | v20->pConditions[16]) )
1683 v23[v2++] = v19;
1684 ++v19;
1685 }
1686 while ( v19 < 4 );
1687 if ( v2 )
1688 LABEL_61:
1689 result = v23[rand() % v2];
1690 else
1691 result = 0;
1692 return result;
1693 }
1694
1695
1696 //----- (0042704B) --------------------------------------------------------
1697 bool stru319::special_ability_use_check(Actor *pActor, int a2)
1698 {
1699 stru319 *v3; // edi@1
1700 signed int v4; // ebx@5
1701 signed int v5; // edi@5
1702
1703 v3 = this;
1704 if ( pActor->pMonsterInfo.uSpecialAbilityType == 2
1705 && pActor->pMonsterInfo.uSpecialAbilityDamageDiceBonus < 3u
1706 && rand() % 100 < 5 )
1707 pActor->_44FD29(a2);
1708 v4 = v3->_427102(pActor, pActor->pMonsterInfo.uSpell1ID);
1709 v5 = v3->_427102(pActor, pActor->pMonsterInfo.uSpell2ID);
1710 if ( v4 && pActor->pMonsterInfo.uSpell1UseChance && rand() % 100 < pActor->pMonsterInfo.uSpell1UseChance )
1711 return 2;
1712 if ( v5 && pActor->pMonsterInfo.uSpell2UseChance && rand() % 100 < pActor->pMonsterInfo.uSpell2UseChance )
1713 return 3;
1714 return pActor->pMonsterInfo.uAttack2Chance && rand() % 100 < pActor->pMonsterInfo.uAttack2Chance;
1715 }
1716
1717 //----- (00427102) --------------------------------------------------------
1718 int stru319::_427102(Actor *pActor, signed int a2)
1719 {
1720 unsigned __int8 v3; // cf@11
1721 unsigned __int8 v4; // zf@11
1722 SpellBuff *v6; // ecx@46
1723 char *v7; // esi@49
1724 signed int v8; // edx@50
1725 char *v9; // ecx@50
1726
1727 if ( a2 > 73 )
1728 {
1729 if ( a2 == 77 )
1730 {
1731 if ( pActor->sCurrentHP >= (signed int)pActor->pMonsterInfo.uHP )
1732 return 0;
1733 return 1;
1734 }
1735 if ( a2 == 80 )
1736 {
1737 v6 = pParty->pPartyBuffs;
1738 while ( (signed __int64)v6->uExpireTime <= 0 )
1739 {
1740 ++v6;
1741 if ( (signed int)v6 >= (signed int)pParty->pPlayers )
1742 {
1743 v7 = (char *)pParty->pPlayers[0].pPlayerBuffs;
1744 LABEL_50:
1745 v8 = 0;
1746 v9 = v7;
1747 while ( *(_QWORD *)v9 <= 0i64 )
1748 {
1749 ++v8;
1750 v9 += 16;
1751 if ( v8 >= 24 )
1752 {
1753 v7 += 6972;
1754 if ( (signed int)v7 < (signed int)&pParty->field_871C[464] )
1755 goto LABEL_50;
1756 return 0;
1757 }
1758 }
1759 return 1;
1760 }
1761 }
1762 return 1;
1763 }
1764 if ( a2 == 85 )
1765 {
1766 if ( SHIDWORD(pActor->pActorBuffs[13].uExpireTime) < 0 )
1767 return 1;
1768 if ( SHIDWORD(pActor->pActorBuffs[13].uExpireTime) > 0 )
1769 return 0;
1770 v3 = 0;
1771 v4 = LODWORD(pActor->pActorBuffs[13].uExpireTime) == 0;
1772 }
1773 else
1774 {
1775 if ( a2 == 86 )
1776 {
1777 if ( SHIDWORD(pActor->pActorBuffs[14].uExpireTime) < 0 )
1778 return 1;
1779 if ( SHIDWORD(pActor->pActorBuffs[14].uExpireTime) > 0 )
1780 return 0;
1781 v3 = 0;
1782 v4 = LODWORD(pActor->pActorBuffs[14].uExpireTime) == 0;
1783 }
1784 else
1785 {
1786 if ( a2 != 95 || SHIDWORD(pActor->pActorBuffs[20].uExpireTime) < 0 )
1787 return 1;
1788 if ( SHIDWORD(pActor->pActorBuffs[20].uExpireTime) > 0 )
1789 return 0;
1790 v3 = 0;
1791 v4 = LODWORD(pActor->pActorBuffs[20].uExpireTime) == 0;
1792 }
1793 }
1794 }
1795 else
1796 {
1797 if ( a2 == 73 )
1798 {
1799 if ( SHIDWORD(pActor->pActorBuffs[21].uExpireTime) < 0 )
1800 return 1;
1801 if ( SHIDWORD(pActor->pActorBuffs[21].uExpireTime) > 0 )
1802 return 0;
1803 v3 = 0;
1804 v4 = LODWORD(pActor->pActorBuffs[21].uExpireTime) == 0;
1805 goto LABEL_15;
1806 }
1807 if ( a2 == 5 )
1808 {
1809 if ( SHIDWORD(pActor->pActorBuffs[19].uExpireTime) < 0 )
1810 return 1;
1811 if ( SHIDWORD(pActor->pActorBuffs[19].uExpireTime) > 0 )
1812 return 0;
1813 v3 = 0;
1814 v4 = LODWORD(pActor->pActorBuffs[19].uExpireTime) == 0;
1815 goto LABEL_15;
1816 }
1817 if ( a2 == 17 )
1818 {
1819 if ( SHIDWORD(pActor->pActorBuffs[15].uExpireTime) < 0 )
1820 return 1;
1821 if ( SHIDWORD(pActor->pActorBuffs[15].uExpireTime) > 0 )
1822 return 0;
1823 v3 = 0;
1824 v4 = LODWORD(pActor->pActorBuffs[15].uExpireTime) == 0;
1825 goto LABEL_15;
1826 }
1827 if ( a2 == 38 )
1828 {
1829 if ( SHIDWORD(pActor->pActorBuffs[16].uExpireTime) < 0 )
1830 return 1;
1831 if ( SHIDWORD(pActor->pActorBuffs[16].uExpireTime) > 0 )
1832 return 0;
1833 v3 = 0;
1834 v4 = LODWORD(pActor->pActorBuffs[16].uExpireTime) == 0;
1835 goto LABEL_15;
1836 }
1837 if ( a2 == 46 )
1838 {
1839 if ( SHIDWORD(pActor->pActorBuffs[17].uExpireTime) < 0 )
1840 return 1;
1841 if ( SHIDWORD(pActor->pActorBuffs[17].uExpireTime) > 0 )
1842 return 0;
1843 v3 = 0;
1844 v4 = LODWORD(pActor->pActorBuffs[17].uExpireTime) == 0;
1845 goto LABEL_15;
1846 }
1847 if ( a2 != 47 )
1848 {
1849 if ( a2 != 51 || SHIDWORD(pActor->pActorBuffs[18].uExpireTime) < 0 )
1850 return 1;
1851 if ( SHIDWORD(pActor->pActorBuffs[18].uExpireTime) <= 0 )
1852 {
1853 v3 = 0;
1854 v4 = LODWORD(pActor->pActorBuffs[18].uExpireTime) == 0;
1855 goto LABEL_15;
1856 }
1857 return 0;
1858 }
1859 if ( SHIDWORD(pActor->pActorBuffs[11].uExpireTime) < 0 )
1860 return 1;
1861 if ( SHIDWORD(pActor->pActorBuffs[11].uExpireTime) > 0 )
1862 return 0;
1863 v3 = 0;
1864 v4 = LODWORD(pActor->pActorBuffs[11].uExpireTime) == 0;
1865 }
1866 LABEL_15:
1867 if ( !(v3 | v4) )
1868 return 0;
1869 return 1;
1870 }
1871
1872 //----- (004272F5) --------------------------------------------------------
1873 int stru319::PlayerHitOrMiss(Player *pPlayer, Actor *pActor, int a3, int a4)
1874 {
1875 signed int v5; // esi@1
1876 signed int v6; // edi@1
1877 int v7; // esi@8
1878 int v8; // eax@9
1879 int v9; // edx@11
1880 int v10; // edx@13
1881 int v11; // esi@13
1882 unsigned __int8 v12; // sf@13
1883 unsigned __int8 v13; // of@13
1884 int v14; // edx@14
1885 int v15; // eax@14
1886 signed int result; // eax@17
1887
1888 v5 = pActor->pMonsterInfo.uAC;
1889 v6 = 0;
1890 if ( (signed __int64)pActor->pActorBuffs[8].uExpireTime > 0 )
1891 v5 /= 2;
1892 if ( (signed __int64)pActor->pActorBuffs[14].uExpireTime > 0 )
1893 v6 = pActor->pActorBuffs[15].uPower;
1894 if ( (signed __int64)pActor->pActorBuffs[16].uExpireTime > 0 && pActor->pActorBuffs[16].uPower > v6 )
1895 v6 = pActor->pActorBuffs[16].uPower;
1896 v7 = v6 + v5;
1897 if ( a3 )
1898 v8 = pPlayer->GetRangedAttack();
1899 else
1900 v8 = pPlayer->GetActualAttack(0);
1901 v9 = rand() % (v7 + 2 * v8 + 30);
1902 if ( a3 == 2 )
1903 {
1904 v14 = a4 + v9;
1905 v15 = ((v7 + 15) >> 1) + v7 + 15;
1906 }
1907 else
1908 {
1909 if ( a3 != 3 )
1910 {
1911 v10 = a4 + v9;
1912 v11 = v7 + 15;
1913 v13 = __OFSUB__(v10, v11);
1914 v12 = v10 - v11 < 0;
1915 goto LABEL_16;
1916 }
1917 v14 = a4 + v9;
1918 v15 = 2 * v7 + 30;
1919 }
1920 v13 = __OFSUB__(v14, v15);
1921 v12 = v14 - v15 < 0;
1922 LABEL_16:
1923 if ( v12 ^ v13 )
1924 result = 0;
1925 else
1926 result = 1;
1927 return result;
1928 }
1929
1930 //----- (004273BB) --------------------------------------------------------
1931 bool stru319::_4273BB(Actor *pActor, Actor *a2, int a3, int a4)
1932 {
1933 Actor *v5; // ecx@1
1934 signed int v6; // ebx@1
1935 signed int v7; // esi@1
1936 unsigned __int8 v8; // zf@1
1937 unsigned __int8 v9; // sf@1
1938 int v10; // ebx@10
1939 signed int a2a; // [sp+18h] [bp+Ch]@1
1940
1941 v5 = a2;
1942 v6 = a2->pMonsterInfo.uAC;
1943 v7 = 0;
1944 v8 = HIDWORD(a2->pActorBuffs[8].uExpireTime) == 0;
1945 v9 = SHIDWORD(a2->pActorBuffs[8].uExpireTime) < 0;
1946 a2a = 0;
1947 if ( !v9 && (!(v9 | v8) || LODWORD(v5->pActorBuffs[8].uExpireTime) > 0) )
1948 v6 /= 2;
1949 if ( (signed __int64)v5->pActorBuffs[14].uExpireTime > 0 )
1950 v7 = v5->pActorBuffs[14].uPower;
1951 if ( (signed __int64)v5->pActorBuffs[16].uExpireTime > 0 && v5->pActorBuffs[16].uPower > v7 )
1952 v7 = v5->pActorBuffs[16].uPower;
1953 v10 = v7 + v6;
1954 if ( (signed __int64)pActor->pActorBuffs[14].uExpireTime > 0 )
1955 a2a = pActor->pActorBuffs[14].uPower;
1956 if ( (signed __int64)pActor->pActorBuffs[17].uExpireTime > 0 && pActor->pActorBuffs[17].uPower > a2a )
1957 a2a = pActor->pActorBuffs[17].uPower;
1958 if ( (signed __int64)pActor->pActorBuffs[11].uExpireTime > 0 )
1959 {
1960 a2a += pActor->pActorBuffs[11].uPower;
1961 pActor->pActorBuffs[11].Reset();
1962 }
1963 return rand() % (v10 + 2 * pActor->pMonsterInfo.uLevel + 10) + a2a + 1 > v10 + 5;
1964 }
1965
1966 //----- (004274AD) --------------------------------------------------------
1967 bool stru319::ActorHitOrMiss(Actor *pActor, Player *pPlayer)
1968 {
1969 signed int v3; // edi@1
1970 signed int v4; // esi@8
1971 int v5; // esi@8
1972
1973 v3 = 0;
1974 if ( (signed __int64)pActor->pActorBuffs[14].uExpireTime > 0 )
1975 v3 = pActor->pActorBuffs[14].uPower;
1976 if ( (signed __int64)pActor->pActorBuffs[17].uExpireTime > 0 && pActor->pActorBuffs[17].uPower > v3 )
1977 v3 = pActor->pActorBuffs[17].uPower;
1978 if ( (signed __int64)pActor->pActorBuffs[11].uExpireTime > 0 )
1979 {
1980 v3 += pActor->pActorBuffs[11].uPower;
1981 pActor->pActorBuffs[11].Reset();
1982 }
1983 v4 = pPlayer->GetActualAC() + 2 * pActor->pMonsterInfo.uLevel + 10;
1984 v5 = rand() % v4 + 1;
1985 return v3 + v5 > pPlayer->GetActualAC() + 5;
1986 }
1987
1988 //----- (00427546) --------------------------------------------------------
1989 int stru319::_427546(int a2)
1990 {
1991 int result; // eax@2
1992
1993 if ( a2 >= 0 )
1994 {
1995 if ( a2 >= 1 )
1996 result = (a2 >= 2) + 2;
1997 else
1998 result = 1;
1999 }
2000 else
2001 {
2002 result = 0;
2003 }
2004 return result;
2005 }
2006
2007 //----- (0042756B) --------------------------------------------------------
2008 int stru319::CalcMagicalDamageToActor(Actor *pActor, int a2, signed int a3)
2009 {
2010 int v4; // edx@1
2011 int v5; // ecx@1
2012 signed int v6; // eax@4
2013 signed int result; // eax@17
2014 signed int v8; // esi@18
2015
2016 v4 = 0;
2017 v5 = 0;
2018 if ( (signed __int64)pActor->pActorBuffs[14].uExpireTime > 0 )
2019 v5 = pActor->pActorBuffs[14].uPower;
2020 switch ( a2 )
2021 {
2022 case 4:
2023 v6 = pActor->pMonsterInfo.uResPhysical;
2024 break;
2025 case 0:
2026 v6 = pActor->pMonsterInfo.uResFire;
2027 goto LABEL_12;
2028 case 1:
2029 v6 = pActor->pMonsterInfo.uResAir;
2030 goto LABEL_12;
2031 case 2:
2032 v6 = pActor->pMonsterInfo.uResWater;
2033 goto LABEL_12;
2034 case 3:
2035 v6 = pActor->pMonsterInfo.uResEarth;
2036 goto LABEL_12;
2037 case 6:
2038 v6 = pActor->pMonsterInfo.uResSpirit;
2039 break;
2040 case 7:
2041 v6 = pActor->pMonsterInfo.uResMind;
2042 goto LABEL_12;
2043 case 8:
2044 v6 = pActor->pMonsterInfo.uResBody;
2045 LABEL_12:
2046 v4 = v5;
2047 break;
2048 case 9:
2049 v6 = pActor->pMonsterInfo.uResLight;
2050 break;
2051 case 10:
2052 v6 = pActor->pMonsterInfo.uResDark;
2053 break;
2054 default:
2055 v6 = 0;
2056 break;
2057 }
2058 if ( v6 < 200 )
2059 {
2060 v8 = v4 + v6 + 30;
2061 if ( rand() % v8 >= 30 )
2062 {
2063 a3 >>= 1;
2064 if ( rand() % v8 >= 30 )
2065 {
2066 a3 >>= 1;
2067 if ( rand() % v8 >= 30 )
2068 {
2069 a3 >>= 1;
2070 if ( rand() % v8 >= 30 )
2071 a3 >>= 1;
2072 }
2073 }
2074 }
2075 result = a3;
2076 }
2077 else
2078 {
2079 result = 0;
2080 }
2081 return result;
2082 }
2083
2084 //----- (00427662) --------------------------------------------------------
2085 bool stru319::GetMagicalResistance(Actor *pActor, unsigned int uType)
2086 {
2087 Actor *v3; // edi@2
2088 signed int v4; // esi@2
2089 bool result; // eax@13
2090
2091 switch ( uType )
2092 {
2093 case 0u:
2094 v3 = pActor;
2095 v4 = pActor->pMonsterInfo.uResFire;
2096 goto LABEL_12;
2097 case 1u:
2098 v3 = pActor;
2099 v4 = pActor->pMonsterInfo.uResAir;
2100 goto LABEL_12;
2101 case 2u:
2102 v3 = pActor;
2103 v4 = pActor->pMonsterInfo.uResWater;
2104 goto LABEL_12;
2105 case 3u:
2106 v3 = pActor;
2107 v4 = pActor->pMonsterInfo.uResEarth;
2108 goto LABEL_12;
2109 case 7u:
2110 v3 = pActor;
2111 v4 = pActor->pMonsterInfo.uResMind;
2112 goto LABEL_12;
2113 case 6u:
2114 v3 = pActor;
2115 v4 = pActor->pMonsterInfo.uResSpirit;
2116 goto LABEL_12;
2117 case 8u:
2118 v3 = pActor;
2119 v4 = pActor->pMonsterInfo.uResBody;
2120 goto LABEL_12;
2121 case 9u:
2122 v3 = pActor;
2123 v4 = pActor->pMonsterInfo.uResLight;
2124 goto LABEL_12;
2125 case 0xAu:
2126 v3 = pActor;
2127 v4 = pActor->pMonsterInfo.uResDark;
2128 goto LABEL_12;
2129 case 4u:
2130 v3 = pActor;
2131 v4 = pActor->pMonsterInfo.uResPhysical;
2132 LABEL_12:
2133 if ( v4 < 200 )
2134 result = rand() % (signed int)(((unsigned int)v3->pMonsterInfo.uLevel >> 2) + v4 + 30) < 30;
2135 else
2136 result = 0;
2137 break;
2138 default:
2139 result = 1;
2140 break;
2141 }
2142 return result;
2143 }
2144
2145
2146 //----- (00427769) --------------------------------------------------------
2147 bool __fastcall sub_427769_spell(unsigned int uSpellID)
2148 {
2149 bool result; // eax@2
2150
2151 if ( *(&pSpellDatas[0].field_12 + 20 * uSpellID) & 0xC )
2152 result = 1;
2153 else
2154 result = 0;
2155 return result;
2156 }
2157
2158 //----- (0042777D) --------------------------------------------------------
2159 bool __fastcall _42777D_CastSpell_UseWand_ShootArrow(int a1, unsigned int uPlayerID, unsigned int a4, __int16 a5, int a6)
2160 {
2161 bool result; // eax@2
2162 __int16 v6; // bx@4
2163 Player *v7; // eax@4
2164 char v8; // zf@12
2165 unsigned __int16 v9; // cx@16
2166 unsigned int v10; // eax@18
2167 unsigned __int8 v11; // sf@18
2168 unsigned __int8 v12; // of@18
2169 unsigned __int16 v13; // cx@21
2170 unsigned int v14; // eax@23
2171 stru277 *v15; // esi@27
2172 stru277 *v16; // eax@28
2173 GUIWindow *v17; // eax@43
2174 GUIWindow *v18; // [sp-30h] [bp-48h]@44
2175 unsigned int v19; // [sp-2Ch] [bp-44h]@44
2176 unsigned int v20; // [sp-28h] [bp-40h]@44
2177 unsigned int v21; // [sp-24h] [bp-3Ch]@44
2178 unsigned int v22; // [sp-20h] [bp-38h]@44
2179 int v23; // [sp-1Ch] [bp-34h]@44
2180 int v24; // [sp-18h] [bp-30h]@44
2181 unsigned int v25; // [sp-14h] [bp-2Ch]@43
2182 unsigned int v26; // [sp-10h] [bp-28h]@43
2183 unsigned __int8 v27; // [sp-Ch] [bp-24h]@43
2184 char *v28; // [sp-8h] [bp-20h]@43
2185 Texture *v29; // [sp-4h] [bp-1Ch]@43
2186 __int16 a3a; // [sp+10h] [bp-8h]@1
2187 __int16 a2a; // [sp+14h] [bp-4h]@1
2188
2189 a3a = uPlayerID;
2190 a2a = a1;
2191 if ( pParty->bTurnBasedModeOn != 1
2192 || (result = pTurnEngine->field_4, pTurnEngine->field_4 != 1) && pTurnEngine->field_4 != 3 )
2193 {
2194 v6 = a5;
2195 v7 = &pParty->pPlayers[uPlayerID];
2196 if ( !(a5 & 0x10) )
2197 {
2198 switch ( a1 )
2199 {
2200 case 47:
2201 case 68:
2202 case 89:
2203 HIBYTE(v6) = HIBYTE(a5) | 1;
2204 break;
2205 case 4:
2206 case 28:
2207 case 30:
2208 case 91:
2209 LOBYTE(v6) = a5 | 0x80;
2210 break;
2211 case 2:
2212 case 6:
2213 case 11:
2214 case 18:
2215 case 20:
2216 case 24:
2217 case 26:
2218 case 29:
2219 case 32:
2220 case 34:
2221 case 35:
2222 case 37:
2223 case 39:
2224 case 44:
2225 case 52:
2226 case 57:
2227 case 60:
2228 case 65:
2229 case 70:
2230 case 76:
2231 case 78:
2232 case 79:
2233 case 87:
2234 case 90:
2235 case 92:
2236 case 93:
2237 case 97:
2238 if ( !a6 )
2239 goto LABEL_9;
2240 break;
2241 case 59:
2242 case 62:
2243 case 66:
2244 case 81:
2245 case 94:
2246 LABEL_9:
2247 v6 = a5 | 8;
2248 break;
2249 case 42:
2250 v6 = a5 | 0x40;
2251 break;
2252 case 46:
2253 if ( a4 )
2254 v8 = (a4 & 0x1C0) == 0;
2255 else
2256 v8 = (v7->pActiveSkills[16] & 0x1C0) == 0;
2257 if ( v8 )
2258 goto LABEL_25;
2259 break;
2260 case 50:
2261 v9 = a4;
2262 if ( !a4 )
2263 v9 = v7->pActiveSkills[16];
2264 goto LABEL_18;
2265 case 95:
2266 v9 = a4;
2267 if ( !a4 )
2268 v9 = v7->pActiveSkills[20];
2269 LABEL_18:
2270 v10 = SkillToMastery(v9);
2271 v12 = __OFSUB__(v10, 3);
2272 v11 = ((v10 - 3) & 0x80000000u) != 0;
2273 goto LABEL_24;
2274 case 73:
2275 v13 = a4;
2276 if ( !a4 )
2277 v13 = v7->pActiveSkills[18];
2278 v14 = SkillToMastery(v13);
2279 v12 = __OFSUB__(v14, 4);
2280 v11 = ((v14 - 4) & 0x80000000u) != 0;
2281 LABEL_24:
2282 if ( v11 ^ v12 )
2283 goto LABEL_25;
2284 break;
2285 case 40:
2286 case 49:
2287 case 53:
2288 case 55:
2289 case 56:
2290 case 61:
2291 case 64:
2292 case 67:
2293 case 71:
2294 case 72:
2295 case 74:
2296 LABEL_25:
2297 v6 = a5 | 2;
2298 break;
2299 case 96:
2300 HIBYTE(v6) = HIBYTE(a5) | 2;
2301 break;
2302 default:
2303 break;
2304 }
2305 }
2306 v15 = pStru277;
2307 if ( v6 & 0x3CA )
2308 {
2309 v16 = pStru277;
2310 while ( !(v16->field_8 & 0x3CA) )
2311 {
2312 ++v16;
2313 if ( (signed int)v16 >= (signed int)&unk_50C190 )
2314 goto LABEL_33;
2315 }
2316 v16->spellnum = 0;
2317 }
2318 do
2319 {
2320 LABEL_33:
2321 if ( v15->spellnum )
2322 {
2323 v8 = (v15->field_8 & 0x3CA) == 0;
2324 v15->spellnum = 0;
2325 if ( !v8 )
2326 {
2327 pGUIWindow_Settings->Release();
2328 pGUIWindow_Settings = 0;
2329 pMouse->SetCursorBitmap("MICON1");
2330 GameUI_StatusBar_TimedStringTimeLeft = 0;
2331 unk_50C9A0 = 0;
2332 back_to_game();
2333 }
2334 }
2335 ++v15;
2336 }
2337 while ( (signed int)v15 < (signed int)&unk_50C190 );
2338 result = pStru277->PushStru277(a2a, a3a, a4, v6, a6);
2339 if ( result != -1 )
2340 {
2341 if ( v6 & 2 )
2342 {
2343 if ( pGUIWindow_Settings )
2344 return result;
2345 pGUIWindow_Settings = GUIWindow::Create(0, 0, 640, 480, (WindowType)(WINDOW_HouseInterior|0x2), (int)&pStru277[result], 0);
2346 pGUIWindow_Settings->CreateButton(0x34u, 0x1A6u, 0x23u, 0, 2, 0, 0x45u, 0, 0x31u, "", 0);
2347 pGUIWindow_Settings->CreateButton(0xA5u, 0x1A6u, 0x23u, 0, 2, 0, 0x45u, 1u, 0x32u, "", 0);
2348 pGUIWindow_Settings->CreateButton(0x118u, 0x1A6u, 0x23u, 0, 2, 0, 0x45u, 2u, 0x33u, "", 0);
2349 pGUIWindow_Settings->CreateButton(0x186u, 0x1A6u, 0x23u, 0, 2, 0, 0x45u, 3u, 0x34u, "", 0);
2350 return sub_421B2C_PlaceInInventory_or_DropPickedItem();
2351 }
2352 if ( v6 & 8 )
2353 {
2354 if ( pGUIWindow_Settings )
2355 return result;
2356 v17 = GUIWindow::Create(0, 0, 640, 480, (WindowType)(WINDOW_HouseInterior|0x2), (int)&pStru277[result], 0);
2357 v29 = 0;
2358 v28 = "";
2359 v27 = 0;
2360 v26 = 0;
2361 v25 = 70;
2362 LABEL_44:
2363 v24 = 0;
2364 v23 = 1;
2365 v22 = 344;
2366 v21 = 460;
2367 v20 = 8;
2368 v19 = 8;
2369 pGUIWindow_Settings = v17;
2370 v18 = v17;
2371 LABEL_56:
2372 v18->CreateButton(v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29);
2373 return sub_421B2C_PlaceInInventory_or_DropPickedItem();
2374 }
2375 if ( v6 & 0x40 )
2376 {
2377 if ( pGUIWindow_Settings )
2378 return result;
2379 v17 = GUIWindow::Create(0, 0, 640, 480, (WindowType)(WINDOW_HouseInterior|0x2), (int)&pStru277[result], 0);
2380 v29 = 0;
2381 v28 = "";
2382 v27 = 0;
2383 v26 = 0;
2384 v25 = 190;
2385 goto LABEL_44;
2386 }
2387 if ( (char)v6 < 0 )
2388 {
2389 if ( pGUIWindow_Settings )
2390 return result;
2391 ++pIcons_LOD->uTexturePacksCount;
2392 if ( !pIcons_LOD->uNumPrevLoadedFiles )
2393 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
2394 pGUIWindow_Settings = pStru277[result].sub_4219BE();
2395 unk_50C9A0 = 1;
2396 some_active_character = uActiveCharacter;
2397 return sub_421B2C_PlaceInInventory_or_DropPickedItem();
2398 }
2399 if ( HIBYTE(v6) & 1 )
2400 {
2401 if ( pGUIWindow_Settings )
2402 return result;
2403 pGUIWindow_Settings = GUIWindow::Create(0, 0, 640, 480, (WindowType)(WINDOW_HouseInterior|0x2), 20 * result + 5292232, 0);
2404 pGUIWindow_Settings->CreateButton(0x34u, 0x1A6u, 0x23u, 0, 2, 0, 0x8Du, 0, 0x31u, "", 0);
2405 pGUIWindow_Settings->CreateButton(0xA5u, 0x1A6u, 0x23u, 0, 2, 0, 0x8Du, 1u, 0x32u, "", 0);
2406 pGUIWindow_Settings->CreateButton(0x118u, 0x1A6u, 0x23u, 0, 2, 0, 0x8Du, 2u, 0x33u, "", 0);
2407 pGUIWindow_Settings->CreateButton(0x186u, 0x1A6u, 0x23u, 0, 2, 0, 0x8Du, 3u, 0x34u, "", 0);
2408 v29 = 0;
2409 v28 = "";
2410 v27 = 0;
2411 v26 = 0;
2412 v25 = 140;
2413 v24 = 0;
2414 v23 = 1;
2415 v22 = 344;
2416 v21 = 460;
2417 v20 = 8;
2418 v19 = 8;
2419 v18 = pGUIWindow_Settings;
2420 goto LABEL_56;
2421 }
2422 if ( HIBYTE(v6) & 2 && !pGUIWindow_Settings )
2423 {
2424 pGUIWindow_Settings = GUIWindow::Create(0, 0, 640, 480, (WindowType)(WINDOW_HouseInterior|0x2), 20 * result + 5292232, 0);
2425 pBtn_NPCLeft = pGUIWindow_Settings->CreateButton(
2426 0x1D5u,
2427 0xB2u,
2428 (uTextureID_507990 != -1 ? pIcons_LOD->pTextures[uTextureID_507990].uTextureWidth : 24),
2429 (uTextureID_507990 != -1 ? pIcons_LOD->pTextures[uTextureID_507990].uTextureHeight : 26),
2430 1,
2431 0,
2432 0xBCu,
2433 0,
2434 0,
2435 "",
2436 (Texture *)(uTextureID_507990 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_507990] : 0),
2437 0);
2438 pBtn_NPCRight = pGUIWindow_Settings->CreateButton(
2439 0x272u,
2440 0xB2u,
2441 (uTextureID_50798C != -1 ? pIcons_LOD->pTextures[uTextureID_50798C].uTextureWidth : 24),
2442 (uTextureID_50798C != -1 ? pIcons_LOD->pTextures[uTextureID_50798C].uTextureHeight : 26),
2443 1,
2444 0,
2445 0xBCu,
2446 1u,
2447 0,
2448 "",
2449 (Texture *)(uTextureID_50798C != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_50798C] : 0),
2450 0);
2451 pGUIWindow_Settings->CreateButton(0x1EBu, 0x95u, 0x40u, 0x4Au, 1, 0, 0x8Fu, 4u, 0x35u, "", 0);
2452 result = (bool)pGUIWindow_Settings->CreateButton(
2453 0x231u,
2454 0x95u,
2455 0x40u,
2456 0x4Au,
2457 1,
2458 0,
2459 0x8Fu,
2460 5u,
2461 0x36u,
2462 "",
2463 0);
2464 }
2465 }
2466 }
2467 return result;
2468 }
2469
2470
2471
2472 //----- (00427D48) --------------------------------------------------------
2473 void stru277::_427D48(unsigned int uPlayerID)
2474 {
2475 stru277 *v2; // esi@1
2476 signed int v3; // ebx@1
2477
2478 v2 = this;
2479 v3 = 10;
2480 do
2481 {
2482 if ( v2->spellnum )
2483 {
2484 if ( v2->field_8 & 0x3CA )
2485 {
2486 v2->spellnum = 0;
2487 pGUIWindow_Settings->Release();
2488 pGUIWindow_Settings = 0;
2489 pMouse->SetCursorBitmap("MICON1");
2490 GameUI_StatusBar_TimedStringTimeLeft = 0;
2491 unk_50C9A0 = 0;
2492 back_to_game();
2493 }
2494 }
2495 ++v2;
2496 --v3;
2497 }
2498 while ( v3 );
2499 }
2500
2501 //----- (00427DA0) --------------------------------------------------------
2502 unsigned int stru277::PushStru277(__int16 a2, __int16 uPlayerID, __int16 a4, __int16 a5, int a6)
2503 {
2504 unsigned int result; // eax@1
2505 stru277 *v7; // edx@1
2506 stru277 *v8; // ecx@5
2507
2508 result = 0;
2509 v7 = this;
2510 while ( v7->spellnum )
2511 {
2512 ++result;
2513 ++v7;
2514 if ( (signed int)result >= 10 )
2515 goto LABEL_8;
2516 }
2517 v8 = &this[result];
2518 v8->spellnum = a2;
2519 v8->uPlayerID = uPlayerID;
2520 if ( a5 & 0x10 )
2521 v8->uPlayerID_2 = uPlayerID;
2522 v8->field_6 = 0;
2523 *(int *)&v8->field_C = 0;
2524 v8->field_8 = a5;
2525 v8->field_A = a4;
2526 v8->field_10 = a6;
2527 LABEL_8:
2528 if ( result == 10 )
2529 result = -1;
2530 return result;
2531 }
2532
2533 //----- (00427E01) --------------------------------------------------------
2534 void stru277::_427E01_cast_spell()
2535 {
2536 int v1; // esi@1
2537 int v2; // edi@1
2538 stru277 *v3; // ebx@2
2539 signed int v4; // eax@8
2540 __int16 v5; // ax@9
2541 signed int v6; // eax@14
2542 __int16 v7; // ax@23
2543 __int16 v8; // ax@24
2544 char v9; // al@44
2545 int v10; // eax@45
2546 unsigned __int16 v11; // cx@45
2547 signed int v12; // ecx@48
2548 int v13; // eax@53
2549 unsigned __int8 v14; // zf@53
2550 unsigned int v15; // edx@53
2551 signed int v16; // eax@53
2552 Player *v17; // esi@70
2553 int v18; // eax@72
2554 int v19; // eax@74
2555 char *v20; // eax@74
2556 signed int i; // esi@76
2557 int v22; // eax@88
2558 __int16 v23; // ax@88
2559 int v24; // ecx@93
2560 int v25; // ecx@94
2561 signed __int64 v26; // qax@100
2562 char *v27; // ecx@100
2563 unsigned __int64 v28; // qax@102
2564 int v29; // ecx@105
2565 int v30; // ecx@106
2566 int v31; // eax@112
2567 int v32; // eax@112
2568 char *v33; // edx@113
2569 int v34; // eax@121
2570 int v35; // eax@123
2571 int v36; // edx@125
2572 int v37; // eax@129
2573 signed int v38; // edi@129
2574 signed int v39; // eax@129
2575 int v40; // ecx@129
2576 int v41; // eax@129
2577 signed int v42; // eax@129
2578 int *v43; // ecx@129
2579 int v44; // eax@132
2580 int v45; // ecx@132
2581 int v46; // eax@132
2582 unsigned int v47; // edx@133
2583 int v48; // eax@137
2584 int v49; // eax@137
2585 int v50; // eax@141
2586 int v51; // eax@146
2587 __int16 v52; // ax@153
2588 int v53; // eax@153
2589 signed __int64 v54; // qax@164
2590 int v55; // edi@164
2591 stru6 *v56; // eax@165
2592 int v57; // eax@169
2593 signed __int64 v58; // qax@177
2594 int v59; // edi@177
2595 unsigned __int16 v60; // ax@184
2596 int v61; // ecx@184
2597 int v62; // eax@186
2598 int v63; // ecx@187
2599 int v64; // ecx@188
2600 int v65; // ecx@189
2601 const char *v66; // ecx@200
2602 unsigned int v67; // edx@201
2603 char v68; // al@207
2604 int v69; // esi@211
2605 int v70; // ecx@214
2606 int v71; // ecx@215
2607 int v72; // ecx@216
2608 __int16 v73; // ST1C_2@222
2609 __int16 v74; // ST18_2@222
2610 stru6 *v75; // eax@222
2611 int v76; // ecx@223
2612 int v77; // ecx@224
2613 int v78; // ecx@225
2614 int v79; // eax@227
2615 int v80; // eax@232
2616 __int16 v81; // ST18_2@245
2617 stru6 *v82; // eax@245
2618 signed int v83; // edi@245
2619 __int16 v84; // ST18_2@245
2620 stru6 *v85; // eax@245
2621 __int16 v86; // ST18_2@245
2622 stru6 *v87; // eax@245
2623 __int16 v88; // ST18_2@245
2624 stru6 *v89; // eax@245
2625 double v90; // st7@245
2626 int v91; // eax@250
2627 char *v92; // eax@255
2628 __int16 v93; // ST18_2@260
2629 stru6 *v94; // eax@260
2630 __int16 v95; // ST18_2@260
2631 stru6 *v96; // eax@260
2632 __int16 v97; // ST18_2@260
2633 stru6 *v98; // eax@260
2634 __int16 v99; // ST18_2@260
2635 stru6 *v100; // eax@260
2636 int v101; // ecx@261
2637 int v102; // ecx@262
2638 int v103; // ecx@263
2639 int v104; // eax@265
2640 int v105; // edi@271
2641 __int16 v106; // ST18_2@272
2642 stru6 *v107; // eax@272
2643 __int16 v108; // ST1C_2@274
2644 __int16 v109; // ST18_2@274
2645 stru6 *v110; // eax@274
2646 int v111; // eax@274
2647 Actor *v112; // esi@278
2648 int v113; // eax@278
2649 int v114; // ebx@278
2650 unsigned int v115; // ecx@278
2651 int v116; // edx@279
2652 int v117; // edx@281
2653 int v118; // edx@283
2654 int v119; // edi@286
2655 int v120; // eax@286
2656 int v121; // eax@286
2657 signed int v122; // eax@286
2658 int v123; // ecx@288
2659 int v124; // ecx@289
2660 int v125; // ecx@290
2661 int v126; // eax@292
2662 int v127; // eax@296
2663 __int16 v128; // ST18_2@303
2664 stru6 *v129; // eax@303
2665 __int16 v130; // ST18_2@303
2666 stru6 *v131; // eax@303
2667 __int16 v132; // ST18_2@303
2668 stru6 *v133; // eax@303
2669 __int16 v134; // ST18_2@303
2670 stru6 *v135; // eax@303
2671 unsigned __int64 v136; // qax@304
2672 char *v137; // ecx@304
2673 int v138; // ecx@305
2674 int v139; // ecx@306
2675 int v140; // eax@308
2676 __int16 v141; // ST18_2@311
2677 stru6 *v142; // eax@311
2678 __int16 v143; // ST18_2@311
2679 stru6 *v144; // eax@311
2680 __int16 v145; // ST18_2@311
2681 stru6 *v146; // eax@311
2682 __int16 v147; // ST18_2@311
2683 stru6 *v148; // eax@311
2684 int v149; // ecx@312
2685 int v150; // ecx@313
2686 int v151; // ecx@314
2687 signed int v152; // eax@322
2688 int v153; // ecx@322
2689 int v154; // eax@322
2690 int v155; // eax@323
2691 int v156; // eax@323
2692 int v157; // eax@326
2693 double v158; // st7@326
2694 double v159; // st6@326
2695 signed __int64 v160; // qtt@334
2696 int v161; // eax@339
2697 int v162; // edi@340
2698 int v163; // eax@340
2699 signed int v164; // eax@340
2700 signed int v165; // edi@340
2701 stru6 *v166; // eax@340
2702 stru6 *v167; // eax@340
2703 signed int v168; // edi@343
2704 int v169; // eax@344
2705 int v170; // ecx@346
2706 int v171; // ecx@347
2707 int v172; // ecx@348
2708 int v173; // edi@350
2709 signed int v174; // edi@355
2710 __int16 v175; // ST18_2@357
2711 stru6 *v176; // eax@357
2712 __int16 v177; // ST18_2@357
2713 stru6 *v178; // eax@357
2714 __int16 v179; // ST18_2@357
2715 stru6 *v180; // eax@357
2716 __int16 v181; // ST18_2@357
2717 stru6 *v182; // eax@357
2718 signed __int64 v183; // qax@357
2719 int v184; // ecx@358
2720 int v185; // ecx@359
2721 int v186; // ecx@360
2722 int v187; // eax@367
2723 int v188; // esi@369
2724 int v189; // edi@369
2725 const char *v190; // ecx@377
2726 signed int v191; // edi@379
2727 int v192; // ecx@382
2728 int v193; // ecx@383
2729 int v194; // ecx@384
2730 int v195; // eax@386
2731 int v196; // eax@387
2732 __int16 v197; // ST18_2@395
2733 stru6 *v198; // eax@395
2734 __int16 v199; // ST18_2@395
2735 stru6 *v200; // eax@395
2736 __int16 v201; // ST18_2@395
2737 stru6 *v202; // eax@395
2738 __int16 v203; // ST18_2@395
2739 stru6 *v204; // eax@395
2740 signed int v205; // edi@405
2741 int v206; // eax@407
2742 __int16 v207; // cx@407
2743 int v208; // eax@411
2744 signed int v209; // ecx@412
2745 int v210; // edx@412
2746 signed int v211; // ecx@412
2747 int v212; // eax@413
2748 int v213; // eax@413
2749 int v214; // eax@413
2750 int v215; // eax@415
2751 double v216; // st7@415
2752 double v217; // st6@415
2753 signed __int64 v218; // qtt@423
2754 int v219; // ecx@425
2755 int v220; // ecx@426
2756 int v221; // edi@428
2757 char *v222; // edi@434
2758 char v223; // al@438
2759 int v224; // ecx@442
2760 int v225; // ecx@443
2761 int v226; // eax@451
2762 int v227; // esi@453
2763 unsigned int v228; // edi@454
2764 int v229; // edi@466
2765 __int16 v230; // ST18_2@469
2766 stru6 *v231; // eax@469
2767 signed int v232; // esi@469
2768 __int16 v233; // ST18_2@469
2769 stru6 *v234; // eax@469
2770 __int16 v235; // ST18_2@469
2771 stru6 *v236; // eax@469
2772 __int16 v237; // ST18_2@469
2773 stru6 *v238; // eax@469
2774 __int16 v239; // ST1C_2@469
2775 char *v240; // ecx@472
2776 double v241; // st7@478
2777 signed __int64 v242; // qax@484
2778 char *v243; // ecx@484
2779 char *v244; // eax@488
2780 int v245; // edi@492
2781 int v246; // eax@492
2782 char *v247; // eax@497
2783 char v248; // al@497
2784 char v249; // cf@500
2785 float v250; // esi@507
2786 char v251; // al@507
2787 int v252; // edx@510
2788 int m; // esi@510
2789 int v254; // eax@513
2790 int v255; // esi@513
2791 int v256; // ecx@513
2792 int v257; // edx@514
2793 int v258; // ecx@514
2794 char v259; // al@516
2795 int v260; // eax@518
2796 int v261; // esi@519
2797 int v262; // edx@521
2798 int v263; // ecx@521
2799 int v264; // esi@521
2800 int v265; // edx@521
2801 int *ii; // eax@522
2802 int v267; // eax@524
2803 int v268; // eax@524
2804 int v269; // eax@526
2805 char *v270; // eax@531
2806 char v271; // al@531
2807 char v272; // cf@534
2808 float v273; // esi@541
2809 char v274; // al@541
2810 int v275; // edx@544
2811 int k; // esi@544
2812 int v277; // edx@548
2813 int v278; // ecx@548
2814 char v279; // al@550
2815 int v280; // eax@552
2816 int v281; // esi@553
2817 int v282; // edx@555
2818 int v283; // ecx@555
2819 int v284; // esi@555
2820 int v285; // edx@555
2821 int *l; // eax@556
2822 int v287; // eax@558
2823 int v288; // eax@558
2824 ItemGen *v289; // eax@560
2825 signed int v290; // eax@560
2826 unsigned __int8 v291; // al@564
2827 char v292; // al@573
2828 int v293; // eax@575
2829 ItemGen *v294; // esi@575
2830 int v295; // edx@575
2831 int kk; // edi@575
2832 int v297; // edx@579
2833 int v298; // ecx@579
2834 char v299; // al@581
2835 int v300; // eax@583
2836 int v301; // edi@584
2837 int v302; // edx@586
2838 int v303; // ecx@586
2839 int v304; // edi@586
2840 int v305; // edx@586
2841 int *jj; // eax@587
2842 int v307; // eax@589
2843 int v308; // eax@589
2844 char *v309; // ecx@593
2845 char v310; // sf@593
2846 unsigned __int8 v311; // of@593
2847 char v312; // cl@597
2848 char v313; // al@606
2849 int v314; // edx@607
2850 int j; // esi@607
2851 unsigned int v316; // eax@613
2852 const char *v317; // ecx@617
2853 Player *v318; // ecx@619
2854 unsigned int v319; // edi@627
2855 int v320; // ecx@629
2856 int v321; // ecx@630
2857 int v322; // edi@632
2858 int v323; // edi@635
2859 char *v324; // eax@635
2860 Player *v325; // ecx@640
2861 int v326; // eax@643
2862 int v327; // eax@648
2863 int v328; // ecx@651
2864 int v329; // ecx@652
2865 int v330; // edi@654
2866 __int16 v331; // ST18_2@658
2867 stru6 *v332; // eax@658
2868 __int16 v333; // ST18_2@658
2869 stru6 *v334; // eax@658
2870 __int16 v335; // ST18_2@658
2871 stru6 *v336; // eax@658
2872 __int16 v337; // ST18_2@658
2873 stru6 *v338; // eax@658
2874 int v339; // ecx@659
2875 int v340; // ecx@660
2876 int v341; // eax@663
2877 signed int v342; // edi@668
2878 signed int v343; // edi@670
2879 unsigned __int64 v344; // ST08_8@670
2880 __int16 v345; // ST1C_2@671
2881 __int16 v346; // ST18_2@671
2882 stru6 *v347; // eax@671
2883 int v348; // ecx@672
2884 int v349; // ecx@673
2885 int v350; // edi@676
2886 Player *v351; // edi@680
2887 __int16 v352; // ST18_2@685
2888 stru6 *v353; // eax@685
2889 int v354; // ecx@686
2890 int v355; // ecx@687
2891 int v356; // eax@689
2892 SpellBuff *v357; // edi@694
2893 unsigned __int16 v358; // ST1C_2@695
2894 __int16 v359; // ST18_2@695
2895 stru6 *v360; // eax@695
2896 __int16 v361; // ST1C_2@697
2897 __int16 v362; // ST18_2@697
2898 stru6 *v363; // eax@697
2899 int v364; // ecx@698
2900 int v365; // ecx@699
2901 int v366; // eax@701
2902 stru6 *v367; // eax@704
2903 int v368; // eax@704
2904 Actor *v369; // edi@705
2905 int v370; // eax@706
2906 int v371; // ecx@709
2907 int v372; // ecx@710
2908 int v373; // eax@715
2909 int v374; // eax@717
2910 char *v375; // edi@717
2911 int v376; // eax@717
2912 Player *v377; // ecx@719
2913 int v378; // ecx@721
2914 int v379; // ecx@722
2915 int v380; // eax@724
2916 int v381; // edi@727
2917 int v382; // ecx@727
2918 Player *v383; // eax@728
2919 int v384; // eax@733
2920 int v385; // edi@736
2921 signed int v386; // eax@736
2922 Player *v387; // edi@738
2923 int v388; // edi@740
2924 unsigned __int16 v389; // ST1C_2@740
2925 __int16 v390; // ST18_2@740
2926 stru6 *v391; // eax@740
2927 int v392; // ecx@742
2928 int v393; // ecx@743
2929 int v394; // ecx@744
2930 int v395; // edi@747
2931 int v396; // eax@752
2932 int v397; // eax@757
2933 int v398; // eax@757
2934 int v399; // eax@757
2935 char *v400; // esi@757
2936 Game *v401; // ecx@759
2937 __int16 v402; // ST1C_2@759
2938 __int16 v403; // ST18_2@759
2939 stru6 *v404; // eax@759
2940 int v405; // ecx@761
2941 int v406; // ecx@762
2942 int v407; // edi@765
2943 __int16 v408; // ST1C_2@769
2944 __int16 v409; // ST18_2@769
2945 stru6 *v410; // eax@769
2946 int v411; // ecx@772
2947 int v412; // ecx@773
2948 int v413; // edi@775
2949 __int16 v414; // ST1C_2@781
2950 __int16 v415; // ST18_2@781
2951 stru6 *v416; // eax@781
2952 int v417; // eax@787
2953 int v418; // ecx@789
2954 __int16 v419; // ax@791
2955 signed int v420; // eax@793
2956 int v421; // edx@793
2957 const char *v422; // eax@801
2958 int v423; // ecx@808
2959 int v424; // ecx@809
2960 int v425; // eax@811
2961 signed int v426; // eax@815
2962 signed int v427; // eax@820
2963 int v428; // ecx@825
2964 int v429; // ecx@826
2965 int v430; // eax@828
2966 stru6 *v431; // eax@831
2967 int v432; // eax@831
2968 Actor *v433; // edi@832
2969 int v434; // eax@833
2970 int v435; // ecx@837
2971 int v436; // ecx@838
2972 __int16 v437; // ST1C_2@843
2973 __int16 v438; // ST18_2@843
2974 stru6 *v439; // eax@843
2975 int v440; // eax@843
2976 int v441; // eax@847
2977 int v442; // ecx@850
2978 int v443; // ecx@851
2979 int v444; // eax@853
2980 signed int v445; // edi@857
2981 int v446; // ecx@862
2982 LevelDecoration *v447; // edi@864
2983 __int16 v448; // ax@864
2984 char *v449; // esi@870
2985 int v450; // eax@870
2986 int v451; // ecx@875
2987 int v452; // ecx@876
2988 int v453; // edi@878
2989 __int16 v454; // ST1C_2@884
2990 __int16 v455; // ST18_2@884
2991 stru6 *v456; // eax@884
2992 int v457; // ecx@887
2993 int v458; // ecx@888
2994 int v459; // eax@890
2995 signed int v460; // eax@895
2996 Actor *v461; // eax@897
2997 unsigned __int16 v462; // cx@897
2998 signed int v463; // edx@897
2999 int v464; // ecx@905
3000 int v465; // ecx@906
3001 int v466; // edi@909
3002 __int16 v467; // ST1C_2@913
3003 __int16 v468; // ST18_2@913
3004 stru6 *v469; // eax@913
3005 int v470; // edi@913
3006 int v471; // eax@917
3007 int v472; // eax@917
3008 char *v473; // esi@918
3009 __int16 v474; // ST18_2@920
3010 stru6 *v475; // eax@920
3011 __int16 v476; // ST18_2@920
3012 stru6 *v477; // eax@920
3013 __int16 v478; // ST18_2@920
3014 stru6 *v479; // eax@920
3015 __int16 v480; // ST18_2@920
3016 stru6 *v481; // eax@920
3017 __int16 v482; // ST18_2@923
3018 stru6 *v483; // eax@923
3019 __int16 v484; // ST18_2@923
3020 stru6 *v485; // eax@923
3021 __int16 v486; // ST18_2@923
3022 stru6 *v487; // eax@923
3023 __int16 v488; // ST18_2@923
3024 stru6 *v489; // eax@923
3025 __int16 v490; // ST1C_2@924
3026 __int16 v491; // ST18_2@924
3027 stru6 *v492; // eax@924
3028 int v493; // ecx@925
3029 int v494; // ecx@926
3030 __int16 v495; // ST1C_2@931
3031 __int16 v496; // ST18_2@931
3032 stru6 *v497; // eax@931
3033 int v498; // edi@931
3034 int v499; // eax@935
3035 int v500; // eax@935
3036 Player *v501; // edi@939
3037 __int16 v502; // ST18_2@940
3038 stru6 *v503; // eax@940
3039 stru6 *v504; // eax@943
3040 int v505; // eax@943
3041 int v506; // eax@943
3042 int v507; // edi@944
3043 int v508; // eax@944
3044 signed int v509; // eax@944
3045 signed int v510; // edi@944
3046 Actor *v511; // edi@946
3047 int v512; // eax@946
3048 SpellBuff *v513; // edi@946
3049 int v514; // ecx@950
3050 int v515; // ecx@951
3051 int v516; // eax@953
3052 int v517; // eax@956
3053 char *v518; // edx@957
3054 __int16 v519; // cx@958
3055 int v520; // ecx@968
3056 int v521; // ecx@969
3057 int v522; // eax@971
3058 __int16 v523; // ST18_2@975
3059 stru6 *v524; // eax@975
3060 __int16 v525; // ST18_2@975
3061 stru6 *v526; // eax@975
3062 __int16 v527; // ST18_2@975
3063 stru6 *v528; // eax@975
3064 __int16 v529; // ST18_2@975
3065 stru6 *v530; // eax@975
3066 int v531; // eax@982
3067 int v532; // eax@982
3068 int v533; // edi@983
3069 int v534; // eax@983
3070 signed int v535; // eax@983
3071 signed int v536; // edi@983
3072 stru6 *v537; // eax@984
3073 int v538; // ecx@985
3074 int v539; // ecx@986
3075 int v540; // eax@988
3076 __int16 v541; // ST18_2@991
3077 stru6 *v542; // eax@991
3078 __int16 v543; // ST18_2@991
3079 stru6 *v544; // eax@991
3080 __int16 v545; // ST18_2@991
3081 stru6 *v546; // eax@991
3082 __int16 v547; // ST18_2@991
3083 stru6 *v548; // eax@991
3084 double v549; // st7@991
3085 unsigned __int16 v550; // di@991
3086 int v551; // ecx@993
3087 int v552; // ecx@994
3088 char *v553; // edi@1001
3089 __int16 v554; // ST18_2@1002
3090 stru6 *v555; // eax@1002
3091 __int16 v556; // ST18_2@1002
3092 stru6 *v557; // eax@1002
3093 __int16 v558; // ST18_2@1002
3094 stru6 *v559; // eax@1002
3095 __int16 v560; // ST18_2@1002
3096 stru6 *v561; // eax@1002
3097 unsigned __int16 v562; // di@1005
3098 signed int v563; // eax@1010
3099 unsigned int v564; // ecx@1011
3100 signed int v565; // eax@1012
3101 Player **v566; // ecx@1012
3102 int v567; // eax@1012
3103 unsigned __int16 v568; // ST1C_2@1012
3104 __int16 v569; // ST18_2@1012
3105 stru6 *v570; // eax@1012
3106 Player *v571; // eax@1013
3107 char *v572; // ecx@1013
3108 int v573; // ecx@1017
3109 int v574; // ecx@1018
3110 int v575; // eax@1020
3111 signed int v576; // eax@1025
3112 Player *v577; // eax@1026
3113 int v578; // eax@1028
3114 __int16 v579; // ax@1029
3115 int v580; // eax@1031
3116 int v581; // edi@1031
3117 int v582; // eax@1031
3118 __int16 v583; // ST1C_2@1034
3119 __int16 v584; // ST18_2@1034
3120 char *v585; // esi@1034
3121 stru6 *v586; // eax@1034
3122 signed int v587; // eax@1035
3123 int v588; // ecx@1036
3124 int v589; // ecx@1037
3125 int v590; // ecx@1038
3126 char v591; // al@1048
3127 int v592; // esi@1052
3128 int v593; // ecx@1057
3129 int v594; // ecx@1058
3130 int v595; // eax@1064
3131 int v596; // esi@1066
3132 unsigned int v597; // edi@1067
3133 int v598; // eax@1079
3134 signed int v599; // eax@1082
3135 int v600; // edi@1086
3136 int v601; // edx@1086
3137 int v602; // eax@1086
3138 int v603; // ecx@1086
3139 int v604; // eax@1087
3140 char *v605; // eax@1089
3141 int v606; // edx@1091
3142 int v607; // ecx@1100
3143 __int16 v608; // ax@1102
3144 signed int v609; // eax@1104
3145 int v610; // edi@1106
3146 unsigned int v611; // eax@1106
3147 char *v612; // edi@1106
3148 char *v613; // eax@1108
3149 int v614; // eax@1116
3150 int v615; // edi@1119
3151 __int16 v616; // ST1C_2@1122
3152 __int16 v617; // ST18_2@1122
3153 stru6 *v618; // eax@1122
3154 SpellBuff *v619; // edi@1123
3155 unsigned __int16 v620; // ST1C_2@1124
3156 __int16 v621; // ST18_2@1124
3157 stru6 *v622; // eax@1124
3158 signed __int64 v623; // qax@1127
3159 int v624; // eax@1127
3160 int v625; // edi@1129
3161 int v626; // eax@1129
3162 signed int v627; // eax@1129
3163 signed int v628; // edi@1129
3164 int v629; // ecx@1130
3165 Player *v630; // eax@1131
3166 int v631; // eax@1137
3167 int v632; // edi@1140
3168 Player *v633; // eax@1140
3169 signed int v634; // eax@1140
3170 int v635; // edi@1142
3171 unsigned __int16 v636; // ST1C_2@1142
3172 __int16 v637; // ST18_2@1142
3173 stru6 *v638; // eax@1142
3174 stru6 *v639; // eax@1143
3175 int v640; // ecx@1146
3176 int v641; // ecx@1147
3177 int v642; // edi@1156
3178 int v643; // eax@1156
3179 int v644; // eax@1156
3180 signed int v645; // eax@1158
3181 Player *v646; // ebx@1169
3182 int v647; // edi@1169
3183 signed int v648; // ST1C_4@1170
3184 Player *v649; // ecx@1170
3185 unsigned __int64 v650; // [sp-10h] [bp-E94h]@103
3186 unsigned __int16 v651; // [sp-8h] [bp-E8Ch]@100
3187 unsigned __int16 v652; // [sp-8h] [bp-E8Ch]@304
3188 unsigned __int16 v653; // [sp-4h] [bp-E88h]@100
3189 int v654; // [sp-4h] [bp-E88h]@124
3190 unsigned __int16 v655; // [sp-4h] [bp-E88h]@304
3191 unsigned int v656; // [sp-4h] [bp-E88h]@639
3192 int v657; // [sp-4h] [bp-E88h]@807
3193 int v658; // [sp+0h] [bp-E84h]@100
3194 int v659; // [sp+0h] [bp-E84h]@123
3195 int v660; // [sp+0h] [bp-E84h]@146
3196 Actor *v661; // [sp+0h] [bp-E84h]@164
3197 int v662; // [sp+0h] [bp-E84h]@304
3198 unsigned __int64 v663; // [sp+0h] [bp-E84h]@639
3199 const char *v664; // [sp+0h] [bp-E84h]@802
3200 int v665; // [sp+0h] [bp-E84h]@807
3201 int v666; // [sp+4h] [bp-E80h]@12
3202 enum PLAYER_SKILL_TYPE v667; // [sp+4h] [bp-E80h]@25
3203 unsigned __int8 v668; // [sp+4h] [bp-E80h]@100
3204 int v669; // [sp+4h] [bp-E80h]@123
3205 Vec3_int_ *v670; // [sp+4h] [bp-E80h]@133
3206 int v671; // [sp+4h] [bp-E80h]@146
3207 unsigned int v672; // [sp+4h] [bp-E80h]@164
3208 unsigned __int8 v673; // [sp+4h] [bp-E80h]@304
3209 __int16 v674; // [sp+4h] [bp-E80h]@684
3210 const char *v675; // [sp+4h] [bp-E80h]@800
3211 int v676; // [sp+4h] [bp-E80h]@807
3212 int v677; // [sp+4h] [bp-E80h]@861
3213 int v678; // [sp+4h] [bp-E80h]@997
3214 int v679; // [sp+14h] [bp-E70h]@515
3215 AIDirection a3; // [sp+C94h] [bp-1F0h]@21
3216 int v681[4]; // [sp+CB0h] [bp-1D4h]@1137
3217 int v682[4]; // [sp+CC0h] [bp-1C4h]@731
3218 ItemGen v683; // [sp+CD0h] [bp-1B4h]@791
3219 int v684; // [sp+D04h] [bp-180h]@416
3220 unsigned __int64 v685; // [sp+D08h] [bp-17Ch]@416
3221 int x; // [sp+D20h] [bp-164h]@327
3222 unsigned __int64 v687; // [sp+D24h] [bp-160h]@327
3223 int v688; // [sp+D2Ch] [bp-158h]@943
3224 int v689; // [sp+D30h] [bp-154h]@943
3225 int v690; // [sp+D34h] [bp-150h]@943
3226 int v691; // [sp+D38h] [bp-14Ch]@137
3227 int v692; // [sp+D3Ch] [bp-148h]@137
3228 int v693; // [sp+D40h] [bp-144h]@137
3229 int v694; // [sp+D44h] [bp-140h]@982
3230 int v695; // [sp+D48h] [bp-13Ch]@982
3231 int v696; // [sp+D4Ch] [bp-138h]@982
3232 int v697; // [sp+D50h] [bp-134h]@129
3233 int v698; // [sp+D54h] [bp-130h]@129
3234 int v699; // [sp+D58h] [bp-12Ch]@129
3235 Vec3_int_ v700; // [sp+D5Ch] [bp-128h]@339
3236 int v701; // [sp+D68h] [bp-11Ch]@286
3237 int v702; // [sp+D6Ch] [bp-118h]@286
3238 int v703; // [sp+D70h] [bp-114h]@286
3239 int v704; // [sp+D74h] [bp-110h]@132
3240 int v705; // [sp+D78h] [bp-10Ch]@132
3241 int v706; // [sp+D7Ch] [bp-108h]@132
3242 int v707; // [sp+D80h] [bp-104h]@1127
3243 int v708; // [sp+D84h] [bp-100h]@1127
3244 int v709; // [sp+D88h] [bp-FCh]@1127
3245 char v710; // [sp+D8Ch] [bp-F8h]@1156
3246 stru277 *v711; // [sp+D90h] [bp-F4h]@1
3247 __int64 v712; // [sp+D94h] [bp-F0h]@991
3248 int v713; // [sp+D9Ch] [bp-E8h]@324
3249 int n; // [sp+DA0h] [bp-E4h]@1
3250 AIDirection v715; // [sp+DA4h] [bp-E0h]@21
3251 int v716; // [sp+DC0h] [bp-C4h]@272
3252 __int64 v717; // [sp+DC4h] [bp-C0h]@271
3253 float v718; // [sp+DCCh] [bp-B8h]@176
3254 signed int sRecoveryTime; // [sp+DD0h] [bp-B4h]@53
3255 char *y; // [sp+DD4h] [bp-B0h]@325
3256 int v721; // [sp+DD8h] [bp-ACh]@163
3257 //LayingItem a1; // [sp+DDCh] [bp-A8h]@1
3258 int v723; // [sp+E4Ch] [bp-38h]@1
3259 ItemGen *_this; // [sp+E50h] [bp-34h]@23
3260 float v725; // [sp+E54h] [bp-30h]@23
3261 Player *v726; // [sp+E58h] [bp-2Ch]@131
3262 float v727; // [sp+E5Ch] [bp-28h]@1
3263 unsigned int uRequiredMana; // [sp+E60h] [bp-24h]@53
3264 Player *pPlayer; // [sp+E64h] [bp-20h]@8
3265 int v730; // [sp+E68h] [bp-1Ch]@53
3266 int v731; // [sp+E6Ch] [bp-18h]@48
3267 signed int v732; // [sp+E70h] [bp-14h]@325
3268 unsigned __int64 v733; // [sp+E74h] [bp-10h]@1
3269 signed int a2; // [sp+E7Ch] [bp-8h]@14
3270 int amount; // [sp+E80h] [bp-4h]@1
3271
3272 auto ecx0 = this;
3273
3274 v711 = ecx0;
3275
3276 LayingItem a1; // [sp+DDCh] [bp-A8h]@1
3277 //LayingItem::LayingItem(&a1);
3278
3279 v1 = 0;
3280 v2 = 0;
3281 amount = 0;
3282 LODWORD(v733) = 0;
3283 v723 = 0;
3284 v727 = 0.0;
3285 n = 0;
3286 while ( 1 )
3287 {
3288 v3 = &v711[n];
3289 HIDWORD(v733) = (int)v3;
3290 if ( v3->spellnum == (short)v1 )
3291 goto LABEL_1166;
3292 if ( pParty->pPartyBuffs[11].NotExpired() )
3293 pParty->pPartyBuffs[11].Reset();
3294 if ( v3->field_8 & 0x3CA )
3295 {
3296 if ( !pParty->pPlayers[v3->uPlayerID].CanAct() )
3297 v711->_427D48(1u);
3298 goto LABEL_1166;
3299 }
3300 pPlayer = &pParty->pPlayers[v3->uPlayerID];
3301 v4 = *(int *)&v3->field_C;
3302 if ( v4 != v1 )
3303 goto LABEL_18;
3304 v5 = v3->spellnum;
3305 if ( v3->spellnum == 79 || v5 == 48 || v5 == 94 )
3306 v666 = 1;
3307 else
3308 v666 = v1;
3309 a2 = stru_50C198.FindClosesActor(5120, 1, v666);
3310 v6 = pMouse->uPointingObjectID;
3311 if ( pMouse->uPointingObjectID != v1 && (v6 & 7) == 3 && pActors[v6 >> 3].CanAct() )
3312 {
3313 v4 = pMouse->uPointingObjectID;
3314 LABEL_18:
3315 a2 = v4;
3316 }
3317 a1.uItemType = stru_4E3ACC[v3->spellnum].uItemType;
3318 if ( (short)a1.uItemType != (short)v1 )
3319 {
3320 if ( (a2 & 7) == 3 )
3321 {
3322 memcpy(&v715, Actor::GetDirectionInfo((8 * v3->uPlayerID + 8) | 4, a2, &a3, 0), sizeof(v715));
3323 v2 = v723;
3324 v1 = 0;
3325 }
3326 else
3327 {
3328 v715.uYawAngle = pParty->sRotationY;
3329 v715.uPitchAngle = pParty->sRotationX;
3330 }
3331 }
3332 v7 = v3->field_A;
3333 LODWORD(v725) = v1;
3334 _this = (ItemGen *)v1;
3335 if ( v7 == (short)v1 )
3336 {
3337 v8 = v3->spellnum;
3338 if ( v3->spellnum >= 12 )
3339 {
3340 if ( v8 >= 23 )
3341 {
3342 if ( v8 >= 34 )
3343 {
3344 if ( v8 >= 45 )
3345 {
3346 if ( v8 >= 56 )
3347 {
3348 if ( v8 >= 67 )
3349 {
3350 if ( v8 >= 78 )
3351 {
3352 if ( v8 >= 89 )
3353 {
3354 if ( v8 >= 100 )
3355 {
3356 if ( v8 != 100 )
3357 {
3358 LABEL_45:
3359 HIWORD(v10) = HIWORD(pPlayer);
3360 v11 = pPlayer->pActiveSkills[LODWORD(v725)];
3361 goto LABEL_47;
3362 }
3363 v667 = (PLAYER_SKILL_TYPE)5;
3364 }
3365 else
3366 {
3367 v667 = (PLAYER_SKILL_TYPE)20;
3368 }
3369 }
3370 else
3371 {
3372 v667 = (PLAYER_SKILL_TYPE)19;
3373 }
3374 }
3375 else
3376 {
3377 v667 = (PLAYER_SKILL_TYPE)18;
3378 }
3379 }
3380 else
3381 {
3382 v667 = (PLAYER_SKILL_TYPE)17;
3383 }
3384 }
3385 else
3386 {
3387 v667 = (PLAYER_SKILL_TYPE)16;
3388 }
3389 }
3390 else
3391 {
3392 v667 = (PLAYER_SKILL_TYPE)15;
3393 }
3394 }
3395 else
3396 {
3397 v667 = (PLAYER_SKILL_TYPE)14;
3398 }
3399 }
3400 else
3401 {
3402 v667 = (PLAYER_SKILL_TYPE)13;
3403 }
3404 }
3405 else
3406 {
3407 v667 = (PLAYER_SKILL_TYPE)12;
3408 }
3409 LODWORD(v725) = v667;
3410 v9 = pPlayer->GetActualSkillLevel(v667);
3411 v723 = v9 & 0x3F;
3412 v2 = v9 & 0x3F;
3413 goto LABEL_45;
3414 }
3415 v11 = v7;
3416 v10 = v7 & 0x3F;
3417 v723 = v10;
3418 v2 = v10;
3419 LABEL_47:
3420 if ( HIBYTE(v11) & 1 )
3421 {
3422 v12 = 4;
3423 v731 = 4;
3424 }
3425 else
3426 {
3427 if ( (v11 & 0x80u) == 0 )
3428 {
3429 v10 = ((v11 & 0x40) != 0) + 1;
3430 v731 = ((v11 & 0x40) != 0) + 1;
3431 }
3432 else
3433 {
3434 v731 = 3;
3435 }
3436 v12 = v731;
3437 }
3438 LOWORD(v10) = v3->spellnum;
3439 v730 = v10;
3440 v13 = v12 + 10 * (signed __int16)v10;
3441 v14 = v3->field_A == (short)v1;
3442 v15 = (unsigned __int16)word_4E3C66[v13]; // pSpellDatas [negoffset] indexing
3443 v16 = *(unsigned __int16 *)((char *)&pSpellDatas[0].uMagisterLevelMana + v13 * 2);
3444 uRequiredMana = v15;
3445 sRecoveryTime = v16;
3446 if ( !v14 )
3447 uRequiredMana = v1;
3448 if ( pParty->uCurrentHour == v1 )
3449 {
3450 if ( pParty->uCurrentMinute != v1 )
3451 goto LABEL_62;
3452 if ( LODWORD(v725) == 20 )
3453 goto LABEL_61;
3454 }
3455 if ( pParty->uCurrentHour == 12 && pParty->uCurrentMinute == v1 && LODWORD(v725) == 19 )
3456 LABEL_61:
3457 uRequiredMana = v1;
3458 LABEL_62:
3459 if ( (signed __int16)v730 >= 100 || ((pPlayer->sMana - uRequiredMana) & 0x80000000u) == 0 )
3460 break;
3461 ShowStatusBarString(pGlobalTXT_LocalizationStrings[586], 2u);
3462 LABEL_203:
3463 v3->spellnum = v1;
3464 LABEL_1166:
3465 ++n;
3466 if ( n >= 10 )
3467 return;
3468 }
3469 if ( !pPlayer->pConditions[0] || (signed __int16)v730 >= 100 )
3470 goto LABEL_69;
3471 if ( rand() % 100 >= 50 )
3472 {
3473 v12 = v731;
3474 LABEL_69:
3475 switch ( v3->spellnum )
3476 {
3477 case 100:
3478 case 101:
3479 v17 = pPlayer;
3480 _this = (ItemGen *)1;
3481 if ( (signed int)SkillToMastery(pPlayer->pActiveSkills[5]) >= 3 )
3482 _this = (ItemGen *)2;
3483 sRecoveryTime = v17->GetAttackRecoveryTime(1);
3484 a1.stru_24.Reset();
3485 v18 = v3->spellnum;
3486 a1.field_4C = v2;
3487 a1.field_48 = v18;
3488 a1.field_50 = v731;
3489 a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
3490 if ( v17->WearsItem(510, 2) )
3491 a1.uObjectDescID = pObjectList->ObjectIDByItemID(0xBD6u);
3492 a1.vPosition.x = pParty->vPosition.x;
3493 a1.vPosition.y = pParty->vPosition.y;
3494 a1.uAttributes = 0;
3495 a1.uSpriteFrameID = 0;
3496 a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
3497 v19 = 8 * v3->uPlayerID;
3498 LOBYTE(v19) = v19 | 4;
3499 a1.field_58 = v19;
3500 a1.field_5C = a2;
3501 a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
3502 a1.uFacing = LOWORD(v715.uYawAngle);
3503 a1.uSoundID = LOWORD(v3->field_10);
3504 v20 = (char *)&pParty->pPlayers[v3->uPlayerID];
3505 memcpy(&a1.stru_24, &v20[36 * *((int *)v20 + 1620) + 496], sizeof(a1.stru_24));
3506 a1.uAttributes = 256;
3507 if ( pParty->bTurnBasedModeOn == 1 )
3508 a1.uAttributes = 260;
3509 for ( i = 0; i < (signed int)this; ++i )
3510 {
3511 if ( i )
3512 a1.vPosition.z += 32;
3513 a1.uSectorID = pIndoor->GetSector(a1.vPosition.x, a1.vPosition.y, a1.vPosition.z);
3514 if ( a1.Create(
3515 v715.uYawAngle,
3516 v715.uPitchAngle,
3517 pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed,
3518 v3->uPlayerID + 1) != -1
3519 && pParty->bTurnBasedModeOn == 1 )
3520 ++pTurnEngine->field_1C;
3521 }
3522 goto LABEL_83;
3523 case 102:
3524 sRecoveryTime = pPlayer->GetAttackRecoveryTime(0);
3525 a1.stru_24.Reset();
3526 a1.field_48 = v3->spellnum;
3527 a1.field_4C = v723;
3528 a1.field_50 = v731;
3529 a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
3530 a1.vPosition.x = pParty->vPosition.x;
3531 a1.vPosition.y = pParty->vPosition.y;
3532 a1.uAttributes = 0;
3533 a1.uSpriteFrameID = 0;
3534 a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2;
3535 v22 = 8 * v3->uPlayerID;
3536 LOBYTE(v22) = v22 | 4;
3537 a1.field_58 = v22;
3538 a1.field_5C = a2;
3539 a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
3540 a1.uFacing = LOWORD(v715.uYawAngle);
3541 a1.uSoundID = LOWORD(v3->field_10);
3542 memcpy(
3543 &a1.stru_24,
3544 &pParty->pPlayers[v3->uPlayerID].spellbook.pDarkSpellbook.bIsSpellAvailable[36
3545 * pParty->pPlayers[v3->uPlayerID].pEquipment.uMainHand
3546 + 5],
3547 sizeof(a1.stru_24));
3548 v23 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, a1.vPosition.z);
3549 HIBYTE(a1.uAttributes) |= 1u;
3550 a1.uSectorID = v23;
3551 if ( pParty->bTurnBasedModeOn == 1 )
3552 LOBYTE(a1.uAttributes) |= 4u;
3553 if ( a1.Create(
3554 v715.uYawAngle,
3555 v715.uPitchAngle,
3556 pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed,
3557 v3->uPlayerID + 1) != -1
3558 && pParty->bTurnBasedModeOn == 1 )
3559 ++pTurnEngine->field_1C;
3560 goto LABEL_83;
3561 case 1:
3562 LODWORD(v733) = 3600 * v2;
3563 v24 = v12 - 2;
3564 if ( v24 )
3565 {
3566 v25 = v24 - 1;
3567 if ( v25 && v25 != 1 )
3568 amount = 2;
3569 else
3570 amount = 4;
3571 }
3572 else
3573 {
3574 amount = 3;
3575 }
3576 if ( !pPlayer->CanCastSpell(uRequiredMana) )
3577 goto LABEL_83;
3578 v668 = v1;
3579 v658 = v1;
3580 v653 = amount;
3581 v651 = v731;
3582 v26 = (signed __int64)((double)(signed int)v733 * 4.2666669);
3583 v27 = (char *)&pParty->pPartyBuffs[16];
3584 goto LABEL_101;
3585 case 7:
3586 v29 = v12 - 2;
3587 if ( v29 )
3588 {
3589 v30 = v29 - 1;
3590 if ( v30 )
3591 {
3592 if ( v30 == 1 )
3593 amount = 9;
3594 else
3595 amount = 3;
3596 }
3597 else
3598 {
3599 amount = 7;
3600 }
3601 }
3602 else
3603 {
3604 amount = 5;
3605 }
3606 v31 = v3->uPlayerID;
3607 HIDWORD(v733) = v1;
3608 v32 = 8 * v31;
3609 LOBYTE(v32) = v32 | 4;
3610 if ( (signed int)uNumLayingItems > v1 )
3611 {
3612 v33 = (char *)&pLayingItems[0].field_48;
3613 v730 = uNumLayingItems;
3614 do
3615 {
3616 if ( *((short *)v33 - 36) != (short)v1 && *(int *)v33 == 7 && *((int *)v33 + 4) == v32 )
3617 ++HIDWORD(v733);
3618 v33 += 112;
3619 --v730;
3620 }
3621 while ( v730 );
3622 }
3623 if ( SHIDWORD(v733) > amount )
3624 goto LABEL_200;
3625 if ( !pPlayer->CanCastSpell(uRequiredMana) )
3626 goto LABEL_83;
3627 a1.stru_24.Reset();
3628 a1.field_48 = v3->spellnum;
3629 a1.field_4C = v2;
3630 a1.field_50 = v731;
3631 a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
3632 a1.vPosition.y = pParty->vPosition.y;
3633 a1.vPosition.x = pParty->vPosition.x;
3634 a1.uAttributes = v1;
3635 a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
3636 a1.uSectorID = pIndoor->GetSector(
3637 pParty->vPosition.x,
3638 pParty->vPosition.y,
3639 pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
3640 a1.uSpriteFrameID = v1;
3641 v34 = 8 * v3->uPlayerID;
3642 LOBYTE(v34) = v34 | 4;
3643 a1.field_58 = v34;
3644 a1.field_5C = a2;
3645 a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
3646 a1.uFacing = LOWORD(v715.uYawAngle);
3647 a1.uSoundID = LOWORD(v3->field_10);
3648 if ( pParty->bTurnBasedModeOn == 1 )
3649 LOBYTE(a1.uAttributes) |= 4u;
3650 v669 = v3->uPlayerID + 1;
3651 v659 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed;
3652 v35 = pParty->sRotationX + 10;
3653 goto LABEL_124;
3654 case 20:
3655 if ( !pPlayer->CanCastSpell(uRequiredMana) )
3656 goto LABEL_83;
3657 if ( a2 == v1 )
3658 goto LABEL_200;
3659 if ( (a2 & 7) != 3 )
3660 goto LABEL_1056;
3661 v699 = v1;
3662 v698 = v1;
3663 v697 = v1;
3664 a1.stru_24.Reset();
3665 a1.field_48 = v3->spellnum;
3666 a1.field_4C = v2;
3667 a1.field_50 = v731;
3668 a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
3669 a1.uAttributes = v1;
3670 a1.uSectorID = v1;
3671 a1.uSpriteFrameID = v1;
3672 v37 = v3->uPlayerID;
3673 a1.field_60_distance_related_prolly_lod = 0;
3674 v37 *= 8;
3675 LOBYTE(v37) = v37 | 4;
3676 a1.uFacing = v1;
3677 a1.field_58 = v37;
3678 v38 = a2 >> 3;
3679 a1.uSoundID = LOWORD(v3->field_10);
3680 v39 = a2 >> 3;
3681 a1.vPosition.x = pActors[v39].vPosition.x;
3682 v40 = pActors[v39].vPosition.y;
3683 a1.vPosition.z = pActors[v39].vPosition.z;
3684 v41 = 8 * (a2 >> 3);
3685 a1.vPosition.y = v40;
3686 LOBYTE(v41) = v41 | 3;
3687 a1.field_5C = v41;
3688 v42 = a1.Create(0, v1, v1, v1);
3689 v43 = &v697;
3690 goto LABEL_133;
3691 case 44:
3692 if ( !pPlayer->CanCastSpell(uRequiredMana) )
3693 goto LABEL_83;
3694 v726 = (Player *)(a2 >> 3);
3695 HIDWORD(v733) = 836 * (a2 >> 3);
3696 if ( !stru_50C198.GetMagicalResistance((Actor *)((char *)pActors + HIDWORD(v733)), 3u) )
3697 goto LABEL_1056;
3698 ((SpellBuff *)((char *)&pActors[0].pActorBuffs[10] + HIDWORD(v733)))->Apply(
3699 pMiscTimer->uTotalGameTimeElapsed + 128,
3700 v1,
3701 v1,
3702 v1,
3703 v1);
3704 v706 = v1;
3705 v705 = v1;
3706 v704 = v1;
3707 a1.stru_24.Reset();
3708 a1.field_48 = v3->spellnum;
3709 a1.field_4C = v2;
3710 a1.field_50 = v731;
3711 a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
3712 a1.uAttributes = v1;
3713 a1.uSectorID = v1;
3714 a1.uSpriteFrameID = v1;
3715 v44 = v3->uPlayerID;
3716 a1.field_60_distance_related_prolly_lod = 0;
3717 a1.uFacing = v1;
3718 v44 *= 8;
3719 LOBYTE(v44) = v44 | 4;
3720 v38 = (signed int)v726;
3721 a1.field_58 = v44;
3722 a1.uSoundID = LOWORD(v3->field_10);
3723 a1.vPosition.x = *(__int16 *)((char *)&pActors[0].vPosition.x + HIDWORD(v733));
3724 v45 = *(__int16 *)((char *)&pActors[0].vPosition.y + HIDWORD(v733));
3725 a1.vPosition.z = *(__int16 *)((char *)&pActors[0].vPosition.z + HIDWORD(v733));
3726 v46 = 8 * (int)v726;
3727 a1.vPosition.y = v45;
3728 LOBYTE(v46) = 8 * (char)v726 | 3;
3729 a1.field_5C = v46;
3730 v42 = a1.Create(0, v1, v1, v1);
3731 v43 = &v704;
3732 LABEL_133:
3733 v670 = (Vec3_int_ *)v43;
3734 v47 = v38;
3735 goto LABEL_139;
3736 case 79:
3737 if ( !pPlayer->CanCastSpell(uRequiredMana) || a2 == v1 || (a2 & 7) != 3 )
3738 goto LABEL_83;
3739 v730 = a2 >> 3;
3740 v693 = v1;
3741 HIDWORD(v733) = (int)&pActors[a2 >> 3];
3742 v692 = v1;
3743 v691 = v1;
3744 a1.stru_24.Reset();
3745 a1.field_48 = v3->spellnum;
3746 a1.field_4C = v2;
3747 a1.field_50 = v731;
3748 a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
3749 a1.vPosition.x = *(short *)(HIDWORD(v733) + 142);
3750 a1.vPosition.y = *(short *)(HIDWORD(v733) + 144);
3751 v48 = *(short *)(HIDWORD(v733) + 138);
3752 a1.vPosition.z = *(short *)(HIDWORD(v733) + 138);
3753 a1.uAttributes = v1;
3754 a1.uSectorID = pIndoor->GetSector(a1.vPosition.x, a1.vPosition.y, v48);
3755 a1.uSpriteFrameID = v1;
3756 v49 = 8 * v3->uPlayerID;
3757 LOBYTE(v49) = v49 | 4;
3758 a1.field_58 = v49;
3759 a1.field_5C = a2;
3760 a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
3761 a1.uFacing = LOWORD(v715.uYawAngle);
3762 LOWORD(v49) = LOWORD(v3->field_10);
3763 LOBYTE(a1.uAttributes) |= 0x80u;
3764 a1.uSoundID = v49;
3765 v726 = (Player *)a1.Create(0, v1, v1, v1);
3766 if ( !MonsterStats::BelongsToSupertype(*(short *)(HIDWORD(v733) + 96), MONSTER_SUPERTYPE_UNDEAD) )
3767 goto LABEL_200;
3768 v47 = v730;
3769 v670 = (Vec3_int_ *)&v691;
3770 v42 = (signed int)v726;
3771 LABEL_139:
3772 DamageMonsterFromParty(8 * v42 | 2, v47, v670);
3773 goto LABEL_1056;
3774 case 2:
3775 case 6:
3776 case 11:
3777 case 18:
3778 case 26:
3779 case 32:
3780 case 34:
3781 case 37:
3782 case 57:
3783 case 65:
3784 case 70:
3785 case 78:
3786 case 97:
3787 if ( !pPlayer->CanCastSpell(uRequiredMana) )
3788 goto LABEL_83;
3789 a1.stru_24.Reset();
3790 a1.field_48 = v3->spellnum;
3791 a1.field_4C = v2;
3792 a1.field_50 = v731;
3793 a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
3794 a1.vPosition.y = pParty->vPosition.y;
3795 a1.vPosition.x = pParty->vPosition.x;
3796 a1.uAttributes = v1;
3797 a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
3798 a1.uSectorID = pIndoor->GetSector(
3799 pParty->vPosition.x,
3800 pParty->vPosition.y,
3801 pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
3802 a1.uSpriteFrameID = v1;
3803 v50 = 8 * v3->uPlayerID;
3804 LOBYTE(v50) = v50 | 4;
3805 a1.field_58 = v50;
3806 a1.field_5C = a2;
3807 a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
3808 a1.uFacing = LOWORD(v715.uYawAngle);
3809 a1.uSoundID = LOWORD(v3->field_10);
3810 if ( pParty->bTurnBasedModeOn == 1 )
3811 LOBYTE(a1.uAttributes) |= 4u;
3812 if ( v3->spellnum == 18 )
3813 LOBYTE(a1.uAttributes) |= 0x40u;
3814 goto LABEL_156;
3815 case 29:
3816 case 39:
3817 case 76:
3818 case 90:
3819 if ( !pPlayer->CanCastSpell(uRequiredMana) )
3820 goto LABEL_83;
3821 a1.stru_24.Reset();
3822 a1.field_48 = v3->spellnum;
3823 a1.field_4C = v2;
3824 a1.field_50 = v731;
3825 a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
3826 v51 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2;
3827 a1.vPosition.y = pParty->vPosition.y;
3828 v671 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2;
3829 v660 = pParty->vPosition.y;
3830 goto LABEL_153;
3831 case 87:
3832 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor
3833 || uCurrentlyLoadedLevelType == LEVEL_Outdoor && (pParty->uCurrentHour < 5 || pParty->uCurrentHour >= 0x15) )
3834 goto LABEL_200;
3835 if ( pPlayer->CanCastSpell(uRequiredMana) )
3836 goto LABEL_152;
3837 goto LABEL_83;
3838 case 81:
3839 if ( !pPlayer->CanCastSpell(uRequiredMana) )
3840 goto LABEL_83;
3841 if ( a2 == v1
3842 || (a2 & 7) != 3
3843 || (v730 = a2 >> 3,
3844 v721 = (int)&pActors[a2 >> 3],
3845 !stru_50C198.GetMagicalResistance(&pActors[a2 >> 3], 9u)) )
3846 goto LABEL_1056;
3847 Actor::_403EB6(v730, 4u, 0x80u, (AIDirection *)v1);
3848 v726 = (Player *)(23040 * v2);
3849 v54 = (signed __int64)((double)(23040 * v2) * 0.033333335);
3850 v55 = v721;
3851 ((SpellBuff *)(v721 + 308))->Apply(pParty->uTimePlayed + (signed int)v54, v731, v1, v1, v1);
3852 *(char *)(v55 + 38) |= 8u;
3853 *(short *)(v55 + 148) = v1;
3854 v672 = v1;
3855 *(short *)(v55 + 150) = v1;
3856 v661 = (Actor *)v55;
3857 goto LABEL_165;
3858 case 35:
3859 if ( v12 == 2 )
3860 {
3861 v57 = 300 * v2;
3862 }
3863 else
3864 {
3865 if ( v12 == 3 )
3866 {
3867 amount = 4;
3868 v57 = 300 * v2;
3869 goto LABEL_174;
3870 }
3871 if ( v12 == 4 )
3872 {
3873 v57 = 300 * v2;
3874 amount = 8;
3875 goto LABEL_174;
3876 }
3877 v57 = 180 * v2;
3878 }
3879 amount = 2;
3880 LABEL_174:
3881 LODWORD(v733) = v57;
3882 if ( !pPlayer->CanCastSpell(uRequiredMana) )
3883 goto LABEL_83;
3884 if ( (a2 & 7) != 3
3885 || (v721 = 836 * (a2 >> 3),
3886 LODWORD(v718) = (int)(char *)pActors + v721,
3887 !stru_50C198.GetMagicalResistance((Actor *)((char *)pActors + v721), 3u)) )
3888 goto LABEL_1056;
3889 v726 = (Player *)(23040 * v2);
3890 v58 = (signed __int64)((double)(23040 * v2) * 0.033333335);
3891 v59 = v721;
3892 ((SpellBuff *)((char *)&pActors[0].pActorBuffs[7] + v721))->Apply(
3893 pParty->uTimePlayed + (signed int)v58,
3894 v731,
3895 amount,
3896 v1,
3897 v1);
3898 *((char *)&pActors[0].uAttributes + v59 + 2) |= 8u;
3899 v672 = v1;
3900 v661 = (Actor *)LODWORD(v718);
3901 goto LABEL_165;
3902 case 60:
3903 if ( !pPlayer->CanCastSpell(uRequiredMana) )
3904 goto LABEL_83;
3905 v730 = 836 * (a2 >> 3);
3906 if ( !stru_50C198.GetMagicalResistance((Actor *)((char *)pActors + v730), 7u) )
3907 goto LABEL_1056;
3908 LODWORD(v733) = 300 * v2;
3909 if ( v731 == 2 )
3910 {
3911 LODWORD(v733) = 600 * v2;
3912 }
3913 else
3914 {
3915 if ( v731 == 3 )
3916 LODWORD(v733) = 29030400;
3917 }
3918 ((SpellBuff *)((char *)&pActors[0].pActorBuffs[9] + v730))->Reset();
3919 ((SpellBuff *)((char *)&pActors[0].pActorBuffs[12] + v730))->Reset();
3920 v726 = (Player *)((int)v733 << 7);
3921 ((SpellBuff *)((char *)&pActors[0].pActorBuffs[1] + v730))->Apply(
3922 pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335),
3923 v731,
3924 v1,
3925 v1,
3926 v1);
3927 a1.stru_24.Reset();
3928 a1.field_48 = v3->spellnum;
3929 a1.field_4C = v2;
3930 a1.field_50 = v731;
3931 v60 = pObjectList->ObjectIDByItemID(a1.uItemType);
3932 v61 = v730;
3933 goto LABEL_1086;
3934 case 92:
3935 if ( !pPlayer->CanCastSpell(uRequiredMana) )
3936 goto LABEL_83;
3937 a1.stru_24.Reset();
3938 a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
3939 a1.vPosition.x = pParty->vPosition.x;
3940 a1.vPosition.y = pParty->vPosition.y;
3941 a1.uAttributes = v1;
3942 a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
3943 a1.uSectorID = pIndoor->GetSector(
3944 pParty->vPosition.x,
3945 pParty->vPosition.y,
3946 pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
3947 a1.uSpriteFrameID = v1;
3948 v62 = 8 * v3->uPlayerID;
3949 LOBYTE(v62) = v62 | 4;
3950 a1.field_58 = v62;
3951 a1.field_5C = a2;
3952 a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
3953 a1.uFacing = LOWORD(v715.uYawAngle);
3954 a1.uSoundID = LOWORD(v3->field_10);
3955 a1.field_50 = v731;
3956 a1.field_48 = 3;
3957 a1.field_4C = 300 * v2;
3958 goto LABEL_154;
3959 case 4:
3960 v63 = v12 - 1;
3961 if ( !v63 )
3962 {
3963 amount = 10;
3964 goto LABEL_195;
3965 }
3966 v64 = v63 - 1;
3967 if ( !v64 )
3968 {
3969 amount = 11;
3970 goto LABEL_195;
3971 }
3972 v65 = v64 - 1;
3973 if ( !v65 )
3974 {
3975 amount = 12;
3976 LABEL_195:
3977 LODWORD(v733) = 3600 * v2;
3978 goto LABEL_196;
3979 }
3980 if ( v65 == 1 )
3981 {
3982 LODWORD(v733) = v1;
3983 amount = 12;
3984 }
3985 LABEL_196:
3986 if ( !pPlayer->CanCastSpell(uRequiredMana) )
3987 goto LABEL_83;
3988 v730 = (int)&pParty->pPlayers[v3->uPlayerID_2].pInventoryItems[a2];
3989 v726 = (Player *)&pItemsTable->pItems[*(int *)v730].pIconName;
3990 ((ItemGen *)v730)->UpdateTempBonus(pParty->uTimePlayed);
3991 if ( *(int *)v730 < 64 || *(int *)v730 > 65 )
3992 {
3993 if ( !(*(char *)(v730 + 20) & 2) )
3994 {
3995 if ( *(int *)(v730 + 12) == v1 )
3996 {
3997 if ( *(int *)(v730 + 4) == v1 )
3998 {
3999 v68 = BYTE4(v726->pConditions[3]);
4000 if ( !v68 || v68 == 1 || v68 == 2 )
4001 {
4002 if ( !pItemsTable->_456D5E_is_some_material((ItemGen *)v730) )
4003 {
4004 v69 = v730;
4005 v14 = v731 == 4;
4006 *(int *)(v730 + 12) = amount;
4007 if ( !v14 )
4008 {
4009 v726 = (Player *)((int)v733 << 7);
4010 *(_QWORD *)(v69 + 28) = pParty->uTimePlayed
4011 + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7)
4012 * 0.033333335);
4013 *(int *)(v69 + 20) |= 8u;
4014 }
4015 *(int *)(v69 + 20) |= 0x10u;
4016 LABEL_1055:
4017 dword_50C9A8 = 256;
4018 LABEL_1056:
4019 LODWORD(v727) = 1;
4020 LABEL_83:
4021 if ( v3->field_8 & 0x20 )
4022 {
4023 LABEL_1162:
4024 if ( v727 != 0.0 )
4025 pAudioPlayer->PlaySound(
4026 (SoundID)word_4EE088_sound_ids[v3->spellnum],
4027 0,
4028 0,
4029 -1,
4030 0,
4031 v3->field_10,
4032 0,
4033 0);
4034 }
4035 else
4036 {
4037 if ( sRecoveryTime < 0 )
4038 sRecoveryTime = 0;
4039 if ( pParty->bTurnBasedModeOn )
4040 {
4041 v645 = sRecoveryTime;
4042 pParty->pTurnBasedPlayerRecoveryTimes[v3->uPlayerID] = sRecoveryTime;
4043 pPlayer->SetRecoveryTime(v645);
4044 if ( !some_active_character )
4045 pTurnEngine->_40471C();
4046 }
4047 else
4048 {
4049 pPlayer->SetRecoveryTime(
4050 (signed __int64)(flt_6BE3A4_debug_recmod1 * (double)sRecoveryTime * 2.133333333333333));
4051 }
4052 if ( v727 != 0.0 )
4053 {
4054 pPlayer->PlaySound(49, 0);
4055 goto LABEL_1162;
4056 }
4057 }
4058 v3->spellnum = 0;
4059 v1 = 0;
4060 LABEL_1165:
4061 v2 = v723;
4062 goto LABEL_1166;
4063 }
4064 }
4065 }
4066 }
4067 }
4068 }
4069 LABEL_199:
4070 dword_50C9D0 = 113;
4071 dword_50C9D4 = v1;
4072 dword_50C9D8 = 1;
4073 LABEL_200:
4074 v66 = pGlobalTXT_LocalizationStrings[428];
4075 LABEL_201:
4076 v67 = 2;
4077 LABEL_202:
4078 ShowStatusBarString(v66, v67);
4079 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, v1, v1, -1, v1, v1, v1, v1);
4080 goto LABEL_203;
4081 case 71:
4082 v70 = v12 - 1;
4083 LODWORD(v733) = 3600 * v2;
4084 if ( v70 && (v71 = v70 - 1) != 0 )
4085 {
4086 v72 = v71 - 1;
4087 if ( v72 )
4088 {
4089 if ( v72 == 1 )
4090 amount = 10;
4091 }
4092 else
4093 {
4094 amount = 3;
4095 }
4096 }
4097 else
4098 {
4099 amount = 1;
4100 }
4101 if ( !pPlayer->CanCastSpell(uRequiredMana) )
4102 goto LABEL_83;
4103 v73 = v3->uPlayerID_2;
4104 v74 = v3->spellnum;
4105 v75 = pGame->GetStru6();
4106 pGame->GetStru6()->SetPlayerBuffAnim(v74, v73);
4107 v668 = v1;
4108 v658 = v1;
4109 v653 = amount;
4110 v651 = v731;
4111 v28 = pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)v733 * 4.2666669);
4112 v27 = (char *)&pParty->pPlayers[v3->uPlayerID_2].pPlayerBuffs[12];
4113 goto LABEL_103;
4114 case 3:
4115 case 14:
4116 case 25:
4117 case 36:
4118 case 58:
4119 case 69:
4120 v76 = v12 - 1;
4121 LODWORD(v733) = 3600 * v2;
4122 if ( v76 )
4123 {
4124 v77 = v76 - 1;
4125 if ( v77 )
4126 {
4127 v78 = v77 - 1;
4128 if ( v78 )
4129 {
4130 if ( v78 != 1 )
4131 goto LABEL_232;
4132 v79 = 4 * v2;
4133 }
4134 else
4135 {
4136 v79 = 3 * v2;
4137 }
4138 }
4139 else
4140 {
4141 v79 = 2 * v2;
4142 }
4143 amount = v79;
4144 }
4145 else
4146 {
4147 amount = v2;
4148 }
4149 LABEL_232:
4150 v80 = v3->spellnum;
4151 switch ( v80 )
4152 {
4153 case 3:
4154 LODWORD(v725) = 6;
4155 break;
4156 case 14:
4157 LODWORD(v725) = v1;
4158 break;
4159 case 25:
4160 LODWORD(v725) = 17;
4161 break;
4162 case 36:
4163 LODWORD(v725) = 4;
4164 break;
4165 case 58:
4166 LODWORD(v725) = 12;
4167 break;
4168 default:
4169 if ( v80 != 69 )
4170 goto LABEL_1166;
4171 LODWORD(v725) = 1;
4172 break;
4173 }
4174 if ( !pPlayer->CanCastSpell(uRequiredMana) )
4175 goto LABEL_83;
4176 v81 = v3->spellnum;
4177 v82 = pGame->GetStru6();
4178 pGame->GetStru6()->SetPlayerBuffAnim(v81, v1);
4179 v83 = 1;
4180 v84 = v3->spellnum;
4181 v85 = pGame->GetStru6();
4182 pGame->GetStru6()->SetPlayerBuffAnim(v84, 1u);
4183 v86 = v3->spellnum;
4184 v87 = pGame->GetStru6();
4185 pGame->GetStru6()->SetPlayerBuffAnim(v86, 2u);
4186 v88 = v3->spellnum;
4187 v89 = pGame->GetStru6();
4188 pGame->GetStru6()->SetPlayerBuffAnim(v88, 3u);
4189 v90 = (double)(signed int)v733 * 4.2666669;
4190 goto LABEL_304;
4191 case 5:
4192 if ( v12 <= v1 )
4193 goto LABEL_254;
4194 if ( v12 <= 2 )
4195 {
4196 v91 = 60 * (v2 + 60);
4197 }
4198 else
4199 {
4200 if ( v12 == 3 )
4201 {
4202 v91 = 180 * (v2 + 20);
4203 }
4204 else
4205 {
4206 if ( v12 != 4 )
4207 goto LABEL_254;
4208 v91 = 240 * (v2 + 15);
4209 }
4210 }
4211 LODWORD(v733) = v91;
4212 LABEL_254:
4213 if ( pPlayer->CanCastSpell(uRequiredMana) )
4214 {
4215 v92 = (char *)&pParty->pPlayers[0].pConditions[1];
4216 LODWORD(v727) = 1;
4217 do
4218 {
4219 if ( *(_QWORD *)v92 )
4220 LODWORD(v727) = v1;
4221 v92 += 6972;
4222 }
4223 while ( (signed int)v92 < (signed int)&pParty->pHirelings[0].uFlags );
4224 if ( LODWORD(v727) != v1 )
4225 {
4226 v726 = (Player *)((int)v733 << 7);
4227 pParty->pPartyBuffs[8].Apply(
4228 pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335),
4229 v731,
4230 v1,
4231 v1,
4232 v1);
4233 v93 = v3->spellnum;
4234 v94 = pGame->GetStru6();
4235 pGame->GetStru6()->SetPlayerBuffAnim(v93, v1);
4236 v95 = v3->spellnum;
4237 v96 = pGame->GetStru6();
4238 pGame->GetStru6()->SetPlayerBuffAnim(v95, 1u);
4239 v97 = v3->spellnum;
4240 v98 = pGame->GetStru6();
4241 pGame->GetStru6()->SetPlayerBuffAnim(v97, 2u);
4242 v99 = v3->spellnum;
4243 v100 = pGame->GetStru6();
4244 pGame->GetStru6()->SetPlayerBuffAnim(v99, 3u);
4245 }
4246 }
4247 goto LABEL_83;
4248 case 46:
4249 v101 = v12 - 1;
4250 if ( v101 && (v102 = v101 - 1) != 0 )
4251 {
4252 v103 = v102 - 1;
4253 if ( v103 )
4254 {
4255 if ( v103 != 1 )
4256 goto LABEL_269;
4257 v104 = 3600 * (v2 + 1);
4258 }
4259 else
4260 {
4261 v104 = 900 * (v2 + 4);
4262 }
4263 }
4264 else
4265 {
4266 v104 = 300 * (v2 + 12);
4267 }
4268 LODWORD(v733) = v104;
4269 LABEL_269:
4270 amount = v2 + 5;
4271 if ( !pPlayer->CanCastSpell(uRequiredMana) )
4272 goto LABEL_83;
4273 if ( v731 == 1 )
4274 {
4275 v108 = v3->uPlayerID_2;
4276 v109 = v3->spellnum;
4277 v110 = pGame->GetStru6();
4278 pGame->GetStru6()->SetPlayerBuffAnim(v109, v108);
4279 v111 = pOtherOverlayList->_4418B1(10000, v3->uPlayerID_2 + 310, v1, 65536);
4280 v668 = v1;
4281 v716 = v111;
4282 v658 = v111;
4283 v653 = amount;
4284 v726 = (Player *)((int)v733 << 7);
4285 v651 = 1;
4286 v28 = pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335);
4287 v27 = (char *)&pParty->pPlayers[v3->uPlayerID_2].pPlayerBuffs[1];
4288 goto LABEL_103;
4289 }
4290 v105 = 0;
4291 v726 = (Player *)((int)v733 << 7);
4292 v717 = (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335);
4293 v730 = (int)&pParty->pPlayers[0].pPlayerBuffs[1];
4294 do
4295 {
4296 v106 = v3->spellnum;
4297 v107 = pGame->GetStru6();
4298 pGame->GetStru6()->SetPlayerBuffAnim(v106, v105);
4299 v716 = pOtherOverlayList->_4418B1(10000, v105 + 310, v1, 65536);
4300 ((SpellBuff *)v730)->Apply(pParty->uTimePlayed + v717, v731, amount, v716, v1);
4301 v730 += 6972;
4302 ++v105;
4303 }
4304 while ( v730 < (signed int)&pParty->field_871C[468] );
4305 goto LABEL_1056;
4306 case 52:
4307 if ( pPlayer->CanCastSpell(uRequiredMana) && a2 != v1 && (a2 & 7) == 3 )
4308 {
4309 v730 = a2 >> 3;
4310 v112 = &pActors[a2 >> 3];
4311 v726 = (Player *)abs(v112->vPosition.z - pParty->vPosition.z);
4312 v721 = abs(v112->vPosition.y - pParty->vPosition.y);
4313 v113 = abs(v112->vPosition.x - pParty->vPosition.x);
4314 _this = (ItemGen *)v113;
4315 v114 = v721;
4316 v115 = (unsigned int)v726;
4317 if ( v113 < v721 )
4318 {
4319 v116 = v113;
4320 v113 = v721;
4321 v114 = v116;
4322 }
4323 if ( v113 < (signed int)v726 )
4324 {
4325 v117 = v113;
4326 v113 = (int)v726;
4327 v115 = v117;
4328 }
4329 if ( v114 < (signed int)v115 )
4330 {
4331 v118 = v115;
4332 v115 = v114;
4333 v114 = v118;
4334 }
4335 _this = (ItemGen *)(((unsigned int)(11 * v114) >> 5) + (v115 >> 2) + v113);
4336 if ( (double)(signed int)this <= 307.2 )
4337 {
4338 v703 = 0;
4339 v702 = 0;
4340 v701 = 0;
4341 a1.stru_24.Reset();
4342 v119 = HIDWORD(v733);
4343 a1.field_48 = *(int *)HIDWORD(v733);
4344 a1.field_4C = v723;
4345 a1.field_50 = v731;
4346 a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
4347 a1.uAttributes = 0;
4348 a1.uSectorID = 0;
4349 a1.uSpriteFrameID = 0;
4350 v120 = 8 * *(short *)(v119 + 2);
4351 LOBYTE(v120) = v120 | 4;
4352 a1.field_60_distance_related_prolly_lod = 0;
4353 a1.field_58 = v120;
4354 a1.uFacing = 0;
4355 a1.uSoundID = *(short *)(v119 + 16);
4356 a1.vPosition.x = v112->vPosition.x;
4357 a1.vPosition.y = v112->vPosition.y;
4358 v726 = (Player *)v112->uActorHeight;
4359 v121 = 8 * a2;
4360 a1.vPosition.z = v112->vPosition.z - (unsigned int)(signed __int64)((double)(signed int)v726 * unk_4D8548);
4361 LOBYTE(v121) = 8 * a2 | 3;
4362 a1.field_5C = v121;
4363 v122 = a1.Create(0, 0, 0, 0);
4364 DamageMonsterFromParty(8 * v122 | 2, v730, (Vec3_int_ *)&v701);
4365 LODWORD(v727) = 1;
4366 }
4367 else
4368 {
4369 ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2u);
4370 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
4371 *(int *)HIDWORD(v733) = 0;
4372 }
4373 v3 = (stru277 *)HIDWORD(v733);
4374 }
4375 goto LABEL_83;
4376 case 17:
4377 case 38:
4378 case 51:
4379 v123 = v12 - 1;
4380 if ( v123 && (v124 = v123 - 1) != 0 )
4381 {
4382 v125 = v124 - 1;
4383 if ( v125 )
4384 {
4385 if ( v125 != 1 )
4386 goto LABEL_296;
4387 v126 = 3600 * (v2 + 1);
4388 }
4389 else
4390 {
4391 v126 = 900 * (v2 + 4);
4392 }
4393 }
4394 else
4395 {
4396 v126 = 300 * (v2 + 12);
4397 }
4398 LODWORD(v733) = v126;
4399 LABEL_296:
4400 v127 = v3->spellnum;
4401 if ( v127 == 17 )
4402 {
4403 amount = v1;
4404 LODWORD(v725) = 14;
4405 }
4406 else
4407 {
4408 if ( v127 == 38 )
4409 {
4410 LODWORD(v725) = 15;
4411 amount = v2 + 5;
4412 }
4413 else
4414 {
4415 if ( v127 != 51 )
4416 goto LABEL_1166;
4417 LODWORD(v725) = 9;
4418 amount = v2 + 5;
4419 }
4420 }
4421 if ( !pPlayer->CanCastSpell(uRequiredMana) )
4422 goto LABEL_83;
4423 v128 = v3->spellnum;
4424 v129 = pGame->GetStru6();
4425 pGame->GetStru6()->SetPlayerBuffAnim(v128, v1);
4426 v83 = 1;
4427 v130 = v3->spellnum;
4428 v131 = pGame->GetStru6();
4429 pGame->GetStru6()->SetPlayerBuffAnim(v130, 1u);
4430 v132 = v3->spellnum;
4431 v133 = pGame->GetStru6();
4432 pGame->GetStru6()->SetPlayerBuffAnim(v132, 2u);
4433 v134 = v3->spellnum;
4434 v135 = pGame->GetStru6();
4435 pGame->GetStru6()->SetPlayerBuffAnim(v134, 3u);
4436 v726 = (Player *)((int)v733 << 7);
4437 v90 = (double)(signed int)((int)v733 << 7) * 0.033333335;
4438 LABEL_304:
4439 v673 = v1;
4440 v662 = v1;
4441 v655 = amount;
4442 v652 = v731;
4443 v136 = pParty->uTimePlayed + (signed int)(signed __int64)v90;
4444 v137 = (char *)&pParty->pPartyBuffs[LODWORD(v725)];
4445 goto LABEL_977;
4446 case 8:
4447 v138 = v12 - 2;
4448 if ( v138 && (v139 = v138 - 1) != 0 && v139 == 1 )
4449 v140 = 600 * v2;
4450 else
4451 v140 = 60 * v2;
4452 LODWORD(v733) = v140;
4453 if ( !pPlayer->CanCastSpell(uRequiredMana) )
4454 goto LABEL_83;
4455 v141 = v3->spellnum;
4456 v142 = pGame->GetStru6();
4457 pGame->GetStru6()->SetPlayerBuffAnim(v141, v1);
4458 v143 = v3->spellnum;
4459 v144 = pGame->GetStru6();
4460 pGame->GetStru6()->SetPlayerBuffAnim(v143, 1u);
4461 v145 = v3->spellnum;
4462 v146 = pGame->GetStru6();
4463 pGame->GetStru6()->SetPlayerBuffAnim(v145, 2u);
4464 v147 = v3->spellnum;
4465 v148 = pGame->GetStru6();
4466 pGame->GetStru6()->SetPlayerBuffAnim(v147, 3u);
4467 v668 = v1;
4468 v726 = (Player *)((int)v733 << 7);
4469 v658 = v1;
4470 v653 = v2;
4471 v651 = v731;
4472 v26 = (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335);
4473 v27 = (char *)&pParty->pPartyBuffs[10];
4474 goto LABEL_102;
4475 case 9:
4476 v149 = v12 - 1;
4477 if ( v149 && (v150 = v149 - 1) != 0 && (v151 = v150 - 1) != 0 )
4478 {
4479 if ( v151 == 1 )
4480 _this = (ItemGen *)20;
4481 }
4482 else
4483 {
4484 _this = (ItemGen *)16;
4485 }
4486 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
4487 {
4488 v66 = pGlobalTXT_LocalizationStrings[491];
4489 goto LABEL_201;
4490 }
4491 if ( !pPlayer->CanCastSpell(uRequiredMana) )
4492 goto LABEL_83;
4493 LODWORD(v725) = a2 & 7;
4494 if ( (a2 & 7) == 3 )
4495 {
4496 v152 = a2 >> 3;
4497 uRequiredMana = pActors[v152].vPosition.x;
4498 v153 = pActors[v152].vPosition.y;
4499 v154 = pActors[v152].vPosition.z;
4500 LODWORD(v727) = v153;
4501 }
4502 else
4503 {
4504 v155 = stru_5C6E00->SinCos(pParty->sRotationY);
4505 uRequiredMana = pParty->vPosition.x + sub_42EBBE(2048, v155);
4506 v156 = stru_5C6E00->_42EBDB(pParty->sRotationY);
4507 LODWORD(v727) = pParty->vPosition.y + sub_42EBBE(2048, v156);
4508 v154 = pParty->vPosition.z;
4509 }
4510 HIDWORD(v733) = v154;
4511 v713 = v154 + 2500;
4512 v721 = v1;
4513 LODWORD(v718) = v1;
4514 if ( (signed int)this > v1 )
4515 {
4516 *(float *)&y = (double)SHIDWORD(v733);
4517 *(float *)&v732 = (double)v713;
4518 v730 = LODWORD(v725) == 3 ? a2 : 0;
4519 v726 = (Player *)this;
4520 do
4521 {
4522 v157 = rand();
4523 v158 = (double)SLODWORD(v718);
4524 v718 = v158;
4525 v159 = (double)v721;
4526 *(float *)&v721 = v159;
4527 a2 = v157 % 1000;
4528 *((float *)&v733 + 1) = (double)(v157 % 1000) + *(float *)&y - *(float *)&v732;
4529 v725 = v159 * v159;
4530 *(float *)&_this = v158 * v158;
4531 if ( sqrt(*((float *)&v733 + 1) * *((float *)&v733 + 1) + *(float *)&_this + v725) <= 1.0 )
4532 {
4533 LODWORD(v687) = v1;
4534 HIDWORD(v687) = v1;
4535 }
4536 else
4537 {
4538 x = (signed __int64)sqrt(*(float *)&_this + v725);
4539 v687 = __PAIR__(
4540 stru_5C6E00->Atan2(x, (signed __int64)*((float *)&v733 + 1)),
4541 stru_5C6E00->Atan2((signed __int64)v718, (signed __int64)*(float *)&v721));
4542 }
4543 a1.stru_24.Reset();
4544 a1.field_48 = v3->spellnum;
4545 a1.field_4C = v2;
4546 a1.field_50 = v731;
4547 a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
4548 a1.uAttributes = v1;
4549 a1.vPosition.x = uRequiredMana;
4550 a1.vPosition.y = LODWORD(v727);
4551 a1.uSectorID = v1;
4552 a1.vPosition.z = a2 + v713;
4553 a1.uSpriteFrameID = v1;
4554 a1.field_58 = 8 * v3->uPlayerID | 4;
4555 a1.field_5C = v730;
4556 a1.field_60_distance_related_prolly_lod = stru_50C198._427546(a2 + 2500);
4557 a1.uFacing = v687;
4558 a1.uSoundID = LOWORD(v3->field_10);
4559 if ( pParty->bTurnBasedModeOn == 1 )
4560 a1.uAttributes = 4;
4561 if ( a1.Create(
4562 v687,
4563 SHIDWORD(v687),
4564 pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed,
4565 v1) != -1
4566 && pParty->bTurnBasedModeOn == 1 )
4567 ++pTurnEngine->field_1C;
4568 LODWORD(v718) = rand() % 1024 - 512;
4569 v160 = rand();
4570 v14 = v726 == (Player *)1;
4571 v726 = (Player *)((char *)v726 - 1);
4572 v721 = (unsigned __int64)(v160 % 1024) - 512;
4573 }
4574 while ( !v14 );
4575 }
4576 goto LABEL_1056;
4577 case 10:
4578 v67 = 2;
4579 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
4580 {
4581 v66 = pGlobalTXT_LocalizationStrings[492];
4582 goto LABEL_202;
4583 }
4584 if ( !pPlayer->CanCastSpell(uRequiredMana) )
4585 goto LABEL_83;
4586 v726 = (Player *)sub_46A6AC((int)dword_50BF30, 100, 4096);
4587 v700.z = v1;
4588 v700.y = v1;
4589 v700.x = v1;
4590 a1.stru_24.Reset();
4591 a1.field_48 = v3->spellnum;
4592 a1.field_4C = v2;
4593 a1.field_50 = v731;
4594 a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
4595 a1.uAttributes = v1;
4596 a1.uSectorID = v1;
4597 a1.uSpriteFrameID = v1;
4598 v161 = v3->uPlayerID;
4599 a1.field_60_distance_related_prolly_lod = 0;
4600 a1.uFacing = v1;
4601 v161 *= 8;
4602 LOBYTE(v161) = v161 | 4;
4603 a1.field_58 = v161;
4604 a1.uSoundID = LOWORD(v3->field_10);
4605 a2 = v1;
4606 if ( (signed int)v726 > v1 )
4607 {
4608 do
4609 {
4610 v162 = dword_50BF30[a2];
4611 a1.vPosition.x = pActors[v162].vPosition.x;
4612 a1.vPosition.y = pActors[v162].vPosition.y;
4613 v732 = pActors[v162].uActorHeight;
4614 a1.vPosition.z = pActors[v162].vPosition.z - (unsigned int)(signed __int64)((double)v732 * unk_4D8548);
4615 v163 = 8 * dword_50BF30[a2];
4616 LOBYTE(v163) = v163 | 3;
4617 a1.field_5C = v163;
4618 v164 = a1.Create(0, v1, v1, v1);
4619 v165 = a2;
4620 DamageMonsterFromParty(8 * v164 | AI_OBJECT_LAYING_ITEM, dword_50BF30[a2], &v700);
4621 v166 = pGame->GetStru6();
4622 v166->_4A81CA(&a1);
4623 v167 = pGame->GetStru6();
4624 v167->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xFF3C1Eu, 0x40u);
4625 a2 = v165 + 1;
4626 }
4627 while ( v165 + 1 < (signed int)v726 );
4628 }
4629 goto LABEL_1056;
4630 case 12:
4631 LODWORD(v733) = 3600 * v2;
4632 if ( !pPlayer->CanCastSpell(uRequiredMana) )
4633 goto LABEL_83;
4634 v168 = 0;
4635 do
4636 {
4637 v169 = pOtherOverlayList->_4418B1(2000, v168++ + 100, v1, 65536);
4638 v716 = v169;
4639 }
4640 while ( v168 < 4 );
4641 v668 = v1;
4642 v732 = (int)v733 << 7;
4643 v658 = v1;
4644 v653 = v1;
4645 v651 = v731;
4646 v28 = pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335);
4647 goto LABEL_992;
4648 case 13:
4649 v170 = v12 - 1;
4650 if ( !v170 )
4651 {
4652 v173 = 300 * v2;
4653 goto LABEL_353;
4654 }
4655 v171 = v170 - 1;
4656 if ( !v171 )
4657 {
4658 v173 = 600 * v2;
4659 goto LABEL_353;
4660 }
4661 v172 = v171 - 1;
4662 if ( !v172 || v172 == 1 )
4663 {
4664 v173 = 3600 * v2;
4665 LABEL_353:
4666 LODWORD(v733) = v173;
4667 }
4668 if ( !pPlayer->CanCastSpell(uRequiredMana) )
4669 goto LABEL_83;
4670 v174 = 0;
4671 do
4672 pOtherOverlayList->_4418B1(2010, v174++ + 100, v1, 65536);
4673 while ( v174 < 4 );
4674 v175 = v3->spellnum;
4675 v176 = pGame->GetStru6();
4676 pGame->GetStru6()->SetPlayerBuffAnim(v175, v1);
4677 v83 = 1;
4678 v177 = v3->spellnum;
4679 v178 = pGame->GetStru6();
4680 pGame->GetStru6()->SetPlayerBuffAnim(v177, 1u);
4681 v179 = v3->spellnum;
4682 v180 = pGame->GetStru6();
4683 pGame->GetStru6()->SetPlayerBuffAnim(v179, 2u);
4684 v181 = v3->spellnum;
4685 v182 = pGame->GetStru6();
4686 pGame->GetStru6()->SetPlayerBuffAnim(v181, 3u);
4687 v673 = v1;
4688 v732 = (int)v733 << 7;
4689 v662 = v1;
4690 v655 = v1;
4691 v652 = v731;
4692 v183 = (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335);
4693 v137 = (char *)&pParty->pPartyBuffs[5];
4694 goto LABEL_976;
4695 case 15:
4696 v184 = v12 - 1;
4697 if ( v184 )
4698 {
4699 v185 = v184 - 1;
4700 if ( v185 )
4701 {
4702 v186 = v185 - 1;
4703 if ( v186 )
4704 {
4705 if ( v186 == 1 )
4706 amount = 9;
4707 }
4708 else
4709 {
4710 amount = 7;
4711 }
4712 }
4713 else
4714 {
4715 amount = 5;
4716 }
4717 }
4718 else
4719 {
4720 amount = 3;
4721 }
4722 if ( !pPlayer->CanCastSpell(uRequiredMana) )
4723 goto LABEL_83;
4724 v726 = (Player *)((signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360);
4725 v732 = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360 / (amount - 1);
4726 a1.stru_24.Reset();
4727 a1.field_48 = v3->spellnum;
4728 a1.field_4C = v2;
4729 a1.field_50 = v731;
4730 a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
4731 a1.vPosition.y = pParty->vPosition.y;
4732 a1.vPosition.x = pParty->vPosition.x;
4733 a1.uAttributes = v1;
4734 a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
4735 a1.uSectorID = pIndoor->GetSector(
4736 pParty->vPosition.x,
4737 pParty->vPosition.y,
4738 pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
4739 a1.uSpriteFrameID = v1;
4740 v187 = 8 * v3->uPlayerID;
4741 LOBYTE(v187) = v187 | 4;
4742 a1.field_58 = v187;
4743 a1.field_5C = a2;
4744 a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
4745 a1.uSoundID = LOWORD(v3->field_10);
4746 if ( pParty->bTurnBasedModeOn == 1 )
4747 LOBYTE(a1.uAttributes) |= 4u;
4748 v188 = (signed int)v726 / -2;
4749 v189 = (signed int)v726 / 2;
4750 while ( v188 <= v189 )
4751 {
4752 a1.uFacing = v188 + LOWORD(v715.uYawAngle);
4753 if ( a1.Create(
4754 (signed __int16)(v188 + LOWORD(v715.uYawAngle)),
4755 v715.uPitchAngle,
4756 pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed,
4757 v3->uPlayerID + 1) != -1
4758 && pParty->bTurnBasedModeOn == 1 )
4759 ++pTurnEngine->field_1C;
4760 v188 += v732;
4761 }
4762 goto LABEL_1056;
4763 case 16:
4764 if ( pParty->uFlags & 8 )
4765 {
4766 v190 = pGlobalTXT_LocalizationStrings[493];
4767 goto LABEL_462;
4768 }
4769 if ( !pPlayer->CanCastSpell(uRequiredMana) )
4770 goto LABEL_83;
4771 v191 = 0;
4772 do
4773 pOtherOverlayList->_4418B1(2040, v191++ + 100, v1, 65536);
4774 while ( v191 < 4 );
4775 BYTE1(pParty->uFlags) |= 1u;
4776 pParty->uFallSpeed = 1000;
4777 goto LABEL_1056;
4778 case 19:
4779 v192 = v12 - 1;
4780 if ( !v192 )
4781 {
4782 amount = v2;
4783 goto LABEL_391;
4784 }
4785 v193 = v192 - 1;
4786 if ( !v193 )
4787 {
4788 v196 = 2 * v2;
4789 LABEL_389:
4790 amount = v196;
4791 LABEL_391:
4792 v195 = 600 * v2;
4793 goto LABEL_392;
4794 }
4795 v194 = v193 - 1;
4796 if ( !v194 )
4797 {
4798 v196 = 3 * v2;
4799 goto LABEL_389;
4800 }
4801 if ( v194 != 1 )
4802 goto LABEL_393;
4803 amount = 4 * v2;
4804 v195 = 3600 * v2;
4805 LABEL_392:
4806 LODWORD(v733) = v195;
4807 LABEL_393:
4808 if ( pParty->uFlags & 0x30 )
4809 {
4810 v66 = pGlobalTXT_LocalizationStrings[638];
4811 goto LABEL_201;
4812 }
4813 if ( pPlayer->CanCastSpell(uRequiredMana) )
4814 {
4815 v197 = v3->spellnum;
4816 v198 = pGame->GetStru6();
4817 pGame->GetStru6()->SetPlayerBuffAnim(v197, v1);
4818 v83 = 1;
4819 v199 = v3->spellnum;
4820 v200 = pGame->GetStru6();
4821 pGame->GetStru6()->SetPlayerBuffAnim(v199, 1u);
4822 v201 = v3->spellnum;
4823 v202 = pGame->GetStru6();
4824 pGame->GetStru6()->SetPlayerBuffAnim(v201, 2u);
4825 v203 = v3->spellnum;
4826 v204 = pGame->GetStru6();
4827 pGame->GetStru6()->SetPlayerBuffAnim(v203, 3u);
4828 v673 = v1;
4829 v732 = (int)v733 << 7;
4830 v662 = v1;
4831 v655 = amount;
4832 v652 = v731;
4833 v183 = (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335);
4834 v137 = (char *)&pParty->pPartyBuffs[11];
4835 LABEL_976:
4836 v136 = pParty->uTimePlayed + v183;
4837 LABEL_977:
4838 ((SpellBuff *)v137)->Apply(v136, v652, v655, v662, v673);
4839 LABEL_978:
4840 LODWORD(v727) = v83;
4841 }
4842 goto LABEL_83;
4843 case 21:
4844 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
4845 {
4846 v190 = pGlobalTXT_LocalizationStrings[494];
4847 LABEL_462:
4848 ShowStatusBarString(v190, 2u);
4849 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, v1, v1, -1, v1, v1, v1, v1);
4850 goto LABEL_83;
4851 }
4852 if ( !pPlayers[v3->uPlayerID + 1]->GetMaxMana() )
4853 {
4854 LABEL_461:
4855 v190 = pGlobalTXT_LocalizationStrings[428];
4856 goto LABEL_462;
4857 }
4858 LODWORD(v733) = 3600 * v2;
4859 if ( v731 == 2 || v731 == 3 || (amount = v1, v731 != 4) )
4860 amount = 1;
4861 if ( !pPlayer->CanCastSpell(uRequiredMana) )
4862 goto LABEL_83;
4863 v205 = 0;
4864 do
4865 pOtherOverlayList->_4418B1(2090, v205++ + 100, v1, 65536);
4866 while ( v205 < 4 );
4867 v206 = pOtherOverlayList->_4418B1(10008, 203, v1, 65536);
4868 v207 = v3->uPlayerID + 1;
4869 v716 = v206;
4870 v668 = v207;
4871 v658 = v206;
4872 v653 = amount;
4873 v732 = (int)v733 << 7;
4874 v651 = v731;
4875 v26 = (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335);
4876 v27 = (char *)&pParty->pPartyBuffs[7];
4877 LABEL_101:
4878 v26 = (signed int)v26;
4879 LABEL_102:
4880 v28 = pParty->uTimePlayed + v26;
4881 LABEL_103:
4882 HIDWORD(v650) = HIDWORD(v28);
4883 LABEL_104:
4884 LODWORD(v650) = v28;
4885 ((SpellBuff *)v27)->Apply(v650, v651, v653, v658, v668);
4886 goto LABEL_1056;
4887 case 22:
4888 v67 = 2;
4889 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
4890 {
4891 v66 = pGlobalTXT_LocalizationStrings[495];
4892 goto LABEL_202;
4893 }
4894 if ( !pPlayer->CanCastSpell(uRequiredMana) )
4895 goto LABEL_83;
4896 v208 = a2 & 7;
4897 LODWORD(v725) = a2 & 7;
4898 if ( v208 == 3 )
4899 {
4900 v209 = a2 >> 3;
4901 LODWORD(v718) = pActors[v209].vPosition.x;
4902 v210 = pActors[v209].vPosition.y;
4903 v211 = pActors[v209].vPosition.z;
4904 v713 = v210;
4905 }
4906 else
4907 {
4908 v212 = stru_5C6E00->SinCos(pParty->sRotationY);
4909 LODWORD(v718) = pParty->vPosition.x + sub_42EBBE(2048, v212);
4910 v213 = stru_5C6E00->_42EBDB(pParty->sRotationY);
4911 v214 = sub_42EBBE(2048, v213);
4912 v211 = pParty->vPosition.z;
4913 v713 = pParty->vPosition.y + v214;
4914 v208 = LODWORD(v725);
4915 }
4916 v726 = (Player *)v211;
4917 HIDWORD(v733) = v1;
4918 *(float *)&v732 = (double)v211;
4919 LODWORD(v725) = v211 + 2500;
4920 v721 = v1;
4921 *(float *)&y = (double)(v211 + 2500);
4922 v730 = v208 == 3 ? a2 : 0;
4923 a2 = 20;
4924 do
4925 {
4926 v215 = rand();
4927 v216 = (double)v721;
4928 v727 = v216;
4929 v217 = (double)SHIDWORD(v733);
4930 *(float *)&uRequiredMana = v217;
4931 _this = (ItemGen *)(v215 % 1000);
4932 *((float *)&v733 + 1) = (double)(v215 % 1000) + *(float *)&v732 - *(float *)&y;
4933 *(float *)&v721 = v217 * v217;
4934 *(float *)&v726 = v216 * v216;
4935 if ( sqrt(*((float *)&v733 + 1) * *((float *)&v733 + 1) + *(float *)&v726 + *(float *)&v721) <= 1.0 )
4936 {
4937 LODWORD(v685) = v1;
4938 HIDWORD(v685) = v1;
4939 }
4940 else
4941 {
4942 v684 = (signed __int64)sqrt(*(float *)&v726 + *(float *)&v721);
4943 v685 = __PAIR__(
4944 stru_5C6E00->Atan2(v684, (signed __int64)*((float *)&v733 + 1)),
4945 stru_5C6E00->Atan2((signed __int64)v727, (signed __int64)*(float *)&uRequiredMana));
4946 }
4947 a1.stru_24.Reset();
4948 a1.field_48 = v3->spellnum;
4949 a1.field_4C = v2;
4950 a1.field_50 = v731;
4951 a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
4952 a1.uAttributes = v1;
4953 a1.vPosition.x = LODWORD(v718);
4954 a1.vPosition.y = v713;
4955 a1.uSectorID = v1;
4956 a1.vPosition.z = (int)((char *)_this + LODWORD(v725));
4957 a1.uSpriteFrameID = v1;
4958 a1.field_58 = 8 * v3->uPlayerID | 4;
4959 a1.field_5C = v730;
4960 a1.field_60_distance_related_prolly_lod = stru_50C198._427546((int)&_this[69].uNumCharges);
4961 a1.uFacing = v685;
4962 a1.uSoundID = LOWORD(v3->field_10);
4963 if ( pParty->bTurnBasedModeOn == 1 )
4964 a1.uAttributes = 4;
4965 if ( a1.Create(
4966 v685,
4967 SHIDWORD(v685),
4968 pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed,
4969 v1) != -1
4970 && pParty->bTurnBasedModeOn == 1 )
4971 ++pTurnEngine->field_1C;
4972 v721 = rand() % 1024 - 512;
4973 v218 = rand();
4974 v14 = a2-- == 1;
4975 HIDWORD(v733) = (unsigned __int64)(v218 % 1024) - 512;
4976 }
4977 while ( !v14 );
4978 goto LABEL_1056;
4979 case 23:
4980 v219 = v12 - 2;
4981 if ( v219 )
4982 {
4983 v220 = v219 - 1;
4984 if ( v220 )
4985 {
4986 if ( v220 == 1 )
4987 {
4988 amount = v1;
4989 goto LABEL_433;
4990 }
4991 v221 = 180 * v2;
4992 }
4993 else
4994 {
4995 v221 = 86400 * v2;
4996 }
4997 }
4998 else
4999 {
5000 v221 = 3600 * v2;
5001 }
5002 amount = v221;
5003 LABEL_433:
5004 if ( !pPlayer->CanCastSpell(uRequiredMana) )
5005 goto LABEL_83;
5006 v222 = (char *)pParty->pPlayers;
5007 HIDWORD(v733) = (int)(char *)&pParty + 2508;
5008 break;
5009 case 24:
5010 v224 = v12 - 2;
5011 if ( v224 )
5012 {
5013 v225 = v224 - 1;
5014 if ( v225 )
5015 {
5016 if ( v225 == 1 )
5017 amount = 7;
5018 else
5019 amount = 1;
5020 }
5021 else
5022 {
5023 amount = 5;
5024 }
5025 }
5026 else
5027 {
5028 amount = 3;
5029 }
5030 if ( !pPlayer->CanCastSpell(uRequiredMana) )
5031 goto LABEL_83;
5032 HIDWORD(v733) = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360;
5033 if ( amount == 1 )
5034 {
5035 LABEL_152:
5036 a1.stru_24.Reset();
5037 a1.field_48 = v3->spellnum;
5038 a1.field_50 = v731;
5039 a1.field_4C = v2;
5040 a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
5041 a1.vPosition.y = pParty->vPosition.y;
5042 v51 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
5043 v671 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
5044 v660 = pParty->vPosition.y;
5045 LABEL_153:
5046 a1.uAttributes = v1;
5047 a1.vPosition.x = pParty->vPosition.x;
5048 a1.vPosition.z = v51;
5049 v52 = pIndoor->GetSector(pParty->vPosition.x, v660, v671);
5050 a1.uSpriteFrameID = v1;
5051 a1.uSectorID = v52;
5052 v53 = 8 * v3->uPlayerID;
5053 LOBYTE(v53) = v53 | 4;
5054 a1.field_58 = v53;
5055 a1.field_5C = a2;
5056 a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
5057 a1.uFacing = LOWORD(v715.uYawAngle);
5058 a1.uSoundID = LOWORD(v3->field_10);
5059 LABEL_154:
5060 if ( pParty->bTurnBasedModeOn == 1 )
5061 LOBYTE(a1.uAttributes) |= 4u;
5062 LABEL_156:
5063 v669 = v3->uPlayerID + 1;
5064 v36 = v715.uYawAngle;
5065 v659 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed;
5066 v654 = v715.uPitchAngle;
5067 LABEL_157:
5068 if ( a1.Create(v36, v654, v659, v669) != -1 && pParty->bTurnBasedModeOn == 1 )
5069 ++pTurnEngine->field_1C;
5070 }
5071 else
5072 {
5073 v732 = SHIDWORD(v733) / (amount - 1);
5074 a1.stru_24.Reset();
5075 a1.field_48 = v3->spellnum;
5076 a1.field_4C = v2;
5077 a1.field_50 = v731;
5078 a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
5079 a1.vPosition.y = pParty->vPosition.y;
5080 a1.vPosition.x = pParty->vPosition.x;
5081 a1.uAttributes = v1;
5082 a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
5083 a1.uSectorID = pIndoor->GetSector(
5084 pParty->vPosition.x,
5085 pParty->vPosition.y,
5086 pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
5087 a1.uSpriteFrameID = v1;
5088 v226 = 8 * v3->uPlayerID;
5089 LOBYTE(v226) = v226 | 4;
5090 a1.field_58 = v226;
5091 a1.field_5C = a2;
5092 a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
5093 a1.uSoundID = LOWORD(v3->field_10);
5094 if ( pParty->bTurnBasedModeOn == 1 )
5095 LOBYTE(a1.uAttributes) |= 4u;
5096 v227 = SHIDWORD(v733) / -2;
5097 y = (char *)(SHIDWORD(v733) / 2);
5098 if ( SHIDWORD(v733) / -2 <= SHIDWORD(v733) / 2 )
5099 {
5100 v228 = v715.uYawAngle;
5101 do
5102 {
5103 a1.uFacing = v227 + v228;
5104 if ( a1.Create(
5105 v227 + v228,
5106 v715.uPitchAngle,
5107 pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed,
5108 v3->uPlayerID + 1) != -1
5109 && pParty->bTurnBasedModeOn == 1 )
5110 ++pTurnEngine->field_1C;
5111 v227 += v732;
5112 }
5113 while ( v227 <= (signed int)y );
5114 }
5115 }
5116 goto LABEL_1056;
5117 case 27:
5118 if ( !pPlayers[v3->uPlayerID + 1]->GetMaxMana() )
5119 goto LABEL_461;
5120 if ( v731 == 2 || v731 != 3 && v731 != 4 )
5121 v229 = 600 * v2;
5122 else
5123 v229 = 3600 * v2;
5124 LODWORD(v733) = v229;
5125 if ( !pPlayer->CanCastSpell(uRequiredMana) )
5126 goto LABEL_83;
5127 v716 = pOtherOverlayList->_4418B1(10005, 201, v1, 65536);
5128 v230 = v3->spellnum;
5129 v231 = pGame->GetStru6();
5130 pGame->GetStru6()->SetPlayerBuffAnim(v230, v1);
5131 v232 = 1;
5132 v233 = v3->spellnum;
5133 v234 = pGame->GetStru6();
5134 pGame->GetStru6()->SetPlayerBuffAnim(v233, 1u);
5135 v235 = v3->spellnum;
5136 v236 = pGame->GetStru6();
5137 pGame->GetStru6()->SetPlayerBuffAnim(v235, 2u);
5138 v237 = v3->spellnum;
5139 v238 = pGame->GetStru6();
5140 pGame->GetStru6()->SetPlayerBuffAnim(v237, 3u);
5141 v239 = v3->uPlayerID + 1;
5142 v732 = v229 << 7;
5143 pParty->pPartyBuffs[18].Apply(
5144 pParty->uTimePlayed + (signed int)(signed __int64)((double)(v229 << 7) * 0.033333335),
5145 v731,
5146 amount,
5147 v716,
5148 v239);
5149 if ( v731 == 4 )
5150 pParty->pPartyBuffs[18].uFlags = 1;
5151 goto LABEL_1112;
5152 case 28:
5153 if ( !pPlayer->CanCastSpell(uRequiredMana) )
5154 goto LABEL_83;
5155 v240 = (char *)&pParty->pPlayers[v3->uPlayerID_2].pInventoryItems[a2];
5156 y = v240;
5157 if ( pItemsTable->pItems[*(int *)v240].uEquipType != 12 || v240[20] & 2 )
5158 goto LABEL_199;
5159 if ( v731 == 1 || v731 == 2 )
5160 {
5161 v241 = (double)v723 * 0.0099999998 + 0.5;
5162 }
5163 else
5164 {
5165 if ( v731 == 3 )
5166 {
5167 v241 = (double)v723 * 0.0099999998 + 0.69999999;
5168 }
5169 else
5170 {
5171 if ( v731 != 4 )
5172 {
5173 v241 = 0.0;
5174 goto LABEL_484;
5175 }
5176 v241 = (double)v723 * 0.0099999998 + 0.80000001;
5177 }
5178 }
5179 if ( v241 > 1.0 )
5180 v241 = 1.0;
5181 LABEL_484:
5182 v732 = (unsigned __int8)v240[25];
5183 v242 = (signed __int64)((double)v732 * v241);
5184 v243 = y;
5185 y[25] = v242;
5186 *((int *)v243 + 4) = (unsigned __int8)v242;
5187 if ( (unsigned __int8)v242 <= v1 )
5188 {
5189 *(int *)v243 = v1;
5190 dword_50C9D0 = 113;
5191 dword_50C9D4 = v1;
5192 dword_50C9D8 = 1;
5193 ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2u);
5194 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, v1, v1, -1, v1, v1, v1, v1);
5195 v3->spellnum = v1;
5196 goto LABEL_1165;
5197 }
5198 *((int *)v243 + 5) |= 0x40u;
5199 goto LABEL_1055;
5200 case 30:
5201 if ( !pPlayer->CanCastSpell(uRequiredMana) )
5202 goto LABEL_83;
5203 uRequiredMana = v1;
5204 HIDWORD(v733) = 10 * v2;
5205 v730 = 1;
5206 v244 = (char *)&pParty->pPlayers[v3->uPlayerID_2];
5207 v726 = &pParty->pPlayers[v3->uPlayerID_2];
5208 if ( v731 == 1 )
5209 {
5210 v245 = (int)&v244[36 * a2 + 532];
5211 v309 = (char *)&pItemsTable->pItems[*(int *)v245].pIconName;
5212 v311 = __OFSUB__(*(int *)v245, 134);
5213 v14 = *(int *)v245 == 134;
5214 v310 = *(int *)v245 - 134 < 0;
5215 LODWORD(v725) = (int)(char *)&pItemsTable + 48 * *(int *)v245 + 4;
5216 if ( (unsigned __int8)(v310 ^ v311) | v14 )
5217 {
5218 if ( *(int *)&v244[36 * a2 + 544] == v1 )
5219 {
5220 if ( *(int *)&v244[36 * a2 + 536] == v1 )
5221 {
5222 if ( *(int *)&v244[36 * a2 + 540] == v1 )
5223 {
5224 v312 = v309[28];
5225 if ( v312 )
5226 {
5227 if ( v312 != 1 )
5228 {
5229 if ( v312 != 2 )
5230 {
5231 _this = (ItemGen *)&v244[36 * a2 + 552];
5232 if ( !(v244[36 * a2 + 552] & 2) )
5233 {
5234 if ( ((ItemGen *)v245)->GetValue() < 0x1C2 )
5235 {
5236 uRequiredMana = 1;
5237 v730 = v1;
5238 }
5239 if ( rand() % 100 >= SHIDWORD(v733) )
5240 uRequiredMana = 1;
5241 if ( uRequiredMana == v1 )
5242 {
5243 v313 = *(char *)(LODWORD(v725) + 28);
5244 if ( v313 == 3 | v313 == 4 | v313 == 5 | v313 == 6 | v313 == 7 | v313 == 8 | v313 == 9 | v313 == 10 | v313 == 11 )
5245 {
5246 v314 = rand() % pItemsTable->field_116D8[pItemsTable->pItems[*(int *)v245].uEquipType];
5247 *(int *)(v245 + 4) = 0;
5248 for ( j = pItemsTable->pEnchantments[0].field_8[pItemsTable->pItems[*(int *)v245].uEquipType
5249 + 1];
5250 ;
5251 j += pItemsTable->pEnchantments[*(int *)(v245 + 4)].field_8[pItemsTable->pItems[*(int *)v245].uEquipType
5252 + 1] )
5253 {
5254 ++*(int *)(v245 + 4);
5255 if ( j >= v314 )
5256 break;
5257 }
5258 v254 = rand();
5259 v255 = pItemsTable->field_116D8[17];
5260 v256 = pItemsTable->field_116D8[16];
5261 LABEL_611:
5262 *(int *)(v245 + 8) = v256 + v254 % (v255 - v256 + 1);
5263 LABEL_612:
5264 _this->uItemID |= 0x20u;
5265 goto LABEL_1055;
5266 }
5267 goto LABEL_615;
5268 }
5269 LABEL_613:
5270 v316 = _this->uItemID;
5271 if ( !(BYTE1(v316) & 2) )
5272 {
5273 LOBYTE(v316) = v316 | 2;
5274 _this->uItemID = v316;
5275 }
5276 }
5277 }
5278 }
5279 }
5280 }
5281 }
5282 }
5283 }
5284 LABEL_616:
5285 if ( LODWORD(v727) == v1 )
5286 {
5287 v317 = pGlobalTXT_LocalizationStrings[428];
5288 if ( v730 == v1 )
5289 v317 = pGlobalTXT_LocalizationStrings[585];
5290 ShowStatusBarString(v317, 2u);
5291 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, v1, v1, -1, v1, v1, v1, v1);
5292 v318 = v726;
5293 v3->spellnum = v1;
5294 v318->PlaySound(43, v1);
5295 }
5296 goto LABEL_83;
5297 }
5298 if ( v731 != 2 )
5299 {
5300 if ( v731 == 3 )
5301 {
5302 v245 = (int)&v244[36 * a2 + 532];
5303 v269 = *(int *)v245;
5304 if ( *(int *)v245 > 134
5305 || *(int *)(v245 + 12) != v1
5306 || *(int *)(v245 + 4) != v1
5307 || *(int *)(v245 + 8) != v1
5308 || (_this = (ItemGen *)(v245 + 20), *(char *)(v245 + 20) & 2) )
5309 goto LABEL_616;
5310 v270 = (char *)&pItemsTable->pItems[v269].pIconName;
5311 LODWORD(v725) = (int)v270;
5312 v271 = v270[28];
5313 if ( v271 && v271 != 1 && v271 != 2 )
5314 v272 = ((ItemGen *)v245)->GetValue() < 0x1C2;
5315 else
5316 v272 = ((ItemGen *)v245)->GetValue() < 0xFA;
5317 if ( v272 )
5318 {
5319 uRequiredMana = 1;
5320 v730 = v1;
5321 }
5322 if ( rand() % 100 >= SHIDWORD(v733) )
5323 uRequiredMana = 1;
5324 if ( uRequiredMana != v1 )
5325 goto LABEL_613;
5326 v273 = v725;
5327 v274 = *(char *)(LODWORD(v725) + 28);
5328 if ( v274 == 0 | v274 == 1 | v274 == 2 | v274 == 3 | v274 == 4 | v274 == 5 | v274 == 6 | v274 == 7 | v274 == 8 | v274 == 9 | v274 == 10 | v274 == 11 )
5329 {
5330 if ( rand() % 100 < 80
5331 && !(*(char *)(LODWORD(v273) + 28) == 0 | *(char *)(LODWORD(v273) + 28) == 1 | *(char *)(LODWORD(v273) + 28) == 2) )
5332 {
5333 v275 = rand() % pItemsTable->field_116D8[pItemsTable->pItems[*(int *)v245].uEquipType];
5334 *(int *)(v245 + 4) = 0;
5335 for ( k = pItemsTable->pEnchantments[0].field_8[pItemsTable->pItems[*(int *)v245].uEquipType + 1];
5336 ;
5337 k += pItemsTable->pEnchantments[*(int *)(v245 + 4)].field_8[pItemsTable->pItems[*(int *)v245].uEquipType
5338 + 1] )
5339 {
5340 ++*(int *)(v245 + 4);
5341 if ( k >= v275 )
5342 break;
5343 }
5344 v254 = rand();
5345 v255 = pItemsTable->field_116D8[19];
5346 v256 = pItemsTable->field_116D8[18];
5347 goto LABEL_611;
5348 }
5349 v277 = pItemsTable->field_11798;
5350 v278 = 0;
5351 v725 = 0.0;
5352 HIDWORD(v733) = 0;
5353 if ( pItemsTable->field_11798 > 0 )
5354 {
5355 v730 = (int)&v679;
5356 do
5357 {
5358 v279 = LOBYTE(pItemsTable->pSpecialEnchantments[v278 + 1].pName);
5359 if ( !v279 || v279 == 1 )
5360 {
5361 v280 = *(&pItemsTable->pSpecialEnchantments[0].field_8[pItemsTable->pItems[*(int *)v245].uEquipType
5362 + 4]
5363 + v278 * 28);
5364 LODWORD(v725) += v280;
5365 if ( v280 )
5366 {
5367 v281 = v730;
5368 v730 += 4;
5369 *(int *)v281 = HIDWORD(v733);
5370 }
5371 }
5372 ++HIDWORD(v733);
5373 ++v278;
5374 }
5375 while ( SHIDWORD(v733) < v277 );
5376 }
5377 v282 = rand() % SLODWORD(v725);
5378 v283 = v679;
5379 *(int *)(v245 + 12) = v679;
5380 v284 = pItemsTable->pSpecialEnchantments[v283].field_8[pItemsTable->pItems[*(int *)v245].uEquipType + 4];
5381 v285 = v282 + 1;
5382 if ( v284 < v285 )
5383 {
5384 for ( l = &v679; ; l = (int *)v732 )
5385 {
5386 v287 = (int)(l + 1);
5387 v732 = v287;
5388 v288 = *(int *)v287;
5389 *(int *)(v245 + 12) = v288;
5390 v284 += pItemsTable->pSpecialEnchantments[v288].field_8[pItemsTable->pItems[*(int *)v245].uEquipType
5391 + 4];
5392 if ( v284 >= v285 )
5393 break;
5394 }
5395 }
5396 goto LABEL_525;
5397 }
5398 }
5399 else
5400 {
5401 if ( v731 != 4
5402 || (v245 = (int)&v726->pInventoryItems[a2], v246 = *(int *)v245, *(int *)v245 > 134)
5403 || v726->pInventoryItems[a2].uAdditionalValue != v1
5404 || v726->pInventoryItems[a2]._bonus_type != v1
5405 || v726->pInventoryItems[a2]._bonus_strength != v1
5406 || (_this = (ItemGen *)((char *)&v726->pInventoryItems[a2] + 20), v726->pInventoryItems[a2].uAttributes & 2) )
5407 goto LABEL_616;
5408 v247 = (char *)&pItemsTable->pItems[v246].pIconName;
5409 LODWORD(v725) = (int)v247;
5410 v248 = v247[28];
5411 if ( v248 && v248 != 1 && v248 != 2 )
5412 v249 = v726->pInventoryItems[a2].GetValue() < 0x1C2;
5413 else
5414 v249 = v726->pInventoryItems[a2].GetValue() < 0xFA;
5415 if ( v249 )
5416 {
5417 uRequiredMana = 1;
5418 v730 = v1;
5419 }
5420 if ( rand() % 100 >= SHIDWORD(v733) )
5421 uRequiredMana = 1;
5422 if ( uRequiredMana != v1 )
5423 goto LABEL_613;
5424 v250 = v725;
5425 v251 = *(char *)(LODWORD(v725) + 28);
5426 if ( v251 == 0 | v251 == 1 | v251 == 2 | v251 == 3 | v251 == 4 | v251 == 5 | v251 == 6 | v251 == 7 | v251 == 8 | v251 == 9 | v251 == 10 | v251 == 11 )
5427 {
5428 if ( rand() % 100 < 80
5429 && !(*(char *)(LODWORD(v250) + 28) == 0 | *(char *)(LODWORD(v250) + 28) == 1 | *(char *)(LODWORD(v250) + 28) == 2) )
5430 {
5431 v252 = rand() % pItemsTable->field_116D8[pItemsTable->pItems[*(int *)v245].uEquipType];
5432 *(int *)(v245 + 4) = 0;
5433 for ( m = pItemsTable->pEnchantments[0].field_8[pItemsTable->pItems[*(int *)v245].uEquipType + 1];
5434 ;
5435 m += pItemsTable->pEnchantments[*(int *)(v245 + 4)].field_8[pItemsTable->pItems[*(int *)v245].uEquipType
5436 + 1] )
5437 {
5438 ++*(int *)(v245 + 4);
5439 if ( m >= v252 )
5440 break;
5441 }
5442 v254 = rand();
5443 v255 = pItemsTable->field_116D8[21];
5444 v256 = pItemsTable->field_116D8[20];
5445 goto LABEL_611;
5446 }
5447 v257 = pItemsTable->field_11798;
5448 v258 = 0;
5449 v725 = 0.0;
5450 HIDWORD(v733) = 0;
5451 if ( pItemsTable->field_11798 > 0 )
5452 {
5453 v730 = (int)&v679;
5454 do
5455 {
5456 v259 = LOBYTE(pItemsTable->pSpecialEnchantments[v258 + 1].pName);
5457 if ( !v259 || v259 == 1 )
5458 {
5459 v260 = *(&pItemsTable->pSpecialEnchantments[0].field_8[pItemsTable->pItems[*(int *)v245].uEquipType
5460 + 4]
5461 + v258 * 28);
5462 LODWORD(v725) += v260;
5463 if ( v260 )
5464 {
5465 v261 = v730;
5466 v730 += 4;
5467 *(int *)v261 = HIDWORD(v733);
5468 }
5469 }
5470 ++HIDWORD(v733);
5471 ++v258;
5472 }
5473 while ( SHIDWORD(v733) < v257 );
5474 }
5475 v262 = rand() % SLODWORD(v725);
5476 v263 = v679;
5477 *(int *)(v245 + 12) = v679;
5478 v264 = pItemsTable->pSpecialEnchantments[v263].field_8[pItemsTable->pItems[*(int *)v245].uEquipType + 4];
5479 v265 = v262 + 1;
5480 if ( v264 < v265 )
5481 {
5482 for ( ii = &v679; ; ii = (int *)v732 )
5483 {
5484 v267 = (int)(ii + 1);
5485 v732 = v267;
5486 v268 = *(int *)v267;
5487 *(int *)(v245 + 12) = v268;
5488 v264 += pItemsTable->pSpecialEnchantments[v268].field_8[pItemsTable->pItems[*(int *)v245].uEquipType
5489 + 4];
5490 if ( v264 >= v265 )
5491 break;
5492 }
5493 }
5494 LABEL_525:
5495 ++*(int *)(v245 + 12);
5496 goto LABEL_612;
5497 }
5498 }
5499 LABEL_615:
5500 v1 = 0;
5501 goto LABEL_616;
5502 }
5503 v289 = (ItemGen *)&v244[36 * a2 + 532];
5504 _this = v289;
5505 v290 = v289->uItemID;
5506 LODWORD(v725) = (int)(char *)&pItemsTable + 48 * v290 + 4;
5507 if ( v290 > 134
5508 || _this->uAdditionalValue != v1
5509 || _this->_bonus_type != v1
5510 || _this->_bonus_strength != v1
5511 || (v291 = pItemsTable->pItems[v290].uEquipType) == 0
5512 || v291 == 1
5513 || v291 == 2
5514 || _this->uAttributes & 2 )
5515 goto LABEL_616;
5516 if ( _this->GetValue() < 0x1C2 )
5517 uRequiredMana = 1;
5518 if ( rand() % 100 >= SHIDWORD(v733) )
5519 uRequiredMana = 1;
5520 if ( uRequiredMana != v1 )
5521 goto LABEL_199;
5522 v292 = *(char *)(LODWORD(v725) + 28);
5523 if ( !(v292 == 3 | v292 == 4 | v292 == 5 | v292 == 6 | v292 == 7 | v292 == 8 | v292 == 9 | v292 == 10 | v292 == 11) )
5524 {
5525 v2 = v723;
5526 v1 = 0;
5527 goto LABEL_199;
5528 }
5529 if ( rand() % 100 >= 80 )
5530 {
5531 v297 = pItemsTable->field_11798;
5532 v294 = _this;
5533 v298 = 0;
5534 v725 = 0.0;
5535 HIDWORD(v733) = 0;
5536 if ( pItemsTable->field_11798 > 0 )
5537 {
5538 v730 = (int)&v679;
5539 do
5540 {
5541 v299 = LOBYTE(pItemsTable->pSpecialEnchantments[v298 + 1].pName);
5542 if ( !v299 || v299 == 1 )
5543 {
5544 v300 = *(&pItemsTable->pSpecialEnchantments[0].field_8[pItemsTable->pItems[v294->uItemID].uEquipType + 4]
5545 + v298 * 28);
5546 LODWORD(v725) += v300;
5547 if ( v300 )
5548 {
5549 v301 = v730;
5550 v730 += 4;
5551 *(int *)v301 = HIDWORD(v733);
5552 }
5553 }
5554 ++HIDWORD(v733);
5555 ++v298;
5556 }
5557 while ( SHIDWORD(v733) < v297 );
5558 }
5559 v302 = rand() % SLODWORD(v725);
5560 v303 = v679;
5561 v294->uAdditionalValue = v679;
5562 v304 = pItemsTable->pSpecialEnchantments[v303].field_8[pItemsTable->pItems[v294->uItemID].uEquipType + 4];
5563 v305 = v302 + 1;
5564 if ( v304 < v305 )
5565 {
5566 for ( jj = &v679; ; jj = (int *)v732 )
5567 {
5568 v307 = (int)(jj + 1);
5569 v732 = v307;
5570 v308 = *(int *)v307;
5571 v294->uAdditionalValue = v308;
5572 v304 += pItemsTable->pSpecialEnchantments[v308].field_8[pItemsTable->pItems[v294->uItemID].uEquipType + 4];
5573 if ( v304 >= v305 )
5574 break;
5575 }
5576 }
5577 ++v294->uAdditionalValue;
5578 }
5579 else
5580 {
5581 v293 = rand();
5582 v294 = _this;
5583 v295 = v293 % pItemsTable->field_116D8[pItemsTable->pItems[_this->uItemID].uEquipType];
5584 _this->_bonus_type = 0;
5585 for ( kk = pItemsTable->pEnchantments[0].field_8[pItemsTable->pItems[v294->uItemID].uEquipType + 1];
5586 ;
5587 kk += pItemsTable->pEnchantments[v294->_bonus_type].field_8[pItemsTable->pItems[v294->uItemID].uEquipType
5588 + 1] )
5589 {
5590 ++v294->_bonus_type;
5591 if ( kk >= v295 )
5592 break;
5593 }
5594 v294->_bonus_strength = pItemsTable->field_116D8[18]
5595 + rand() % (pItemsTable->field_116D8[19] - pItemsTable->field_116D8[18] + 1);
5596 }
5597 v294->uAttributes |= 0x20u;
5598 goto LABEL_1055;
5599 case 31:
5600 amount = 10 * v2;
5601 if ( pPlayer->sMana < (signed int)uRequiredMana )
5602 goto LABEL_83;
5603 if ( pParty->uFlags & 0x30 && v12 != 4 || rand() % 100 >= amount && v731 != 4 )
5604 goto LABEL_200;
5605 byte_50C0C0 = LOBYTE(v3->uPlayerID);
5606 pMessageQueue_50CBD0->SendMessage((UIMessageType)195, v1, v1);
5607 goto LABEL_1056;
5608 case 33:
5609 LODWORD(v733) = 604800 * v2;
5610 if ( !_strcmpi(pCurrentMapName, "d05.blv") )
5611 goto LABEL_200;
5612 v319 = uRequiredMana;
5613 if ( pPlayer->sMana >= (signed int)uRequiredMana )
5614 {
5615 pEventTimer->Pause();
5616 pMessageQueue_50CBD0->SendMessage((UIMessageType)177, v1, v1);
5617 qword_506350 = (signed int)v733;
5618 _506348_current_lloyd_playerid = v3->uPlayerID;
5619 ::uRequiredMana = v319;
5620 ::sRecoveryTime = sRecoveryTime;
5621 dword_50633C = v3->field_10;
5622 dword_506338 = v3->spellnum;
5623 LOBYTE(v3->field_8) |= 0x20u;
5624 }
5625 goto LABEL_83;
5626 case 40:
5627 v320 = v12 - 2;
5628 if ( !v320 )
5629 goto LABEL_632;
5630 v321 = v320 - 1;
5631 if ( v321 )
5632 {
5633 if ( v321 == 1 )
5634 goto LABEL_634;
5635 LABEL_632:
5636 v322 = 3600 * v2;
5637 }
5638 else
5639 {
5640 v322 = 86400 * v2;
5641 }
5642 amount = v322;
5643 LABEL_634:
5644 if ( !pPlayer->CanCastSpell(uRequiredMana) )
5645 goto LABEL_83;
5646 v323 = v3->uPlayerID_2;
5647 v324 = (char *)&pParty->pPlayers[v323].pConditions[15];
5648 if ( !pParty->pPlayers[v323].pConditions[15] )
5649 goto LABEL_1056;
5650 if ( v731 == 4 )
5651 goto LABEL_637;
5652 v732 = amount << 7;
5653 v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335);
5654 v656 = 15;
5655 goto LABEL_640;
5656 case 41:
5657 if ( !pPlayer->CanCastSpell(uRequiredMana) )
5658 goto LABEL_83;
5659 a1.stru_24.Reset();
5660 a1.field_48 = v3->spellnum;
5661 a1.field_4C = v2;
5662 a1.field_50 = v731;
5663 a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
5664 a1.vPosition.y = pParty->vPosition.y;
5665 a1.vPosition.x = pParty->vPosition.x;
5666 a1.uAttributes = v1;
5667 a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
5668 a1.uSectorID = pIndoor->GetSector(
5669 pParty->vPosition.x,
5670 pParty->vPosition.y,
5671 pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
5672 a1.uSpriteFrameID = v1;
5673 v326 = 8 * v3->uPlayerID;
5674 LOBYTE(v326) = v326 | 4;
5675 a1.field_58 = v326;
5676 a1.field_5C = a2;
5677 a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
5678 a1.uFacing = LOWORD(pParty->sRotationY);
5679 a1.uSoundID = LOWORD(v3->field_10);
5680 if ( pParty->bTurnBasedModeOn == 1 )
5681 LOBYTE(a1.uAttributes) |= 4u;
5682 v669 = v3->uPlayerID + 1;
5683 v659 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed;
5684 v654 = pParty->sRotationX;
5685 goto LABEL_125;
5686 case 43:
5687 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
5688 goto LABEL_200;
5689 if ( !pPlayer->CanCastSpell(uRequiredMana) )
5690 goto LABEL_83;
5691 a1.uItemType = 4090;
5692 a1.stru_24.Reset();
5693 a1.field_48 = v3->spellnum;
5694 a1.field_4C = v2;
5695 a1.field_50 = v731;
5696 a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
5697 a1.vPosition.x = pParty->vPosition.x;
5698 a1.vPosition.y = pParty->vPosition.y;
5699 a1.uAttributes = v1;
5700 a1.uSectorID = v1;
5701 a1.uSpriteFrameID = v1;
5702 a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
5703 v327 = 8 * v3->uPlayerID;
5704 LOBYTE(v327) = v327 | 4;
5705 a1.field_60_distance_related_prolly_lod = 0;
5706 a1.field_58 = v327;
5707 a1.field_5C = a2;
5708 a1.uFacing = LOWORD(pParty->sRotationY);
5709 a1.uSoundID = LOWORD(v3->field_10);
5710 if ( pParty->bTurnBasedModeOn == 1 )
5711 a1.uAttributes = 4;
5712 v669 = v1;
5713 v659 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed;
5714 v35 = (signed int)stru_5C6E00->uIntegerHalfPi / 2;
5715 LABEL_124:
5716 v654 = v35;
5717 LABEL_125:
5718 v36 = pParty->sRotationY;
5719 goto LABEL_157;
5720 case 45:
5721 v328 = v12 - 2;
5722 if ( v328 )
5723 {
5724 v329 = v328 - 1;
5725 if ( v329 && v329 != 1 )
5726 v330 = 600 * v2;
5727 else
5728 v330 = 3600 * v2;
5729 }
5730 else
5731 {
5732 v330 = 1800 * v2;
5733 }
5734 LODWORD(v733) = v330;
5735 if ( !pPlayer->CanCastSpell(uRequiredMana) )
5736 goto LABEL_83;
5737 v331 = v3->spellnum;
5738 v332 = pGame->GetStru6();
5739 pGame->GetStru6()->SetPlayerBuffAnim(v331, v1);
5740 v83 = 1;
5741 v333 = v3->spellnum;
5742 v334 = pGame->GetStru6();
5743 pGame->GetStru6()->SetPlayerBuffAnim(v333, 1u);
5744 v335 = v3->spellnum;
5745 v336 = pGame->GetStru6();
5746 pGame->GetStru6()->SetPlayerBuffAnim(v335, 2u);
5747 v337 = v3->spellnum;
5748 v338 = pGame->GetStru6();
5749 pGame->GetStru6()->SetPlayerBuffAnim(v337, 3u);
5750 v673 = v1;
5751 v732 = (int)v733 << 7;
5752 v662 = v1;
5753 v655 = v1;
5754 v652 = v731;
5755 v183 = (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335);
5756 v137 = (char *)&pParty->pPartyBuffs[3];
5757 goto LABEL_976;
5758 case 47:
5759 LODWORD(v733) = 300;
5760 v339 = v12 - 2;
5761 if ( v339 )
5762 {
5763 v340 = v339 - 1;
5764 if ( v340 )
5765 {
5766 if ( v340 != 1 )
5767 {
5768 amount = v2;
5769 goto LABEL_667;
5770 }
5771 v341 = 6 * v2;
5772 }
5773 else
5774 {
5775 v341 = 4 * v2;
5776 }
5777 }
5778 else
5779 {
5780 v341 = 2 * v2;
5781 }
5782 amount = v341;
5783 LABEL_667:
5784 if ( !pPlayer->CanCastSpell(uRequiredMana) )
5785 goto LABEL_83;
5786 v342 = *(int *)&v3->field_C;
5787 if ( v342 == v1 )
5788 {
5789 v345 = v3->uPlayerID_2;
5790 v346 = v3->spellnum;
5791 v347 = pGame->GetStru6();
5792 pGame->GetStru6()->SetPlayerBuffAnim(v346, v345);
5793 v668 = v1;
5794 v658 = v1;
5795 v653 = amount;
5796 LODWORD(v28) = LODWORD(pParty->uTimePlayed) + 1280;
5797 v651 = v731;
5798 HIDWORD(v650) = v1 + ((pParty->uTimePlayed + 1280) >> 32);
5799 v27 = (char *)&pParty->pPlayers[v3->uPlayerID_2].pPlayerBuffs[4];
5800 goto LABEL_104;
5801 }
5802 if ( (v342 & 7) == 3 )
5803 {
5804 v343 = v342 >> 3;
5805 HIDWORD(v344) = v1 + ((pParty->uTimePlayed + 1280) >> 32);
5806 LODWORD(v344) = LODWORD(pParty->uTimePlayed) + 1280;
5807 pActors[v343].pActorBuffs[11].Apply(v344, v731, amount, v1, v1);
5808 BYTE2(pActors[v343].uAttributes) |= 8u;
5809 v672 = v1;
5810 v661 = &pActors[v343];
5811 LABEL_165:
5812 v56 = pGame->GetStru6();
5813 pGame->GetStru6()->_4A7E89_sparkles_on_actor_after_it_casts_buff(v661, v672);
5814 }
5815 goto LABEL_1056;
5816 case 49:
5817 v348 = v12 - 2;
5818 if ( !v348 )
5819 goto LABEL_677;
5820 v349 = v348 - 1;
5821 if ( v349 )
5822 {
5823 if ( v349 == 1 )
5824 {
5825 amount = v1;
5826 goto LABEL_679;
5827 }
5828 LABEL_677:
5829 v350 = 3600 * v2;
5830 }
5831 else
5832 {
5833 v350 = 86400 * v2;
5834 }
5835 amount = v350;
5836 LABEL_679:
5837 if ( !pPlayer->CanCastSpell(uRequiredMana) )
5838 goto LABEL_83;
5839 v351 = &pParty->pPlayers[v3->uPlayerID_2];
5840 if ( !v351->pConditions[0] )
5841 goto LABEL_1056;
5842 if ( v731 == 4 )
5843 {
5844 LODWORD(v351->pConditions[0]) = v1;
5845 HIDWORD(v351->pConditions[0]) = v1;
5846 goto LABEL_904;
5847 }
5848 v732 = amount << 7;
5849 v351->DiscardConditionIfLastsLongerThan(
5850 v1,
5851 (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335));
5852 if ( HIDWORD(pParty->pPlayers[v3->uPlayerID_2].pConditions[0]) | LODWORD(pParty->pPlayers[v3->uPlayerID_2].pConditions[0]) )
5853 goto LABEL_1056;
5854 v674 = v3->uPlayerID_2;
5855 goto LABEL_685;
5856 case 50:
5857 v354 = v12 - 2;
5858 if ( v354 && (v355 = v354 - 1) != 0 && v355 == 1 )
5859 v356 = 900 * (v2 + 4);
5860 else
5861 v356 = 300 * (v2 + 12);
5862 LODWORD(v733) = v356;
5863 if ( !pPlayer->CanCastSpell(uRequiredMana) )
5864 goto LABEL_83;
5865 if ( v731 == 1 || v731 == 2 )
5866 {
5867 v361 = v3->uPlayerID_2;
5868 v362 = v3->spellnum;
5869 v363 = pGame->GetStru6();
5870 pGame->GetStru6()->SetPlayerBuffAnim(v362, v361);
5871 v668 = v1;
5872 v732 = (int)v733 << 7;
5873 v658 = v1;
5874 v653 = v1;
5875 v651 = v731;
5876 v28 = pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335);
5877 v27 = (char *)&pParty->pPlayers[v3->uPlayerID_2].pPlayerBuffs[11];
5878 goto LABEL_103;
5879 }
5880 a2 = v1;
5881 v732 = (int)v733 << 7;
5882 v717 = (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335);
5883 v357 = &pParty->pPlayers[0].pPlayerBuffs[11];
5884 do
5885 {
5886 v358 = a2;
5887 v359 = v3->spellnum;
5888 v360 = pGame->GetStru6();
5889 pGame->GetStru6()->SetPlayerBuffAnim(v359, v358);
5890 v357->Apply(pParty->uTimePlayed + v717, v731, v1, v1, v1);
5891 ++a2;
5892 v357 = (SpellBuff *)((char *)v357 + 6972);
5893 }
5894 while ( (signed int)v357 < (signed int)&pParty->field_871C[508] );
5895 goto LABEL_1056;
5896 case 48:
5897 v364 = v12 - 2;
5898 if ( !v364 || (v365 = v364 - 1) != 0 && v365 != 1 )
5899 v366 = 60 * (v2 + 3);
5900 else
5901 v366 = 300 * v2 + 180;
5902 LODWORD(v733) = v366;
5903 if ( !pPlayer->CanCastSpell(uRequiredMana) )
5904 goto LABEL_83;
5905 v726 = (Player *)sub_46A6AC((int)dword_50BF30, 100, 4096);
5906 v367 = pGame->GetStru6();
5907 pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xFFFFFFu, 0xC0u);
5908 ++a1.uItemType;
5909 a1.stru_24.Reset();
5910 a1.field_48 = v3->spellnum;
5911 a1.field_4C = v2;
5912 a1.field_50 = v731;
5913 a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
5914 a1.uAttributes = v1;
5915 a1.uSectorID = v1;
5916 a1.uSpriteFrameID = v1;
5917 v368 = v3->uPlayerID;
5918 a1.field_60_distance_related_prolly_lod = 0;
5919 a1.uFacing = v1;
5920 v368 *= 8;
5921 LOBYTE(v368) = v368 | 4;
5922 a1.field_58 = v368;
5923 a1.uSoundID = LOWORD(v3->field_10);
5924 for ( a2 = v1; a2 < (signed int)v726; ++a2 )
5925 {
5926 v369 = &pActors[dword_50BF30[a2]];
5927 if ( MonsterStats::BelongsToSupertype(v369->pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) )
5928 {
5929 a1.vPosition.x = v369->vPosition.x;
5930 a1.vPosition.y = v369->vPosition.y;
5931 v732 = v369->uActorHeight;
5932 a1.vPosition.z = v369->vPosition.z - (unsigned int)(signed __int64)((double)v732 * unk_4D8548);
5933 v370 = 8 * dword_50BF30[a2];
5934 LOBYTE(v370) = v370 | 3;
5935 a1.field_5C = v370;
5936 a1.Create(0, v1, v1, v1);
5937 v732 = (int)v733 << 7;
5938 v369->pActorBuffs[4].Apply(
5939 pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335),
5940 v731,
5941 v1,
5942 v1,
5943 v1);
5944 }
5945 }
5946 goto LABEL_1056;
5947 case 53:
5948 v371 = v12 - 2;
5949 if ( v371 && (v372 = v371 - 1) != 0 && v372 == 1 )
5950 amount = v1;
5951 else
5952 amount = 86400 * v2;
5953 if ( !pPlayer->CanCastSpell(uRequiredMana) )
5954 goto LABEL_83;
5955 pOtherOverlayList->_4418B1(5080, v3->uPlayerID_2 + 100, v1, 65536);
5956 v373 = v3->uPlayerID_2;
5957 if ( !(HIDWORD(pParty->pPlayers[v373].pConditions[14]) | LODWORD(pParty->pPlayers[v373].pConditions[14])) )
5958 goto LABEL_1056;
5959 v14 = v731 == 4;
5960 pParty->pPlayers[v373].sHealth = 1;
5961 if ( v14 )
5962 {
5963 v374 = v3->uPlayerID_2;
5964 v375 = (char *)pParty->pPlayers;
5965 LODWORD(pParty->pPlayers[v374].pConditions[14]) = v1;
5966 HIDWORD(pParty->pPlayers[v374].pConditions[14]) = v1;
5967 v376 = v3->uPlayerID_2;
5968 LODWORD(pParty->pPlayers[v376].pConditions[13]) = v1;
5969 HIDWORD(pParty->pPlayers[v376].pConditions[13]) = v1;
5970 }
5971 else
5972 {
5973 v732 = amount << 7;
5974 *(float *)&a2 = (double)(amount << 7) * 0.033333335;
5975 v375 = (char *)pParty->pPlayers;
5976 pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan(
5977 0xEu,
5978 (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2));
5979 pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan(
5980 0xDu,
5981 (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2));
5982 }
5983 v377 = (Player *)&v375[6972 * v3->uPlayerID_2];
5984 goto LABEL_720;
5985 case 54:
5986 v378 = v12 - 2;
5987 if ( v378 && (v379 = v378 - 1) != 0 && v379 == 1 )
5988 v380 = 4 * v2;
5989 else
5990 v380 = 3 * v2;
5991 amount = v380;
5992 if ( !pPlayer->CanCastSpell(uRequiredMana) )
5993 goto LABEL_83;
5994 v381 = 0;
5995 HIDWORD(v733) = amount;
5996 v730 = 0;
5997 v382 = 1;
5998 do
5999 {
6000 v383 = pPlayers[v382];
6001 if ( !v383->pConditions[14] && !v383->pConditions[15] && !v383->pConditions[16] )
6002 v682[v381++] = v382;
6003 ++v382;
6004 }
6005 while ( v382 <= 4 );
6006 v384 = 0;
6007 v730 = v381;
6008 if ( v381 > v1 )
6009 {
6010 do
6011 HIDWORD(v733) += pPlayers[v682[v384++]]->sHealth;
6012 while ( v384 < v381 );
6013 }
6014 v732 = (signed __int64)((double)SHIDWORD(v733) / (double)v730);
6015 HIDWORD(v733) = v1;
6016 if ( v381 > v1 )
6017 {
6018 do
6019 {
6020 v385 = 4 * v682[HIDWORD(v733)] + 10965188;
6021 pPlayers[v682[HIDWORD(v733)]]->sHealth = v732;
6022 v726 = *(Player **)v385;
6023 v386 = v726->GetMaxHealth();
6024 if ( v726->sHealth > v386 )
6025 *(int *)(*(int *)v385 + 6460) = v726->GetMaxHealth();
6026 v387 = *(Player **)v385;
6027 if ( v387->sHealth > v1 )
6028 {
6029 LODWORD(v387->pConditions[13]) = v1;
6030 HIDWORD(v387->pConditions[13]) = v1;
6031 }
6032 v388 = HIDWORD(v733);
6033 v389 = LOWORD(v682[HIDWORD(v733)]) - 1;
6034 v390 = v3->spellnum;
6035 v391 = pGame->GetStru6();
6036 pGame->GetStru6()->SetPlayerBuffAnim(v390, v389);
6037 HIDWORD(v733) = v388 + 1;
6038 }
6039 while ( v388 + 1 < v730 );
6040 }
6041 goto LABEL_1056;
6042 case 55:
6043 v392 = v12 - 1;
6044 if ( !v392 )
6045 {
6046 v395 = 180 * v2;
6047 goto LABEL_750;
6048 }
6049 v393 = v392 - 1;
6050 if ( !v393 )
6051 {
6052 v395 = 10800 * v2;
6053 goto LABEL_750;
6054 }
6055 v394 = v393 - 1;
6056 if ( !v394 )
6057 {
6058 v395 = 259200 * v2;
6059 LABEL_750:
6060 amount = v395;
6061 goto LABEL_751;
6062 }
6063 if ( v394 == 1 )
6064 amount = v1;
6065 LABEL_751:
6066 if ( !pPlayer->CanCastSpell(uRequiredMana) )
6067 goto LABEL_83;
6068 v396 = v3->uPlayerID_2;
6069 if ( HIDWORD(pParty->pPlayers[v396].pConditions[16]) | LODWORD(pParty->pPlayers[v396].pConditions[16])
6070 || HIDWORD(pParty->pPlayers[v396].pConditions[14]) | LODWORD(pParty->pPlayers[v396].pConditions[14]) )
6071 {
6072 if ( !(HIDWORD(pParty->pPlayers[v396].pConditions[1]) | LODWORD(pParty->pPlayers[v396].pConditions[1])) )
6073 pParty->pPlayers[v396].PlaySound(25, v1);
6074 if ( v731 == 4 )
6075 {
6076 v397 = v3->uPlayerID_2;
6077 LODWORD(pParty->pPlayers[v397].pConditions[16]) = v1;
6078 HIDWORD(pParty->pPlayers[v397].pConditions[16]) = v1;
6079 v398 = v3->uPlayerID_2;
6080 LODWORD(pParty->pPlayers[v398].pConditions[14]) = v1;
6081 HIDWORD(pParty->pPlayers[v398].pConditions[14]) = v1;
6082 v399 = v3->uPlayerID_2;
6083 LODWORD(pParty->pPlayers[v399].pConditions[13]) = v1;
6084 HIDWORD(pParty->pPlayers[v399].pConditions[13]) = v1;
6085 v400 = (char *)pParty->pPlayers;
6086 }
6087 else
6088 {
6089 v732 = amount << 7;
6090 *(float *)&a2 = (double)(amount << 7) * 0.033333335;
6091 v400 = (char *)pParty->pPlayers;
6092 pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan(
6093 0x10u,
6094 (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2));
6095 pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan(
6096 0xEu,
6097 (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2));
6098 pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan(
6099 0xDu,
6100 (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2));
6101 }
6102 v83 = 1;
6103 ((Player *)&v400[6972 * v3->uPlayerID_2])->SetCondition(1u, 1);
6104 v401 = pGame;
6105 pParty->pPlayers[v3->uPlayerID_2].sHealth = 1;
6106 v402 = v3->uPlayerID_2;
6107 v403 = v3->spellnum;
6108 v404 = pGame->GetStru6();
6109 pGame->GetStru6()->SetPlayerBuffAnim(v403, v402);
6110 }
6111 else
6112 {
6113 v83 = 1;
6114 }
6115 goto LABEL_978;
6116 case 61:
6117 v405 = v12 - 2;
6118 if ( !v405 )
6119 goto LABEL_766;
6120 v406 = v405 - 1;
6121 if ( v406 )
6122 {
6123 if ( v406 == 1 )
6124 {
6125 amount = v1;
6126 goto LABEL_768;
6127 }
6128 LABEL_766:
6129 v407 = 3600 * v2;
6130 }
6131 else
6132 {
6133 v407 = 86400 * v2;
6134 }
6135 amount = v407;
6136 LABEL_768:
6137 if ( !pPlayer->CanCastSpell(uRequiredMana) )
6138 goto LABEL_83;
6139 v408 = v3->uPlayerID_2;
6140 v409 = v3->spellnum;
6141 v410 = pGame->GetStru6();
6142 pGame->GetStru6()->SetPlayerBuffAnim(v409, v408);
6143 v323 = v3->uPlayerID_2;
6144 v324 = (char *)&pParty->pPlayers[v323].pConditions[12];
6145 if ( !pParty->pPlayers[v323].pConditions[12] )
6146 goto LABEL_1056;
6147 if ( v731 == 4 )
6148 goto LABEL_637;
6149 v732 = amount << 7;
6150 v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335);
6151 v656 = 12;
6152 goto LABEL_640;
6153 case 56:
6154 v411 = v12 - 2;
6155 if ( v411 )
6156 {
6157 v412 = v411 - 1;
6158 if ( v412 )
6159 {
6160 if ( v412 == 1 )
6161 {
6162 amount = v1;
6163 goto LABEL_780;
6164 }
6165 v413 = 180 * v2;
6166 }
6167 else
6168 {
6169 v413 = 86400 * v2;
6170 }
6171 }
6172 else
6173 {
6174 v413 = 3600 * v2;
6175 }
6176 amount = v413;
6177 LABEL_780:
6178 if ( !pPlayer->CanCastSpell(uRequiredMana) )
6179 goto LABEL_83;
6180 v414 = v3->uPlayerID_2;
6181 v415 = v3->spellnum;
6182 v416 = pGame->GetStru6();
6183 pGame->GetStru6()->SetPlayerBuffAnim(v415, v414);
6184 v323 = v3->uPlayerID_2;
6185 v324 = (char *)&pParty->pPlayers[v323].pConditions[3];
6186 if ( !pParty->pPlayers[v323].pConditions[3] )
6187 goto LABEL_1056;
6188 if ( v731 == 4 )
6189 goto LABEL_637;
6190 v732 = amount << 7;
6191 v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335);
6192 v656 = 3;
6193 goto LABEL_640;
6194 case 59:
6195 if ( !pPlayer->CanCastSpell(uRequiredMana) )
6196 goto LABEL_83;
6197 if ( a2 == v1 || (a2 & 7) != 3 )
6198 goto LABEL_1056;
6199 v417 = (int)&pActors[a2 >> 3];
6200 v730 = v417;
6201 if ( !(*(char *)(v417 + 38) & 0x80) )
6202 {
6203 ((Actor *)v417)->SetRandomGoldIfTheresNoItem();
6204 v417 = v730;
6205 }
6206 v418 = *(int *)(v417 + 672);
6207 HIDWORD(v733) = v1;
6208 if ( pItemsTable->pItems[v418].uEquipType == 18 )
6209 HIDWORD(v733) = *(int *)(v417 + 684);
6210
6211 //ItemGen::ItemGen(&v683);
6212 v683.Reset();
6213
6214 v419 = *(short *)(v730 + 180);
6215 if ( v419 != (short)v1 )
6216 {
6217 v683.uItemID = v419;
6218 goto LABEL_799;
6219 }
6220 v420 = 0;
6221 v421 = v730 + 564;
6222 while ( *(int *)v421 == v1 || pItemsTable->pItems[*(int *)v421].uEquipType == 18 )
6223 {
6224 ++v420;
6225 v421 += 36;
6226 if ( v420 >= 4 )
6227 goto LABEL_799;
6228 }
6229 memcpy(&v683, (const void *)(v730 + 36 * v420 + 564), sizeof(v683));
6230 v2 = v723;
6231 v1 = 0;
6232 LABEL_799:
6233 if ( HIDWORD(v733) != v1 )
6234 {
6235 v675 = (const char *)HIDWORD(v733);
6236 if ( v683.uItemID != v1 )
6237 {
6238 v422 = v683.GetDisplayName();
6239 sprintf(pTmpBuf2, "(%s), and %d gold", v422, v675);
6240 goto LABEL_807;
6241 }
6242 v664 = "%d gold";
6243 goto LABEL_803;
6244 }
6245 if ( v683.uItemID != v1 )
6246 {
6247 v675 = v683.GetDisplayName();
6248 v664 = "(%s)";
6249 LABEL_803:
6250 sprintf(pTmpBuf2, v664, v675);
6251 goto LABEL_807;
6252 }
6253 strcpy(pTmpBuf2, "nothing");
6254 LABEL_807:
6255 ShowStatusBarString(pTmpBuf2, 2u);
6256 a1.stru_24.Reset();
6257 a1.field_48 = v3->spellnum;
6258 a1.field_4C = v2;
6259 a1.field_50 = v731;
6260 a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
6261 a1.vPosition.x = *(short *)(v730 + 142);
6262 a1.vPosition.y = *(short *)(v730 + 144);
6263 v676 = *(short *)(v730 + 138);
6264 v665 = a1.vPosition.y;
6265 a1.vPosition.z = *(short *)(v730 + 138);
6266 v657 = a1.vPosition.x;
6267 goto LABEL_1087;
6268 case 62:
6269 v423 = v12 - 2;
6270 if ( !v423 )
6271 goto LABEL_813;
6272 v424 = v423 - 1;
6273 if ( v424 )
6274 {
6275 if ( v424 == 1 )
6276 v425 = 3600 * v2;
6277 else
6278 LABEL_813:
6279 v425 = 300 * v2;
6280 }
6281 else
6282 {
6283 v425 = 600 * v2;
6284 }
6285 amount = v425;
6286 if ( !pPlayer->CanCastSpell(uRequiredMana) )
6287 goto LABEL_83;
6288 v426 = a2 >> 3;
6289 if ( (a2 & 7) != 3 )
6290 goto LABEL_1056;
6291 v730 = 836 * v426;
6292 if ( stru_50C198.GetMagicalResistance(&pActors[v426], 7u) )
6293 {
6294 ((SpellBuff *)((char *)&pActors[0].pActorBuffs[1] + v730))->Reset();
6295 ((SpellBuff *)((char *)&pActors[0].pActorBuffs[12] + v730))->Reset();
6296 v732 = amount << 7;
6297 ((SpellBuff *)((char *)&pActors[0].pActorBuffs[9] + v730))->Apply(
6298 pParty->uTimePlayed + (signed __int64)((double)(amount << 7) * 0.033333335),
6299 v731,
6300 v1,
6301 v1,
6302 v1);
6303 *(&pActors[0].pMonsterInfo.uHostilityType + v730) = MonsterInfo::Hostility_Long;
6304 }
6305 a1.stru_24.Reset();
6306 a1.field_48 = v3->spellnum;
6307 a1.field_4C = v2;
6308 a1.field_50 = v731;
6309 v60 = pObjectList->ObjectIDByItemID(a1.uItemType);
6310 v61 = v730;
6311 goto LABEL_1086;
6312 case 66:
6313 if ( !pPlayer->CanCastSpell(uRequiredMana) )
6314 goto LABEL_83;
6315 amount = 600 * v2;
6316 v427 = a2 >> 3;
6317 if ( (a2 & 7) != 3 )
6318 goto LABEL_1056;
6319 v730 = 836 * v427;
6320 if ( MonsterStats::BelongsToSupertype(pActors[v427].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) )
6321 goto LABEL_83;
6322 if ( stru_50C198.GetMagicalResistance((Actor *)((char *)pActors + v730), 7u) )
6323 {
6324 ((SpellBuff *)((char *)&pActors[0].pActorBuffs[9] + v730))->Reset();
6325 ((SpellBuff *)((char *)&pActors[0].pActorBuffs[1] + v730))->Reset();
6326 v732 = amount << 7;
6327 ((SpellBuff *)((char *)&pActors[0].pActorBuffs[12] + v730))->Apply(
6328 pParty->uTimePlayed + (signed __int64)((double)(amount << 7) * 0.033333335),
6329 v731,
6330 v1,
6331 v1,
6332 v1);
6333 }
6334 a1.stru_24.Reset();
6335 a1.field_48 = v3->spellnum;
6336 a1.field_4C = v2;
6337 a1.field_50 = v731;
6338 v60 = pObjectList->ObjectIDByItemID(a1.uItemType);
6339 v61 = v730;
6340 goto LABEL_1086;
6341 case 63:
6342 v428 = v12 - 2;
6343 if ( v428 && (v429 = v428 - 1) != 0 && v429 == 1 )
6344 v430 = 300 * v2;
6345 else
6346 v430 = 180 * v2;
6347 amount = v430;
6348 if ( !pPlayer->CanCastSpell(uRequiredMana) )
6349 goto LABEL_83;
6350 v726 = (Player *)sub_46A6AC((int)dword_50BF30, 100, 4096);
6351 v431 = pGame->GetStru6();
6352 pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xA0A0Au, 0xC0u);
6353 ++a1.uItemType;
6354 a1.stru_24.Reset();
6355 a1.field_48 = v3->spellnum;
6356 a1.field_4C = v2;
6357 a1.field_50 = v731;
6358 a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
6359 a1.uAttributes = v1;
6360 a1.uSectorID = v1;
6361 a1.uSpriteFrameID = v1;
6362 v432 = v3->uPlayerID;
6363 a1.field_60_distance_related_prolly_lod = 0;
6364 a1.uFacing = v1;
6365 v432 *= 8;
6366 LOBYTE(v432) = v432 | 4;
6367 a1.field_58 = v432;
6368 a1.uSoundID = LOWORD(v3->field_10);
6369 for ( a2 = v1; a2 < (signed int)v726; ++a2 )
6370 {
6371 v433 = &pActors[dword_50BF30[a2]];
6372 if ( MonsterStats::BelongsToSupertype(v433->pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) )
6373 break;
6374 a1.vPosition.x = v433->vPosition.x;
6375 a1.vPosition.y = v433->vPosition.y;
6376 v732 = v433->uActorHeight;
6377 a1.vPosition.z = v433->vPosition.z - (unsigned int)(signed __int64)((double)v732 * unk_4D8548);
6378 v434 = 8 * dword_50BF30[a2];
6379 LOBYTE(v434) = v434 | 3;
6380 a1.field_5C = v434;
6381 a1.Create(0, v1, v1, v1);
6382 if ( stru_50C198.GetMagicalResistance(v433, 7u) )
6383 {
6384 v732 = amount << 7;
6385 v433->pActorBuffs[4].Apply(
6386 pParty->uTimePlayed + (signed __int64)((double)(amount << 7) * 0.033333335),
6387 v731,
6388 v1,
6389 v1,
6390 v1);
6391 }
6392 }
6393 goto LABEL_1056;
6394 case 64:
6395 v435 = v12 - 2;
6396 if ( v435 && (v436 = v435 - 1) != 0 && v436 == 1 )
6397 amount = v1;
6398 else
6399 amount = 86400 * v2;
6400 if ( !pPlayer->CanCastSpell(uRequiredMana) )
6401 goto LABEL_83;
6402 v437 = v3->uPlayerID_2;
6403 v438 = v3->spellnum;
6404 v439 = pGame->GetStru6();
6405 pGame->GetStru6()->SetPlayerBuffAnim(v438, v437);
6406 v440 = v3->uPlayerID_2;
6407 if ( HIDWORD(pParty->pPlayers[v440].pConditions[5]) | LODWORD(pParty->pPlayers[v440].pConditions[5]) )
6408 {
6409 if ( !(HIDWORD(pParty->pPlayers[v440].pConditions[1]) | LODWORD(pParty->pPlayers[v440].pConditions[1])) )
6410 pParty->pPlayers[v440].PlaySound(25, v1);
6411 if ( v731 == 4 )
6412 {
6413 v441 = v3->uPlayerID_2;
6414 LODWORD(pParty->pPlayers[v441].pConditions[5]) = v1;
6415 HIDWORD(pParty->pPlayers[v441].pConditions[5]) = v1;
6416 }
6417 else
6418 {
6419 v732 = amount << 7;
6420 pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan(
6421 5u,
6422 (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335));
6423 }
6424 v377 = &pParty->pPlayers[v3->uPlayerID_2];
6425 LABEL_720:
6426 v377->SetCondition(1u, v1);
6427 }
6428 goto LABEL_1056;
6429 case 42:
6430 v442 = v12 - 2;
6431 if ( !v442 )
6432 goto LABEL_855;
6433 v443 = v442 - 1;
6434 if ( v443 )
6435 {
6436 if ( v443 == 1 )
6437 v444 = 4 * v2;
6438 else
6439 LABEL_855:
6440 v444 = 2 * v2;
6441 }
6442 else
6443 {
6444 v444 = 3 * v2;
6445 }
6446 amount = v444;
6447 if ( !pPlayer->CanCastSpell(uRequiredMana) )
6448 goto LABEL_83;
6449 v445 = a2 >> 3;
6450 if ( (a2 & 7) == 2 )
6451 {
6452 v449 = (char *)&pLayingItems[v445].stru_24;
6453 v450 = *(int *)v449;
6454 if ( pItemsTable->pItems[v450].uEquipType == 18 )
6455 {
6456 party_finds_gold(*((int *)v449 + 3), 0);
6457 viewparams->bRedrawGameUI = 1;
6458 }
6459 else
6460 {
6461 sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[471], pItemsTable->pItems[v450].pUnidentifiedName);
6462 ShowStatusBarString(pTmpBuf2, 2u);
6463 if ( !pParty->AddItem(&pLayingItems[v445].stru_24) )
6464 pParty->SetHoldingItem(&pLayingItems[v445].stru_24);
6465 }
6466 LayingItem::_42F933(v445);
6467 }
6468 else
6469 {
6470 if ( (a2 & 7) == 3 )
6471 {
6472 stru_50C198.LootActor(&pActors[v445]);
6473 }
6474 else
6475 {
6476 if ( (a2 & 7) != 5 )
6477 {
6478 if ( (a2 & 7) != 6 )
6479 goto LABEL_1056;
6480 dword_507CD8 = 1;
6481 v677 = 1;
6482 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
6483 v446 = pIndoor->pFaceExtras[pIndoor->pFaces[v445].uFaceExtraID].uEventID;
6484 else
6485 v446 = pOutdoor->pBModels[a2 >> 9].pFaces[v445 & 0x3F].sCogTriggeredID;
6486 goto LABEL_866;
6487 }
6488 v447 = &pLevelDecorations[v445];
6489 dword_507CD8 = 1;
6490 v448 = v447->field_16_event_id;
6491 if ( v448 != (short)v1 )
6492 {
6493 v677 = 1;
6494 v446 = v448;
6495 LABEL_866:
6496 EventProcessor(v446, a2, v677);
6497 goto LABEL_1056;
6498 }
6499 if ( v447->IsInteractive() )
6500 {
6501 _5C3420_pDecoration = v447;
6502 EventProcessor(stru_5E4C90._decor_events[v447->_idx_in_stru123 - 75] + 380, 0, 1);
6503 _5C3420_pDecoration = (LevelDecoration *)v1;
6504 }
6505 }
6506 }
6507 goto LABEL_1056;
6508 case 67:
6509 v451 = v12 - 2;
6510 if ( v451 )
6511 {
6512 v452 = v451 - 1;
6513 if ( v452 )
6514 {
6515 if ( v452 == 1 )
6516 {
6517 amount = v1;
6518 goto LABEL_883;
6519 }
6520 v453 = 180 * v2;
6521 }
6522 else
6523 {
6524 v453 = 86400 * v2;
6525 }
6526 }
6527 else
6528 {
6529 v453 = 3600 * v2;
6530 }
6531 amount = v453;
6532 LABEL_883:
6533 if ( !pPlayer->CanCastSpell(uRequiredMana) )
6534 goto LABEL_83;
6535 v454 = v3->uPlayerID_2;
6536 v455 = v3->spellnum;
6537 v456 = pGame->GetStru6();
6538 pGame->GetStru6()->SetPlayerBuffAnim(v455, v454);
6539 v323 = v3->uPlayerID_2;
6540 v324 = (char *)&pParty->pPlayers[v323].pConditions[1];
6541 if ( !pParty->pPlayers[v323].pConditions[1] )
6542 goto LABEL_1056;
6543 if ( v731 == 4 )
6544 {
6545 LABEL_637:
6546 *(int *)v324 = v1;
6547 *((int *)v324 + 1) = v1;
6548 goto LABEL_1056;
6549 }
6550 v732 = amount << 7;
6551 v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335);
6552 v656 = 1;
6553 LABEL_640:
6554 v325 = &pParty->pPlayers[v323];
6555 goto LABEL_641;
6556 case 68:
6557 v457 = v12 - 2;
6558 if ( v457 )
6559 {
6560 v458 = v457 - 1;
6561 if ( v458 )
6562 {
6563 if ( v458 == 1 )
6564 v459 = 5 * v2 + 5;
6565 else
6566 v459 = 2 * v2 + 5;
6567 }
6568 else
6569 {
6570 v459 = 4 * v2 + 5;
6571 }
6572 }
6573 else
6574 {
6575 v459 = 3 * v2 + 5;
6576 }
6577 amount = v459;
6578 if ( !pPlayer->CanCastSpell(uRequiredMana) )
6579 goto LABEL_83;
6580 v460 = *(int *)&v3->field_C;
6581 if ( v460 == v1 )
6582 {
6583 pParty->pPlayers[v3->uPlayerID_2].Heal(amount);
6584 LABEL_904:
6585 v674 = v3->uPlayerID_2;
6586 LABEL_685:
6587 v352 = v3->spellnum;
6588 v353 = pGame->GetStru6();
6589 pGame->GetStru6()->SetPlayerBuffAnim(v352, v674);
6590 }
6591 else
6592 {
6593 if ( (v460 & 7) == 3 )
6594 {
6595 v461 = &pActors[v460 >> 3];
6596 v462 = v461->uAIState;
6597 v463 = v461->pMonsterInfo.uHP;
6598 if ( v462 != 5 )
6599 {
6600 if ( v462 != 4 )
6601 {
6602 if ( v462 != 19 )
6603 {
6604 if ( v462 != 11 )
6605 {
6606 v461->sCurrentHP += amount;
6607 if ( v461->sCurrentHP > v463 )
6608 v461->sCurrentHP = v463;
6609 }
6610 }
6611 }
6612 }
6613 }
6614 }
6615 goto LABEL_1056;
6616 case 72:
6617 v464 = v12 - 2;
6618 if ( !v464 )
6619 goto LABEL_910;
6620 v465 = v464 - 1;
6621 if ( v465 )
6622 {
6623 if ( v465 == 1 )
6624 {
6625 amount = v1;
6626 goto LABEL_912;
6627 }
6628 LABEL_910:
6629 v466 = 3600 * v2;
6630 }
6631 else
6632 {
6633 v466 = 86400 * v2;
6634 }
6635 amount = v466;
6636 LABEL_912:
6637 if ( !pPlayer->CanCastSpell(uRequiredMana) )
6638 goto LABEL_83;
6639 v467 = v3->uPlayerID_2;
6640 v468 = v3->spellnum;
6641 v469 = pGame->GetStru6();
6642 pGame->GetStru6()->SetPlayerBuffAnim(v468, v467);
6643 v470 = v3->uPlayerID_2;
6644 if ( !(HIDWORD(pParty->pPlayers[v470].pConditions[6]) | LODWORD(pParty->pPlayers[v470].pConditions[6]))
6645 && !(HIDWORD(pParty->pPlayers[v470].pConditions[8]) | LODWORD(pParty->pPlayers[v470].pConditions[8]))
6646 && !(HIDWORD(pParty->pPlayers[v470].pConditions[10]) | LODWORD(pParty->pPlayers[v470].pConditions[10])) )
6647 goto LABEL_1056;
6648 if ( v731 == 4 )
6649 {
6650 LODWORD(pParty->pPlayers[v470].pConditions[6]) = v1;
6651 HIDWORD(pParty->pPlayers[v470].pConditions[6]) = v1;
6652 v471 = v3->uPlayerID_2;
6653 LODWORD(pParty->pPlayers[v471].pConditions[8]) = v1;
6654 HIDWORD(pParty->pPlayers[v471].pConditions[8]) = v1;
6655 v472 = v3->uPlayerID_2;
6656 LODWORD(pParty->pPlayers[v472].pConditions[10]) = v1;
6657 HIDWORD(pParty->pPlayers[v472].pConditions[10]) = v1;
6658 goto LABEL_1056;
6659 }
6660 v732 = amount << 7;
6661 *(float *)&a2 = (double)(amount << 7) * 0.033333335;
6662 pParty->pPlayers[v470].DiscardConditionIfLastsLongerThan(
6663 6u,
6664 (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2));
6665 v473 = (char *)pParty->pPlayers;
6666 pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan(
6667 8u,
6668 (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2));
6669 v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2);
6670 v656 = 10;
6671 goto LABEL_937;
6672 case 75:
6673 amount = v2;
6674 LODWORD(v733) = 3600 * v2;
6675 if ( !pPlayer->CanCastSpell(uRequiredMana) )
6676 goto LABEL_83;
6677 v474 = v3->spellnum;
6678 v475 = pGame->GetStru6();
6679 pGame->GetStru6()->SetPlayerBuffAnim(v474, v1);
6680 v476 = v3->spellnum;
6681 v477 = pGame->GetStru6();
6682 pGame->GetStru6()->SetPlayerBuffAnim(v476, 1u);
6683 v478 = v3->spellnum;
6684 v479 = pGame->GetStru6();
6685 pGame->GetStru6()->SetPlayerBuffAnim(v478, 2u);
6686 v480 = v3->spellnum;
6687 v481 = pGame->GetStru6();
6688 pGame->GetStru6()->SetPlayerBuffAnim(v480, 3u);
6689 v668 = v1;
6690 v732 = (int)v733 << 7;
6691 v658 = v1;
6692 v653 = v2;
6693 v651 = v731;
6694 v26 = (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335);
6695 v27 = (char *)&pParty->pPartyBuffs[13];
6696 goto LABEL_101;
6697 case 73:
6698 LODWORD(v733) = 3600 * v2;
6699 amount = v2;
6700 if ( !pPlayer->CanCastSpell(uRequiredMana) )
6701 goto LABEL_83;
6702 if ( v731 == 4 )
6703 {
6704 v482 = v3->spellnum;
6705 v483 = pGame->GetStru6();
6706 pGame->GetStru6()->SetPlayerBuffAnim(v482, v1);
6707 v484 = v3->spellnum;
6708 v485 = pGame->GetStru6();
6709 pGame->GetStru6()->SetPlayerBuffAnim(v484, 1u);
6710 v486 = v3->spellnum;
6711 v487 = pGame->GetStru6();
6712 pGame->GetStru6()->SetPlayerBuffAnim(v486, 2u);
6713 v488 = v3->spellnum;
6714 v489 = pGame->GetStru6();
6715 pGame->GetStru6()->SetPlayerBuffAnim(v488, 3u);
6716 v732 = (int)v733 << 7;
6717 v717 = (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335);
6718 pParty->pPlayers[0].pPlayerBuffs[6].Apply(pParty->uTimePlayed + v717, 4u, v2, v2, v1);
6719 pParty->pPlayers[1].pPlayerBuffs[6].Apply(pParty->uTimePlayed + v717, 4u, v2, v2, v1);
6720 pParty->pPlayers[2].pPlayerBuffs[6].Apply(pParty->uTimePlayed + v717, 4u, v2, v2, v1);
6721 v668 = v1;
6722 v658 = v2;
6723 v653 = v2;
6724 LODWORD(v28) = LODWORD(pParty->uTimePlayed) + v717;
6725 v651 = 4;
6726 HIDWORD(v650) = (pParty->uTimePlayed + v717) >> 32;
6727 v27 = (char *)&pParty->pPlayers[3].pPlayerBuffs[6];
6728 goto LABEL_104;
6729 }
6730 v490 = v3->uPlayerID_2;
6731 v491 = v3->spellnum;
6732 v492 = pGame->GetStru6();
6733 pGame->GetStru6()->SetPlayerBuffAnim(v491, v490);
6734 v668 = v1;
6735 v732 = (int)v733 << 7;
6736 v658 = v2;
6737 v653 = v2;
6738 v651 = v731;
6739 v28 = pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335);
6740 v27 = (char *)&pParty->pPlayers[v3->uPlayerID_2].pPlayerBuffs[6];
6741 goto LABEL_103;
6742 case 74:
6743 v493 = v12 - 2;
6744 if ( v493 && (v494 = v493 - 1) != 0 && v494 == 1 )
6745 amount = v1;
6746 else
6747 amount = 86400 * v2;
6748 if ( !pPlayer->CanCastSpell(uRequiredMana) )
6749 goto LABEL_83;
6750 v495 = v3->uPlayerID_2;
6751 v496 = v3->spellnum;
6752 v497 = pGame->GetStru6();
6753 pGame->GetStru6()->SetPlayerBuffAnim(v496, v495);
6754 v498 = v3->uPlayerID_2;
6755 if ( !(HIDWORD(pParty->pPlayers[v498].pConditions[7]) | LODWORD(pParty->pPlayers[v498].pConditions[7]))
6756 && !(HIDWORD(pParty->pPlayers[v498].pConditions[9]) | LODWORD(pParty->pPlayers[v498].pConditions[9]))
6757 && !(HIDWORD(pParty->pPlayers[v498].pConditions[11]) | LODWORD(pParty->pPlayers[v498].pConditions[11])) )
6758 goto LABEL_1056;
6759 if ( v731 == 4 )
6760 {
6761 LODWORD(pParty->pPlayers[v498].pConditions[7]) = v1;
6762 HIDWORD(pParty->pPlayers[v498].pConditions[7]) = v1;
6763 v499 = v3->uPlayerID_2;
6764 LODWORD(pParty->pPlayers[v499].pConditions[9]) = v1;
6765 HIDWORD(pParty->pPlayers[v499].pConditions[9]) = v1;
6766 v500 = v3->uPlayerID_2;
6767 LODWORD(pParty->pPlayers[v500].pConditions[11]) = v1;
6768 HIDWORD(pParty->pPlayers[v500].pConditions[11]) = v1;
6769 }
6770 else
6771 {
6772 v732 = amount << 7;
6773 *(float *)&a2 = (double)(amount << 7) * 0.033333335;
6774 pParty->pPlayers[v498].DiscardConditionIfLastsLongerThan(
6775 7u,
6776 (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2));
6777 v473 = (char *)pParty->pPlayers;
6778 pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan(
6779 9u,
6780 (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2));
6781 v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2);
6782 v656 = 11;
6783 LABEL_937:
6784 v325 = (Player *)&v473[6972 * v3->uPlayerID_2];
6785 LABEL_641:
6786 v325->DiscardConditionIfLastsLongerThan(v656, v663);
6787 }
6788 goto LABEL_1056;
6789 case 77:
6790 amount = 5 * v2 + 10;
6791 if ( !pPlayer->CanCastSpell(uRequiredMana) )
6792 goto LABEL_83;
6793 v501 = pParty->pPlayers;
6794 do
6795 {
6796 v502 = v3->spellnum;
6797 v503 = pGame->GetStru6();
6798 pGame->GetStru6()->SetPlayerBuffAnim(v502, v1);
6799 v501->Heal(amount);
6800 ++v501;
6801 ++v1;
6802 }
6803 while ( (signed int)v501 < (signed int)pParty->pHirelings );
6804 goto LABEL_1056;
6805 case 80:
6806 sRecoveryTime -= v2;
6807 if ( !pPlayer->CanCastSpell(uRequiredMana) )
6808 goto LABEL_83;
6809 v504 = pGame->GetStru6();
6810 pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xAFF0Au, 0xC0u);
6811 v505 = sub_46A6AC((int)dword_50BF30, 100, 4096);
6812 ++a1.uItemType;
6813 HIDWORD(v733) = v505;
6814 v690 = v1;
6815 v689 = v1;
6816 v688 = v1;
6817 a1.stru_24.Reset();
6818 a1.field_48 = v3->spellnum;
6819 a1.field_4C = v2;
6820 a1.field_50 = v731;
6821 a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
6822 a1.uAttributes = v1;
6823 a1.uSectorID = v1;
6824 a1.uSpriteFrameID = v1;
6825 v506 = v3->uPlayerID;
6826 a1.field_60_distance_related_prolly_lod = 0;
6827 a1.uFacing = v1;
6828 v506 *= 8;
6829 LOBYTE(v506) = v506 | 4;
6830 a1.field_58 = v506;
6831 a1.uSoundID = LOWORD(v3->field_10);
6832 a2 = v1;
6833 if ( SHIDWORD(v733) > v1 )
6834 {
6835 do
6836 {
6837 v507 = dword_50BF30[a2];
6838 a1.vPosition.x = pActors[v507].vPosition.x;
6839 a1.vPosition.y = pActors[v507].vPosition.y;
6840 v732 = pActors[v507].uActorHeight;
6841 a1.vPosition.z = pActors[v507].vPosition.z - (unsigned int)(signed __int64)((double)v732 * unk_4D8548);
6842 v508 = 8 * dword_50BF30[a2];
6843 LOBYTE(v508) = v508 | 3;
6844 a1.field_5C = v508;
6845 v509 = a1.Create(0, v1, v1, v1);
6846 v510 = a2;
6847 DamageMonsterFromParty(8 * v509 | 2, dword_50BF30[a2], (Vec3_int_ *)&v688);
6848 a2 = v510 + 1;
6849 }
6850 while ( v510 + 1 < SHIDWORD(v733) );
6851 }
6852 for ( a2 = v1; a2 < SHIDWORD(v733); ++a2 )
6853 {
6854 v511 = &pActors[dword_50BF30[a2]];
6855 a1.vPosition.x = v511->vPosition.x;
6856 a1.vPosition.y = v511->vPosition.y;
6857 v732 = v511->uActorHeight;
6858 a1.vPosition.z = v511->vPosition.z - (unsigned int)(signed __int64)((double)v732 * unk_4D8548);
6859 v512 = 8 * dword_50BF30[a2];
6860 LOBYTE(v512) = v512 | 3;
6861 a1.field_5C = v512;
6862 a1.Create(0, v1, v1, v1);
6863 v513 = v511->pActorBuffs;
6864 v726 = (Player *)22;
6865 do
6866 {
6867 v513->Reset();
6868 ++v513;
6869 v726 = (Player *)((char *)v726 - 1);
6870 }
6871 while ( *(float *)&v726 != 0.0 );
6872 }
6873 goto LABEL_1056;
6874 case 82:
6875 v514 = v12 - 2;
6876 if ( !v514 )
6877 goto LABEL_955;
6878 v515 = v514 - 1;
6879 if ( v515 )
6880 {
6881 if ( v515 == 1 )
6882 {
6883 v516 = 900 * v2;
6884 amount = 5;
6885 }
6886 else
6887 {
6888 LABEL_955:
6889 v516 = 300 * v2;
6890 amount = 1;
6891 }
6892 }
6893 else
6894 {
6895 v516 = 900 * v2;
6896 amount = 3;
6897 }
6898 v733 = __PAIR__(v1, v516);
6899 v517 = 8 * v3->uPlayerID;
6900 LOBYTE(v517) = v517 | 4;
6901 if ( (signed int)uNumActors > v1 )
6902 {
6903 v518 = (char *)&pActors[0].uAIState;
6904 v726 = (Player *)uNumActors;
6905 do
6906 {
6907 v519 = *(short *)v518;
6908 if ( *(short *)v518 != 5 && v519 != 11 && v519 != 19 && v517 == *((int *)v518 + 159) )
6909 ++HIDWORD(v733);
6910 v518 += 836;
6911 v726 = (Player *)((char *)v726 - 1);
6912 }
6913 while ( *(float *)&v726 != 0.0 );
6914 }
6915 if ( SHIDWORD(v733) >= amount )
6916 {
6917 v66 = pGlobalTXT_LocalizationStrings[648];
6918 goto LABEL_201;
6919 }
6920 if ( !pPlayer->CanCastSpell(uRequiredMana) )
6921 goto LABEL_83;
6922 sub_44FA4C_spawn_light_elemental(v3->uPlayerID, v731, v733);
6923 goto LABEL_1056;
6924 case 83:
6925 v520 = v12 - 2;
6926 if ( !v520 )
6927 goto LABEL_973;
6928 v521 = v520 - 1;
6929 if ( v521 )
6930 {
6931 if ( v521 == 1 )
6932 {
6933 LODWORD(v733) = 18000 * v2;
6934 v522 = 5 * v2 + 10;
6935 }
6936 else
6937 {
6938 LABEL_973:
6939 LODWORD(v733) = 10800 * v2;
6940 v522 = 3 * v2 + 10;
6941 }
6942 }
6943 else
6944 {
6945 LODWORD(v733) = 14400 * v2;
6946 v522 = 4 * v2 + 10;
6947 }
6948 amount = v522;
6949 if ( !pPlayer->CanCastSpell(uRequiredMana) )
6950 goto LABEL_83;
6951 v523 = v3->spellnum;
6952 v524 = pGame->GetStru6();
6953 pGame->GetStru6()->SetPlayerBuffAnim(v523, v1);
6954 v83 = 1;
6955 v525 = v3->spellnum;
6956 v526 = pGame->GetStru6();
6957 pGame->GetStru6()->SetPlayerBuffAnim(v525, 1u);
6958 v527 = v3->spellnum;
6959 v528 = pGame->GetStru6();
6960 pGame->GetStru6()->SetPlayerBuffAnim(v527, 2u);
6961 v529 = v3->spellnum;
6962 v530 = pGame->GetStru6();
6963 pGame->GetStru6()->SetPlayerBuffAnim(v529, 3u);
6964 v673 = v1;
6965 v732 = (int)v733 << 7;
6966 v662 = v1;
6967 v655 = amount;
6968 v652 = v731;
6969 v183 = (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335);
6970 v137 = (char *)&pParty->pPartyBuffs[2];
6971 goto LABEL_976;
6972 case 84:
6973 v67 = 2;
6974 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
6975 {
6976 v66 = pGlobalTXT_LocalizationStrings[497];
6977 goto LABEL_202;
6978 }
6979 if ( !pPlayer->CanCastSpell(uRequiredMana) )
6980 goto LABEL_83;
6981 v531 = sub_46A6AC((int)dword_50BF30, 100, 4096);
6982 ++a1.uItemType;
6983 v726 = (Player *)v531;
6984 v696 = v1;
6985 v695 = v1;
6986 v694 = v1;
6987 a1.stru_24.Reset();
6988 a1.field_48 = v3->spellnum;
6989 a1.field_4C = v2;
6990 a1.field_50 = v731;
6991 a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
6992 a1.uAttributes = v1;
6993 a1.uSectorID = v1;
6994 a1.uSpriteFrameID = v1;
6995 v532 = v3->uPlayerID;
6996 a1.field_60_distance_related_prolly_lod = 0;
6997 a1.uFacing = v1;
6998 v532 *= 8;
6999 LOBYTE(v532) = v532 | 4;
7000 a1.field_58 = v532;
7001 a1.uSoundID = LOWORD(v3->field_10);
7002 a2 = v1;
7003 if ( (signed int)v726 > v1 )
7004 {
7005 do
7006 {
7007 v533 = dword_50BF30[a2];
7008 a1.vPosition.x = pActors[v533].vPosition.x;
7009 a1.vPosition.y = pActors[v533].vPosition.y;
7010 v732 = pActors[v533].uActorHeight;
7011 a1.vPosition.z = pActors[v533].vPosition.z - (unsigned int)(signed __int64)((double)v732 * unk_4D8548);
7012 v534 = 8 * dword_50BF30[a2];
7013 LOBYTE(v534) = v534 | 3;
7014 a1.field_5C = v534;
7015 v535 = a1.Create(0, v1, v1, v1);
7016 v536 = a2;
7017 DamageMonsterFromParty(8 * v535 | 2, dword_50BF30[a2], (Vec3_int_ *)&v694);
7018 a2 = v536 + 1;
7019 }
7020 while ( v536 + 1 < (signed int)v726 );
7021 }
7022 v537 = pGame->GetStru6();
7023 pGame->GetStru6()->_4A8BFC();
7024 goto LABEL_1056;
7025 case 85:
7026 v538 = v12 - 2;
7027 if ( v538 && (v539 = v538 - 1) != 0 && v539 == 1 )
7028 {
7029 amount = 5 * v2;
7030 v540 = 18000 * v2;
7031 }
7032 else
7033 {
7034 amount = 4 * v2;
7035 v540 = 14400 * v2;
7036 }
7037 v730 = v540;
7038 LODWORD(v733) = v540;
7039 if ( !pPlayer->CanCastSpell(uRequiredMana) )
7040 goto LABEL_83;
7041 v541 = v3->spellnum;
7042 v542 = pGame->GetStru6();
7043 pGame->GetStru6()->SetPlayerBuffAnim(v541, v1);
7044 v543 = v3->spellnum;
7045 v544 = pGame->GetStru6();
7046 pGame->GetStru6()->SetPlayerBuffAnim(v543, 1u);
7047 v545 = v3->spellnum;
7048 v546 = pGame->GetStru6();
7049 pGame->GetStru6()->SetPlayerBuffAnim(v545, 2u);
7050 v547 = v3->spellnum;
7051 v548 = pGame->GetStru6();
7052 pGame->GetStru6()->SetPlayerBuffAnim(v547, 3u);
7053 v732 = v730 << 7;
7054 v549 = (double)(v730 << 7) * 0.033333335;
7055 *((float *)&v733 + 1) = v549;
7056 v712 = (signed __int64)v549;
7057 pParty->pPartyBuffs[ 1].Apply(pParty->uTimePlayed + (signed __int64)v549, v731, amount, v1, v1);
7058 pParty->pPartyBuffs[12].Apply(pParty->uTimePlayed + v712, v731, amount, v1, v1);
7059 pParty->pPartyBuffs[ 6].Apply(pParty->uTimePlayed + v712, v731, amount, v1, v1);
7060 pParty->pPartyBuffs[17].Apply(pParty->uTimePlayed + v712, v731, amount, v1, v1);
7061 pParty->pPartyBuffs[ 0].Apply(pParty->uTimePlayed + v712, v731, amount, v1, v1);
7062 pParty->pPartyBuffs[ 4].Apply(pParty->uTimePlayed + v712, v731, amount, v1, v1);
7063 v550 = v2 + 5;
7064 pParty->pPartyBuffs[ 5].Apply(
7065 (signed __int64)((double)(signed __int64)pParty->uTimePlayed + *((float *)&v733 + 1)),
7066 v731,
7067 v550,
7068 v1,
7069 v1);
7070 v668 = v1;
7071 v658 = v1;
7072 v653 = v550;
7073 v651 = v731;
7074 v28 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed + *((float *)&v733 + 1));
7075 LABEL_992:
7076 v27 = (char *)&pParty->pPartyBuffs[19];
7077 goto LABEL_103;
7078 case 86:
7079 v551 = v12 - 2;
7080 if ( !v551 )
7081 goto LABEL_998;
7082 v552 = v551 - 1;
7083 if ( v552 )
7084 {
7085 if ( v552 == 1 )
7086 {
7087 amount = 15;
7088 HIDWORD(v733) = 20;
7089 goto LABEL_1000;
7090 }
7091 LABEL_998:
7092 v678 = 4;
7093 }
7094 else
7095 {
7096 v678 = 12;
7097 }
7098 amount = v678;
7099 HIDWORD(v733) = v678;
7100 LABEL_1000:
7101 if ( !pPlayer->CanCastSpell(uRequiredMana) )
7102 goto LABEL_83;
7103 y = (char *)(60 * (v2 * HIDWORD(v733) + 60));
7104 v732 = (300 * amount * v2 + 60) << 7;
7105 v730 = v2 + 5;
7106 v726 = (Player *)v1;
7107 v553 = (char *)&pParty->pPlayers[0].pConditions[1];
7108 *((float *)&v733 + 1) = (double)v732 * 0.033333335;
7109 do
7110 {
7111 v554 = v3->spellnum;
7112 v555 = pGame->GetStru6();
7113 pGame->GetStru6()->SetPlayerBuffAnim(v554, v1);
7114 v556 = v3->spellnum;
7115 v557 = pGame->GetStru6();
7116 pGame->GetStru6()->SetPlayerBuffAnim(v556, 1u);
7117 v558 = v3->spellnum;
7118 v559 = pGame->GetStru6();
7119 pGame->GetStru6()->SetPlayerBuffAnim(v558, 2u);
7120 v560 = v3->spellnum;
7121 v561 = pGame->GetStru6();
7122 pGame->GetStru6()->SetPlayerBuffAnim(v560, 3u);
7123 ((SpellBuff *)(v553 + 6056))->Apply(
7124 (signed __int64)((double)(signed __int64)pParty->uTimePlayed + *((float *)&v733 + 1)),
7125 v731,
7126 v730,
7127 v1,
7128 v1);
7129 if ( *(_QWORD *)v553 )
7130 v726 = (Player *)1;
7131 v553 += 6972;
7132 }
7133 while ( (signed int)v553 < (signed int)&pParty->pHirelings[0].uFlags );
7134 v562 = v731;
7135 pParty->pPartyBuffs[9].Apply(
7136 (signed __int64)((double)(signed __int64)pParty->uTimePlayed + *((float *)&v733 + 1)),
7137 v731,
7138 v730,
7139 v1,
7140 v1);
7141 pParty->pPartyBuffs[14].Apply(
7142 (signed __int64)((double)(signed __int64)pParty->uTimePlayed + *((float *)&v733 + 1)),
7143 v562,
7144 v1,
7145 v1,
7146 v1);
7147 pParty->pPartyBuffs[15].Apply(
7148 (signed __int64)((double)(signed __int64)pParty->uTimePlayed + *((float *)&v733 + 1)),
7149 v562,
7150 v730,
7151 v1,
7152 v1);
7153 if ( v726 != (Player *)v1 )
7154 goto LABEL_1056;
7155 v668 = v1;
7156 v732 = (int)y << 7;
7157 v658 = v1;
7158 v653 = v730;
7159 v651 = v562;
7160 v28 = (signed __int64)((double)(signed int)((int)y << 7) * 0.033333335
7161 + (double)(signed __int64)pParty->uTimePlayed);
7162 v27 = (char *)&pParty->pPartyBuffs[8];
7163 goto LABEL_103;
7164 case 88:
7165 amount = 3;
7166 if ( pPlayer->uNumDivineInterventionCastsThisDay >= 3u )
7167 goto LABEL_200;
7168 if ( !pPlayer->CanCastSpell(uRequiredMana) )
7169 goto LABEL_83;
7170 a2 = v1;
7171 _this = (ItemGen *)&pPlayers[1];
7172 do
7173 {
7174 v563 = 0;
7175 do
7176 {
7177 v564 = _this->uItemID;
7178 *(int *)(v563 + _this->uItemID) = v1;
7179 v563 += 8;
7180 *(int *)(v563 + v564 - 4) = v1;
7181 }
7182 while ( v563 <= 128 );
7183 v565 = ((Player *)_this->uItemID)->GetMaxHealth();
7184 v566 = (Player **)_this;
7185 *(int *)(_this->uItemID + 6460) = v565;
7186 v567 = (*v566)->GetMaxMana();
7187 v568 = a2;
7188 *(int *)(_this->uItemID + 6464) = v567;
7189 v569 = v3->spellnum;
7190 v570 = pGame->GetStru6();
7191 pGame->GetStru6()->SetPlayerBuffAnim(v569, v568);
7192 ++a2;
7193 _this = (ItemGen *)((char *)_this + 4);
7194 }
7195 while ( (signed int)this < (signed int)&qword_A750D8 );
7196 v571 = pPlayer;
7197 v572 = (char *)&pPlayer->sAgeModifier;
7198 if ( pPlayer->sAgeModifier + 10 >= 120 )
7199 *(short *)v572 = 120;
7200 else
7201 *(short *)v572 = pPlayer->sAgeModifier + 10;
7202 sRecoveryTime += -5 * v2;
7203 ++v571->uNumDivineInterventionCastsThisDay;
7204 goto LABEL_1056;
7205 case 89:
7206 v573 = v12 - 2;
7207 if ( v573 )
7208 {
7209 v574 = v573 - 1;
7210 if ( v574 )
7211 {
7212 if ( v574 == 1 )
7213 v575 = 5 * v2;
7214 else
7215 v575 = 2 * v2;
7216 }
7217 else
7218 {
7219 v575 = 4 * v2;
7220 }
7221 }
7222 else
7223 {
7224 v575 = 3 * v2;
7225 }
7226 amount = v575;
7227 if ( !pPlayer->CanCastSpell(uRequiredMana) )
7228 goto LABEL_83;
7229 v576 = *(int *)&v3->field_C;
7230 if ( v576 == v1 )
7231 {
7232 v583 = v3->uPlayerID_2;
7233 v584 = v3->spellnum;
7234 v585 = (char *)&pParty->pPlayers[v3->uPlayerID_2];
7235 v586 = pGame->GetStru6();
7236 pGame->GetStru6()->SetPlayerBuffAnim(v584, v583);
7237 if ( *((_QWORD *)v585 + 14) )
7238 {
7239 ((Player *)v585)->SetCondition(0x11u, 1);
7240 v587 = ((Player *)v585)->GetSexByVoice();
7241 ReloadPlayerPortraits(v3->uPlayerID_2, (v587 != 0) + 23);
7242 *((_QWORD *)v585 + 17) = pParty->uTimePlayed;
7243 }
7244 goto LABEL_83;
7245 }
7246 v577 = (Player *)(v576 >> 3);
7247 v726 = v577;
7248 if ( v577 == (Player *)-1 )
7249 {
7250 v66 = pGlobalTXT_LocalizationStrings[496];
7251 goto LABEL_201;
7252 }
7253 v578 = (int)&pActors[(int)v577];
7254 v721 = v578;
7255 if ( *(short *)(v578 + 40) > (signed __int16)v1 || (v579 = *(short *)(v578 + 176), v579 != 5) && v579 != 4 )
7256 goto LABEL_200;
7257 ++a1.uItemType;
7258 a1.stru_24.Reset();
7259 a1.field_48 = v3->spellnum;
7260 a1.field_4C = v2;
7261 a1.field_50 = v731;
7262 a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
7263 a1.uAttributes = v1;
7264 a1.uSectorID = v1;
7265 a1.uSpriteFrameID = v1;
7266 v580 = v3->uPlayerID;
7267 a1.field_60_distance_related_prolly_lod = 0;
7268 v581 = v721;
7269 v580 *= 8;
7270 LOBYTE(v580) = v580 | 4;
7271 a1.uFacing = v1;
7272 a1.field_58 = v580;
7273 a1.uSoundID = LOWORD(v3->field_10);
7274 a1.vPosition.x = *(short *)(v721 + 142);
7275 a1.vPosition.y = *(short *)(v721 + 144);
7276 v732 = *(short *)(v721 + 138);
7277 v582 = 8 * (int)v726;
7278 a1.vPosition.z = *(short *)(v721 + 146) - (unsigned int)(signed __int64)((double)v732 * unk_4D8548);
7279 LOBYTE(v582) = 8 * (char)v726 | 3;
7280 a1.field_5C = v582;
7281 a1.Create(0, v1, v1, v1);
7282 if ( *(char *)(v581 + 52) > amount )
7283 goto LABEL_83;
7284 Actor::Resurrect((unsigned int)v726);
7285 *(char *)(v581 + 61) = 0;
7286 *(char *)(v581 + 53) = 0;
7287 *(char *)(v581 + 54) = 0;
7288 *(char *)(v581 + 55) = 0;
7289 *(char *)(v581 + 56) = 0;
7290 *(char *)(v581 + 57) = 0;
7291 *(int *)(v581 + 712) = 9999;
7292 *(char *)(v581 + 38) &= 0xF7u;
7293 *(int *)(v581 + 708) = v1;
7294 ((SpellBuff *)(v581 + 356))->Reset();
7295 ((SpellBuff *)(v581 + 228))->Reset();
7296 ((SpellBuff *)(v581 + 404))->Reset();
7297 if ( *(short *)(v581 + 40) > 10 * amount )
7298 *(short *)(v581 + 40) = 10 * amount;
7299 goto LABEL_1056;
7300 case 91:
7301 v588 = v12 - 1;
7302 amount = 16;
7303 if ( v588 && (v589 = v588 - 1) != 0 && (v590 = v589 - 1) != 0 )
7304 {
7305 if ( v590 == 1 )
7306 LODWORD(v733) = v1;
7307 }
7308 else
7309 {
7310 LODWORD(v733) = 3600 * v2;
7311 }
7312 if ( !pPlayer->CanCastSpell(uRequiredMana) )
7313 goto LABEL_83;
7314 HIDWORD(v733) = (int)(char *)&pParty + 6972 * v3->uPlayerID_2 + 36 * a2 + 3040;
7315 v732 = (signed int)&pItemsTable->pItems[*(int *)HIDWORD(v733)].pIconName;
7316 ((ItemGen *)HIDWORD(v733))->UpdateTempBonus(pParty->uTimePlayed);
7317 if ( *(int *)HIDWORD(v733) >= 64 && *(int *)HIDWORD(v733) <= 65
7318 || *(char *)(HIDWORD(v733) + 20) & 2
7319 || *(int *)(HIDWORD(v733) + 12) != v1
7320 || *(int *)(HIDWORD(v733) + 4) != v1
7321 || (v591 = *(char *)(v732 + 28)) != 0 && v591 != 1 && v591 != 2
7322 || pItemsTable->_456D5E_is_some_material((ItemGen *)HIDWORD(v733)) )
7323 goto LABEL_199;
7324 v592 = HIDWORD(v733);
7325 v14 = v731 == 4;
7326 *(int *)(HIDWORD(v733) + 12) = 16;
7327 if ( !v14 )
7328 {
7329 v732 = (int)v733 << 7;
7330 *(_QWORD *)(v592 + 28) = pParty->uTimePlayed
7331 + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335);
7332 *(int *)(v592 + 20) |= 8u;
7333 }
7334 *(char *)(v592 + 20) |= 0x80u;
7335 goto LABEL_1055;
7336 case 93:
7337 v593 = v12 - 2;
7338 if ( !v593 )
7339 goto LABEL_1062;
7340 v594 = v593 - 1;
7341 if ( v594 )
7342 {
7343 if ( v594 == 1 )
7344 amount = 9;
7345 else
7346 LABEL_1062:
7347 amount = 5;
7348 }
7349 else
7350 {
7351 amount = 7;
7352 }
7353 if ( !pPlayer->CanCastSpell(uRequiredMana) )
7354 goto LABEL_83;
7355 v726 = (Player *)((signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360);
7356 v732 = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360 / (amount - 1);
7357 a1.stru_24.Reset();
7358 a1.field_48 = v3->spellnum;
7359 a1.field_4C = v2;
7360 a1.field_50 = v731;
7361 a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
7362 a1.vPosition.x = pParty->vPosition.x;
7363 a1.vPosition.y = pParty->vPosition.y;
7364 a1.uAttributes = v1;
7365 a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2;
7366 a1.uSectorID = pIndoor->GetSector(
7367 pParty->vPosition.x,
7368 pParty->vPosition.y,
7369 pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2);
7370 a1.uSpriteFrameID = v1;
7371 v595 = 8 * v3->uPlayerID;
7372 LOBYTE(v595) = v595 | 4;
7373 a1.field_58 = v595;
7374 a1.field_5C = a2;
7375 a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
7376 a1.uSoundID = LOWORD(v3->field_10);
7377 if ( pParty->bTurnBasedModeOn == 1 )
7378 LOBYTE(a1.uAttributes) |= 4u;
7379 v596 = (signed int)v726 / -2;
7380 y = (char *)((signed int)v726 / 2);
7381 if ( (signed int)v726 / -2 <= (signed int)v726 / 2 )
7382 {
7383 v597 = v715.uYawAngle;
7384 do
7385 {
7386 a1.uFacing = v596 + v597;
7387 if ( a1.Create(
7388 v596 + v597,
7389 v715.uPitchAngle,
7390 pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed,
7391 v3->uPlayerID + 1) != -1
7392 && pParty->bTurnBasedModeOn == 1 )
7393 ++pTurnEngine->field_1C;
7394 v596 += v732;
7395 }
7396 while ( v596 <= (signed int)y );
7397 }
7398 goto LABEL_1056;
7399 case 94:
7400 if ( !pPlayer->CanCastSpell(uRequiredMana) )
7401 goto LABEL_83;
7402 if ( v731 == 1 || v731 == 2 )
7403 {
7404 v598 = 180 * v2;
7405 goto LABEL_1081;
7406 }
7407 if ( v731 == 3 )
7408 {
7409 v598 = 300 * v2;
7410 LABEL_1081:
7411 LODWORD(v733) = v598;
7412 goto LABEL_1082;
7413 }
7414 if ( v731 == 4 )
7415 LODWORD(v733) = 29030400;
7416 LABEL_1082:
7417 v599 = a2 >> 3;
7418 if ( (a2 & 7) != 3 )
7419 goto LABEL_1056;
7420 v730 = 836 * v599;
7421 if ( !MonsterStats::BelongsToSupertype(pActors[v599].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) )
7422 goto LABEL_83;
7423 if ( !stru_50C198.GetMagicalResistance((Actor *)((char *)pActors + v730), 0xAu) )
7424 goto LABEL_200;
7425 ((SpellBuff *)((char *)&pActors[0].pActorBuffs[9] + v730))->Reset();
7426 ((SpellBuff *)((char *)&pActors[0].pActorBuffs[1] + v730))->Reset();
7427 v732 = (int)v733 << 7;
7428 ((SpellBuff *)((char *)&pActors[0].pActorBuffs[12] + v730))->Apply(
7429 pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335),
7430 v731,
7431 v1,
7432 v1,
7433 v1);
7434 a1.stru_24.Reset();
7435 a1.field_48 = v3->spellnum;
7436 a1.field_4C = v2;
7437 a1.field_50 = v731;
7438 v60 = pObjectList->ObjectIDByItemID(a1.uItemType);
7439 v61 = v730;
7440 LABEL_1086:
7441 v600 = *(__int16 *)((char *)&pActors[0].vPosition.y + v61);
7442 v601 = *(__int16 *)((char *)&pActors[0].vPosition.x + v61);
7443 a1.uObjectDescID = v60;
7444 a1.vPosition.x = v601;
7445 v602 = *(unsigned __int16 *)((char *)&pActors[0].uActorHeight + v61);
7446 v603 = *(__int16 *)((char *)&pActors[0].vPosition.z + v61);
7447 a1.vPosition.y = v600;
7448 v676 = v603 + v602;
7449 v665 = v600;
7450 a1.vPosition.z = v603 + v602;
7451 v657 = v601;
7452 LABEL_1087:
7453 a1.uAttributes = v1;
7454 a1.uSectorID = pIndoor->GetSector(v657, v665, v676);
7455 a1.uSpriteFrameID = v1;
7456 v604 = 8 * v3->uPlayerID;
7457 LOBYTE(v604) = v604 | 4;
7458 a1.field_58 = v604;
7459 a1.field_5C = a2;
7460 a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance);
7461 a1.uFacing = LOWORD(v715.uYawAngle);
7462 LOWORD(v604) = LOWORD(v3->field_10);
7463 LOBYTE(a1.uAttributes) |= 0x80u;
7464 a1.uSoundID = v604;
7465 a1.Create(0, v1, v1, v3->uPlayerID + 1);
7466 goto LABEL_1056;
7467 case 96:
7468 if ( !pPlayer->CanCastSpell(uRequiredMana) )
7469 goto LABEL_83;
7470 HIDWORD(v733) = v1;
7471 memset(&pStru179, v1, 0xFA0u);
7472 _this = (ItemGen *)v1;
7473 v605 = (char *)pParty->pHirelings;
7474 do
7475 {
7476 if ( *(int *)v605 != v1 )
7477 {
7478 v606 = HIDWORD(v733)++;
7479 pStru179->field_0[v606] = (int)((char *)&_this->uItemID + 1);
7480 }
7481 _this = (ItemGen *)((char *)_this + 1);
7482 v605 += 76;
7483 }
7484 while ( (signed int)v605 < (signed int)&pParty->pPickedItem );
7485 _this = (ItemGen *)v1;
7486 if ( (signed int)pNPCStats->uNumNewNPCs > v1 )
7487 {
7488 v730 = (int)pNPCStats->pNewNPCData;
7489 HIDWORD(v733) = 4 * HIDWORD(v733) + 6043152;
7490 do
7491 {
7492 if ( *(char *)(v730 + 8) & 0x80
7493 && (pParty->pHirelings[0].pName == (char *)v1 || strcmp(*(const char **)v730, pParty->pHirelings[0].pName))
7494 && (pParty->pHirelings[1].pName == (char *)v1 || strcmp(*(const char **)v730, pParty->pHirelings[1].pName)) )
7495 {
7496 v607 = HIDWORD(v733);
7497 HIDWORD(v733) += 4;
7498 *(int *)v607 = (int)_this + 3;
7499 }
7500 _this = (ItemGen *)((char *)_this + 1);
7501 v730 += 76;
7502 }
7503 while ( (signed int)this < (signed int)pNPCStats->uNumNewNPCs );
7504 }
7505 v608 = v3->uPlayerID_2;
7506 if ( v608 != 4 && v608 != 5
7507 || (v609 = (signed int)*(&pFontCChar + v608 + (unsigned __int8)pParty->field_709), v609 <= v1)
7508 || v609 >= 3 )
7509 goto LABEL_200;
7510 v610 = 76 * v609;
7511 *((int *)&pParty->pPlayers[3].pInstalledBeacons[4].uBeaconTime + 19 * v609) = v1;
7512 v611 = pIconsFrameTable->FindIcon("spell96");
7513 *(int *)((char *)&pParty->pPlayers[3].pInstalledBeacons[4].uBeaconTime + v610 + 4) = pIconsFrameTable->GetIconAnimLength(
7514 v611);
7515 v232 = 1;
7516 *(int *)((char *)&pParty->pPlayers[3].pInstalledBeacons[3].field_18 + v610) = 1;
7517 v612 = (char *)pParty->pPlayers;
7518 do
7519 {
7520 *((int *)v612 + 1615) = ((Player *)v612)->GetMaxHealth();
7521 *((int *)v612 + 1616) = ((Player *)v612)->GetMaxMana();
7522 v612 += 6972;
7523 }
7524 while ( (signed int)v612 < (signed int)pParty->pHirelings );
7525 v613 = (char *)&pOutdoor->ddm;
7526 if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor)
7527 v613 = (char *)&pIndoor->dlv;
7528 *((int *)v613 + 2) += 15;
7529 if ( *((int *)v613 + 2) > 10000 )
7530 *((int *)v613 + 2) = 10000;
7531 LABEL_1112:
7532 LODWORD(v727) = v232;
7533 goto LABEL_83;
7534 case 95:
7535 if ( v12 <= v1 )
7536 goto LABEL_1119;
7537 if ( v12 <= 3 )
7538 {
7539 v614 = 300 * (v2 + 12);
7540 }
7541 else
7542 {
7543 if ( v12 != 4 )
7544 goto LABEL_1119;
7545 v614 = 900 * (v2 + 4);
7546 }
7547 LODWORD(v733) = v614;
7548 LABEL_1119:
7549 v615 = v2 + 5;
7550 amount = v615;
7551 if ( !pPlayer->CanCastSpell(uRequiredMana) )
7552 goto LABEL_83;
7553 if ( v731 != 3 && v731 != 4 )
7554 {
7555 v616 = v3->uPlayerID_2;
7556 v617 = v3->spellnum;
7557 v618 = pGame->GetStru6();
7558 pGame->GetStru6()->SetPlayerBuffAnim(v617, v616);
7559 v668 = v1;
7560 v658 = v716;
7561 v732 = (int)v733 << 7;
7562 v653 = v615;
7563 v651 = v731;
7564 v28 = pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335);
7565 v27 = (char *)&pParty->pPlayers[v3->uPlayerID_2].pPlayerBuffs[10];
7566 goto LABEL_103;
7567 }
7568 a2 = v1;
7569 v732 = (int)v733 << 7;
7570 v717 = (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335);
7571 v619 = &pParty->pPlayers[0].pPlayerBuffs[10];
7572 do
7573 {
7574 v620 = a2;
7575 v621 = v3->spellnum;
7576 v622 = pGame->GetStru6();
7577 pGame->GetStru6()->SetPlayerBuffAnim(v621, v620);
7578 v619->Apply(pParty->uTimePlayed + v717, v731, amount, v716, v1);
7579 ++a2;
7580 v619 = (SpellBuff *)((char *)v619 + 6972);
7581 }
7582 while ( (signed int)v619 < (signed int)&pParty->field_871C[504] );
7583 goto LABEL_1056;
7584 case 99:
7585 if ( !pPlayer->CanCastSpell(uRequiredMana) )
7586 goto LABEL_83;
7587 v726 = (Player *)v1;
7588 pGame->GetIndoorCamera();
7589 v623 = (signed __int64)GetPickDepth();
7590 HIDWORD(v733) = sub_46A6AC((int)dword_50BF30, 100, v623);
7591 v709 = v1;
7592 v708 = v1;
7593 v707 = v1;
7594 a1.stru_24.Reset();
7595 a1.field_48 = v3->spellnum;
7596 a1.field_4C = v2;
7597 a1.field_50 = v731;
7598 a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
7599 a1.uAttributes = v1;
7600 a1.uSectorID = v1;
7601 a1.uSpriteFrameID = v1;
7602 v624 = v3->uPlayerID;
7603 a1.field_60_distance_related_prolly_lod = 0;
7604 a1.uFacing = v1;
7605 v624 *= 8;
7606 LOBYTE(v624) = v624 | 4;
7607 a1.field_58 = v624;
7608 a1.uSoundID = LOWORD(v3->field_10);
7609 a2 = v1;
7610 if ( SHIDWORD(v733) > v1 )
7611 {
7612 v726 = (Player *)(HIDWORD(v733) * (7 * v2 + 25));
7613 do
7614 {
7615 v625 = dword_50BF30[a2];
7616 a1.vPosition.x = pActors[v625].vPosition.x;
7617 a1.vPosition.y = pActors[v625].vPosition.y;
7618 v732 = pActors[v625].uActorHeight;
7619 a1.vPosition.z = pActors[v625].vPosition.z - (unsigned int)(signed __int64)((double)v732 * unk_4D8548);
7620 v626 = 8 * dword_50BF30[a2];
7621 LOBYTE(v626) = v626 | 3;
7622 a1.field_5C = v626;
7623 v627 = a1.Create(0, v1, v1, v1);
7624 v628 = a2;
7625 DamageMonsterFromParty(8 * v627 | 2, dword_50BF30[a2], (Vec3_int_ *)&v707);
7626 a2 = v628 + 1;
7627 }
7628 while ( v628 + 1 < SHIDWORD(v733) );
7629 }
7630 v730 = v1;
7631 v629 = 1;
7632 do
7633 {
7634 v630 = pPlayers[v629];
7635 if ( !v630->pConditions[2]
7636 && !v630->pConditions[12]
7637 && !v630->pConditions[13]
7638 && !v630->pConditions[14]
7639 && !v630->pConditions[15]
7640 && !v630->pConditions[16] )
7641 {
7642 v631 = v730++;
7643 v681[v631] = v629;
7644 }
7645 ++v629;
7646 }
7647 while ( v629 <= 4 );
7648 v732 = (signed __int64)((double)(signed int)v726 / (double)v730);
7649 HIDWORD(v733) = v1;
7650 if ( v730 > v1 )
7651 {
7652 do
7653 {
7654 v632 = 4 * v681[HIDWORD(v733)] + 10965188;
7655 v633 = pPlayers[v681[HIDWORD(v733)]];
7656 v633->sHealth += v732;
7657 v726 = *(Player **)v632;
7658 v634 = v726->GetMaxHealth();
7659 if ( v726->sHealth > v634 )
7660 *(int *)(*(int *)v632 + 6460) = v726->GetMaxHealth();
7661 v635 = HIDWORD(v733);
7662 v636 = WORD2(v733);
7663 v637 = v3->spellnum;
7664 v638 = pGame->GetStru6();
7665 pGame->GetStru6()->SetPlayerBuffAnim(v637, v636);
7666 HIDWORD(v733) = v635 + 1;
7667 }
7668 while ( v635 + 1 < v730 );
7669 }
7670 v639 = pGame->GetStru6();
7671 pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(v1, 0x40u);
7672 goto LABEL_1056;
7673 case 98:
7674 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
7675 {
7676 v66 = pGlobalTXT_LocalizationStrings[499];
7677 goto LABEL_201;
7678 }
7679 v640 = v12 - 2;
7680 if ( !v640 || (v641 = v640 - 1) == 0 || (amount = 4, v641 != 1) )
7681 amount = 3;
7682 if ( pPlayer->uNumArmageddonCasts >= amount || pParty->field_1613C > v1 )
7683 goto LABEL_200;
7684 if ( !pPlayer->CanCastSpell(uRequiredMana) )
7685 goto LABEL_83;
7686 pParty->field_1613C = 256;
7687 pParty->field_16140 = v2;
7688 ++pPlayer->uNumArmageddonCasts;
7689 if ( pParty->bTurnBasedModeOn == 1 )
7690 ++pTurnEngine->field_1C;
7691 v726 = (Player *)50;
7692 do
7693 {
7694 v642 = rand() % 4096 - 2048;
7695 v643 = rand();
7696 v721 = v642 + pParty->vPosition.x;
7697 y = (char *)(pParty->vPosition.y + v643 % 4096 - 2048);
7698 v732 = GetTerrainHeightsAroundParty2(v642 + pParty->vPosition.x, (int)y, (int *)&v710, v1);
7699 v644 = rand();
7700 sub_42F7EB_DropItemAt(0xFE6u, v721, (int)y, v732 + 16, v644 % 500 + 500, 1, v1, v1, (ItemGen *)v1);
7701 v726 = (Player *)((char *)v726 - 1);
7702 }
7703 while ( *(float *)&v726 != 0.0 );
7704 goto LABEL_1056;
7705 default:
7706 goto LABEL_83;
7707 }
7708 while ( 2 )
7709 {
7710 if ( v731 == 4 )
7711 {
7712 if ( *((_QWORD *)v222 + 2) )
7713 {
7714 *((int *)v222 + 4) = v1;
7715 *((int *)v222 + 5) = v1;
7716 goto LABEL_439;
7717 }
7718 }
7719 else
7720 {
7721 v732 = amount << 7;
7722 v223 = ((Player *)v222)->DiscardConditionIfLastsLongerThan(
7723 2u,
7724 pParty->uTimePlayed - (signed int)(signed __int64)((double)(amount << 7) * 0.033333335));
7725 v222 = (char *)HIDWORD(v733);
7726 if ( v223 )
7727 LABEL_439:
7728 ((Player *)v222)->PlaySound(103, v1);
7729 }
7730 v222 += 6972;
7731 HIDWORD(v733) = (int)v222;
7732 if ( (signed int)v222 >= (signed int)pParty->pHirelings )
7733 goto LABEL_1056;
7734 continue;
7735 }
7736 }
7737 if ( pParty->bTurnBasedModeOn == v1 )
7738 {
7739 v646 = pPlayer;
7740 pPlayer->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * 213.3333333333333));
7741 v647 = n;
7742 }
7743 else
7744 {
7745 v647 = n;
7746 v646 = pPlayer;
7747 v648 = sRecoveryTime;
7748 v649 = pPlayer;
7749 pParty->pTurnBasedPlayerRecoveryTimes[v711[n].uPlayerID] = 100;
7750 v649->SetRecoveryTime(v648);
7751 pTurnEngine->_40471C();
7752 }
7753 ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2u);
7754 pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, v1, v1, -1, v1, v1, v1, v1);
7755 v711[v647].spellnum = v1;
7756 v646->sMana -= uRequiredMana;
7757 }
7758 //----- (0042EB42) --------------------------------------------------------
7759 __int16 ObjectList::ObjectIDByItemID(unsigned __int16 uItemID)
7760 {
7761 unsigned int v2; // edx@1
7762 signed int v3; // eax@1
7763 char *v4; // ecx@2
7764
7765 v2 = this->uNumObjects;
7766 v3 = 0;
7767 if ( (signed int)this->uNumObjects <= 0 )
7768 {
7769 LABEL_5:
7770 LOWORD(v3) = 0;
7771 }
7772 else
7773 {
7774 v4 = (char *)&this->pObjects->uObjectID;
7775 while ( uItemID != *(short *)v4 )
7776 {
7777 ++v3;
7778 v4 += 56;
7779 if ( v3 >= (signed int)v2 )
7780 goto LABEL_5;
7781 }
7782 }
7783 return v3;
7784 }
7785
7786
7787
7788 //----- (0042EB78) --------------------------------------------------------
7789 int IconFrameTable::GetIconAnimLength(unsigned int uIconID)
7790 {
7791 return 8 * this->pIcons[uIconID].uAnimLength;
7792 }
7793
7794 //----- (0042EB8D) --------------------------------------------------------
7795 void GUIMessageQueue::SendMessage(UIMessageType msg, int param, unsigned int a4)
7796 {
7797 if (uNumMessages < 40)
7798 {
7799 pMessages[uNumMessages].eType = msg;
7800 pMessages[uNumMessages].param = param;
7801 pMessages[uNumMessages++].field_8 = a4;
7802 }
7803 }
7804
7805 //----- (0042EBBE) --------------------------------------------------------
7806 int __fastcall sub_42EBBE(int a1, int a2)
7807 {
7808 return (unsigned __int64)(a2 * (signed __int64)a1) >> 16;
7809 }
7810 // 42EBBE: using guessed type int __fastcall sub_42EBBE(int, int);
7811
7812 //----- (0042EBDB) --------------------------------------------------------
7813 int stru193_math::_42EBDB(int angle)
7814 {
7815 return SinCos(angle - this->uIntegerHalfPi);
7816 }
7817
7818 //----- (0042ECB5) --------------------------------------------------------
7819 bool __cdecl _42ECB5_PlayerAttacksActor()
7820 {
7821 unsigned int v0; // ebx@1
7822 Player *v1; // esi@1
7823 bool result; // eax@1
7824 int v3; // edi@2
7825 unsigned int v4; // eax@7
7826 char *v5; // eax@8
7827 int v6; // ecx@9
7828 signed int v7; // eax@16
7829 Actor *v8; // edi@20
7830 unsigned int v9; // ecx@21
7831 char *v10; // eax@26
7832 char *v11; // eax@26
7833 unsigned int v12; // eax@47
7834 char *v13; // eax@47
7835 char *v14; // eax@47
7836 unsigned int v15; // ebx@54
7837 int v16; // [sp-10h] [bp-4Ch]@24
7838 int v17; // [sp-10h] [bp-4Ch]@44
7839 unsigned int v18; // [sp-Ch] [bp-48h]@24
7840 unsigned int v19; // [sp-Ch] [bp-48h]@44
7841 __int16 v20; // [sp-8h] [bp-44h]@24
7842 __int16 v21; // [sp-8h] [bp-44h]@44
7843 int v22; // [sp-4h] [bp-40h]@24
7844 int v23; // [sp-4h] [bp-40h]@44
7845 SoundID v24; // [sp-4h] [bp-40h]@58
7846 Vec3_int_ a3; // [sp+Ch] [bp-30h]@19
7847 unsigned int a2; // [sp+18h] [bp-24h]@20
7848 unsigned int v27; // [sp+1Ch] [bp-20h]@1
7849 char *v28; // [sp+20h] [bp-1Ch]@9
7850 int v29; // [sp+24h] [bp-18h]@16
7851 int v30; // [sp+28h] [bp-14h]@16
7852 int v31; // [sp+2Ch] [bp-10h]@4
7853 int v32; // [sp+30h] [bp-Ch]@7
7854 int v33; // [sp+34h] [bp-8h]@7
7855 int v34; // [sp+38h] [bp-4h]@17
7856
7857 v0 = uActiveCharacter;
7858 v27 = 6972 * uActiveCharacter;
7859 v1 = (Player *)&stru_AA1058[3].pSounds[6972 * uActiveCharacter + 40552];
7860 result = ((Player *)&stru_AA1058[3].pSounds[6972 * uActiveCharacter + 40552])->CanAct();
7861 if ( result )
7862 {
7863 pStru277->_427D48(v0);
7864 v3 = 0;
7865 if ( (signed __int64)pParty->pPartyBuffs[11].uExpireTime > 0 )
7866 pParty->pPartyBuffs[11].Reset();
7867 v31 = v1->pEquipment.uBow;
7868 if ( v31 && v1->field_1F5[36 * v31 + 15] & 2 )
7869 v31 = 0;
7870 v4 = v1->pEquipment.uMainHand;
7871 v32 = 0;
7872 v33 = 0;
7873 if ( v4 )
7874 {
7875 v5 = (char *)v1 + 36 * v4;
7876 if ( !(v5[516] & 2) )
7877 {
7878 v28 = v5 + 496;
7879 v6 = *((int *)v5 + 124);
7880 if ( pItemsTable->pItems[v6].uEquipType == 12 )
7881 {
7882 if ( *((int *)v5 + 128) <= 0 )
7883 {
7884 *(int *)v28 = 0;
7885 v1->pEquipment.uMainHand = 0;
7886 }
7887 else
7888 {
7889 v32 = *((int *)v5 + 124);
7890 }
7891 }
7892 else
7893 {
7894 if ( v6 == 64 || v6 == 65 )
7895 v33 = *((int *)v5 + 124);
7896 }
7897 }
7898 }
7899 v30 = 0;
7900 v29 = 0;
7901 v28 = 0;
7902 v7 = pMouse->uPointingObjectID;
7903 if ( (pMouse->uPointingObjectID & 7) != 3 || (v34 = pMouse->uPointingObjectID, !pActors[v7 >> 3].CanAct()) )
7904 v34 = stru_50C198.FindClosesActor(5120, 0, 0);
7905 a3.z = 0;
7906 a3.y = 0;
7907 a3.x = 0;
7908 if ( (v34 & 7) == 3 )
7909 {
7910 a2 = v34 >> 3;
7911 v8 = &pActors[v34 >> 3];
7912 v34 = sub_452A9E((v8->vPosition.x - pParty->vPosition.x) * (v8->vPosition.x - pParty->vPosition.x) + (v8->vPosition.y - pParty->vPosition.y) * (v8->vPosition.y - pParty->vPosition.y) + (v8->vPosition.z - pParty->vPosition.z) * (v8->vPosition.z - pParty->vPosition.z))
7913 - v8->uActorRadius;
7914 if ( v34 >= 0 )
7915 {
7916 v9 = 0;
7917 }
7918 else
7919 {
7920 v9 = 0;
7921 v34 = 0;
7922 }
7923 if ( v33 != v9 )
7924 {
7925 v28 = (char *)1;
7926 v22 = v0 + 8;
7927 v20 = v9;
7928 v18 = v9;
7929 v16 = 102;
7930 LABEL_34:
7931 _42777D_CastSpell_UseWand_ShootArrow(v16, v0 - 1, v18, v20, v22);
7932 LABEL_28:
7933 v3 = 0;
7934 goto LABEL_29;
7935 }
7936 if ( v32 != v9 )
7937 {
7938 v29 = 1;
7939 _42777D_CastSpell_UseWand_ShootArrow(
7940 *((int *)&pSpellDatas[66].field_8
7941 + *(int *)(&stru_AA1058[3].pSounds[36 * *(int *)&pParty->pArtifactsFound[v27 + 22] + 41048] + v27)),
7942 v0 - 1,
7943 8u,
7944 v9,
7945 v0 + 8);
7946 v10 = &v1->field_1F5[36 * v1->pEquipment.uMainHand + 11];
7947 --*(int *)v10;
7948 v11 = (char *)v1 + 36 * v1->pEquipment.uMainHand;
7949 if ( *((int *)v11 + 128) <= 0 )
7950 {
7951 *((int *)v11 + 124) = 0;
7952 v1->pEquipment.uMainHand = 0;
7953 }
7954 goto LABEL_28;
7955 }
7956 if ( (double)v34 <= 407.2 )
7957 {
7958 a3.x = v8->vPosition.x - pParty->vPosition.x;
7959 a3.y = v8->vPosition.y - pParty->vPosition.y;
7960 a3.z = v8->vPosition.z - pParty->vPosition.z;
7961 Vec3_int_::Normalize(&a3.x, &a3.y, &a3.z);
7962 DamageMonsterFromParty((8 * v0 - 8) | 4, a2, &a3);
7963 if ( v1->WearsItem(506, 1) || v1->WearsItem(506, 0) )
7964 _42FA66_do_explosive_impact(
7965 v8->vPosition.x,
7966 v8->vPosition.y,
7967 v8->vPosition.z + v8->uActorHeight / 2,
7968 0,
7969 512,
7970 v0);
7971 }
7972 else
7973 {
7974 if ( v31 != v9 )
7975 {
7976 v30 = 1;
7977 v22 = 0;
7978 v20 = 0;
7979 v18 = 0;
7980 v16 = 100;
7981 goto LABEL_34;
7982 }
7983 }
7984 v3 = 0;
7985 goto LABEL_39;
7986 }
7987 if ( v33 )
7988 {
7989 v28 = (char *)1;
7990 v23 = v0 + 8;
7991 v21 = 0;
7992 v19 = 0;
7993 v17 = 102;
7994 }
7995 else
7996 {
7997 if ( v32 )
7998 {
7999 v12 = v1->pEquipment.uMainHand;
8000 v29 = 1;
8001 _42777D_CastSpell_UseWand_ShootArrow(
8002 *((int *)&pSpellDatas[66].field_8 + *(int *)&v1->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v12 + 5]),
8003 v0 - 1,
8004 8u,
8005 0,
8006 v0 + 8);
8007 v13 = &v1->field_1F5[36 * v1->pEquipment.uMainHand + 11];
8008 --*(int *)v13;
8009 v14 = (char *)v1 + 36 * v1->pEquipment.uMainHand;
8010 if ( *((int *)v14 + 128) <= 0 )
8011 {
8012 *((int *)v14 + 124) = 0;
8013 v1->pEquipment.uMainHand = 0;
8014 }
8015 LABEL_29:
8016 v34 = v3;
8017 if ( v30 == v3 )
8018 {
8019 if ( v29 != v3 )
8020 return 1;
8021 if ( v28 == (char *)v3 )
8022 {
8023 v15 = v1->pEquipment.uMainHand;
8024 if ( v1->HasItemEquipped(EQUIP_TWO_HANDED) )
8025 v34 = pItemsTable->pItems[*(int *)&v1->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v15 + 5]].uSkillType;
8026 pTurnEngine->_40471C();
8027 }
8028 else
8029 {
8030 v34 = 7;
8031 }
8032 }
8033 else
8034 {
8035 v34 = 5;
8036 v1->PlaySound(50, v3);
8037 }
8038 switch ( v34 )
8039 {
8040 case 0:
8041 v24 = (SoundID)81;
8042 goto LABEL_66;
8043 case 1:
8044 v24 = (SoundID)84;
8045 goto LABEL_66;
8046 case 2:
8047 v24 = (SoundID)85;
8048 goto LABEL_66;
8049 case 3:
8050 v24 = (SoundID)78;
8051 goto LABEL_66;
8052 case 4:
8053 v24 = (SoundID)80;
8054 goto LABEL_66;
8055 case 5:
8056 v24 = (SoundID)71;
8057 goto LABEL_66;
8058 case 6:
8059 v24 = (SoundID)83;
8060 goto LABEL_66;
8061 case 7:
8062 v24 = (SoundID)67;
8063 LABEL_66:
8064 pAudioPlayer->PlaySound(v24, v3, v3, -1, v3, v3, v3, v3);
8065 break;
8066 default:
8067 return 1;
8068 }
8069 return 1;
8070 }
8071 if ( !v31 )
8072 {
8073 LABEL_39:
8074 v31 = v1->GetAttackRecoveryTime(v3);
8075 if ( v31 < 30 )
8076 v31 = 30;
8077 if ( pParty->bTurnBasedModeOn == v3 )
8078 v1->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * (double)v31 * 2.133333333333333));
8079 goto LABEL_29;
8080 }
8081 v23 = 0;
8082 v21 = 0;
8083 v19 = 0;
8084 v30 = 1;
8085 v17 = 100;
8086 }
8087 _42777D_CastSpell_UseWand_ShootArrow(v17, v0 - 1, v19, v21, v23);
8088 goto LABEL_29;
8089 }
8090 return result;
8091 }
8092
8093 //----- (0042F184) --------------------------------------------------------
8094 int stru319::FindClosesActor(int a2, int a3, int a4)
8095 {
8096 int v4; // edi@1
8097 stru319 *v5; // esi@1
8098 int v6; // eax@2
8099 int v7; // eax@4
8100 int result; // eax@5
8101 int *v9; // edx@8
8102 signed int v10; // ebx@10
8103 int v11; // edi@11
8104 Actor *v12; // esi@12
8105 unsigned __int16 v13; // ax@12
8106 int v14; // eax@22
8107 char v15; // zf@30
8108 int v16; // esi@32
8109 int v17; // ecx@34
8110 stru319 *v18; // eax@39
8111 int v19; // edx@39
8112 int v20; // ecx@41
8113 unsigned __int16 v21; // ax@42
8114 unsigned int v22; // [sp+8h] [bp-24h]@11
8115 unsigned int v23; // [sp+Ch] [bp-20h]@7
8116 stru319 *v24; // [sp+10h] [bp-1Ch]@1
8117 unsigned int v25; // [sp+14h] [bp-18h]@8
8118 int *v26; // [sp+18h] [bp-14h]@8
8119 int v27; // [sp+1Ch] [bp-10h]@10
8120 int *v28; // [sp+20h] [bp-Ch]@10
8121 unsigned int v29; // [sp+24h] [bp-8h]@7
8122 int v30; // [sp+28h] [bp-4h]@6
8123 int i; // [sp+38h] [bp+Ch]@33
8124 signed int v32; // [sp+3Ch] [bp+10h]@32
8125
8126 v4 = 0;
8127 v5 = this;
8128 v24 = this;
8129 if ( pRenderer->pRenderD3D )
8130 {
8131 v6 = a3 != 0;
8132 if ( a4 )
8133 LOBYTE(v6) = v6 | 8;
8134 v7 = pGame->pVisInstance->_4C1944(3, a2, v6, 657456, -1);
8135 if ( v7 != -1 )
8136 return (unsigned __int16)v7;
8137 }
8138 else
8139 {
8140 v30 = 0;
8141 if ( pRenderer->pActiveZBuffer )
8142 {
8143 v29 = viewparams->uScreenX;
8144 v23 = viewparams->uScreenZ;
8145 if ( (signed int)viewparams->uScreenY < (signed int)viewparams->uScreenW )
8146 {
8147 v25 = viewparams->uScreenW - viewparams->uScreenY;
8148 v9 = &pRenderer->pActiveZBuffer[viewparams->uScreenX + 640 * viewparams->uScreenY];
8149 v26 = &pRenderer->pActiveZBuffer[viewparams->uScreenX + 640 * viewparams->uScreenY];
8150 do
8151 {
8152 if ( (signed int)v29 < (signed int)v23 )
8153 {
8154 v28 = v9;
8155 v10 = v4;
8156 v27 = v23 - v29;
8157 do
8158 {
8159 v22 = *v28;
8160 v11 = *v28 & 0xFFFF;
8161 if ( (*(char *)v28 & 7) == 3 )
8162 {
8163 v12 = &pActors[(unsigned int)v11 >> 3];
8164 v13 = v12->uAIState;
8165 if ( v13 != 5 )
8166 {
8167 if ( v13 != 4
8168 && v13 != 11
8169 && v13 != 19
8170 && v13 != 17
8171 && (!a3 || pActors[(unsigned int)v11 >> 3].GetActorsRelation(0)) )
8172 {
8173 if ( (!a4 || MonsterStats::BelongsToSupertype(v12->pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD))
8174 && v22 <= a2 << 16 )
8175 {
8176 v14 = 0;
8177 if ( v10 > 0 )
8178 {
8179 do
8180 {
8181 if ( dword_50BDA0[v14] == v11 )
8182 break;
8183 ++v14;
8184 }
8185 while ( v14 < v30 );
8186 }
8187 if ( v14 == v30 && v10 < 100 )
8188 {
8189 ++v30;
8190 dword_50BC10[v10] = v22;
8191 dword_50BDA0[v10] = v11;
8192 ++v10;
8193 }
8194 }
8195 }
8196 }
8197 }
8198 ++v28;
8199 --v27;
8200 }
8201 while ( v27 );
8202 v4 = v30;
8203 v5 = v24;
8204 }
8205 v9 = v26 + 640;
8206 v15 = v25-- == 1;
8207 v26 += 640;
8208 }
8209 while ( !v15 );
8210 }
8211 if ( v4 > 0 )
8212 {
8213 v32 = 1;
8214 v16 = (int)dword_50BC10;
8215 do
8216 {
8217 for ( i = v32; i < v4; ++i )
8218 {
8219 v17 = dword_50BC10[i];
8220 if ( v17 < *(int *)v16 )
8221 {
8222 dword_50BC10[i] = *(int *)v16;
8223 *(int *)v16 = v17;
8224 }
8225 }
8226 ++v32;
8227 v16 += 4;
8228 }
8229 while ( v32 - 1 < v4 );
8230 v5 = v24;
8231 if ( v4 > 0 )
8232 {
8233 v18 = v24;
8234 v19 = v4;
8235 do
8236 {
8237 *(int *)&v18->field_0 = (*(int *)&v18[(char *)dword_50BC10 - (char *)v24].field_0 >> 3) & 0x1FFF;
8238 v18 += 4;
8239 --v19;
8240 }
8241 while ( v19 );
8242 }
8243 }
8244 v20 = 0;
8245 for ( *(int *)&v5[2000].field_0 = v4; v20 < v4; ++v20 )
8246 {
8247 v21 = pActors[*(int *)&v5[4 * v20].field_0].uAIState;
8248 if ( v21 != 4 && v21 != 5 )
8249 break;
8250 }
8251 if ( v20 != v4 )
8252 {
8253 result = 8 * *(int *)&v5[4 * v20].field_0;
8254 LOBYTE(result) = result | 3;
8255 return result;
8256 }
8257 }
8258 }
8259 return 0;
8260 }
8261
8262
8263 //----- (0042F3D6) --------------------------------------------------------
8264 void InitializeTurnBasedAnimations(void *_this)
8265 {
8266 unsigned int *v1; // edi@1
8267
8268 pIconIDs_Turn[0] = pIconsFrameTable->FindIcon("turn0");
8269 pIconIDs_Turn[1] = pIconsFrameTable->FindIcon("turn1");
8270 pIconIDs_Turn[2] = pIconsFrameTable->FindIcon("turn2");
8271 pIconIDs_Turn[3] = pIconsFrameTable->FindIcon("turn3");
8272 pIconIDs_Turn[4] = pIconsFrameTable->FindIcon("turn4");
8273 uIconID_TurnStop = pIconsFrameTable->FindIcon("turnstop");
8274 uIconID_TurnHour = pIconsFrameTable->FindIcon("turnhour");
8275 uIconID_TurnStart = pIconsFrameTable->FindIcon("turnstart");
8276 uIconID_CharacterFrame = pIconsFrameTable->FindIcon("aframe1");
8277 uSpriteID_Spell11 = pSpriteFrameTable->FastFindSprite("spell11");
8278 v1 = pIconIDs_Turn;
8279 do
8280 {
8281 pIconsFrameTable->InitializeAnimation(*v1);
8282 ++v1;
8283 }
8284 while ( (signed int)v1 < (signed int)&uIconID_TurnStop );
8285 pIconsFrameTable->InitializeAnimation(uIconID_TurnHour);
8286 pIconsFrameTable->InitializeAnimation(uIconID_TurnStop);
8287 pIconsFrameTable->InitializeAnimation(uIconID_TurnStart);
8288 pIconsFrameTable->InitializeAnimation(uIconID_CharacterFrame);
8289 }
8290
8291 //----- (0042F4DA) --------------------------------------------------------
8292 signed int __cdecl sub_42F4DA()
8293 {
8294 signed int v0; // edi@1
8295 char *v1; // esi@4
8296 int v2; // ebx@5
8297 int v3; // eax@5
8298 int v4; // ebx@5
8299 unsigned int v5; // ecx@5
8300 int v6; // edx@6
8301 unsigned int v7; // edx@8
8302 unsigned int v8; // edx@10
8303 __int16 v9; // ax@12
8304 signed int result; // eax@20
8305 int v11; // [sp+Ch] [bp-10h]@5
8306 int v12; // [sp+10h] [bp-Ch]@5
8307 signed int v13; // [sp+14h] [bp-8h]@3
8308
8309 v0 = 5120;
8310 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
8311 v0 = 2560;
8312 v13 = 0;
8313 if ( (signed int)uNumActors <= 0 )
8314 {
8315 LABEL_20:
8316 result = 0;
8317 }
8318 else
8319 {
8320 v1 = (char *)&pActors[0].uAIState;
8321 while ( 1 )
8322 {
8323 v2 = abs(*((short *)v1 - 17) - pParty->vPosition.x);
8324 v11 = abs(*((short *)v1 - 16) - pParty->vPosition.y);
8325 v12 = abs(*((short *)v1 - 15) - pParty->vPosition.z);
8326 v3 = v2;
8327 v4 = v11;
8328 v5 = v12;
8329 if ( v3 < v11 )
8330 {
8331 v6 = v3;
8332 v3 = v11;
8333 v4 = v6;
8334 }
8335 if ( v3 < v12 )
8336 {
8337 v7 = v3;
8338 v3 = v12;
8339 v5 = v7;
8340 }
8341 if ( v4 < (signed int)v5 )
8342 {
8343 v8 = v5;
8344 v5 = v4;
8345 v4 = v8;
8346 }
8347 if ( (signed int)(((unsigned int)(11 * v4) >> 5) + (v5 >> 2) + v3) < v0 )
8348 {
8349 v9 = *(short *)v1;
8350 if ( *(short *)v1 != 5 )
8351 {
8352 if ( v9 != 4
8353 && v9 != 11
8354 && v9 != 19
8355 && v9 != 17
8356 && (*(v1 - 138) & 8 || ((Actor *)nullptr)->GetActorsRelation( (Actor *)(v1 - 176))) )
8357 break;
8358 }
8359 }
8360 ++v13;
8361 v1 += 836;
8362 if ( v13 >= (signed int)uNumActors )
8363 goto LABEL_20;
8364 }
8365 result = 1;
8366 }
8367 return result;
8368 }
8369
8370 //----- (0042F5ED) --------------------------------------------------------
8371 int LayingItem::Create(int yaw, int pitch, int a4, int a5)
8372 {
8373 LayingItem *v5; // eax@1
8374 signed int v6; // ebx@2
8375 char *v7; // ecx@2
8376 signed int result; // eax@6
8377 LayingItem *v9; // ebx@7
8378 int v10; // edx@11
8379 int v11; // edi@18
8380 __int16 v12; // ax@18
8381 int v13; // ST2C_4@20
8382 int v14; // eax@20
8383 int v15; // [sp-28h] [bp-38h]@14
8384 int v16; // [sp-24h] [bp-34h]@11
8385 Vec3_int_ v17; // [sp-20h] [bp-30h]@11
8386 int *v18; // [sp-14h] [bp-24h]@11
8387 int *v19; // [sp-10h] [bp-20h]@11
8388 int *v20; // [sp-Ch] [bp-1Ch]@11
8389 signed int v21; // [sp+8h] [bp-8h]@2
8390 int angle; // [sp+Ch] [bp-4h]@1
8391 int a4a; // [sp+1Ch] [bp+Ch]@20
8392 int a4b; // [sp+1Ch] [bp+Ch]@20
8393 int a5a; // [sp+20h] [bp+10h]@20
8394
8395 auto a1 = this;
8396 angle = yaw;
8397 v5 = a1;
8398 if ( !a1->uObjectDescID )
8399 return -1;
8400 v6 = 0;
8401 v7 = (char *)&pLayingItems[0].uObjectDescID;
8402 v21 = 0;
8403 do
8404 {
8405 if ( !*(short *)v7 )
8406 break;
8407 v7 += 112;
8408 ++v6;
8409 v21 = v6;
8410 }
8411 while ( (signed int)v7 < (signed int)((char *)&pObjectList->uNumObjects + 2) );
8412 if ( v6 >= 1000 )
8413 return -1;
8414 *(int *)&v5->field_62[2] = v5->vPosition.x;
8415 *(int *)&v5->field_62[6] = v5->vPosition.y;
8416 v9 = &pLayingItems[v6];
8417 *(int *)&v5->field_62[10] = v5->vPosition.z;
8418 memcpy(v9, v5, 0x70u);
8419 if ( a5 == 1 )
8420 {
8421 v20 = &v9->vPosition.z;
8422 v19 = &v9->vPosition.y;
8423 v18 = (int *)&v9->vPosition;
8424 v17.z = v5->vPosition.z;
8425 *(_QWORD *)&v17.x = *(_QWORD *)&v5->vPosition.x;
8426 v16 = 0;
8427 v10 = stru_5C6E00->uIntegerHalfPi + v9->uFacing;
8428 goto LABEL_16;
8429 }
8430 if ( a5 == 2 )
8431 {
8432 v20 = &v9->vPosition.z;
8433 v19 = &v9->vPosition.y;
8434 v18 = (int *)&v9->vPosition;
8435 v17.z = v5->vPosition.z;
8436 *(_QWORD *)&v17.x = *(_QWORD *)&v5->vPosition.x;
8437 v16 = 0;
8438 v10 = stru_5C6E00->uIntegerHalfPi + v9->uFacing;
8439 goto LABEL_14;
8440 }
8441 if ( a5 == 3 )
8442 {
8443 v20 = &v9->vPosition.z;
8444 v19 = &v9->vPosition.y;
8445 v18 = (int *)&v9->vPosition;
8446 v17.z = v5->vPosition.z;
8447 *(_QWORD *)&v17.x = *(_QWORD *)&v5->vPosition.x;
8448 v16 = 0;
8449 v10 = v9->uFacing - stru_5C6E00->uIntegerHalfPi;
8450 LABEL_14:
8451 v15 = 8;
8452 LABEL_17:
8453 Vec3_int_::Rotate(v15, v10, v16, v17, v18, v19, v20);
8454 goto LABEL_18;
8455 }
8456 if ( a5 == 4 )
8457 {
8458 v20 = &v9->vPosition.z;
8459 v19 = &v9->vPosition.y;
8460 v18 = (int *)&v9->vPosition;
8461 v17.z = v5->vPosition.z;
8462 *(_QWORD *)&v17.x = *(_QWORD *)&v5->vPosition.x;
8463 v16 = 0;
8464 v10 = v9->uFacing - stru_5C6E00->uIntegerHalfPi;
8465 LABEL_16:
8466 v15 = 24;
8467 goto LABEL_17;
8468 }
8469 LABEL_18:
8470 v11 = a4;
8471 v12 = 0;
8472 if ( a4 )
8473 {
8474 a4a = stru_5C6E00->SinCos(angle);
8475 v13 = (unsigned __int64)(a4a * (signed __int64)stru_5C6E00->SinCos(pitch)) >> 16;
8476 a4b = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi);
8477 a5a = (unsigned __int64)(a4b * (signed __int64)stru_5C6E00->SinCos(pitch)) >> 16;
8478 v14 = stru_5C6E00->SinCos(pitch - stru_5C6E00->uIntegerHalfPi);
8479 v9->vVelocity.x = (unsigned int)(v13 * v11) >> 16;
8480 v9->vVelocity.y = (unsigned int)(a5a * v11) >> 16;
8481 v12 = (unsigned int)(v14 * v11) >> 16;
8482 }
8483 else
8484 {
8485 v9->vVelocity.y = 0;
8486 v9->vVelocity.x = 0;
8487 }
8488 v9->vVelocity.z = v12;
8489 result = v21;
8490 if ( v21 >= (signed int)uNumLayingItems )
8491 uNumLayingItems = v21 + 1;
8492 return result;
8493 }
8494
8495 //----- (0042F7EB) --------------------------------------------------------
8496 bool __fastcall sub_42F7EB_DropItemAt(unsigned int uSpriteID, int x, int y, int z, int a4, int count, int a7, unsigned __int16 attributes, ItemGen *a9)
8497 {
8498 unsigned int v9; // edi@1
8499 signed int v10; // edx@3
8500 char *v11; // ecx@4
8501 unsigned __int16 v12; // ax@7
8502 unsigned int v13; // edx@9
8503 char *v14; // ecx@10
8504 int v15; // esi@17
8505 int v16; // eax@18
8506 int v17; // edi@20
8507 int v18; // esi@20
8508 //LayingItem a1a; // [sp+Ch] [bp-78h]@1
8509 int v21; // [sp+7Ch] [bp-8h]@1
8510 unsigned int v22; // [sp+80h] [bp-4h]@1
8511
8512 v9 = uSpriteID;
8513 v21 = x;
8514 v22 = uSpriteID;
8515
8516 LayingItem a1a; // [sp+Ch] [bp-78h]@1
8517 //LayingItem::LayingItem(&a1a);
8518 a1a.stru_24.Reset();
8519
8520 if ( a9 )
8521 {
8522 memcpy(&a1a.stru_24, a9, sizeof(a1a.stru_24));
8523 v9 = v22;
8524 }
8525 v10 = 0;
8526 a1a.field_50 = 0;
8527 a1a.field_4C = 0;
8528 a1a.field_48 = 0;
8529 a1a.field_54 = 0;
8530 a1a.uItemType = v9;
8531 if ( (signed int)pObjectList->uNumObjects <= 0 )
8532 {
8533 LABEL_7:
8534 v12 = 0;
8535 }
8536 else
8537 {
8538 v11 = (char *)&pObjectList->pObjects->uObjectID;
8539 while ( (short)v9 != *(short *)v11 )
8540 {
8541 ++v10;
8542 v11 += 56;
8543 if ( v10 >= (signed int)pObjectList->uNumObjects )
8544 goto LABEL_7;
8545 }
8546 v12 = v10;
8547 }
8548 a1a.uObjectDescID = v12;
8549 a1a.vPosition.z = z;
8550 a1a.vPosition.x = v21;
8551 a1a.vPosition.y = y;
8552 a1a.uSoundID = 0;
8553 a1a.uAttributes = attributes;
8554 a1a.uSectorID = pIndoor->GetSector(v21, y, z);
8555 a1a.uSpriteFrameID = 0;
8556 a1a.field_58 = 0;
8557 a1a.field_5C = 0;
8558 if ( !(a1a.uAttributes & 0x10) )
8559 {
8560 v13 = 0;
8561 if ( (signed int)pItemsTable->pItems[0].uItemID > 0 )
8562 {
8563 v14 = (char *)&pItemsTable->pItems[0].uSpriteID;
8564 while ( *(short *)v14 != v9 )
8565 {
8566 ++v13;
8567 v14 += 48;
8568 if ( (signed int)v13 >= (signed int)pItemsTable->pItems[0].uItemID )
8569 goto LABEL_16;
8570 }
8571 a1a.stru_24.uItemID = v13;
8572 }
8573 }
8574 LABEL_16:
8575 if ( a7 )
8576 {
8577 v15 = count;
8578 if ( count > 0 )
8579 {
8580 do
8581 {
8582 a1a.uFacing = rand() % (signed int)stru_5C6E00->uIntegerDoublePi;
8583 v16 = rand();
8584 a1a.Create(
8585 (signed __int16)a1a.uFacing,
8586 ((signed int)stru_5C6E00->uIntegerHalfPi >> 1) + (v16 % (signed int)stru_5C6E00->uIntegerHalfPi >> 1),
8587 a4,
8588 0);
8589 --v15;
8590 }
8591 while ( v15 );
8592 }
8593 }
8594 else
8595 {
8596 v17 = count;
8597 v18 = stru_5C6E00->uIntegerHalfPi;
8598 a1a.uFacing = 0;
8599 if ( count > 0 )
8600 {
8601 do
8602 {
8603 a1a.Create((signed __int16)a1a.uFacing, v18, a4, 0);
8604 --v17;
8605 }
8606 while ( v17 );
8607 }
8608 }
8609 return 1;
8610 }
8611
8612 //----- (0042F960) --------------------------------------------------------
8613 void __fastcall sub_42F960_create_object(int x, int y, int z)
8614 {
8615 int v3; // ebx@1
8616 int v4; // edi@1
8617 signed int v5; // edx@1
8618 char *v6; // ecx@2
8619 unsigned __int16 v7; // ax@5
8620 signed int v8; // eax@6
8621 signed int v9; // eax@7
8622 //LayingItem a1; // [sp+Ch] [bp-70h]@1
8623
8624 v3 = x;
8625 v4 = y;
8626
8627 LayingItem a1; // [sp+Ch] [bp-70h]@1
8628 //LayingItem::LayingItem(&a1);
8629 a1.stru_24.Reset();
8630
8631 v5 = 0;
8632 a1.field_50 = 0;
8633 a1.field_4C = 0;
8634 a1.field_48 = 0;
8635 a1.field_54 = 0;
8636 a1.uItemType = 800;
8637 if ( (signed int)pObjectList->uNumObjects <= 0 )
8638 {
8639 LABEL_5:
8640 v7 = 0;
8641 }
8642 else
8643 {
8644 v6 = (char *)&pObjectList->pObjects->uObjectID;
8645 while ( *(short *)v6 != 800 )
8646 {
8647 ++v5;
8648 v6 += 56;
8649 if ( v5 >= (signed int)pObjectList->uNumObjects )
8650 goto LABEL_5;
8651 }
8652 v7 = v5;
8653 }
8654 a1.uObjectDescID = v7;
8655 a1.vPosition.x = v3;
8656 a1.vPosition.y = v4;
8657 a1.vPosition.z = z;
8658 a1.uSoundID = 0;
8659 a1.uAttributes = 0;
8660 a1.uSectorID = pIndoor->GetSector(v3, v4, z);
8661 a1.uSpriteFrameID = 0;
8662 a1.field_58 = 0;
8663 a1.field_5C = 0;
8664 v8 = a1.Create(0, 0, 0, 0);
8665 if ( v8 != -1 )
8666 {
8667 v9 = 8 * v8;
8668 LOBYTE(v9) = v9 | 2;
8669 pAudioPlayer->PlaySound((SoundID)(SOUND_GoldReceived|0x14), v9, 0, -1, 0, 0, 0, 0);
8670 }
8671 }
8672
8673 //----- (0042FA22) --------------------------------------------------------
8674 char *__cdecl sub_42FA22_mess_with_laying_item_list()
8675 {
8676 size_t v0; // edx@1
8677 int v1; // ebp@1
8678 char *result; // eax@1
8679 void *v3; // ebx@1
8680
8681 v0 = 0;
8682 v1 = 0;
8683 result = (char *)&pLayingItems[0].uObjectDescID;
8684 v3 = pLayingItems;
8685 do
8686 {
8687 if ( *(short *)result )
8688 {
8689 if ( v1 != v0 )
8690 {
8691 memcpy(v3, result - 2, 0x70u);
8692 *(short *)result = 0;
8693 }
8694 ++v0;
8695 v3 = (char *)v3 + 112;
8696 }
8697 result += 112;
8698 ++v1;
8699 }
8700 while ( (signed int)result < (signed int)((char *)&pObjectList->uNumObjects + 2) );
8701 uNumLayingItems = v0;
8702 return result;
8703 }
8704
8705 //----- (0042FA66) --------------------------------------------------------
8706 int __fastcall _42FA66_do_explosive_impact(int a1, int a2, int a3, int a4, __int16 a5, signed int a6)
8707 {
8708 int v6; // edi@1
8709 int v7; // esi@1
8710 char *v8; // ecx@2
8711 unsigned __int16 v9; // ax@5
8712 int v10; // eax@10
8713 signed int result; // eax@11
8714 __int16 v12; // ax@12
8715 //LayingItem a1a; // [sp+Ch] [bp-74h]@1
8716 int v14; // [sp+7Ch] [bp-4h]@1
8717
8718 v6 = a1;
8719 v7 = a2;
8720 LayingItem a1a; // [sp+Ch] [bp-74h]@1
8721 //LayingItem::LayingItem(&a1a);
8722 a1a.uItemType = 600;
8723 a1a.stru_24.Reset();
8724
8725 a1a.field_48 = 6;
8726 a1a.field_4C = 8;
8727 a1a.field_50 = 3;
8728 v14 = 0;
8729 if ( (signed int)pObjectList->uNumObjects <= 0 )
8730 {
8731 LABEL_5:
8732 v9 = 0;
8733 }
8734 else
8735 {
8736 v8 = (char *)&pObjectList->pObjects->uObjectID;
8737 while ( (short)a1a.uItemType != *(short *)v8 )
8738 {
8739 ++v14;
8740 v8 += 56;
8741 if ( v14 >= (signed int)pObjectList->uNumObjects )
8742 goto LABEL_5;
8743 }
8744 v9 = v14;
8745 }
8746 a1a.uObjectDescID = v9;
8747 a1a.vPosition.x = v6;
8748 a1a.vPosition.y = v7;
8749 a1a.vPosition.z = a3;
8750 a1a.uAttributes = 0;
8751 a1a.uSectorID = pIndoor->GetSector(v6, v7, a3);
8752 a1a.uSpriteFrameID = 0;
8753 a1a.field_5C = 0;
8754 a1a.field_60_distance_related_prolly_lod = 0;
8755 a1a.uFacing = 0;
8756 a1a.uSoundID = 0;
8757 if ( a6 >= 1 || a6 <= 4 )
8758 {
8759 v10 = 8 * a6 - 8;
8760 LOBYTE(v10) = v10 | 4;
8761 a1a.field_58 = v10;
8762 }
8763 else
8764 {
8765 a1a.field_58 = 0;
8766 }
8767 result = a1a.Create(0, 0, 0, 0);
8768 if ( result != -1 )
8769 {
8770 v12 = 8 * result;
8771 LOBYTE(v12) = v12 | 2;
8772 result = stru_50FE08.Add(
8773 v12,
8774 a5,
8775 SLOWORD(a1a.vPosition.x),
8776 SLOWORD(a1a.vPosition.y),
8777 SLOWORD(a1a.vPosition.z),
8778 0,
8779 0);
8780 }
8781 return result;
8782 }
8783
8784
8785
8786 //----- (0042FB5C) --------------------------------------------------------
8787 bool __fastcall sub_42FB5C(signed int a1)
8788 {
8789 int v1; // ecx@3
8790 int v2; // ecx@4
8791 int v3; // ecx@5
8792 int v4; // ecx@6
8793 int v5; // ecx@7
8794 int v6; // ecx@8
8795 char v7; // zf@9
8796
8797 if ( a1 > 39 )
8798 {
8799 if ( a1 > 77 )
8800 {
8801 if ( a1 == 80 )
8802 return 0;
8803 if ( a1 > 84 )
8804 {
8805 if ( a1 <= 86 )
8806 return 0;
8807 v7 = a1 == 95;
8808 goto LABEL_20;
8809 }
8810 }
8811 else
8812 {
8813 if ( a1 == 77 )
8814 return 0;
8815 if ( a1 >= 46 )
8816 {
8817 if ( a1 <= 47 || a1 == 51 )
8818 return 0;
8819 v7 = a1 == 73;
8820 goto LABEL_20;
8821 }
8822 }
8823 return 1;
8824 }
8825 if ( a1 == 39 || (v1 = a1 - 2) == 0 )
8826 return 1;
8827 v2 = v1 - 3;
8828 if ( !v2 )
8829 return 0;
8830 v3 = v2 - 1;
8831 if ( !v3 || (v4 = v3 - 3) == 0 )
8832 return 1;
8833 v5 = v4 - 8;
8834 if ( !v5 )
8835 return 0;
8836 v6 = v5 - 1;
8837 if ( !v6 )
8838 return 1;
8839 v7 = v6 == 20;
8840 LABEL_20:
8841 if ( !v7 )
8842 return 1;
8843 return 0;
8844 }
8845
8846 //----- (0042FBDD) --------------------------------------------------------
8847 void __cdecl sub_42FBDD()
8848 {
8849 pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
8850 pRenderer->DrawTextureTransparent(pBtn_YES->uX, pBtn_YES->uY, pBtn_YES->pTextures[0]);
8851 pRenderer->Present();
8852 }
8853
8854 //----- (0042FC15) --------------------------------------------------------
8855 void __cdecl sub_42FC15()
8856 {
8857 pAudioPlayer->PlaySound((SoundID)75, -2, 0, -1, 0, 0, 0, 0);
8858 pRenderer->DrawTextureTransparent(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY, pBtn_ExitCancel->pTextures[0]);
8859 pRenderer->Present();
8860 }
8861
8862 //----- (0042FC4E) --------------------------------------------------------
8863 void __cdecl ProcessInputActions()
8864 {
8865 ActionQueue *pActionQueue; // esi@7
8866 Keyboard *v3; // ecx@8
8867 char v4; // al@9
8868 ActionQueue *v5; // ecx@19
8869 Player *v6; // ecx@86
8870 Player *v7; // esi@100
8871 char v8; // bl@100
8872 unsigned __int16 v9; // ax@102
8873 int v10; // eax@103
8874 unsigned int v11; // eax@127
8875 signed int v12; // esi@157
8876 Keyboard *v13; // ecx@158
8877 char v14; // al@159
8878 unsigned int v15; // eax@168
8879 void *v16; // esi@177
8880 int v17; // [sp-14h] [bp-1Ch]@8
8881 PartyAction partyAction; // [sp-14h] [bp-1Ch]@20
8882 PartyAction partyAction_; // [sp-14h] [bp-1Ch]@54
8883 __int16 v20; // [sp-14h] [bp-1Ch]@60
8884 int v21; // [sp-14h] [bp-1Ch]@68
8885 int v22; // [sp-Ch] [bp-14h]@158
8886 InputAction inputAction; // [sp+0h] [bp-8h]@7
8887 int v24; // [sp+4h] [bp-4h]@87
8888
8889 pGame->pKeyboardInstance->EnterCriticalSection();
8890 auto pKeyboard = pGame->pKeyboardInstance;
8891 if (!bAlwaysRun)
8892 {
8893 if (pKeyboard->IsShiftHeld())
8894 pParty->uFlags2 |= PARTY_FLAGS_2_RUNNING;
8895 else
8896 pParty->uFlags2 &= ~PARTY_FLAGS_2_RUNNING;
8897 }
8898 else
8899 {
8900 if (pKeyboard->IsShiftHeld())
8901 pParty->uFlags2 &= ~PARTY_FLAGS_2_RUNNING;
8902 else
8903 pParty->uFlags2 |= PARTY_FLAGS_2_RUNNING;
8904 }
8905
8906 pParty->uFlags2 |= PARTY_FLAGS_2_RUNNING;
8907 LABEL_6:
8908 if ( !pEventTimer->bPaused )
8909 {
8910 inputAction = (InputAction)0;
8911 pActionQueue = pPartyActionQueue;
8912 while ( 1 )
8913 {
8914 v3 = pGame->pKeyboardInstance;
8915 v17 = pKeyActionMap->pVirtualKeyCodesMapping[inputAction];
8916 if ( pKeyActionMap->pToggleTypes[inputAction] )
8917 v4 = v3->WasKeyPressed(v17);
8918 else
8919 v4 = v3->IsKeyBeingHeld(v17);
8920 if ( v4 )
8921 {
8922 switch ( inputAction )
8923 {
8924 case INPUT_MoveForward:
8925 if ( pCurrentScreen )
8926 break;
8927 if (!pParty->bTurnBasedModeOn)
8928 goto _do_move_forward;
8929 if (pTurnEngine->field_4 != 1 && pTurnEngine->field_4 != 2 && pTurnEngine->uActionPointsLeft > 0 )
8930 {
8931 pTurnEngine->uActionPointsLeft -= 26;
8932 _do_move_forward:
8933 v5 = pActionQueue;
8934 if ( pParty->uFlags2 & 2 )
8935 partyAction = PARTY_RunForward;
8936 else
8937 partyAction = PARTY_WalkForward;
8938 goto _add_action_and_continue;
8939 }
8940 break;
8941 case INPUT_MoveBackwards:
8942 __debugbreak();
8943 if ( pCurrentScreen )
8944 break;
8945 if (!pParty->bTurnBasedModeOn)
8946 goto _do_move_backwards;
8947 if ( pTurnEngine->field_4 != 1 && pTurnEngine->field_4 != 2 && pTurnEngine->uActionPointsLeft > 0 )
8948 {
8949 pTurnEngine->uActionPointsLeft -= 26;
8950 _do_move_backwards:
8951 v5 = pActionQueue;
8952 if ( pParty->uFlags2 & 2 )
8953 partyAction = PARTY_RunBackward;
8954 else
8955 partyAction = PARTY_WalkBackward;
8956 goto _add_action_and_continue;
8957 }
8958 break;
8959 case INPUT_StrafeLeft:
8960 __debugbreak();
8961 if ( pCurrentScreen )
8962 break;
8963 if (!pParty->bTurnBasedModeOn)
8964 goto _do_strafe_left;
8965 if ( pTurnEngine->field_4 == 1 || pTurnEngine->field_4 == 2 || pTurnEngine->uActionPointsLeft <= 0 )
8966 break;
8967 pTurnEngine->uActionPointsLeft -= 26;
8968 _do_strafe_left:
8969 partyAction = PARTY_StrafeLeft;
8970 goto _add_action_and_continue_;
8971 case INPUT_StrafeRight:
8972 __debugbreak();
8973 if ( pCurrentScreen )
8974 break;
8975 if (!pParty->bTurnBasedModeOn)
8976 goto _do_strafe_right;
8977 if ( pTurnEngine->field_4 == 1 || pTurnEngine->field_4 == 2 || pTurnEngine->uActionPointsLeft <= 0 )
8978 break;
8979 pTurnEngine->uActionPointsLeft -= 26;
8980 _do_strafe_right:
8981 partyAction = PARTY_StrafeRight;
8982 goto _add_action_and_continue_;
8983 case INPUT_TurnLeft:
8984 if ( pCurrentScreen )
8985 break;
8986 if ( GetAsyncKeyState(VK_CONTROL) ) // strafing
8987 {
8988 if (pParty->bTurnBasedModeOn)
8989 {
8990 if ( pTurnEngine->field_4 == 1 || pTurnEngine->field_4 == 2 || pTurnEngine->uActionPointsLeft <= 0 )
8991 break;
8992 pTurnEngine->uActionPointsLeft -= 26;
8993 }
8994 partyAction_ = PARTY_StrafeLeft;
8995 }
8996 else
8997 {
8998 if ( pParty->uFlags2 & 2 )
8999 partyAction_ = PARTY_FastTurnLeft;
9000 else
9001 partyAction_ = PARTY_TurnLeft;
9002 }
9003 pActionQueue->Add(partyAction_);
9004 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor && pWeather->bRenderSnow)
9005 {
9006 v20 = 10;
9007 goto LABEL_75;
9008 }
9009 break;
9010 case INPUT_TurnRight:
9011 if ( pCurrentScreen )
9012 break;
9013 if ( GetAsyncKeyState(17) ) // strafing
9014 {
9015 if (pParty->bTurnBasedModeOn)
9016 {
9017 if ( pTurnEngine->field_4 == 1 || pTurnEngine->field_4 == 2 || pTurnEngine->uActionPointsLeft <= 0 )
9018 break;
9019 pTurnEngine->uActionPointsLeft -= 26;
9020 }
9021 v21 = 4;
9022 }
9023 else
9024 {
9025 if ( pParty->uFlags2 & 2 )
9026 v21 = 19;
9027 else
9028 v21 = 2;
9029 }
9030 pActionQueue->Add((PartyAction)v21);
9031 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor && pWeather->bRenderSnow)
9032 {
9033 v20 = -10;
9034 LABEL_75:
9035 pWeather->_4C2F0B(v20);
9036 }
9037 break;
9038 case INPUT_Jump:
9039 __debugbreak();
9040 if ( pCurrentScreen
9041 || pParty->bTurnBasedModeOn)
9042 break;
9043 partyAction = (PartyAction)12;
9044 goto _add_action_and_continue_;
9045 case INPUT_Yell:
9046 __debugbreak();
9047 if ( !pCurrentScreen
9048 && uActiveCharacter )
9049 {
9050 pParty->Yell();
9051 pPlayers[uActiveCharacter]->PlaySound(65, 0);
9052 }
9053 break;
9054 case INPUT_Pass:
9055 __debugbreak();
9056 if ( pCurrentScreen )
9057 break;
9058 if (pParty->bTurnBasedModeOn && pTurnEngine->field_4 == 3)
9059 goto LABEL_118;
9060 if ( uActiveCharacter )
9061 {
9062 v6 = pPlayers[uActiveCharacter];
9063 if ( !v6->uTimeToRecovery )
9064 {
9065 v24 = v6->GetAttackRecoveryTime(0);
9066 if ( !pParty->bTurnBasedModeOn )
9067 pPlayers[uActiveCharacter]->SetRecoveryTime(
9068 (signed __int64)(flt_6BE3A4_debug_recmod1 * (double)v24 * 2.133333333333333));
9069 pStru277->_427D48(uActiveCharacter);
9070 pTurnEngine->_40471C();
9071 }
9072 }
9073 break;
9074 case INPUT_Combat:
9075 __debugbreak();
9076 if ( !pCurrentScreen )
9077 {
9078 if (pParty->bTurnBasedModeOn)
9079 {
9080 if ( pTurnEngine->field_4 == 3 || (pTurnEngine->pQueue[0].uPackedID & 7) == 4 )
9081 {
9082 pParty->bTurnBasedModeOn = 0;
9083 pTurnEngine->End(true);
9084 }
9085 }
9086 else
9087 {
9088 pTurnEngine->Start();
9089 pParty->bTurnBasedModeOn = true;
9090 }
9091 }
9092 break;
9093 case INPUT_CastReady:
9094 __debugbreak();
9095 if ( pCurrentScreen )
9096 break;
9097 if (pParty->bTurnBasedModeOn && pTurnEngine->field_4 == 3)
9098 goto LABEL_118;
9099 if ( !uActiveCharacter )
9100 break;
9101 v7 = pPlayers[uActiveCharacter];
9102 v8 = v7->uQuickSpell;
9103 if ( !v8
9104 || bUnderwater
9105 || ((v9 = v7->pActiveSkills[(unsigned __int8)v8 / 11 + 12], !(HIBYTE(v9) & 1)) ? ((v9 & 0x80u) == 0 ? (!(v9 & 0x40) ? (v10 = *(&pSpellDatas[0].uNormalLevelMana + 10 * (unsigned __int8)v8)) : (v10 = *(&pSpellDatas[0].uExpertLevelMana + 10 * (unsigned __int8)v8))) : (v10 = *(&pSpellDatas[0].uMasterLevelMana + 10 * (unsigned __int8)v8))) : (v10 = *(&pSpellDatas[0].uMagisterLevelMana + 10 * (unsigned __int8)v8)),
9106 v10 > v7->sMana) )
9107 {
9108 pActionQueue = pPartyActionQueue;
9109 LABEL_120:
9110 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
9111 {
9112 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)23;
9113 goto _send_message;
9114 }
9115 }
9116 else
9117 {
9118 pActionQueue = pPartyActionQueue;
9119 if ( dword_50C9E8 < 40 )
9120 {
9121 dword_50C9EC[3 * dword_50C9E8] = 25;
9122 dword_50C9F0[3 * dword_50C9E8] = 0;
9123 *(&dword_50C9E8 + 3 * dword_50C9E8 + 3) = 0;
9124 ++dword_50C9E8;
9125 }
9126 }
9127 break;
9128 default:
9129 __debugbreak();
9130 break;
9131 case INPUT_Attack:
9132 __debugbreak();
9133 if ( pCurrentScreen )
9134 break;
9135 if (!pParty->bTurnBasedModeOn || pTurnEngine->field_4 != 3)
9136 goto LABEL_120;
9137 LABEL_118:
9138 pTurnEngine->field_18 |= 8u;
9139 break;
9140 case INPUT_EventTrigger:
9141 if ( !pCurrentScreen )
9142 {
9143 if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 )
9144 break;
9145 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)404;
9146 goto _send_message;
9147 }
9148 if ( pCurrentScreen == 4 )
9149 {
9150 v11 = pMessageQueue_50CBD0->uNumMessages;
9151 if ( pMessageQueue_50CBD0->uNumMessages )
9152 {
9153 if ( pMessageQueue_50CBD0->pMessages[0].field_8 )
9154 {
9155 v11 = 1;
9156 pMessageQueue_50CBD0->uNumMessages = 1;
9157 LABEL_132:
9158 pMessageQueue_50CBD0->pMessages[v11].eType = (UIMessageType)113;
9159 _send_message:
9160 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
9161 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
9162 ++pMessageQueue_50CBD0->uNumMessages;
9163 break;
9164 }
9165 v11 = 0;
9166 pMessageQueue_50CBD0->uNumMessages = 0;
9167 }
9168 if ( (signed int)v11 < 40 )
9169 goto LABEL_132;
9170 }
9171 break;
9172 case INPUT_CharCycle:
9173 __debugbreak();
9174 if ( pCurrentScreen == 8
9175 || dword_50C9E8 >= 40 )
9176 break;
9177 dword_50C9EC[3 * dword_50C9E8] = 176;
9178 goto LABEL_155;
9179 case INPUT_LookUp:
9180 __debugbreak();
9181 if ( pEventTimer->bPaused )
9182 break;
9183 partyAction = (PartyAction)7;
9184 goto _add_action_and_continue_;
9185 case INPUT_CenterView:
9186 __debugbreak();
9187 if ( pEventTimer->bPaused )
9188 break;
9189 partyAction = (PartyAction)9;
9190 goto _add_action_and_continue_;
9191 case INPUT_LookDown:
9192 __debugbreak();
9193 if ( pEventTimer->bPaused )
9194 break;
9195 partyAction = (PartyAction)8;
9196 goto _add_action_and_continue_;
9197 case INPUT_FlyUp:
9198 __debugbreak();
9199 if ( pCurrentScreen
9200 || pEventTimer->bPaused )
9201 break;
9202 partyAction = (PartyAction)13;
9203 goto _add_action_and_continue_;
9204 case INPUT_Land:
9205 __debugbreak();
9206 if ( pCurrentScreen
9207 || pEventTimer->bPaused )
9208 break;
9209 partyAction = (PartyAction)15;
9210 goto _add_action_and_continue_;
9211 case INPUT_FlyDown:
9212 __debugbreak();
9213 if ( !pCurrentScreen
9214 && !pEventTimer->bPaused )
9215 {
9216 partyAction = (PartyAction)14;
9217 _add_action_and_continue_:
9218 v5 = pActionQueue;
9219 _add_action_and_continue:
9220 v5->Add(partyAction);
9221 }
9222 break;
9223 case INPUT_ZoomIn:
9224 __debugbreak();
9225 if ( dword_50C9E8 >= 40 )
9226 break;
9227 dword_50C9EC[3 * dword_50C9E8] = 367;
9228 goto LABEL_155;
9229 case INPUT_ZoomOut:
9230 __debugbreak();
9231 if ( dword_50C9E8 < 40 )
9232 {
9233 dword_50C9EC[3 * dword_50C9E8] = 368;
9234 LABEL_155:
9235 dword_50C9F0[3 * dword_50C9E8] = 0;
9236 *(&dword_50C9E8 + 3 * dword_50C9E8 + 3) = 0;
9237 ++dword_50C9E8;
9238 }
9239 break;
9240 case INPUT_AlwaysRun:
9241 bAlwaysRun = bAlwaysRun == 0;
9242 break;
9243 }
9244 }
9245 inputAction = (InputAction)((int)inputAction + 1);
9246 if ( (signed int)inputAction >= 30 )
9247 goto LABEL_176;
9248 }
9249 }
9250 v12 = 0;
9251 do
9252 {
9253 v22 = pKeyActionMap->pVirtualKeyCodesMapping[v12];
9254 v13 = pGame->pKeyboardInstance;
9255 if ( pKeyActionMap->pToggleTypes[v12] )
9256 v14 = v13->WasKeyPressed(v22);
9257 else
9258 v14 = v13->IsKeyBeingHeld(v22);
9259 if ( v14 && v12 == 9 )
9260 {
9261 if ( !pCurrentScreen )
9262 {
9263 if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 )
9264 goto LABEL_175;
9265 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)404;
9266 goto LABEL_174;
9267 }
9268 if ( pCurrentScreen == 4
9269 || pCurrentScreen == 19 )
9270 {
9271 v15 = pMessageQueue_50CBD0->uNumMessages;
9272 if ( pMessageQueue_50CBD0->uNumMessages )
9273 {
9274 v15 = 0;
9275 if ( pMessageQueue_50CBD0->pMessages[0].field_8 )
9276 {
9277 v15 = 1;
9278 pMessageQueue_50CBD0->uNumMessages = 1;
9279 goto LABEL_173;
9280 }
9281 pMessageQueue_50CBD0->uNumMessages = 0;
9282 }
9283 if ( (signed int)v15 >= 40 )
9284 goto LABEL_175;
9285 LABEL_173:
9286 pMessageQueue_50CBD0->pMessages[v15].eType = (UIMessageType)113;
9287 LABEL_174:
9288 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
9289 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
9290 ++pMessageQueue_50CBD0->uNumMessages;
9291 goto LABEL_175;
9292 }
9293 }
9294 LABEL_175:
9295 ++v12;
9296 }
9297 while ( v12 < 30 );
9298 LABEL_176:
9299 if (pGame->pKeyboardInstance->bUsingAsynKeyboard)
9300 {
9301 AsyncKeyboard::LeaveCriticalSection();
9302 v16 = pAsyncKeyboard;
9303 AsyncKeyboard::EnterCriticalSection();
9304 memset((char *)v16 + 521, 0, 0x100u);
9305 AsyncKeyboard::LeaveCriticalSection();
9306 }
9307 }
9308