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