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