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