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