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