Mercurial > mm7
annotate mm7_6.cpp @ 1406:d071e0e9ba75
Explosion Traps fix
author | Ritor1 |
---|---|
date | Tue, 23 Jul 2013 15:41:45 +0600 |
parents | cc9a3a24d61d |
children | 9a1adf08f4ed |
rev | line source |
---|---|
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1160
diff
changeset
|
1 #ifdef _MSC_VER |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1160
diff
changeset
|
2 #define _CRT_SECURE_NO_WARNINGS |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1160
diff
changeset
|
3 #endif |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1160
diff
changeset
|
4 |
0 | 5 #include "MM7.h" |
6 | |
1016 | 7 |
8 | |
1323 | 9 #include "Weather.h" |
1016 | 10 #include "Sprites.h" |
11 #include "BSPModel.h" | |
12 #include "OutdoorCamera.h" | |
13 #include "Mouse.h" | |
14 #include "Keyboard.h" | |
15 #include "stru6.h" | |
16 | |
17 #include "Vis.h" | |
0 | 18 #include "Game.h" |
19 #include "GUIWindow.h" | |
20 #include "GUIFont.h" | |
21 #include "Party.h" | |
22 #include "AudioPlayer.h" | |
23 #include "Outdoor.h" | |
1277 | 24 #include "Outdoor_stuff.h" |
0 | 25 #include "Overlays.h" |
26 #include "LOD.h" | |
27 #include "Actor.h" | |
28 #include "Events.h" | |
29 #include "Viewport.h" | |
30 #include "Math.h" | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
490
diff
changeset
|
31 #include "SpriteObject.h" |
0 | 32 #include "ObjectList.h" |
33 #include "stru123.h" | |
34 #include "Time.h" | |
35 #include "IconFrameTable.h" | |
36 #include "Awards.h" | |
37 #include "TurnEngine.h" | |
924 | 38 #include "CastSpellInfo.h" |
0 | 39 #include "stru298.h" |
189 | 40 #include "texts.h" |
0 | 41 |
42 #include "mm7_data.h" | |
43 | |
44 | |
45 | |
46 //----- (00424EE0) -------------------------------------------------------- | |
47 signed int __fastcall sr_424EE0_MakeFanFromTriangle(unsigned int uVertexID) | |
48 { | |
49 unsigned int v1; // edx@1 | |
50 double v2; // st7@1 | |
51 signed int v3; // edi@1 | |
52 char *v4; // esi@4 | |
53 char *v5; // ecx@4 | |
54 unsigned int v6; // eax@4 | |
55 char *v7; // edx@4 | |
56 double v8; // st6@10 | |
57 double v9; // st5@10 | |
58 double v10; // st6@11 | |
59 unsigned __int8 v11; // c2@15 | |
60 unsigned __int8 v12; // c3@15 | |
61 void *v13; // edi@22 | |
62 char *v14; // eax@22 | |
63 double v15; // st6@22 | |
64 char *v16; // ecx@22 | |
65 signed int result; // eax@24 | |
66 unsigned int v18; // [sp+8h] [bp-2Ch]@4 | |
67 bool v19; // [sp+Ch] [bp-28h]@6 | |
68 char *v20; // [sp+10h] [bp-24h]@4 | |
69 char *v21; // [sp+14h] [bp-20h]@4 | |
70 signed int v22; // [sp+18h] [bp-1Ch]@1 | |
71 char *v23; // [sp+1Ch] [bp-18h]@4 | |
72 RenderVertexSoft *v24; // [sp+20h] [bp-14h]@4 | |
73 char *v25; // [sp+24h] [bp-10h]@4 | |
74 char *v26; // [sp+28h] [bp-Ch]@4 | |
75 char *v27; // [sp+2Ch] [bp-8h]@4 | |
76 char *v28; // [sp+30h] [bp-4h]@4 | |
77 | |
78 v1 = uVertexID; | |
79 v2 = (double)pOutdoorCamera->shading_dist_mist; | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
80 memcpy(&array_50AC10[uVertexID], array_50AC10, sizeof(array_50AC10[uVertexID])); |
0 | 81 v3 = 0; |
82 v22 = 0; | |
83 if ( array_50AC10[0].vWorldViewPosition.x <= v2 ) | |
84 v3 = 1; | |
85 if ( (signed int)(uVertexID + 1) <= 1 ) | |
86 return 0; | |
87 v4 = (char *)&array_507D30[0].vWorldViewPosition.z; | |
88 v5 = (char *)&array_507D30[0].vWorldViewPosition.y; | |
89 v6 = v1; | |
90 v23 = (char *)&array_507D30[0].flt_2C; | |
168 | 91 v26 = (char *)&array_507D30[0]._rhw; |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
92 v24 = array_507D30; |
0 | 93 v20 = (char *)&array_507D30[0].vWorldViewPosition.z; |
94 v21 = (char *)&array_507D30[0].vWorldViewPosition.y; | |
95 v25 = (char *)&array_507D30[0].vWorldViewPosition; | |
96 v27 = (char *)&array_507D30[0].v; | |
97 v28 = (char *)&array_507D30[0].u; | |
98 v7 = (char *)&array_50AC10[0].v; | |
99 v18 = v6; | |
100 do | |
101 { | |
102 v19 = v2 >= *((float *)v7 + 5); | |
103 if ( v3 != v19 ) | |
104 { | |
105 if ( v19 ) | |
106 { | |
107 v8 = (v2 - *((float *)v7 - 7)) / (*((float *)v7 + 5) - *((float *)v7 - 7)); | |
108 *(float *)v5 = (*((float *)v7 + 6) - *((float *)v7 - 6)) * v8 + *((float *)v7 - 6); | |
109 *(float *)v4 = (*((float *)v7 + 7) - *((float *)v7 - 5)) * v8 + *((float *)v7 - 5); | |
110 *(float *)v28 = (*((float *)v7 + 11) - *((float *)v7 - 1)) * v8 + *((float *)v7 - 1); | |
111 v9 = (*((float *)v7 + 12) - *(float *)v7) * v8 + *(float *)v7; | |
112 } | |
113 else | |
114 { | |
115 v10 = (v2 - *((float *)v7 + 5)) / (*((float *)v7 - 7) - *((float *)v7 + 5)); | |
116 *(float *)v5 = (*((float *)v7 - 6) - *((float *)v7 + 6)) * v10 + *((float *)v7 + 6); | |
117 *(float *)v4 = (*((float *)v7 - 5) - *((float *)v7 + 7)) * v10 + *((float *)v7 + 7); | |
118 *(float *)v28 = (*((float *)v7 - 1) - *((float *)v7 + 11)) * v10 + *((float *)v7 + 11); | |
119 v9 = (*(float *)v7 - *((float *)v7 + 12)) * v10 + *((float *)v7 + 12); | |
120 } | |
121 *(float *)v27 = v9; | |
122 *(float *)v25 = v2; | |
123 *(float *)v26 = 1.0 / v2; | |
124 if ( v3 ) | |
125 { | |
126 if ( v2 == *((float *)v7 - 7) && *(float *)v5 == *((float *)v7 - 6) ) | |
127 { | |
128 v11 = 0; | |
129 v12 = *(float *)v4 == *((float *)v7 - 5); | |
130 goto LABEL_19; | |
131 } | |
132 } | |
133 else | |
134 { | |
135 if ( v2 == *((float *)v7 + 5) && *(float *)v5 == *((float *)v7 + 6) ) | |
136 { | |
137 v11 = 0; | |
138 v12 = *(float *)v4 == *((float *)v7 + 7); | |
139 LABEL_19: | |
140 if ( v12 | v11 ) | |
141 goto LABEL_21; | |
142 goto LABEL_20; | |
143 } | |
144 } | |
145 LABEL_20: | |
146 v26 += 48; | |
147 ++v24; | |
148 v25 += 48; | |
149 v27 += 48; | |
150 v28 += 48; | |
151 v5 += 48; | |
152 v4 += 48; | |
153 ++v22; | |
154 v23 += 48; | |
155 v21 = v5; | |
156 v20 = v4; | |
157 } | |
158 LABEL_21: | |
159 if ( v19 ) | |
160 { | |
161 v13 = v24; | |
162 v14 = v26; | |
163 v21 += 48; | |
164 v15 = 1.0 / (*((float *)v7 + 5) + 0.0000001); | |
165 v20 += 48; | |
166 ++v22; | |
167 v28 += 48; | |
168 v27 += 48; | |
169 v25 += 48; | |
170 ++v24; | |
171 v26 += 48; | |
172 memcpy(v13, v7 + 8, 0x30u); | |
173 v16 = v23; | |
174 v23 += 48; | |
175 v4 = v20; | |
176 *(float *)v14 = v15; | |
177 *(int *)v16 = *((int *)v7 + 13); | |
178 v5 = v21; | |
179 } | |
180 v3 = v19; | |
181 v7 += 48; | |
182 --v18; | |
183 } | |
184 while ( v18 ); | |
185 result = v22; | |
186 if ( v22 < 3 ) | |
187 return 0; | |
188 return result; | |
189 } | |
190 | |
191 //----- (0042620A) -------------------------------------------------------- | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1384
diff
changeset
|
192 bool sr_42620A(RenderVertexSoft *p) |
0 | 193 { |
194 __int16 v1; // fps@1 | |
195 unsigned __int8 v2; // c0@2 | |
196 char v3; // c2@2 | |
197 unsigned __int8 v4; // c3@2 | |
198 bool result; // eax@2 | |
199 unsigned __int8 v6; // c0@4 | |
200 char v7; // c2@4 | |
201 unsigned __int8 v8; // c3@4 | |
202 unsigned __int8 v9; // c0@6 | |
203 char v10; // c2@6 | |
204 unsigned __int8 v11; // c3@6 | |
205 double v12; // st6@7 | |
206 float v13; // ST04_4@7 | |
207 float v14; // ST00_4@7 | |
208 double v15; // st7@7 | |
209 double v16; // st6@8 | |
210 float v17; // ST04_4@8 | |
211 float v18; // ST00_4@8 | |
212 double v19; // st7@8 | |
213 | |
214 //UNDEF(v1); | |
215 if ( p->vWorldViewPosition.x < 300.0 | |
216 || (v2 = 300.0 < p[1].vWorldViewPosition.x, | |
217 v3 = 0, | |
218 v4 = 300.0 == p[1].vWorldViewPosition.x, | |
921 | 219 //BYTE1(result) = HIBYTE(v1), |
0 | 220 !(v2 | v4)) ) |
221 { | |
222 if ( p->vWorldViewPosition.x < 300.0 ) | |
223 { | |
224 v6 = 300.0 < p[1].vWorldViewPosition.x; | |
225 v7 = 0; | |
226 v8 = 300.0 == p[1].vWorldViewPosition.x; | |
921 | 227 //BYTE1(result) = HIBYTE(v1); |
0 | 228 if ( !(v6 | v8) ) |
229 { | |
921 | 230 //LOBYTE(result) = 0; |
231 return false; | |
0 | 232 } |
233 } | |
234 v9 = 300.0 < p->vWorldViewPosition.x; | |
235 v10 = 0; | |
236 v11 = 300.0 == p->vWorldViewPosition.x; | |
921 | 237 //BYTE1(result) = HIBYTE(v1); |
0 | 238 if ( v9 | v11 ) |
239 { | |
240 v16 = 1.0 / (p->vWorldViewPosition.x - p[1].vWorldViewPosition.x); | |
241 v17 = (p->vWorldViewPosition.y - p[1].vWorldViewPosition.y) * v16; | |
242 v18 = (p->vWorldViewPosition.z - p[1].vWorldViewPosition.z) * v16; | |
243 v19 = 300.0 - p[1].vWorldViewPosition.x; | |
244 p[1].vWorldViewPosition.x = v19 + p[1].vWorldViewPosition.x; | |
245 p[1].vWorldViewPosition.y = v17 * v19 + p[1].vWorldViewPosition.y; | |
246 p[1].vWorldViewPosition.z = v19 * v18 + p[1].vWorldViewPosition.z; | |
247 } | |
248 else | |
249 { | |
250 v12 = 1.0 / (p[1].vWorldViewPosition.x - p->vWorldViewPosition.x); | |
251 v13 = (p[1].vWorldViewPosition.y - p->vWorldViewPosition.y) * v12; | |
252 v14 = (p[1].vWorldViewPosition.z - p->vWorldViewPosition.z) * v12; | |
253 v15 = 300.0 - p->vWorldViewPosition.x; | |
254 p->vWorldViewPosition.x = v15 + p->vWorldViewPosition.x; | |
255 p->vWorldViewPosition.y = v13 * v15 + p->vWorldViewPosition.y; | |
256 p->vWorldViewPosition.z = v15 * v14 + p->vWorldViewPosition.z; | |
257 } | |
258 } | |
921 | 259 //LOBYTE(result) = 1; |
260 return true; | |
0 | 261 } |
262 | |
263 //----- (004268E3) -------------------------------------------------------- | |
264 int __fastcall _4268E3_smthn_to_a1r5g5b5(unsigned int uColor) | |
265 { | |
266 unsigned int v1; // eax@1 | |
267 unsigned int v2; // edx@1 | |
268 int v3; // eax@1 | |
269 int v4; // edx@1 | |
270 unsigned int v5; // ecx@1 | |
271 | |
272 v1 = uColor >> 9; | |
273 v2 = uColor >> 6; | |
274 LOWORD(v1) = (uColor >> 9) & 0x7C00; | |
275 LOWORD(v2) = (uColor >> 6) & 0x3E0; | |
276 v3 = v2 | v1; | |
277 v4 = (unsigned __int8)uColor >> 3; | |
278 v5 = uColor >> 16; | |
279 LOWORD(v5) = v5 & 0x8000; | |
280 return v5 | v4 | v3; | |
281 } | |
282 | |
283 //----- (0042690D) -------------------------------------------------------- | |
284 int __fastcall _42690D_colors_cvt(unsigned int a1) | |
285 { | |
286 unsigned int v1; // eax@1 | |
287 unsigned int v2; // edx@1 | |
288 | |
289 v1 = a1 >> 8; | |
290 v2 = a1 >> 5; | |
291 LOWORD(v1) = (a1 >> 8) & 0xF800; | |
292 LOWORD(v2) = (a1 >> 5) & 0x7E0; | |
293 return ((unsigned __int8)a1 >> 3) | v2 | v1; | |
294 } | |
295 //----- (00426947) -------------------------------------------------------- | |
296 void __cdecl sub_426947() | |
297 { | |
893 | 298 stru_50C198.field_0 = 0; |
0 | 299 dword_50C994 = 0; |
300 dword_50C998_turnbased_icon_1A = 0; | |
301 } | |
302 // 50C968: using guessed type int dword_50C968; | |
303 // 50C994: using guessed type int dword_50C994; | |
304 // 50C998: using guessed type int dword_50C998_turnbased_icon_1A; | |
305 | |
306 //----- (00426A5A) -------------------------------------------------------- | |
307 void stru319::LootActor(Actor *pActor) | |
308 { | |
309 signed int v2; // edi@1 | |
310 char v3; // zf@1 | |
311 unsigned int v4; // eax@13 | |
312 unsigned int v5; // esi@13 | |
313 int v6; // eax@14 | |
314 unsigned __int8 v7; // al@30 | |
315 Party *v8; // esi@34 | |
316 char *v9; // [sp-4h] [bp-3Ch]@10 | |
317 char *v10; // [sp-4h] [bp-3Ch]@31 | |
318 char *v11; // [sp-4h] [bp-3Ch]@38 | |
319 ItemGen Dst; // [sp+Ch] [bp-2Ch]@1 | |
320 int v13; // [sp+30h] [bp-8h]@1 | |
321 int v14; // [sp+34h] [bp-4h]@1 | |
322 | |
323 sub_421B2C_PlaceInInventory_or_DropPickedItem(); | |
324 Dst.Reset(); | |
325 v2 = 0; | |
326 v3 = ((unsigned int)&array_77EC08[1975].pEdgeList1[1] & pActor->uAttributes) == 0; | |
327 v13 = 0; | |
328 v14 = 0; | |
329 if ( v3 ) | |
330 { | |
331 if ( !pActor->pMonsterInfo.uTreasureDiceRolls ) | |
332 goto LABEL_9; | |
333 do | |
334 { | |
335 ++v2; | |
336 v14 += rand() % pActor->pMonsterInfo.uTreasureDiceSides + 1; | |
337 } | |
338 while ( v2 < pActor->pMonsterInfo.uTreasureDiceRolls ); | |
339 } | |
340 else | |
341 { | |
342 if ( pItemsTable->pItems[pActor->array_000234[3].uItemID].uEquipType != 18 ) | |
343 goto LABEL_9; | |
377 | 344 v14 = pActor->array_000234[3].uSpecEnchantmentType; |
0 | 345 pActor->array_000234[3].Reset(); |
346 } | |
347 if ( v14 ) | |
348 { | |
349 party_finds_gold(v14, 0); | |
350 viewparams->bRedrawGameUI = 1; | |
351 } | |
352 LABEL_9: | |
353 if ( pActor->uCarriedItemID ) | |
354 { | |
355 Dst.Reset(); | |
356 Dst.uItemID = pActor->uCarriedItemID; | |
357 v9 = pItemsTable->pItems[Dst.uItemID].pUnidentifiedName; | |
358 if ( v14 ) | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
359 sprintfex(pTmpBuf2.data(), (char*)pGlobalTXT_LocalizationStrings[490], v14, v9); |
0 | 360 else |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
361 sprintfex(pTmpBuf2.data(), (char*)pGlobalTXT_LocalizationStrings[471], v9); |
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
362 ShowStatusBarString(pTmpBuf2.data(), 2u); |
0 | 363 v4 = Dst.uItemID; |
364 v5 = Dst.uItemID; | |
365 if ( pItemsTable->pItems[Dst.uItemID].uEquipType == 12 ) | |
366 { | |
367 v5 = Dst.uItemID; | |
368 v6 = rand() % 6 + pItemsTable->pItems[Dst.uItemID].uDamageMod + 1; | |
369 Dst.uNumCharges = v6; | |
370 Dst.uMaxCharges = v6; | |
371 v4 = Dst.uItemID; | |
372 } | |
373 if ( pItemsTable->pItems[v5].uEquipType == 14 && v4 != 220 ) | |
570 | 374 Dst.uEnchantmentType = 2 * rand() % 4 + 2; |
0 | 375 pItemsTable->SetSpecialBonus(&Dst); |
376 if ( !pParty->AddItem(&Dst) ) | |
377 pParty->SetHoldingItem(&Dst); | |
378 pActor->uCarriedItemID = 0; | |
379 if ( pActor->array_000234[0].uItemID ) | |
380 { | |
381 if ( !pParty->AddItem(pActor->array_000234) ) | |
382 { | |
383 sub_421B2C_PlaceInInventory_or_DropPickedItem(); | |
384 pParty->SetHoldingItem(pActor->array_000234); | |
385 } | |
386 pActor->array_000234[0].Reset(); | |
387 } | |
388 if ( pActor->array_000234[1].uItemID ) | |
389 { | |
390 if ( !pParty->AddItem(&pActor->array_000234[1]) ) | |
391 { | |
392 sub_421B2C_PlaceInInventory_or_DropPickedItem(); | |
393 pParty->SetHoldingItem(&pActor->array_000234[1]); | |
394 } | |
395 pActor->array_000234[1].Reset(); | |
396 } | |
397 LABEL_55: | |
398 pActor->Remove(); | |
399 return; | |
400 } | |
401 if ( (unsigned int)&array_77EC08[1975].pEdgeList1[1] & pActor->uAttributes ) | |
402 { | |
403 if ( pActor->array_000234[3].uItemID ) | |
404 { | |
405 memcpy(&Dst, &pActor->array_000234[3], sizeof(Dst)); | |
406 pActor->array_000234[3].Reset(); | |
407 v11 = pItemsTable->pItems[Dst.uItemID].pUnidentifiedName; | |
408 if ( v14 ) | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
409 sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[490], v14, v11); |
0 | 410 else |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
411 sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], v11); |
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
412 ShowStatusBarString(pTmpBuf2.data(), 2u); |
0 | 413 if ( !pParty->AddItem(&Dst) ) |
414 pParty->SetHoldingItem(&Dst); | |
415 v13 = 1; | |
416 } | |
417 goto LABEL_44; | |
418 } | |
419 if ( rand() % 100 >= pActor->pMonsterInfo.uTreasureDropChance || (v7 = pActor->pMonsterInfo.uTreasureLevel) == 0 ) | |
420 { | |
421 LABEL_44: | |
422 v8 = pParty; | |
423 goto LABEL_45; | |
424 } | |
425 pItemsTable->GenerateItem(v7, pActor->pMonsterInfo.uTreasureType, &Dst); | |
426 v10 = pItemsTable->pItems[Dst.uItemID].pUnidentifiedName; | |
427 if ( v14 ) | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
428 sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[490], v14, v10); |
0 | 429 else |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
430 sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], v10); |
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
431 ShowStatusBarString(pTmpBuf2.data(), 2u); |
0 | 432 v8 = pParty; |
433 if ( !pParty->AddItem(&Dst) ) | |
434 pParty->SetHoldingItem(&Dst); | |
435 v13 = 1; | |
436 LABEL_45: | |
437 if ( pActor->array_000234[0].uItemID ) | |
438 { | |
439 if ( !v8->AddItem(pActor->array_000234) ) | |
440 { | |
441 sub_421B2C_PlaceInInventory_or_DropPickedItem(); | |
442 v8->SetHoldingItem(pActor->array_000234); | |
443 v13 = 1; | |
444 } | |
445 pActor->array_000234[0].Reset(); | |
446 } | |
447 if ( pActor->array_000234[1].uItemID ) | |
448 { | |
449 if ( !v8->AddItem(&pActor->array_000234[1]) ) | |
450 { | |
451 sub_421B2C_PlaceInInventory_or_DropPickedItem(); | |
452 v8->SetHoldingItem(&pActor->array_000234[1]); | |
453 v13 = 1; | |
454 } | |
455 pActor->array_000234[1].Reset(); | |
456 } | |
457 if ( !v13 || rand() % 100 < 90 ) | |
458 goto LABEL_55; | |
459 } | |
460 | |
461 //----- (00426E10) -------------------------------------------------------- | |
462 int stru319::which_player_would_attack(Actor *pActor) | |
463 { | |
464 signed int v2; // ebx@1 | |
465 int v3; // ecx@2 | |
466 signed int v4; // edx@3 | |
467 char v5; // zf@3 | |
468 unsigned int v6; // eax@3 | |
469 int v7; // eax@6 | |
470 int v8; // eax@7 | |
471 int v9; // eax@8 | |
472 int v10; // eax@9 | |
473 int v11; // eax@10 | |
474 int v12; // eax@11 | |
475 int v13; // esi@35 | |
476 signed int v14; // edi@37 | |
477 enum CHARACTER_RACE v15; // eax@44 | |
478 Player *v16; // ecx@47 | |
479 unsigned __int8 v17; // sf@50 | |
480 unsigned __int8 v18; // of@50 | |
481 int v19; // esi@52 | |
482 Player *v20; // ecx@53 | |
483 int result; // eax@57 | |
484 int v22[16]; // [sp+8h] [bp-140h]@3 | |
485 int v23[60]; // [sp+48h] [bp-100h]@48 | |
486 int v24; // [sp+138h] [bp-10h]@2 | |
487 int v25; // [sp+13Ch] [bp-Ch]@1 | |
488 int v26; // [sp+140h] [bp-8h]@1 | |
489 int v27; // [sp+144h] [bp-4h]@1 | |
490 | |
491 v27 = -1; | |
492 v26 = -1; | |
493 v25 = -1; | |
494 v2 = 0; | |
495 if ( pActor->pMonsterInfo.uAttackPreference ) | |
496 { | |
497 v3 = 0; | |
498 v24 = 0; | |
499 do | |
500 { | |
501 v4 = 1; | |
502 v6 = pActor->pMonsterInfo.uAttackPreference & (1 << v3); | |
503 v5 = (pActor->pMonsterInfo.uAttackPreference & (1 << v3)) == 0; | |
504 v22[v3] = v6; | |
505 if ( !v5 ) | |
506 { | |
507 if ( (signed int)v6 > 128 ) | |
508 { | |
509 switch ( v6 ) | |
510 { | |
511 case 0x100u: | |
512 v27 = 8; | |
513 break; | |
514 case 0x200u: | |
515 v25 = 0; | |
516 break; | |
517 case 0x400u: | |
518 v25 = 1; | |
519 break; | |
520 case 0x800u: | |
521 v26 = 0; | |
522 break; | |
523 case 0x1000u: | |
524 v26 = 1; | |
525 break; | |
526 case 0x2000u: | |
527 v26 = 3; | |
528 break; | |
529 case 0x4000u: | |
530 v26 = 2; | |
531 break; | |
532 } | |
533 } | |
534 else | |
535 { | |
536 if ( v6 == 128 ) | |
537 { | |
538 v27 = 4; | |
539 } | |
540 else | |
541 { | |
542 v7 = v6 - 1; | |
543 if ( v7 ) | |
544 { | |
545 v8 = v7 - 1; | |
546 if ( v8 ) | |
547 { | |
548 v9 = v8 - 2; | |
549 if ( v9 ) | |
550 { | |
551 v10 = v9 - 4; | |
552 if ( v10 ) | |
553 { | |
554 v11 = v10 - 8; | |
555 if ( v11 ) | |
556 { | |
557 v12 = v11 - 16; | |
558 if ( v12 ) | |
559 { | |
560 if ( v12 == 32 ) | |
561 v27 = 20; | |
562 } | |
563 else | |
564 { | |
565 v27 = 32; | |
566 } | |
567 } | |
568 else | |
569 { | |
570 v27 = 24; | |
571 } | |
572 } | |
573 else | |
574 { | |
575 v27 = 28; | |
576 } | |
577 } | |
578 else | |
579 { | |
580 v27 = 16; | |
581 } | |
582 } | |
583 else | |
584 { | |
585 v27 = 12; | |
586 } | |
587 } | |
588 else | |
589 { | |
590 v27 = 0; | |
591 } | |
592 } | |
593 } | |
594 v2 = 0; | |
595 v13 = 0; | |
596 while ( 1 ) | |
597 { | |
598 v14 = 0; | |
135 | 599 if ( v27 != -1 && v27 == pPlayers[v13 + 1]->classType ) |
0 | 600 v14 = v4; |
601 if ( v25 != -1 && v25 == pPlayers[v13 + 1]->uSex ) | |
602 v14 = v4; | |
603 if ( v26 != -1 ) | |
604 { | |
605 v15 = pPlayers[v13 + 1]->GetRace(); | |
606 if ( v26 == v15 ) | |
607 v14 = 1; | |
608 } | |
609 if ( v14 == 1 ) | |
610 { | |
611 v16 = pPlayers[v13 + 1]; | |
612 if ( !(v16->pConditions[12] | v16->pConditions[13] | v16->pConditions[14] | v16->pConditions[15] | v16->pConditions[16]) ) | |
613 v23[v2++] = v13; | |
614 } | |
615 ++v13; | |
616 if ( v13 >= 4 ) | |
617 break; | |
618 v4 = 1; | |
619 } | |
620 } | |
621 v3 = v24 + 1; | |
622 v18 = __OFSUB__(v24 + 1, 15); | |
623 v17 = v24++ - 14 < 0; | |
624 } | |
625 while ( v17 ^ v18 ); | |
626 if ( v2 ) | |
627 goto LABEL_61; | |
628 } | |
629 v19 = 0; | |
630 do | |
631 { | |
632 v20 = pPlayers[v19 + 1]; | |
633 if ( !(v20->pConditions[12] | v20->pConditions[13] | v20->pConditions[14] | v20->pConditions[15] | v20->pConditions[16]) ) | |
634 v23[v2++] = v19; | |
635 ++v19; | |
636 } | |
637 while ( v19 < 4 ); | |
638 if ( v2 ) | |
639 LABEL_61: | |
640 result = v23[rand() % v2]; | |
641 else | |
642 result = 0; | |
643 return result; | |
644 } | |
645 | |
646 //----- (0042704B) -------------------------------------------------------- | |
647 bool stru319::special_ability_use_check(Actor *pActor, int a2) | |
648 { | |
649 stru319 *v3; // edi@1 | |
650 signed int v4; // ebx@5 | |
651 signed int v5; // edi@5 | |
652 | |
653 v3 = this; | |
654 if ( pActor->pMonsterInfo.uSpecialAbilityType == 2 | |
655 && pActor->pMonsterInfo.uSpecialAbilityDamageDiceBonus < 3u | |
656 && rand() % 100 < 5 ) | |
657 pActor->_44FD29(a2); | |
658 v4 = v3->_427102(pActor, pActor->pMonsterInfo.uSpell1ID); | |
659 v5 = v3->_427102(pActor, pActor->pMonsterInfo.uSpell2ID); | |
660 if ( v4 && pActor->pMonsterInfo.uSpell1UseChance && rand() % 100 < pActor->pMonsterInfo.uSpell1UseChance ) | |
661 return 2; | |
662 if ( v5 && pActor->pMonsterInfo.uSpell2UseChance && rand() % 100 < pActor->pMonsterInfo.uSpell2UseChance ) | |
663 return 3; | |
664 return pActor->pMonsterInfo.uAttack2Chance && rand() % 100 < pActor->pMonsterInfo.uAttack2Chance; | |
665 } | |
666 | |
667 //----- (00427102) -------------------------------------------------------- | |
668 int stru319::_427102(Actor *pActor, signed int a2) | |
669 { | |
670 unsigned __int8 v3; // cf@11 | |
671 unsigned __int8 v4; // zf@11 | |
672 SpellBuff *v6; // ecx@46 | |
89 | 673 Player *v7; // esi@49 |
0 | 674 signed int v8; // edx@50 |
89 | 675 SpellBuff *v9; // ecx@50 |
0 | 676 |
597 | 677 switch(a2) |
0 | 678 { |
597 | 679 case 77: |
680 { | |
681 if ( pActor->sCurrentHP >= (signed int)pActor->pMonsterInfo.uHP ) | |
682 return 0; | |
683 return 1; | |
684 } | |
685 case 80: | |
686 { | |
687 v6 = pParty->pPartyBuffs; | |
688 while ( (signed __int64)v6->uExpireTime <= 0 ) | |
689 { | |
690 ++v6; | |
1167 | 691 if ( v6 > &pParty->pPartyBuffs[PARTY_BUFF_WIZARD_EYE] ) |
597 | 692 { |
693 v7 = pParty->pPlayers;//[0].pPlayerBuffs; | |
694 v8 = 0; | |
695 v9 = v7->pPlayerBuffs; | |
696 while ( v9->uExpireTime <= 0i64 ) | |
697 { | |
698 ++v8; | |
699 ++v9; | |
700 if ( v8 >= 24 ) | |
701 { | |
702 ++v7; | |
703 if ( v7 <= &pParty->pPlayers[3] ) | |
704 { | |
705 v8 = 0; | |
706 v9 = v7->pPlayerBuffs; | |
707 } | |
708 else | |
709 return 0; | |
710 } | |
711 } | |
712 return 1; | |
713 } | |
714 } | |
715 return 1; | |
716 } | |
717 case 85: | |
718 { | |
719 if ( SHIDWORD(pActor->pActorBuffs[13].uExpireTime) < 0 ) | |
720 return 1; | |
721 if ( SHIDWORD(pActor->pActorBuffs[13].uExpireTime) > 0 ) | |
722 return 0; | |
723 v3 = 0; | |
724 v4 = LODWORD(pActor->pActorBuffs[13].uExpireTime) == 0; | |
725 break; | |
726 } | |
727 case 86: | |
728 { | |
0 | 729 if ( SHIDWORD(pActor->pActorBuffs[14].uExpireTime) < 0 ) |
597 | 730 return 1; |
0 | 731 if ( SHIDWORD(pActor->pActorBuffs[14].uExpireTime) > 0 ) |
597 | 732 return 0; |
0 | 733 v3 = 0; |
734 v4 = LODWORD(pActor->pActorBuffs[14].uExpireTime) == 0; | |
597 | 735 break; |
736 } | |
737 case 95: | |
738 { | |
739 if ( SHIDWORD(pActor->pActorBuffs[20].uExpireTime) < 0 ) | |
740 return 1; | |
0 | 741 if ( SHIDWORD(pActor->pActorBuffs[20].uExpireTime) > 0 ) |
597 | 742 return 0; |
0 | 743 v3 = 0; |
744 v4 = LODWORD(pActor->pActorBuffs[20].uExpireTime) == 0; | |
597 | 745 break; |
746 } | |
747 case 73: | |
748 { | |
749 if ( SHIDWORD(pActor->pActorBuffs[21].uExpireTime) < 0 ) | |
750 return 1; | |
751 if ( SHIDWORD(pActor->pActorBuffs[21].uExpireTime) > 0 ) | |
752 return 0; | |
753 v3 = 0; | |
754 v4 = LODWORD(pActor->pActorBuffs[21].uExpireTime) == 0; | |
755 break; | |
756 } | |
757 case 5: | |
758 { | |
759 if ( SHIDWORD(pActor->pActorBuffs[19].uExpireTime) < 0 ) | |
760 return 1; | |
761 if ( SHIDWORD(pActor->pActorBuffs[19].uExpireTime) > 0 ) | |
762 return 0; | |
763 v3 = 0; | |
764 v4 = LODWORD(pActor->pActorBuffs[19].uExpireTime) == 0; | |
765 break; | |
766 } | |
767 case 17: | |
768 { | |
769 if ( SHIDWORD(pActor->pActorBuffs[15].uExpireTime) < 0 ) | |
770 return 1; | |
771 if ( SHIDWORD(pActor->pActorBuffs[15].uExpireTime) > 0 ) | |
772 return 0; | |
773 v3 = 0; | |
774 v4 = LODWORD(pActor->pActorBuffs[15].uExpireTime) == 0; | |
775 break; | |
776 } | |
777 case 38: | |
89 | 778 { |
597 | 779 if ( SHIDWORD(pActor->pActorBuffs[16].uExpireTime) < 0 ) |
780 return 1; | |
781 if ( SHIDWORD(pActor->pActorBuffs[16].uExpireTime) > 0 ) | |
782 return 0; | |
783 v3 = 0; | |
784 v4 = LODWORD(pActor->pActorBuffs[16].uExpireTime) == 0; | |
785 } | |
786 case 46: | |
787 { | |
788 if ( SHIDWORD(pActor->pActorBuffs[17].uExpireTime) < 0 ) | |
89 | 789 return 1; |
597 | 790 if ( SHIDWORD(pActor->pActorBuffs[17].uExpireTime) > 0 ) |
791 return 0; | |
792 v3 = 0; | |
793 v4 = LODWORD(pActor->pActorBuffs[17].uExpireTime) == 0; | |
794 break; | |
795 } | |
796 case 47: | |
797 { | |
798 if ( SHIDWORD(pActor->pActorBuffs[11].uExpireTime) < 0 ) | |
799 return 1; | |
800 if ( SHIDWORD(pActor->pActorBuffs[11].uExpireTime) > 0 ) | |
801 return 0; | |
802 v3 = 0; | |
803 v4 = LODWORD(pActor->pActorBuffs[11].uExpireTime) == 0; | |
804 break; | |
805 } | |
806 case 51: | |
807 { | |
808 if ( SHIDWORD(pActor->pActorBuffs[18].uExpireTime) < 0 ) | |
809 return 1; | |
810 if ( SHIDWORD(pActor->pActorBuffs[18].uExpireTime) <= 0 ) | |
811 { | |
89 | 812 v3 = 0; |
813 v4 = LODWORD(pActor->pActorBuffs[18].uExpireTime) == 0; | |
814 } | |
815 else | |
597 | 816 return 0; |
817 break; | |
818 } | |
819 default: | |
89 | 820 { |
597 | 821 return 1; |
89 | 822 } |
0 | 823 } |
824 if ( !(v3 | v4) ) | |
825 return 0; | |
826 return 1; | |
827 } | |
828 | |
829 //----- (004272F5) -------------------------------------------------------- | |
830 int stru319::PlayerHitOrMiss(Player *pPlayer, Actor *pActor, int a3, int a4) | |
831 { | |
832 signed int v5; // esi@1 | |
833 signed int v6; // edi@1 | |
834 int v7; // esi@8 | |
835 int v8; // eax@9 | |
836 int v9; // edx@11 | |
837 int v10; // edx@13 | |
838 int v11; // esi@13 | |
839 unsigned __int8 v12; // sf@13 | |
840 unsigned __int8 v13; // of@13 | |
841 int v14; // edx@14 | |
842 int v15; // eax@14 | |
843 signed int result; // eax@17 | |
844 | |
845 v5 = pActor->pMonsterInfo.uAC; | |
846 v6 = 0; | |
847 if ( (signed __int64)pActor->pActorBuffs[8].uExpireTime > 0 ) | |
848 v5 /= 2; | |
849 if ( (signed __int64)pActor->pActorBuffs[14].uExpireTime > 0 ) | |
850 v6 = pActor->pActorBuffs[15].uPower; | |
851 if ( (signed __int64)pActor->pActorBuffs[16].uExpireTime > 0 && pActor->pActorBuffs[16].uPower > v6 ) | |
852 v6 = pActor->pActorBuffs[16].uPower; | |
853 v7 = v6 + v5; | |
854 if ( a3 ) | |
855 v8 = pPlayer->GetRangedAttack(); | |
856 else | |
857 v8 = pPlayer->GetActualAttack(0); | |
858 v9 = rand() % (v7 + 2 * v8 + 30); | |
859 if ( a3 == 2 ) | |
860 { | |
861 v14 = a4 + v9; | |
862 v15 = ((v7 + 15) >> 1) + v7 + 15; | |
863 } | |
864 else | |
865 { | |
866 if ( a3 != 3 ) | |
867 { | |
868 v10 = a4 + v9; | |
869 v11 = v7 + 15; | |
870 v13 = __OFSUB__(v10, v11); | |
871 v12 = v10 - v11 < 0; | |
872 goto LABEL_16; | |
873 } | |
874 v14 = a4 + v9; | |
875 v15 = 2 * v7 + 30; | |
876 } | |
877 v13 = __OFSUB__(v14, v15); | |
878 v12 = v14 - v15 < 0; | |
879 LABEL_16: | |
880 if ( v12 ^ v13 ) | |
881 result = 0; | |
882 else | |
883 result = 1; | |
884 return result; | |
885 } | |
886 | |
887 //----- (004273BB) -------------------------------------------------------- | |
888 bool stru319::_4273BB(Actor *pActor, Actor *a2, int a3, int a4) | |
889 { | |
890 Actor *v5; // ecx@1 | |
891 signed int v6; // ebx@1 | |
892 signed int v7; // esi@1 | |
893 unsigned __int8 v8; // zf@1 | |
894 unsigned __int8 v9; // sf@1 | |
895 int v10; // ebx@10 | |
896 signed int a2a; // [sp+18h] [bp+Ch]@1 | |
897 | |
898 v5 = a2; | |
899 v6 = a2->pMonsterInfo.uAC; | |
900 v7 = 0; | |
901 v8 = HIDWORD(a2->pActorBuffs[8].uExpireTime) == 0; | |
902 v9 = SHIDWORD(a2->pActorBuffs[8].uExpireTime) < 0; | |
903 a2a = 0; | |
904 if ( !v9 && (!(v9 | v8) || LODWORD(v5->pActorBuffs[8].uExpireTime) > 0) ) | |
905 v6 /= 2; | |
906 if ( (signed __int64)v5->pActorBuffs[14].uExpireTime > 0 ) | |
907 v7 = v5->pActorBuffs[14].uPower; | |
908 if ( (signed __int64)v5->pActorBuffs[16].uExpireTime > 0 && v5->pActorBuffs[16].uPower > v7 ) | |
909 v7 = v5->pActorBuffs[16].uPower; | |
910 v10 = v7 + v6; | |
911 if ( (signed __int64)pActor->pActorBuffs[14].uExpireTime > 0 ) | |
912 a2a = pActor->pActorBuffs[14].uPower; | |
913 if ( (signed __int64)pActor->pActorBuffs[17].uExpireTime > 0 && pActor->pActorBuffs[17].uPower > a2a ) | |
914 a2a = pActor->pActorBuffs[17].uPower; | |
915 if ( (signed __int64)pActor->pActorBuffs[11].uExpireTime > 0 ) | |
916 { | |
917 a2a += pActor->pActorBuffs[11].uPower; | |
918 pActor->pActorBuffs[11].Reset(); | |
919 } | |
920 return rand() % (v10 + 2 * pActor->pMonsterInfo.uLevel + 10) + a2a + 1 > v10 + 5; | |
921 } | |
922 | |
923 //----- (004274AD) -------------------------------------------------------- | |
924 bool stru319::ActorHitOrMiss(Actor *pActor, Player *pPlayer) | |
925 { | |
926 signed int v3; // edi@1 | |
927 signed int v4; // esi@8 | |
928 int v5; // esi@8 | |
929 | |
930 v3 = 0; | |
931 if ( (signed __int64)pActor->pActorBuffs[14].uExpireTime > 0 ) | |
932 v3 = pActor->pActorBuffs[14].uPower; | |
933 if ( (signed __int64)pActor->pActorBuffs[17].uExpireTime > 0 && pActor->pActorBuffs[17].uPower > v3 ) | |
934 v3 = pActor->pActorBuffs[17].uPower; | |
935 if ( (signed __int64)pActor->pActorBuffs[11].uExpireTime > 0 ) | |
936 { | |
937 v3 += pActor->pActorBuffs[11].uPower; | |
938 pActor->pActorBuffs[11].Reset(); | |
939 } | |
940 v4 = pPlayer->GetActualAC() + 2 * pActor->pMonsterInfo.uLevel + 10; | |
941 v5 = rand() % v4 + 1; | |
942 return v3 + v5 > pPlayer->GetActualAC() + 5; | |
943 } | |
944 | |
945 //----- (00427546) -------------------------------------------------------- | |
946 int stru319::_427546(int a2) | |
947 { | |
948 int result; // eax@2 | |
949 | |
950 if ( a2 >= 0 ) | |
951 { | |
952 if ( a2 >= 1 ) | |
953 result = (a2 >= 2) + 2; | |
954 else | |
955 result = 1; | |
956 } | |
957 else | |
958 { | |
959 result = 0; | |
960 } | |
961 return result; | |
962 } | |
963 | |
964 //----- (0042756B) -------------------------------------------------------- | |
965 int stru319::CalcMagicalDamageToActor(Actor *pActor, int a2, signed int a3) | |
966 { | |
967 int v4; // edx@1 | |
968 int v5; // ecx@1 | |
969 signed int v6; // eax@4 | |
970 signed int result; // eax@17 | |
971 signed int v8; // esi@18 | |
972 | |
973 v4 = 0; | |
974 v5 = 0; | |
975 if ( (signed __int64)pActor->pActorBuffs[14].uExpireTime > 0 ) | |
976 v5 = pActor->pActorBuffs[14].uPower; | |
977 switch ( a2 ) | |
978 { | |
979 case 4: | |
980 v6 = pActor->pMonsterInfo.uResPhysical; | |
981 break; | |
982 case 0: | |
983 v6 = pActor->pMonsterInfo.uResFire; | |
984 goto LABEL_12; | |
985 case 1: | |
986 v6 = pActor->pMonsterInfo.uResAir; | |
987 goto LABEL_12; | |
988 case 2: | |
989 v6 = pActor->pMonsterInfo.uResWater; | |
990 goto LABEL_12; | |
991 case 3: | |
992 v6 = pActor->pMonsterInfo.uResEarth; | |
993 goto LABEL_12; | |
994 case 6: | |
995 v6 = pActor->pMonsterInfo.uResSpirit; | |
996 break; | |
997 case 7: | |
998 v6 = pActor->pMonsterInfo.uResMind; | |
999 goto LABEL_12; | |
1000 case 8: | |
1001 v6 = pActor->pMonsterInfo.uResBody; | |
1002 LABEL_12: | |
1003 v4 = v5; | |
1004 break; | |
1005 case 9: | |
1006 v6 = pActor->pMonsterInfo.uResLight; | |
1007 break; | |
1008 case 10: | |
1009 v6 = pActor->pMonsterInfo.uResDark; | |
1010 break; | |
1011 default: | |
1012 v6 = 0; | |
1013 break; | |
1014 } | |
1015 if ( v6 < 200 ) | |
1016 { | |
1017 v8 = v4 + v6 + 30; | |
1018 if ( rand() % v8 >= 30 ) | |
1019 { | |
1020 a3 >>= 1; | |
1021 if ( rand() % v8 >= 30 ) | |
1022 { | |
1023 a3 >>= 1; | |
1024 if ( rand() % v8 >= 30 ) | |
1025 { | |
1026 a3 >>= 1; | |
1027 if ( rand() % v8 >= 30 ) | |
1028 a3 >>= 1; | |
1029 } | |
1030 } | |
1031 } | |
1032 result = a3; | |
1033 } | |
1034 else | |
1035 { | |
1036 result = 0; | |
1037 } | |
1038 return result; | |
1039 } | |
1040 | |
1041 //----- (00427662) -------------------------------------------------------- | |
1042 bool stru319::GetMagicalResistance(Actor *pActor, unsigned int uType) | |
1043 { | |
1044 Actor *v3; // edi@2 | |
1045 signed int v4; // esi@2 | |
1046 bool result; // eax@13 | |
1047 | |
1048 switch ( uType ) | |
1049 { | |
1050 case 0u: | |
1051 v3 = pActor; | |
1052 v4 = pActor->pMonsterInfo.uResFire; | |
1053 goto LABEL_12; | |
1054 case 1u: | |
1055 v3 = pActor; | |
1056 v4 = pActor->pMonsterInfo.uResAir; | |
1057 goto LABEL_12; | |
1058 case 2u: | |
1059 v3 = pActor; | |
1060 v4 = pActor->pMonsterInfo.uResWater; | |
1061 goto LABEL_12; | |
1062 case 3u: | |
1063 v3 = pActor; | |
1064 v4 = pActor->pMonsterInfo.uResEarth; | |
1065 goto LABEL_12; | |
1066 case 7u: | |
1067 v3 = pActor; | |
1068 v4 = pActor->pMonsterInfo.uResMind; | |
1069 goto LABEL_12; | |
1070 case 6u: | |
1071 v3 = pActor; | |
1072 v4 = pActor->pMonsterInfo.uResSpirit; | |
1073 goto LABEL_12; | |
1074 case 8u: | |
1075 v3 = pActor; | |
1076 v4 = pActor->pMonsterInfo.uResBody; | |
1077 goto LABEL_12; | |
1078 case 9u: | |
1079 v3 = pActor; | |
1080 v4 = pActor->pMonsterInfo.uResLight; | |
1081 goto LABEL_12; | |
1082 case 0xAu: | |
1083 v3 = pActor; | |
1084 v4 = pActor->pMonsterInfo.uResDark; | |
1085 goto LABEL_12; | |
1086 case 4u: | |
1087 v3 = pActor; | |
1088 v4 = pActor->pMonsterInfo.uResPhysical; | |
1089 LABEL_12: | |
1090 if ( v4 < 200 ) | |
1091 result = rand() % (signed int)(((unsigned int)v3->pMonsterInfo.uLevel >> 2) + v4 + 30) < 30; | |
1092 else | |
1093 result = 0; | |
1094 break; | |
1095 default: | |
1096 result = 1; | |
1097 break; | |
1098 } | |
1099 return result; | |
1100 } | |
1101 | |
1102 //----- (0042EB8D) -------------------------------------------------------- | |
437 | 1103 void GUIMessageQueue::AddMessageImpl(UIMessageType msg, int param, unsigned int a4, const char *file, int line) |
0 | 1104 { |
482 | 1105 //Log::Warning(L"%s @ (%S %u)", UIMessage2String(msg), file, line); |
0 | 1106 if (uNumMessages < 40) |
1107 { | |
437 | 1108 files[uNumMessages] = file; |
1109 lines[uNumMessages] = line; | |
1110 | |
0 | 1111 pMessages[uNumMessages].eType = msg; |
1112 pMessages[uNumMessages].param = param; | |
1113 pMessages[uNumMessages++].field_8 = a4; | |
1114 } | |
1115 } | |
1116 | |
1117 //----- (0042EBBE) -------------------------------------------------------- | |
1118 int __fastcall sub_42EBBE(int a1, int a2) | |
1119 { | |
1120 return (unsigned __int64)(a2 * (signed __int64)a1) >> 16; | |
1121 } | |
1122 // 42EBBE: using guessed type int __fastcall sub_42EBBE(int, int); | |
1123 | |
1124 //----- (0042EBDB) -------------------------------------------------------- | |
323 | 1125 int stru193_math::Sin(int angle) |
0 | 1126 { |
323 | 1127 return Cos(angle - this->uIntegerHalfPi); |
0 | 1128 } |
1129 | |
1130 //----- (0042ECB5) -------------------------------------------------------- | |
271 | 1131 void _42ECB5_PlayerAttacksActor() |
0 | 1132 { |
271 | 1133 //unsigned int v0; // ebx@1 |
1134 //Player *v1; // esi@1 | |
1135 //bool result; // eax@1 | |
295 | 1136 //int v3; // edi@2 |
271 | 1137 //unsigned int v4; // eax@7 |
0 | 1138 char *v5; // eax@8 |
271 | 1139 //int v6; // ecx@9 |
1140 //signed int v7; // eax@16 | |
295 | 1141 //Actor *v8; // edi@20 |
0 | 1142 unsigned int v9; // ecx@21 |
295 | 1143 //char *v10; // eax@26 |
0 | 1144 char *v11; // eax@26 |
1145 unsigned int v12; // eax@47 | |
295 | 1146 //char *v13; // eax@47 |
1147 //char *v14; // eax@47 | |
1148 //unsigned int v15; // ebx@54 | |
1149 //int v16; // [sp-10h] [bp-4Ch]@24 | |
1150 //int v17; // [sp-10h] [bp-4Ch]@44 | |
1151 //unsigned int v18; // [sp-Ch] [bp-48h]@24 | |
1152 //unsigned int v19; // [sp-Ch] [bp-48h]@44 | |
1153 //__int16 v20; // [sp-8h] [bp-44h]@24 | |
1154 //__int16 v21; // [sp-8h] [bp-44h]@44 | |
1155 //int v22; // [sp-4h] [bp-40h]@24 | |
1156 //int v23; // [sp-4h] [bp-40h]@44 | |
0 | 1157 SoundID v24; // [sp-4h] [bp-40h]@58 |
295 | 1158 //Vec3_int_ a3; // [sp+Ch] [bp-30h]@19 |
271 | 1159 //unsigned int a2; // [sp+18h] [bp-24h]@20 |
1160 //unsigned int v27; // [sp+1Ch] [bp-20h]@1 | |
295 | 1161 //int v28; // [sp+20h] [bp-1Ch]@9 |
271 | 1162 //unsigned int *v28b; |
295 | 1163 //int v29; // [sp+24h] [bp-18h]@16 |
1164 //int v30; // [sp+28h] [bp-14h]@16 | |
271 | 1165 //int v31; // [sp+2Ch] [bp-10h]@4 |
295 | 1166 //int v32; // [sp+30h] [bp-Ch]@7 |
271 | 1167 //int v33; // [sp+34h] [bp-8h]@7 |
295 | 1168 //int v34; // [sp+38h] [bp-4h]@17 |
0 | 1169 |
271 | 1170 //v0 = uActiveCharacter; |
1171 //v27 = 6972 * uActiveCharacter; | |
1172 //v1 = &pParty->pPlayers[uActiveCharacter-1]; | |
1173 //result = pParty->pPlayers[uActiveCharacter-1].CanAct(); | |
1174 auto player = &pParty->pPlayers[uActiveCharacter - 1]; | |
1175 if (!player->CanAct()) | |
1176 return; | |
1177 | |
1202 | 1178 pCastSpellInfo.data()->_427D48(uActiveCharacter); |
295 | 1179 //v3 = 0; |
271 | 1180 if (pParty->Invisible()) |
1181 pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset(); | |
1182 | |
1183 //v31 = player->pEquipment.uBow; | |
1184 int bow_idx = player->pEquipment.uBow; | |
1384
b51332ab228f
changed a few member variables in Player to slightly less confusing names
Grumpy7
parents:
1340
diff
changeset
|
1185 if (bow_idx && player->pInventoryItemList[bow_idx - 1].Broken()) |
271 | 1186 bow_idx = 0; |
1187 | |
295 | 1188 //v32 = 0; |
1189 int wand_item_id = 0; | |
271 | 1190 //v33 = 0; |
1191 //v4 = v1->pEquipment.uMainHand; | |
1192 int laser_weapon_item_id = 0; | |
1193 | |
1194 int main_hand_idx = player->pEquipment.uMainHand; | |
1195 if (main_hand_idx) | |
0 | 1196 { |
1384
b51332ab228f
changed a few member variables in Player to slightly less confusing names
Grumpy7
parents:
1340
diff
changeset
|
1197 auto item = &player->pInventoryItemList[main_hand_idx - 1]; |
112 | 1198 //v5 = (char *)v1 + 36 * v4; |
271 | 1199 if (!item->Broken()) |
1200 { | |
1201 //v28b = &v1->pInventoryItems[v4].uItemID; | |
1202 //v6 = v1->pInventoryItems[v4].uItemID;//*((int *)v5 + 124); | |
295 | 1203 if (pItemsTable->pItems[item->uItemID].uEquipType == EQUIP_WAND) |
0 | 1204 { |
295 | 1205 if (item->uNumCharges <= 0) |
1206 player->pEquipment.uMainHand = 0; // wand discharged - unequip | |
0 | 1207 else |
295 | 1208 wand_item_id = item->uItemID;//*((int *)v5 + 124); |
0 | 1209 } |
271 | 1210 else if (item->uItemID == ITEM_BLASTER || item->uItemID == ITEM_LASER_RIFLE) |
1211 laser_weapon_item_id = item->uItemID;//*((int *)v5 + 124); | |
0 | 1212 } |
271 | 1213 } |
1214 | |
295 | 1215 //v30 = 0; |
1216 //v29 = 0; | |
1217 //v28 = 0; | |
271 | 1218 //v7 = pMouse->uPointingObjectID; |
1219 | |
1220 int target_pid = pMouse->uPointingObjectID; | |
848 | 1221 int target_type = PID_TYPE(target_pid), |
1222 target_id = PID_ID(target_pid); | |
271 | 1223 if (target_type != OBJECT_Actor || !pActors[target_id].CanAct()) |
1224 { | |
1225 target_pid = stru_50C198.FindClosestActor(5120, 0, 0); | |
848 | 1226 target_type = PID_TYPE(target_pid); |
1227 target_id = PID_ID(target_pid); | |
271 | 1228 } |
295 | 1229 |
1230 auto actor = &pActors[target_id]; | |
1231 int actor_distance = 0; | |
271 | 1232 if (target_type == OBJECT_Actor) |
1233 { | |
295 | 1234 int distance_x = actor->vPosition.x - pParty->vPosition.x, |
1235 distance_y = actor->vPosition.y - pParty->vPosition.y, | |
1236 distance_z = actor->vPosition.z - pParty->vPosition.z; | |
1237 actor_distance = integer_sqrt(distance_x * distance_x + distance_y * distance_y + distance_z * distance_z) - actor->uActorRadius; | |
1238 if (actor_distance < 0) | |
1239 actor_distance = 0; | |
1240 } | |
1241 | |
1242 bool shooting_bow = false, | |
1243 shotting_laser = false, | |
816 | 1244 shooting_wand = false, |
1245 melee_attack = false; | |
295 | 1246 if (laser_weapon_item_id) |
1247 { | |
1248 shotting_laser = true; | |
490 | 1249 _42777D_CastSpell_UseWand_ShootArrow(SPELL_LASER_PROJECTILE, uActiveCharacter - 1, 0, 0, uActiveCharacter + 8); |
295 | 1250 } |
1251 else if (wand_item_id) | |
1252 { | |
1253 shooting_wand = true; | |
1254 | |
1255 int main_hand_idx = player->pEquipment.uMainHand; | |
1384
b51332ab228f
changed a few member variables in Player to slightly less confusing names
Grumpy7
parents:
1340
diff
changeset
|
1256 _42777D_CastSpell_UseWand_ShootArrow(wand_spell_ids[player->pInventoryItemList[main_hand_idx - 1].uItemID - ITEM_WAND_FIRE], uActiveCharacter - 1, 8, 0, uActiveCharacter + 8); |
295 | 1257 |
1384
b51332ab228f
changed a few member variables in Player to slightly less confusing names
Grumpy7
parents:
1340
diff
changeset
|
1258 if (!--player->pInventoryItemList[main_hand_idx - 1].uNumCharges) |
295 | 1259 player->pEquipment.uMainHand = 0; |
1260 } | |
303 | 1261 else if (target_type == OBJECT_Actor && actor_distance <= 407.2) |
295 | 1262 { |
816 | 1263 melee_attack = true; |
1264 | |
303 | 1265 Vec3_int_ a3; |
1266 a3.x = actor->vPosition.x - pParty->vPosition.x; | |
1267 a3.y = actor->vPosition.y - pParty->vPosition.y; | |
1268 a3.z = actor->vPosition.z - pParty->vPosition.z; | |
1269 Vec3_int_::Normalize(&a3.x, &a3.y, &a3.z); | |
1270 | |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
1271 DamageMonsterFromParty(PID(OBJECT_Player, uActiveCharacter - 1), target_id, &a3); |
1080 | 1272 if (player->WearsItem(ITEM_ARTIFACT_SPLITTER, EQUIP_MAIN_HAND) || player->WearsItem(ITEM_ARTIFACT_SPLITTER, EQUIP_OFF_HAND)) |
295 | 1273 _42FA66_do_explosive_impact( |
1274 actor->vPosition.x, | |
1275 actor->vPosition.y, | |
1276 actor->vPosition.z + actor->uActorHeight / 2, | |
1277 0, 512, uActiveCharacter); | |
303 | 1278 } |
1279 else if (bow_idx) | |
1280 { | |
1281 shooting_bow = true; | |
490 | 1282 _42777D_CastSpell_UseWand_ShootArrow(SPELL_BOW_ARROW, uActiveCharacter - 1, 0, 0, 0); |
295 | 1283 } |
1284 else | |
1285 { | |
816 | 1286 melee_attack = true; |
303 | 1287 ; // actor out of range or no actor; no ranged weapon so melee attacking air |
1288 } | |
1289 | |
816 | 1290 if (!pParty->bTurnBasedModeOn && melee_attack) // wands, bows & lasers will add recovery while shooting spell effect |
303 | 1291 { |
816 | 1292 int recovery = player->GetAttackRecoveryTime(false); |
303 | 1293 if (recovery < 30 ) |
1294 recovery = 30; | |
816 | 1295 player->SetRecoveryTime(flt_6BE3A4_debug_recmod1 * (double)recovery * 2.133333333333333); |
295 | 1296 } |
1297 | |
1298 | |
1299 int v34 = 0; | |
1300 if (shooting_wand) | |
1301 return; | |
1302 else if (shooting_bow) | |
1303 { | |
1304 v34 = 5; | |
1305 player->PlaySound(SPEECH_50, 0); | |
1306 } | |
1307 if (shotting_laser) | |
1308 v34 = 7; | |
1309 else | |
1310 { | |
1311 int main_hand_idx = player->pEquipment.uMainHand; | |
816 | 1312 if (player->HasItemEquipped(EQUIP_MAIN_HAND)) |
1384
b51332ab228f
changed a few member variables in Player to slightly less confusing names
Grumpy7
parents:
1340
diff
changeset
|
1313 v34 = pItemsTable->pItems[*(int *)&player->pInventoryItemList[main_hand_idx - 1]].uSkillType; |
295 | 1314 pTurnEngine->_40471C(); |
1315 } | |
1316 | |
1317 switch (v34) | |
1318 { | |
1319 case 0: pAudioPlayer->PlaySound(SOUND_81, 0, 0, -1, 0, 0, 0, 0); break; | |
1320 case 1: pAudioPlayer->PlaySound(SOUND_84, 0, 0, -1, 0, 0, 0, 0); break; | |
1321 case 2: pAudioPlayer->PlaySound(SOUND_85, 0, 0, -1, 0, 0, 0, 0); break; | |
1322 case 3: pAudioPlayer->PlaySound(SOUND_78, 0, 0, -1, 0, 0, 0, 0); break; | |
1323 case 4: pAudioPlayer->PlaySound(SOUND_80, 0, 0, -1, 0, 0, 0, 0); break; | |
1324 case 5: pAudioPlayer->PlaySound(SOUND_71, 0, 0, -1, 0, 0, 0, 0); break; | |
1325 case 6: pAudioPlayer->PlaySound(SOUND_83, 0, 0, -1, 0, 0, 0, 0); break; | |
1326 case 7: pAudioPlayer->PlaySound(SOUND_67, 0, 0, -1, 0, 0, 0, 0); break; | |
1327 } | |
0 | 1328 } |
1329 | |
1330 //----- (0042F184) -------------------------------------------------------- | |
295 | 1331 int stru319::FindClosestActor(int pick_depth, int a3, int a4) |
0 | 1332 { |
1333 int v4; // edi@1 | |
1334 stru319 *v5; // esi@1 | |
1335 int v6; // eax@2 | |
1336 int v7; // eax@4 | |
1337 int result; // eax@5 | |
1338 int *v9; // edx@8 | |
1339 signed int v10; // ebx@10 | |
1340 int v11; // edi@11 | |
1341 Actor *v12; // esi@12 | |
1342 unsigned __int16 v13; // ax@12 | |
1343 int v14; // eax@22 | |
1344 char v15; // zf@30 | |
1345 int v16; // esi@32 | |
1346 int v17; // ecx@34 | |
1347 stru319 *v18; // eax@39 | |
1348 int v19; // edx@39 | |
1349 int v20; // ecx@41 | |
1350 unsigned __int16 v21; // ax@42 | |
1351 unsigned int v22; // [sp+8h] [bp-24h]@11 | |
1352 unsigned int v23; // [sp+Ch] [bp-20h]@7 | |
1353 stru319 *v24; // [sp+10h] [bp-1Ch]@1 | |
1354 unsigned int v25; // [sp+14h] [bp-18h]@8 | |
1355 int *v26; // [sp+18h] [bp-14h]@8 | |
1356 int v27; // [sp+1Ch] [bp-10h]@10 | |
1357 int *v28; // [sp+20h] [bp-Ch]@10 | |
1358 unsigned int v29; // [sp+24h] [bp-8h]@7 | |
1359 int v30; // [sp+28h] [bp-4h]@6 | |
1360 int i; // [sp+38h] [bp+Ch]@33 | |
1361 signed int v32; // [sp+3Ch] [bp+10h]@32 | |
1362 | |
1363 v4 = 0; | |
1364 v5 = this; | |
1365 v24 = this; | |
1366 if ( pRenderer->pRenderD3D ) | |
1367 { | |
1368 v6 = a3 != 0; | |
1369 if ( a4 ) | |
1370 LOBYTE(v6) = v6 | 8; | |
295 | 1371 v7 = pGame->pVisInstance->PickClosestActor(OBJECT_Actor, pick_depth, v6, 657456, -1); |
0 | 1372 if ( v7 != -1 ) |
1373 return (unsigned __int16)v7; | |
295 | 1374 else return 0; |
0 | 1375 } |
1376 else | |
1377 { | |
1378 v30 = 0; | |
1379 if ( pRenderer->pActiveZBuffer ) | |
1380 { | |
692 | 1381 v29 = viewparams->uScreen_topL_X; |
1382 v23 = viewparams->uScreen_BttmR_X; | |
1383 if ( (signed int)viewparams->uScreen_topL_Y < (signed int)viewparams->uScreen_BttmR_Y ) | |
0 | 1384 { |
692 | 1385 v25 = viewparams->uScreen_BttmR_Y - viewparams->uScreen_topL_Y; |
1386 v9 = &pRenderer->pActiveZBuffer[viewparams->uScreen_topL_X + 640 * viewparams->uScreen_topL_Y]; | |
1387 v26 = &pRenderer->pActiveZBuffer[viewparams->uScreen_topL_X + 640 * viewparams->uScreen_topL_Y]; | |
0 | 1388 do |
1389 { | |
1390 if ( (signed int)v29 < (signed int)v23 ) | |
1391 { | |
1392 v28 = v9; | |
1393 v10 = v4; | |
1394 v27 = v23 - v29; | |
1395 do | |
1396 { | |
1397 v22 = *v28; | |
1398 v11 = *v28 & 0xFFFF; | |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
1399 if (PID_TYPE(v11) == OBJECT_Actor) |
0 | 1400 { |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
1401 v12 = &pActors[PID_ID(v11)]; |
0 | 1402 v13 = v12->uAIState; |
1403 if ( v13 != 5 ) | |
1404 { | |
1405 if ( v13 != 4 | |
1406 && v13 != 11 | |
1407 && v13 != 19 | |
1408 && v13 != 17 | |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
1409 && (!a3 || pActors[PID_ID(v11)].GetActorsRelation(0)) ) |
0 | 1410 { |
1411 if ( (!a4 || MonsterStats::BelongsToSupertype(v12->pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD)) | |
295 | 1412 && v22 <= pick_depth << 16 ) |
0 | 1413 { |
1414 v14 = 0; | |
1415 if ( v10 > 0 ) | |
1416 { | |
1417 do | |
1418 { | |
1419 if ( dword_50BDA0[v14] == v11 ) | |
1420 break; | |
1421 ++v14; | |
1422 } | |
1423 while ( v14 < v30 ); | |
1424 } | |
1425 if ( v14 == v30 && v10 < 100 ) | |
1426 { | |
1427 ++v30; | |
1428 dword_50BC10[v10] = v22; | |
1429 dword_50BDA0[v10] = v11; | |
1430 ++v10; | |
1431 } | |
1432 } | |
1433 } | |
1434 } | |
1435 } | |
1436 ++v28; | |
1437 --v27; | |
1438 } | |
1439 while ( v27 ); | |
1440 v4 = v30; | |
1441 v5 = v24; | |
1442 } | |
1443 v9 = v26 + 640; | |
1444 v15 = v25-- == 1; | |
1445 v26 += 640; | |
1446 } | |
1447 while ( !v15 ); | |
1448 } | |
1449 if ( v4 > 0 ) | |
1450 { | |
1451 v32 = 1; | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
1452 v16 = (int)dword_50BC10.data(); |
0 | 1453 do |
1454 { | |
1455 for ( i = v32; i < v4; ++i ) | |
1456 { | |
1457 v17 = dword_50BC10[i]; | |
1458 if ( v17 < *(int *)v16 ) | |
1459 { | |
1460 dword_50BC10[i] = *(int *)v16; | |
1461 *(int *)v16 = v17; | |
1462 } | |
1463 } | |
1464 ++v32; | |
1465 v16 += 4; | |
1466 } | |
1467 while ( v32 - 1 < v4 ); | |
1468 v5 = v24; | |
1469 if ( v4 > 0 ) | |
1470 { | |
1471 v18 = v24; | |
1472 v19 = v4; | |
1473 do | |
1474 { | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
1475 *(int *)&v18->field_0 = (*(int *)&v18[(char *)dword_50BC10.data() - (char *)v24].field_0 >> 3) & 0x1FFF; |
0 | 1476 v18 += 4; |
1477 --v19; | |
1478 } | |
1479 while ( v19 ); | |
1480 } | |
1481 } | |
1482 v20 = 0; | |
1483 for ( *(int *)&v5[2000].field_0 = v4; v20 < v4; ++v20 ) | |
1484 { | |
1485 v21 = pActors[*(int *)&v5[4 * v20].field_0].uAIState; | |
1486 if ( v21 != 4 && v21 != 5 ) | |
1487 break; | |
1488 } | |
1489 if ( v20 != v4 ) | |
1490 { | |
1491 result = 8 * *(int *)&v5[4 * v20].field_0; | |
1492 LOBYTE(result) = result | 3; | |
1493 return result; | |
1494 } | |
1495 } | |
1496 } | |
1497 return 0; | |
1498 } | |
1499 | |
1500 //----- (0042F3D6) -------------------------------------------------------- | |
1501 void InitializeTurnBasedAnimations(void *_this) | |
1502 { | |
1503 unsigned int *v1; // edi@1 | |
1504 | |
1505 pIconIDs_Turn[0] = pIconsFrameTable->FindIcon("turn0"); | |
1506 pIconIDs_Turn[1] = pIconsFrameTable->FindIcon("turn1"); | |
1507 pIconIDs_Turn[2] = pIconsFrameTable->FindIcon("turn2"); | |
1508 pIconIDs_Turn[3] = pIconsFrameTable->FindIcon("turn3"); | |
1509 pIconIDs_Turn[4] = pIconsFrameTable->FindIcon("turn4"); | |
1510 uIconID_TurnStop = pIconsFrameTable->FindIcon("turnstop"); | |
1511 uIconID_TurnHour = pIconsFrameTable->FindIcon("turnhour"); | |
1512 uIconID_TurnStart = pIconsFrameTable->FindIcon("turnstart"); | |
1513 uIconID_CharacterFrame = pIconsFrameTable->FindIcon("aframe1"); | |
1514 uSpriteID_Spell11 = pSpriteFrameTable->FastFindSprite("spell11"); | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
1515 v1 = pIconIDs_Turn.data(); |
0 | 1516 do |
1517 { | |
1518 pIconsFrameTable->InitializeAnimation(*v1); | |
1519 ++v1; | |
1520 } | |
1521 while ( (signed int)v1 < (signed int)&uIconID_TurnStop ); | |
1522 pIconsFrameTable->InitializeAnimation(uIconID_TurnHour); | |
1523 pIconsFrameTable->InitializeAnimation(uIconID_TurnStop); | |
1524 pIconsFrameTable->InitializeAnimation(uIconID_TurnStart); | |
1525 pIconsFrameTable->InitializeAnimation(uIconID_CharacterFrame); | |
1526 } | |
1527 | |
1528 //----- (0042F4DA) -------------------------------------------------------- | |
1529 signed int __cdecl sub_42F4DA() | |
1530 { | |
1531 signed int v0; // edi@1 | |
82 | 1532 Actor *v1; // esi@4 |
0 | 1533 int v2; // ebx@5 |
1534 int v3; // eax@5 | |
1535 int v4; // ebx@5 | |
1536 unsigned int v5; // ecx@5 | |
1537 int v6; // edx@6 | |
1538 unsigned int v7; // edx@8 | |
1539 unsigned int v8; // edx@10 | |
1540 __int16 v9; // ax@12 | |
1541 signed int result; // eax@20 | |
1542 int v11; // [sp+Ch] [bp-10h]@5 | |
1543 int v12; // [sp+10h] [bp-Ch]@5 | |
1544 signed int v13; // [sp+14h] [bp-8h]@3 | |
1545 | |
1546 v0 = 5120; | |
1547 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
1548 v0 = 2560; | |
1549 v13 = 0; | |
1550 if ( (signed int)uNumActors <= 0 ) | |
1551 { | |
1552 LABEL_20: | |
1553 result = 0; | |
1554 } | |
1555 else | |
1556 { | |
1202 | 1557 v1 = pActors.data(); |
0 | 1558 while ( 1 ) |
1559 { | |
82 | 1560 v2 = abs(v1->vInitialPosition.x - pParty->vPosition.x); |
1561 v11 = abs(v1->vInitialPosition.y - pParty->vPosition.y); | |
1562 v12 = abs(v1->vInitialPosition.z - pParty->vPosition.z); | |
0 | 1563 v3 = v2; |
1564 v4 = v11; | |
1565 v5 = v12; | |
1566 if ( v3 < v11 ) | |
1567 { | |
1568 v6 = v3; | |
1569 v3 = v11; | |
1570 v4 = v6; | |
1571 } | |
1572 if ( v3 < v12 ) | |
1573 { | |
1574 v7 = v3; | |
1575 v3 = v12; | |
1576 v5 = v7; | |
1577 } | |
1578 if ( v4 < (signed int)v5 ) | |
1579 { | |
1580 v8 = v5; | |
1581 v5 = v4; | |
1582 v4 = v8; | |
1583 } | |
1584 if ( (signed int)(((unsigned int)(11 * v4) >> 5) + (v5 >> 2) + v3) < v0 ) | |
1585 { | |
82 | 1586 v9 = v1->uAIState; |
1587 if ( v1->uAIState != 5 ) | |
0 | 1588 { |
1589 if ( v9 != 4 | |
1590 && v9 != 11 | |
1591 && v9 != 19 | |
1592 && v9 != 17 | |
82 | 1593 && (BYTE2(v1->uAttributes) & 8 || ((Actor *)nullptr)->GetActorsRelation( v1)) ) |
0 | 1594 break; |
1595 } | |
1596 } | |
1597 ++v13; | |
82 | 1598 ++v1; |
0 | 1599 if ( v13 >= (signed int)uNumActors ) |
1600 goto LABEL_20; | |
1601 } | |
1602 result = 1; | |
1603 } | |
1604 return result; | |
1605 } | |
1606 | |
1607 //----- (0042F7EB) -------------------------------------------------------- | |
1608 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) | |
1609 { | |
1406 | 1610 unsigned __int16 pObjectDescID; // ax@7 |
1611 SpriteObject pSpellObject; // [sp+Ch] [bp-78h]@1 | |
0 | 1612 |
1406 | 1613 pSpellObject.stru_24.Reset(); |
0 | 1614 if ( a9 ) |
1406 | 1615 memcpy(&pSpellObject.stru_24, a9, sizeof(pSpellObject.stru_24)); |
1616 pSpellObject.spell_skill = 0; | |
1617 pSpellObject.spell_level = 0; | |
1618 pSpellObject.spell_id = 0; | |
1619 pSpellObject.field_54 = 0; | |
1620 pSpellObject.uType = uSpriteID; | |
0 | 1621 if ( (signed int)pObjectList->uNumObjects <= 0 ) |
1406 | 1622 pObjectDescID = 0; |
0 | 1623 else |
1624 { | |
1406 | 1625 pObjectDescID = 0; |
1626 for ( uint i = 0; i < (signed int)pObjectList->uNumObjects; ++i ) | |
0 | 1627 { |
1406 | 1628 if ( (short)uSpriteID == pObjectList->pObjects[i].uObjectID ) |
1629 pObjectDescID = i; | |
0 | 1630 } |
1631 } | |
1406 | 1632 pSpellObject.uObjectDescID = pObjectDescID; |
1633 pSpellObject.vPosition.x = x; | |
1634 pSpellObject.vPosition.y = y; | |
1635 pSpellObject.vPosition.z = z; | |
1636 pSpellObject.uSoundID = 0; | |
1637 pSpellObject.uAttributes = attributes; | |
1638 pSpellObject.uSectorID = pIndoor->GetSector(x, y, z); | |
1639 pSpellObject.uSpriteFrameID = 0; | |
1640 pSpellObject.spell_caster_pid = 0; | |
1641 pSpellObject.spell_target_pid = 0; | |
1642 if ( !(pSpellObject.uAttributes & 0x10) ) | |
1643 { | |
1644 if ( pItemsTable->uAllItemsCount ) | |
1645 { | |
1646 for ( uint i = 0; i < pItemsTable->uAllItemsCount; ++i ) | |
1647 { | |
1648 if ( pItemsTable->pItems[i].uSpriteID == uSpriteID ) | |
1649 pSpellObject.stru_24.uItemID = i; | |
1650 } | |
1651 } | |
1652 } | |
0 | 1653 if ( a7 ) |
1654 { | |
1655 if ( count > 0 ) | |
1656 { | |
1406 | 1657 for ( uint i = count; i; --i ) |
0 | 1658 { |
1406 | 1659 pSpellObject.uFacing = rand() % (signed int)stru_5C6E00->uIntegerDoublePi; |
1660 pSpellObject.Create((signed __int16)pSpellObject.uFacing, | |
1661 ((signed int)stru_5C6E00->uIntegerHalfPi / 2) + (rand() % ((signed int)stru_5C6E00->uIntegerHalfPi / 2)), a4, 0); | |
1662 | |
0 | 1663 } |
1664 } | |
1665 } | |
1666 else | |
1667 { | |
1406 | 1668 pSpellObject.uFacing = 0; |
0 | 1669 if ( count > 0 ) |
1670 { | |
1406 | 1671 for ( uint i = count; i; --i ) |
0 | 1672 { |
1406 | 1673 pSpellObject.Create((signed __int16)pSpellObject.uFacing, stru_5C6E00->uIntegerHalfPi, a4, 0); |
0 | 1674 } |
1675 } | |
1676 } | |
1406 | 1677 return true; |
0 | 1678 } |
1679 | |
1680 //----- (0042F960) -------------------------------------------------------- | |
1681 void __fastcall sub_42F960_create_object(int x, int y, int z) | |
1682 { | |
1683 int v3; // ebx@1 | |
1684 int v4; // edi@1 | |
1685 signed int v5; // edx@1 | |
1686 char *v6; // ecx@2 | |
1687 unsigned __int16 v7; // ax@5 | |
1688 signed int v8; // eax@6 | |
1689 signed int v9; // eax@7 | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
490
diff
changeset
|
1690 //SpriteObject a1; // [sp+Ch] [bp-70h]@1 |
0 | 1691 |
1692 v3 = x; | |
1693 v4 = y; | |
1694 | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
490
diff
changeset
|
1695 SpriteObject a1; // [sp+Ch] [bp-70h]@1 |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
490
diff
changeset
|
1696 //SpriteObject::SpriteObject(&a1); |
0 | 1697 a1.stru_24.Reset(); |
1698 | |
1699 v5 = 0; | |
822 | 1700 a1.spell_skill = 0; |
1701 a1.spell_level = 0; | |
1702 a1.spell_id = 0; | |
0 | 1703 a1.field_54 = 0; |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
490
diff
changeset
|
1704 a1.uType = 800; |
0 | 1705 if ( (signed int)pObjectList->uNumObjects <= 0 ) |
1706 { | |
1707 LABEL_5: | |
1708 v7 = 0; | |
1709 } | |
1710 else | |
1711 { | |
1712 v6 = (char *)&pObjectList->pObjects->uObjectID; | |
1713 while ( *(short *)v6 != 800 ) | |
1714 { | |
1715 ++v5; | |
1716 v6 += 56; | |
1717 if ( v5 >= (signed int)pObjectList->uNumObjects ) | |
1718 goto LABEL_5; | |
1719 } | |
1720 v7 = v5; | |
1721 } | |
1722 a1.uObjectDescID = v7; | |
1723 a1.vPosition.x = v3; | |
1724 a1.vPosition.y = v4; | |
1725 a1.vPosition.z = z; | |
1726 a1.uSoundID = 0; | |
1727 a1.uAttributes = 0; | |
1728 a1.uSectorID = pIndoor->GetSector(v3, v4, z); | |
1729 a1.uSpriteFrameID = 0; | |
822 | 1730 a1.spell_caster_pid = 0; |
823 | 1731 a1.spell_target_pid = 0; |
0 | 1732 v8 = a1.Create(0, 0, 0, 0); |
1733 if ( v8 != -1 ) | |
1734 { | |
1735 v9 = 8 * v8; | |
1736 LOBYTE(v9) = v9 | 2; | |
1737 pAudioPlayer->PlaySound((SoundID)(SOUND_GoldReceived|0x14), v9, 0, -1, 0, 0, 0, 0); | |
1738 } | |
1739 } | |
1740 | |
810 | 1741 |
0 | 1742 |
1743 //----- (0042FA66) -------------------------------------------------------- | |
1744 int __fastcall _42FA66_do_explosive_impact(int a1, int a2, int a3, int a4, __int16 a5, signed int a6) | |
1745 { | |
1746 int v6; // edi@1 | |
1747 int v7; // esi@1 | |
1748 char *v8; // ecx@2 | |
1749 unsigned __int16 v9; // ax@5 | |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
1750 //int v10; // eax@10 |
0 | 1751 signed int result; // eax@11 |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
1752 //__int16 v12; // ax@12 |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
490
diff
changeset
|
1753 //SpriteObject a1a; // [sp+Ch] [bp-74h]@1 |
0 | 1754 int v14; // [sp+7Ch] [bp-4h]@1 |
1755 | |
1756 v6 = a1; | |
1757 v7 = a2; | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
490
diff
changeset
|
1758 SpriteObject a1a; // [sp+Ch] [bp-74h]@1 |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
490
diff
changeset
|
1759 //SpriteObject::SpriteObject(&a1a); |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
490
diff
changeset
|
1760 a1a.uType = 600; |
0 | 1761 a1a.stru_24.Reset(); |
1762 | |
822 | 1763 a1a.spell_id = SPELL_FIRE_FIREBALL; |
1764 a1a.spell_level = 8; | |
1765 a1a.spell_skill = 3; | |
0 | 1766 v14 = 0; |
1767 if ( (signed int)pObjectList->uNumObjects <= 0 ) | |
1768 { | |
1769 LABEL_5: | |
1770 v9 = 0; | |
1771 } | |
1772 else | |
1773 { | |
1774 v8 = (char *)&pObjectList->pObjects->uObjectID; | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
490
diff
changeset
|
1775 while ( (short)a1a.uType != *(short *)v8 ) |
0 | 1776 { |
1777 ++v14; | |
1778 v8 += 56; | |
1779 if ( v14 >= (signed int)pObjectList->uNumObjects ) | |
1780 goto LABEL_5; | |
1781 } | |
1782 v9 = v14; | |
1783 } | |
1784 a1a.uObjectDescID = v9; | |
1785 a1a.vPosition.x = v6; | |
1786 a1a.vPosition.y = v7; | |
1787 a1a.vPosition.z = a3; | |
1788 a1a.uAttributes = 0; | |
1789 a1a.uSectorID = pIndoor->GetSector(v6, v7, a3); | |
1790 a1a.uSpriteFrameID = 0; | |
823 | 1791 a1a.spell_target_pid = 0; |
0 | 1792 a1a.field_60_distance_related_prolly_lod = 0; |
1793 a1a.uFacing = 0; | |
1794 a1a.uSoundID = 0; | |
1795 if ( a6 >= 1 || a6 <= 4 ) | |
1796 { | |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
1797 a1a.spell_caster_pid = PID(OBJECT_Player, a6 - 1); |
0 | 1798 } |
1799 else | |
1800 { | |
822 | 1801 a1a.spell_caster_pid = 0; |
0 | 1802 } |
1803 result = a1a.Create(0, 0, 0, 0); | |
1804 if ( result != -1 ) | |
1805 { | |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
1806 result = stru_50FE08.Add(PID(OBJECT_Item, result), |
0 | 1807 a5, |
1808 SLOWORD(a1a.vPosition.x), | |
1809 SLOWORD(a1a.vPosition.y), | |
1810 SLOWORD(a1a.vPosition.z), | |
1811 0, | |
1812 0); | |
1813 } | |
1814 return result; | |
1815 } | |
1816 | |
1817 //----- (0042FB5C) -------------------------------------------------------- | |
1818 bool __fastcall sub_42FB5C(signed int a1) | |
1819 { | |
1820 int v1; // ecx@3 | |
1821 int v2; // ecx@4 | |
1822 int v3; // ecx@5 | |
1823 int v4; // ecx@6 | |
1824 int v5; // ecx@7 | |
1825 int v6; // ecx@8 | |
1826 char v7; // zf@9 | |
1827 | |
1828 if ( a1 > 39 ) | |
1829 { | |
1830 if ( a1 > 77 ) | |
1831 { | |
1832 if ( a1 == 80 ) | |
1833 return 0; | |
1834 if ( a1 > 84 ) | |
1835 { | |
1836 if ( a1 <= 86 ) | |
1837 return 0; | |
1838 v7 = a1 == 95; | |
1839 goto LABEL_20; | |
1840 } | |
1841 } | |
1842 else | |
1843 { | |
1844 if ( a1 == 77 ) | |
1845 return 0; | |
1846 if ( a1 >= 46 ) | |
1847 { | |
1848 if ( a1 <= 47 || a1 == 51 ) | |
1849 return 0; | |
1850 v7 = a1 == 73; | |
1851 goto LABEL_20; | |
1852 } | |
1853 } | |
1854 return 1; | |
1855 } | |
1856 if ( a1 == 39 || (v1 = a1 - 2) == 0 ) | |
1857 return 1; | |
1858 v2 = v1 - 3; | |
1859 if ( !v2 ) | |
1860 return 0; | |
1861 v3 = v2 - 1; | |
1862 if ( !v3 || (v4 = v3 - 3) == 0 ) | |
1863 return 1; | |
1864 v5 = v4 - 8; | |
1865 if ( !v5 ) | |
1866 return 0; | |
1867 v6 = v5 - 1; | |
1868 if ( !v6 ) | |
1869 return 1; | |
1870 v7 = v6 == 20; | |
1871 LABEL_20: | |
1872 if ( !v7 ) | |
1873 return 1; | |
1874 return 0; | |
1875 } | |
1876 | |
1877 //----- (0042FBDD) -------------------------------------------------------- | |
1878 void __cdecl sub_42FBDD() | |
1879 { | |
388 | 1880 pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); |
0 | 1881 pRenderer->DrawTextureTransparent(pBtn_YES->uX, pBtn_YES->uY, pBtn_YES->pTextures[0]); |
1882 pRenderer->Present(); | |
1883 } | |
1884 | |
1885 //----- (0042FC15) -------------------------------------------------------- | |
11 | 1886 void __cdecl CloseWindowBackground() |
0 | 1887 { |
388 | 1888 pAudioPlayer->PlaySound(SOUND_Button2, -2, 0, -1, 0, 0, 0, 0); |
0 | 1889 pRenderer->DrawTextureTransparent(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY, pBtn_ExitCancel->pTextures[0]); |
1890 pRenderer->Present(); | |
1891 } | |
1892 | |
1893 //----- (0042FC4E) -------------------------------------------------------- | |
1894 void __cdecl ProcessInputActions() | |
1895 { | |
1896 char v4; // al@9 | |
1897 char v8; // bl@100 | |
1898 unsigned __int16 v9; // ax@102 | |
1899 int v10; // eax@103 | |
1900 char v14; // al@159 | |
1901 unsigned int v15; // eax@168 | |
1902 PartyAction partyAction; // [sp-14h] [bp-1Ch]@20 | |
1903 InputAction inputAction; // [sp+0h] [bp-8h]@7 | |
1904 int v24; // [sp+4h] [bp-4h]@87 | |
1905 | |
1906 pGame->pKeyboardInstance->EnterCriticalSection(); | |
1907 auto pKeyboard = pGame->pKeyboardInstance; | |
1908 if (!bAlwaysRun) | |
1909 { | |
1910 if (pKeyboard->IsShiftHeld()) | |
1911 pParty->uFlags2 |= PARTY_FLAGS_2_RUNNING; | |
1912 else | |
1913 pParty->uFlags2 &= ~PARTY_FLAGS_2_RUNNING; | |
1914 } | |
1915 else | |
1916 { | |
1917 if (pKeyboard->IsShiftHeld()) | |
1918 pParty->uFlags2 &= ~PARTY_FLAGS_2_RUNNING; | |
1919 else | |
1920 pParty->uFlags2 |= PARTY_FLAGS_2_RUNNING; | |
1921 } | |
1922 | |
140 | 1923 //pParty->uFlags2 |= PARTY_FLAGS_2_RUNNING; |
1052 | 1924 |
1925 | |
1926 // WUT? double event trigger | |
1927 /*for ( uint i = 0; i < 30; ++i ) | |
998 | 1928 { |
1929 if ( pKeyActionMap->pToggleTypes[i] ) | |
1930 v14 = pGame->pKeyboardInstance->WasKeyPressed(pKeyActionMap->pVirtualKeyCodesMapping[i]); | |
1931 else | |
1932 v14 = pGame->pKeyboardInstance->IsKeyBeingHeld(pKeyActionMap->pVirtualKeyCodesMapping[i]); | |
1052 | 1933 if ( v14 ) |
998 | 1934 { |
1052 | 1935 if (pCurrentScreen == SCREEN_GAME) |
998 | 1936 { |
1937 pMessageQueue_50CBD0->AddMessage(UIMSG_Game_Action, 0, 0); | |
1938 continue; | |
1939 } | |
1940 if ( pCurrentScreen == SCREEN_NPC_DIALOGUE || pCurrentScreen == SCREEN_BRANCHLESS_NPC_DIALOG ) | |
1941 { | |
1942 v15 = pMessageQueue_50CBD0->uNumMessages; | |
1943 if ( pMessageQueue_50CBD0->uNumMessages ) | |
1944 { | |
1945 v15 = 0; | |
1946 if ( pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].field_8 ) | |
1947 { | |
1948 v15 = 1; | |
1949 pMessageQueue_50CBD0->uNumMessages = 0; | |
1950 pMessageQueue_50CBD0->pMessages[v15].eType = UIMSG_Escape; | |
1951 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; | |
1952 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; | |
1953 ++pMessageQueue_50CBD0->uNumMessages; | |
1954 continue; | |
1955 } | |
1956 pMessageQueue_50CBD0->uNumMessages = 0; | |
1957 } | |
1958 //pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); | |
1959 } | |
1960 } | |
1052 | 1961 }*/ |
0 | 1962 if ( !pEventTimer->bPaused ) |
1963 { | |
998 | 1964 for ( uint i = 0; i < 30; ++i ) |
0 | 1965 { |
998 | 1966 inputAction = (InputAction)i; |
1967 if ( pKeyActionMap->pToggleTypes[(InputAction)i] ) | |
1968 v4 = pKeyboard->WasKeyPressed(pKeyActionMap->pVirtualKeyCodesMapping[(InputAction)i]); | |
0 | 1969 else |
998 | 1970 v4 = pKeyboard->IsKeyBeingHeld(pKeyActionMap->pVirtualKeyCodesMapping[(InputAction)i]); |
0 | 1971 if ( v4 ) |
1972 { | |
1973 switch ( inputAction ) | |
1974 { | |
1975 case INPUT_MoveForward: | |
271 | 1976 if (pCurrentScreen != SCREEN_GAME) |
0 | 1977 break; |
1978 if (!pParty->bTurnBasedModeOn) | |
1979 { | |
140 | 1980 if ( pParty->uFlags2 & PARTY_FLAGS_2_RUNNING) |
0 | 1981 partyAction = PARTY_RunForward; |
1982 else | |
1983 partyAction = PARTY_WalkForward; | |
998 | 1984 pPartyActionQueue->Add(partyAction); |
163 | 1985 break; |
1986 } | |
1340 | 1987 if (pTurnEngine->turn_stage != 1 && pTurnEngine->turn_stage != 2 && pTurnEngine->uActionPointsLeft > 0 ) |
163 | 1988 { |
1989 pTurnEngine->uActionPointsLeft -= 26; | |
1990 if ( pParty->uFlags2 & PARTY_FLAGS_2_RUNNING) | |
1991 partyAction = PARTY_RunForward; | |
1992 else | |
1993 partyAction = PARTY_WalkForward; | |
998 | 1994 pPartyActionQueue->Add(partyAction); |
163 | 1995 break; |
0 | 1996 } |
1997 break; | |
1998 case INPUT_MoveBackwards: | |
271 | 1999 if (pCurrentScreen != SCREEN_GAME) |
0 | 2000 break; |
2001 if (!pParty->bTurnBasedModeOn) | |
17 | 2002 { |
2003 if ( pParty->uFlags2 & 2 ) | |
2004 partyAction = PARTY_RunBackward; | |
2005 else | |
2006 partyAction = PARTY_WalkBackward; | |
998 | 2007 pPartyActionQueue->Add(partyAction); |
163 | 2008 break; |
17 | 2009 } |
1340 | 2010 if ( pTurnEngine->turn_stage != 1 && pTurnEngine->turn_stage != 2 && pTurnEngine->uActionPointsLeft > 0 ) |
0 | 2011 { |
2012 pTurnEngine->uActionPointsLeft -= 26; | |
2013 if ( pParty->uFlags2 & 2 ) | |
2014 partyAction = PARTY_RunBackward; | |
2015 else | |
2016 partyAction = PARTY_WalkBackward; | |
998 | 2017 pPartyActionQueue->Add(partyAction); |
163 | 2018 break; |
0 | 2019 } |
2020 break; | |
2021 case INPUT_StrafeLeft: | |
271 | 2022 if (pCurrentScreen != SCREEN_GAME) |
0 | 2023 break; |
2024 if (!pParty->bTurnBasedModeOn) | |
17 | 2025 { |
2026 partyAction = PARTY_StrafeLeft; | |
998 | 2027 pPartyActionQueue->Add(partyAction); |
163 | 2028 break; |
17 | 2029 } |
1340 | 2030 if ( pTurnEngine->turn_stage == 1 || pTurnEngine->turn_stage == 2 || pTurnEngine->uActionPointsLeft <= 0 ) |
0 | 2031 break; |
2032 pTurnEngine->uActionPointsLeft -= 26; | |
2033 partyAction = PARTY_StrafeLeft; | |
998 | 2034 pPartyActionQueue->Add(partyAction); |
2035 break; | |
0 | 2036 case INPUT_StrafeRight: |
271 | 2037 if (pCurrentScreen != SCREEN_GAME) |
0 | 2038 break; |
2039 if (!pParty->bTurnBasedModeOn) | |
17 | 2040 { |
2041 partyAction = PARTY_StrafeRight; | |
998 | 2042 pPartyActionQueue->Add(partyAction); |
163 | 2043 break; |
17 | 2044 } |
1340 | 2045 if ( pTurnEngine->turn_stage == 1 || pTurnEngine->turn_stage == 2 || pTurnEngine->uActionPointsLeft <= 0 ) |
0 | 2046 break; |
2047 pTurnEngine->uActionPointsLeft -= 26; | |
2048 partyAction = PARTY_StrafeRight; | |
998 | 2049 pPartyActionQueue->Add(partyAction); |
163 | 2050 break; |
0 | 2051 case INPUT_TurnLeft: |
271 | 2052 if (pCurrentScreen != SCREEN_GAME) |
0 | 2053 break; |
2054 if ( GetAsyncKeyState(VK_CONTROL) ) // strafing | |
2055 { | |
2056 if (pParty->bTurnBasedModeOn) | |
2057 { | |
1340 | 2058 if ( pTurnEngine->turn_stage == 1 || pTurnEngine->turn_stage == 2 || pTurnEngine->uActionPointsLeft <= 0 ) |
0 | 2059 break; |
2060 pTurnEngine->uActionPointsLeft -= 26; | |
2061 } | |
998 | 2062 partyAction = PARTY_StrafeLeft; |
0 | 2063 } |
2064 else | |
2065 { | |
2066 if ( pParty->uFlags2 & 2 ) | |
998 | 2067 partyAction = PARTY_FastTurnLeft; |
0 | 2068 else |
998 | 2069 partyAction = PARTY_TurnLeft; |
0 | 2070 } |
998 | 2071 pPartyActionQueue->Add(partyAction); |
0 | 2072 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor && pWeather->bRenderSnow) |
2073 { | |
271 | 2074 pWeather->OnPlayerTurn(10); |
0 | 2075 } |
2076 break; | |
2077 case INPUT_TurnRight: | |
271 | 2078 if (pCurrentScreen != SCREEN_GAME) |
0 | 2079 break; |
2080 if ( GetAsyncKeyState(17) ) // strafing | |
2081 { | |
2082 if (pParty->bTurnBasedModeOn) | |
2083 { | |
1340 | 2084 if ( pTurnEngine->turn_stage == 1 || pTurnEngine->turn_stage == 2 || pTurnEngine->uActionPointsLeft <= 0 ) |
0 | 2085 break; |
2086 pTurnEngine->uActionPointsLeft -= 26; | |
2087 } | |
998 | 2088 partyAction = PARTY_StrafeRight; |
0 | 2089 } |
2090 else | |
2091 { | |
2092 if ( pParty->uFlags2 & 2 ) | |
998 | 2093 partyAction = PARTY_FastTurnRight; |
0 | 2094 else |
998 | 2095 partyAction = PARTY_TurnRight; |
0 | 2096 } |
998 | 2097 pPartyActionQueue->Add(partyAction); |
0 | 2098 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor && pWeather->bRenderSnow) |
2099 { | |
271 | 2100 pWeather->OnPlayerTurn(-10); |
0 | 2101 } |
2102 break; | |
2103 case INPUT_Jump: | |
271 | 2104 if (pCurrentScreen != SCREEN_GAME || pParty->bTurnBasedModeOn) |
0 | 2105 break; |
2106 partyAction = (PartyAction)12; | |
998 | 2107 pPartyActionQueue->Add(partyAction); |
163 | 2108 break; |
0 | 2109 case INPUT_Yell: |
187 | 2110 if (!pCurrentScreen && uActiveCharacter) |
0 | 2111 { |
2112 pParty->Yell(); | |
187 | 2113 pPlayers[uActiveCharacter]->PlaySound(SPEECH_Yell, 0); |
0 | 2114 } |
187 | 2115 break; |
0 | 2116 case INPUT_Pass: |
2117 if ( pCurrentScreen ) | |
2118 break; | |
1340 | 2119 if (pParty->bTurnBasedModeOn && pTurnEngine->turn_stage == 3) |
17 | 2120 { |
1332 | 2121 pTurnEngine->field_18 |= TE_FLAG_8; |
17 | 2122 break; |
2123 } | |
0 | 2124 if ( uActiveCharacter ) |
2125 { | |
998 | 2126 if ( !pPlayers[uActiveCharacter]->uTimeToRecovery ) |
0 | 2127 { |
998 | 2128 v24 = pPlayers[uActiveCharacter]->GetAttackRecoveryTime(false); |
0 | 2129 if ( !pParty->bTurnBasedModeOn ) |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
2130 pPlayers[uActiveCharacter]->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * (double)v24 * 2.133333333333333)); |
1202 | 2131 pCastSpellInfo.data()->_427D48(uActiveCharacter); |
0 | 2132 pTurnEngine->_40471C(); |
2133 } | |
2134 } | |
2135 break; | |
998 | 2136 case INPUT_Combat://if press ENTER |
271 | 2137 if (pCurrentScreen == SCREEN_GAME) |
0 | 2138 { |
2139 if (pParty->bTurnBasedModeOn) | |
2140 { | |
1340 | 2141 if (pTurnEngine->turn_stage == 3 || PID_TYPE(pTurnEngine->pQueue[0].uPackedID) == OBJECT_Player) |
0 | 2142 { |
2143 pParty->bTurnBasedModeOn = 0; | |
2144 pTurnEngine->End(true); | |
2145 } | |
2146 } | |
2147 else | |
2148 { | |
2149 pTurnEngine->Start(); | |
2150 pParty->bTurnBasedModeOn = true; | |
2151 } | |
2152 } | |
2153 break; | |
2154 case INPUT_CastReady: | |
271 | 2155 if (pCurrentScreen != SCREEN_GAME) |
0 | 2156 break; |
1340 | 2157 if (pParty->bTurnBasedModeOn && pTurnEngine->turn_stage == 3) |
17 | 2158 { |
1332 | 2159 pTurnEngine->field_18 |= TE_FLAG_8; |
17 | 2160 break; |
2161 } | |
0 | 2162 if ( !uActiveCharacter ) |
2163 break; | |
998 | 2164 v8 = pPlayers[uActiveCharacter]->uQuickSpell; |
0 | 2165 if ( !v8 |
2166 || bUnderwater | |
998 | 2167 || ((v9 = pPlayers[uActiveCharacter]->pActiveSkills[(unsigned __int8)v8 / 11 + 12], !(HIBYTE(v9) & 1)) ? |
2168 ((v9 & 0x80u) == 0 ? (!(v9 & 0x40) ? (v10 = *(&pSpellDatas[0].uNormalLevelMana + 10 * (unsigned __int8)v8)) : | |
2169 (v10 = *(&pSpellDatas[0].uExpertLevelMana + 10 * (unsigned __int8)v8))) : | |
2170 (v10 = *(&pSpellDatas[0].uMasterLevelMana + 10 * (unsigned __int8)v8))) : | |
2171 (v10 = *(&pSpellDatas[0].uMagisterLevelMana + 10 * (unsigned __int8)v8)), | |
2172 v10 > pPlayers[uActiveCharacter]->sMana) ) | |
0 | 2173 { |
998 | 2174 pPartyActionQueue = pPartyActionQueue; |
437 | 2175 pMessageQueue_50CBD0->AddMessage(UIMSG_Attack, 0, 0); |
2176 break; | |
0 | 2177 } |
2178 else | |
2179 { | |
1012 | 2180 pMessageQueue_50C9E8->AddMessage(UIMSG_CastQuickSpell, 0, 0); |
0 | 2181 } |
2182 break; | |
2183 case INPUT_Attack: | |
271 | 2184 if (pCurrentScreen != SCREEN_GAME) |
0 | 2185 break; |
1340 | 2186 if (pParty->bTurnBasedModeOn == 1 && pTurnEngine->turn_stage == 3) |
998 | 2187 { |
1332 | 2188 pTurnEngine->field_18 |= TE_FLAG_8; |
998 | 2189 break; |
2190 } | |
2191 pMessageQueue_50CBD0->AddMessage(UIMSG_Attack, 0, 0); | |
0 | 2192 break; |
2193 case INPUT_EventTrigger: | |
271 | 2194 if (pCurrentScreen == SCREEN_GAME) |
0 | 2195 { |
437 | 2196 pMessageQueue_50CBD0->AddMessage(UIMSG_Game_Action, 0, 0); |
163 | 2197 break; |
0 | 2198 } |
151 | 2199 if ( pCurrentScreen == SCREEN_NPC_DIALOGUE ) |
0 | 2200 { |
2201 if ( pMessageQueue_50CBD0->uNumMessages ) | |
2202 { | |
437 | 2203 pMessageQueue_50CBD0->uNumMessages = 0; |
0 | 2204 if ( pMessageQueue_50CBD0->pMessages[0].field_8 ) |
2205 { | |
2206 pMessageQueue_50CBD0->uNumMessages = 1; | |
998 | 2207 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape; |
0 | 2208 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; |
2209 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; | |
2210 ++pMessageQueue_50CBD0->uNumMessages; | |
2211 break; | |
2212 } | |
437 | 2213 break; |
0 | 2214 } |
437 | 2215 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); |
0 | 2216 } |
2217 break; | |
2218 case INPUT_CharCycle: | |
1012 | 2219 if ( pCurrentScreen == SCREEN_SPELL_BOOK ) |
0 | 2220 break; |
1012 | 2221 /* dword_50C9EC[3 * dword_50C9E8] = 176;|| dword_50C9E8 >= 40 |
437 | 2222 dword_50C9EC[3 * dword_50C9E8 + 1] = 0; |
2223 dword_50C9EC[3 * dword_50C9E8 + 2] = 0; | |
1012 | 2224 ++dword_50C9E8;*/ |
2225 pMessageQueue_50C9E8->AddMessage(UIMSG_CycleCharacters, 0, 0); | |
163 | 2226 break; |
0 | 2227 case INPUT_LookUp: |
2228 if ( pEventTimer->bPaused ) | |
2229 break; | |
2230 partyAction = (PartyAction)7; | |
998 | 2231 pPartyActionQueue->Add(partyAction); |
163 | 2232 break; |
0 | 2233 case INPUT_CenterView: |
2234 if ( pEventTimer->bPaused ) | |
2235 break; | |
2236 partyAction = (PartyAction)9; | |
998 | 2237 pPartyActionQueue->Add(partyAction); |
163 | 2238 break; |
0 | 2239 case INPUT_LookDown: |
2240 if ( pEventTimer->bPaused ) | |
2241 break; | |
2242 partyAction = (PartyAction)8; | |
998 | 2243 pPartyActionQueue->Add(partyAction); |
163 | 2244 break; |
0 | 2245 case INPUT_FlyUp: |
998 | 2246 if ( pCurrentScreen || pEventTimer->bPaused ) |
0 | 2247 break; |
2248 partyAction = (PartyAction)13; | |
998 | 2249 pPartyActionQueue->Add(partyAction); |
163 | 2250 break; |
0 | 2251 case INPUT_Land: |
998 | 2252 if ( pCurrentScreen || pEventTimer->bPaused ) |
0 | 2253 break; |
2254 partyAction = (PartyAction)15; | |
998 | 2255 pPartyActionQueue->Add(partyAction); |
163 | 2256 break; |
0 | 2257 case INPUT_FlyDown: |
2258 if ( !pCurrentScreen | |
2259 && !pEventTimer->bPaused ) | |
2260 { | |
2261 partyAction = (PartyAction)14; | |
998 | 2262 pPartyActionQueue->Add(partyAction); |
0 | 2263 } |
2264 break; | |
2265 case INPUT_ZoomIn: | |
1012 | 2266 /*if ( dword_50C9E8 >= 40 ) |
0 | 2267 break; |
2268 dword_50C9EC[3 * dword_50C9E8] = 367; | |
437 | 2269 dword_50C9EC[3 * dword_50C9E8 + 1] = 0; |
2270 dword_50C9EC[3 * dword_50C9E8 + 2] = 0; | |
1012 | 2271 ++dword_50C9E8;*/ |
2272 pMessageQueue_50C9E8->AddMessage(UIMSG_ClickZoomOutBtn, 0, 0); | |
163 | 2273 break; |
0 | 2274 case INPUT_ZoomOut: |
1012 | 2275 /*if ( dword_50C9E8 < 40 ) |
0 | 2276 { |
2277 dword_50C9EC[3 * dword_50C9E8] = 368; | |
437 | 2278 dword_50C9EC[3 * dword_50C9E8 + 1] = 0; |
2279 dword_50C9EC[3 * dword_50C9E8 + 2] = 0; | |
0 | 2280 ++dword_50C9E8; |
1012 | 2281 }*/ |
2282 pMessageQueue_50C9E8->AddMessage(UIMSG_ClickZoomInBtn, 0, 0); | |
0 | 2283 break; |
2284 case INPUT_AlwaysRun: | |
2285 bAlwaysRun = bAlwaysRun == 0; | |
2286 break; | |
17 | 2287 default: |
2288 break; | |
0 | 2289 } |
2290 } | |
2291 } | |
2292 } | |
2293 } |