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