Mercurial > mm7
annotate mm7_6.cpp @ 2052:71a814f4482a
Moved implementation to cpp
author | Nomad |
---|---|
date | Fri, 29 Nov 2013 12:20:07 +0200 |
parents | 28cb79ae2f6f |
children | b7485a6502f2 |
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" | |
2037
7a9477135943
Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
1989
diff
changeset
|
29 #include "OurMath.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" | |
2044 | 33 #include "Timer.h" |
0 | 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 | |
46 | |
47 //----- (004272F5) -------------------------------------------------------- | |
48 int stru319::PlayerHitOrMiss(Player *pPlayer, Actor *pActor, int a3, int a4) | |
49 { | |
50 signed int v5; // esi@1 | |
51 signed int v6; // edi@1 | |
52 int v7; // esi@8 | |
53 int v8; // eax@9 | |
54 int v9; // edx@11 | |
55 int v10; // edx@13 | |
56 int v11; // esi@13 | |
57 unsigned __int8 v12; // sf@13 | |
58 unsigned __int8 v13; // of@13 | |
59 int v14; // edx@14 | |
60 int v15; // eax@14 | |
61 signed int result; // eax@17 | |
62 | |
63 v5 = pActor->pMonsterInfo.uAC; | |
64 v6 = 0; | |
1952
4ed7d18abe93
pActorBuffs[8] to pActorBuffs[ACTOR_BUFF_SOMETHING_THAT_HALVES_AC]
Grumpy7
parents:
1936
diff
changeset
|
65 if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_SOMETHING_THAT_HALVES_AC].uExpireTime > 0 ) |
0 | 66 v5 /= 2; |
1958
95095c2a5e19
pActorBuffs[14] to pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER]
Grumpy7
parents:
1957
diff
changeset
|
67 if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uExpireTime > 0 ) |
1959 | 68 v6 = pActor->pActorBuffs[ACTOR_BUFF_SHIELD].uPower; |
1960
f92fc67d66cb
pActorBuffs[16] to pActorBuffs[ACTOR_BUFF_STONESKIN]
Grumpy7
parents:
1959
diff
changeset
|
69 if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_STONESKIN].uExpireTime > 0 && pActor->pActorBuffs[ACTOR_BUFF_STONESKIN].uPower > v6 ) |
f92fc67d66cb
pActorBuffs[16] to pActorBuffs[ACTOR_BUFF_STONESKIN]
Grumpy7
parents:
1959
diff
changeset
|
70 v6 = pActor->pActorBuffs[ACTOR_BUFF_STONESKIN].uPower; |
0 | 71 v7 = v6 + v5; |
72 if ( a3 ) | |
73 v8 = pPlayer->GetRangedAttack(); | |
74 else | |
1685
2a309997c42f
Player::StealFromShop started cleanup, fixing a few errors caused by not commiting everything
Grumpy7
parents:
1637
diff
changeset
|
75 v8 = pPlayer->GetActualAttack(false); |
0 | 76 v9 = rand() % (v7 + 2 * v8 + 30); |
77 if ( a3 == 2 ) | |
78 { | |
79 v14 = a4 + v9; | |
80 v15 = ((v7 + 15) >> 1) + v7 + 15; | |
1419 | 81 v13 = __OFSUB__(v14, v15); |
82 v12 = v14 - v15 < 0; | |
0 | 83 } |
84 else | |
85 { | |
86 if ( a3 != 3 ) | |
87 { | |
88 v10 = a4 + v9; | |
89 v11 = v7 + 15; | |
90 v13 = __OFSUB__(v10, v11); | |
91 v12 = v10 - v11 < 0; | |
92 } | |
1419 | 93 else |
94 { | |
95 v14 = a4 + v9; | |
96 v15 = 2 * v7 + 30; | |
97 v13 = __OFSUB__(v14, v15); | |
98 v12 = v14 - v15 < 0; | |
99 } | |
0 | 100 } |
101 if ( v12 ^ v13 ) | |
102 result = 0; | |
103 else | |
104 result = 1; | |
105 return result; | |
106 } | |
107 | |
108 //----- (004274AD) -------------------------------------------------------- | |
109 bool stru319::ActorHitOrMiss(Actor *pActor, Player *pPlayer) | |
110 { | |
111 signed int v3; // edi@1 | |
112 signed int v4; // esi@8 | |
113 int v5; // esi@8 | |
114 | |
115 v3 = 0; | |
1958
95095c2a5e19
pActorBuffs[14] to pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER]
Grumpy7
parents:
1957
diff
changeset
|
116 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
|
117 v3 = pActor->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uPower; |
1961 | 118 if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_BLESS].uExpireTime > 0 && pActor->pActorBuffs[ACTOR_BUFF_BLESS].uPower > v3 ) |
119 v3 = pActor->pActorBuffs[ACTOR_BUFF_BLESS].uPower; | |
1955 | 120 if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_FATE].uExpireTime > 0 ) |
0 | 121 { |
1955 | 122 v3 += pActor->pActorBuffs[ACTOR_BUFF_FATE].uPower; |
123 pActor->pActorBuffs[ACTOR_BUFF_FATE].Reset(); | |
0 | 124 } |
125 v4 = pPlayer->GetActualAC() + 2 * pActor->pMonsterInfo.uLevel + 10; | |
126 v5 = rand() % v4 + 1; | |
127 return v3 + v5 > pPlayer->GetActualAC() + 5; | |
128 } | |
129 | |
130 //----- (00427546) -------------------------------------------------------- | |
131 int stru319::_427546(int a2) | |
132 { | |
133 int result; // eax@2 | |
134 | |
135 if ( a2 >= 0 ) | |
136 { | |
137 if ( a2 >= 1 ) | |
138 result = (a2 >= 2) + 2; | |
139 else | |
140 result = 1; | |
141 } | |
142 else | |
143 { | |
144 result = 0; | |
145 } | |
146 return result; | |
147 } | |
148 | |
149 //----- (0042756B) -------------------------------------------------------- | |
150 int stru319::CalcMagicalDamageToActor(Actor *pActor, int a2, signed int a3) | |
151 { | |
152 int v4; // edx@1 | |
153 int v5; // ecx@1 | |
154 signed int v6; // eax@4 | |
155 signed int result; // eax@17 | |
156 signed int v8; // esi@18 | |
157 | |
158 v4 = 0; | |
159 v5 = 0; | |
1958
95095c2a5e19
pActorBuffs[14] to pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER]
Grumpy7
parents:
1957
diff
changeset
|
160 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
|
161 v5 = pActor->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uPower; |
0 | 162 switch ( a2 ) |
163 { | |
164 case 0: | |
165 v6 = pActor->pMonsterInfo.uResFire; | |
1419 | 166 v4 = v5; |
167 break; | |
0 | 168 case 1: |
169 v6 = pActor->pMonsterInfo.uResAir; | |
1419 | 170 v4 = v5; |
171 break; | |
0 | 172 case 2: |
173 v6 = pActor->pMonsterInfo.uResWater; | |
1419 | 174 v4 = v5; |
175 break; | |
0 | 176 case 3: |
177 v6 = pActor->pMonsterInfo.uResEarth; | |
1419 | 178 v4 = v5; |
179 break; | |
1765 | 180 case 4: |
181 v6 = pActor->pMonsterInfo.uResPhysical; | |
182 break; | |
0 | 183 case 6: |
184 v6 = pActor->pMonsterInfo.uResSpirit; | |
185 break; | |
186 case 7: | |
187 v6 = pActor->pMonsterInfo.uResMind; | |
1419 | 188 v4 = v5; |
189 break; | |
0 | 190 case 8: |
191 v6 = pActor->pMonsterInfo.uResBody; | |
192 v4 = v5; | |
193 break; | |
194 case 9: | |
195 v6 = pActor->pMonsterInfo.uResLight; | |
196 break; | |
197 case 10: | |
198 v6 = pActor->pMonsterInfo.uResDark; | |
199 break; | |
200 default: | |
201 v6 = 0; | |
202 break; | |
203 } | |
204 if ( v6 < 200 ) | |
205 { | |
206 v8 = v4 + v6 + 30; | |
207 if ( rand() % v8 >= 30 ) | |
208 { | |
209 a3 >>= 1; | |
210 if ( rand() % v8 >= 30 ) | |
211 { | |
212 a3 >>= 1; | |
213 if ( rand() % v8 >= 30 ) | |
214 { | |
215 a3 >>= 1; | |
216 if ( rand() % v8 >= 30 ) | |
217 a3 >>= 1; | |
218 } | |
219 } | |
220 } | |
221 result = a3; | |
222 } | |
223 else | |
224 { | |
225 result = 0; | |
226 } | |
227 return result; | |
228 } | |
229 | |
230 //----- (00427662) -------------------------------------------------------- | |
231 bool stru319::GetMagicalResistance(Actor *pActor, unsigned int uType) | |
232 { | |
1765 | 233 signed int resist; // esi@2 |
0 | 234 bool result; // eax@13 |
235 | |
236 switch ( uType ) | |
237 { | |
1765 | 238 case 0: |
239 resist = pActor->pMonsterInfo.uResFire; | |
240 break; | |
241 case 1: | |
242 resist = pActor->pMonsterInfo.uResAir; | |
243 break; | |
244 case 2: | |
245 resist = pActor->pMonsterInfo.uResWater; | |
246 break; | |
247 case 3: | |
248 resist = pActor->pMonsterInfo.uResEarth; | |
249 break; | |
250 case 4: | |
251 resist = pActor->pMonsterInfo.uResPhysical; | |
252 break; | |
253 case 6: | |
254 resist = pActor->pMonsterInfo.uResSpirit; | |
255 break; | |
256 case 7: | |
257 resist = pActor->pMonsterInfo.uResMind; | |
258 case 8: | |
259 resist = pActor->pMonsterInfo.uResBody; | |
260 break; | |
261 case 9: | |
262 resist = pActor->pMonsterInfo.uResLight; | |
263 break; | |
264 case 10: | |
265 resist = pActor->pMonsterInfo.uResDark; | |
0 | 266 break; |
267 default: | |
1419 | 268 return 1; |
0 | 269 } |
1765 | 270 if ( resist < 200 ) |
271 result = rand() % (signed int)(((unsigned int)pActor->pMonsterInfo.uLevel >> 2) + resist + 30) < 30; | |
1419 | 272 else |
1765 | 273 result = 0; |
0 | 274 return result; |
275 } | |
276 | |
277 //----- (0042EB8D) -------------------------------------------------------- | |
437 | 278 void GUIMessageQueue::AddMessageImpl(UIMessageType msg, int param, unsigned int a4, const char *file, int line) |
0 | 279 { |
482 | 280 //Log::Warning(L"%s @ (%S %u)", UIMessage2String(msg), file, line); |
0 | 281 if (uNumMessages < 40) |
282 { | |
437 | 283 files[uNumMessages] = file; |
284 lines[uNumMessages] = line; | |
285 | |
0 | 286 pMessages[uNumMessages].eType = msg; |
287 pMessages[uNumMessages].param = param; | |
288 pMessages[uNumMessages++].field_8 = a4; | |
289 } | |
290 } | |
291 | |
292 | |
293 //----- (0042EBDB) -------------------------------------------------------- | |
323 | 294 int stru193_math::Sin(int angle) |
0 | 295 { |
323 | 296 return Cos(angle - this->uIntegerHalfPi); |
0 | 297 } |
298 | |
299 //----- (0042ECB5) -------------------------------------------------------- | |
271 | 300 void _42ECB5_PlayerAttacksActor() |
0 | 301 { |
271 | 302 //unsigned int v0; // ebx@1 |
303 //Player *v1; // esi@1 | |
304 //bool result; // eax@1 | |
295 | 305 //int v3; // edi@2 |
271 | 306 //unsigned int v4; // eax@7 |
0 | 307 char *v5; // eax@8 |
271 | 308 //int v6; // ecx@9 |
309 //signed int v7; // eax@16 | |
295 | 310 //Actor *v8; // edi@20 |
0 | 311 unsigned int v9; // ecx@21 |
295 | 312 //char *v10; // eax@26 |
0 | 313 char *v11; // eax@26 |
314 unsigned int v12; // eax@47 | |
295 | 315 //char *v13; // eax@47 |
316 //char *v14; // eax@47 | |
317 //unsigned int v15; // ebx@54 | |
318 //int v16; // [sp-10h] [bp-4Ch]@24 | |
319 //int v17; // [sp-10h] [bp-4Ch]@44 | |
320 //unsigned int v18; // [sp-Ch] [bp-48h]@24 | |
321 //unsigned int v19; // [sp-Ch] [bp-48h]@44 | |
322 //__int16 v20; // [sp-8h] [bp-44h]@24 | |
323 //__int16 v21; // [sp-8h] [bp-44h]@44 | |
324 //int v22; // [sp-4h] [bp-40h]@24 | |
325 //int v23; // [sp-4h] [bp-40h]@44 | |
0 | 326 SoundID v24; // [sp-4h] [bp-40h]@58 |
295 | 327 //Vec3_int_ a3; // [sp+Ch] [bp-30h]@19 |
271 | 328 //unsigned int a2; // [sp+18h] [bp-24h]@20 |
329 //unsigned int v27; // [sp+1Ch] [bp-20h]@1 | |
295 | 330 //int v28; // [sp+20h] [bp-1Ch]@9 |
271 | 331 //unsigned int *v28b; |
295 | 332 //int v29; // [sp+24h] [bp-18h]@16 |
333 //int v30; // [sp+28h] [bp-14h]@16 | |
271 | 334 //int v31; // [sp+2Ch] [bp-10h]@4 |
295 | 335 //int v32; // [sp+30h] [bp-Ch]@7 |
271 | 336 //int v33; // [sp+34h] [bp-8h]@7 |
295 | 337 //int v34; // [sp+38h] [bp-4h]@17 |
0 | 338 |
271 | 339 //v0 = uActiveCharacter; |
340 //v27 = 6972 * uActiveCharacter; | |
341 //v1 = &pParty->pPlayers[uActiveCharacter-1]; | |
342 //result = pParty->pPlayers[uActiveCharacter-1].CanAct(); | |
1980 | 343 Player* player = &pParty->pPlayers[uActiveCharacter - 1]; |
271 | 344 if (!player->CanAct()) |
345 return; | |
346 | |
1517 | 347 CastSpellInfoHelpers::_427D48(); |
295 | 348 //v3 = 0; |
271 | 349 if (pParty->Invisible()) |
350 pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset(); | |
351 | |
352 //v31 = player->pEquipment.uBow; | |
353 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
|
354 if (bow_idx && player->pInventoryItemList[bow_idx - 1].IsBroken()) |
271 | 355 bow_idx = 0; |
356 | |
295 | 357 //v32 = 0; |
358 int wand_item_id = 0; | |
271 | 359 //v33 = 0; |
360 //v4 = v1->pEquipment.uMainHand; | |
361 int laser_weapon_item_id = 0; | |
362 | |
363 int main_hand_idx = player->pEquipment.uMainHand; | |
364 if (main_hand_idx) | |
0 | 365 { |
1980 | 366 ItemGen* item = &player->pInventoryItemList[main_hand_idx - 1]; |
112 | 367 //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
|
368 if (!item->IsBroken()) |
271 | 369 { |
370 //v28b = &v1->pInventoryItems[v4].uItemID; | |
371 //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
|
372 if (item->GetItemEquipType() == EQUIP_WAND) |
0 | 373 { |
295 | 374 if (item->uNumCharges <= 0) |
375 player->pEquipment.uMainHand = 0; // wand discharged - unequip | |
0 | 376 else |
295 | 377 wand_item_id = item->uItemID;//*((int *)v5 + 124); |
0 | 378 } |
271 | 379 else if (item->uItemID == ITEM_BLASTER || item->uItemID == ITEM_LASER_RIFLE) |
380 laser_weapon_item_id = item->uItemID;//*((int *)v5 + 124); | |
0 | 381 } |
271 | 382 } |
383 | |
295 | 384 //v30 = 0; |
385 //v29 = 0; | |
386 //v28 = 0; | |
271 | 387 //v7 = pMouse->uPointingObjectID; |
388 | |
389 int target_pid = pMouse->uPointingObjectID; | |
848 | 390 int target_type = PID_TYPE(target_pid), |
391 target_id = PID_ID(target_pid); | |
271 | 392 if (target_type != OBJECT_Actor || !pActors[target_id].CanAct()) |
393 { | |
394 target_pid = stru_50C198.FindClosestActor(5120, 0, 0); | |
848 | 395 target_type = PID_TYPE(target_pid); |
396 target_id = PID_ID(target_pid); | |
271 | 397 } |
295 | 398 |
1980 | 399 Actor* actor = &pActors[target_id]; |
295 | 400 int actor_distance = 0; |
271 | 401 if (target_type == OBJECT_Actor) |
402 { | |
295 | 403 int distance_x = actor->vPosition.x - pParty->vPosition.x, |
404 distance_y = actor->vPosition.y - pParty->vPosition.y, | |
405 distance_z = actor->vPosition.z - pParty->vPosition.z; | |
406 actor_distance = integer_sqrt(distance_x * distance_x + distance_y * distance_y + distance_z * distance_z) - actor->uActorRadius; | |
407 if (actor_distance < 0) | |
408 actor_distance = 0; | |
409 } | |
410 | |
411 bool shooting_bow = false, | |
412 shotting_laser = false, | |
816 | 413 shooting_wand = false, |
414 melee_attack = false; | |
295 | 415 if (laser_weapon_item_id) |
416 { | |
417 shotting_laser = true; | |
490 | 418 _42777D_CastSpell_UseWand_ShootArrow(SPELL_LASER_PROJECTILE, uActiveCharacter - 1, 0, 0, uActiveCharacter + 8); |
295 | 419 } |
420 else if (wand_item_id) | |
421 { | |
422 shooting_wand = true; | |
423 | |
424 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
|
425 _42777D_CastSpell_UseWand_ShootArrow(wand_spell_ids[player->pInventoryItemList[main_hand_idx - 1].uItemID - ITEM_WAND_FIRE], uActiveCharacter - 1, 8, 0, uActiveCharacter + 8); |
295 | 426 |
1384
b51332ab228f
changed a few member variables in Player to slightly less confusing names
Grumpy7
parents:
1340
diff
changeset
|
427 if (!--player->pInventoryItemList[main_hand_idx - 1].uNumCharges) |
295 | 428 player->pEquipment.uMainHand = 0; |
429 } | |
303 | 430 else if (target_type == OBJECT_Actor && actor_distance <= 407.2) |
295 | 431 { |
816 | 432 melee_attack = true; |
433 | |
303 | 434 Vec3_int_ a3; |
435 a3.x = actor->vPosition.x - pParty->vPosition.x; | |
436 a3.y = actor->vPosition.y - pParty->vPosition.y; | |
437 a3.z = actor->vPosition.z - pParty->vPosition.z; | |
438 Vec3_int_::Normalize(&a3.x, &a3.y, &a3.z); | |
439 | |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
440 DamageMonsterFromParty(PID(OBJECT_Player, uActiveCharacter - 1), target_id, &a3); |
1989 | 441 if (player->WearsItem(ITEM_ARTIFACT_SPLITTER, EQUIP_TWO_HANDED) || player->WearsItem(ITEM_ARTIFACT_SPLITTER, EQUIP_SINGLE_HANDED)) |
295 | 442 _42FA66_do_explosive_impact( |
443 actor->vPosition.x, | |
444 actor->vPosition.y, | |
445 actor->vPosition.z + actor->uActorHeight / 2, | |
446 0, 512, uActiveCharacter); | |
303 | 447 } |
448 else if (bow_idx) | |
449 { | |
450 shooting_bow = true; | |
490 | 451 _42777D_CastSpell_UseWand_ShootArrow(SPELL_BOW_ARROW, uActiveCharacter - 1, 0, 0, 0); |
295 | 452 } |
453 else | |
454 { | |
816 | 455 melee_attack = true; |
303 | 456 ; // actor out of range or no actor; no ranged weapon so melee attacking air |
457 } | |
458 | |
816 | 459 if (!pParty->bTurnBasedModeOn && melee_attack) // wands, bows & lasers will add recovery while shooting spell effect |
303 | 460 { |
816 | 461 int recovery = player->GetAttackRecoveryTime(false); |
303 | 462 if (recovery < 30 ) |
463 recovery = 30; | |
816 | 464 player->SetRecoveryTime(flt_6BE3A4_debug_recmod1 * (double)recovery * 2.133333333333333); |
295 | 465 } |
466 | |
467 | |
468 int v34 = 0; | |
469 if (shooting_wand) | |
470 return; | |
471 else if (shooting_bow) | |
472 { | |
473 v34 = 5; | |
474 player->PlaySound(SPEECH_50, 0); | |
475 } | |
476 if (shotting_laser) | |
477 v34 = 7; | |
478 else | |
479 { | |
480 int main_hand_idx = player->pEquipment.uMainHand; | |
1989 | 481 if (player->HasItemEquipped(EQUIP_TWO_HANDED)) |
1709
8251e59fd7c1
ITEM_ENCHANTED to ITEM_HARDENED, created helper functions to get params from itemtable for ItemGens
Grumpy7
parents:
1685
diff
changeset
|
482 v34 = player->pInventoryItemList[main_hand_idx - 1].GetPlayerSkillType(); |
1448 | 483 pTurnEngine->ApplyPlayerAction(); |
295 | 484 } |
485 | |
486 switch (v34) | |
487 { | |
488 case 0: pAudioPlayer->PlaySound(SOUND_81, 0, 0, -1, 0, 0, 0, 0); break; | |
489 case 1: pAudioPlayer->PlaySound(SOUND_84, 0, 0, -1, 0, 0, 0, 0); break; | |
490 case 2: pAudioPlayer->PlaySound(SOUND_85, 0, 0, -1, 0, 0, 0, 0); break; | |
491 case 3: pAudioPlayer->PlaySound(SOUND_78, 0, 0, -1, 0, 0, 0, 0); break; | |
492 case 4: pAudioPlayer->PlaySound(SOUND_80, 0, 0, -1, 0, 0, 0, 0); break; | |
493 case 5: pAudioPlayer->PlaySound(SOUND_71, 0, 0, -1, 0, 0, 0, 0); break; | |
494 case 6: pAudioPlayer->PlaySound(SOUND_83, 0, 0, -1, 0, 0, 0, 0); break; | |
495 case 7: pAudioPlayer->PlaySound(SOUND_67, 0, 0, -1, 0, 0, 0, 0); break; | |
496 } | |
0 | 497 } |
498 | |
499 //----- (0042F184) -------------------------------------------------------- | |
295 | 500 int stru319::FindClosestActor(int pick_depth, int a3, int a4) |
0 | 501 { |
502 int v4; // edi@1 | |
503 stru319 *v5; // esi@1 | |
504 int v6; // eax@2 | |
505 int v7; // eax@4 | |
506 int result; // eax@5 | |
507 int *v9; // edx@8 | |
508 signed int v10; // ebx@10 | |
509 int v11; // edi@11 | |
510 Actor *v12; // esi@12 | |
511 unsigned __int16 v13; // ax@12 | |
512 int v14; // eax@22 | |
513 char v15; // zf@30 | |
514 int v16; // esi@32 | |
515 int v17; // ecx@34 | |
516 stru319 *v18; // eax@39 | |
517 int v19; // edx@39 | |
518 int v20; // ecx@41 | |
519 unsigned __int16 v21; // ax@42 | |
520 unsigned int v22; // [sp+8h] [bp-24h]@11 | |
521 unsigned int v23; // [sp+Ch] [bp-20h]@7 | |
522 stru319 *v24; // [sp+10h] [bp-1Ch]@1 | |
523 unsigned int v25; // [sp+14h] [bp-18h]@8 | |
524 int *v26; // [sp+18h] [bp-14h]@8 | |
525 int v27; // [sp+1Ch] [bp-10h]@10 | |
526 int *v28; // [sp+20h] [bp-Ch]@10 | |
527 unsigned int v29; // [sp+24h] [bp-8h]@7 | |
528 int v30; // [sp+28h] [bp-4h]@6 | |
529 int i; // [sp+38h] [bp+Ch]@33 | |
530 signed int v32; // [sp+3Ch] [bp+10h]@32 | |
531 | |
532 v4 = 0; | |
533 v5 = this; | |
534 v24 = this; | |
535 if ( pRenderer->pRenderD3D ) | |
536 { | |
537 v6 = a3 != 0; | |
538 if ( a4 ) | |
539 LOBYTE(v6) = v6 | 8; | |
295 | 540 v7 = pGame->pVisInstance->PickClosestActor(OBJECT_Actor, pick_depth, v6, 657456, -1); |
0 | 541 if ( v7 != -1 ) |
542 return (unsigned __int16)v7; | |
295 | 543 else return 0; |
0 | 544 } |
545 else | |
546 { | |
547 v30 = 0; | |
548 if ( pRenderer->pActiveZBuffer ) | |
549 { | |
692 | 550 v29 = viewparams->uScreen_topL_X; |
551 v23 = viewparams->uScreen_BttmR_X; | |
552 if ( (signed int)viewparams->uScreen_topL_Y < (signed int)viewparams->uScreen_BttmR_Y ) | |
0 | 553 { |
692 | 554 v25 = viewparams->uScreen_BttmR_Y - viewparams->uScreen_topL_Y; |
555 v9 = &pRenderer->pActiveZBuffer[viewparams->uScreen_topL_X + 640 * viewparams->uScreen_topL_Y]; | |
556 v26 = &pRenderer->pActiveZBuffer[viewparams->uScreen_topL_X + 640 * viewparams->uScreen_topL_Y]; | |
0 | 557 do |
558 { | |
559 if ( (signed int)v29 < (signed int)v23 ) | |
560 { | |
561 v28 = v9; | |
562 v10 = v4; | |
563 v27 = v23 - v29; | |
564 do | |
565 { | |
566 v22 = *v28; | |
567 v11 = *v28 & 0xFFFF; | |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
568 if (PID_TYPE(v11) == OBJECT_Actor) |
0 | 569 { |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
570 v12 = &pActors[PID_ID(v11)]; |
0 | 571 v13 = v12->uAIState; |
572 if ( v13 != 5 ) | |
573 { | |
574 if ( v13 != 4 | |
575 && v13 != 11 | |
576 && v13 != 19 | |
577 && v13 != 17 | |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
578 && (!a3 || pActors[PID_ID(v11)].GetActorsRelation(0)) ) |
0 | 579 { |
580 if ( (!a4 || MonsterStats::BelongsToSupertype(v12->pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD)) | |
295 | 581 && v22 <= pick_depth << 16 ) |
0 | 582 { |
583 v14 = 0; | |
584 if ( v10 > 0 ) | |
585 { | |
586 do | |
587 { | |
588 if ( dword_50BDA0[v14] == v11 ) | |
589 break; | |
590 ++v14; | |
591 } | |
592 while ( v14 < v30 ); | |
593 } | |
594 if ( v14 == v30 && v10 < 100 ) | |
595 { | |
596 ++v30; | |
597 dword_50BC10[v10] = v22; | |
598 dword_50BDA0[v10] = v11; | |
599 ++v10; | |
600 } | |
601 } | |
602 } | |
603 } | |
604 } | |
605 ++v28; | |
606 --v27; | |
607 } | |
608 while ( v27 ); | |
609 v4 = v30; | |
610 v5 = v24; | |
611 } | |
612 v9 = v26 + 640; | |
613 v15 = v25-- == 1; | |
614 v26 += 640; | |
615 } | |
616 while ( !v15 ); | |
617 } | |
618 if ( v4 > 0 ) | |
619 { | |
620 v32 = 1; | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
621 v16 = (int)dword_50BC10.data(); |
0 | 622 do |
623 { | |
624 for ( i = v32; i < v4; ++i ) | |
625 { | |
626 v17 = dword_50BC10[i]; | |
627 if ( v17 < *(int *)v16 ) | |
628 { | |
629 dword_50BC10[i] = *(int *)v16; | |
630 *(int *)v16 = v17; | |
631 } | |
632 } | |
633 ++v32; | |
634 v16 += 4; | |
635 } | |
636 while ( v32 - 1 < v4 ); | |
637 v5 = v24; | |
638 if ( v4 > 0 ) | |
639 { | |
640 v18 = v24; | |
641 v19 = v4; | |
642 do | |
643 { | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
644 *(int *)&v18->field_0 = (*(int *)&v18[(char *)dword_50BC10.data() - (char *)v24].field_0 >> 3) & 0x1FFF; |
0 | 645 v18 += 4; |
646 --v19; | |
647 } | |
648 while ( v19 ); | |
649 } | |
650 } | |
651 v20 = 0; | |
652 for ( *(int *)&v5[2000].field_0 = v4; v20 < v4; ++v20 ) | |
653 { | |
654 v21 = pActors[*(int *)&v5[4 * v20].field_0].uAIState; | |
655 if ( v21 != 4 && v21 != 5 ) | |
656 break; | |
657 } | |
658 if ( v20 != v4 ) | |
659 { | |
660 result = 8 * *(int *)&v5[4 * v20].field_0; | |
661 LOBYTE(result) = result | 3; | |
662 return result; | |
663 } | |
664 } | |
665 } | |
666 return 0; | |
667 } | |
668 | |
669 //----- (0042F3D6) -------------------------------------------------------- | |
670 void InitializeTurnBasedAnimations(void *_this) | |
671 { | |
672 unsigned int *v1; // edi@1 | |
673 | |
674 pIconIDs_Turn[0] = pIconsFrameTable->FindIcon("turn0"); | |
675 pIconIDs_Turn[1] = pIconsFrameTable->FindIcon("turn1"); | |
676 pIconIDs_Turn[2] = pIconsFrameTable->FindIcon("turn2"); | |
677 pIconIDs_Turn[3] = pIconsFrameTable->FindIcon("turn3"); | |
678 pIconIDs_Turn[4] = pIconsFrameTable->FindIcon("turn4"); | |
679 uIconID_TurnStop = pIconsFrameTable->FindIcon("turnstop"); | |
680 uIconID_TurnHour = pIconsFrameTable->FindIcon("turnhour"); | |
681 uIconID_TurnStart = pIconsFrameTable->FindIcon("turnstart"); | |
682 uIconID_CharacterFrame = pIconsFrameTable->FindIcon("aframe1"); | |
683 uSpriteID_Spell11 = pSpriteFrameTable->FastFindSprite("spell11"); | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
684 v1 = pIconIDs_Turn.data(); |
0 | 685 do |
686 { | |
687 pIconsFrameTable->InitializeAnimation(*v1); | |
688 ++v1; | |
689 } | |
690 while ( (signed int)v1 < (signed int)&uIconID_TurnStop ); | |
691 pIconsFrameTable->InitializeAnimation(uIconID_TurnHour); | |
692 pIconsFrameTable->InitializeAnimation(uIconID_TurnStop); | |
693 pIconsFrameTable->InitializeAnimation(uIconID_TurnStart); | |
694 pIconsFrameTable->InitializeAnimation(uIconID_CharacterFrame); | |
695 } | |
696 | |
697 //----- (0042F7EB) -------------------------------------------------------- | |
698 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) | |
699 { | |
1406 | 700 unsigned __int16 pObjectDescID; // ax@7 |
701 SpriteObject pSpellObject; // [sp+Ch] [bp-78h]@1 | |
0 | 702 |
1406 | 703 pSpellObject.stru_24.Reset(); |
0 | 704 if ( a9 ) |
1406 | 705 memcpy(&pSpellObject.stru_24, a9, sizeof(pSpellObject.stru_24)); |
706 pSpellObject.spell_skill = 0; | |
707 pSpellObject.spell_level = 0; | |
708 pSpellObject.spell_id = 0; | |
709 pSpellObject.field_54 = 0; | |
710 pSpellObject.uType = uSpriteID; | |
0 | 711 if ( (signed int)pObjectList->uNumObjects <= 0 ) |
1406 | 712 pObjectDescID = 0; |
0 | 713 else |
714 { | |
1406 | 715 pObjectDescID = 0; |
716 for ( uint i = 0; i < (signed int)pObjectList->uNumObjects; ++i ) | |
0 | 717 { |
1406 | 718 if ( (short)uSpriteID == pObjectList->pObjects[i].uObjectID ) |
719 pObjectDescID = i; | |
0 | 720 } |
721 } | |
1406 | 722 pSpellObject.uObjectDescID = pObjectDescID; |
723 pSpellObject.vPosition.x = x; | |
724 pSpellObject.vPosition.y = y; | |
725 pSpellObject.vPosition.z = z; | |
726 pSpellObject.uSoundID = 0; | |
727 pSpellObject.uAttributes = attributes; | |
728 pSpellObject.uSectorID = pIndoor->GetSector(x, y, z); | |
729 pSpellObject.uSpriteFrameID = 0; | |
730 pSpellObject.spell_caster_pid = 0; | |
731 pSpellObject.spell_target_pid = 0; | |
732 if ( !(pSpellObject.uAttributes & 0x10) ) | |
733 { | |
734 if ( pItemsTable->uAllItemsCount ) | |
735 { | |
1729
f44b6e02e81c
pop-up window in character(paperdill) window, alchemy
Ritor1
parents:
1709
diff
changeset
|
736 for ( uint i = 1; i < pItemsTable->uAllItemsCount; ++i ) |
1406 | 737 { |
738 if ( pItemsTable->pItems[i].uSpriteID == uSpriteID ) | |
739 pSpellObject.stru_24.uItemID = i; | |
740 } | |
741 } | |
742 } | |
0 | 743 if ( a7 ) |
744 { | |
745 if ( count > 0 ) | |
746 { | |
1406 | 747 for ( uint i = count; i; --i ) |
0 | 748 { |
1406 | 749 pSpellObject.uFacing = rand() % (signed int)stru_5C6E00->uIntegerDoublePi; |
750 pSpellObject.Create((signed __int16)pSpellObject.uFacing, | |
751 ((signed int)stru_5C6E00->uIntegerHalfPi / 2) + (rand() % ((signed int)stru_5C6E00->uIntegerHalfPi / 2)), a4, 0); | |
752 | |
0 | 753 } |
754 } | |
755 } | |
756 else | |
757 { | |
1406 | 758 pSpellObject.uFacing = 0; |
0 | 759 if ( count > 0 ) |
760 { | |
1406 | 761 for ( uint i = count; i; --i ) |
0 | 762 { |
1406 | 763 pSpellObject.Create((signed __int16)pSpellObject.uFacing, stru_5C6E00->uIntegerHalfPi, a4, 0); |
0 | 764 } |
765 } | |
766 } | |
1406 | 767 return true; |
0 | 768 } |
769 | |
770 //----- (0042F960) -------------------------------------------------------- | |
771 void __fastcall sub_42F960_create_object(int x, int y, int z) | |
772 { | |
773 int v3; // ebx@1 | |
774 int v4; // edi@1 | |
775 signed int v5; // edx@1 | |
776 char *v6; // ecx@2 | |
777 unsigned __int16 v7; // ax@5 | |
778 signed int v8; // eax@6 | |
779 signed int v9; // eax@7 | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
490
diff
changeset
|
780 //SpriteObject a1; // [sp+Ch] [bp-70h]@1 |
0 | 781 |
782 v3 = x; | |
783 v4 = y; | |
784 | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
490
diff
changeset
|
785 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
|
786 //SpriteObject::SpriteObject(&a1); |
0 | 787 a1.stru_24.Reset(); |
788 | |
789 v5 = 0; | |
822 | 790 a1.spell_skill = 0; |
791 a1.spell_level = 0; | |
792 a1.spell_id = 0; | |
0 | 793 a1.field_54 = 0; |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
490
diff
changeset
|
794 a1.uType = 800; |
0 | 795 if ( (signed int)pObjectList->uNumObjects <= 0 ) |
796 { | |
797 LABEL_5: | |
798 v7 = 0; | |
799 } | |
800 else | |
801 { | |
802 v6 = (char *)&pObjectList->pObjects->uObjectID; | |
803 while ( *(short *)v6 != 800 ) | |
804 { | |
805 ++v5; | |
806 v6 += 56; | |
807 if ( v5 >= (signed int)pObjectList->uNumObjects ) | |
808 goto LABEL_5; | |
809 } | |
810 v7 = v5; | |
811 } | |
812 a1.uObjectDescID = v7; | |
813 a1.vPosition.x = v3; | |
814 a1.vPosition.y = v4; | |
815 a1.vPosition.z = z; | |
816 a1.uSoundID = 0; | |
817 a1.uAttributes = 0; | |
818 a1.uSectorID = pIndoor->GetSector(v3, v4, z); | |
819 a1.uSpriteFrameID = 0; | |
822 | 820 a1.spell_caster_pid = 0; |
823 | 821 a1.spell_target_pid = 0; |
0 | 822 v8 = a1.Create(0, 0, 0, 0); |
823 if ( v8 != -1 ) | |
824 { | |
825 v9 = 8 * v8; | |
826 LOBYTE(v9) = v9 | 2; | |
827 pAudioPlayer->PlaySound((SoundID)(SOUND_GoldReceived|0x14), v9, 0, -1, 0, 0, 0, 0); | |
828 } | |
829 } | |
830 | |
810 | 831 |
0 | 832 |
833 //----- (0042FA66) -------------------------------------------------------- | |
1546 | 834 void _42FA66_do_explosive_impact(int a1, int a2, int a3, int a4, __int16 a5, signed int a6) |
0 | 835 { |
836 int v6; // edi@1 | |
837 int v7; // esi@1 | |
838 char *v8; // ecx@2 | |
839 unsigned __int16 v9; // ax@5 | |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
840 //int v10; // eax@10 |
1546 | 841 //signed int result; // eax@11 |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
842 //__int16 v12; // ax@12 |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
490
diff
changeset
|
843 //SpriteObject a1a; // [sp+Ch] [bp-74h]@1 |
0 | 844 int v14; // [sp+7Ch] [bp-4h]@1 |
845 | |
846 v6 = a1; | |
847 v7 = a2; | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
490
diff
changeset
|
848 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
|
849 //SpriteObject::SpriteObject(&a1a); |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
490
diff
changeset
|
850 a1a.uType = 600; |
0 | 851 a1a.stru_24.Reset(); |
852 | |
822 | 853 a1a.spell_id = SPELL_FIRE_FIREBALL; |
854 a1a.spell_level = 8; | |
855 a1a.spell_skill = 3; | |
0 | 856 v14 = 0; |
857 if ( (signed int)pObjectList->uNumObjects <= 0 ) | |
858 { | |
859 LABEL_5: | |
860 v9 = 0; | |
861 } | |
862 else | |
863 { | |
864 v8 = (char *)&pObjectList->pObjects->uObjectID; | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
490
diff
changeset
|
865 while ( (short)a1a.uType != *(short *)v8 ) |
0 | 866 { |
867 ++v14; | |
868 v8 += 56; | |
869 if ( v14 >= (signed int)pObjectList->uNumObjects ) | |
870 goto LABEL_5; | |
871 } | |
872 v9 = v14; | |
873 } | |
874 a1a.uObjectDescID = v9; | |
875 a1a.vPosition.x = v6; | |
876 a1a.vPosition.y = v7; | |
877 a1a.vPosition.z = a3; | |
878 a1a.uAttributes = 0; | |
879 a1a.uSectorID = pIndoor->GetSector(v6, v7, a3); | |
880 a1a.uSpriteFrameID = 0; | |
823 | 881 a1a.spell_target_pid = 0; |
0 | 882 a1a.field_60_distance_related_prolly_lod = 0; |
883 a1a.uFacing = 0; | |
884 a1a.uSoundID = 0; | |
885 if ( a6 >= 1 || a6 <= 4 ) | |
886 { | |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
887 a1a.spell_caster_pid = PID(OBJECT_Player, a6 - 1); |
0 | 888 } |
889 else | |
890 { | |
822 | 891 a1a.spell_caster_pid = 0; |
0 | 892 } |
1546 | 893 |
894 int id = a1a.Create(0, 0, 0, 0); | |
895 if (id != -1) | |
896 stru_50FE08.Add(PID(OBJECT_Item, id), | |
0 | 897 a5, |
898 SLOWORD(a1a.vPosition.x), | |
899 SLOWORD(a1a.vPosition.y), | |
900 SLOWORD(a1a.vPosition.z), | |
901 0, | |
902 0); | |
903 } | |
904 | |
905 //----- (0042FB5C) -------------------------------------------------------- | |
1458 | 906 bool _42FB5C_check_spell(signed int a1) |
0 | 907 { |
908 int v1; // ecx@3 | |
909 int v2; // ecx@4 | |
910 int v3; // ecx@5 | |
911 int v4; // ecx@6 | |
912 int v5; // ecx@7 | |
913 int v6; // ecx@8 | |
914 char v7; // zf@9 | |
915 | |
916 if ( a1 > 39 ) | |
917 { | |
918 if ( a1 > 77 ) | |
919 { | |
920 if ( a1 == 80 ) | |
921 return 0; | |
922 if ( a1 > 84 ) | |
923 { | |
924 if ( a1 <= 86 ) | |
925 return 0; | |
926 v7 = a1 == 95; | |
927 goto LABEL_20; | |
928 } | |
929 } | |
930 else | |
931 { | |
932 if ( a1 == 77 ) | |
933 return 0; | |
934 if ( a1 >= 46 ) | |
935 { | |
936 if ( a1 <= 47 || a1 == 51 ) | |
937 return 0; | |
938 v7 = a1 == 73; | |
939 goto LABEL_20; | |
940 } | |
941 } | |
942 return 1; | |
943 } | |
944 if ( a1 == 39 || (v1 = a1 - 2) == 0 ) | |
945 return 1; | |
946 v2 = v1 - 3; | |
947 if ( !v2 ) | |
948 return 0; | |
949 v3 = v2 - 1; | |
950 if ( !v3 || (v4 = v3 - 3) == 0 ) | |
951 return 1; | |
952 v5 = v4 - 8; | |
953 if ( !v5 ) | |
954 return 0; | |
955 v6 = v5 - 1; | |
956 if ( !v6 ) | |
957 return 1; | |
958 v7 = v6 == 20; | |
959 LABEL_20: | |
960 if ( !v7 ) | |
961 return 1; | |
962 return 0; | |
963 } | |
964 | |
965 //----- (0042FBDD) -------------------------------------------------------- | |
1458 | 966 void sub_42FBDD() |
0 | 967 { |
388 | 968 pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); |
0 | 969 pRenderer->DrawTextureTransparent(pBtn_YES->uX, pBtn_YES->uY, pBtn_YES->pTextures[0]); |
970 pRenderer->Present(); | |
971 } | |
972 | |
973 //----- (0042FC15) -------------------------------------------------------- | |
1458 | 974 void CloseWindowBackground() |
0 | 975 { |
388 | 976 pAudioPlayer->PlaySound(SOUND_Button2, -2, 0, -1, 0, 0, 0, 0); |
0 | 977 pRenderer->DrawTextureTransparent(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY, pBtn_ExitCancel->pTextures[0]); |
978 pRenderer->Present(); | |
979 } | |
980 | |
981 //----- (0042FC4E) -------------------------------------------------------- | |
1575 | 982 void ProcessInputActions() |
0 | 983 { |
984 char v4; // al@9 | |
985 char v8; // bl@100 | |
986 unsigned __int16 v9; // ax@102 | |
987 int v10; // eax@103 | |
988 char v14; // al@159 | |
989 unsigned int v15; // eax@168 | |
990 PartyAction partyAction; // [sp-14h] [bp-1Ch]@20 | |
991 InputAction inputAction; // [sp+0h] [bp-8h]@7 | |
992 int v24; // [sp+4h] [bp-4h]@87 | |
993 | |
994 pGame->pKeyboardInstance->EnterCriticalSection(); | |
1980 | 995 Keyboard* pKeyboard = pGame->pKeyboardInstance; |
0 | 996 if (!bAlwaysRun) |
997 { | |
998 if (pKeyboard->IsShiftHeld()) | |
999 pParty->uFlags2 |= PARTY_FLAGS_2_RUNNING; | |
1000 else | |
1001 pParty->uFlags2 &= ~PARTY_FLAGS_2_RUNNING; | |
1002 } | |
1003 else | |
1004 { | |
1005 if (pKeyboard->IsShiftHeld()) | |
1006 pParty->uFlags2 &= ~PARTY_FLAGS_2_RUNNING; | |
1007 else | |
1008 pParty->uFlags2 |= PARTY_FLAGS_2_RUNNING; | |
1009 } | |
1010 | |
140 | 1011 //pParty->uFlags2 |= PARTY_FLAGS_2_RUNNING; |
1052 | 1012 |
1013 | |
1014 // WUT? double event trigger | |
1015 /*for ( uint i = 0; i < 30; ++i ) | |
998 | 1016 { |
1017 if ( pKeyActionMap->pToggleTypes[i] ) | |
1018 v14 = pGame->pKeyboardInstance->WasKeyPressed(pKeyActionMap->pVirtualKeyCodesMapping[i]); | |
1019 else | |
1020 v14 = pGame->pKeyboardInstance->IsKeyBeingHeld(pKeyActionMap->pVirtualKeyCodesMapping[i]); | |
1052 | 1021 if ( v14 ) |
998 | 1022 { |
1052 | 1023 if (pCurrentScreen == SCREEN_GAME) |
998 | 1024 { |
1025 pMessageQueue_50CBD0->AddMessage(UIMSG_Game_Action, 0, 0); | |
1026 continue; | |
1027 } | |
1028 if ( pCurrentScreen == SCREEN_NPC_DIALOGUE || pCurrentScreen == SCREEN_BRANCHLESS_NPC_DIALOG ) | |
1029 { | |
1030 v15 = pMessageQueue_50CBD0->uNumMessages; | |
1031 if ( pMessageQueue_50CBD0->uNumMessages ) | |
1032 { | |
1033 v15 = 0; | |
1034 if ( pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].field_8 ) | |
1035 { | |
1036 v15 = 1; | |
1037 pMessageQueue_50CBD0->uNumMessages = 0; | |
1038 pMessageQueue_50CBD0->pMessages[v15].eType = UIMSG_Escape; | |
1039 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; | |
1040 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; | |
1041 ++pMessageQueue_50CBD0->uNumMessages; | |
1042 continue; | |
1043 } | |
1044 pMessageQueue_50CBD0->uNumMessages = 0; | |
1045 } | |
1046 //pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); | |
1047 } | |
1048 } | |
1052 | 1049 }*/ |
0 | 1050 if ( !pEventTimer->bPaused ) |
1051 { | |
998 | 1052 for ( uint i = 0; i < 30; ++i ) |
0 | 1053 { |
998 | 1054 inputAction = (InputAction)i; |
1055 if ( pKeyActionMap->pToggleTypes[(InputAction)i] ) | |
1056 v4 = pKeyboard->WasKeyPressed(pKeyActionMap->pVirtualKeyCodesMapping[(InputAction)i]); | |
0 | 1057 else |
998 | 1058 v4 = pKeyboard->IsKeyBeingHeld(pKeyActionMap->pVirtualKeyCodesMapping[(InputAction)i]); |
0 | 1059 if ( v4 ) |
1060 { | |
1061 switch ( inputAction ) | |
1062 { | |
1063 case INPUT_MoveForward: | |
271 | 1064 if (pCurrentScreen != SCREEN_GAME) |
0 | 1065 break; |
1066 if (!pParty->bTurnBasedModeOn) | |
1067 { | |
140 | 1068 if ( pParty->uFlags2 & PARTY_FLAGS_2_RUNNING) |
0 | 1069 partyAction = PARTY_RunForward; |
1070 else | |
1071 partyAction = PARTY_WalkForward; | |
998 | 1072 pPartyActionQueue->Add(partyAction); |
163 | 1073 break; |
1074 } | |
1340 | 1075 if (pTurnEngine->turn_stage != 1 && pTurnEngine->turn_stage != 2 && pTurnEngine->uActionPointsLeft > 0 ) |
163 | 1076 { |
1077 pTurnEngine->uActionPointsLeft -= 26; | |
1078 if ( pParty->uFlags2 & PARTY_FLAGS_2_RUNNING) | |
1079 partyAction = PARTY_RunForward; | |
1080 else | |
1081 partyAction = PARTY_WalkForward; | |
998 | 1082 pPartyActionQueue->Add(partyAction); |
163 | 1083 break; |
0 | 1084 } |
1085 break; | |
1086 case INPUT_MoveBackwards: | |
271 | 1087 if (pCurrentScreen != SCREEN_GAME) |
0 | 1088 break; |
1089 if (!pParty->bTurnBasedModeOn) | |
17 | 1090 { |
1091 if ( pParty->uFlags2 & 2 ) | |
1092 partyAction = PARTY_RunBackward; | |
1093 else | |
1094 partyAction = PARTY_WalkBackward; | |
998 | 1095 pPartyActionQueue->Add(partyAction); |
163 | 1096 break; |
17 | 1097 } |
1340 | 1098 if ( pTurnEngine->turn_stage != 1 && pTurnEngine->turn_stage != 2 && pTurnEngine->uActionPointsLeft > 0 ) |
0 | 1099 { |
1100 pTurnEngine->uActionPointsLeft -= 26; | |
1101 if ( pParty->uFlags2 & 2 ) | |
1102 partyAction = PARTY_RunBackward; | |
1103 else | |
1104 partyAction = PARTY_WalkBackward; | |
998 | 1105 pPartyActionQueue->Add(partyAction); |
163 | 1106 break; |
0 | 1107 } |
1108 break; | |
1109 case INPUT_StrafeLeft: | |
271 | 1110 if (pCurrentScreen != SCREEN_GAME) |
0 | 1111 break; |
1112 if (!pParty->bTurnBasedModeOn) | |
17 | 1113 { |
1114 partyAction = PARTY_StrafeLeft; | |
998 | 1115 pPartyActionQueue->Add(partyAction); |
163 | 1116 break; |
17 | 1117 } |
1340 | 1118 if ( pTurnEngine->turn_stage == 1 || pTurnEngine->turn_stage == 2 || pTurnEngine->uActionPointsLeft <= 0 ) |
0 | 1119 break; |
1120 pTurnEngine->uActionPointsLeft -= 26; | |
1121 partyAction = PARTY_StrafeLeft; | |
998 | 1122 pPartyActionQueue->Add(partyAction); |
1123 break; | |
0 | 1124 case INPUT_StrafeRight: |
271 | 1125 if (pCurrentScreen != SCREEN_GAME) |
0 | 1126 break; |
1127 if (!pParty->bTurnBasedModeOn) | |
17 | 1128 { |
1129 partyAction = PARTY_StrafeRight; | |
998 | 1130 pPartyActionQueue->Add(partyAction); |
163 | 1131 break; |
17 | 1132 } |
1340 | 1133 if ( pTurnEngine->turn_stage == 1 || pTurnEngine->turn_stage == 2 || pTurnEngine->uActionPointsLeft <= 0 ) |
0 | 1134 break; |
1135 pTurnEngine->uActionPointsLeft -= 26; | |
1136 partyAction = PARTY_StrafeRight; | |
998 | 1137 pPartyActionQueue->Add(partyAction); |
163 | 1138 break; |
0 | 1139 case INPUT_TurnLeft: |
271 | 1140 if (pCurrentScreen != SCREEN_GAME) |
0 | 1141 break; |
1142 if ( GetAsyncKeyState(VK_CONTROL) ) // strafing | |
1143 { | |
1144 if (pParty->bTurnBasedModeOn) | |
1145 { | |
1340 | 1146 if ( pTurnEngine->turn_stage == 1 || pTurnEngine->turn_stage == 2 || pTurnEngine->uActionPointsLeft <= 0 ) |
0 | 1147 break; |
1148 pTurnEngine->uActionPointsLeft -= 26; | |
1149 } | |
998 | 1150 partyAction = PARTY_StrafeLeft; |
0 | 1151 } |
1152 else | |
1153 { | |
1154 if ( pParty->uFlags2 & 2 ) | |
998 | 1155 partyAction = PARTY_FastTurnLeft; |
0 | 1156 else |
998 | 1157 partyAction = PARTY_TurnLeft; |
0 | 1158 } |
998 | 1159 pPartyActionQueue->Add(partyAction); |
0 | 1160 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor && pWeather->bRenderSnow) |
1161 { | |
271 | 1162 pWeather->OnPlayerTurn(10); |
0 | 1163 } |
1164 break; | |
1165 case INPUT_TurnRight: | |
271 | 1166 if (pCurrentScreen != SCREEN_GAME) |
0 | 1167 break; |
1168 if ( GetAsyncKeyState(17) ) // strafing | |
1169 { | |
1170 if (pParty->bTurnBasedModeOn) | |
1171 { | |
1340 | 1172 if ( pTurnEngine->turn_stage == 1 || pTurnEngine->turn_stage == 2 || pTurnEngine->uActionPointsLeft <= 0 ) |
0 | 1173 break; |
1174 pTurnEngine->uActionPointsLeft -= 26; | |
1175 } | |
998 | 1176 partyAction = PARTY_StrafeRight; |
0 | 1177 } |
1178 else | |
1179 { | |
1180 if ( pParty->uFlags2 & 2 ) | |
998 | 1181 partyAction = PARTY_FastTurnRight; |
0 | 1182 else |
998 | 1183 partyAction = PARTY_TurnRight; |
0 | 1184 } |
998 | 1185 pPartyActionQueue->Add(partyAction); |
0 | 1186 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor && pWeather->bRenderSnow) |
1187 { | |
271 | 1188 pWeather->OnPlayerTurn(-10); |
0 | 1189 } |
1190 break; | |
1191 case INPUT_Jump: | |
271 | 1192 if (pCurrentScreen != SCREEN_GAME || pParty->bTurnBasedModeOn) |
0 | 1193 break; |
1194 partyAction = (PartyAction)12; | |
998 | 1195 pPartyActionQueue->Add(partyAction); |
163 | 1196 break; |
0 | 1197 case INPUT_Yell: |
187 | 1198 if (!pCurrentScreen && uActiveCharacter) |
0 | 1199 { |
1200 pParty->Yell(); | |
187 | 1201 pPlayers[uActiveCharacter]->PlaySound(SPEECH_Yell, 0); |
0 | 1202 } |
187 | 1203 break; |
0 | 1204 case INPUT_Pass: |
1205 if ( pCurrentScreen ) | |
1206 break; | |
1340 | 1207 if (pParty->bTurnBasedModeOn && pTurnEngine->turn_stage == 3) |
17 | 1208 { |
1332 | 1209 pTurnEngine->field_18 |= TE_FLAG_8; |
17 | 1210 break; |
1211 } | |
0 | 1212 if ( uActiveCharacter ) |
1213 { | |
998 | 1214 if ( !pPlayers[uActiveCharacter]->uTimeToRecovery ) |
0 | 1215 { |
998 | 1216 v24 = pPlayers[uActiveCharacter]->GetAttackRecoveryTime(false); |
0 | 1217 if ( !pParty->bTurnBasedModeOn ) |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
1218 pPlayers[uActiveCharacter]->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * (double)v24 * 2.133333333333333)); |
1517 | 1219 CastSpellInfoHelpers::_427D48(); |
1448 | 1220 pTurnEngine->ApplyPlayerAction(); |
0 | 1221 } |
1222 } | |
1223 break; | |
998 | 1224 case INPUT_Combat://if press ENTER |
271 | 1225 if (pCurrentScreen == SCREEN_GAME) |
0 | 1226 { |
1227 if (pParty->bTurnBasedModeOn) | |
1228 { | |
1340 | 1229 if (pTurnEngine->turn_stage == 3 || PID_TYPE(pTurnEngine->pQueue[0].uPackedID) == OBJECT_Player) |
0 | 1230 { |
1231 pParty->bTurnBasedModeOn = 0; | |
1232 pTurnEngine->End(true); | |
1233 } | |
1234 } | |
1235 else | |
1236 { | |
1237 pTurnEngine->Start(); | |
1238 pParty->bTurnBasedModeOn = true; | |
1239 } | |
1240 } | |
1241 break; | |
1242 case INPUT_CastReady: | |
271 | 1243 if (pCurrentScreen != SCREEN_GAME) |
0 | 1244 break; |
1340 | 1245 if (pParty->bTurnBasedModeOn && pTurnEngine->turn_stage == 3) |
17 | 1246 { |
1332 | 1247 pTurnEngine->field_18 |= TE_FLAG_8; |
17 | 1248 break; |
1249 } | |
0 | 1250 if ( !uActiveCharacter ) |
1251 break; | |
998 | 1252 v8 = pPlayers[uActiveCharacter]->uQuickSpell; |
0 | 1253 if ( !v8 |
1254 || bUnderwater | |
998 | 1255 || ((v9 = pPlayers[uActiveCharacter]->pActiveSkills[(unsigned __int8)v8 / 11 + 12], !(HIBYTE(v9) & 1)) ? |
1256 ((v9 & 0x80u) == 0 ? (!(v9 & 0x40) ? (v10 = *(&pSpellDatas[0].uNormalLevelMana + 10 * (unsigned __int8)v8)) : | |
1257 (v10 = *(&pSpellDatas[0].uExpertLevelMana + 10 * (unsigned __int8)v8))) : | |
1258 (v10 = *(&pSpellDatas[0].uMasterLevelMana + 10 * (unsigned __int8)v8))) : | |
1259 (v10 = *(&pSpellDatas[0].uMagisterLevelMana + 10 * (unsigned __int8)v8)), | |
1260 v10 > pPlayers[uActiveCharacter]->sMana) ) | |
0 | 1261 { |
998 | 1262 pPartyActionQueue = pPartyActionQueue; |
437 | 1263 pMessageQueue_50CBD0->AddMessage(UIMSG_Attack, 0, 0); |
1264 break; | |
0 | 1265 } |
1266 else | |
1267 { | |
1012 | 1268 pMessageQueue_50C9E8->AddMessage(UIMSG_CastQuickSpell, 0, 0); |
0 | 1269 } |
1270 break; | |
1271 case INPUT_Attack: | |
271 | 1272 if (pCurrentScreen != SCREEN_GAME) |
0 | 1273 break; |
1340 | 1274 if (pParty->bTurnBasedModeOn == 1 && pTurnEngine->turn_stage == 3) |
998 | 1275 { |
1332 | 1276 pTurnEngine->field_18 |= TE_FLAG_8; |
998 | 1277 break; |
1278 } | |
1279 pMessageQueue_50CBD0->AddMessage(UIMSG_Attack, 0, 0); | |
0 | 1280 break; |
1281 case INPUT_EventTrigger: | |
271 | 1282 if (pCurrentScreen == SCREEN_GAME) |
0 | 1283 { |
437 | 1284 pMessageQueue_50CBD0->AddMessage(UIMSG_Game_Action, 0, 0); |
163 | 1285 break; |
0 | 1286 } |
151 | 1287 if ( pCurrentScreen == SCREEN_NPC_DIALOGUE ) |
0 | 1288 { |
1289 if ( pMessageQueue_50CBD0->uNumMessages ) | |
1290 { | |
437 | 1291 pMessageQueue_50CBD0->uNumMessages = 0; |
0 | 1292 if ( pMessageQueue_50CBD0->pMessages[0].field_8 ) |
1293 { | |
1294 pMessageQueue_50CBD0->uNumMessages = 1; | |
998 | 1295 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape; |
0 | 1296 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; |
1575 | 1297 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].field_8 = 0; |
0 | 1298 ++pMessageQueue_50CBD0->uNumMessages; |
1299 break; | |
1300 } | |
437 | 1301 break; |
0 | 1302 } |
437 | 1303 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); |
0 | 1304 } |
1305 break; | |
1306 case INPUT_CharCycle: | |
1012 | 1307 if ( pCurrentScreen == SCREEN_SPELL_BOOK ) |
0 | 1308 break; |
1575 | 1309 |
1012 | 1310 pMessageQueue_50C9E8->AddMessage(UIMSG_CycleCharacters, 0, 0); |
163 | 1311 break; |
0 | 1312 case INPUT_LookUp: |
1313 if ( pEventTimer->bPaused ) | |
1314 break; | |
1315 partyAction = (PartyAction)7; | |
998 | 1316 pPartyActionQueue->Add(partyAction); |
163 | 1317 break; |
0 | 1318 case INPUT_CenterView: |
1319 if ( pEventTimer->bPaused ) | |
1320 break; | |
1321 partyAction = (PartyAction)9; | |
998 | 1322 pPartyActionQueue->Add(partyAction); |
163 | 1323 break; |
0 | 1324 case INPUT_LookDown: |
1325 if ( pEventTimer->bPaused ) | |
1326 break; | |
1327 partyAction = (PartyAction)8; | |
998 | 1328 pPartyActionQueue->Add(partyAction); |
163 | 1329 break; |
0 | 1330 case INPUT_FlyUp: |
998 | 1331 if ( pCurrentScreen || pEventTimer->bPaused ) |
0 | 1332 break; |
1333 partyAction = (PartyAction)13; | |
998 | 1334 pPartyActionQueue->Add(partyAction); |
163 | 1335 break; |
0 | 1336 case INPUT_Land: |
998 | 1337 if ( pCurrentScreen || pEventTimer->bPaused ) |
0 | 1338 break; |
1339 partyAction = (PartyAction)15; | |
998 | 1340 pPartyActionQueue->Add(partyAction); |
163 | 1341 break; |
0 | 1342 case INPUT_FlyDown: |
1343 if ( !pCurrentScreen | |
1344 && !pEventTimer->bPaused ) | |
1345 { | |
1346 partyAction = (PartyAction)14; | |
998 | 1347 pPartyActionQueue->Add(partyAction); |
0 | 1348 } |
1349 break; | |
1350 case INPUT_ZoomIn: | |
1012 | 1351 pMessageQueue_50C9E8->AddMessage(UIMSG_ClickZoomOutBtn, 0, 0); |
163 | 1352 break; |
0 | 1353 case INPUT_ZoomOut: |
1012 | 1354 pMessageQueue_50C9E8->AddMessage(UIMSG_ClickZoomInBtn, 0, 0); |
0 | 1355 break; |
1356 case INPUT_AlwaysRun: | |
1357 bAlwaysRun = bAlwaysRun == 0; | |
1358 break; | |
17 | 1359 default: |
1360 break; | |
0 | 1361 } |
1362 } | |
1363 } | |
1364 } | |
1365 } |