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