Mercurial > mm7
annotate mm7_6.cpp @ 1440:a72236d60edc
m
author | Ritor1 |
---|---|
date | Sat, 27 Jul 2013 09:36:29 +0600 |
parents | cc9a3a24d61d |
children | d071e0e9ba75 |
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 { | |
1610 unsigned int v9; // edi@1 | |
1611 signed int v10; // edx@3 | |
1612 char *v11; // ecx@4 | |
1613 unsigned __int16 v12; // ax@7 | |
1614 unsigned int v13; // edx@9 | |
1615 char *v14; // ecx@10 | |
1616 int v15; // esi@17 | |
1617 int v16; // eax@18 | |
1618 int v17; // edi@20 | |
1619 int v18; // esi@20 | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
490
diff
changeset
|
1620 //SpriteObject a1a; // [sp+Ch] [bp-78h]@1 |
0 | 1621 int v21; // [sp+7Ch] [bp-8h]@1 |
1622 unsigned int v22; // [sp+80h] [bp-4h]@1 | |
1623 | |
1624 v9 = uSpriteID; | |
1625 v21 = x; | |
1626 v22 = uSpriteID; | |
1627 | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
490
diff
changeset
|
1628 SpriteObject a1a; // [sp+Ch] [bp-78h]@1 |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
490
diff
changeset
|
1629 //SpriteObject::SpriteObject(&a1a); |
0 | 1630 a1a.stru_24.Reset(); |
1631 | |
1632 if ( a9 ) | |
1633 { | |
1634 memcpy(&a1a.stru_24, a9, sizeof(a1a.stru_24)); | |
1635 v9 = v22; | |
1636 } | |
1637 v10 = 0; | |
822 | 1638 a1a.spell_skill = 0; |
1639 a1a.spell_level = 0; | |
1640 a1a.spell_id = 0; | |
0 | 1641 a1a.field_54 = 0; |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
490
diff
changeset
|
1642 a1a.uType = v9; |
0 | 1643 if ( (signed int)pObjectList->uNumObjects <= 0 ) |
1644 { | |
1645 LABEL_7: | |
1646 v12 = 0; | |
1647 } | |
1648 else | |
1649 { | |
1650 v11 = (char *)&pObjectList->pObjects->uObjectID; | |
1651 while ( (short)v9 != *(short *)v11 ) | |
1652 { | |
1653 ++v10; | |
1654 v11 += 56; | |
1655 if ( v10 >= (signed int)pObjectList->uNumObjects ) | |
1656 goto LABEL_7; | |
1657 } | |
1658 v12 = v10; | |
1659 } | |
1660 a1a.uObjectDescID = v12; | |
1661 a1a.vPosition.z = z; | |
1662 a1a.vPosition.x = v21; | |
1663 a1a.vPosition.y = y; | |
1664 a1a.uSoundID = 0; | |
1665 a1a.uAttributes = attributes; | |
1666 a1a.uSectorID = pIndoor->GetSector(v21, y, z); | |
1667 a1a.uSpriteFrameID = 0; | |
822 | 1668 a1a.spell_caster_pid = 0; |
823 | 1669 a1a.spell_target_pid = 0; |
0 | 1670 if ( !(a1a.uAttributes & 0x10) ) |
1671 { | |
1672 v13 = 0; | |
222 | 1673 if ( (signed int)pItemsTable->uAllItemsCount > 0 ) |
0 | 1674 { |
1675 v14 = (char *)&pItemsTable->pItems[0].uSpriteID; | |
1676 while ( *(short *)v14 != v9 ) | |
1677 { | |
1678 ++v13; | |
1679 v14 += 48; | |
222 | 1680 if ( (signed int)v13 >= (signed int)pItemsTable->uAllItemsCount ) |
0 | 1681 goto LABEL_16; |
1682 } | |
1683 a1a.stru_24.uItemID = v13; | |
1684 } | |
1685 } | |
1686 LABEL_16: | |
1687 if ( a7 ) | |
1688 { | |
1689 v15 = count; | |
1690 if ( count > 0 ) | |
1691 { | |
1692 do | |
1693 { | |
1694 a1a.uFacing = rand() % (signed int)stru_5C6E00->uIntegerDoublePi; | |
1695 v16 = rand(); | |
1696 a1a.Create( | |
1697 (signed __int16)a1a.uFacing, | |
1698 ((signed int)stru_5C6E00->uIntegerHalfPi >> 1) + (v16 % (signed int)stru_5C6E00->uIntegerHalfPi >> 1), | |
1699 a4, | |
1700 0); | |
1701 --v15; | |
1702 } | |
1703 while ( v15 ); | |
1704 } | |
1705 } | |
1706 else | |
1707 { | |
1708 v17 = count; | |
1709 v18 = stru_5C6E00->uIntegerHalfPi; | |
1710 a1a.uFacing = 0; | |
1711 if ( count > 0 ) | |
1712 { | |
1713 do | |
1714 { | |
1715 a1a.Create((signed __int16)a1a.uFacing, v18, a4, 0); | |
1716 --v17; | |
1717 } | |
1718 while ( v17 ); | |
1719 } | |
1720 } | |
1721 return 1; | |
1722 } | |
1723 | |
1724 //----- (0042F960) -------------------------------------------------------- | |
1725 void __fastcall sub_42F960_create_object(int x, int y, int z) | |
1726 { | |
1727 int v3; // ebx@1 | |
1728 int v4; // edi@1 | |
1729 signed int v5; // edx@1 | |
1730 char *v6; // ecx@2 | |
1731 unsigned __int16 v7; // ax@5 | |
1732 signed int v8; // eax@6 | |
1733 signed int v9; // eax@7 | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
490
diff
changeset
|
1734 //SpriteObject a1; // [sp+Ch] [bp-70h]@1 |
0 | 1735 |
1736 v3 = x; | |
1737 v4 = y; | |
1738 | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
490
diff
changeset
|
1739 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
|
1740 //SpriteObject::SpriteObject(&a1); |
0 | 1741 a1.stru_24.Reset(); |
1742 | |
1743 v5 = 0; | |
822 | 1744 a1.spell_skill = 0; |
1745 a1.spell_level = 0; | |
1746 a1.spell_id = 0; | |
0 | 1747 a1.field_54 = 0; |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
490
diff
changeset
|
1748 a1.uType = 800; |
0 | 1749 if ( (signed int)pObjectList->uNumObjects <= 0 ) |
1750 { | |
1751 LABEL_5: | |
1752 v7 = 0; | |
1753 } | |
1754 else | |
1755 { | |
1756 v6 = (char *)&pObjectList->pObjects->uObjectID; | |
1757 while ( *(short *)v6 != 800 ) | |
1758 { | |
1759 ++v5; | |
1760 v6 += 56; | |
1761 if ( v5 >= (signed int)pObjectList->uNumObjects ) | |
1762 goto LABEL_5; | |
1763 } | |
1764 v7 = v5; | |
1765 } | |
1766 a1.uObjectDescID = v7; | |
1767 a1.vPosition.x = v3; | |
1768 a1.vPosition.y = v4; | |
1769 a1.vPosition.z = z; | |
1770 a1.uSoundID = 0; | |
1771 a1.uAttributes = 0; | |
1772 a1.uSectorID = pIndoor->GetSector(v3, v4, z); | |
1773 a1.uSpriteFrameID = 0; | |
822 | 1774 a1.spell_caster_pid = 0; |
823 | 1775 a1.spell_target_pid = 0; |
0 | 1776 v8 = a1.Create(0, 0, 0, 0); |
1777 if ( v8 != -1 ) | |
1778 { | |
1779 v9 = 8 * v8; | |
1780 LOBYTE(v9) = v9 | 2; | |
1781 pAudioPlayer->PlaySound((SoundID)(SOUND_GoldReceived|0x14), v9, 0, -1, 0, 0, 0, 0); | |
1782 } | |
1783 } | |
1784 | |
810 | 1785 |
0 | 1786 |
1787 //----- (0042FA66) -------------------------------------------------------- | |
1788 int __fastcall _42FA66_do_explosive_impact(int a1, int a2, int a3, int a4, __int16 a5, signed int a6) | |
1789 { | |
1790 int v6; // edi@1 | |
1791 int v7; // esi@1 | |
1792 char *v8; // ecx@2 | |
1793 unsigned __int16 v9; // ax@5 | |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
1794 //int v10; // eax@10 |
0 | 1795 signed int result; // eax@11 |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
1796 //__int16 v12; // ax@12 |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
490
diff
changeset
|
1797 //SpriteObject a1a; // [sp+Ch] [bp-74h]@1 |
0 | 1798 int v14; // [sp+7Ch] [bp-4h]@1 |
1799 | |
1800 v6 = a1; | |
1801 v7 = a2; | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
490
diff
changeset
|
1802 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
|
1803 //SpriteObject::SpriteObject(&a1a); |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
490
diff
changeset
|
1804 a1a.uType = 600; |
0 | 1805 a1a.stru_24.Reset(); |
1806 | |
822 | 1807 a1a.spell_id = SPELL_FIRE_FIREBALL; |
1808 a1a.spell_level = 8; | |
1809 a1a.spell_skill = 3; | |
0 | 1810 v14 = 0; |
1811 if ( (signed int)pObjectList->uNumObjects <= 0 ) | |
1812 { | |
1813 LABEL_5: | |
1814 v9 = 0; | |
1815 } | |
1816 else | |
1817 { | |
1818 v8 = (char *)&pObjectList->pObjects->uObjectID; | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
490
diff
changeset
|
1819 while ( (short)a1a.uType != *(short *)v8 ) |
0 | 1820 { |
1821 ++v14; | |
1822 v8 += 56; | |
1823 if ( v14 >= (signed int)pObjectList->uNumObjects ) | |
1824 goto LABEL_5; | |
1825 } | |
1826 v9 = v14; | |
1827 } | |
1828 a1a.uObjectDescID = v9; | |
1829 a1a.vPosition.x = v6; | |
1830 a1a.vPosition.y = v7; | |
1831 a1a.vPosition.z = a3; | |
1832 a1a.uAttributes = 0; | |
1833 a1a.uSectorID = pIndoor->GetSector(v6, v7, a3); | |
1834 a1a.uSpriteFrameID = 0; | |
823 | 1835 a1a.spell_target_pid = 0; |
0 | 1836 a1a.field_60_distance_related_prolly_lod = 0; |
1837 a1a.uFacing = 0; | |
1838 a1a.uSoundID = 0; | |
1839 if ( a6 >= 1 || a6 <= 4 ) | |
1840 { | |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
1841 a1a.spell_caster_pid = PID(OBJECT_Player, a6 - 1); |
0 | 1842 } |
1843 else | |
1844 { | |
822 | 1845 a1a.spell_caster_pid = 0; |
0 | 1846 } |
1847 result = a1a.Create(0, 0, 0, 0); | |
1848 if ( result != -1 ) | |
1849 { | |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
1850 result = stru_50FE08.Add(PID(OBJECT_Item, result), |
0 | 1851 a5, |
1852 SLOWORD(a1a.vPosition.x), | |
1853 SLOWORD(a1a.vPosition.y), | |
1854 SLOWORD(a1a.vPosition.z), | |
1855 0, | |
1856 0); | |
1857 } | |
1858 return result; | |
1859 } | |
1860 | |
1861 //----- (0042FB5C) -------------------------------------------------------- | |
1862 bool __fastcall sub_42FB5C(signed int a1) | |
1863 { | |
1864 int v1; // ecx@3 | |
1865 int v2; // ecx@4 | |
1866 int v3; // ecx@5 | |
1867 int v4; // ecx@6 | |
1868 int v5; // ecx@7 | |
1869 int v6; // ecx@8 | |
1870 char v7; // zf@9 | |
1871 | |
1872 if ( a1 > 39 ) | |
1873 { | |
1874 if ( a1 > 77 ) | |
1875 { | |
1876 if ( a1 == 80 ) | |
1877 return 0; | |
1878 if ( a1 > 84 ) | |
1879 { | |
1880 if ( a1 <= 86 ) | |
1881 return 0; | |
1882 v7 = a1 == 95; | |
1883 goto LABEL_20; | |
1884 } | |
1885 } | |
1886 else | |
1887 { | |
1888 if ( a1 == 77 ) | |
1889 return 0; | |
1890 if ( a1 >= 46 ) | |
1891 { | |
1892 if ( a1 <= 47 || a1 == 51 ) | |
1893 return 0; | |
1894 v7 = a1 == 73; | |
1895 goto LABEL_20; | |
1896 } | |
1897 } | |
1898 return 1; | |
1899 } | |
1900 if ( a1 == 39 || (v1 = a1 - 2) == 0 ) | |
1901 return 1; | |
1902 v2 = v1 - 3; | |
1903 if ( !v2 ) | |
1904 return 0; | |
1905 v3 = v2 - 1; | |
1906 if ( !v3 || (v4 = v3 - 3) == 0 ) | |
1907 return 1; | |
1908 v5 = v4 - 8; | |
1909 if ( !v5 ) | |
1910 return 0; | |
1911 v6 = v5 - 1; | |
1912 if ( !v6 ) | |
1913 return 1; | |
1914 v7 = v6 == 20; | |
1915 LABEL_20: | |
1916 if ( !v7 ) | |
1917 return 1; | |
1918 return 0; | |
1919 } | |
1920 | |
1921 //----- (0042FBDD) -------------------------------------------------------- | |
1922 void __cdecl sub_42FBDD() | |
1923 { | |
388 | 1924 pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); |
0 | 1925 pRenderer->DrawTextureTransparent(pBtn_YES->uX, pBtn_YES->uY, pBtn_YES->pTextures[0]); |
1926 pRenderer->Present(); | |
1927 } | |
1928 | |
1929 //----- (0042FC15) -------------------------------------------------------- | |
11 | 1930 void __cdecl CloseWindowBackground() |
0 | 1931 { |
388 | 1932 pAudioPlayer->PlaySound(SOUND_Button2, -2, 0, -1, 0, 0, 0, 0); |
0 | 1933 pRenderer->DrawTextureTransparent(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY, pBtn_ExitCancel->pTextures[0]); |
1934 pRenderer->Present(); | |
1935 } | |
1936 | |
1937 //----- (0042FC4E) -------------------------------------------------------- | |
1938 void __cdecl ProcessInputActions() | |
1939 { | |
1940 char v4; // al@9 | |
1941 char v8; // bl@100 | |
1942 unsigned __int16 v9; // ax@102 | |
1943 int v10; // eax@103 | |
1944 char v14; // al@159 | |
1945 unsigned int v15; // eax@168 | |
1946 PartyAction partyAction; // [sp-14h] [bp-1Ch]@20 | |
1947 InputAction inputAction; // [sp+0h] [bp-8h]@7 | |
1948 int v24; // [sp+4h] [bp-4h]@87 | |
1949 | |
1950 pGame->pKeyboardInstance->EnterCriticalSection(); | |
1951 auto pKeyboard = pGame->pKeyboardInstance; | |
1952 if (!bAlwaysRun) | |
1953 { | |
1954 if (pKeyboard->IsShiftHeld()) | |
1955 pParty->uFlags2 |= PARTY_FLAGS_2_RUNNING; | |
1956 else | |
1957 pParty->uFlags2 &= ~PARTY_FLAGS_2_RUNNING; | |
1958 } | |
1959 else | |
1960 { | |
1961 if (pKeyboard->IsShiftHeld()) | |
1962 pParty->uFlags2 &= ~PARTY_FLAGS_2_RUNNING; | |
1963 else | |
1964 pParty->uFlags2 |= PARTY_FLAGS_2_RUNNING; | |
1965 } | |
1966 | |
140 | 1967 //pParty->uFlags2 |= PARTY_FLAGS_2_RUNNING; |
1052 | 1968 |
1969 | |
1970 // WUT? double event trigger | |
1971 /*for ( uint i = 0; i < 30; ++i ) | |
998 | 1972 { |
1973 if ( pKeyActionMap->pToggleTypes[i] ) | |
1974 v14 = pGame->pKeyboardInstance->WasKeyPressed(pKeyActionMap->pVirtualKeyCodesMapping[i]); | |
1975 else | |
1976 v14 = pGame->pKeyboardInstance->IsKeyBeingHeld(pKeyActionMap->pVirtualKeyCodesMapping[i]); | |
1052 | 1977 if ( v14 ) |
998 | 1978 { |
1052 | 1979 if (pCurrentScreen == SCREEN_GAME) |
998 | 1980 { |
1981 pMessageQueue_50CBD0->AddMessage(UIMSG_Game_Action, 0, 0); | |
1982 continue; | |
1983 } | |
1984 if ( pCurrentScreen == SCREEN_NPC_DIALOGUE || pCurrentScreen == SCREEN_BRANCHLESS_NPC_DIALOG ) | |
1985 { | |
1986 v15 = pMessageQueue_50CBD0->uNumMessages; | |
1987 if ( pMessageQueue_50CBD0->uNumMessages ) | |
1988 { | |
1989 v15 = 0; | |
1990 if ( pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].field_8 ) | |
1991 { | |
1992 v15 = 1; | |
1993 pMessageQueue_50CBD0->uNumMessages = 0; | |
1994 pMessageQueue_50CBD0->pMessages[v15].eType = UIMSG_Escape; | |
1995 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; | |
1996 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; | |
1997 ++pMessageQueue_50CBD0->uNumMessages; | |
1998 continue; | |
1999 } | |
2000 pMessageQueue_50CBD0->uNumMessages = 0; | |
2001 } | |
2002 //pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); | |
2003 } | |
2004 } | |
1052 | 2005 }*/ |
0 | 2006 if ( !pEventTimer->bPaused ) |
2007 { | |
998 | 2008 for ( uint i = 0; i < 30; ++i ) |
0 | 2009 { |
998 | 2010 inputAction = (InputAction)i; |
2011 if ( pKeyActionMap->pToggleTypes[(InputAction)i] ) | |
2012 v4 = pKeyboard->WasKeyPressed(pKeyActionMap->pVirtualKeyCodesMapping[(InputAction)i]); | |
0 | 2013 else |
998 | 2014 v4 = pKeyboard->IsKeyBeingHeld(pKeyActionMap->pVirtualKeyCodesMapping[(InputAction)i]); |
0 | 2015 if ( v4 ) |
2016 { | |
2017 switch ( inputAction ) | |
2018 { | |
2019 case INPUT_MoveForward: | |
271 | 2020 if (pCurrentScreen != SCREEN_GAME) |
0 | 2021 break; |
2022 if (!pParty->bTurnBasedModeOn) | |
2023 { | |
140 | 2024 if ( pParty->uFlags2 & PARTY_FLAGS_2_RUNNING) |
0 | 2025 partyAction = PARTY_RunForward; |
2026 else | |
2027 partyAction = PARTY_WalkForward; | |
998 | 2028 pPartyActionQueue->Add(partyAction); |
163 | 2029 break; |
2030 } | |
1340 | 2031 if (pTurnEngine->turn_stage != 1 && pTurnEngine->turn_stage != 2 && pTurnEngine->uActionPointsLeft > 0 ) |
163 | 2032 { |
2033 pTurnEngine->uActionPointsLeft -= 26; | |
2034 if ( pParty->uFlags2 & PARTY_FLAGS_2_RUNNING) | |
2035 partyAction = PARTY_RunForward; | |
2036 else | |
2037 partyAction = PARTY_WalkForward; | |
998 | 2038 pPartyActionQueue->Add(partyAction); |
163 | 2039 break; |
0 | 2040 } |
2041 break; | |
2042 case INPUT_MoveBackwards: | |
271 | 2043 if (pCurrentScreen != SCREEN_GAME) |
0 | 2044 break; |
2045 if (!pParty->bTurnBasedModeOn) | |
17 | 2046 { |
2047 if ( pParty->uFlags2 & 2 ) | |
2048 partyAction = PARTY_RunBackward; | |
2049 else | |
2050 partyAction = PARTY_WalkBackward; | |
998 | 2051 pPartyActionQueue->Add(partyAction); |
163 | 2052 break; |
17 | 2053 } |
1340 | 2054 if ( pTurnEngine->turn_stage != 1 && pTurnEngine->turn_stage != 2 && pTurnEngine->uActionPointsLeft > 0 ) |
0 | 2055 { |
2056 pTurnEngine->uActionPointsLeft -= 26; | |
2057 if ( pParty->uFlags2 & 2 ) | |
2058 partyAction = PARTY_RunBackward; | |
2059 else | |
2060 partyAction = PARTY_WalkBackward; | |
998 | 2061 pPartyActionQueue->Add(partyAction); |
163 | 2062 break; |
0 | 2063 } |
2064 break; | |
2065 case INPUT_StrafeLeft: | |
271 | 2066 if (pCurrentScreen != SCREEN_GAME) |
0 | 2067 break; |
2068 if (!pParty->bTurnBasedModeOn) | |
17 | 2069 { |
2070 partyAction = PARTY_StrafeLeft; | |
998 | 2071 pPartyActionQueue->Add(partyAction); |
163 | 2072 break; |
17 | 2073 } |
1340 | 2074 if ( pTurnEngine->turn_stage == 1 || pTurnEngine->turn_stage == 2 || pTurnEngine->uActionPointsLeft <= 0 ) |
0 | 2075 break; |
2076 pTurnEngine->uActionPointsLeft -= 26; | |
2077 partyAction = PARTY_StrafeLeft; | |
998 | 2078 pPartyActionQueue->Add(partyAction); |
2079 break; | |
0 | 2080 case INPUT_StrafeRight: |
271 | 2081 if (pCurrentScreen != SCREEN_GAME) |
0 | 2082 break; |
2083 if (!pParty->bTurnBasedModeOn) | |
17 | 2084 { |
2085 partyAction = PARTY_StrafeRight; | |
998 | 2086 pPartyActionQueue->Add(partyAction); |
163 | 2087 break; |
17 | 2088 } |
1340 | 2089 if ( pTurnEngine->turn_stage == 1 || pTurnEngine->turn_stage == 2 || pTurnEngine->uActionPointsLeft <= 0 ) |
0 | 2090 break; |
2091 pTurnEngine->uActionPointsLeft -= 26; | |
2092 partyAction = PARTY_StrafeRight; | |
998 | 2093 pPartyActionQueue->Add(partyAction); |
163 | 2094 break; |
0 | 2095 case INPUT_TurnLeft: |
271 | 2096 if (pCurrentScreen != SCREEN_GAME) |
0 | 2097 break; |
2098 if ( GetAsyncKeyState(VK_CONTROL) ) // strafing | |
2099 { | |
2100 if (pParty->bTurnBasedModeOn) | |
2101 { | |
1340 | 2102 if ( pTurnEngine->turn_stage == 1 || pTurnEngine->turn_stage == 2 || pTurnEngine->uActionPointsLeft <= 0 ) |
0 | 2103 break; |
2104 pTurnEngine->uActionPointsLeft -= 26; | |
2105 } | |
998 | 2106 partyAction = PARTY_StrafeLeft; |
0 | 2107 } |
2108 else | |
2109 { | |
2110 if ( pParty->uFlags2 & 2 ) | |
998 | 2111 partyAction = PARTY_FastTurnLeft; |
0 | 2112 else |
998 | 2113 partyAction = PARTY_TurnLeft; |
0 | 2114 } |
998 | 2115 pPartyActionQueue->Add(partyAction); |
0 | 2116 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor && pWeather->bRenderSnow) |
2117 { | |
271 | 2118 pWeather->OnPlayerTurn(10); |
0 | 2119 } |
2120 break; | |
2121 case INPUT_TurnRight: | |
271 | 2122 if (pCurrentScreen != SCREEN_GAME) |
0 | 2123 break; |
2124 if ( GetAsyncKeyState(17) ) // strafing | |
2125 { | |
2126 if (pParty->bTurnBasedModeOn) | |
2127 { | |
1340 | 2128 if ( pTurnEngine->turn_stage == 1 || pTurnEngine->turn_stage == 2 || pTurnEngine->uActionPointsLeft <= 0 ) |
0 | 2129 break; |
2130 pTurnEngine->uActionPointsLeft -= 26; | |
2131 } | |
998 | 2132 partyAction = PARTY_StrafeRight; |
0 | 2133 } |
2134 else | |
2135 { | |
2136 if ( pParty->uFlags2 & 2 ) | |
998 | 2137 partyAction = PARTY_FastTurnRight; |
0 | 2138 else |
998 | 2139 partyAction = PARTY_TurnRight; |
0 | 2140 } |
998 | 2141 pPartyActionQueue->Add(partyAction); |
0 | 2142 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor && pWeather->bRenderSnow) |
2143 { | |
271 | 2144 pWeather->OnPlayerTurn(-10); |
0 | 2145 } |
2146 break; | |
2147 case INPUT_Jump: | |
271 | 2148 if (pCurrentScreen != SCREEN_GAME || pParty->bTurnBasedModeOn) |
0 | 2149 break; |
2150 partyAction = (PartyAction)12; | |
998 | 2151 pPartyActionQueue->Add(partyAction); |
163 | 2152 break; |
0 | 2153 case INPUT_Yell: |
187 | 2154 if (!pCurrentScreen && uActiveCharacter) |
0 | 2155 { |
2156 pParty->Yell(); | |
187 | 2157 pPlayers[uActiveCharacter]->PlaySound(SPEECH_Yell, 0); |
0 | 2158 } |
187 | 2159 break; |
0 | 2160 case INPUT_Pass: |
2161 if ( pCurrentScreen ) | |
2162 break; | |
1340 | 2163 if (pParty->bTurnBasedModeOn && pTurnEngine->turn_stage == 3) |
17 | 2164 { |
1332 | 2165 pTurnEngine->field_18 |= TE_FLAG_8; |
17 | 2166 break; |
2167 } | |
0 | 2168 if ( uActiveCharacter ) |
2169 { | |
998 | 2170 if ( !pPlayers[uActiveCharacter]->uTimeToRecovery ) |
0 | 2171 { |
998 | 2172 v24 = pPlayers[uActiveCharacter]->GetAttackRecoveryTime(false); |
0 | 2173 if ( !pParty->bTurnBasedModeOn ) |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
2174 pPlayers[uActiveCharacter]->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * (double)v24 * 2.133333333333333)); |
1202 | 2175 pCastSpellInfo.data()->_427D48(uActiveCharacter); |
0 | 2176 pTurnEngine->_40471C(); |
2177 } | |
2178 } | |
2179 break; | |
998 | 2180 case INPUT_Combat://if press ENTER |
271 | 2181 if (pCurrentScreen == SCREEN_GAME) |
0 | 2182 { |
2183 if (pParty->bTurnBasedModeOn) | |
2184 { | |
1340 | 2185 if (pTurnEngine->turn_stage == 3 || PID_TYPE(pTurnEngine->pQueue[0].uPackedID) == OBJECT_Player) |
0 | 2186 { |
2187 pParty->bTurnBasedModeOn = 0; | |
2188 pTurnEngine->End(true); | |
2189 } | |
2190 } | |
2191 else | |
2192 { | |
2193 pTurnEngine->Start(); | |
2194 pParty->bTurnBasedModeOn = true; | |
2195 } | |
2196 } | |
2197 break; | |
2198 case INPUT_CastReady: | |
271 | 2199 if (pCurrentScreen != SCREEN_GAME) |
0 | 2200 break; |
1340 | 2201 if (pParty->bTurnBasedModeOn && pTurnEngine->turn_stage == 3) |
17 | 2202 { |
1332 | 2203 pTurnEngine->field_18 |= TE_FLAG_8; |
17 | 2204 break; |
2205 } | |
0 | 2206 if ( !uActiveCharacter ) |
2207 break; | |
998 | 2208 v8 = pPlayers[uActiveCharacter]->uQuickSpell; |
0 | 2209 if ( !v8 |
2210 || bUnderwater | |
998 | 2211 || ((v9 = pPlayers[uActiveCharacter]->pActiveSkills[(unsigned __int8)v8 / 11 + 12], !(HIBYTE(v9) & 1)) ? |
2212 ((v9 & 0x80u) == 0 ? (!(v9 & 0x40) ? (v10 = *(&pSpellDatas[0].uNormalLevelMana + 10 * (unsigned __int8)v8)) : | |
2213 (v10 = *(&pSpellDatas[0].uExpertLevelMana + 10 * (unsigned __int8)v8))) : | |
2214 (v10 = *(&pSpellDatas[0].uMasterLevelMana + 10 * (unsigned __int8)v8))) : | |
2215 (v10 = *(&pSpellDatas[0].uMagisterLevelMana + 10 * (unsigned __int8)v8)), | |
2216 v10 > pPlayers[uActiveCharacter]->sMana) ) | |
0 | 2217 { |
998 | 2218 pPartyActionQueue = pPartyActionQueue; |
437 | 2219 pMessageQueue_50CBD0->AddMessage(UIMSG_Attack, 0, 0); |
2220 break; | |
0 | 2221 } |
2222 else | |
2223 { | |
1012 | 2224 pMessageQueue_50C9E8->AddMessage(UIMSG_CastQuickSpell, 0, 0); |
0 | 2225 } |
2226 break; | |
2227 case INPUT_Attack: | |
271 | 2228 if (pCurrentScreen != SCREEN_GAME) |
0 | 2229 break; |
1340 | 2230 if (pParty->bTurnBasedModeOn == 1 && pTurnEngine->turn_stage == 3) |
998 | 2231 { |
1332 | 2232 pTurnEngine->field_18 |= TE_FLAG_8; |
998 | 2233 break; |
2234 } | |
2235 pMessageQueue_50CBD0->AddMessage(UIMSG_Attack, 0, 0); | |
0 | 2236 break; |
2237 case INPUT_EventTrigger: | |
271 | 2238 if (pCurrentScreen == SCREEN_GAME) |
0 | 2239 { |
437 | 2240 pMessageQueue_50CBD0->AddMessage(UIMSG_Game_Action, 0, 0); |
163 | 2241 break; |
0 | 2242 } |
151 | 2243 if ( pCurrentScreen == SCREEN_NPC_DIALOGUE ) |
0 | 2244 { |
2245 if ( pMessageQueue_50CBD0->uNumMessages ) | |
2246 { | |
437 | 2247 pMessageQueue_50CBD0->uNumMessages = 0; |
0 | 2248 if ( pMessageQueue_50CBD0->pMessages[0].field_8 ) |
2249 { | |
2250 pMessageQueue_50CBD0->uNumMessages = 1; | |
998 | 2251 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape; |
0 | 2252 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; |
2253 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; | |
2254 ++pMessageQueue_50CBD0->uNumMessages; | |
2255 break; | |
2256 } | |
437 | 2257 break; |
0 | 2258 } |
437 | 2259 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); |
0 | 2260 } |
2261 break; | |
2262 case INPUT_CharCycle: | |
1012 | 2263 if ( pCurrentScreen == SCREEN_SPELL_BOOK ) |
0 | 2264 break; |
1012 | 2265 /* dword_50C9EC[3 * dword_50C9E8] = 176;|| dword_50C9E8 >= 40 |
437 | 2266 dword_50C9EC[3 * dword_50C9E8 + 1] = 0; |
2267 dword_50C9EC[3 * dword_50C9E8 + 2] = 0; | |
1012 | 2268 ++dword_50C9E8;*/ |
2269 pMessageQueue_50C9E8->AddMessage(UIMSG_CycleCharacters, 0, 0); | |
163 | 2270 break; |
0 | 2271 case INPUT_LookUp: |
2272 if ( pEventTimer->bPaused ) | |
2273 break; | |
2274 partyAction = (PartyAction)7; | |
998 | 2275 pPartyActionQueue->Add(partyAction); |
163 | 2276 break; |
0 | 2277 case INPUT_CenterView: |
2278 if ( pEventTimer->bPaused ) | |
2279 break; | |
2280 partyAction = (PartyAction)9; | |
998 | 2281 pPartyActionQueue->Add(partyAction); |
163 | 2282 break; |
0 | 2283 case INPUT_LookDown: |
2284 if ( pEventTimer->bPaused ) | |
2285 break; | |
2286 partyAction = (PartyAction)8; | |
998 | 2287 pPartyActionQueue->Add(partyAction); |
163 | 2288 break; |
0 | 2289 case INPUT_FlyUp: |
998 | 2290 if ( pCurrentScreen || pEventTimer->bPaused ) |
0 | 2291 break; |
2292 partyAction = (PartyAction)13; | |
998 | 2293 pPartyActionQueue->Add(partyAction); |
163 | 2294 break; |
0 | 2295 case INPUT_Land: |
998 | 2296 if ( pCurrentScreen || pEventTimer->bPaused ) |
0 | 2297 break; |
2298 partyAction = (PartyAction)15; | |
998 | 2299 pPartyActionQueue->Add(partyAction); |
163 | 2300 break; |
0 | 2301 case INPUT_FlyDown: |
2302 if ( !pCurrentScreen | |
2303 && !pEventTimer->bPaused ) | |
2304 { | |
2305 partyAction = (PartyAction)14; | |
998 | 2306 pPartyActionQueue->Add(partyAction); |
0 | 2307 } |
2308 break; | |
2309 case INPUT_ZoomIn: | |
1012 | 2310 /*if ( dword_50C9E8 >= 40 ) |
0 | 2311 break; |
2312 dword_50C9EC[3 * dword_50C9E8] = 367; | |
437 | 2313 dword_50C9EC[3 * dword_50C9E8 + 1] = 0; |
2314 dword_50C9EC[3 * dword_50C9E8 + 2] = 0; | |
1012 | 2315 ++dword_50C9E8;*/ |
2316 pMessageQueue_50C9E8->AddMessage(UIMSG_ClickZoomOutBtn, 0, 0); | |
163 | 2317 break; |
0 | 2318 case INPUT_ZoomOut: |
1012 | 2319 /*if ( dword_50C9E8 < 40 ) |
0 | 2320 { |
2321 dword_50C9EC[3 * dword_50C9E8] = 368; | |
437 | 2322 dword_50C9EC[3 * dword_50C9E8 + 1] = 0; |
2323 dword_50C9EC[3 * dword_50C9E8 + 2] = 0; | |
0 | 2324 ++dword_50C9E8; |
1012 | 2325 }*/ |
2326 pMessageQueue_50C9E8->AddMessage(UIMSG_ClickZoomInBtn, 0, 0); | |
0 | 2327 break; |
2328 case INPUT_AlwaysRun: | |
2329 bAlwaysRun = bAlwaysRun == 0; | |
2330 break; | |
17 | 2331 default: |
2332 break; | |
0 | 2333 } |
2334 } | |
2335 } | |
2336 } | |
2337 } |