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