Mercurial > mm7
diff mm7_6.cpp @ 828:0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
author | Nomad |
---|---|
date | Wed, 27 Mar 2013 00:27:38 +0200 |
parents | fe4c8b113548 |
children | 08d90b633131 |
line wrap: on
line diff
--- a/mm7_6.cpp Tue Mar 26 20:06:51 2013 +0200 +++ b/mm7_6.cpp Wed Mar 27 00:27:38 2013 +0200 @@ -2489,20 +2489,20 @@ //int v32; // eax@112 //char *v33; // edx@113 //int v34; // eax@121 - int v35; // eax@123 - int v36; // edx@125 + //int v35; // eax@123 + //int v36; // edx@125 //int v37; // eax@129 - signed int v38; // edi@129 - signed int v39; // eax@129 - int v40; // ecx@129 - int v41; // eax@129 - signed int v42; // eax@129 - int *v43; // ecx@129 + //signed int v38; // edi@129 + //signed int v39; // eax@129 + //int v40; // ecx@129 + //int v41; // eax@129 + //signed int v42; // eax@129 + //int *v43; // ecx@129 //int v44; // eax@132 - int v45; // ecx@132 + //int v45; // ecx@132 int v46; // eax@132 - unsigned int v47; // edx@133 - int v48; // eax@137 + //unsigned int v47; // edx@133 + //int v48; // eax@137 //int v49; // eax@137 //int v50; // eax@141 int v51; // eax@146 @@ -2537,7 +2537,7 @@ //int v80; // eax@232 //__int16 v81; // ST18_2@245 //stru6 *v82; // eax@245 - signed int v83; // edi@245 + //signed int v83; // edi@245 //__int16 v84; // ST18_2@245 //stru6 *v85; // eax@245 //__int16 v86; // ST18_2@245 @@ -2574,8 +2574,8 @@ int v117; // edx@281 int v118; // edx@283 int v119; // edi@286 - int v120; // eax@286 - int v121; // eax@286 + //int v120; // eax@286 + //int v121; // eax@286 signed int v122; // eax@286 int v123; // ecx@288 int v124; // ecx@289 @@ -2606,7 +2606,7 @@ int v149; // ecx@312 int v150; // ecx@313 int v151; // ecx@314 - signed int v152; // eax@322 + //signed int v152; // eax@322 int v153; // ecx@322 int v154; // eax@322 int v155; // eax@323 @@ -2617,7 +2617,7 @@ signed __int64 v160; // qtt@334 //int v161; // eax@339 int v162; // edi@340 - int v163; // eax@340 + //int v163; // eax@340 signed int v164; // eax@340 signed int v165; // edi@340 //stru6 *v166; // eax@340 @@ -2693,7 +2693,7 @@ //stru6 *v236; // eax@469 //__int16 v237; // ST18_2@469 //stru6 *v238; // eax@469 - __int16 v239; // ST1C_2@469 + //__int16 v239; // ST1C_2@469 char *v240; // ecx@472 double v241; // st7@478 signed __int64 v242; // qax@484 @@ -2780,7 +2780,7 @@ int v323; // edi@635 char *v324; // eax@635 Player *v325; // ecx@640 - int v326; // eax@643 + //int v326; // eax@643 //int v327; // eax@648 int v328; // ecx@651 int v329; // ecx@652 @@ -2824,7 +2824,7 @@ //stru6 *v367; // eax@704 //int v368; // eax@704 Actor *v369; // edi@705 - int v370; // eax@706 + //int v370; // eax@706 int v371; // ecx@709 int v372; // ecx@710 int v373; // eax@715 @@ -2839,9 +2839,9 @@ int v382; // ecx@727 Player *v383; // eax@728 int v384; // eax@733 - int v385; // edi@736 - signed int v386; // eax@736 - Player *v387; // edi@738 + //int v385; // edi@736 + //signed int v386; // eax@736 + //Player *v387; // edi@738 int v388; // edi@740 //unsigned __int16 v389; // ST1C_2@740 //__int16 v390; // ST18_2@740 @@ -2881,14 +2881,14 @@ int v424; // ecx@809 int v425; // eax@811 signed int v426; // eax@815 - signed int v427; // eax@820 + //signed int v427; // eax@820 int v428; // ecx@825 int v429; // ecx@826 int v430; // eax@828 //stru6 *v431; // eax@831 //int v432; // eax@831 Actor *v433; // edi@832 - int v434; // eax@833 + //int v434; // eax@833 int v435; // ecx@837 int v436; // ecx@838 //__int16 v437; // ST1C_2@843 @@ -2962,16 +2962,16 @@ int v505; // eax@943 //int v506; // eax@943 int v507; // edi@944 - int v508; // eax@944 + //int v508; // eax@944 signed int v509; // eax@944 signed int v510; // edi@944 Actor *v511; // edi@946 - int v512; // eax@946 + //int v512; // eax@946 SpellBuff *v513; // edi@946 int v514; // ecx@950 int v515; // ecx@951 int v516; // eax@953 - int v517; // eax@956 + //int v517; // eax@956 Actor *v518; // edx@957 __int16 v519; // cx@958 int v520; // ecx@968 @@ -2988,7 +2988,7 @@ int v531; // eax@982 //int v532; // eax@982 int v533; // edi@983 - int v534; // eax@983 + //int v534; // eax@983 signed int v535; // eax@983 signed int v536; // edi@983 stru6 *v537; // eax@984 @@ -3036,7 +3036,7 @@ __int16 v579; // ax@1029 //int v580; // eax@1031 int v581; // edi@1031 - int v582; // eax@1031 + //int v582; // eax@1031 //__int16 v583; // ST1C_2@1034 //__int16 v584; // ST18_2@1034 char *v585; // esi@1034 @@ -3053,7 +3053,7 @@ int v596; // esi@1066 unsigned int v597; // edi@1067 int v598; // eax@1079 - signed int v599; // eax@1082 + //signed int v599; // eax@1082 int v600; // edi@1086 int v601; // edx@1086 int v602; // eax@1086 @@ -3080,15 +3080,15 @@ signed __int64 v623; // qax@1127 //int v624; // eax@1127 int v625; // edi@1129 - int v626; // eax@1129 + //int v626; // eax@1129 signed int v627; // eax@1129 signed int v628; // edi@1129 int v629; // ecx@1130 Player *v630; // eax@1131 int v631; // eax@1137 - int v632; // edi@1140 - Player *v633; // eax@1140 - signed int v634; // eax@1140 + //int v632; // edi@1140 + //Player *v633; // eax@1140 + //signed int v634; // eax@1140 int v635; // edi@1142 //unsigned __int16 v636; // ST1C_2@1142 //__int16 v637; // ST18_2@1142 @@ -3108,7 +3108,7 @@ //unsigned __int16 v651; // [sp-8h] [bp-E8Ch]@100 //unsigned __int16 v652; // [sp-8h] [bp-E8Ch]@304 //unsigned __int16 v653; // [sp-4h] [bp-E88h]@100 - int v654; // [sp-4h] [bp-E88h]@124 + //int v654; // [sp-4h] [bp-E88h]@124 //unsigned __int16 v655; // [sp-4h] [bp-E88h]@304 unsigned int v656; // [sp-4h] [bp-E88h]@639 int v657; // [sp-4h] [bp-E88h]@807 @@ -3123,12 +3123,12 @@ int v666; // [sp+4h] [bp-E80h]@12 PLAYER_SKILL_TYPE v667; // [sp+4h] [bp-E80h]@25 //unsigned __int8 v668; // [sp+4h] [bp-E80h]@100 - int v669; // [sp+4h] [bp-E80h]@123 - Vec3_int_ *v670; // [sp+4h] [bp-E80h]@133 + //int v669; // [sp+4h] [bp-E80h]@123 + //Vec3_int_ *v670; // [sp+4h] [bp-E80h]@133 int v671; // [sp+4h] [bp-E80h]@146 unsigned int v672; // [sp+4h] [bp-E80h]@164 //unsigned __int8 v673; // [sp+4h] [bp-E80h]@304 - __int16 v674; // [sp+4h] [bp-E80h]@684 + //__int16 v674; // [sp+4h] [bp-E80h]@684 const char *v675; // [sp+4h] [bp-E80h]@800 int v676; // [sp+4h] [bp-E80h]@807 int v677; // [sp+4h] [bp-E80h]@861 @@ -3142,28 +3142,28 @@ unsigned __int64 v685; // [sp+D08h] [bp-17Ch]@416 int x; // [sp+D20h] [bp-164h]@327 unsigned __int64 v687; // [sp+D24h] [bp-160h]@327 - int v688; // [sp+D2Ch] [bp-158h]@943 - int v689; // [sp+D30h] [bp-154h]@943 - int v690; // [sp+D34h] [bp-150h]@943 - int v691; // [sp+D38h] [bp-14Ch]@137 - int v692; // [sp+D3Ch] [bp-148h]@137 - int v693; // [sp+D40h] [bp-144h]@137 - int v694; // [sp+D44h] [bp-140h]@982 - int v695; // [sp+D48h] [bp-13Ch]@982 - int v696; // [sp+D4Ch] [bp-138h]@982 - int v697; // [sp+D50h] [bp-134h]@129 - int v698; // [sp+D54h] [bp-130h]@129 - int v699; // [sp+D58h] [bp-12Ch]@129 + Vec3_int_ v688; // [sp+D2Ch] [bp-158h]@943 + //int v689; // [sp+D30h] [bp-154h]@943 + //int v690; // [sp+D34h] [bp-150h]@943 + Vec3_int_ v691; // [sp+D38h] [bp-14Ch]@137 + //int v692; // [sp+D3Ch] [bp-148h]@137 + //int v693; // [sp+D40h] [bp-144h]@137 + Vec3_int_ v694; // [sp+D44h] [bp-140h]@982 + //int v695; // [sp+D48h] [bp-13Ch]@982 + //int v696; // [sp+D4Ch] [bp-138h]@982 + Vec3_int_ v697; // [sp+D50h] [bp-134h]@129 + //int v698; // [sp+D54h] [bp-130h]@129 + //int v699; // [sp+D58h] [bp-12Ch]@129 Vec3_int_ v700; // [sp+D5Ch] [bp-128h]@339 - int v701; // [sp+D68h] [bp-11Ch]@286 - int v702; // [sp+D6Ch] [bp-118h]@286 - int v703; // [sp+D70h] [bp-114h]@286 - int v704; // [sp+D74h] [bp-110h]@132 - int v705; // [sp+D78h] [bp-10Ch]@132 - int v706; // [sp+D7Ch] [bp-108h]@132 - int v707; // [sp+D80h] [bp-104h]@1127 - int v708; // [sp+D84h] [bp-100h]@1127 - int v709; // [sp+D88h] [bp-FCh]@1127 + Vec3_int_ v701; // [sp+D68h] [bp-11Ch]@286 + //int v702; // [sp+D6Ch] [bp-118h]@286 + //int v703; // [sp+D70h] [bp-114h]@286 + Vec3_int_ v704; // [sp+D74h] [bp-110h]@132 + //int v705; // [sp+D78h] [bp-10Ch]@132 + //int v706; // [sp+D7Ch] [bp-108h]@132 + Vec3_int_ v707; // [sp+D80h] [bp-104h]@1127 + //int v708; // [sp+D84h] [bp-100h]@1127 + //int v709; // [sp+D88h] [bp-FCh]@1127 char v710; // [sp+D8Ch] [bp-F8h]@1156 stru277 *v711; // [sp+D90h] [bp-F4h]@1 __int64 v712; // [sp+D94h] [bp-F0h]@991 @@ -3181,7 +3181,7 @@ ItemGen *_this; // [sp+E50h] [bp-34h]@23 float v725; // [sp+E54h] [bp-30h]@23 Player *v726; // [sp+E58h] [bp-2Ch]@131 - int v726b; + //int v726b; float v727; // [sp+E5Ch] [bp-28h]@1 unsigned int uRequiredMana; // [sp+E60h] [bp-24h]@53 Player *pPlayer; // [sp+E64h] [bp-20h]@8 @@ -3238,7 +3238,7 @@ a2 = stru_50C198.FindClosestActor(5120, 1, v666); v6 = pMouse->uPointingObjectID; - if ( pMouse->uPointingObjectID && (v6 & 7) == OBJECT_Actor && pActors[v6 >> 3].CanAct() ) + if ( pMouse->uPointingObjectID && PID_TYPE(v6) == OBJECT_Actor && pActors[PID_ID(v6)].CanAct() ) a2 = pMouse->uPointingObjectID; } @@ -3246,9 +3246,9 @@ a1.uType = stru_4E3ACC[v3->spellnum].field_0; if (a1.uType) { - if ( (a2 & 7) == OBJECT_Actor) + if (PID_TYPE(a2) == OBJECT_Actor) { - memcpy(&v715, Actor::GetDirectionInfo((8 * v3->uPlayerID + 8) | OBJECT_Player, a2, &a3, 0), sizeof(v715)); + memcpy(&v715, Actor::GetDirectionInfo(PID(OBJECT_Player, v3->uPlayerID + 8), a2, &a3, 0), sizeof(v715)); v2 = v723; } else @@ -3313,7 +3313,6 @@ } } - v730 = v3->spellnum; if (v3->forced_spell_skill_level) uRequiredMana = 0; else @@ -3328,7 +3327,6 @@ break; ShowStatusBarString(pGlobalTXT_LocalizationStrings[586], 2u); // "Not enough spell points" -LABEL_203: v3->spellnum = 0; LABEL_1166: ++n; @@ -3336,10 +3334,11 @@ return; } - if (pPlayer->Cursed() && v730 < SPELL_BOW_ARROW) + v730 = v3->spellnum; + if (pPlayer->Cursed() && v3->spellnum < SPELL_BOW_ARROW) if (rand() % 100 < 50) { - if ( pParty->bTurnBasedModeOn == 0 ) + if (!pParty->bTurnBasedModeOn) { //v646 = pPlayer; pPlayer->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * 213.3333333333333)); @@ -3464,9 +3463,11 @@ goto play_sound_and_continue; pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)3600 * v2 * 4.2666669), v731, amount, 0, 0); - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; case SPELL_FIRE_FIRE_SPIKE: + { v29 = v731 - 2; if ( v29 ) { @@ -3492,12 +3493,12 @@ //LOBYTE(v32) = v32 | OBJECT_Player; //if ( (signed int)uNumSpriteObjects > 0 ) - HIDWORD(v733) = 0; + int _v733 = 0; for (uint i = 0; i < uNumSpriteObjects; ++i) { auto object = pSpriteObjects + i; - if (object->uType && object->spell_id == SPELL_FIRE_FIRE_SPIKE && object->spell_caster_pid == (8 * (int)v3->uPlayerID) | OBJECT_Player) - ++HIDWORD(v733); + if (object->uType && object->spell_id == SPELL_FIRE_FIRE_SPIKE && object->spell_caster_pid == PID(OBJECT_Player, v3->uPlayerID)) + ++_v733; /*v33 = (char *)&pSpriteObjects[0].field_48; v730 = uNumSpriteObjects; do @@ -3509,11 +3510,12 @@ } while ( v730 );*/ } - if ( SHIDWORD(v733) > amount ) + if (_v733 > amount) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; + v3->spellnum = 0; + goto LABEL_1166; } if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; @@ -3539,25 +3541,32 @@ a1.uSoundID = LOWORD(v3->sound_id); if ( pParty->bTurnBasedModeOn == 1 ) LOBYTE(a1.uAttributes) |= 4u; - v669 = v3->uPlayerID + 1; v659 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed; - v35 = pParty->sRotationX + 10; - goto LABEL_124; + if ( a1.Create(pParty->sRotationY, pParty->sRotationX + 10, v659, v3->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) + ++pTurnEngine->field_1C; + LODWORD(v727) = 1; + goto play_sound_and_continue; + } case 20: + { if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; if (!a2) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; - } - if ( (a2 & 7) != OBJECT_Actor) - goto LABEL_1056; - v699 = 0; - v698 = 0; - v697 = 0; + v3->spellnum = 0; + goto LABEL_1166; + } + if (PID_TYPE(a2) != OBJECT_Actor) + { + LODWORD(v727) = 1; + goto play_sound_and_continue; + } + v697.x = 0; + v697.y = 0; + v697.z = 0; a1.stru_24.Reset(); a1.spell_id = v3->spellnum; a1.spell_level = v2; @@ -3569,31 +3578,31 @@ a1.field_60_distance_related_prolly_lod = 0; a1.uFacing = 0; a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); - v38 = a2 >> 3; a1.uSoundID = LOWORD(v3->sound_id); - v39 = a2 >> 3; - a1.vPosition.x = pActors[v39].vPosition.x; - v40 = pActors[v39].vPosition.y; - a1.vPosition.z = pActors[v39].vPosition.z; - v41 = 8 * (a2 >> 3); - a1.vPosition.y = v40; - LOBYTE(v41) = v41 | OBJECT_Actor; - a1.spell_target_pid = v41; - v42 = a1.Create(0, 0, 0, 0); - v43 = &v697; - goto LABEL_133; + a1.vPosition.x = pActors[PID_ID(a2)].vPosition.x; + a1.vPosition.z = pActors[PID_ID(a2)].vPosition.z; + a1.vPosition.y = pActors[PID_ID(a2)].vPosition.y; + a1.spell_target_pid = PID(OBJECT_Actor, a2 >> 3); + auto obj_id = a1.Create(0, 0, 0, 0); + DamageMonsterFromParty(PID(OBJECT_Item, obj_id), PID_ID(a2), &v697); + LODWORD(v727) = 1; + goto play_sound_and_continue; + } + case 44: + { if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; - v726 = (Player *)(a2 >> 3); - HIDWORD(v733) = 836 * (a2 >> 3); + if ( !stru_50C198.GetMagicalResistance(&pActors[a2 >> 3], 3u) ) - goto LABEL_1056; - pActors[a2 >> 3].pActorBuffs[10].Apply( - pMiscTimer->uTotalGameTimeElapsed + 128, 0, 0, 0, 0); - v706 = 0; - v705 = 0; - v704 = 0; + { + LODWORD(v727) = 1; + goto play_sound_and_continue; + } + pActors[a2 >> 3].pActorBuffs[10].Apply(pMiscTimer->uTotalGameTimeElapsed + 128, 0, 0, 0, 0); + v704.x = 0; + v704.y = 0; + v704.z = 0; a1.stru_24.Reset(); a1.spell_id = v3->spellnum; a1.spell_level = v2; @@ -3604,59 +3613,59 @@ a1.uSpriteFrameID = 0; a1.field_60_distance_related_prolly_lod = 0; a1.uFacing = 0; - v38 = (signed int)v726; a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); a1.uSoundID = LOWORD(v3->sound_id); - a1.vPosition.x = *(__int16 *)((char *)&pActors[0].vPosition.x + HIDWORD(v733)); - v45 = *(__int16 *)((char *)&pActors[0].vPosition.y + HIDWORD(v733)); - a1.vPosition.z = *(__int16 *)((char *)&pActors[0].vPosition.z + HIDWORD(v733)); - a1.vPosition.y = v45; + a1.vPosition.x = pActors[PID_ID(a2)].vPosition.x; + a1.vPosition.y = pActors[PID_ID(a2)].vPosition.y; + a1.vPosition.z = pActors[PID_ID(a2)].vPosition.z; a1.spell_target_pid = PID(OBJECT_Actor, (int)v726); - v42 = a1.Create(0, 0, 0, 0); - v43 = &v704; -LABEL_133: - v670 = (Vec3_int_ *)v43; - v47 = v38; - goto LABEL_139; + + auto obj_id = a1.Create(0, 0, 0, 0); + DamageMonsterFromParty(PID(OBJECT_Item, obj_id), PID_ID(a2), &v704); + + LODWORD(v727) = 1; + goto play_sound_and_continue; + } + case 79: - if ( !pPlayer->CanCastSpell(uRequiredMana) || !a2 || (a2 & 7) != OBJECT_Actor) - goto play_sound_and_continue; - v730 = a2 >> 3; - v693 = 0; - HIDWORD(v733) = (int)&pActors[a2 >> 3]; - v692 = 0; - v691 = 0; + { + if ( !pPlayer->CanCastSpell(uRequiredMana) || !a2 || PID_TYPE(a2) != OBJECT_Actor) + goto play_sound_and_continue; + //v730 = a2 >> 3; + //HIDWORD(v733) = (int)&pActors[PID_ID(a2)]; + v691.x = 0; + v691.y = 0; + v691.z = 0; a1.stru_24.Reset(); a1.spell_id = v3->spellnum; a1.spell_level = v2; a1.spell_skill = v731; a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); - a1.vPosition.x = *(short *)(HIDWORD(v733) + 142); - a1.vPosition.y = *(short *)(HIDWORD(v733) + 144); - v48 = *(short *)(HIDWORD(v733) + 138); - a1.vPosition.z = *(short *)(HIDWORD(v733) + 138); + a1.vPosition.x = pActors[PID_ID(a2)].vPosition.x; + a1.vPosition.y = pActors[PID_ID(a2)].vPosition.y; + a1.vPosition.z = pActors[PID_ID(a2)].vPosition.z; a1.uAttributes = 0; - a1.uSectorID = pIndoor->GetSector(a1.vPosition.x, a1.vPosition.y, v48); + a1.uSectorID = pIndoor->GetSector(a1.vPosition.x, a1.vPosition.y, a1.vPosition.z); a1.uSpriteFrameID = 0; a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); a1.spell_target_pid = a2; a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); a1.uFacing = LOWORD(v715.uYawAngle); - LOBYTE(a1.uAttributes) |= 0x80u; + a1.uAttributes |= 0x80u; a1.uSoundID = LOWORD(v3->sound_id); - v726 = (Player *)a1.Create(0, 0, 0, 0); + + auto obj_id = a1.Create(0, 0, 0, 0); if ( !MonsterStats::BelongsToSupertype(*(short *)(HIDWORD(v733) + 96), MONSTER_SUPERTYPE_UNDEAD) ) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; - } - v47 = v730; - v670 = (Vec3_int_ *)&v691; - v42 = (signed int)v726; -LABEL_139: - DamageMonsterFromParty(8 * v42 | 2, v47, v670); - goto LABEL_1056; + v3->spellnum = 0; + goto LABEL_1166; + } + DamageMonsterFromParty(PID(OBJECT_Item, obj_id), PID_ID(a2), &v691); + LODWORD(v727) = 1; + goto play_sound_and_continue; + } case SPELL_FIRE_FIRE_BOLT: @@ -3690,16 +3699,21 @@ else a1.uSectorID = 0; a1.uSpriteFrameID = 0; - a1.spell_caster_pid = (8 * v3->uPlayerID) | OBJECT_Player; + a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); a1.spell_target_pid = a2; a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); a1.uFacing = LOWORD(v715.uYawAngle); a1.uSoundID = LOWORD(v3->sound_id); if ( pParty->bTurnBasedModeOn == 1 ) LOBYTE(a1.uAttributes) |= 4u; - if ( v3->spellnum == 18 ) + if ( v3->spellnum == SPELL_AIR_LIGHNING_BOLT ) LOBYTE(a1.uAttributes) |= 0x40u; - goto LABEL_156; + + v659 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed; + if ( a1.Create(v715.uYawAngle, v715.uPitchAngle, v659, v3->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) + ++pTurnEngine->field_1C; + LODWORD(v727) = 1; + goto play_sound_and_continue; @@ -3725,22 +3739,28 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; + v3->spellnum = 0; + goto LABEL_1166; } if ( pPlayer->CanCastSpell(uRequiredMana) ) goto LABEL_152; goto play_sound_and_continue; + + case 81: + { if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; - if ( !a2 - || (a2 & 7) != OBJECT_Actor - || (v730 = a2 >> 3, - v721 = (int)&pActors[a2 >> 3], + + if (PID_TYPE(a2) != OBJECT_Actor || + (v730 = PID_ID(a2), + v721 = (int)&pActors[PID_ID(a2)], !stru_50C198.GetMagicalResistance(&pActors[a2 >> 3], 9u)) ) - goto LABEL_1056; - Actor::AI_Stand(v730, 4u, 0x80u, 0); - v726 = (Player *)(23040 * v2); + { + LODWORD(v727) = 1; + goto play_sound_and_continue; + } + Actor::AI_Stand(PID_ID(a2), 4u, 0x80u, 0); v54 = (signed __int64)((double)(23040 * v2) * 0.033333335); v55 = v721; ((SpellBuff *)(v721 + 308))->Apply(pParty->uTimePlayed + (signed int)v54, v731, 0, 0, 0); @@ -3750,6 +3770,8 @@ *(short *)(v55 + 150) = 0; v661 = (Actor *)v55; goto LABEL_165; + } + case 35: if ( v731 == 2 ) { @@ -3776,17 +3798,18 @@ LODWORD(v733) = v57; if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; - if ( (a2 & 7) != OBJECT_Actor - || (v721 = 836 * (a2 >> 3), - LODWORD(v718) = (int)&pActors[a2 >> 3], - !stru_50C198.GetMagicalResistance(&pActors[a2 >> 3], 3u)) ) - goto LABEL_1056; - v726 = (Player *)(23040 * v2); + if (PID_TYPE(a2) != OBJECT_Actor + || (v721 = 836 * PID_ID(a2), + LODWORD(v718) = (int)&pActors[PID_ID(a2)], + !stru_50C198.GetMagicalResistance(&pActors[PID_ID(a2)], 3u)) ) + { + LODWORD(v727) = 1; + goto play_sound_and_continue; + } v58 = (signed __int64)((double)(23040 * v2) * 0.033333335); v59 = v721; //((SpellBuff *)((char *)&pActors[0].pActorBuffs[7] + v721))->Apply( - pActors[a2 >> 3].pActorBuffs[7].Apply( - pParty->uTimePlayed + (signed int)v58, + pActors[a2 >> 3].pActorBuffs[7].Apply(pParty->uTimePlayed + (signed int)v58, v731, amount, 0, @@ -3795,30 +3818,33 @@ v672 = 0; v661 = (Actor *)LODWORD(v718); goto LABEL_165; + + case 60: + { if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; - v730 = 836 * (a2 >> 3); - if ( !stru_50C198.GetMagicalResistance(&pActors[a2>>3], 7u) ) - goto LABEL_1056; - LODWORD(v733) = 300 * v2; + + if ( !stru_50C198.GetMagicalResistance(&pActors[PID_ID(a2)], 7u) ) + { + LODWORD(v727) = 1; + goto play_sound_and_continue; + } + + uint power = 300 * v2; if ( v731 == 2 ) { - LODWORD(v733) = 600 * v2; - } - else - { - if ( v731 == 3 ) - LODWORD(v733) = 29030400; - } + power = 600 * v2; + } + else if ( v731 == 3 ) + power = 29030400; + //((SpellBuff *)((char *)&pActors[0].pActorBuffs[9] + v730))->Reset(); - pActors[a2 >> 3].pActorBuffs[9].Reset(); + pActors[PID_ID(a2)].pActorBuffs[9].Reset(); //((SpellBuff *)((char *)&pActors[0].pActorBuffs[12] + v730))->Reset(); - pActors[a2 >> 3].pActorBuffs[12].Reset(); - v726 = (Player *)((int)v733 << 7); + pActors[PID_ID(a2)].pActorBuffs[12].Reset(); //((SpellBuff *)((char *)&pActors[0].pActorBuffs[1] + v730))->Apply( - pActors[a2 >> 3].pActorBuffs[1].Apply( - pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), + pActors[PID_ID(a2)].pActorBuffs[1].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)(power << 7) * 0.033333335), v731, 0, 0, 0); a1.stru_24.Reset(); a1.spell_id = v3->spellnum; @@ -3827,6 +3853,8 @@ v60 = pObjectList->ObjectIDByItemID(a1.uType); v61 = a2 >> 3; goto LABEL_1086; + } + case 92: if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; @@ -3849,8 +3877,18 @@ a1.spell_skill = v731; a1.spell_id = SPELL_FIRE_PROTECTION_FROM_FIRE; a1.spell_level = 300 * v2; - goto LABEL_154; + if ( pParty->bTurnBasedModeOn == 1 ) + LOBYTE(a1.uAttributes) |= 4u; + + v659 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed; + + if ( a1.Create(v715.uYawAngle, v715.uPitchAngle, v659, v3->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) + ++pTurnEngine->field_1C; + LODWORD(v727) = 1; + goto play_sound_and_continue; + case 4: + { v63 = v731 - 1; if ( !v63 ) { @@ -3880,7 +3918,7 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; v730c = &pParty->pPlayers[v3->uPlayerID_2].pInventoryItems[a2]; - v726 = (Player *)&pItemsTable->pItems[v730c->uItemID].pIconName; + auto _itm = &pItemsTable->pItems[v730c->uItemID]; v730c->UpdateTempBonus(pParty->uTimePlayed); if ( v730c->uItemID < 64 || v730c->uItemID > 65 ) { @@ -3890,7 +3928,7 @@ { if (!v730c->uEnchantmentType) { - v68 = BYTE4(v726->pConditions[3]); + v68 = _itm->uEquipType; if ( !v68 || v68 == 1 || v68 == 2 ) { if ( !pItemsTable->IsMaterialNonCommon(v730c) ) @@ -3900,21 +3938,17 @@ *(int *)(v730 + 12) = amount; if ( !v14 ) { - v726 = (Player *)((int)v733 << 7); *(_QWORD *)(v69 + 28) = pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335); *(int *)(v69 + 20) |= 8u; } *(int *)(v69 + 20) |= 0x10u; -LABEL_1055: dword_50C9A8 = 256; -LABEL_1056: LODWORD(v727) = 1; play_sound_and_continue: if ( v3->field_8 & 0x20 ) { -LABEL_1162: if ( v727 != 0.0 ) pAudioPlayer->PlaySound( (SoundID)word_4EE088_sound_ids[v3->spellnum], @@ -3946,12 +3980,23 @@ if ( v727 != 0.0 ) { pPlayer->PlaySound(SPEECH_49, 0); - goto LABEL_1162; + if ( v727 != 0.0 ) + pAudioPlayer->PlaySound( + (SoundID)word_4EE088_sound_ids[v3->spellnum], + 0, + 0, + -1, + 0, + v3->sound_id, + 0, + 0); + + v3->spellnum = 0; + v2 = v723; + goto LABEL_1166; } } v3->spellnum = 0; - //v1 = 0; -LABEL_1165: v2 = v723; goto LABEL_1166; } @@ -3967,9 +4012,12 @@ ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; + v3->spellnum = 0; + goto LABEL_1166; + } case SPELL_BODY_REGENERATION: + { v70 = v731 - 1; LODWORD(v733) = 3600 * v2; if ( v70 && (v71 = v70 - 1) != 0 ) @@ -3995,7 +4043,9 @@ pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2); pParty->pPlayers[v3->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_REGENERATION].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)v733 * 4.2666669), v731, amount, 0, 0); - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; + } case SPELL_FIRE_PROTECTION_FROM_FIRE: case SPELL_AIR_PROTECTION_FROM_AIR: @@ -4065,11 +4115,10 @@ pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 1); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 3); - v83 = 1; v90 = (double)(signed int)v733 * 4.2666669; pParty->pPartyBuffs[LODWORD(v725)].Apply(pParty->uTimePlayed + (signed int)(signed __int64)v90, v731, amount, 0, 0); - LODWORD(v727) = 1; + LODWORD(v727) = 1; goto play_sound_and_continue; case SPELL_FIRE_HASTE: @@ -4107,7 +4156,6 @@ while ( v92 <= &pParty->pPlayers[3] ); if (LODWORD(v727)) { - v726 = (Player *)((int)v733 << 7); pParty->pPartyBuffs[PARTY_BUFF_HASTE].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, 0, 0, 0); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 0); @@ -4154,7 +4202,6 @@ v716 = v111; //v658 = v111; //v653 = amount; - v726 = (Player *)((int)v733 << 7); //v651 = 1; //v28 = pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335); //v27 = (char *)&pParty->pPlayers[v3->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_BLESS]; @@ -4163,10 +4210,10 @@ //LABEL_104: //LODWORD(v650) = v28; pParty->pPlayers[v3->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_BLESS].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), 1, amount, v111, 0); - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; } v105 = 0; - v726 = (Player *)((int)v733 << 7); v717 = (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335); v730b = pParty->pPlayers;//[0].pPlayerBuffs[1]; do @@ -4178,29 +4225,30 @@ ++v105; } while ( v730b <= &pParty->pPlayers[3] ); - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; case 52: - if ( pPlayer->CanCastSpell(uRequiredMana) && a2 && (a2 & 7) == OBJECT_Actor) - { - v730 = a2 >> 3; - v112 = &pActors[a2 >> 3]; - v726 = (Player *)abs(v112->vPosition.z - pParty->vPosition.z); + if ( pPlayer->CanCastSpell(uRequiredMana) && a2 && PID_TYPE(a2) == OBJECT_Actor) + { + //v730 = a2 >> 3; + v112 = &pActors[PID_ID(a2)]; + //v726 = (Player *)abs(v112->vPosition.z - pParty->vPosition.z); v721 = abs(v112->vPosition.y - pParty->vPosition.y); v113 = abs(v112->vPosition.x - pParty->vPosition.x); _this = (ItemGen *)v113; v114 = v721; - v115 = (unsigned int)v726; + v115 = (unsigned int)abs(v112->vPosition.z - pParty->vPosition.z); if ( v113 < v721 ) { v116 = v113; v113 = v721; v114 = v116; } - if ( v113 < (signed int)v726 ) + if ( v113 < (signed int)v115 ) { v117 = v113; - v113 = (int)v726; + v113 = (int)v115; v115 = v117; } if ( v114 < (signed int)v115 ) @@ -4212,9 +4260,9 @@ _this = (ItemGen *)(((unsigned int)(11 * v114) >> 5) + (v115 >> 2) + v113); if ( (double)(signed int)this <= 307.2 ) { - v703 = 0; - v702 = 0; - v701 = 0; + v701.x = 0; + v701.y = 0; + v701.z = 0; a1.stru_24.Reset(); v119 = HIDWORD(v733); a1.spell_id = *(int *)HIDWORD(v733); @@ -4224,21 +4272,16 @@ a1.uAttributes = 0; a1.uSectorID = 0; a1.uSpriteFrameID = 0; - v120 = 8 * *(short *)(v119 + 2); - LOBYTE(v120) = v120 | OBJECT_Player; a1.field_60_distance_related_prolly_lod = 0; - a1.spell_caster_pid = v120; + a1.spell_caster_pid = PID(OBJECT_Player, *(short *)(v119 + 2)); a1.uFacing = 0; a1.uSoundID = *(short *)(v119 + 16); a1.vPosition.x = v112->vPosition.x; a1.vPosition.y = v112->vPosition.y; - v726 = (Player *)v112->uActorHeight; - v121 = 8 * a2; - a1.vPosition.z = v112->vPosition.z - (unsigned int)(signed __int64)((double)(signed int)v726 * unk_4D8548); - LOBYTE(v121) = 8 * a2 | 3; - a1.spell_target_pid = v121; + a1.vPosition.z = v112->vPosition.z - (unsigned int)(signed __int64)((double)(signed int)v112->uActorHeight * unk_4D8548); + a1.spell_target_pid = PID(OBJECT_Actor, a2); v122 = a1.Create(0, 0, 0, 0); - DamageMonsterFromParty(8 * v122 | 2, v730, (Vec3_int_ *)&v701); + DamageMonsterFromParty(PID(OBJECT_Item, v122), PID_ID(a2), &v701); LODWORD(v727) = 1; } else @@ -4302,12 +4345,10 @@ pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 1); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 3); - v83 = 1; - v726 = (Player *)((int)v733 << 7); v90 = (double)(signed int)((int)v733 << 7) * 0.033333335; //LABEL_304: pParty->pPartyBuffs[LODWORD(v725)].Apply(pParty->uTimePlayed + (signed int)(signed __int64)v90, v731, amount, 0, 0); - LODWORD(v727) = v83; + LODWORD(v727) = 1; goto play_sound_and_continue; case SPELL_FIRE_IMMOLATION: @@ -4325,10 +4366,9 @@ pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 3); - v726 = (Player *)((int)v733 << 7); - pParty->pPartyBuffs[PARTY_BUFF_IMMOLATION].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, v2, 0, 0); - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; case 9: v149 = v731 - 1; @@ -4345,17 +4385,17 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[491], 2); // Can't cast Meteor Shower indoors! pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; + v3->spellnum = 0; + goto LABEL_1166; } if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; LODWORD(v725) = a2 & 7; - if ( (a2 & 7) == OBJECT_Actor) - { - v152 = a2 >> 3; - uRequiredMana = pActors[v152].vPosition.x; - v153 = pActors[v152].vPosition.y; - v154 = pActors[v152].vPosition.z; + if (PID_TYPE(a2) == OBJECT_Actor) + { + uRequiredMana = pActors[PID_ID(a2)].vPosition.x; + v153 = pActors[PID_ID(a2)].vPosition.y; + v154 = pActors[PID_ID(a2)].vPosition.z; LODWORD(v727) = v153; } else @@ -4370,12 +4410,12 @@ v713 = v154 + 2500; v721 = 0; LODWORD(v718) = 0; - if ( (signed int)this > 0 ) + if ( (signed int)_this > 0 ) { *(float *)&y = (double)SHIDWORD(v733); *(float *)&v732 = (double)v713; v730 = LODWORD(v725) == 3 ? a2 : 0; - v726 = (Player *)this; + auto _this_cpy = (int)_this; do { v157 = rand(); @@ -4410,7 +4450,7 @@ a1.uSectorID = 0; a1.vPosition.z = a2 + v713; a1.uSpriteFrameID = 0; - a1.spell_caster_pid = 8 * v3->uPlayerID | OBJECT_Player; + a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); a1.spell_target_pid = v730; a1.field_60_distance_related_prolly_lod = stru_50C198._427546(a2 + 2500); a1.uFacing = v687; @@ -4426,24 +4466,27 @@ ++pTurnEngine->field_1C; LODWORD(v718) = rand() % 1024 - 512; v160 = rand(); - v14 = v726 == (Player *)1; - v726 = (Player *)((char *)v726 - 1); + v14 = _this_cpy-- == 1; v721 = (unsigned __int64)(v160 % 1024) - 512; } while ( !v14 ); } - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; + case 10: + { //v67 = 2; if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[492], 2); // Can't cast Inferno outdoors! pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; + v3->spellnum = 0; + goto LABEL_1166; } if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; - v726 = (Player *)sub_46A6AC((int)dword_50BF30, 100, 4096); + auto _v726 = sub_46A6AC((int)dword_50BF30, 100, 4096); v700.z = 0; v700.y = 0; v700.x = 0; @@ -4460,28 +4503,27 @@ a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); a1.uSoundID = LOWORD(v3->sound_id); a2 = 0; - if ( (signed int)v726 > 0 ) + if ( (signed int)_v726 > 0 ) { do { v162 = dword_50BF30[a2]; a1.vPosition.x = pActors[v162].vPosition.x; a1.vPosition.y = pActors[v162].vPosition.y; - v732 = pActors[v162].uActorHeight; - a1.vPosition.z = pActors[v162].vPosition.z - (unsigned int)(signed __int64)((double)v732 * unk_4D8548); - v163 = 8 * dword_50BF30[a2]; - LOBYTE(v163) = v163 | OBJECT_Actor; - a1.spell_target_pid = v163; + a1.vPosition.z = pActors[v162].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v162].uActorHeight * unk_4D8548); + a1.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]); v164 = a1.Create(0, 0, 0, 0); v165 = a2; - DamageMonsterFromParty(8 * v164 | AI_OBJECT_LAYING_ITEM, dword_50BF30[a2], &v700); + DamageMonsterFromParty(PID(OBJECT_Item, v164), dword_50BF30[a2], &v700); pGame->GetStru6()->_4A81CA(&a1); pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xFF3C1Eu, 0x40u); a2 = v165 + 1; } - while ( v165 + 1 < (signed int)v726 ); - } - goto LABEL_1056; + while ( v165 + 1 < (signed int)_v726 ); + } + LODWORD(v727) = 1; + goto play_sound_and_continue; + } case SPELL_AIR_WIZARD_EYE: LODWORD(v733) = 3600 * v2; @@ -4495,10 +4537,9 @@ } while ( v168 < 4 ); - v732 = (int)v733 << 7; - pParty->pPartyBuffs[PARTY_BUFF_WIZARD_EYE].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, 0, 0, 0); - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; case SPELL_AIR_FEATHER_FALL: v170 = v731 - 1; @@ -4530,13 +4571,13 @@ pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 1); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 3); - v83 = 1; - v732 = (int)v733 << 7; - pParty->pPartyBuffs[PARTY_BUFF_FEATHER_FALL].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, 0, 0, 0); - LODWORD(v727) = v83; + + pParty->pPartyBuffs[PARTY_BUFF_FEATHER_FALL].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, 0, 0, 0); + LODWORD(v727) = 1; goto play_sound_and_continue; case SPELL_AIR_SPARKS: + { v184 = v731 - 1; if ( v184 ) { @@ -4565,8 +4606,7 @@ } if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; - v726 = (Player *)((signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360); - v732 = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360 / (amount - 1); + auto _v726 = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360; a1.stru_24.Reset(); a1.spell_id = v3->spellnum; a1.spell_level = v2; @@ -4587,8 +4627,8 @@ a1.uSoundID = LOWORD(v3->sound_id); if ( pParty->bTurnBasedModeOn == 1 ) LOBYTE(a1.uAttributes) |= 4u; - v188 = (signed int)v726 / -2; - v189 = (signed int)v726 / 2; + v188 = (signed int)_v726 / -2; + v189 = (signed int)_v726 / 2; while ( v188 <= v189 ) { a1.uFacing = v188 + LOWORD(v715.uYawAngle); @@ -4599,9 +4639,12 @@ v3->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) ++pTurnEngine->field_1C; - v188 += v732; - } - goto LABEL_1056; + v188 += _v726 / (amount - 1); + } + LODWORD(v727) = 1; + goto play_sound_and_continue; + } + case 16: if ( pParty->uFlags & PARTY_FLAGS_1_FALLING) { @@ -4617,7 +4660,8 @@ while ( v191 < 4 ); BYTE1(pParty->uFlags) |= 1u; pParty->uFallSpeed = 1000; - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; case SPELL_AIR_INVISIBILITY: v192 = v731 - 1; @@ -4653,7 +4697,8 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[638], 2); // There are hostile creatures nearby! pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; + v3->spellnum = 0; + goto LABEL_1166; } if ( pPlayer->CanCastSpell(uRequiredMana) ) { @@ -4661,15 +4706,14 @@ pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 1); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 3); - v83 = 1; - v732 = (int)v733 << 7; pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, amount, 0, 0); - LODWORD(v727) = v83; + LODWORD(v727) = 1; } goto play_sound_and_continue; case 21: + { if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[494], 2); // Can not cast Fly indoors! @@ -4695,18 +4739,20 @@ v207 = v3->uPlayerID + 1; v716 = v206; - v732 = (int)v733 << 7; - pParty->pPartyBuffs[PARTY_BUFF_FLY].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, amount, v206, v207); - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; + } case 22: + { //v67 = 2; if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[495], 2); // Can't cast Starburst indoors! pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; + v3->spellnum = 0; + goto LABEL_1166; } if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; @@ -4730,7 +4776,6 @@ v713 = pParty->vPosition.y + v214; v208 = LODWORD(v725); } - v726 = (Player *)v211; HIDWORD(v733) = 0; *(float *)&v732 = (double)v211; LODWORD(v725) = v211 + 2500; @@ -4742,24 +4787,23 @@ { v215 = rand(); v216 = (double)v721; - v727 = v216; v217 = (double)SHIDWORD(v733); *(float *)&uRequiredMana = v217; _this = (ItemGen *)(v215 % 1000); *((float *)&v733 + 1) = (double)(v215 % 1000) + *(float *)&v732 - *(float *)&y; *(float *)&v721 = v217 * v217; - *(float *)&v726 = v216 * v216; - if ( sqrt(*((float *)&v733 + 1) * *((float *)&v733 + 1) + *(float *)&v726 + *(float *)&v721) <= 1.0 ) + //*(float *)&v726 = v216 * v216; + if ( sqrt(*((float *)&v733 + 1) * *((float *)&v733 + 1) + v216 * v216 + *(float *)&v721) <= 1.0 ) { LODWORD(v685) = 0; HIDWORD(v685) = 0; } else { - v684 = (signed __int64)sqrt(*(float *)&v726 + *(float *)&v721); + v684 = (signed __int64)sqrt(v216 * v216 + *(float *)&v721); v685 = __PAIR__( stru_5C6E00->Atan2(v684, (signed __int64)*((float *)&v733 + 1)), - stru_5C6E00->Atan2((signed __int64)v727, (signed __int64)*(float *)&uRequiredMana)); + stru_5C6E00->Atan2((signed __int64)v216, (signed __int64)*(float *)&uRequiredMana)); } a1.stru_24.Reset(); a1.spell_id = v3->spellnum; @@ -4772,8 +4816,9 @@ a1.uSectorID = 0; a1.vPosition.z = (int)((char *)_this + LODWORD(v725)); a1.uSpriteFrameID = 0; - a1.spell_caster_pid = 8 * v3->uPlayerID | OBJECT_Player; + a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); a1.spell_target_pid = v730; + __debugbreak(); a1.field_60_distance_related_prolly_lod = stru_50C198._427546((int)&_this[69].uNumCharges); a1.uFacing = v685; a1.uSoundID = LOWORD(v3->sound_id); @@ -4792,7 +4837,10 @@ HIDWORD(v733) = (unsigned __int64)(v218 % 1024) - 512; } while ( !v14 ); - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; + } + case 23: v219 = v731 - 2; if ( v219 ) @@ -4871,21 +4919,17 @@ a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); a1.uFacing = LOWORD(v715.uYawAngle); a1.uSoundID = LOWORD(v3->sound_id); -LABEL_154: + if ( pParty->bTurnBasedModeOn == 1 ) LOBYTE(a1.uAttributes) |= 4u; -LABEL_156: - v669 = v3->uPlayerID + 1; - v36 = v715.uYawAngle; + v659 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed; - v654 = v715.uPitchAngle; -LABEL_157: - if ( a1.Create(v36, v654, v659, v669) != -1 && pParty->bTurnBasedModeOn == 1 ) + + if ( a1.Create(v715.uYawAngle, v715.uPitchAngle, v659, v3->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) ++pTurnEngine->field_1C; } else { - v732 = SHIDWORD(v733) / (amount - 1); a1.stru_24.Reset(); a1.spell_id = v3->spellnum; a1.spell_level = v2; @@ -4921,12 +4965,14 @@ v3->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) ++pTurnEngine->field_1C; - v227 += v732; + v227 += SHIDWORD(v733) / (amount - 1); } while ( v227 <= (signed int)y ); } } - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; + case 27: if ( !pPlayers[v3->uPlayerID + 1]->GetMaxMana() ) { @@ -4946,16 +4992,15 @@ pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 1); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 3); - v239 = v3->uPlayerID + 1; - v732 = v229 << 7; - pParty->pPartyBuffs[18].Apply( + + pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].Apply( pParty->uTimePlayed + (signed int)(signed __int64)((double)(v229 << 7) * 0.033333335), v731, amount, v716, - v239); + v3->uPlayerID + 1); if ( v731 == 4 ) - pParty->pPartyBuffs[18].uFlags = 1; + pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uFlags = 1; LODWORD(v727) = 1; goto play_sound_and_continue; @@ -4972,7 +5017,8 @@ ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; + v3->spellnum = 0; + goto LABEL_1166; } if ( v731 == 1 || v731 == 2 ) { @@ -5011,10 +5057,14 @@ ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2u); pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); v3->spellnum = 0; - goto LABEL_1165; + v2 = v723; + goto LABEL_1166; } *((int *)v243 + 5) |= 0x40u; - goto LABEL_1055; + dword_50C9A8 = 256; + LODWORD(v727) = 1; + goto play_sound_and_continue; + case 30: if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; @@ -5022,7 +5072,6 @@ HIDWORD(v733) = 10 * v2; v730 = 1; v244 = (char *)&pParty->pPlayers[v3->uPlayerID_2]; - v726 = &pParty->pPlayers[v3->uPlayerID_2]; if ( v731 == 1 ) { v245 = (int)&v244[36 * a2 + 532]; @@ -5080,7 +5129,10 @@ *(int *)(v245 + 8) = v256 + v254 % (v255 - v256 + 1); LABEL_612: _this->uItemID |= 0x20u; - goto LABEL_1055; + + dword_50C9A8 = 256; + LODWORD(v727) = 1; + goto play_sound_and_continue; } goto LABEL_615; } @@ -5107,7 +5159,8 @@ v317 = pGlobalTXT_LocalizationStrings[585]; ShowStatusBarString(v317, 2u); pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - v318 = v726; + __debugbreak(); // decompilation error; most probably v318 is the caster, filled in case 54 + //v318 = v726; v3->spellnum = 0; v318->PlaySound(SPEECH_43, 0); } @@ -5216,6 +5269,7 @@ } else { + __debugbreak(); // v726 is most probably the caster, filled in case 54 if ( v731 != 4 || (v245 = (int)&v726->pInventoryItems[a2], v246 = *(int *)v245, *(int *)v245 > 134) || v726->pInventoryItems[a2].uSpecEnchantmentType != 0 @@ -5343,7 +5397,8 @@ ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; + v3->spellnum = 0; + goto LABEL_1166; } v292 = *(char *)(LODWORD(v725) + 28); if ( !(v292 == 3 | v292 == 4 | v292 == 5 | v292 == 6 | v292 == 7 | v292 == 8 | v292 == 9 | v292 == 10 | v292 == 11) ) @@ -5357,7 +5412,8 @@ ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; + v3->spellnum = 0; + goto LABEL_1166; } if ( rand() % 100 >= 80 ) { @@ -5428,7 +5484,10 @@ + rand() % 10;//(pItemsTable->field_116D8[19] - pItemsTable->field_116D8[18] + 1); } v294->uAttributes |= 0x20u; - goto LABEL_1055; + dword_50C9A8 = 256; + LODWORD(v727) = 1; + goto play_sound_and_continue; + case SPELL_WATER_TOWN_PORTAL: amount = 10 * v2; if ( pPlayer->sMana < (signed int)uRequiredMana ) @@ -5437,18 +5496,21 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; + v3->spellnum = 0; + goto LABEL_1166; } town_portal_caster_id = LOBYTE(v3->uPlayerID); pMessageQueue_50CBD0->AddMessage(UIMSG_OnCastTownPortal, 0, 0); - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; case 33: LODWORD(v733) = 604800 * v2; if ( !_strcmpi(pCurrentMapName, "d05.blv") ) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; + v3->spellnum = 0; + goto LABEL_1166; } v319 = uRequiredMana; if ( pPlayer->sMana >= (signed int)uRequiredMana ) @@ -5487,13 +5549,22 @@ v323 = v3->uPlayerID_2; v324 = (char *)&pParty->pPlayers[v323].pConditions[15]; if ( !pParty->pPlayers[v323].pConditions[15] ) - goto LABEL_1056; + { + LODWORD(v727) = 1; + goto play_sound_and_continue; + } if ( v731 == 4 ) - goto LABEL_637; + { + *(int *)v324 = 0; + *((int *)v324 + 1) = 0; + LODWORD(v727) = 1; + goto play_sound_and_continue; + } v732 = amount << 7; v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335); v656 = 15; goto LABEL_640; + case 41: if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; @@ -5511,25 +5582,27 @@ pParty->vPosition.y, pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3); a1.uSpriteFrameID = 0; - v326 = 8 * v3->uPlayerID; - LOBYTE(v326) = v326 | OBJECT_Player; - a1.spell_caster_pid = v326; + a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); a1.spell_target_pid = a2; a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); a1.uFacing = LOWORD(pParty->sRotationY); a1.uSoundID = LOWORD(v3->sound_id); if ( pParty->bTurnBasedModeOn == 1 ) LOBYTE(a1.uAttributes) |= 4u; - v669 = v3->uPlayerID + 1; + v659 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed; - v654 = pParty->sRotationX; - goto LABEL_125; + if ( a1.Create(pParty->sRotationY, pParty->sRotationX, v659, v3->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) + ++pTurnEngine->field_1C; + LODWORD(v727) = 1; + goto play_sound_and_continue; + case 43: if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; + v3->spellnum = 0; + goto LABEL_1166; } if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; @@ -5552,14 +5625,12 @@ a1.uSoundID = LOWORD(v3->sound_id); if ( pParty->bTurnBasedModeOn == 1 ) a1.uAttributes = 4; - v669 = 0; + v659 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed; - v35 = (signed int)stru_5C6E00->uIntegerHalfPi / 2; -LABEL_124: - v654 = v35; -LABEL_125: - v36 = pParty->sRotationY; - goto LABEL_157; + if ( a1.Create(pParty->sRotationY, stru_5C6E00->uIntegerHalfPi / 2, v659, 0) != -1 && pParty->bTurnBasedModeOn == 1 ) + ++pTurnEngine->field_1C; + LODWORD(v727) = 1; + goto play_sound_and_continue; case SPELL_SPIRIT_DETECT_LIFE: v328 = v731 - 2; @@ -5582,13 +5653,9 @@ pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 1); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 3); - v83 = 1; - - v732 = (int)v733 << 7; pParty->pPartyBuffs[PARTY_BUFF_DETECT_LIFE].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, 0, 0, 0); - LODWORD(v727) = v83; - + LODWORD(v727) = 1; goto play_sound_and_continue; case SPELL_SPIRIT_FATE: @@ -5625,9 +5692,10 @@ pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2); pParty->pPlayers[v3->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_FATE].Apply(pParty->uTimePlayed + 1280, v731, amount, 0, 0); - goto LABEL_1056; - } - if ( (v342 & 7) == OBJECT_Actor) + LODWORD(v727) = 1; + goto play_sound_and_continue; + } + if (PID_TYPE(v342) == OBJECT_Actor) { v343 = v342 >> 3; HIDWORD(v344) = 0 + ((pParty->uTimePlayed + 1280) >> 32); @@ -5639,7 +5707,8 @@ LABEL_165: pGame->GetStru6()->_4A7E89_sparkles_on_actor_after_it_casts_buff(v661, v672); } - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; case 49: v348 = v731 - 2; @@ -5666,21 +5735,29 @@ goto play_sound_and_continue; v351 = &pParty->pPlayers[v3->uPlayerID_2]; if ( !v351->pConditions[0] ) - goto LABEL_1056; + { + LODWORD(v727) = 1; + goto play_sound_and_continue; + } if ( v731 == 4 ) { LODWORD(v351->pConditions[0]) = 0; HIDWORD(v351->pConditions[0]) = 0; - goto LABEL_904; - } - v732 = amount << 7; - v351->DiscardConditionIfLastsLongerThan( - 0, - (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335)); - if ( HIDWORD(pParty->pPlayers[v3->uPlayerID_2].pConditions[0]) | LODWORD(pParty->pPlayers[v3->uPlayerID_2].pConditions[0]) ) - goto LABEL_1056; - v674 = v3->uPlayerID_2; - goto LABEL_685; + } + else + { + v732 = amount << 7; + v351->DiscardConditionIfLastsLongerThan(0, (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335)); + if ( HIDWORD(pParty->pPlayers[v3->uPlayerID_2].pConditions[0]) | LODWORD(pParty->pPlayers[v3->uPlayerID_2].pConditions[0]) ) + { + LODWORD(v727) = 1; + goto play_sound_and_continue; + } + } + pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2); + LODWORD(v727) = 1; + goto play_sound_and_continue; + case SPELL_SPIRIT_PRESERVATION: v354 = v731 - 2; if ( v354 && (v355 = v354 - 1) != 0 && v355 == 1 ) @@ -5694,13 +5771,11 @@ { pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2); - v732 = (int)v733 << 7; - pParty->pPlayers[v3->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_PRESERVATION].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, 0, 0, 0); - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; } a2 = 0; - v732 = (int)v733 << 7; v717 = (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335); v357 = pParty->pPlayers;//[0].pPlayerBuffs[11]; do @@ -5711,8 +5786,11 @@ ++v357;// = (SpellBuff *)((char *)v357 + 6972); } while ( v357 <= &pParty->pPlayers[3] ); - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; + case 48: + { v364 = v731 - 2; if ( !v364 || (v365 = v364 - 1) != 0 && v365 != 1 ) v366 = 60 * (v2 + 3); @@ -5721,7 +5799,7 @@ LODWORD(v733) = v366; if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; - v726 = (Player *)sub_46A6AC((int)dword_50BF30, 100, 4096); + auto _v726 = sub_46A6AC((int)dword_50BF30, 100, 4096); pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xFFFFFFu, 0xC0u); ++a1.uType; a1.stru_24.Reset(); @@ -5736,26 +5814,26 @@ a1.uFacing = 0; a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); a1.uSoundID = LOWORD(v3->sound_id); - for ( a2 = 0; a2 < (signed int)v726; ++a2 ) + for ( a2 = 0; a2 < (signed int)_v726; ++a2 ) { v369 = &pActors[dword_50BF30[a2]]; if ( MonsterStats::BelongsToSupertype(v369->pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) ) { a1.vPosition.x = v369->vPosition.x; a1.vPosition.y = v369->vPosition.y; - v732 = v369->uActorHeight; - a1.vPosition.z = v369->vPosition.z - (unsigned int)(signed __int64)((double)v732 * unk_4D8548); - v370 = 8 * dword_50BF30[a2]; - LOBYTE(v370) = v370 | OBJECT_Actor; - a1.spell_target_pid = v370; + a1.vPosition.z = v369->vPosition.z - (unsigned int)(signed __int64)((double)v369->uActorHeight * unk_4D8548); + + a1.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]); a1.Create(0, 0, 0, 0); - v732 = (int)v733 << 7; v369->pActorBuffs[4].Apply( pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, 0, 0, 0); } } - goto LABEL_1056; + LODWORD(v727) = 1; + } + goto play_sound_and_continue; + case 53: v371 = v731 - 2; if ( v371 && (v372 = v371 - 1) != 0 && v372 == 1 ) @@ -5767,7 +5845,10 @@ pOtherOverlayList->_4418B1(5080, v3->uPlayerID_2 + 100, 0, 65536); v373 = v3->uPlayerID_2; if ( !(HIDWORD(pParty->pPlayers[v373].pConditions[14]) | LODWORD(pParty->pPlayers[v373].pConditions[14])) ) - goto LABEL_1056; + { + LODWORD(v727) = 1; + goto play_sound_and_continue; + } v14 = v731 == 4; pParty->pPlayers[v373].sHealth = 1; if ( v14 ) @@ -5781,7 +5862,6 @@ } else { - v732 = amount << 7; *(float *)&a2 = (double)(amount << 7) * 0.033333335; pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan( 0xEu, @@ -5827,17 +5907,15 @@ { do { - v385 = 4 * v682[HIDWORD(v733)] + 10965188; - pPlayers[v682[HIDWORD(v733)]]->sHealth = v732; - v726 = *(Player **)v385; - v386 = v726->GetMaxHealth(); - if ( v726->sHealth > v386 ) - *(int *)(*(int *)v385 + 6460) = v726->GetMaxHealth(); - v387 = *(Player **)v385; - if ( v387->sHealth > 0 ) + //v385 = (ItemGen **)&pPlayers[v682[HIDWORD(v733)]]; + v726 = pPlayers[v682[HIDWORD(v733)]]; + v726->sHealth = v732; + //v386 = v726->GetMaxHealth(); + if ( v726->sHealth > v726->GetMaxHealth()) + v726->sHealth = v726->GetMaxHealth(); + if ( v726->sHealth > 0 ) { - LODWORD(v387->pConditions[13]) = 0; - HIDWORD(v387->pConditions[13]) = 0; + v726->pConditions[Player::Condition_Unconcious] = 0; } v388 = HIDWORD(v733); @@ -5846,7 +5924,8 @@ } while ( v388 + 1 < v730 ); } - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; case 55: v392 = v731 - 1; @@ -5894,30 +5973,21 @@ } else { - v732 = amount << 7; *(float *)&a2 = (double)(amount << 7) * 0.033333335; - pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan( - 0x10u, + pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan( 0x10u, (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2)); - pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan( - 0xEu, + pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan( 0xEu, (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2)); - pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan( - 0xDu, + pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan( 0xDu, (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2)); } - v83 = 1; pParty->pPlayers[v3->uPlayerID_2].SetCondition(1u, 1); pParty->pPlayers[v3->uPlayerID_2].sHealth = 1; pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2); } - else - { - v83 = 1; - } - LODWORD(v727) = v83; + LODWORD(v727) = 1; goto play_sound_and_continue; case 61: @@ -5948,13 +6018,22 @@ v323 = v3->uPlayerID_2; v324 = (char *)&pParty->pPlayers[v323].pConditions[12]; if ( !pParty->pPlayers[v323].pConditions[12] ) - goto LABEL_1056; + { + LODWORD(v727) = 1; + goto play_sound_and_continue; + } if ( v731 == 4 ) - goto LABEL_637; - v732 = amount << 7; + { + *(int *)v324 = 0; + *((int *)v324 + 1) = 0; + LODWORD(v727) = 1; + goto play_sound_and_continue; + } v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335); v656 = 12; goto LABEL_640; + + case 56: v411 = v731 - 2; if ( v411 ) @@ -5987,19 +6066,30 @@ v323 = v3->uPlayerID_2; v324 = (char *)&pParty->pPlayers[v323].pConditions[3]; if ( !pParty->pPlayers[v323].pConditions[3] ) - goto LABEL_1056; + { + LODWORD(v727) = 1; + goto play_sound_and_continue; + } if ( v731 == 4 ) - goto LABEL_637; - v732 = amount << 7; + { + *(int *)v324 = 0; + *((int *)v324 + 1) = 0; + LODWORD(v727) = 1; + goto play_sound_and_continue; + } v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335); v656 = 3; goto LABEL_640; + case 59: if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; - if ( a2 == 0 || (a2 & 7) != OBJECT_Actor) - goto LABEL_1056; - v417 = (int)&pActors[a2 >> 3]; + if (PID_TYPE(a2) != OBJECT_Actor) + { + LODWORD(v727) = 1; + goto play_sound_and_continue; + } + v417 = (int)&pActors[PID_ID(a2)]; v730 = v417; if ( !(*(char *)(v417 + 38) & 0x80) ) { @@ -6088,15 +6178,17 @@ amount = v425; if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; - v426 = a2 >> 3; - if ( (a2 & 7) != OBJECT_Actor) - goto LABEL_1056; + v426 = PID_ID(a2); + if (PID_TYPE(a2) != OBJECT_Actor) + { + LODWORD(v727) = 1; + goto play_sound_and_continue; + } v730 = 836 * v426; if ( stru_50C198.GetMagicalResistance(&pActors[v426], 7u) ) { pActors[v426].pActorBuffs[1].Reset(); pActors[v426].pActorBuffs[12].Reset(); - v732 = amount << 7; pActors[v426].pActorBuffs[9].Apply( pParty->uTimePlayed + (signed __int64)((double)(amount << 7) * 0.033333335), v731, 0, 0, 0); @@ -6109,23 +6201,25 @@ v60 = pObjectList->ObjectIDByItemID(a1.uType); v61 = v426; goto LABEL_1086; + + case 66: if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; amount = 600 * v2; - v427 = a2 >> 3; - if ( (a2 & 7) != OBJECT_Actor) - goto LABEL_1056; - v730 = 836 * v427; - if ( MonsterStats::BelongsToSupertype(pActors[v427].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) ) - goto play_sound_and_continue; - if ( stru_50C198.GetMagicalResistance(&pActors[v427], 7u) ) - { - pActors[v427].pActorBuffs[9].Reset(); - pActors[v427].pActorBuffs[1].Reset(); - v732 = amount << 7; - pActors[v427].pActorBuffs[12].Apply( - pParty->uTimePlayed + (signed __int64)((double)(amount << 7) * 0.033333335), + if (PID_TYPE(a2) != OBJECT_Actor) + { + LODWORD(v727) = 1; + goto play_sound_and_continue; + } + v730 = 836 * PID_ID(a2); + if ( MonsterStats::BelongsToSupertype(pActors[PID_ID(a2)].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) ) + goto play_sound_and_continue; + if ( stru_50C198.GetMagicalResistance(&pActors[PID_ID(a2)], 7u) ) + { + pActors[PID_ID(a2)].pActorBuffs[9].Reset(); + pActors[PID_ID(a2)].pActorBuffs[1].Reset(); + pActors[PID_ID(a2)].pActorBuffs[12].Apply(pParty->uTimePlayed + (signed __int64)((double)(amount << 7) * 0.033333335), v731, 0, 0, 0); } a1.stru_24.Reset(); @@ -6133,9 +6227,11 @@ a1.spell_level = v2; a1.spell_skill = v731; v60 = pObjectList->ObjectIDByItemID(a1.uType); - v61 = v427; + v61 = PID_ID(a2); goto LABEL_1086; + case 63: + { v428 = v731 - 2; if ( v428 && (v429 = v428 - 1) != 0 && v429 == 1 ) v430 = 300 * v2; @@ -6144,7 +6240,7 @@ amount = v430; if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; - v726 = (Player *)sub_46A6AC((int)dword_50BF30, 100, 4096); + auto _v726 = sub_46A6AC((int)dword_50BF30, 100, 4096); pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xA0A0Au, 0xC0u); ++a1.uType; a1.stru_24.Reset(); @@ -6159,28 +6255,27 @@ a1.uFacing = 0; a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); a1.uSoundID = LOWORD(v3->sound_id); - for ( a2 = 0; a2 < (signed int)v726; ++a2 ) + for ( a2 = 0; a2 < (signed int)_v726; ++a2 ) { v433 = &pActors[dword_50BF30[a2]]; if ( MonsterStats::BelongsToSupertype(v433->pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) ) break; a1.vPosition.x = v433->vPosition.x; a1.vPosition.y = v433->vPosition.y; - v732 = v433->uActorHeight; - a1.vPosition.z = v433->vPosition.z - (unsigned int)(signed __int64)((double)v732 * unk_4D8548); - v434 = 8 * dword_50BF30[a2]; - LOBYTE(v434) = v434 | OBJECT_Actor; - a1.spell_target_pid = v434; + a1.vPosition.z = v433->vPosition.z - (unsigned int)(signed __int64)((double)v433->uActorHeight * unk_4D8548); + + a1.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]); a1.Create(0, 0, 0, 0); if ( stru_50C198.GetMagicalResistance(v433, 7u) ) { - v732 = amount << 7; - v433->pActorBuffs[4].Apply( - pParty->uTimePlayed + (signed __int64)((double)(amount << 7) * 0.033333335), + v433->pActorBuffs[4].Apply(pParty->uTimePlayed + (signed __int64)((double)(amount << 7) * 0.033333335), v731, 0, 0, 0); } } - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; + } + case 64: v435 = v731 - 2; if ( v435 && (v436 = v435 - 1) != 0 && v436 == 1 ) @@ -6204,16 +6299,16 @@ } else { - v732 = amount << 7; - pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan( - 5u, + pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan(5u, (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335)); } v377 = &pParty->pPlayers[v3->uPlayerID_2]; LABEL_720: v377->SetCondition(1, 0); } - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; + case 42: v442 = v731 - 2; if ( !v442 ) @@ -6234,8 +6329,8 @@ amount = v444; if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; - v445 = a2 >> 3; - if ( (a2 & 7) == OBJECT_Item) + v445 = PID_ID(a2); + if (PID_TYPE(a2) == OBJECT_Item) { v449 = (char *)&pSpriteObjects[v445].stru_24; v450 = *(int *)v449; @@ -6246,7 +6341,7 @@ } else { - sprintfex(pTmpBuf2, (char*)pGlobalTXT_LocalizationStrings[471], pItemsTable->pItems[v450].pUnidentifiedName); + sprintfex(pTmpBuf2, pGlobalTXT_LocalizationStrings[471], pItemsTable->pItems[v450].pUnidentifiedName); ShowStatusBarString(pTmpBuf2, 2u); if ( !pParty->AddItem(&pSpriteObjects[v445].stru_24) ) pParty->SetHoldingItem(&pSpriteObjects[v445].stru_24); @@ -6255,23 +6350,29 @@ } else { - if ( (a2 & 7) == OBJECT_Actor) + if (PID_TYPE(a2) == OBJECT_Actor) { stru_50C198.LootActor(&pActors[v445]); } else { - if ( (a2 & 7) != OBJECT_Decoration) + if (PID_TYPE(a2) != OBJECT_Decoration) { - if ( (a2 & 7) != OBJECT_BModel) - goto LABEL_1056; + if (PID_TYPE(a2) != OBJECT_BModel) + { + LODWORD(v727) = 1; + goto play_sound_and_continue; + } dword_507CD8 = 1; v677 = 1; if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) v446 = pIndoor->pFaceExtras[pIndoor->pFaces[v445].uFaceExtraID].uEventID; else v446 = pOutdoor->pBModels[a2 >> 9].pFaces[v445 & 0x3F].sCogTriggeredID; - goto LABEL_866; + + EventProcessor(v446, a2, v677); + LODWORD(v727) = 1; + goto play_sound_and_continue; } v447 = &pLevelDecorations[v445]; dword_507CD8 = 1; @@ -6280,9 +6381,9 @@ { v677 = 1; v446 = v448; -LABEL_866: EventProcessor(v446, a2, v677); - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; } if ( v447->IsInteractive() ) { @@ -6292,7 +6393,9 @@ } } } - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; + case 67: v451 = v731 - 2; if ( v451 ) @@ -6325,20 +6428,23 @@ v323 = v3->uPlayerID_2; v324 = (char *)&pParty->pPlayers[v323].pConditions[1]; if ( !pParty->pPlayers[v323].pConditions[1] ) - goto LABEL_1056; + { + LODWORD(v727) = 1; + goto play_sound_and_continue; + } if ( v731 == 4 ) { -LABEL_637: *(int *)v324 = 0; *((int *)v324 + 1) = 0; - goto LABEL_1056; - } - v732 = amount << 7; + LODWORD(v727) = 1; + goto play_sound_and_continue; + } v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335); v656 = 1; LABEL_640: v325 = &pParty->pPlayers[v323]; goto LABEL_641; + case 68: v457 = v731 - 2; if ( v457 ) @@ -6367,16 +6473,13 @@ if (!v460) { pParty->pPlayers[v3->uPlayerID_2].Heal(amount); -LABEL_904: - v674 = v3->uPlayerID_2; -LABEL_685: - pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v674); + pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2); } else { - if ( (v460 & 7) == OBJECT_Actor) + if (PID_TYPE(v460) == OBJECT_Actor) { - v461 = &pActors[v460 >> 3]; + v461 = &pActors[PID_ID(v460)]; v462 = v461->uAIState; v463 = v461->pMonsterInfo.uHP; if ( v462 != 5 ) @@ -6396,7 +6499,9 @@ } } } - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; + case 72: v464 = v731 - 2; if ( !v464 ) @@ -6426,7 +6531,10 @@ if ( !(HIDWORD(pParty->pPlayers[v470].pConditions[6]) | LODWORD(pParty->pPlayers[v470].pConditions[6])) && !(HIDWORD(pParty->pPlayers[v470].pConditions[8]) | LODWORD(pParty->pPlayers[v470].pConditions[8])) && !(HIDWORD(pParty->pPlayers[v470].pConditions[10]) | LODWORD(pParty->pPlayers[v470].pConditions[10])) ) - goto LABEL_1056; + { + LODWORD(v727) = 1; + goto play_sound_and_continue; + } if ( v731 == 4 ) { LODWORD(pParty->pPlayers[v470].pConditions[6]) = 0; @@ -6437,9 +6545,9 @@ v472 = v3->uPlayerID_2; LODWORD(pParty->pPlayers[v472].pConditions[10]) = 0; HIDWORD(pParty->pPlayers[v472].pConditions[10]) = 0; - goto LABEL_1056; - } - v732 = amount << 7; + LODWORD(v727) = 1; + goto play_sound_and_continue; + } *(float *)&a2 = (double)(amount << 7) * 0.033333335; pParty->pPlayers[v470].DiscardConditionIfLastsLongerThan( 6u, @@ -6463,10 +6571,9 @@ pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 3); - v732 = (int)v733 << 7; - pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, v2, 0, 0); - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; case 73: LODWORD(v733) = 3600 * v2; @@ -6486,15 +6593,15 @@ pParty->pPlayers[2].pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].Apply(pParty->uTimePlayed + v717, 4u, v2, v2, 0); pParty->pPlayers[3].pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].Apply(pParty->uTimePlayed + v717, 4, v2, v2, 0); - goto LABEL_1056; - //goto LABEL_104; + LODWORD(v727) = 1; + goto play_sound_and_continue; } pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2); - v732 = (int)v733 << 7; - pParty->pPlayers[v3->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, v2, v2, 0); - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; + case 74: v493 = v731 - 2; if ( v493 && (v494 = v493 - 1) != 0 && v494 == 1 ) @@ -6509,7 +6616,10 @@ if ( !(HIDWORD(pParty->pPlayers[v498].pConditions[7]) | LODWORD(pParty->pPlayers[v498].pConditions[7])) && !(HIDWORD(pParty->pPlayers[v498].pConditions[9]) | LODWORD(pParty->pPlayers[v498].pConditions[9])) && !(HIDWORD(pParty->pPlayers[v498].pConditions[11]) | LODWORD(pParty->pPlayers[v498].pConditions[11])) ) - goto LABEL_1056; + { + LODWORD(v727) = 1; + goto play_sound_and_continue; + } if ( v731 == 4 ) { LODWORD(pParty->pPlayers[v498].pConditions[7]) = 0; @@ -6523,7 +6633,6 @@ } else { - v732 = amount << 7; *(float *)&a2 = (double)(amount << 7) * 0.033333335; pParty->pPlayers[v498].DiscardConditionIfLastsLongerThan( 7u, @@ -6538,7 +6647,9 @@ LABEL_641: v325->DiscardConditionIfLastsLongerThan(v656, v663); } - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; + case 77: { amount = 5 * v2 + 10; @@ -6554,7 +6665,8 @@ ++v1; } while ( (signed int)v501 < (signed int)pParty->pHirelings ); - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; } case 80: sRecoveryTime -= v2; @@ -6565,9 +6677,9 @@ v505 = sub_46A6AC((int)dword_50BF30, 100, 4096); ++a1.uType; HIDWORD(v733) = v505; - v690 = 0; - v689 = 0; - v688 = 0; + v688.x = 0; + v688.y = 0; + v688.z = 0; a1.stru_24.Reset(); a1.spell_id = v3->spellnum; a1.spell_level = v2; @@ -6588,14 +6700,11 @@ v507 = dword_50BF30[a2]; a1.vPosition.x = pActors[v507].vPosition.x; a1.vPosition.y = pActors[v507].vPosition.y; - v732 = pActors[v507].uActorHeight; - a1.vPosition.z = pActors[v507].vPosition.z - (unsigned int)(signed __int64)((double)v732 * unk_4D8548); - v508 = 8 * dword_50BF30[a2]; - LOBYTE(v508) = v508 | OBJECT_Actor; - a1.spell_target_pid = v508; + a1.vPosition.z = pActors[v507].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v507].uActorHeight * unk_4D8548); + a1.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]); v509 = a1.Create(0, 0, 0, 0); v510 = a2; - DamageMonsterFromParty(8 * v509 | OBJECT_Item, dword_50BF30[a2], (Vec3_int_ *)&v688); + DamageMonsterFromParty(PID(OBJECT_Item, v509), dword_50BF30[a2], (Vec3_int_ *)&v688); a2 = v510 + 1; } while ( v510 + 1 < SHIDWORD(v733) ); @@ -6605,23 +6714,19 @@ v511 = &pActors[dword_50BF30[a2]]; a1.vPosition.x = v511->vPosition.x; a1.vPosition.y = v511->vPosition.y; - v732 = v511->uActorHeight; - a1.vPosition.z = v511->vPosition.z - (unsigned int)(signed __int64)((double)v732 * unk_4D8548); - v512 = 8 * dword_50BF30[a2]; - LOBYTE(v512) = v512 | OBJECT_Actor; - a1.spell_target_pid = v512; + a1.vPosition.z = v511->vPosition.z - (unsigned int)(signed __int64)((double)v511->uActorHeight * unk_4D8548); + a1.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]); a1.Create(0, 0, 0, 0); v513 = v511->pActorBuffs; - v726 = (Player *)22; - do + for (int _v726 = 22; _v726 != 0; --_v726) { v513->Reset(); ++v513; - v726 = (Player *)((char *)v726 - 1); } - while ( *(float *)&v726 != 0.0 ); - } - goto LABEL_1056; + } + LODWORD(v727) = 1; + goto play_sound_and_continue; + case 82: v514 = v731 - 2; if ( !v514 ) @@ -6647,32 +6752,34 @@ amount = 3; } v733 = __PAIR__(0, v516); - v517 = 8 * v3->uPlayerID; - LOBYTE(v517) = v517 | 4; + if ( (signed int)uNumActors > 0 ) { v518 = pActors;//[0].uAIState; - v726b = uNumActors; + auto _v726 = uNumActors; do { v519 = v518->uAIState; - if ( v518->uAIState != 5 && v519 != 11 && v519 != 19 && v517 == v518->uSummonerID ) + if ( v518->uAIState != 5 && v519 != 11 && v519 != 19 && PID(OBJECT_Player, v3->uPlayerID) == v518->uSummonerID ) ++HIDWORD(v733); ++v518; - --v726; + --_v726; } - while ( v726 != 0 ); + while ( _v726 != 0 ); } if ( SHIDWORD(v733) >= amount ) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[648], 2); // This character can't summon any more monsters! pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; + v3->spellnum = 0; + goto LABEL_1166; } if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; sub_44FA4C_spawn_light_elemental(v3->uPlayerID, v731, v733); - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; + case 83: v520 = v731 - 2; if ( !v520 ) @@ -6705,13 +6812,9 @@ pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 1); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 3); - v83 = 1; - - v732 = (int)v733 << 7; pParty->pPartyBuffs[PARTY_BUFF_DAY_OF_GODS].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, amount, 0, 0); - LODWORD(v727) = v83; - + LODWORD(v727) = 1; goto play_sound_and_continue; case 84: @@ -6720,16 +6823,16 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[497], 2); // Can't cast Prismatic Light outdoors! pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; + v3->spellnum = 0; + goto LABEL_1166; } if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; v531 = sub_46A6AC((int)dword_50BF30, 100, 4096); ++a1.uType; - v726 = (Player *)v531; - v696 = 0; - v695 = 0; - v694 = 0; + v694.x = 0; + v694.y = 0; + v694.z = 0; a1.stru_24.Reset(); a1.spell_id = v3->spellnum; a1.spell_level = v2; @@ -6743,30 +6846,29 @@ a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); a1.uSoundID = LOWORD(v3->sound_id); a2 = 0; - if ( (signed int)v726 > 0 ) + if ( (signed int)v531 > 0 ) { do { v533 = dword_50BF30[a2]; a1.vPosition.x = pActors[v533].vPosition.x; a1.vPosition.y = pActors[v533].vPosition.y; - v732 = pActors[v533].uActorHeight; - a1.vPosition.z = pActors[v533].vPosition.z - (unsigned int)(signed __int64)((double)v732 * unk_4D8548); - v534 = 8 * dword_50BF30[a2]; - LOBYTE(v534) = v534 | OBJECT_Actor; - a1.spell_target_pid = v534; + a1.vPosition.z = pActors[v533].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v533].uActorHeight * unk_4D8548); + a1.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]); v535 = a1.Create(0, 0, 0, 0); v536 = a2; - DamageMonsterFromParty(8 * v535 | OBJECT_Item, dword_50BF30[a2], (Vec3_int_ *)&v694); + DamageMonsterFromParty(PID(OBJECT_Item, v535), dword_50BF30[a2], &v694); a2 = v536 + 1; } - while ( v536 + 1 < (signed int)v726 ); + while ( v536 + 1 < (signed int)v531 ); } v537 = pGame->GetStru6(); pGame->GetStru6()->_4A8BFC(); - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; case SPELL_LIGHT_DAY_OF_PROTECTION: + { v538 = v731 - 2; if ( v538 && (v539 = v538 - 1) != 0 && v539 == 1 ) { @@ -6805,8 +6907,12 @@ v550, 0, 0); pParty->pPartyBuffs[PARTY_BUFF_WIZARD_EYE].Apply((signed __int64)((double)(signed __int64)pParty->uTimePlayed + *((float *)&v733 + 1)), v731, v550, 0, 0); - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; + } + case 86: + { v551 = v731 - 2; if ( !v551 ) goto LABEL_998; @@ -6834,7 +6940,7 @@ y = (char *)(60 * (v2 * HIDWORD(v733) + 60)); v732 = (300 * amount * v2 + 60) << 7; v730 = v2 + 5; - v726 = 0; + int _v726 = 0; v553 = pParty->pPlayers;//[0].pConditions[1]; *((float *)&v733 + 1) = (double)v732 * 0.033333335; do @@ -6847,7 +6953,7 @@ //((SpellBuff *)(v553 + 6056))->Apply( v553->pPlayerBuffs[4].Apply((signed __int64)((double)(signed __int64)pParty->uTimePlayed + *((float *)&v733 + 1)), v731, v730, 0, 0); if ( *(_QWORD *)v553 ) - v726 = (Player *)1; + _v726 = 1; ++v553; } while ( v553 <= &pParty->pPlayers[3] ); @@ -6855,18 +6961,23 @@ pParty->pPartyBuffs[PARTY_BUFF_HEROISM].Apply((signed __int64)((double)(signed __int64)pParty->uTimePlayed + *((float *)&v733 + 1)), v731, v730, 0, 0); pParty->pPartyBuffs[PARTY_BUFF_SHIELD].Apply((signed __int64)((double)(signed __int64)pParty->uTimePlayed + *((float *)&v733 + 1)), v562, 0, 0, 0); pParty->pPartyBuffs[PARTY_BUFF_STONE_SKIN].Apply((signed __int64)((double)(signed __int64)pParty->uTimePlayed + *((float *)&v733 + 1)), v562, v730, 0, 0); - if (v726) - goto LABEL_1056; - v732 = (int)y << 7; - pParty->pPartyBuffs[PARTY_BUFF_HASTE].Apply((signed __int64)((double)(signed int)((int)y << 7) * 0.033333335 + (double)(signed __int64)pParty->uTimePlayed), v562, v730, 0, 0); - goto LABEL_1056; + if (!_v726) + { + pParty->pPartyBuffs[PARTY_BUFF_HASTE].Apply((signed __int64)((double)(signed int)((int)y << 7) * 0.033333335 + (double)(signed __int64)pParty->uTimePlayed), v562, v730, 0, 0); + } + LODWORD(v727) = 1; + goto play_sound_and_continue; + } + + case 88: amount = 3; if ( pPlayer->uNumDivineInterventionCastsThisDay >= 3u ) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; + v3->spellnum = 0; + goto LABEL_1166; } if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; @@ -6901,7 +7012,9 @@ *(short *)v572 = pPlayer->sAgeModifier + 10; sRecoveryTime += -5 * v2; ++v571->uNumDivineInterventionCastsThisDay; - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; + case 89: v573 = v731 - 2; if ( v573 ) @@ -6941,12 +7054,13 @@ goto play_sound_and_continue; } v577 = (Player *)(v576 >> 3); - v726 = v577; + //v726 = v577; if ( v577 == (Player *)-1 ) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[496], 2); // No valid target exists! pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; + v3->spellnum = 0; + goto LABEL_1166; } v578 = (int)&pActors[(int)v577]; v721 = v578; @@ -6954,7 +7068,8 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; + v3->spellnum = 0; + goto LABEL_1166; } ++a1.uType; a1.stru_24.Reset(); @@ -6973,13 +7088,12 @@ a1.vPosition.x = *(short *)(v721 + 142); a1.vPosition.y = *(short *)(v721 + 144); v732 = *(short *)(v721 + 138); - v582 = 8 * (int)v726; a1.vPosition.z = *(short *)(v721 + 146) - (unsigned int)(signed __int64)((double)v732 * unk_4D8548); - a1.spell_target_pid = PID(OBJECT_Actor, (int)v726); + a1.spell_target_pid = PID(OBJECT_Actor, (int)v577); a1.Create(0, 0, 0, 0); if ( *(char *)(v581 + 52) > amount ) goto play_sound_and_continue; - Actor::Resurrect((unsigned int)v726); + Actor::Resurrect((unsigned int)v577); *(char *)(v581 + 61) = 0; *(char *)(v581 + 53) = 0; *(char *)(v581 + 54) = 0; @@ -6994,7 +7108,9 @@ ((SpellBuff *)(v581 + 404))->Reset(); if ( *(short *)(v581 + 40) > 10 * amount ) *(short *)(v581 + 40) = 10 * amount; - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; + case 91: v588 = v731 - 1; amount = 16; @@ -7009,6 +7125,7 @@ } if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; + __debugbreak(); HIDWORD(v733) = (int)(char *)&pParty + 6972 * v3->uPlayerID_2 + 36 * a2 + 3040; v732 = (signed int)&pItemsTable->pItems[*(int *)HIDWORD(v733)].pIconName; ((ItemGen *)HIDWORD(v733))->UpdateTempBonus(pParty->uTimePlayed); @@ -7025,7 +7142,8 @@ ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; + v3->spellnum = 0; + goto LABEL_1166; } v592 = HIDWORD(v733); v14 = v731 == 4; @@ -7033,13 +7151,16 @@ if ( !v14 ) { v732 = (int)v733 << 7; - *(_QWORD *)(v592 + 28) = pParty->uTimePlayed - + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335); + *(_QWORD *)(v592 + 28) = pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335); *(int *)(v592 + 20) |= 8u; } *(char *)(v592 + 20) |= 0x80u; - goto LABEL_1055; + dword_50C9A8 = 256; + LODWORD(v727) = 1; + goto play_sound_and_continue; + case 93: + { v593 = v731 - 2; if ( !v593 ) goto LABEL_1062; @@ -7058,8 +7179,7 @@ } if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; - v726 = (Player *)((signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360); - v732 = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360 / (amount - 1); + auto _v726 = ((signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360); a1.stru_24.Reset(); a1.spell_id = v3->spellnum; a1.spell_level = v2; @@ -7080,9 +7200,9 @@ a1.uSoundID = LOWORD(v3->sound_id); if ( pParty->bTurnBasedModeOn == 1 ) LOBYTE(a1.uAttributes) |= 4u; - v596 = (signed int)v726 / -2; - y = (char *)((signed int)v726 / 2); - if ( (signed int)v726 / -2 <= (signed int)v726 / 2 ) + v596 = (signed int)_v726 / -2; + y = (char *)((signed int)_v726 / 2); + if ( (signed int)_v726 / -2 <= (signed int)_v726 / 2 ) { v597 = v715.uYawAngle; do @@ -7095,11 +7215,14 @@ v3->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) ++pTurnEngine->field_1C; - v596 += v732; + v596 += _v726 / (amount - 1); } while ( v596 <= (signed int)y ); } - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; + } + case 94: if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; @@ -7118,30 +7241,31 @@ if ( v731 == 4 ) LODWORD(v733) = 29030400; LABEL_1082: - v599 = a2 >> 3; - if ( (a2 & 7) != OBJECT_Actor) - goto LABEL_1056; - v730 = 836 * v599; - if ( !MonsterStats::BelongsToSupertype(pActors[v599].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) ) - goto play_sound_and_continue; - if ( !stru_50C198.GetMagicalResistance(&pActors[v599], 0xAu) ) + if (PID_TYPE(a2) != OBJECT_Actor) + { + LODWORD(v727) = 1; + goto play_sound_and_continue; + } + v730 = 836 * PID_ID(a2); + if ( !MonsterStats::BelongsToSupertype(pActors[PID_ID(a2)].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) ) + goto play_sound_and_continue; + if ( !stru_50C198.GetMagicalResistance(&pActors[PID_ID(a2)], 0xAu) ) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; - } - pActors[v599].pActorBuffs[9].Reset(); - pActors[v599].pActorBuffs[1].Reset(); - v732 = (int)v733 << 7; - pActors[v599].pActorBuffs[12].Apply( - pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), + v3->spellnum = 0; + goto LABEL_1166; + } + pActors[PID_ID(a2)].pActorBuffs[9].Reset(); + pActors[PID_ID(a2)].pActorBuffs[1].Reset(); + pActors[PID_ID(a2)].pActorBuffs[12].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, 0, 0, 0); a1.stru_24.Reset(); a1.spell_id = v3->spellnum; a1.spell_level = v2; a1.spell_skill = v731; v60 = pObjectList->ObjectIDByItemID(a1.uType); - v61 = v599; + v61 = PID_ID(a2); LABEL_1086: v600 = pActors[v61].vPosition.y; v601 = pActors[v61].vPosition.x; @@ -7165,7 +7289,9 @@ LOBYTE(a1.uAttributes) |= 0x80u; a1.uSoundID = LOWORD(v3->sound_id); a1.Create(0, 0, 0, v3->uPlayerID + 1); - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; + case 96: if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; @@ -7211,7 +7337,8 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; + v3->spellnum = 0; + goto LABEL_1166; } v610 = 76 * v609; *((int *)&pParty->pPlayers[3].pInstalledBeacons[4].uBeaconTime + 19 * v609) = 0; @@ -7257,13 +7384,11 @@ { pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2); - v732 = (int)v733 << 7; - pParty->pPlayers[v3->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_PAIN_REFLECTION].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, v615, v716, 0); - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; } a2 = 0; - v732 = (int)v733 << 7; v717 = (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335); v619 = pParty->pPlayers;//[0].pPlayerBuffs[10]; do @@ -7274,17 +7399,19 @@ ++v619; } while ( v619 <= &pParty->pPlayers[3] ); - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; + case 99: + { if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; - v726 = 0; pGame->GetIndoorCamera(); v623 = (signed __int64)GetPickDepth(); HIDWORD(v733) = sub_46A6AC((int)dword_50BF30, 100, v623); - v709 = 0; - v708 = 0; - v707 = 0; + v707.x = 0; + v707.y = 0; + v707.z = 0; a1.stru_24.Reset(); a1.spell_id = v3->spellnum; a1.spell_level = v2; @@ -7298,22 +7425,21 @@ a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); a1.uSoundID = LOWORD(v3->sound_id); a2 = 0; + int _v726 = 0; if ( SHIDWORD(v733) > 0 ) { - v726 = (Player *)(HIDWORD(v733) * (7 * v2 + 25)); + _v726 = (HIDWORD(v733) * (7 * v2 + 25)); do { v625 = dword_50BF30[a2]; a1.vPosition.x = pActors[v625].vPosition.x; a1.vPosition.y = pActors[v625].vPosition.y; - v732 = pActors[v625].uActorHeight; - a1.vPosition.z = pActors[v625].vPosition.z - (unsigned int)(signed __int64)((double)v732 * unk_4D8548); - v626 = 8 * dword_50BF30[a2]; - LOBYTE(v626) = v626 | OBJECT_Actor; - a1.spell_target_pid = v626; + //v732 = pActors[v625].uActorHeight; + a1.vPosition.z = pActors[v625].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v625].uActorHeight * unk_4D8548); + a1.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]); v627 = a1.Create(0, 0, 0, 0); v628 = a2; - DamageMonsterFromParty(8 * v627 | 2, dword_50BF30[a2], (Vec3_int_ *)&v707); + DamageMonsterFromParty(PID(OBJECT_Item, v627), dword_50BF30[a2], &v707); a2 = v628 + 1; } while ( v628 + 1 < SHIDWORD(v733) ); @@ -7336,19 +7462,20 @@ ++v629; } while ( v629 <= 4 ); - v732 = (signed __int64)((double)(signed int)v726 / (double)v730); + v732 = (signed __int64)((double)(signed int)_v726 / (double)v730); HIDWORD(v733) = 0; if ( v730 > 0 ) { do { - v632 = 4 * v681[HIDWORD(v733)] + 10965188; - v633 = pPlayers[v681[HIDWORD(v733)]]; - v633->sHealth += v732; - v726 = *(Player **)v632; - v634 = v726->GetMaxHealth(); - if ( v726->sHealth > v634 ) - *(int *)(*(int *)v632 + 6460) = v726->GetMaxHealth(); + //v632 = 4 * v681[HIDWORD(v733)] + 10965188; + v726 = pPlayers[v681[HIDWORD(v733)]]; + //v633 = pPlayers[v681[HIDWORD(v733)]]; + v726->sHealth += v732; + //v726 = *(Player **)v632; + //v634 = v726->GetMaxHealth(); + if ( v726->sHealth > v726->GetMaxHealth()) + v726->sHealth = v726->GetMaxHealth(); v635 = HIDWORD(v733); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, WORD2(v733)); @@ -7357,13 +7484,18 @@ while ( v635 + 1 < v730 ); } pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0, 0x40u); - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; + } + case 98: + { if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[499], 2); // Can't cast Armageddon indoors! pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; + v3->spellnum = 0; + goto LABEL_1166; } v640 = v731 - 2; if ( !v640 || (v641 = v640 - 1) == 0 || (amount = 4, v641 != 1) ) @@ -7372,7 +7504,8 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; + v3->spellnum = 0; + goto LABEL_1166; } if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; @@ -7381,7 +7514,7 @@ ++pPlayer->uNumArmageddonCasts; if ( pParty->bTurnBasedModeOn == 1 ) ++pTurnEngine->field_1C; - v726 = (Player *)50; + auto _v726 = 50; do { v642 = rand() % 4096 - 2048; @@ -7391,10 +7524,13 @@ v732 = GetTerrainHeightsAroundParty2(v642 + pParty->vPosition.x, (int)y, (int *)&v710, 0); v644 = rand(); sub_42F7EB_DropItemAt(0xFE6u, v721, (int)y, v732 + 16, v644 % 500 + 500, 1, 0, 0, 0); - v726 = (Player *)((char *)v726 - 1); - } - while ( *(float *)&v726 != 0.0 ); - goto LABEL_1056; + --_v726; + } + while ( _v726 != 0 ); + LODWORD(v727) = 1; + goto play_sound_and_continue; + } + default: goto play_sound_and_continue; } @@ -7411,7 +7547,6 @@ } else { - v732 = amount << 7; v223 = ((Player *)v222)->DiscardConditionIfLastsLongerThan( 2u, pParty->uTimePlayed - (signed int)(signed __int64)((double)(amount << 7) * 0.033333335)); @@ -7423,7 +7558,10 @@ v222 += 6972; HIDWORD(v733) = (int)v222; if ( (signed int)v222 >= (signed int)pParty->pHirelings ) - goto LABEL_1056; + { + LODWORD(v727) = 1; + goto play_sound_and_continue; + } continue; } } @@ -7728,7 +7866,7 @@ a3.z = actor->vPosition.z - pParty->vPosition.z; Vec3_int_::Normalize(&a3.x, &a3.y, &a3.z); - DamageMonsterFromParty((8 * (uActiveCharacter - 1)) | OBJECT_Player, target_id, &a3); + DamageMonsterFromParty(PID(OBJECT_Player, uActiveCharacter - 1), target_id, &a3); if (player->WearsItem(ITEM_ARTIFACT_SPLITTER, 1) || player->WearsItem(ITEM_ARTIFACT_SPLITTER, 0)) _42FA66_do_explosive_impact( actor->vPosition.x, @@ -7856,9 +7994,9 @@ { v22 = *v28; v11 = *v28 & 0xFFFF; - if ( (*(char *)v28 & 7) == OBJECT_Actor) + if (PID_TYPE(v11) == OBJECT_Actor) { - v12 = &pActors[(unsigned int)v11 >> 3]; + v12 = &pActors[PID_ID(v11)]; v13 = v12->uAIState; if ( v13 != 5 ) { @@ -7866,7 +8004,7 @@ && v13 != 11 && v13 != 19 && v13 != 17 - && (!a3 || pActors[(unsigned int)v11 >> 3].GetActorsRelation(0)) ) + && (!a3 || pActors[PID_ID(v11)].GetActorsRelation(0)) ) { if ( (!a4 || MonsterStats::BelongsToSupertype(v12->pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD)) && v22 <= pick_depth << 16 ) @@ -8251,9 +8389,9 @@ int v7; // esi@1 char *v8; // ecx@2 unsigned __int16 v9; // ax@5 - int v10; // eax@10 + //int v10; // eax@10 signed int result; // eax@11 - __int16 v12; // ax@12 + //__int16 v12; // ax@12 //SpriteObject a1a; // [sp+Ch] [bp-74h]@1 int v14; // [sp+7Ch] [bp-4h]@1 @@ -8298,9 +8436,7 @@ a1a.uSoundID = 0; if ( a6 >= 1 || a6 <= 4 ) { - v10 = 8 * a6 - 8; - LOBYTE(v10) = v10 | OBJECT_Player; - a1a.spell_caster_pid = v10; + a1a.spell_caster_pid = PID(OBJECT_Player, a6 - 1); } else { @@ -8309,10 +8445,7 @@ result = a1a.Create(0, 0, 0, 0); if ( result != -1 ) { - v12 = 8 * result; - LOBYTE(v12) = v12 | 2; - result = stru_50FE08.Add( - v12, + result = stru_50FE08.Add(PID(OBJECT_Item, result), a5, SLOWORD(a1a.vPosition.x), SLOWORD(a1a.vPosition.y), @@ -8649,8 +8782,7 @@ { v24 = v6->GetAttackRecoveryTime(false); if ( !pParty->bTurnBasedModeOn ) - pPlayers[uActiveCharacter]->SetRecoveryTime( - (signed __int64)(flt_6BE3A4_debug_recmod1 * (double)v24 * 2.133333333333333)); + pPlayers[uActiveCharacter]->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * (double)v24 * 2.133333333333333)); pStru277->_427D48(uActiveCharacter); pTurnEngine->_40471C(); } @@ -8662,7 +8794,7 @@ { if (pParty->bTurnBasedModeOn) { - if ( pTurnEngine->field_4 == OBJECT_Actor || (pTurnEngine->pQueue[0].uPackedID & 7) == OBJECT_Player) + if (pTurnEngine->field_4 == OBJECT_Actor || PID_TYPE(pTurnEngine->pQueue[0].uPackedID) == OBJECT_Player) { pParty->bTurnBasedModeOn = 0; pTurnEngine->End(true);