# HG changeset patch # User Ritor1 # Date 1364397864 -21600 # Node ID 95d9727412c9293ded402b45aefd130ddda47c61 # Parent 3233927402e51abe24a3d8d618e46de909947366# Parent 9c3f28b31b4a096079486e527b73a3aafdf2d937 Слияние diff -r 3233927402e5 -r 95d9727412c9 Actor.cpp --- a/Actor.cpp Wed Mar 27 21:24:13 2013 +0600 +++ b/Actor.cpp Wed Mar 27 21:24:24 2013 +0600 @@ -21,6 +21,14 @@ #include "GUIWindow.h" #include "GUIFont.h" +#include "MM7.h" + + + + + + + Actor pActors[500]; int uNumActors; @@ -384,7 +392,7 @@ int v15; // eax@34 AIDirection *v16; // esi@34 unsigned __int16 v17; // di@34 - int v18; // eax@34 + //int v18; // eax@34 int v19; // edi@34 int v20; // eax@35 int v21; // eax@39 @@ -444,7 +452,7 @@ int v75; // eax@184 AIDirection *v76; // esi@184 unsigned __int16 v77; // di@184 - int v78; // eax@184 + //int v78; // eax@184 int v79; // edx@185 int v80; // eax@185 int v81; // eax@189 @@ -456,7 +464,7 @@ unsigned __int16 v87; // di@192 __int16 v88; // ax@192 signed int v89; // ecx@192 - int v90; // eax@192 + //int v90; // eax@192 signed int v91; // eax@200 int v92; // eax@201 int v93; // ecx@207 @@ -609,9 +617,7 @@ a1.uSoundID = 0; a1.uAttributes = 0; a1.uSectorID = pIndoor->GetSector(v13, v14, v15); - v18 = 8 * LODWORD(v120); - LOBYTE(v18) = 8 * LOBYTE(v120) | AI_OBJECT_ACTOR; - a1.spell_caster_pid = v18; + a1.spell_caster_pid = PID(OBJECT_Actor, LODWORD(v120)); a1.uSpriteFrameID = 0; a1.spell_target_pid = 0; a1.field_60_distance_related_prolly_lod = 3; @@ -693,10 +699,8 @@ v89 = v86->uDistance; a1.uSectorID = v88; LODWORD(v119) = v89; - v90 = 8 * LODWORD(v120); - LOBYTE(v90) = 8 * LOBYTE(v120) | OBJECT_Actor; a1.uSpriteFrameID = 0; - a1.spell_caster_pid = v90; + a1.spell_caster_pid = PID(OBJECT_Actor, LODWORD(v120)); a1.spell_target_pid = 0; a1.field_60_distance_related_prolly_lod = 3; if ( (double)v89 >= 307.2 ) @@ -1382,9 +1386,7 @@ a1.uSoundID = 0; a1.uAttributes = 0; a1.uSectorID = pIndoor->GetSector(v73, v74, v75); - v78 = 8 * LODWORD(v120); - LOBYTE(v78) = 8 * LOBYTE(v120) | OBJECT_Actor; - a1.spell_caster_pid = v78; + a1.spell_caster_pid = PID(OBJECT_Actor, LODWORD(v120)); a1.uSpriteFrameID = 0; a1.spell_target_pid = 0; a1.field_60_distance_related_prolly_lod = 3; @@ -1490,7 +1492,7 @@ unsigned __int16 v9; // ax@19 __int16 v10; // ax@19 signed int v11; // ecx@19 - int v12; // eax@19 + //int v12; // eax@19 int v13; // edx@28 //SpriteObject a1; // [sp+Ch] [bp-74h]@1 unsigned int v15; // [sp+7Ch] [bp-4h]@1 @@ -1580,10 +1582,8 @@ v10 = pIndoor->GetSector(a1.vPosition.x, a1.vPosition.y, a1.vPosition.z); v11 = v4->uDistance; a1.uSectorID = v10; - v12 = 8 * v15; - LOBYTE(v12) = 8 * v15 | AI_OBJECT_ACTOR; a1.uSpriteFrameID = 0; - a1.spell_caster_pid = v12; + a1.spell_caster_pid = PID(OBJECT_Actor, v15); a1.spell_target_pid = 0; if ( (double)v11 >= 307.2 ) { @@ -1645,7 +1645,7 @@ unsigned __int16 v4; // ax@5 int v5; // ebx@6 int v6; // ecx@6 - int v7; // eax@6 + //int v7; // eax@6 SpriteObject a1; // [sp+Ch] [bp-78h]@1 unsigned int v10; // [sp+7Ch] [bp-8h]@1 int v11; // [sp+80h] [bp-4h]@6 @@ -1686,10 +1686,8 @@ a1.uSoundID = 0; a1.uAttributes = 0; a1.uSectorID = pIndoor->GetSector(v5, a1.vPosition.y, v6); - v7 = 8 * v10; - LOBYTE(v7) = 8 * v10 | OBJECT_Actor; a1.uSpriteFrameID = 0; - a1.spell_caster_pid = v7; + a1.spell_caster_pid = PID(OBJECT_Actor, v10); a1.spell_target_pid = 0; a1.field_60_distance_related_prolly_lod = 3; a1.field_61 = 4; @@ -1983,7 +1981,7 @@ v9 = &pActors[v5]; if ( !a4 ) { - v10 = Actor::GetDirectionInfo(8 * v5 | AI_OBJECT_ACTOR, v4, &a3, 0); + v10 = Actor::GetDirectionInfo(PID(OBJECT_Actor, v5), v4, &a3, 0); v7 = &v13; memcpy(&v13, v10, sizeof(v13)); v8 = 0; @@ -2020,7 +2018,7 @@ AIDirection a3; if (!a4) - a4 = Actor::GetDirectionInfo(8 * uActorID | 3, object_to_face_pid, &a3, 0); + a4 = Actor::GetDirectionInfo(PID(OBJECT_Actor, uActorID), object_to_face_pid, &a3, 0); actor->uAIState = Standing; if (!uActionLength) @@ -2121,7 +2119,7 @@ v13 = 0; if ( !arg0 ) { - v14 = Actor::GetDirectionInfo(8 * v24 | OBJECT_Actor, a2, &a3, 0); + v14 = Actor::GetDirectionInfo(PID(OBJECT_Actor, v24), a2, &a3, 0); v12 = &v20; memcpy(&v20, v14, sizeof(v20)); v13 = 0; @@ -3173,7 +3171,7 @@ int v4; // eax@3 int v5; // eax@4 unsigned int v6; // eax@6 - signed int v7; // eax@12 + //signed int v7; // eax@12 signed int v8; // [sp-18h] [bp-1Ch]@10 signed int v9; // [sp-14h] [bp-18h]@10 int v10; // [sp-10h] [bp-14h]@10 @@ -3220,9 +3218,7 @@ v9 = 0; v8 = 0; } - v7 = 8 * uActorID; - LOBYTE(v7) = 8 * uActorID | OBJECT_Actor; - pAudioPlayer->PlaySound((SoundID)(signed __int16)v3, v7, 0, v8, v9, v10, v11, v12); + pAudioPlayer->PlaySound((SoundID)(signed __int16)v3, PID(OBJECT_Actor, uActorID), 0, v8, v9, v10, v11, v12); } } @@ -3628,7 +3624,7 @@ if ( v23 <= v11 && v27 <= v11 && v12 <= v11 - && sub_4070EF_prolly_collide_objects(8 * i | OBJECT_Actor, 8 * uActorID | OBJECT_Actor) + && sub_4070EF_prolly_collide_objects(PID(OBJECT_Actor, i), PID(OBJECT_Actor, uActorID)) && v23 * v23 + v27 * v27 + v19 * v19 < (unsigned int)v25 ) { v25 = v23 * v23 + v27 * v27 + v19 * v19; @@ -3645,7 +3641,7 @@ { //v13 = 8 * v21; //LOBYTE(v13) = 8 * v21 | OBJECT_Actor; - *a2 = 8 * v21 | OBJECT_Actor; + *a2 = PID(OBJECT_Actor, v21); } if (pParty->Invisible()) diff -r 3233927402e5 -r 95d9727412c9 Actor.h --- a/Actor.h Wed Mar 27 21:24:13 2013 +0600 +++ b/Actor.h Wed Mar 27 21:24:24 2013 +0600 @@ -68,15 +68,6 @@ -/* 337 */ -enum AI_OBJECT_TYPE -{ - AI_OBJECT_LAYING_ITEM = 0x2, - AI_OBJECT_ACTOR = 0x3, - AI_OBJECT_PARTY = 0x4, - AI_OBJECT_DECORATION = 0x5, -}; - /* 264 */ enum AIState : unsigned __int16 { diff -r 3233927402e5 -r 95d9727412c9 Game.cpp --- a/Game.cpp Wed Mar 27 21:24:13 2013 +0600 +++ b/Game.cpp Wed Mar 27 21:24:24 2013 +0600 @@ -204,7 +204,8 @@ if (uCurrentlyLoadedLevelType == LEVEL_Indoor) { - sprintf(pTmpBuf, "Party Sector ID: %u/%u\n", pBLVRenderParams->uPartySectorID, pIndoor->uNumSectors); + auto sector_id = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); + sprintf(pTmpBuf, "Party Sector ID: %u/%u\n", sector_id, pIndoor->uNumSectors); pPrimaryWindow->DrawText(pFontArrus, 16, 16, GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(255, 255, 255), pTmpBuf, 0, 0, 0xFFFFFFFF); } sprintf(pTmpBuf, "Party Position: % d % d % d", pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); @@ -213,7 +214,8 @@ if (uCurrentlyLoadedLevelType == LEVEL_Indoor) { uint uFaceID; - auto floor_level = BLV_GetFloorLevel(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z, pBLVRenderParams->uPartySectorID, &uFaceID); + auto sector_id = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); + auto floor_level = BLV_GetFloorLevel(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + 40, sector_id, &uFaceID); sprintf(pTmpBuf, "BLV_GetFloorLevel: %d face_id %d\n", floor_level, uFaceID); } else diff -r 3233927402e5 -r 95d9727412c9 Indoor.cpp --- a/Indoor.cpp Wed Mar 27 21:24:13 2013 +0600 +++ b/Indoor.cpp Wed Mar 27 21:24:24 2013 +0600 @@ -28,6 +28,7 @@ #include "GUIFont.h" #include "mm7_data.h" +#include "MM7.h" @@ -533,54 +534,45 @@ if (pDecalBuilder->uNumDecals > 0) pDecalBuilder->ApplyDecals(a4a, 1, &stru_F7B60C, uNumVerticesa, array_507D30, pVertices, 0, pFace->uSectorID); - if (pFace->Fluid() && - pFace->uBitmapID == pRenderer->hd_water_tile_id ) - { - v23 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; - v27 = pBitmaps_LOD->pHardwareTextures[v23]; - if (pFace->uAttributes & FACE_DO_NOT_LIGHT) - _479A53_draw_some_blv_poly(uNumVerticesa, uFaceID); - else - pRenderer->DrawIndoorPolygon(uNumVerticesa, pFace, v27, v28, 8 * uFaceID | OBJECT_BModel, v17, 0); - return; - } if (pFace->Fluid()) { - //auto v24 = GetTickCount() / 4; - //auto v25 = v24 - stru_5C6E00->uIntegerHalfPi; - uint eightSeconds = GetTickCount() % 8000; - float angle = (eightSeconds / 8000.0f) * 2 * 3.1415f; - - //animte lava back and forth - for (uint i = 0; i < uNumVerticesa; ++i) - //array_507D30[i].v += (double)(pBitmaps_LOD->pTextures[pFace->uBitmapID].uHeightMinus1 & (unsigned int)(stru_5C6E00->SinCos(v25) >> 8)); - array_507D30[i].v += pBitmaps_LOD->pTextures[pFace->uBitmapID].uHeightMinus1 * cosf(angle); - v23 = pFace->uBitmapID; - v27 = pBitmaps_LOD->pHardwareTextures[v23]; - if (pFace->uAttributes & FACE_DO_NOT_LIGHT) - _479A53_draw_some_blv_poly(uNumVerticesa, uFaceID); + if (pFace->uBitmapID == pRenderer->hd_water_tile_id) + { + v23 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; + v27 = pBitmaps_LOD->pHardwareTextures[v23]; + } else - pRenderer->DrawIndoorPolygon(uNumVerticesa, pFace, v27, v28, 8 * uFaceID | OBJECT_BModel, v17, 0); - return; + { + //auto v24 = GetTickCount() / 4; + //auto v25 = v24 - stru_5C6E00->uIntegerHalfPi; + uint eightSeconds = GetTickCount() % 8000; + float angle = (eightSeconds / 8000.0f) * 2 * 3.1415f; + + //animte lava back and forth + for (uint i = 0; i < uNumVerticesa; ++i) + //array_507D30[i].v += (double)(pBitmaps_LOD->pTextures[pFace->uBitmapID].uHeightMinus1 & (unsigned int)(stru_5C6E00->SinCos(v25) >> 8)); + array_507D30[i].v += pBitmaps_LOD->pTextures[pFace->uBitmapID].uHeightMinus1 * cosf(angle); + v23 = pFace->uBitmapID; + v27 = pBitmaps_LOD->pHardwareTextures[v23]; + } } else if (pFace->uAttributes & 0x4000) { v23 = pTextureFrameTable->GetFrameTexture(pFace->uBitmapID, pBLVRenderParams->field_0_timer_); v27 = pBitmaps_LOD->pHardwareTextures[v23]; - if (pFace->uAttributes & FACE_DO_NOT_LIGHT) - _479A53_draw_some_blv_poly(uNumVerticesa, uFaceID); - else - pRenderer->DrawIndoorPolygon(uNumVerticesa, pFace, v27, v28, 8 * uFaceID | OBJECT_BModel, v17, 0); - return; } - v17 = 0xFFFFFFFF; - v23 = pFace->uBitmapID; - v27 = pBitmaps_LOD->pHardwareTextures[v23]; + else + { + v17 = 0xFFD0D0D0; + v23 = pFace->uBitmapID; + v27 = pBitmaps_LOD->pHardwareTextures[v23]; + } + if (pFace->uAttributes & FACE_DO_NOT_LIGHT) _479A53_draw_some_blv_poly(uNumVerticesa, uFaceID); else - pRenderer->DrawIndoorPolygon(uNumVerticesa, pFace, v27, v28, 8 * uFaceID | OBJECT_BModel, v17, 0); - return;; + pRenderer->DrawIndoorPolygon(uNumVerticesa, pFace, v27, v28, PID(OBJECT_BModel, uFaceID), v17, 0); + return; } } } @@ -1291,6 +1283,7 @@ //v39 = &pIndoor->pFaces[uFaceID]; auto pFace = &pIndoor->pFaces[uFaceID]; + auto p = &nodes[node_id]; if (!pFace->Portal()) { @@ -1302,9 +1295,8 @@ return; } - auto p = &nodes[node_id]; - //v6 = (int)((char *)this + 2252 * a2); - //a0 = v6; + + if (p->uFaceID == uFaceID) return; if (!node_id && @@ -1316,8 +1308,8 @@ pBLVRenderParams->vPartyPos.z <= pFace->pBounding.z2 + 16 ) { if ( abs(pFace->pFacePlane_old.dist + pBLVRenderParams->vPartyPos.x * pFace->pFacePlane_old.vNormal.x - + pBLVRenderParams->vPartyPos.y * pFace->pFacePlane_old.vNormal.y - + pBLVRenderParams->vPartyPos.z * pFace->pFacePlane_old.vNormal.z) <= 589824 ) // we sure are standing at the portal plane + + pBLVRenderParams->vPartyPos.y * pFace->pFacePlane_old.vNormal.y + + pBLVRenderParams->vPartyPos.z * pFace->pFacePlane_old.vNormal.z) <= 589824 ) // we sure are standing at the portal plane { v7 = pFace->uSectorID; if ( nodes[0].uSectorID == v7 ) // draw back sector @@ -1328,11 +1320,11 @@ nodes[num_nodes].uViewportZ = pBLVRenderParams->uViewportZ; nodes[num_nodes].uViewportY = pBLVRenderParams->uViewportY; nodes[num_nodes].uViewportW = pBLVRenderParams->uViewportW; - nodes[num_nodes++].field_C._43F9E1(pBLVRenderParams->uViewportX, - pBLVRenderParams->uViewportY, - pBLVRenderParams->uViewportZ, - pBLVRenderParams->uViewportW); - AddBspNodeToRenderList(num_nodes - 1); + nodes[num_nodes].field_C._43F9E1(pBLVRenderParams->uViewportX, + pBLVRenderParams->uViewportY, + pBLVRenderParams->uViewportZ, + pBLVRenderParams->uViewportW); + AddBspNodeToRenderList(++num_nodes - 1); return; } //v5 = v39; @@ -1368,40 +1360,7 @@ if (face_max_screenspace_y < _50B9D8_screen_space_y[i]) face_max_screenspace_y = _50B9D8_screen_space_y[i]; } - //v10 = sub_423B5D(uFaceID); - //v34 = v10; - //if ( v10 ) - //{ - /* v11 = _50BAC8_screen_space_x[0]; - v12 = _50B9D8_screen_space_y[0]; - a2 = _50BAC8_screen_space_x[0]; - v13 = 1; - v37 = _50B9D8_screen_space_y[0]; - if ( v10 > 1 ) - { - do - { - v14 = _50BAC8_screen_space_x[v13]; - if ( v14 < a2 ) - a2 = _50BAC8_screen_space_x[v13]; - if ( v14 > v11 ) - v11 = v14; - v15 = _50B9D8_screen_space_y[v13]; - if ( v15 < v37 ) - v37 = _50B9D8_screen_space_y[v13]; - if ( v15 > v12 ) - v12 = _50B9D8_screen_space_y[v13]; - v10 = v34; - ++v13; - } - while ( v13 < v34 ); - } - //v16 = a0; - if (v11 >= p->uViewportX && - a2 <= p->uViewportZ && - v12 >= p->uViewportY && - v37 <= p->uViewportW && - sub_424829(v10, &nodes[num_nodes].field_C, &p->field_C, uFaceID))*/ + if (face_max_screenspace_x >= p->uViewportX && face_min_screenspace_x <= p->uViewportZ && face_max_screenspace_y >= p->uViewportY && diff -r 3233927402e5 -r 95d9727412c9 Items.h --- a/Items.h Wed Mar 27 21:24:13 2013 +0600 +++ b/Items.h Wed Mar 27 21:24:24 2013 +0600 @@ -74,10 +74,12 @@ ITEM_RILIC_TITANS_BELT = 524,//20C ITEM_RELIC_TWILIGHT = 525,//20D ITEM_RELIC_MEKORIGS_HAMMER = 0x210, + ITEM_ARTIFACT_HERMES_SANDALS = 529, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP = 530,//212 ITEM_ARTIFACT_MINDS_EYE = 532,//214 ITEM_ELVEN_CHAINMAIL = 533,//215 - ITEM_ARTIFAT_HEROS_BELT = 535,//217 + ITEM_ARTIFACT_HEROS_BELT = 535,//217 + ITEM_ARTIFACT_LADYS_ESCORT = 536, ITEM_RARE_SHADOWS_MASK = 544,//220 ITEM_RARE_SUN_CLOAK = 547,//223 ITEM_RARE_MOON_CLOAK = 548,//224 @@ -157,6 +159,8 @@ // 64 Double Damage vs. Undead. // 67 Adds 5 points of Body damage and +2 Disarm skill. // 68 Adds 6-8 points of Cold damage and +5 Armor Class. + // 71 Prevents drowning damage. + // 72 Prevents falling damage. int uNumCharges; unsigned int uAttributes; unsigned __int8 uBodyAnchor; diff -r 3233927402e5 -r 95d9727412c9 MM7.h --- a/MM7.h Wed Mar 27 21:24:13 2013 +0600 +++ b/MM7.h Wed Mar 27 21:24:24 2013 +0600 @@ -22,6 +22,8 @@ #define BYTE3(a) (*((unsigned char *)&a + 3)) #define PID(type, id) (unsigned int)((((8 * (id))) | (type)) & 0xFFFF) // packed id +#define PID_TYPE(pid) (unsigned int)((pid) & 7) // extract type +#define PID_ID(pid) (unsigned int)(((pid) & 0xFFFF) >> 3) // extract value typedef unsigned __int16 _WORD; diff -r 3233927402e5 -r 95d9727412c9 Outdoor.cpp --- a/Outdoor.cpp Wed Mar 27 21:24:13 2013 +0600 +++ b/Outdoor.cpp Wed Mar 27 21:24:24 2013 +0600 @@ -24,7 +24,7 @@ #include "Events.h" #include "mm7_data.h" -//#include "MM7.h" +#include "MM7.h" @@ -2949,8 +2949,8 @@ y = actor->vPosition.y; if (actor->uAIState == Summoned) { - if ((actor->uSummonerID & 7) != OBJECT_Actor || - pActors[actor->uSummonerID >> 3].pMonsterInfo.uSpecialAbilityDamageDiceSides != 1 ) + if (PID_TYPE(actor->uSummonerID) != OBJECT_Actor || + pActors[PID_ID(actor->uSummonerID)].pMonsterInfo.uSpecialAbilityDamageDiceSides != 1 ) { z += floorf(actor->uActorHeight * 0.5f + 0.5f); } @@ -3115,7 +3115,7 @@ HIWORD(v34) = HIWORD(X); LOWORD(v34) = 0; v28->dimming_level = 0; - v28->sZValue = v34 + (8 * i | OBJECT_Actor); + v28->sZValue = v34 + PID(OBJECT_Actor, i); v28->field_14_actor_id = i; v35 = pMonsterList->pMonsters; v36 = actor->pMonsterInfo.uID; diff -r 3233927402e5 -r 95d9727412c9 Party.cpp --- a/Party.cpp Wed Mar 27 21:24:13 2013 +0600 +++ b/Party.cpp Wed Mar 27 21:24:24 2013 +0600 @@ -15,6 +15,7 @@ #include "texts.h" #include "mm7_data.h" +#include "MM7.h" @@ -139,7 +140,7 @@ v12 = 0; if ( pParty->bTurnBasedModeOn == 1 ) { - if ( pTurnEngine->field_4 != 2 || (pTurnEngine->pQueue[0].uPackedID & 7) != OBJECT_Player) + if ( pTurnEngine->field_4 != 2 || PID_TYPE(pTurnEngine->pQueue[0].uPackedID) != OBJECT_Player) return 0; v2 = pTurnEngine->pQueue[0].uPackedID >> 3; return v2 + 1; diff -r 3233927402e5 -r 95d9727412c9 Party.h --- a/Party.h Wed Mar 27 21:24:13 2013 +0600 +++ b/Party.h Wed Mar 27 21:24:24 2013 +0600 @@ -211,8 +211,8 @@ int uFallSpeed; int field_6EC; int field_6F0; - int field_6F4_packedid; - int field_6F8; + int floor_face_pid; // face we are standing at + int walk_sound_timer; int field_6FC; int uFallStartY; unsigned int bFlying; diff -r 3233927402e5 -r 95d9727412c9 Player.cpp --- a/Player.cpp Wed Mar 27 21:24:13 2013 +0600 +++ b/Player.cpp Wed Mar 27 21:24:24 2013 +0600 @@ -25,6 +25,7 @@ #include "texts.h" #include "mm7_data.h" +#include "MM7.h" @@ -582,7 +583,7 @@ int v9; // eax@10 //unsigned int pVoiceID; // ecx@10 int v11; // esi@10 - signed int v12; // eax@11 + //signed int v12; // eax@11 signed int v13; // esi@12 int v14; // eax@12 //int v15; // eax@17 @@ -629,8 +630,7 @@ if (int _v1 = byte_4ECF08[v11 - 1][uVoiceID]) { pSoundId = rand() % _v1 + 2 * (v11 + 50 * uVoiceID) + 4998; - v12 = (8 * pPlayerNum + 312) | OBJECT_Player; - pAudioPlayer->PlaySound((SoundID)pSoundId, v12, 0, -1, 0, 0, pSoundVolumeLevels[uVoicesVolumeMultiplier] * 128.0f, 0); + pAudioPlayer->PlaySound((SoundID)pSoundId, PID(OBJECT_Player, pPlayerNum + 39), 0, -1, 0, 0, pSoundVolumeLevels[uVoicesVolumeMultiplier] * 128.0f, 0); } } } @@ -4549,7 +4549,7 @@ //----- (0048E96A) -------------------------------------------------------- void Player::SetRecoveryTime(signed int rec) { - assert(rec > 0); + assert(rec >= 0); if (rec > uTimeToRecovery) uTimeToRecovery = rec; diff -r 3233927402e5 -r 95d9727412c9 Player.h --- a/Player.h Wed Mar 27 21:24:13 2013 +0600 +++ b/Player.h Wed Mar 27 21:24:24 2013 +0600 @@ -401,7 +401,7 @@ // ? - CHARACTER_EXPRESSION_46 = 46, + CHARACTER_EXPRESSION_SCARED = 46, // like falling CHARACTER_EXPRESSION_54 = 54, CHARACTER_EXPRESSION_55 = 55, diff -r 3233927402e5 -r 95d9727412c9 SpriteObject.cpp --- a/SpriteObject.cpp Wed Mar 27 21:24:13 2013 +0600 +++ b/SpriteObject.cpp Wed Mar 27 21:24:24 2013 +0600 @@ -14,7 +14,16 @@ #include "LOD.h" #include "Actor.h" #include "Events.h" + #include "mm7_data.h" +#include "MM7.h" + + + + + + + size_t uNumSpriteObjects; SpriteObject pSpriteObjects[MAX_SPRITE_OBJECTS]; @@ -408,11 +417,11 @@ v58 = v16; v18 = WorldPosToGridCellX(v17); _46E26D_collide_against_sprites(v18, v58); - if ( (v1->spell_caster_pid & 7) != OBJECT_Player) + if (PID_TYPE(v1->spell_caster_pid) != OBJECT_Player) _46EF01_collision_chech_player(0); - if ( (v1->spell_caster_pid & 7) == OBJECT_Actor) + if (PID_TYPE(v1->spell_caster_pid) == OBJECT_Actor) { - v19 = v1->spell_caster_pid >> 3; + v19 = PID_ID(v1->spell_caster_pid); if ( v19 >= 0 ) { if ( v19 < (signed int)(uNumActors - 1) ) @@ -514,10 +523,10 @@ if ( !_46BFFA_check_object_intercept(uLayingItemID_, stru_721530.uFaceID) ) return; } - v30 = (signed int)stru_721530.uFaceID >> 3; - if ( (stru_721530.uFaceID & 7) == OBJECT_Decoration) + v30 = (signed int)PID_ID(stru_721530.uFaceID); + if (PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration) break; - if ( (stru_721530.uFaceID & 7) == OBJECT_BModel) + if (PID_TYPE(stru_721530.uFaceID) == OBJECT_BModel) { v31 = &pOutdoor->pBModels[(signed int)stru_721530.uFaceID >> 9]; v32 = &v31->pFaces[v30 & 0x3F]; @@ -698,11 +707,11 @@ { _46E44E_collide_against_faces_and_portals(0); _46E0B2_collide_against_decorations(); - if ( (pSpriteObject->spell_caster_pid & 7) != OBJECT_Player) + if (PID_TYPE(pSpriteObject->spell_caster_pid) != OBJECT_Player) _46EF01_collision_chech_player(1); v13 = pSpriteObject->spell_caster_pid; v42 = v8; - if ( (v13 & 7) == OBJECT_Actor) + if (PID_TYPE(v13) == OBJECT_Actor) { if ( (signed int)uNumActors > v8 ) { @@ -800,7 +809,7 @@ if ( pObject->uFlags & 0x40 && !_46BFFA_check_object_intercept(uLayingItemID, stru_721530.uFaceID) ) return; v15 = (signed int)stru_721530.uFaceID >> 3; - if ( (stru_721530.uFaceID & 7) == OBJECT_Decoration) + if (PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration) { v40 = integer_sqrt(pSpriteObject->vVelocity.x * pSpriteObject->vVelocity.x + pSpriteObject->vVelocity.y * pSpriteObject->vVelocity.y); v23 = stru_5C6E00->Atan2(pSpriteObject->vPosition.x - pLevelDecorations[v15].vPosition.x, @@ -817,9 +826,9 @@ } else { - if ( (stru_721530.uFaceID & 7) != OBJECT_BModel) + if (PID_TYPE(stru_721530.uFaceID) != OBJECT_BModel) goto LABEL_64; - stru_721530.field_84 = (signed int)stru_721530.uFaceID >> 3; + stru_721530.field_84 = (signed int)PID_ID(stru_721530.uFaceID); v16 = &pIndoor->pFaces[v15]; if ( v16->uPolygonType != 3 ) { diff -r 3233927402e5 -r 95d9727412c9 UICharacter.cpp --- a/UICharacter.cpp Wed Mar 27 21:24:13 2013 +0600 +++ b/UICharacter.cpp Wed Mar 27 21:24:24 2013 +0600 @@ -3392,8 +3392,7 @@ ptr_50C9A4 = 0; } v32 = (double)GetTickCount() * 0.1; - pRenderer->_4A63E6(0x24Au, 0x58u, (Texture *)(v28 != -1 ? (int)&pIcons_LOD->pTextures[v28] : 0), - v31, (signed __int64)v32, 0, 255); + pRenderer->_4A63E6(0x24Au, 0x58u, pIcons_LOD->GetTexture(v28), v31, (signed __int64)v32, 0, 255); } //----- (0043BCA7) -------------------------------------------------------- @@ -3553,7 +3552,7 @@ if (sub_43EE15_player_has_item(ITEM_ARTIFACT_MINDS_EYE, player, 1)) byte_5111F6[7] = 1; if (sub_43EE15_player_has_item(ITEM_RARE_SHADOWS_MASK, player, 1)) byte_5111F6[8] = 1; if (sub_43EE15_player_has_item(ITEM_RILIC_TITANS_BELT, player, 1)) byte_5111F6[9] = 1; - if (sub_43EE15_player_has_item(ITEM_ARTIFAT_HEROS_BELT, player, 1)) byte_5111F6[10] = 1; + if (sub_43EE15_player_has_item(ITEM_ARTIFACT_HEROS_BELT, player, 1)) byte_5111F6[10] = 1; if (sub_43EE15_player_has_item(ITEM_RELIC_TWILIGHT, player, 1)) byte_5111F6[11] = 1; if (sub_43EE15_player_has_item(ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, player, 1)) byte_5111F6[12] = 1; if (sub_43EE15_player_has_item(ITEM_RARE_SUN_CLOAK, player, 1)) byte_5111F6[13] = 1; diff -r 3233927402e5 -r 95d9727412c9 UIPopup.cpp --- a/UIPopup.cpp Wed Mar 27 21:24:13 2013 +0600 +++ b/UIPopup.cpp Wed Mar 27 21:24:24 2013 +0600 @@ -2120,9 +2120,9 @@ else v5 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]]; v6 = (unsigned __int16)v5; - if ( (v6 & 7) != OBJECT_Item) + if (PID_TYPE(v6) != OBJECT_Item) { - if ( (v6 & 7) == OBJECT_Actor) + if (PID_TYPE(v6) == OBJECT_Actor) { if ( pRenderer->uNumSceneBegins ) { diff -r 3233927402e5 -r 95d9727412c9 UiGame.cpp --- a/UiGame.cpp Wed Mar 27 21:24:13 2013 +0600 +++ b/UiGame.cpp Wed Mar 27 21:24:24 2013 +0600 @@ -585,8 +585,8 @@ v18 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]]; } pMouse->uPointingObjectID = (unsigned __int16)v18; - v19 = (signed int)(unsigned __int16)v18 >> 3; - if ( (v18 & 7) == OBJECT_Item ) + v19 = (signed)PID_ID(v18); + if (PID_TYPE(v18) == OBJECT_Item) { v30 = v19; if ( pObjectList->pObjects[pSpriteObjects[v30].uObjectDescID].uFlags & 0x10 ) @@ -630,9 +630,9 @@ } else { - if ( (v18 & 7) != OBJECT_Actor ) + if (PID_TYPE(v18) != OBJECT_Actor) { - if ( (v18 & 7) == OBJECT_Decoration ) + if (PID_TYPE(v18) == OBJECT_Decoration) { v23 = &pLevelDecorations[v19]; v24 = v23; @@ -686,7 +686,7 @@ uLastPointedObjectID = pMouse->uPointingObjectID; return; } - if ( (v18 & 7) == OBJECT_BModel) + if (PID_TYPE(v18) == OBJECT_BModel) { if ( v18 < (signed int)0x2000000u ) { @@ -1442,7 +1442,7 @@ { if ( pTurnEngine->field_4 != 1 ) { - if ( (pTurnEngine->pQueue[0].uPackedID & 7) == OBJECT_Player) + if (PID_TYPE(pTurnEngine->pQueue[0].uPackedID) == OBJECT_Player) { //v14 = 0; if ( pTurnEngine->uActorQueueSize > 0 ) @@ -1452,7 +1452,7 @@ { auto pElem = pTurnEngine->pQueue + i; - if ( (pElem->uPackedID & 7) != OBJECT_Player) + if (PID_TYPE(pElem->uPackedID) != OBJECT_Player) break; v16 = dword_5079D0; if ( pParty->uFlags & 0x10 ) diff -r 3233927402e5 -r 95d9727412c9 Vis.cpp --- a/Vis.cpp Wed Mar 27 21:24:13 2013 +0600 +++ b/Vis.cpp Wed Mar 27 21:24:24 2013 +0600 @@ -9,7 +9,7 @@ #include "Log.h" #include "mm7_data.h" -//#include "MM7.h" +#include "MM7.h" static Vis_SelectionList Vis_static_sub_4C1944_stru_F8BDE8; @@ -377,7 +377,7 @@ { pGame->pIndoorCameraD3D->ViewTransform(&intersection, 1u); int v13 = _48B561_mess_with_scaling_along_z(/*v12, */intersection.vWorldViewPosition.x); - v13 += (8 * (j | (i << 6)) | OBJECT_BModel); + v13 += PID(OBJECT_BModel, j | (i << 6)); list->AddObject(face, VisObjectType_Face, v13); } @@ -1802,7 +1802,7 @@ int result; // eax@1 signed int pFaceID; // esi@2 BLVFace *pFace; // edi@4 - unsigned int v7; // eax@6 + //unsigned int v7; // eax@6 Vis_ObjectInfo *v8; // eax@6 signed int i; // [sp+18h] [bp-8h]@1 @@ -1819,9 +1819,7 @@ { if ( is_part_of_selection(pFace, filter) ) { - v7 = 8 * pFaceID; - LOBYTE(v7) = 8 * pFaceID | OBJECT_BModel; - v8 = _4C1026(pFace, v7, pick_depth); + v8 = _4C1026(pFace, PID(OBJECT_BModel, pFaceID), pick_depth); if ( v8 ) list->AddObject(v8->object, v8->object_type, v8->sZValue); } @@ -1853,7 +1851,7 @@ BLVFace blv_face; blv_face.FromODM(face); - int pid = 8 * (j | (i << 6)) | OBJECT_BModel; + int pid = PID(OBJECT_BModel, j | (i << 6)); if (auto object_info = _4C1026(&blv_face, pid, pick_depth)) list->AddObject(object_info->object, object_info->object_type, object_info->sZValue); } diff -r 3233927402e5 -r 95d9727412c9 mm7_2.cpp --- a/mm7_2.cpp Wed Mar 27 21:24:13 2013 +0600 +++ b/mm7_2.cpp Wed Mar 27 21:24:24 2013 +0600 @@ -7776,7 +7776,7 @@ bUnderwater = 1; pGame->uFlags2 |= 8u; } - pParty->field_6F4_packedid = 0; + pParty->floor_face_pid = 0; if ( _strcmpi(Str1, "blv") ) PrepareToLoadODM(v9, 0); else diff -r 3233927402e5 -r 95d9727412c9 mm7_3.cpp --- a/mm7_3.cpp Wed Mar 27 21:24:13 2013 +0600 +++ b/mm7_3.cpp Wed Mar 27 21:24:24 2013 +0600 @@ -43,6 +43,8 @@ #include "stru298.h" #include "texts.h" #include "Log.h" + +#include "MM7.h" #include "mm7_data.h" //----- (0046E44E) -------------------------------------------------------- @@ -1479,7 +1481,7 @@ } //----- (0047272C) -------------------------------------------------------- -int _47272C_collide_agains_some_secotors_floors(int x, int y, int z, unsigned int *pSectorID, unsigned int *pFaceID) +int collide_against_floor_approximate(int x, int y, int z, unsigned int *pSectorID, unsigned int *pFaceID) { signed int v5; // ebx@1 int result; // eax@1 @@ -1519,15 +1521,15 @@ { int v1; // ebx@1 int v2; // edi@1 - int v6; // eax@18 - signed __int64 v8; // qax@27 - int v9; // eax@27 + //int v6; // eax@18 + //signed __int64 v8; // qax@27 + //int v9; // eax@27 double v10; // st7@27 unsigned int v12; // eax@49 double v13; // st7@50 - int v14; // eax@51 - signed __int64 v15; // qax@53 - double v16; // st7@54 + //int v14; // eax@51 + //signed __int64 v15; // qax@53 + //double v16; // st7@54 int v17; // eax@62 double v18; // st7@62 int v19; // ST40_4@62 @@ -1572,10 +1574,10 @@ unsigned int v64; // [sp-8h] [bp-68h]@161 int v65; // [sp-4h] [bp-64h]@75 int v66; // [sp-4h] [bp-64h]@161 - int v68; // [sp+10h] [bp-50h]@45 + //int v68; // [sp+10h] [bp-50h]@45 int v69; // [sp+10h] [bp-50h]@140 unsigned int uFaceEvent; // [sp+14h] [bp-4Ch]@1 - signed int v71; // [sp+18h] [bp-48h]@1 + //signed int v71; // [sp+18h] [bp-48h]@1 signed int v72; // [sp+1Ch] [bp-44h]@1 signed int v73; // [sp+20h] [bp-40h]@100 int v74; // [sp+20h] [bp-40h]@140 @@ -1604,29 +1606,24 @@ uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); v72 = 0; v78 = 0; - v71 = 0; bJumping = 0; uFaceID = -1; - v80 = collide_against_floor(new_party_x, new_party_y, party_z + 40, &uSectorID, &uFaceID); - assert(uFaceID != -1); - - for (uint i = 0; i < pIndoor->uNumFaces; ++i) - pIndoor->pFaces[i].uAttributes &= ~FACE_OUTLINED; - pIndoor->pFaces[uFaceID].uAttributes |= FACE_OUTLINED; + auto floor_level = collide_against_floor(new_party_x, new_party_y, party_z + 40, &uSectorID, &uFaceID); if ( pParty->bFlying ) { pParty->bFlying = false; if (pParty->FlyActive()) pOtherOverlayList->pOverlays[pParty->pPartyBuffs[PARTY_BUFF_FLY].uOverlayID - 1].field_E |= 1; - //stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[PARTY_BUFF_FLY].uOverlayID + 119] |= 1u;// 005E4D58 pOtherOverlayList [negindexing] - } - if ( v80 == -30000 ) - { - v80 = _47272C_collide_agains_some_secotors_floors(new_party_x, new_party_y, party_z + 40, &uSectorID, &uFaceID); - if ( v80 == -30000 ) - { + } + + if ( floor_level == -30000 || uFaceID == -1) + { + floor_level = collide_against_floor_approximate(new_party_x, new_party_y, party_z + 40, &uSectorID, &uFaceID); + if ( floor_level == -30000 || uFaceID == -1) + { + __debugbreak(); // level built with errors pParty->vPosition.x = blv_prev_party_x; pParty->vPosition.y = blv_prev_party_z; pParty->vPosition.z = blv_prev_party_y; @@ -1634,6 +1631,11 @@ return; } } + + for (uint i = 0; i < pIndoor->uNumFaces; ++i) + pIndoor->pFaces[i].uAttributes &= ~FACE_OUTLINED; + pIndoor->pFaces[uFaceID].uAttributes |= FACE_OUTLINED; + blv_prev_party_x = pParty->vPosition.x; blv_prev_party_z = pParty->vPosition.y; blv_prev_party_y = pParty->vPosition.z; @@ -1650,84 +1652,86 @@ } dword_720CDC = v67; } + + uint fall_start; if (!pParty->FeatherFallActive()) { bFeatherFall = false; - if (!pParty->pPlayers[0].WearsItem(536, 16) && - !pParty->pPlayers[1].WearsItem(536, 16) && - !pParty->pPlayers[2].WearsItem(536, 16) && - !pParty->pPlayers[3].WearsItem(536, 16)) - { - v6 = pParty->uFallStartY; - } - } - else - { - v6 = v80; + if (!pParty->pPlayers[0].WearsItem(ITEM_ARTIFACT_LADYS_ESCORT, 16) && // grants feather fall + !pParty->pPlayers[1].WearsItem(ITEM_ARTIFACT_LADYS_ESCORT, 16) && + !pParty->pPlayers[2].WearsItem(ITEM_ARTIFACT_LADYS_ESCORT, 16) && + !pParty->pPlayers[3].WearsItem(ITEM_ARTIFACT_LADYS_ESCORT, 16)) + { + fall_start = pParty->uFallStartY; + } + } + else + { + fall_start = floor_level; bFeatherFall = true; - pParty->uFallStartY = v80; - } -LABEL_20: - if ( v6 - party_z > 512 && !bFeatherFall && party_z <= v80 + 1 ) - { + pParty->uFallStartY = floor_level; + } + + + if (fall_start - party_z > 512 && !bFeatherFall && party_z <= floor_level + 1) + { + assert(~pParty->uFlags & PARTY_FLAGS_1_LANDING); // why land in indoor? if (pParty->uFlags & PARTY_FLAGS_1_LANDING) - { pParty->uFlags &= ~PARTY_FLAGS_1_LANDING; - } else for (uint i = 0; i < 4; ++i) { // receive falling damage - auto pPlayer = pParty->pPlayers + i; - - if (!pPlayer->HasEnchantedItemEquipped(72) && - !pPlayer->WearsItem(529, 8)) - { - v8 = (signed __int64)((double)pPlayer->GetMaxHealth() * 0.1); - pPlayer->ReceiveDamage((pParty->uFallStartY - party_z) * (signed int)v8 / 256, 4); - v9 = pPlayer->GetActualEndurance(); - v10 = (double)(20 - pPlayer->_48EA1B_get_static_effect(v9)) * flt_6BE3A4_debug_recmod1 * 2.133333333333333; - pPlayer->SetRecoveryTime((signed __int64)v10); - } - } - } - if ( party_z > v80 + 1 ) + auto player = pParty->pPlayers + i; + if (!player->HasEnchantedItemEquipped(72) && !player->WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, 8)) + { + player->ReceiveDamage((pParty->uFallStartY - party_z) * (0.1f * player->GetMaxHealth()) / 256, 4); + v10 = (double)(20 - player->_48EA1B_get_static_effect(player->GetActualEndurance())) * flt_6BE3A4_debug_recmod1 * 2.133333333333333; + player->SetRecoveryTime((signed __int64)v10); + } + } + } + + if ( party_z > floor_level + 1 ) bJumping = 1; - bFeatherFall = party_z - v80 <= 32; - if ( party_z - v80 <= 32 ) + + bool jumping_up = false; + + if ( party_z - floor_level <= 32 ) + { pParty->uFallStartY = party_z; - if ( bWalkSound && pParty->field_6F8 > 0 ) - pParty->field_6F8 -= pEventTimer->uTimeElapsed; - if ( party_z > v80 + 1 ) - { - if ( bJumping ) - goto LABEL_45; - goto LABEL_44; - } - party_z = v80 + 1; - pParty->uFallStartY = v80 + 1; - if ( bJumping ) - goto LABEL_45; - if (pParty->field_6F4_packedid != uFaceID) - { - auto pFace = &pIndoor->pFaces[uFaceID]; - if (pFace->uAttributes & 0x04000000 ) - { - uFaceEvent = pIndoor->pFaceExtras[pFace->uFaceExtraID].uEventID; - if ( bJumping ) - goto LABEL_45; - goto LABEL_44; - } - } -LABEL_44: - pParty->field_6F4_packedid = uFaceID; -LABEL_45: - v68 = uFaceID; - if ( pIndoor->pFaces[uFaceID].uAttributes & 0x10 ) - v71 = 1; + jumping_up = true; + } + + if (bWalkSound && pParty->walk_sound_timer) + { + if (pParty->walk_sound_timer > pEventTimer->uTimeElapsed) + pParty->walk_sound_timer -= pEventTimer->uTimeElapsed; + else pParty->walk_sound_timer = 0; + } + + + if (party_z <= floor_level + 1) + { + party_z = floor_level + 1; + pParty->uFallStartY = floor_level + 1; + + if (!bJumping && pParty->floor_face_pid != uFaceID) + { + auto pFace = &pIndoor->pFaces[uFaceID]; + if (pFace->uAttributes & FACE_PRESSURE_PLATE) + uFaceEvent = pIndoor->pFaceExtras[pFace->uFaceExtraID].uEventID; + } + } + if (!bJumping) + pParty->floor_face_pid = uFaceID; + + bool on_water = false; + if ( pIndoor->pFaces[uFaceID].Fluid()) + on_water = true; + v81 = pParty->uWalkSpeed; angle = pParty->sRotationY; _view_angle = pParty->sRotationX; - v82 = (unsigned __int64)(pEventTimer->dt_in_some_format - * (signed __int64)((signed int)(pParty->y_rotation_speed * stru_5C6E00->uIntegerPi) + v82 = (unsigned __int64)(pEventTimer->dt_in_some_format * (signed __int64)((signed int)(pParty->y_rotation_speed * stru_5C6E00->uIntegerPi) / 180)) >> 16; //LABEL_87: while ( pPartyActionQueue->uNumActions ) @@ -1735,43 +1739,32 @@ switch ( pPartyActionQueue->Next() ) { case PARTY_TurnLeft: - if ( uTurnSpeed ) - { - v14 = angle + uTurnSpeed; - angle = stru_5C6E00->uDoublePiMask & v14; - break; - } - v14 = angle + (unsigned __int64)(signed __int64)(double)v82 * fTurnSpeedMultiplier; - angle = stru_5C6E00->uDoublePiMask & v14; + if (uTurnSpeed) + angle = stru_5C6E00->uDoublePiMask & (angle + uTurnSpeed); + else + angle = stru_5C6E00->uDoublePiMask & (angle + (int)(v82 * fTurnSpeedMultiplier)); break; case PARTY_TurnRight: - if ( uTurnSpeed ) - { + if (uTurnSpeed) angle = stru_5C6E00->uDoublePiMask & (angle - uTurnSpeed); - break; - } - v16 = (double)v82 * fTurnSpeedMultiplier; - angle = stru_5C6E00->uDoublePiMask & (angle - (signed __int64)v16); + else + angle = stru_5C6E00->uDoublePiMask & (angle - (int)(v82 * fTurnSpeedMultiplier)); break; + case PARTY_FastTurnLeft: - if ( uTurnSpeed ) - { - v14 = angle + uTurnSpeed; - } + if (uTurnSpeed) + angle = stru_5C6E00->uDoublePiMask & (angle + uTurnSpeed); else - { - v14 = angle + (unsigned __int64)(signed __int64)(fTurnSpeedMultiplier + fTurnSpeedMultiplier) * (double)v82; - } - angle = stru_5C6E00->uDoublePiMask & v14; + angle = stru_5C6E00->uDoublePiMask & (angle + (int)(2.0f * fTurnSpeedMultiplier * (double)v82)); break; + case PARTY_FastTurnRight: - LODWORD(v15) = uTurnSpeed; - if ( !uTurnSpeed ) - { - v15 = (signed __int64)(fTurnSpeedMultiplier + fTurnSpeedMultiplier) * (double)v82; - } - angle = stru_5C6E00->uDoublePiMask & (angle - v15); + if (uTurnSpeed) + angle = stru_5C6E00->uDoublePiMask & (angle - uTurnSpeed); + else + angle = stru_5C6E00->uDoublePiMask & (angle - (int)(2.0f * fTurnSpeedMultiplier * (double)v82)); break; + case PARTY_StrafeLeft: v2 -= (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)((signed int)(signed __int64)((double)v81 * fWalkSpeedMultiplier) >> 1)) >> 16; v1 += (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)((signed int)(signed __int64)((double)v81 * fWalkSpeedMultiplier) >> 1)) >> 16; @@ -1783,8 +1776,8 @@ v78 = 1; break; case PARTY_WalkForward: - v2 += (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)(signed int)(signed __int64)((double)v81 * fWalkSpeedMultiplier)) >> 16; - v1 += (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)(signed int)(signed __int64)((double)v81 * fWalkSpeedMultiplier)) >> 16; + v2 += (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)(signed int)(signed __int64)(5 * (double)v81 * fWalkSpeedMultiplier)) >> 16; + v1 += (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)(signed int)(signed __int64)(5 * (double)v81 * fWalkSpeedMultiplier)) >> 16; v78 = 1; break; case PARTY_WalkBackward: @@ -1826,7 +1819,7 @@ _view_angle = 0; break; case PARTY_Jump: - if ( (!bJumping || party_z <= v80 + 6 && pParty->uFallSpeed <= 0) && pParty->field_24 ) + if ( (!bJumping || party_z <= floor_level + 6 && pParty->uFallSpeed <= 0) && pParty->field_24 ) { bJumping = 1; pParty->uFallSpeed = (signed __int64)((double)(pParty->field_24 << 6) * 1.5 + (double)pParty->uFallSpeed); @@ -1845,7 +1838,7 @@ } else { - if ( pIndoor->pFaces[v68].pFacePlane_old.vNormal.z < 32768 ) + if ( pIndoor->pFaces[uFaceID].pFacePlane_old.vNormal.z < 32768 ) { pParty->uFallSpeed -= pEventTimer->uTimeElapsed * GetGravityStrength(); goto LABEL_92; @@ -1861,8 +1854,8 @@ v41 = &pPlayers[1]; do { - if ( !(*v41)->HasEnchantedItemEquipped(72) && !(*v41)->WearsItem(529, 8) ) - (*v41)->PlayEmotion(CHARACTER_EXPRESSION_46, 0); + if ( !(*v41)->HasEnchantedItemEquipped(72) && !(*v41)->WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, 8) ) + (*v41)->PlayEmotion(CHARACTER_EXPRESSION_SCARED, 0); ++v41; } while ( (signed int)v41 <= (signed int)&pPlayers[4] ); @@ -1978,7 +1971,7 @@ v1 = 0; v2 = 0; } - if ( pParty->field_6F4_packedid != v43 >> 3 && BYTE3(v44->uAttributes) & 4 ) + if ( pParty->floor_face_pid != PID_ID(v43) && BYTE3(v44->uAttributes) & 4 ) uFaceEvent = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID; goto LABEL_152; } @@ -2010,7 +2003,7 @@ v87 += v52 * v74 >> 16; } v43 = stru_721530.uFaceID; - if ( pParty->field_6F4_packedid != v43 >> 3 && BYTE3(v44->uAttributes) & 4 ) + if ( pParty->floor_face_pid != PID_ID(v43) && BYTE3(v44->uAttributes) & 4 ) uFaceEvent = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID; goto LABEL_152; } @@ -2028,7 +2021,7 @@ if ( v2 * v2 + v1 * v1 >= 400 ) { v43 = stru_721530.uFaceID; - if ( pParty->field_6F4_packedid != v43 >> 3 && BYTE3(v44->uAttributes) & 4 ) + if ( pParty->floor_face_pid != PID_ID(v43) && BYTE3(v44->uAttributes) & 4 ) uFaceEvent = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID; goto LABEL_152; } @@ -2048,13 +2041,13 @@ break; } } - if ( bWalkSound && pParty->field_6F8 <= 0 ) + if ( bWalkSound && !pParty->walk_sound_timer) { if ( integer_sqrt((pParty->vPosition.x - new_party_x) * (pParty->vPosition.x - new_party_x) + (pParty->vPosition.y - new_party_y) * (pParty->vPosition.y - new_party_y) + (pParty->vPosition.z - new_party_z) * (pParty->vPosition.z - new_party_z)) <= 16 ) goto LABEL_188; - if ( v72 && (!bJumping || bFeatherFall) ) + if ( v72 && (!bJumping || jumping_up) ) { v66 = 0; v64 = 0; @@ -2063,7 +2056,7 @@ v60 = -1; v59 = 1; v58 = 804; - if ( !v71 ) + if ( !on_water ) { v56 = pAudioPlayer; if ( BYTE2(pIndoor->pFaces[uFaceID].uAttributes) & 0x20 ) @@ -2076,7 +2069,7 @@ v56 = pAudioPlayer; goto LABEL_175; } - if ( v78 && (!bJumping || bFeatherFall) ) + if ( v78 && (!bJumping || jumping_up) ) { v66 = 0; v64 = 0; @@ -2085,7 +2078,7 @@ v60 = -1; v59 = 1; v58 = 804; - if ( v71 ) + if ( on_water ) { v57 = (SoundID)102; v56 = pAudioPlayer; @@ -2103,10 +2096,10 @@ { LABEL_188: pAudioPlayer->_4AA258(804); - pParty->field_6F8 = 64; - } - } - if ( !bJumping || bFeatherFall ) + pParty->walk_sound_timer = 64; + } + } + if ( !bJumping || jumping_up ) pParty->uFlags &= ~PARTY_FLAGS_1_FALLING; else pParty->uFlags |= PARTY_FLAGS_1_FALLING; @@ -2349,15 +2342,19 @@ bJumping = 1; } v101 = pZ - v111 <= 32; - if ( bWalkSound && pParty->field_6F8 > 0 ) - pParty->field_6F8 -= pEventTimer->uTimeElapsed; + if ( bWalkSound && pParty->walk_sound_timer) + { + if (pParty->walk_sound_timer >= pEventTimer->uTimeElapsed) + pParty->walk_sound_timer -= pEventTimer->uTimeElapsed; + else pParty->walk_sound_timer = 0; + } if (!bUnderwater && SHIDWORD(pParty->pPartyBuffs[7].uExpireTime) <= 0 && (SHIDWORD(pParty->pPartyBuffs[7].uExpireTime) < 0 || LODWORD(pParty->pPartyBuffs[7].uExpireTime) <= 0) ) pParty->bFlying = false; if (!bJumping) { - if ( pParty->field_6F4_packedid != (8 * v108 | OBJECT_BModel) ) + if ( pParty->floor_face_pid != PID(OBJECT_BModel, v108) ) { if (v108) { @@ -2372,13 +2369,13 @@ }*/ if ( BYTE3(v7[v6].uAttributes) & 4 ) { - pParty->field_6F4_packedid = 8 * v108 | OBJECT_BModel; + pParty->floor_face_pid = PID(OBJECT_BModel, v108); v103 = v7[v6].sCogTriggeredID; } } } } - pParty->field_6F4_packedid = 8 * v108 | OBJECT_BModel; + pParty->floor_face_pid = PID(OBJECT_BModel, v108); } _walk_speed = pParty->uWalkSpeed; _angle_y = pParty->sRotationY; @@ -2953,9 +2950,9 @@ LABEL_220: v45 = stru_721530.uFaceID; LABEL_221: - if ( pParty->field_6F4_packedid != v45 && BYTE3(v47->uAttributes) & 4 ) - { - pParty->field_6F4_packedid = v45; + if ( pParty->floor_face_pid != v45 && BYTE3(v47->uAttributes) & 4 ) + { + pParty->floor_face_pid = v45; v103 = v47->sCogTriggeredID; } goto LABEL_234; @@ -2988,7 +2985,7 @@ v121 = (unsigned __int64)(58500i64 * v121) >> 16; } while ( v126 < 100 ); - if ( bWalkSound && pParty->field_6F8 <= 0 ) + if ( bWalkSound && pParty->walk_sound_timer <= 0 ) { v122 = abs(pParty->vPosition.x - pX); v126 = abs(pParty->vPosition.y - pY); @@ -2998,7 +2995,7 @@ if ( v114 && (!bJumping || v101) ) { if ( !v107 - && !(BYTE1(pOutdoor->pBModels[pParty->field_6F4_packedid >> 9].pFaces[(pParty->field_6F4_packedid >> 3) & 0x3F].uAttributes) & 0x20) ) + && !(BYTE1(pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].uAttributes) & 0x20) ) { v90 = -1; @@ -3021,7 +3018,7 @@ if ( v124 && (!bJumping || v101) ) { if ( v107 - || BYTE1(pOutdoor->pBModels[pParty->field_6F4_packedid >> 9].pFaces[(pParty->field_6F4_packedid >> 3) & 0x3F].uAttributes) & 0x20 ) + || BYTE1(pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].uAttributes) & 0x20 ) { v90 = -1; @@ -3041,7 +3038,7 @@ { LABEL_344: pAudioPlayer->_4AA258(804); - pParty->field_6F8 = 64; + pParty->walk_sound_timer = 64; } } if ( !bJumping || v101 ) @@ -3175,10 +3172,10 @@ } goto LABEL_318; } - if ( bWalkSound && pParty->field_6F8 <= 0 ) + if ( bWalkSound && pParty->walk_sound_timer <= 0 ) { pAudioPlayer->_4AA258(804); - pParty->field_6F8 = 64; + pParty->walk_sound_timer = 64; } LABEL_318: v81 = pZ; @@ -13603,7 +13600,7 @@ { v11 = uNumActors; SpawnEncounter((MapInfo *)&pMapStats->pInfos[v10], &v16, 0, count, 0); - memcpy(&v15, Actor::GetDirectionInfo(8 * v11 | AI_OBJECT_ACTOR, 4u, &a3, 1), sizeof(v15)); + memcpy(&v15, Actor::GetDirectionInfo(PID(OBJECT_Actor, v11), 4u, &a3, 1), sizeof(v15)); v12 = v11; if ( (signed int)v11 < (signed int)uNumActors ) { diff -r 3233927402e5 -r 95d9727412c9 mm7_4.cpp --- a/mm7_4.cpp Wed Mar 27 21:24:13 2013 +0600 +++ b/mm7_4.cpp Wed Mar 27 21:24:24 2013 +0600 @@ -236,12 +236,12 @@ signed int v28; // eax@45 int v29; // ebx@47 int v30; // edx@49 - int v31; // ST10_4@49 - signed int v32; // edx@49 + //int v31; // ST10_4@49 + //signed int v32; // edx@49 signed __int64 v33; // qtt@49 - signed int v34; // eax@54 - signed int v35; // esi@56 - int result; // eax@57 + //signed int v34; // eax@54 + //signed int v35; // esi@56 + //int result; // eax@57 int v38; // edx@62 //int v44; // [sp+20h] [bp-20h]@10 bool v47; // [sp+24h] [bp-1Ch]@43 @@ -343,6 +343,9 @@ if (portal->uPolygonType != POLYGON_Floor) continue; + if (!portal->uNumVertices) + continue; + if (x <= portal->pBounding.x2 && x >= portal->pBounding.x1 && y <= portal->pBounding.y2 && y >= portal->pBounding.y1 ) { @@ -356,45 +359,40 @@ word_721460_xs[2 * portal->uNumVertices] = word_721460_xs[0]; word_721390_ys[2 * portal->uNumVertices] = word_721390_ys[0]; v54 = 0; - v49 = word_721390_ys[0] >= y; - if ( portal->uNumVertices > 0 ) - { - for ( int i = 0; i < 2 * portal->uNumVertices; ++i ) + v47 = word_721390_ys[0] >= y; + + for (uint j = 0; j < 2 * portal->uNumVertices; ++j) { + v49 = v47; if ( v54 >= 2 ) break; - v47 = word_721390_ys[i + 1] >= y; + v47 = word_721390_ys[j + 1] >= y; if ( v49 != v47 ) { - v28 = word_721460_xs[i + 1] >= x ? 0 : 2; - v29 = v28 | word_721460_xs[i] < x; + v28 = word_721460_xs[j + 1] >= x ? 0 : 2; + v29 = v28 | (word_721460_xs[j] < x); if ( v29 != 3 ) { if ( !v29 ) ++v54; else { - //v30 = word_721390_ys[v27]; - v31 = word_721390_ys[i + 1] - word_721390_ys[i]; - v32 = y - word_721390_ys[i]; - LODWORD(v33) = v32 << 16; - HIDWORD(v33) = v32 >> 16; - if ((signed int)(((unsigned __int64)(((signed int)word_721460_xs[i + 1] - (signed int)word_721460_xs[i]) * v33 / v31) >> 16) + word_721460_xs[i]) >= x) + auto a_div_b = fixpoint_div(y - word_721390_ys[j], word_721390_ys[j + 1] - word_721390_ys[j]); + auto res = fixpoint_mul(word_721460_xs[j + 1] - word_721460_xs[j], a_div_b); + if (res + word_721460_xs[j] >= x) ++v54; } } } - v49 = v47; } if ( v54 == 1 ) { if ( v55 >= 50 ) break; - v34 = v55++; - blv_floor_level[v34] = -29000; - blv_floor_id[v34] = pSector->pPortals[i]; + blv_floor_level[v55] = -29000; + blv_floor_id[v55] = pSector->pPortals[i]; + v55++; } - } } } } @@ -407,9 +405,8 @@ return -30000; *pFaceID = blv_floor_id[0]; //result = blv_floor_level[0]; - if ( v55 > 1 ) - { - for ( v35 = 1; v35 < v55; ++v35 ) + + /*for ( v35 = 1; v35 < v55; ++v35 ) { if ( blv_floor_level[0] <= z + 5 ) { @@ -424,9 +421,29 @@ blv_floor_level[0] = blv_floor_level[v35]; *pFaceID = blv_floor_id[v35]; } - } - } - return blv_floor_level[0]; + }*/ + + + int result = blv_floor_level[0]; + for (uint i = 1; i < v55; ++i) + { + v38 = blv_floor_level[i]; + if ( result <= z + 5 ) + { + if ( v38 > result && v38 <= z + 5 ) + { + result = blv_floor_level[i]; + *pFaceID = blv_floor_id[i]; + } + } + else if ( v38 < result ) + { + result = blv_floor_level[i]; + *pFaceID = blv_floor_id[i]; + } + } + + return result; } //----- (0046D49E) -------------------------------------------------------- diff -r 3233927402e5 -r 95d9727412c9 mm7_5.cpp --- a/mm7_5.cpp Wed Mar 27 21:24:13 2013 +0600 +++ b/mm7_5.cpp Wed Mar 27 21:24:24 2013 +0600 @@ -5680,44 +5680,32 @@ //----- (0043A97E) -------------------------------------------------------- void __fastcall sub_43A97E(unsigned int uLayingItemID, signed int a2) { - unsigned int v2; // esi@1 - unsigned int v3; // ebx@1 - int v4; // edi@1 - int v5; // edx@1 - unsigned int v6; // [sp+10h] [bp-4h]@1 - - v6 = uLayingItemID; - v2 = uLayingItemID; - v3 = a2 >> 3; - v4 = pSpriteObjects[uLayingItemID].spell_caster_pid & 7; - v5 = (a2 & 7) - 3; - if ( v5 ) - { - if ( v5 == 1 ) - { - layingitem_vel_50FDFC.x = pSpriteObjects[v2].vVelocity.x; - layingitem_vel_50FDFC.y = pSpriteObjects[v2].vVelocity.y; - layingitem_vel_50FDFC.z = pSpriteObjects[v2].vVelocity.z; - Vec3_int_::Normalize(&layingitem_vel_50FDFC.x, &layingitem_vel_50FDFC.y, &layingitem_vel_50FDFC.z); - DamagePlayerFromMonster(8 * v6 | 2, pSpriteObjects[v2].field_61, &layingitem_vel_50FDFC, 0xFFFFFFFFu); - } - } - else - { - layingitem_vel_50FDFC.x = pSpriteObjects[v2].vVelocity.x; - layingitem_vel_50FDFC.y = pSpriteObjects[v2].vVelocity.y; - layingitem_vel_50FDFC.z = pSpriteObjects[v2].vVelocity.z; + if ( PID_TYPE(a2) == OBJECT_BLVDoor) + { + layingitem_vel_50FDFC.x = pSpriteObjects[uLayingItemID].vVelocity.x; + layingitem_vel_50FDFC.y = pSpriteObjects[uLayingItemID].vVelocity.y; + layingitem_vel_50FDFC.z = pSpriteObjects[uLayingItemID].vVelocity.z; + Vec3_int_::Normalize(&layingitem_vel_50FDFC.x, &layingitem_vel_50FDFC.y, &layingitem_vel_50FDFC.z); - switch ( v4 ) + DamagePlayerFromMonster(PID(OBJECT_Item, uLayingItemID), pSpriteObjects[uLayingItemID].field_61, &layingitem_vel_50FDFC, 0xFFFFFFFFu); + } + else if (PID_TYPE(a2) == OBJECT_Actor) + { + layingitem_vel_50FDFC.x = pSpriteObjects[uLayingItemID].vVelocity.x; + layingitem_vel_50FDFC.y = pSpriteObjects[uLayingItemID].vVelocity.y; + layingitem_vel_50FDFC.z = pSpriteObjects[uLayingItemID].vVelocity.z; + + Vec3_int_::Normalize(&layingitem_vel_50FDFC.x, &layingitem_vel_50FDFC.y, &layingitem_vel_50FDFC.z); + switch (PID_TYPE(pSpriteObjects[uLayingItemID].spell_caster_pid)) { case OBJECT_Actor: - sub_43B1B0(8 * v6 | AI_OBJECT_LAYING_ITEM, v3, &layingitem_vel_50FDFC, pSpriteObjects[v2].field_61); + sub_43B1B0(PID(OBJECT_Item, uLayingItemID), PID_ID(a2), &layingitem_vel_50FDFC, pSpriteObjects[uLayingItemID].field_61); break; case OBJECT_Player: - DamageMonsterFromParty(8 * v6 | AI_OBJECT_LAYING_ITEM, v3, &layingitem_vel_50FDFC); + DamageMonsterFromParty(PID(OBJECT_Item, uLayingItemID), PID_ID(a2), &layingitem_vel_50FDFC); break; case OBJECT_Item: - sub_43B057(8 * v6 | AI_OBJECT_LAYING_ITEM, v3, &layingitem_vel_50FDFC); + sub_43B057(PID(OBJECT_Item, uLayingItemID), PID_ID(a2), &layingitem_vel_50FDFC); break; } } @@ -6894,8 +6882,8 @@ _404544(); v2 = v1->pQueue; v3 = 0; - if ( (v1->pQueue[0].uPackedID & 7) == OBJECT_Player) - uActiveCharacter = (v1->pQueue[0].uPackedID >> 3) + 1; + if (PID_TYPE(v1->pQueue[0].uPackedID) == OBJECT_Player) + uActiveCharacter = PID_ID(v1->pQueue[0].uPackedID) + 1; else uActiveCharacter = 0; viewparams->bRedrawGameUI = 1; @@ -6913,9 +6901,9 @@ goto LABEL_27; do { - if ( (v2->uPackedID & 7) != OBJECT_Player) - { - v5 = &pActors[v2->uPackedID >> 3]; + if (PID_TYPE(v2->uPackedID) != OBJECT_Player) + { + v5 = &pActors[PID_ID(v2->uPackedID)]; LOWORD(v6) = v5->uAIState; if ( (short)v6 == 4 || (short)v6 == 8 @@ -6971,9 +6959,9 @@ v9 = v1->pQueue; do { - if ( (v9->uPackedID & 7) != OBJECT_Player) - { - v10 = v9->uPackedID >> 3; + if (PID_TYPE(v9->uPackedID) != OBJECT_Player) + { + v10 = PID_ID(v9->uPackedID); v11 = pActors[v10].uAIState; if ( v11 != 5 ) { @@ -7023,7 +7011,7 @@ v4 = v1->pQueue[0].field_4; if ( v4 ) { - if ( (v1->pQueue[0].uPackedID & 7) == OBJECT_Player) + if (PID_TYPE(v1->pQueue[0].uPackedID) == OBJECT_Player) { v5 = v1->uActorQueueSize; while ( 1 ) @@ -7122,8 +7110,8 @@ } v2->pQueue[a2].field_4 = v6; v2->_404544(); - if ( (v2->pQueue[0].uPackedID & 7) == OBJECT_Player) - uActiveCharacter = (v2->pQueue[0].uPackedID >> 3) + 1; + if (PID_TYPE(v2->pQueue[0].uPackedID) == OBJECT_Player) + uActiveCharacter = PID_ID(v2->pQueue[0].uPackedID) + 1; else uActiveCharacter = 0; result = (int)&v2->pQueue[0].field_4; @@ -7201,7 +7189,7 @@ v1 = this; LOWORD(v2) = _404544(); if ( v1->pQueue[0].field_4 <= 0 - || ((_4063A1(), v2 = v1->pQueue[0].uPackedID, (v1->pQueue[0].uPackedID & 7) != OBJECT_Player) ? (uActiveCharacter = 0) : (v2 = (v2 >> 3) + 1, uActiveCharacter = v2), + || ((_4063A1(), v2 = v1->pQueue[0].uPackedID, PID_TYPE(v1->pQueue[0].uPackedID) != OBJECT_Player) ? (uActiveCharacter = 0) : (v2 = (v2 >> 3) + 1, uActiveCharacter = v2), viewparams->bRedrawGameUI = 1, v1->pQueue[0].field_4 <= 0) ) { @@ -7269,13 +7257,13 @@ v1 = (TurnBased_QueueElem *)((char *)this + 16 * (a2 + 2)); v28 = v1; v3 = v1->uPackedID; - if ( (v1->uPackedID & 7) != OBJECT_Player) - { - v4 = v3 >> 3; // turn based only stuff - a2a = ai_near_actors_targets_pid[v3 >> 3]; - memcpy(&a3, Actor::GetDirectionInfo(v1->uPackedID, ai_near_actors_targets_pid[v3 >> 3], &a3, 0), sizeof(a3)); + if (PID_TYPE(v1->uPackedID) != OBJECT_Player) + { + v4 = PID_ID(v3); + a2a = ai_near_actors_targets_pid[PID_ID(v3)]; + memcpy(&a3, Actor::GetDirectionInfo(v1->uPackedID, ai_near_actors_targets_pid[PID_ID(v3)], &a3, 0), sizeof(a3)); memcpy(&a4, &a3, sizeof(a4)); - v5 = &pActors[v3 >> 3]; + v5 = &pActors[PID_ID(v3 >> 3)]; LOWORD(v3) = v5->uAIState; if ( (short)v3 != Dead ) { @@ -7433,11 +7421,8 @@ v9 = 0; v20 = 0; } - if ( (v22 & 7) == OBJECT_Actor) - v10 = (unsigned __int8)*(&byte_5C8D1A[89 - * (pMonsterStats->pInfos[pActors[v22 >> 3].pMonsterInfo.uID].uID - 1) - / 3] - + (v5->pMonsterInfo.uID - 1) / 3); + if (PID_TYPE(v22) == OBJECT_Actor) + v10 = (unsigned __int8)*(&byte_5C8D1A[89 * (pMonsterStats->pInfos[pActors[v22 >> 3].pMonsterInfo.uID].uID - 1) / 3] + (v5->pMonsterInfo.uID - 1) / 3); else v10 = 4; if ( v10 == 1 ) @@ -7566,9 +7551,9 @@ while ( 1 ) { v5 = v10->uPackedID; - if ( (v10->uPackedID & 7) == OBJECT_Actor) - { - v8 = ai_near_actors_targets_pid[v5 >> 3]; + if (PID_TYPE(v10->uPackedID) == OBJECT_Actor) + { + v8 = ai_near_actors_targets_pid[PID_ID(v5)]; memcpy(&v7, Actor::GetDirectionInfo(v5, v8, &a3, v2), sizeof(v7)); if ( !v1->_406D10(a2) ) Actor::AI_Stand(v10->uPackedID >> 3, v8, 0x20u, &v7); @@ -7605,9 +7590,9 @@ v2 = this->pQueue; do { - if ( (v2->uPackedID & 7) == OBJECT_Actor) - { - v3 = v2->uPackedID >> 3; + if (PID_TYPE(v2->uPackedID) == OBJECT_Actor) + { + v3 = PID_ID(v2->uPackedID); v8 = v3; if ( pActors[v3].CanAct() ) { @@ -7660,7 +7645,7 @@ { v4 = v14->uPackedID; a1 = v14->uPackedID; - if ( (a1 & 7) != OBJECT_Player) + if (PID_TYPE(a1) != OBJECT_Player) { v5 = v4 >> 3; v12 = v5; @@ -7743,10 +7728,11 @@ unsigned int uActorID; // [sp+50h] [bp-4h]@2 unsigned int a2a; // [sp+5Ch] [bp+8h]@7 + __debugbreak(); v2 = *(&this->field_0 + 4 * (a2 + 2)); - if ( (v2 & 7) == OBJECT_Player) + if (PID_TYPE(v2) == OBJECT_Player) return 0; - v3 = v2 >> 3; + v3 = PID_ID(v2); uActorID = v3; v4 = &pActors[v3]; v5 = v4->uAIState; @@ -7938,9 +7924,9 @@ v14 = this->pQueue; do { - if ( (v3->uPackedID & 7) != OBJECT_Player) - { - v4 = v3->uPackedID >> 3; + if (PID_TYPE(v3->uPackedID) != OBJECT_Player) + { + v4 = PID_ID(v3->uPackedID); uActorID = v4; v5 = &pActors[v4]; v6 = v5->uAIState; @@ -11620,9 +11606,9 @@ else v5 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]]; v6 = (unsigned __int16)v5; - if ( (v5 & 7) == OBJECT_Actor + if (PID_TYPE(v5) == OBJECT_Actor && uActiveCharacter - && v5 < 33554432 + && v5 < 0x2000000 && pPlayers[uActiveCharacter]->CanAct() && pPlayers[uActiveCharacter]->CanSteal() ) { @@ -11633,7 +11619,7 @@ *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; ++pMessageQueue_50CBD0->uNumMessages; }*/ - pMessageQueue_50CBD0->AddMessage(UIMSG_1B, v6 >> 3, 0); + pMessageQueue_50CBD0->AddMessage(UIMSG_1B, PID_ID(v6), 0); if ( pParty->bTurnBasedModeOn == 1 ) { diff -r 3233927402e5 -r 95d9727412c9 mm7_6.cpp --- a/mm7_6.cpp Wed Mar 27 21:24:13 2013 +0600 +++ b/mm7_6.cpp Wed Mar 27 21:24:24 2013 +0600 @@ -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 + 1), 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); diff -r 3233927402e5 -r 95d9727412c9 mm7_data.cpp --- a/mm7_data.cpp Wed Mar 27 21:24:13 2013 +0600 +++ b/mm7_data.cpp Wed Mar 27 21:24:24 2013 +0600 @@ -1402,7 +1402,7 @@ int ai_arrays_size; // weak int ai_near_actors_distances[500]; unsigned int ai_near_actors_ids[500]; -int dword_4F8580[182]; // weak +int dword_4F8580[121]; // weak int dword_4FA9B0[777]; // weak int dword_4FA9B4[777]; // weak char byte_4FAA00; // weak diff -r 3233927402e5 -r 95d9727412c9 mm7_data.h --- a/mm7_data.h Wed Mar 27 21:24:13 2013 +0600 +++ b/mm7_data.h Wed Mar 27 21:24:24 2013 +0600 @@ -1962,7 +1962,7 @@ void __cdecl UpdateActors_BLV(); void __cdecl UpdateActors_ODM(); void __cdecl UpdateObjects(); -int _47272C_collide_agains_some_secotors_floors(int x, int y, int z, unsigned int *pSectorID, unsigned int *pFaceID); // idb +int collide_against_floor_approximate(int x, int y, int z, unsigned int *pSectorID, unsigned int *pFaceID); // idb void __cdecl BLV_ProcessPartyActions(); void __cdecl ODM_ProcessPartyActions(); bool __fastcall sub_47531C(int a1, int *a2, int a3, int a4, int a5, int a6, int a7, int a8, BLVFace *a9, int a10); diff -r 3233927402e5 -r 95d9727412c9 stru6.cpp --- a/stru6.cpp Wed Mar 27 21:24:13 2013 +0600 +++ b/stru6.cpp Wed Mar 27 21:24:24 2013 +0600 @@ -17,6 +17,8 @@ #include "Overlays.h" #include "stru160.h" +#include "MM7.h" + @@ -831,8 +833,8 @@ if (pRenderer->pRenderD3D) { result = a2->spell_caster_pid & 7; - if ((a2->spell_caster_pid & 7) != OBJECT_Actor && - (a2->spell_caster_pid & 7) != OBJECT_Item) + if (PID_TYPE(a2->spell_caster_pid) != OBJECT_Actor && + PID_TYPE(a2->spell_caster_pid) != OBJECT_Item) { if (field_204 != 4) {