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