Mercurial > mm7
annotate mm7_6.cpp @ 1958:95095c2a5e19
pActorBuffs[14] to pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER]
author | Grumpy7 |
---|---|
date | Fri, 25 Oct 2013 11:19:01 -0700 |
parents | 3d0c57c4fa83 |
children | 4fbffad6e011 |
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 { | |
1957
3d0c57c4fa83
pActorBuffs[13] to pActorBuffs[ACTOR_BUFF_DAY_OF_PROTECTION]
Grumpy7
parents:
1955
diff
changeset
|
279 if ( SHIDWORD(pActor->pActorBuffs[ACTOR_BUFF_DAY_OF_PROTECTION].uExpireTime) < 0 ) |
597 | 280 return 1; |
1957
3d0c57c4fa83
pActorBuffs[13] to pActorBuffs[ACTOR_BUFF_DAY_OF_PROTECTION]
Grumpy7
parents:
1955
diff
changeset
|
281 if ( SHIDWORD(pActor->pActorBuffs[ACTOR_BUFF_DAY_OF_PROTECTION].uExpireTime) > 0 ) |
597 | 282 return 0; |
283 v3 = 0; | |
1957
3d0c57c4fa83
pActorBuffs[13] to pActorBuffs[ACTOR_BUFF_DAY_OF_PROTECTION]
Grumpy7
parents:
1955
diff
changeset
|
284 v4 = LODWORD(pActor->pActorBuffs[ACTOR_BUFF_DAY_OF_PROTECTION].uExpireTime) == 0; |
597 | 285 break; |
286 } | |
287 case 86: | |
288 { | |
1958
95095c2a5e19
pActorBuffs[14] to pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER]
Grumpy7
parents:
1957
diff
changeset
|
289 if ( SHIDWORD(pActor->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uExpireTime) < 0 ) |
597 | 290 return 1; |
1958
95095c2a5e19
pActorBuffs[14] to pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER]
Grumpy7
parents:
1957
diff
changeset
|
291 if ( SHIDWORD(pActor->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uExpireTime) > 0 ) |
597 | 292 return 0; |
0 | 293 v3 = 0; |
1958
95095c2a5e19
pActorBuffs[14] to pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER]
Grumpy7
parents:
1957
diff
changeset
|
294 v4 = LODWORD(pActor->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].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 { | |
1955 | 358 if ( SHIDWORD(pActor->pActorBuffs[ACTOR_BUFF_FATE].uExpireTime) < 0 ) |
597 | 359 return 1; |
1955 | 360 if ( SHIDWORD(pActor->pActorBuffs[ACTOR_BUFF_FATE].uExpireTime) > 0 ) |
597 | 361 return 0; |
362 v3 = 0; | |
1955 | 363 v4 = LODWORD(pActor->pActorBuffs[ACTOR_BUFF_FATE].uExpireTime) == 0; |
597 | 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; | |
1952
4ed7d18abe93
pActorBuffs[8] to pActorBuffs[ACTOR_BUFF_SOMETHING_THAT_HALVES_AC]
Grumpy7
parents:
1936
diff
changeset
|
407 if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_SOMETHING_THAT_HALVES_AC].uExpireTime > 0 ) |
0 | 408 v5 /= 2; |
1958
95095c2a5e19
pActorBuffs[14] to pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER]
Grumpy7
parents:
1957
diff
changeset
|
409 if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uExpireTime > 0 ) |
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; | |
1952
4ed7d18abe93
pActorBuffs[8] to pActorBuffs[ACTOR_BUFF_SOMETHING_THAT_HALVES_AC]
Grumpy7
parents:
1936
diff
changeset
|
464 v8 = HIDWORD(a2->pActorBuffs[ACTOR_BUFF_SOMETHING_THAT_HALVES_AC].uExpireTime) == 0; |
4ed7d18abe93
pActorBuffs[8] to pActorBuffs[ACTOR_BUFF_SOMETHING_THAT_HALVES_AC]
Grumpy7
parents:
1936
diff
changeset
|
465 v9 = SHIDWORD(a2->pActorBuffs[ACTOR_BUFF_SOMETHING_THAT_HALVES_AC].uExpireTime) < 0; |
0 | 466 a2a = 0; |
1952
4ed7d18abe93
pActorBuffs[8] to pActorBuffs[ACTOR_BUFF_SOMETHING_THAT_HALVES_AC]
Grumpy7
parents:
1936
diff
changeset
|
467 if ( !v9 && (!(v9 | v8) || LODWORD(v5->pActorBuffs[ACTOR_BUFF_SOMETHING_THAT_HALVES_AC].uExpireTime) > 0) ) |
0 | 468 v6 /= 2; |
1958
95095c2a5e19
pActorBuffs[14] to pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER]
Grumpy7
parents:
1957
diff
changeset
|
469 if ( (signed __int64)v5->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uExpireTime > 0 ) |
95095c2a5e19
pActorBuffs[14] to pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER]
Grumpy7
parents:
1957
diff
changeset
|
470 v7 = v5->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uPower; |
0 | 471 if ( (signed __int64)v5->pActorBuffs[16].uExpireTime > 0 && v5->pActorBuffs[16].uPower > v7 ) |
472 v7 = v5->pActorBuffs[16].uPower; | |
473 v10 = v7 + v6; | |
1958
95095c2a5e19
pActorBuffs[14] to pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER]
Grumpy7
parents:
1957
diff
changeset
|
474 if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uExpireTime > 0 ) |
95095c2a5e19
pActorBuffs[14] to pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER]
Grumpy7
parents:
1957
diff
changeset
|
475 a2a = pActor->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uPower; |
0 | 476 if ( (signed __int64)pActor->pActorBuffs[17].uExpireTime > 0 && pActor->pActorBuffs[17].uPower > a2a ) |
477 a2a = pActor->pActorBuffs[17].uPower; | |
1955 | 478 if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_FATE].uExpireTime > 0 ) |
0 | 479 { |
1955 | 480 a2a += pActor->pActorBuffs[ACTOR_BUFF_FATE].uPower; |
481 pActor->pActorBuffs[ACTOR_BUFF_FATE].Reset(); | |
0 | 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; | |
1958
95095c2a5e19
pActorBuffs[14] to pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER]
Grumpy7
parents:
1957
diff
changeset
|
494 if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uExpireTime > 0 ) |
95095c2a5e19
pActorBuffs[14] to pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER]
Grumpy7
parents:
1957
diff
changeset
|
495 v3 = pActor->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uPower; |
0 | 496 if ( (signed __int64)pActor->pActorBuffs[17].uExpireTime > 0 && pActor->pActorBuffs[17].uPower > v3 ) |
497 v3 = pActor->pActorBuffs[17].uPower; | |
1955 | 498 if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_FATE].uExpireTime > 0 ) |
0 | 499 { |
1955 | 500 v3 += pActor->pActorBuffs[ACTOR_BUFF_FATE].uPower; |
501 pActor->pActorBuffs[ACTOR_BUFF_FATE].Reset(); | |
0 | 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; | |
1958
95095c2a5e19
pActorBuffs[14] to pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER]
Grumpy7
parents:
1957
diff
changeset
|
538 if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uExpireTime > 0 ) |
95095c2a5e19
pActorBuffs[14] to pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER]
Grumpy7
parents:
1957
diff
changeset
|
539 v5 = pActor->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uPower; |
0 | 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 //----- (0042F7EB) -------------------------------------------------------- | |
1076 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) | |
1077 { | |
1406 | 1078 unsigned __int16 pObjectDescID; // ax@7 |
1079 SpriteObject pSpellObject; // [sp+Ch] [bp-78h]@1 | |
0 | 1080 |
1406 | 1081 pSpellObject.stru_24.Reset(); |
0 | 1082 if ( a9 ) |
1406 | 1083 memcpy(&pSpellObject.stru_24, a9, sizeof(pSpellObject.stru_24)); |
1084 pSpellObject.spell_skill = 0; | |
1085 pSpellObject.spell_level = 0; | |
1086 pSpellObject.spell_id = 0; | |
1087 pSpellObject.field_54 = 0; | |
1088 pSpellObject.uType = uSpriteID; | |
0 | 1089 if ( (signed int)pObjectList->uNumObjects <= 0 ) |
1406 | 1090 pObjectDescID = 0; |
0 | 1091 else |
1092 { | |
1406 | 1093 pObjectDescID = 0; |
1094 for ( uint i = 0; i < (signed int)pObjectList->uNumObjects; ++i ) | |
0 | 1095 { |
1406 | 1096 if ( (short)uSpriteID == pObjectList->pObjects[i].uObjectID ) |
1097 pObjectDescID = i; | |
0 | 1098 } |
1099 } | |
1406 | 1100 pSpellObject.uObjectDescID = pObjectDescID; |
1101 pSpellObject.vPosition.x = x; | |
1102 pSpellObject.vPosition.y = y; | |
1103 pSpellObject.vPosition.z = z; | |
1104 pSpellObject.uSoundID = 0; | |
1105 pSpellObject.uAttributes = attributes; | |
1106 pSpellObject.uSectorID = pIndoor->GetSector(x, y, z); | |
1107 pSpellObject.uSpriteFrameID = 0; | |
1108 pSpellObject.spell_caster_pid = 0; | |
1109 pSpellObject.spell_target_pid = 0; | |
1110 if ( !(pSpellObject.uAttributes & 0x10) ) | |
1111 { | |
1112 if ( pItemsTable->uAllItemsCount ) | |
1113 { | |
1729
f44b6e02e81c
pop-up window in character(paperdill) window, alchemy
Ritor1
parents:
1709
diff
changeset
|
1114 for ( uint i = 1; i < pItemsTable->uAllItemsCount; ++i ) |
1406 | 1115 { |
1116 if ( pItemsTable->pItems[i].uSpriteID == uSpriteID ) | |
1117 pSpellObject.stru_24.uItemID = i; | |
1118 } | |
1119 } | |
1120 } | |
0 | 1121 if ( a7 ) |
1122 { | |
1123 if ( count > 0 ) | |
1124 { | |
1406 | 1125 for ( uint i = count; i; --i ) |
0 | 1126 { |
1406 | 1127 pSpellObject.uFacing = rand() % (signed int)stru_5C6E00->uIntegerDoublePi; |
1128 pSpellObject.Create((signed __int16)pSpellObject.uFacing, | |
1129 ((signed int)stru_5C6E00->uIntegerHalfPi / 2) + (rand() % ((signed int)stru_5C6E00->uIntegerHalfPi / 2)), a4, 0); | |
1130 | |
0 | 1131 } |
1132 } | |
1133 } | |
1134 else | |
1135 { | |
1406 | 1136 pSpellObject.uFacing = 0; |
0 | 1137 if ( count > 0 ) |
1138 { | |
1406 | 1139 for ( uint i = count; i; --i ) |
0 | 1140 { |
1406 | 1141 pSpellObject.Create((signed __int16)pSpellObject.uFacing, stru_5C6E00->uIntegerHalfPi, a4, 0); |
0 | 1142 } |
1143 } | |
1144 } | |
1406 | 1145 return true; |
0 | 1146 } |
1147 | |
1148 //----- (0042F960) -------------------------------------------------------- | |
1149 void __fastcall sub_42F960_create_object(int x, int y, int z) | |
1150 { | |
1151 int v3; // ebx@1 | |
1152 int v4; // edi@1 | |
1153 signed int v5; // edx@1 | |
1154 char *v6; // ecx@2 | |
1155 unsigned __int16 v7; // ax@5 | |
1156 signed int v8; // eax@6 | |
1157 signed int v9; // eax@7 | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
490
diff
changeset
|
1158 //SpriteObject a1; // [sp+Ch] [bp-70h]@1 |
0 | 1159 |
1160 v3 = x; | |
1161 v4 = y; | |
1162 | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
490
diff
changeset
|
1163 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
|
1164 //SpriteObject::SpriteObject(&a1); |
0 | 1165 a1.stru_24.Reset(); |
1166 | |
1167 v5 = 0; | |
822 | 1168 a1.spell_skill = 0; |
1169 a1.spell_level = 0; | |
1170 a1.spell_id = 0; | |
0 | 1171 a1.field_54 = 0; |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
490
diff
changeset
|
1172 a1.uType = 800; |
0 | 1173 if ( (signed int)pObjectList->uNumObjects <= 0 ) |
1174 { | |
1175 LABEL_5: | |
1176 v7 = 0; | |
1177 } | |
1178 else | |
1179 { | |
1180 v6 = (char *)&pObjectList->pObjects->uObjectID; | |
1181 while ( *(short *)v6 != 800 ) | |
1182 { | |
1183 ++v5; | |
1184 v6 += 56; | |
1185 if ( v5 >= (signed int)pObjectList->uNumObjects ) | |
1186 goto LABEL_5; | |
1187 } | |
1188 v7 = v5; | |
1189 } | |
1190 a1.uObjectDescID = v7; | |
1191 a1.vPosition.x = v3; | |
1192 a1.vPosition.y = v4; | |
1193 a1.vPosition.z = z; | |
1194 a1.uSoundID = 0; | |
1195 a1.uAttributes = 0; | |
1196 a1.uSectorID = pIndoor->GetSector(v3, v4, z); | |
1197 a1.uSpriteFrameID = 0; | |
822 | 1198 a1.spell_caster_pid = 0; |
823 | 1199 a1.spell_target_pid = 0; |
0 | 1200 v8 = a1.Create(0, 0, 0, 0); |
1201 if ( v8 != -1 ) | |
1202 { | |
1203 v9 = 8 * v8; | |
1204 LOBYTE(v9) = v9 | 2; | |
1205 pAudioPlayer->PlaySound((SoundID)(SOUND_GoldReceived|0x14), v9, 0, -1, 0, 0, 0, 0); | |
1206 } | |
1207 } | |
1208 | |
810 | 1209 |
0 | 1210 |
1211 //----- (0042FA66) -------------------------------------------------------- | |
1546 | 1212 void _42FA66_do_explosive_impact(int a1, int a2, int a3, int a4, __int16 a5, signed int a6) |
0 | 1213 { |
1214 int v6; // edi@1 | |
1215 int v7; // esi@1 | |
1216 char *v8; // ecx@2 | |
1217 unsigned __int16 v9; // ax@5 | |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
1218 //int v10; // eax@10 |
1546 | 1219 //signed int result; // eax@11 |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
1220 //__int16 v12; // ax@12 |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
490
diff
changeset
|
1221 //SpriteObject a1a; // [sp+Ch] [bp-74h]@1 |
0 | 1222 int v14; // [sp+7Ch] [bp-4h]@1 |
1223 | |
1224 v6 = a1; | |
1225 v7 = a2; | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
490
diff
changeset
|
1226 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
|
1227 //SpriteObject::SpriteObject(&a1a); |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
490
diff
changeset
|
1228 a1a.uType = 600; |
0 | 1229 a1a.stru_24.Reset(); |
1230 | |
822 | 1231 a1a.spell_id = SPELL_FIRE_FIREBALL; |
1232 a1a.spell_level = 8; | |
1233 a1a.spell_skill = 3; | |
0 | 1234 v14 = 0; |
1235 if ( (signed int)pObjectList->uNumObjects <= 0 ) | |
1236 { | |
1237 LABEL_5: | |
1238 v9 = 0; | |
1239 } | |
1240 else | |
1241 { | |
1242 v8 = (char *)&pObjectList->pObjects->uObjectID; | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
490
diff
changeset
|
1243 while ( (short)a1a.uType != *(short *)v8 ) |
0 | 1244 { |
1245 ++v14; | |
1246 v8 += 56; | |
1247 if ( v14 >= (signed int)pObjectList->uNumObjects ) | |
1248 goto LABEL_5; | |
1249 } | |
1250 v9 = v14; | |
1251 } | |
1252 a1a.uObjectDescID = v9; | |
1253 a1a.vPosition.x = v6; | |
1254 a1a.vPosition.y = v7; | |
1255 a1a.vPosition.z = a3; | |
1256 a1a.uAttributes = 0; | |
1257 a1a.uSectorID = pIndoor->GetSector(v6, v7, a3); | |
1258 a1a.uSpriteFrameID = 0; | |
823 | 1259 a1a.spell_target_pid = 0; |
0 | 1260 a1a.field_60_distance_related_prolly_lod = 0; |
1261 a1a.uFacing = 0; | |
1262 a1a.uSoundID = 0; | |
1263 if ( a6 >= 1 || a6 <= 4 ) | |
1264 { | |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
1265 a1a.spell_caster_pid = PID(OBJECT_Player, a6 - 1); |
0 | 1266 } |
1267 else | |
1268 { | |
822 | 1269 a1a.spell_caster_pid = 0; |
0 | 1270 } |
1546 | 1271 |
1272 int id = a1a.Create(0, 0, 0, 0); | |
1273 if (id != -1) | |
1274 stru_50FE08.Add(PID(OBJECT_Item, id), | |
0 | 1275 a5, |
1276 SLOWORD(a1a.vPosition.x), | |
1277 SLOWORD(a1a.vPosition.y), | |
1278 SLOWORD(a1a.vPosition.z), | |
1279 0, | |
1280 0); | |
1281 } | |
1282 | |
1283 //----- (0042FB5C) -------------------------------------------------------- | |
1458 | 1284 bool _42FB5C_check_spell(signed int a1) |
0 | 1285 { |
1286 int v1; // ecx@3 | |
1287 int v2; // ecx@4 | |
1288 int v3; // ecx@5 | |
1289 int v4; // ecx@6 | |
1290 int v5; // ecx@7 | |
1291 int v6; // ecx@8 | |
1292 char v7; // zf@9 | |
1293 | |
1294 if ( a1 > 39 ) | |
1295 { | |
1296 if ( a1 > 77 ) | |
1297 { | |
1298 if ( a1 == 80 ) | |
1299 return 0; | |
1300 if ( a1 > 84 ) | |
1301 { | |
1302 if ( a1 <= 86 ) | |
1303 return 0; | |
1304 v7 = a1 == 95; | |
1305 goto LABEL_20; | |
1306 } | |
1307 } | |
1308 else | |
1309 { | |
1310 if ( a1 == 77 ) | |
1311 return 0; | |
1312 if ( a1 >= 46 ) | |
1313 { | |
1314 if ( a1 <= 47 || a1 == 51 ) | |
1315 return 0; | |
1316 v7 = a1 == 73; | |
1317 goto LABEL_20; | |
1318 } | |
1319 } | |
1320 return 1; | |
1321 } | |
1322 if ( a1 == 39 || (v1 = a1 - 2) == 0 ) | |
1323 return 1; | |
1324 v2 = v1 - 3; | |
1325 if ( !v2 ) | |
1326 return 0; | |
1327 v3 = v2 - 1; | |
1328 if ( !v3 || (v4 = v3 - 3) == 0 ) | |
1329 return 1; | |
1330 v5 = v4 - 8; | |
1331 if ( !v5 ) | |
1332 return 0; | |
1333 v6 = v5 - 1; | |
1334 if ( !v6 ) | |
1335 return 1; | |
1336 v7 = v6 == 20; | |
1337 LABEL_20: | |
1338 if ( !v7 ) | |
1339 return 1; | |
1340 return 0; | |
1341 } | |
1342 | |
1343 //----- (0042FBDD) -------------------------------------------------------- | |
1458 | 1344 void sub_42FBDD() |
0 | 1345 { |
388 | 1346 pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); |
0 | 1347 pRenderer->DrawTextureTransparent(pBtn_YES->uX, pBtn_YES->uY, pBtn_YES->pTextures[0]); |
1348 pRenderer->Present(); | |
1349 } | |
1350 | |
1351 //----- (0042FC15) -------------------------------------------------------- | |
1458 | 1352 void CloseWindowBackground() |
0 | 1353 { |
388 | 1354 pAudioPlayer->PlaySound(SOUND_Button2, -2, 0, -1, 0, 0, 0, 0); |
0 | 1355 pRenderer->DrawTextureTransparent(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY, pBtn_ExitCancel->pTextures[0]); |
1356 pRenderer->Present(); | |
1357 } | |
1358 | |
1359 //----- (0042FC4E) -------------------------------------------------------- | |
1575 | 1360 void ProcessInputActions() |
0 | 1361 { |
1362 char v4; // al@9 | |
1363 char v8; // bl@100 | |
1364 unsigned __int16 v9; // ax@102 | |
1365 int v10; // eax@103 | |
1366 char v14; // al@159 | |
1367 unsigned int v15; // eax@168 | |
1368 PartyAction partyAction; // [sp-14h] [bp-1Ch]@20 | |
1369 InputAction inputAction; // [sp+0h] [bp-8h]@7 | |
1370 int v24; // [sp+4h] [bp-4h]@87 | |
1371 | |
1372 pGame->pKeyboardInstance->EnterCriticalSection(); | |
1373 auto pKeyboard = pGame->pKeyboardInstance; | |
1374 if (!bAlwaysRun) | |
1375 { | |
1376 if (pKeyboard->IsShiftHeld()) | |
1377 pParty->uFlags2 |= PARTY_FLAGS_2_RUNNING; | |
1378 else | |
1379 pParty->uFlags2 &= ~PARTY_FLAGS_2_RUNNING; | |
1380 } | |
1381 else | |
1382 { | |
1383 if (pKeyboard->IsShiftHeld()) | |
1384 pParty->uFlags2 &= ~PARTY_FLAGS_2_RUNNING; | |
1385 else | |
1386 pParty->uFlags2 |= PARTY_FLAGS_2_RUNNING; | |
1387 } | |
1388 | |
140 | 1389 //pParty->uFlags2 |= PARTY_FLAGS_2_RUNNING; |
1052 | 1390 |
1391 | |
1392 // WUT? double event trigger | |
1393 /*for ( uint i = 0; i < 30; ++i ) | |
998 | 1394 { |
1395 if ( pKeyActionMap->pToggleTypes[i] ) | |
1396 v14 = pGame->pKeyboardInstance->WasKeyPressed(pKeyActionMap->pVirtualKeyCodesMapping[i]); | |
1397 else | |
1398 v14 = pGame->pKeyboardInstance->IsKeyBeingHeld(pKeyActionMap->pVirtualKeyCodesMapping[i]); | |
1052 | 1399 if ( v14 ) |
998 | 1400 { |
1052 | 1401 if (pCurrentScreen == SCREEN_GAME) |
998 | 1402 { |
1403 pMessageQueue_50CBD0->AddMessage(UIMSG_Game_Action, 0, 0); | |
1404 continue; | |
1405 } | |
1406 if ( pCurrentScreen == SCREEN_NPC_DIALOGUE || pCurrentScreen == SCREEN_BRANCHLESS_NPC_DIALOG ) | |
1407 { | |
1408 v15 = pMessageQueue_50CBD0->uNumMessages; | |
1409 if ( pMessageQueue_50CBD0->uNumMessages ) | |
1410 { | |
1411 v15 = 0; | |
1412 if ( pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].field_8 ) | |
1413 { | |
1414 v15 = 1; | |
1415 pMessageQueue_50CBD0->uNumMessages = 0; | |
1416 pMessageQueue_50CBD0->pMessages[v15].eType = UIMSG_Escape; | |
1417 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; | |
1418 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; | |
1419 ++pMessageQueue_50CBD0->uNumMessages; | |
1420 continue; | |
1421 } | |
1422 pMessageQueue_50CBD0->uNumMessages = 0; | |
1423 } | |
1424 //pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); | |
1425 } | |
1426 } | |
1052 | 1427 }*/ |
0 | 1428 if ( !pEventTimer->bPaused ) |
1429 { | |
998 | 1430 for ( uint i = 0; i < 30; ++i ) |
0 | 1431 { |
998 | 1432 inputAction = (InputAction)i; |
1433 if ( pKeyActionMap->pToggleTypes[(InputAction)i] ) | |
1434 v4 = pKeyboard->WasKeyPressed(pKeyActionMap->pVirtualKeyCodesMapping[(InputAction)i]); | |
0 | 1435 else |
998 | 1436 v4 = pKeyboard->IsKeyBeingHeld(pKeyActionMap->pVirtualKeyCodesMapping[(InputAction)i]); |
0 | 1437 if ( v4 ) |
1438 { | |
1439 switch ( inputAction ) | |
1440 { | |
1441 case INPUT_MoveForward: | |
271 | 1442 if (pCurrentScreen != SCREEN_GAME) |
0 | 1443 break; |
1444 if (!pParty->bTurnBasedModeOn) | |
1445 { | |
140 | 1446 if ( pParty->uFlags2 & PARTY_FLAGS_2_RUNNING) |
0 | 1447 partyAction = PARTY_RunForward; |
1448 else | |
1449 partyAction = PARTY_WalkForward; | |
998 | 1450 pPartyActionQueue->Add(partyAction); |
163 | 1451 break; |
1452 } | |
1340 | 1453 if (pTurnEngine->turn_stage != 1 && pTurnEngine->turn_stage != 2 && pTurnEngine->uActionPointsLeft > 0 ) |
163 | 1454 { |
1455 pTurnEngine->uActionPointsLeft -= 26; | |
1456 if ( pParty->uFlags2 & PARTY_FLAGS_2_RUNNING) | |
1457 partyAction = PARTY_RunForward; | |
1458 else | |
1459 partyAction = PARTY_WalkForward; | |
998 | 1460 pPartyActionQueue->Add(partyAction); |
163 | 1461 break; |
0 | 1462 } |
1463 break; | |
1464 case INPUT_MoveBackwards: | |
271 | 1465 if (pCurrentScreen != SCREEN_GAME) |
0 | 1466 break; |
1467 if (!pParty->bTurnBasedModeOn) | |
17 | 1468 { |
1469 if ( pParty->uFlags2 & 2 ) | |
1470 partyAction = PARTY_RunBackward; | |
1471 else | |
1472 partyAction = PARTY_WalkBackward; | |
998 | 1473 pPartyActionQueue->Add(partyAction); |
163 | 1474 break; |
17 | 1475 } |
1340 | 1476 if ( pTurnEngine->turn_stage != 1 && pTurnEngine->turn_stage != 2 && pTurnEngine->uActionPointsLeft > 0 ) |
0 | 1477 { |
1478 pTurnEngine->uActionPointsLeft -= 26; | |
1479 if ( pParty->uFlags2 & 2 ) | |
1480 partyAction = PARTY_RunBackward; | |
1481 else | |
1482 partyAction = PARTY_WalkBackward; | |
998 | 1483 pPartyActionQueue->Add(partyAction); |
163 | 1484 break; |
0 | 1485 } |
1486 break; | |
1487 case INPUT_StrafeLeft: | |
271 | 1488 if (pCurrentScreen != SCREEN_GAME) |
0 | 1489 break; |
1490 if (!pParty->bTurnBasedModeOn) | |
17 | 1491 { |
1492 partyAction = PARTY_StrafeLeft; | |
998 | 1493 pPartyActionQueue->Add(partyAction); |
163 | 1494 break; |
17 | 1495 } |
1340 | 1496 if ( pTurnEngine->turn_stage == 1 || pTurnEngine->turn_stage == 2 || pTurnEngine->uActionPointsLeft <= 0 ) |
0 | 1497 break; |
1498 pTurnEngine->uActionPointsLeft -= 26; | |
1499 partyAction = PARTY_StrafeLeft; | |
998 | 1500 pPartyActionQueue->Add(partyAction); |
1501 break; | |
0 | 1502 case INPUT_StrafeRight: |
271 | 1503 if (pCurrentScreen != SCREEN_GAME) |
0 | 1504 break; |
1505 if (!pParty->bTurnBasedModeOn) | |
17 | 1506 { |
1507 partyAction = PARTY_StrafeRight; | |
998 | 1508 pPartyActionQueue->Add(partyAction); |
163 | 1509 break; |
17 | 1510 } |
1340 | 1511 if ( pTurnEngine->turn_stage == 1 || pTurnEngine->turn_stage == 2 || pTurnEngine->uActionPointsLeft <= 0 ) |
0 | 1512 break; |
1513 pTurnEngine->uActionPointsLeft -= 26; | |
1514 partyAction = PARTY_StrafeRight; | |
998 | 1515 pPartyActionQueue->Add(partyAction); |
163 | 1516 break; |
0 | 1517 case INPUT_TurnLeft: |
271 | 1518 if (pCurrentScreen != SCREEN_GAME) |
0 | 1519 break; |
1520 if ( GetAsyncKeyState(VK_CONTROL) ) // strafing | |
1521 { | |
1522 if (pParty->bTurnBasedModeOn) | |
1523 { | |
1340 | 1524 if ( pTurnEngine->turn_stage == 1 || pTurnEngine->turn_stage == 2 || pTurnEngine->uActionPointsLeft <= 0 ) |
0 | 1525 break; |
1526 pTurnEngine->uActionPointsLeft -= 26; | |
1527 } | |
998 | 1528 partyAction = PARTY_StrafeLeft; |
0 | 1529 } |
1530 else | |
1531 { | |
1532 if ( pParty->uFlags2 & 2 ) | |
998 | 1533 partyAction = PARTY_FastTurnLeft; |
0 | 1534 else |
998 | 1535 partyAction = PARTY_TurnLeft; |
0 | 1536 } |
998 | 1537 pPartyActionQueue->Add(partyAction); |
0 | 1538 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor && pWeather->bRenderSnow) |
1539 { | |
271 | 1540 pWeather->OnPlayerTurn(10); |
0 | 1541 } |
1542 break; | |
1543 case INPUT_TurnRight: | |
271 | 1544 if (pCurrentScreen != SCREEN_GAME) |
0 | 1545 break; |
1546 if ( GetAsyncKeyState(17) ) // strafing | |
1547 { | |
1548 if (pParty->bTurnBasedModeOn) | |
1549 { | |
1340 | 1550 if ( pTurnEngine->turn_stage == 1 || pTurnEngine->turn_stage == 2 || pTurnEngine->uActionPointsLeft <= 0 ) |
0 | 1551 break; |
1552 pTurnEngine->uActionPointsLeft -= 26; | |
1553 } | |
998 | 1554 partyAction = PARTY_StrafeRight; |
0 | 1555 } |
1556 else | |
1557 { | |
1558 if ( pParty->uFlags2 & 2 ) | |
998 | 1559 partyAction = PARTY_FastTurnRight; |
0 | 1560 else |
998 | 1561 partyAction = PARTY_TurnRight; |
0 | 1562 } |
998 | 1563 pPartyActionQueue->Add(partyAction); |
0 | 1564 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor && pWeather->bRenderSnow) |
1565 { | |
271 | 1566 pWeather->OnPlayerTurn(-10); |
0 | 1567 } |
1568 break; | |
1569 case INPUT_Jump: | |
271 | 1570 if (pCurrentScreen != SCREEN_GAME || pParty->bTurnBasedModeOn) |
0 | 1571 break; |
1572 partyAction = (PartyAction)12; | |
998 | 1573 pPartyActionQueue->Add(partyAction); |
163 | 1574 break; |
0 | 1575 case INPUT_Yell: |
187 | 1576 if (!pCurrentScreen && uActiveCharacter) |
0 | 1577 { |
1578 pParty->Yell(); | |
187 | 1579 pPlayers[uActiveCharacter]->PlaySound(SPEECH_Yell, 0); |
0 | 1580 } |
187 | 1581 break; |
0 | 1582 case INPUT_Pass: |
1583 if ( pCurrentScreen ) | |
1584 break; | |
1340 | 1585 if (pParty->bTurnBasedModeOn && pTurnEngine->turn_stage == 3) |
17 | 1586 { |
1332 | 1587 pTurnEngine->field_18 |= TE_FLAG_8; |
17 | 1588 break; |
1589 } | |
0 | 1590 if ( uActiveCharacter ) |
1591 { | |
998 | 1592 if ( !pPlayers[uActiveCharacter]->uTimeToRecovery ) |
0 | 1593 { |
998 | 1594 v24 = pPlayers[uActiveCharacter]->GetAttackRecoveryTime(false); |
0 | 1595 if ( !pParty->bTurnBasedModeOn ) |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
1596 pPlayers[uActiveCharacter]->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * (double)v24 * 2.133333333333333)); |
1517 | 1597 CastSpellInfoHelpers::_427D48(); |
1448 | 1598 pTurnEngine->ApplyPlayerAction(); |
0 | 1599 } |
1600 } | |
1601 break; | |
998 | 1602 case INPUT_Combat://if press ENTER |
271 | 1603 if (pCurrentScreen == SCREEN_GAME) |
0 | 1604 { |
1605 if (pParty->bTurnBasedModeOn) | |
1606 { | |
1340 | 1607 if (pTurnEngine->turn_stage == 3 || PID_TYPE(pTurnEngine->pQueue[0].uPackedID) == OBJECT_Player) |
0 | 1608 { |
1609 pParty->bTurnBasedModeOn = 0; | |
1610 pTurnEngine->End(true); | |
1611 } | |
1612 } | |
1613 else | |
1614 { | |
1615 pTurnEngine->Start(); | |
1616 pParty->bTurnBasedModeOn = true; | |
1617 } | |
1618 } | |
1619 break; | |
1620 case INPUT_CastReady: | |
271 | 1621 if (pCurrentScreen != SCREEN_GAME) |
0 | 1622 break; |
1340 | 1623 if (pParty->bTurnBasedModeOn && pTurnEngine->turn_stage == 3) |
17 | 1624 { |
1332 | 1625 pTurnEngine->field_18 |= TE_FLAG_8; |
17 | 1626 break; |
1627 } | |
0 | 1628 if ( !uActiveCharacter ) |
1629 break; | |
998 | 1630 v8 = pPlayers[uActiveCharacter]->uQuickSpell; |
0 | 1631 if ( !v8 |
1632 || bUnderwater | |
998 | 1633 || ((v9 = pPlayers[uActiveCharacter]->pActiveSkills[(unsigned __int8)v8 / 11 + 12], !(HIBYTE(v9) & 1)) ? |
1634 ((v9 & 0x80u) == 0 ? (!(v9 & 0x40) ? (v10 = *(&pSpellDatas[0].uNormalLevelMana + 10 * (unsigned __int8)v8)) : | |
1635 (v10 = *(&pSpellDatas[0].uExpertLevelMana + 10 * (unsigned __int8)v8))) : | |
1636 (v10 = *(&pSpellDatas[0].uMasterLevelMana + 10 * (unsigned __int8)v8))) : | |
1637 (v10 = *(&pSpellDatas[0].uMagisterLevelMana + 10 * (unsigned __int8)v8)), | |
1638 v10 > pPlayers[uActiveCharacter]->sMana) ) | |
0 | 1639 { |
998 | 1640 pPartyActionQueue = pPartyActionQueue; |
437 | 1641 pMessageQueue_50CBD0->AddMessage(UIMSG_Attack, 0, 0); |
1642 break; | |
0 | 1643 } |
1644 else | |
1645 { | |
1012 | 1646 pMessageQueue_50C9E8->AddMessage(UIMSG_CastQuickSpell, 0, 0); |
0 | 1647 } |
1648 break; | |
1649 case INPUT_Attack: | |
271 | 1650 if (pCurrentScreen != SCREEN_GAME) |
0 | 1651 break; |
1340 | 1652 if (pParty->bTurnBasedModeOn == 1 && pTurnEngine->turn_stage == 3) |
998 | 1653 { |
1332 | 1654 pTurnEngine->field_18 |= TE_FLAG_8; |
998 | 1655 break; |
1656 } | |
1657 pMessageQueue_50CBD0->AddMessage(UIMSG_Attack, 0, 0); | |
0 | 1658 break; |
1659 case INPUT_EventTrigger: | |
271 | 1660 if (pCurrentScreen == SCREEN_GAME) |
0 | 1661 { |
437 | 1662 pMessageQueue_50CBD0->AddMessage(UIMSG_Game_Action, 0, 0); |
163 | 1663 break; |
0 | 1664 } |
151 | 1665 if ( pCurrentScreen == SCREEN_NPC_DIALOGUE ) |
0 | 1666 { |
1667 if ( pMessageQueue_50CBD0->uNumMessages ) | |
1668 { | |
437 | 1669 pMessageQueue_50CBD0->uNumMessages = 0; |
0 | 1670 if ( pMessageQueue_50CBD0->pMessages[0].field_8 ) |
1671 { | |
1672 pMessageQueue_50CBD0->uNumMessages = 1; | |
998 | 1673 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape; |
0 | 1674 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; |
1575 | 1675 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].field_8 = 0; |
0 | 1676 ++pMessageQueue_50CBD0->uNumMessages; |
1677 break; | |
1678 } | |
437 | 1679 break; |
0 | 1680 } |
437 | 1681 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); |
0 | 1682 } |
1683 break; | |
1684 case INPUT_CharCycle: | |
1012 | 1685 if ( pCurrentScreen == SCREEN_SPELL_BOOK ) |
0 | 1686 break; |
1575 | 1687 |
1012 | 1688 pMessageQueue_50C9E8->AddMessage(UIMSG_CycleCharacters, 0, 0); |
163 | 1689 break; |
0 | 1690 case INPUT_LookUp: |
1691 if ( pEventTimer->bPaused ) | |
1692 break; | |
1693 partyAction = (PartyAction)7; | |
998 | 1694 pPartyActionQueue->Add(partyAction); |
163 | 1695 break; |
0 | 1696 case INPUT_CenterView: |
1697 if ( pEventTimer->bPaused ) | |
1698 break; | |
1699 partyAction = (PartyAction)9; | |
998 | 1700 pPartyActionQueue->Add(partyAction); |
163 | 1701 break; |
0 | 1702 case INPUT_LookDown: |
1703 if ( pEventTimer->bPaused ) | |
1704 break; | |
1705 partyAction = (PartyAction)8; | |
998 | 1706 pPartyActionQueue->Add(partyAction); |
163 | 1707 break; |
0 | 1708 case INPUT_FlyUp: |
998 | 1709 if ( pCurrentScreen || pEventTimer->bPaused ) |
0 | 1710 break; |
1711 partyAction = (PartyAction)13; | |
998 | 1712 pPartyActionQueue->Add(partyAction); |
163 | 1713 break; |
0 | 1714 case INPUT_Land: |
998 | 1715 if ( pCurrentScreen || pEventTimer->bPaused ) |
0 | 1716 break; |
1717 partyAction = (PartyAction)15; | |
998 | 1718 pPartyActionQueue->Add(partyAction); |
163 | 1719 break; |
0 | 1720 case INPUT_FlyDown: |
1721 if ( !pCurrentScreen | |
1722 && !pEventTimer->bPaused ) | |
1723 { | |
1724 partyAction = (PartyAction)14; | |
998 | 1725 pPartyActionQueue->Add(partyAction); |
0 | 1726 } |
1727 break; | |
1728 case INPUT_ZoomIn: | |
1012 | 1729 pMessageQueue_50C9E8->AddMessage(UIMSG_ClickZoomOutBtn, 0, 0); |
163 | 1730 break; |
0 | 1731 case INPUT_ZoomOut: |
1012 | 1732 pMessageQueue_50C9E8->AddMessage(UIMSG_ClickZoomInBtn, 0, 0); |
0 | 1733 break; |
1734 case INPUT_AlwaysRun: | |
1735 bAlwaysRun = bAlwaysRun == 0; | |
1736 break; | |
17 | 1737 default: |
1738 break; | |
0 | 1739 } |
1740 } | |
1741 } | |
1742 } | |
1743 } |