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