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