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