# HG changeset patch # User Ritor1 # Date 1374572505 -21600 # Node ID d071e0e9ba75c915157ae567ff213e603fc3c8c9 # Parent c0b273d33338e4cfe0223f436933de21f9dd6114 Explosion Traps fix diff -r c0b273d33338 -r d071e0e9ba75 AudioPlayer.cpp --- a/AudioPlayer.cpp Mon Jul 22 15:23:43 2013 +0600 +++ b/AudioPlayer.cpp Tue Jul 23 15:41:45 2013 +0600 @@ -847,12 +847,6 @@ } } } - - - - - - LABEL_123: for (uint i = 0; i < uMixerChannels; ++i) { @@ -862,12 +856,10 @@ { if (channel->uSourceTrackIdx == sound_id) return; // already playing the same sound from the same source - return - AIL_end_sample(channel->hSample); // requested new sound from the same source - end & switch FreeChannel(channel); } } - LABEL_133: v62 = start_channel; //pAudioPlayer4 = pAudioPlayer; @@ -1040,9 +1032,6 @@ return; } - - - __debugbreak(); // 3d sound stuff, refactor v12 = 13; if ( a3 < 0 ) @@ -1347,7 +1336,6 @@ { pRenderVertexSoft.vWorldPosition.x = (double)pParty->vPosition.x; v43 = (double)pParty->vPosition.y; -LABEL_100: pRenderVertexSoft.vWorldPosition.y = v43; v47 = (double)pParty->sEyelevel + (double)pParty->vPosition.z; goto LABEL_101; @@ -1361,7 +1349,9 @@ } pRenderVertexSoft.vWorldPosition.x = (double)PartyX; v43 = (double)PartyY; - goto LABEL_100; + pRenderVertexSoft.vWorldPosition.y = v43; + v47 = (double)pParty->sEyelevel + (double)pParty->vPosition.z; + goto LABEL_101; } } } diff -r c0b273d33338 -r d071e0e9ba75 Chest.cpp --- a/Chest.cpp Mon Jul 22 15:23:43 2013 +0600 +++ b/Chest.cpp Tue Jul 23 15:41:45 2013 +0600 @@ -43,215 +43,156 @@ //----- (0042041E) -------------------------------------------------------- bool Chest::Open( signed int uChestID ) { - //char *v1; // edi@5 - unsigned int v2; // eax@8 - GUIWindow *v3; // eax@15 - int v5; // edx@16 + unsigned int pMapID; // eax@8 + int pRandom; // edx@16 int v6; // eax@16 - ODMFace *v7; // eax@19 - int v8; // edx@19 - int v9; // edi@19 - signed int v10; // ebx@19 - int v11; // ecx@19 - int v12; // eax@19 - BLVFace *v13; // eax@20 - int v14; // ebx@21 - int v15; // edi@21 - int v16; // ecx@22 - __int64 v17; // qax@22 - double v18; // st7@23 - double v19; // st6@23 + ODMFace *pODMFace; // eax@19 + BLVFace *pBLVFace; // eax@20 + int pObjectX; // ebx@21 + int pObjectZ; // edi@21 + double dir_x; // st7@23 + double dir_y; // st6@23 double v20; // st7@23 - int v21; // ecx@26 - char v22[12]; // ST4C_12@28 - unsigned int *v23; // edi@28 - unsigned __int16 v24; // di@28 - signed int v25; // ecx@28 - char *v26; // edx@29 - unsigned __int16 v27; // ax@32 - //SpriteObject a1; // [sp+14h] [bp-B0h]@28 - int v29[4]; // [sp+84h] [bp-40h]@16 - //int v30; // [sp+88h] [bp-3Ch]@16 - //int v31; // [sp+8Ch] [bp-38h]@16 - //int v32; // [sp+90h] [bp-34h]@16 - float v33; // [sp+94h] [bp-30h]@23 - //char *v34; // [sp+98h] [bp-2Ch]@5 - int v35; // [sp+9Ch] [bp-28h]@16 + int pDepth; // ecx@26 + Vec3_int_ v; // ST4C_12@28 + bool flag_shout; // edi@28 + int pSpriteID[4]; // [sp+84h] [bp-40h]@16 Vec3_int_ pOut; // [sp+A0h] [bp-24h]@28 - int a4; // [sp+ACh] [bp-18h]@1 - int v38; // [sp+B0h] [bp-14h]@21 + int pObjectY; // [sp+B0h] [bp-14h]@21 int sRotX; // [sp+B4h] [bp-10h]@23 - float v40; // [sp+B8h] [bp-Ch]@23 - float v41; // [sp+BCh] [bp-8h]@23 + float dir_z; // [sp+BCh] [bp-8h]@23 int sRotY; // [sp+C0h] [bp-4h]@8 + SpriteObject pSpellObject; // [sp+14h] [bp-B0h]@28 - //a4 = uChestID; - assert(uChestID < 20); - if ((uChestID <0)&&(uChestID >=20) ) - return false; + assert( uChestID < 20 ); + if ( ( uChestID < 0 ) && ( uChestID >= 20 ) ) + return false; auto chest = &pChests[uChestID]; ++pIcons_LOD->uTexturePacksCount; if (!pIcons_LOD->uNumPrevLoadedFiles) pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; - - //v1 = (char *)&pChests[uChestID].uFlags; - //v34 = v1; if (!chest->Initialized()) Chest::PlaceItems(uChestID); if ( !uActiveCharacter ) - return 0; - *(float *)&sRotY = 0.0; - v2 = pMapStats->GetMapInfo(pCurrentMapName.data()); - if ( !chest->Trapped() || !v2 ) - goto LABEL_12; - if ( pPlayers[uActiveCharacter]->GetDisarmTrap() < 2 * pMapStats->pInfos[v2].LockX5 ) + return false; + flag_shout = false; + pMapID = pMapStats->GetMapInfo(pCurrentMapName.data()); + if ( chest->Trapped() && pMapID ) { - v29[0] = 811; - v29[1] = 812; - v29[2] = 813; - v29[3] = 814; - v5 = rand() % 4; - v6 = PID_ID(EvtTargetObj); - v35 = v5; - if ( PID_TYPE(EvtTargetObj) == OBJECT_Decoration) + if ( pPlayers[uActiveCharacter]->GetDisarmTrap() < 2 * pMapStats->pInfos[pMapID].LockX5 ) { - v16 = v6; - v14 = pLevelDecorations[v6].vPosition.x; - v38 = pLevelDecorations[v6].vPosition.y; - v17 = pDecorationList->pDecorations[pLevelDecorations[v6].uDecorationDescID].uDecorationHeight; - v15 = pLevelDecorations[v16].vPosition.z + (((signed int)v17 - HIDWORD(v17)) >> 1); - } - else - { - if ( PID_TYPE(EvtTargetObj) != OBJECT_BModel) - goto LABEL_12; - if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) + pSpriteID[0] = 811; + pSpriteID[1] = 812; + pSpriteID[2] = 813; + pSpriteID[3] = 814; + pRandom = rand() % 4; + v6 = PID_ID(EvtTargetObj); + if ( PID_TYPE(EvtTargetObj) == OBJECT_Decoration) + { + pObjectX = pLevelDecorations[v6].vPosition.x; + pObjectY = pLevelDecorations[v6].vPosition.y; + pObjectZ = pLevelDecorations[v6].vPosition.z + ( pDecorationList->pDecorations[pLevelDecorations[v6].uDecorationDescID].uDecorationHeight / 2 ); + } + if ( PID_TYPE(EvtTargetObj) == OBJECT_BModel) { - v7 = &pOutdoor->pBModels[EvtTargetObj >> 9].pFaces[(EvtTargetObj >> 3) & 0x3F]; - v8 = v7->pBoundingBox.y1; - v9 = v7->pBoundingBox.z2; - v10 = v7->pBoundingBox.x1 + v7->pBoundingBox.x2; - v11 = v7->pBoundingBox.y2; - v12 = v7->pBoundingBox.z1; + if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) + { + pODMFace = &pOutdoor->pBModels[EvtTargetObj >> 9].pFaces[(EvtTargetObj >> 3) & 0x3F]; + pObjectX = ( pODMFace->pBoundingBox.x1 + pODMFace->pBoundingBox.x2 ) / 2; + pObjectY = ( pODMFace->pBoundingBox.y1 + pODMFace->pBoundingBox.y2 ) / 2; + pObjectZ = ( pODMFace->pBoundingBox.z1 + pODMFace->pBoundingBox.z2 ) / 2; + } + else//Indoor + { + pBLVFace = &pIndoor->pFaces[v6]; + pObjectX = ( pBLVFace->pBounding.x1 + pBLVFace->pBounding.x2 ) / 2; + pObjectY = ( pBLVFace->pBounding.y1 + pBLVFace->pBounding.y2 ) / 2; + pObjectZ = ( pBLVFace->pBounding.z1 + pBLVFace->pBounding.z2 ) / 2; + } + } + dir_x = (double)pParty->vPosition.x - (double)pObjectX; + dir_y = (double)pParty->vPosition.y - (double)pObjectY; + dir_z = ( (double)pParty->sEyelevel + (double)pParty->vPosition.z ) - (double)pObjectZ; + v20 = sqrt( (dir_x * dir_x) + (dir_y * dir_y) + (dir_z * dir_z) ); + if ( v20 <= 1.0 ) + { + *(float *)&sRotX = 0.0; + *(float *)&sRotY = 0.0; } else { - v13 = &pIndoor->pFaces[v6]; - v8 = v13->pBounding.y1; - v9 = v13->pBounding.z2; - v10 = v13->pBounding.x1 + v13->pBounding.x2; - v11 = v13->pBounding.y2; - v12 = v13->pBounding.z1; + sRotY = (signed __int64)sqrt(dir_x * dir_x + dir_y * dir_y); + sRotX = stru_5C6E00->Atan2((signed __int64)dir_x, (signed __int64)dir_y); + sRotY = stru_5C6E00->Atan2(dir_y * dir_y, (signed __int64)dir_z); } - v14 = v10 >> 1; - v38 = (v8 + v11) >> 1; - v15 = (v12 + v9) >> 1; - } - v18 = (double)pParty->vPosition.x - (double)v14; - *(float *)&a4 = v18; - v19 = (double)pParty->vPosition.y - (double)v38; - v33 = v19; - v41 = (double)pParty->sEyelevel + (double)pParty->vPosition.z - (double)v15; - *(float *)&sRotY = v19 * v19; - *(float *)&sRotX = v18 * v18; - v20 = sqrt(v41 * v41 + *(float *)&sRotX + *(float *)&sRotY); - v40 = v20; - if ( v20 <= 1.0 ) - { - *(float *)&sRotX = 0.0; - *(float *)&sRotY = 0.0; - } - else - { - sRotY = (signed __int64)sqrt(*(float *)&sRotX + *(float *)&sRotY); - sRotX = stru_5C6E00->Atan2((signed __int64)*(float *)&a4, (signed __int64)v33); - sRotY = stru_5C6E00->Atan2(sRotY, (signed __int64)v41); - } - v21 = 256; - if ( v40 < 256.0 ) - v21 = (signed __int64)v40 / 4; - *(int *)&v22[8] = v15; - *(_QWORD *)v22 = __PAIR__(v38, v14); - Vec3_int_::Rotate(v21, sRotX, sRotY, *(Vec3_int_ *)v22, &pOut.x, &pOut.z, &pOut.y); - v23 = (unsigned int *)(&v29 + v35); - sub_42F7EB_DropItemAt(*v23, pOut.x, pOut.z, pOut.y, 0, 1, 0, 0x30u, 0); - - SpriteObject a1; // [sp+14h] [bp-B0h]@28 - //SpriteObject::SpriteObject(&a1); + pDepth = 256; + if ( v20 < 256.0 ) + pDepth = (signed __int64)v20 / 4; + v.x = pObjectX; + v.y = pObjectY; + v.z = pObjectZ; + Vec3_int_::Rotate(pDepth, sRotX, sRotY, v, &pOut.x, &pOut.z, &pOut.y); + sub_42F7EB_DropItemAt(pSpriteID[pRandom], pOut.x, pOut.z, pOut.y, 0, 1, 0, 48, 0); - a1.stru_24.Reset(); - v24 = *(short *)v23; - v25 = 0; - a1.spell_skill = 0; - a1.spell_level = 0; - a1.spell_id = 0; - a1.field_54 = 0; - a1.uType = v24; - if ( (signed int)pObjectList->uNumObjects <= 0 ) - { -LABEL_32: - v27 = 0; - } - else - { - v26 = (char *)&pObjectList->pObjects->uObjectID; - while ( v24 != *(short *)v26 ) + pSpellObject.stru_24.Reset(); + pSpellObject.spell_skill = 0; + pSpellObject.spell_level = 0; + pSpellObject.spell_id = 0; + pSpellObject.field_54 = 0; + pSpellObject.uType = pSpriteID[pRandom]; + pSpellObject.uObjectDescID = 0; + if ( pObjectList->uNumObjects ) { - ++v25; - v26 += 56; - if ( v25 >= (signed int)pObjectList->uNumObjects ) - goto LABEL_32; + for ( uint i = 0; i < (signed int)pObjectList->uNumObjects; ++i ) + { + if ( pSpriteID[pRandom] == pObjectList->pObjects[i].uObjectID ) + pSpellObject.uObjectDescID = i; + } } - v27 = v25; + pSpellObject.vPosition.y = pOut.z; + pSpellObject.vPosition.x = pOut.x; + pSpellObject.vPosition.z = pOut.y; + pSpellObject.uSoundID = 0; + pSpellObject.uAttributes = 48; + pSpellObject.uSectorID = pIndoor->GetSector(pOut.x, pOut.z, pOut.y); + pSpellObject.uSpriteFrameID = 0; + pSpellObject.spell_caster_pid = 0; + pSpellObject.spell_target_pid = 0; + pSpellObject.uFacing = 0; + pSpellObject.Create(0, 0, 0, 0); + pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0); + pSpellObject.ExplosionTraps(); + chest->uFlags &= 0xFEu; + if ( uActiveCharacter && !qword_A750D8 && !dword_507CD8 ) + { + qword_A750D8 = 256i64; + PlayerSpeechID = SPEECH_5; + word_A750E2 = uActiveCharacter; + } + pIcons_LOD->RemoveTexturesPackFromTextureList(); + dword_507CD8 = 0; + return false; } - a1.uObjectDescID = v27; - a1.vPosition.y = pOut.z; - a1.vPosition.x = pOut.x; - a1.vPosition.z = pOut.y; - a1.uSoundID = 0; - a1.uAttributes = 48; - a1.uSectorID = pIndoor->GetSector(pOut.x, pOut.z, pOut.y); - a1.uSpriteFrameID = 0; - a1.spell_caster_pid = 0; - a1.spell_target_pid = 0; - a1.uFacing = 0; - a1.Create(0, 0, 0, 0); - pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0); - a1._438E35(); - chest->SetInitialized(false);//*v34 &= 0xFEu; - if ( uActiveCharacter && !qword_A750D8 && !dword_507CD8 ) - { - qword_A750D8 = 256i64; - word_A750E0 = 5; - word_A750E2 = uActiveCharacter; - } - pIcons_LOD->RemoveTexturesPackFromTextureList(); - dword_507CD8 = 0; - return 0; + chest->uFlags &= 0xFEu; + flag_shout = true; } - chest->SetInitialized(false);//*v1 &= 0xFEu; - sRotY = 1; -LABEL_12: pAudioPlayer->StopChannels(-1, -1); pAudioPlayer->PlaySound(SOUND_OpenChest, 0, 0, -1, 0, 0, 0, 0); - if ( *(float *)&sRotY != 0.0 ) + if ( flag_shout == true ) { if ( !dword_507CD8 ) pPlayers[uActiveCharacter]->PlaySound(SPEECH_4, 0); } dword_507CD8 = 0; - pChestWindow = pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_Chest, uChestID, 0); - - pBtn_ExitCancel = pChestWindow->CreateButton(471, 445, 169, 35, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[79], pIcons_LOD->GetTexture(uExitCancelTextureId), 0);// Exit - pChestWindow->CreateButton( 7, 8, 460, 343, 1, 0, UIMSG_CHEST_ClickItem, 0, 0, "", 0); - + pBtn_ExitCancel = pChestWindow->CreateButton(471, 445, 169, 35, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[79], pIcons_LOD->GetTexture(uExitCancelTextureId), 0);// Exit + pChestWindow->CreateButton( 7, 8, 460, 343, 1, 0, UIMSG_CHEST_ClickItem, 0, 0, "", 0); pCurrentScreen = SCREEN_CHEST; pEventTimer->Pause(); - return 1; + return true; } //----- (0042092D) -------------------------------------------------------- diff -r c0b273d33338 -r d071e0e9ba75 Indoor.cpp --- a/Indoor.cpp Mon Jul 22 15:23:43 2013 +0600 +++ b/Indoor.cpp Tue Jul 23 15:41:45 2013 +0600 @@ -4011,7 +4011,7 @@ if ( pDest ) { qword_A750D8 = 256i64; - word_A750E0 = 46; + PlayerSpeechID = SPEECH_46; word_A750E2 = LOWORD(v34[rand() % v30]); } } diff -r c0b273d33338 -r d071e0e9ba75 Player.cpp --- a/Player.cpp Mon Jul 22 15:23:43 2013 +0600 +++ b/Player.cpp Tue Jul 23 15:41:45 2013 +0600 @@ -529,35 +529,22 @@ { signed int speechCount = 0; // esi@4 signed int expressionCount = 0; // esi@4 - unsigned __int8 v8; // al@6 int pickedVariant; // esi@10 - int v14; // eax@12 CHARACTER_EXPRESSION_ID expression; // ebx@17 - signed int v17; // ecx@19 - unsigned int pSoundID; // edi@20 + signed int pSoundID; // ecx@19 int speechVariantArray[5]; // [sp+Ch] [bp-1Ch]@7 int expressionVariantArray[5]; - int pPlayerNum; // [sp+24h] [bp-4h]@1 unsigned int pickedSoundID; // [sp+30h] [bp+8h]@4 unsigned int expressionDuration = 0; - pPlayerNum = 1; - for (int i = 0; i < 4; ++i) - if (&pParty->pPlayers[i] == this) - { - pPlayerNum = i + 1; - break; - } - pickedSoundID = 0; if (uVoicesVolumeMultiplier) { for (int i = 0; i < 2; i++) { - v8 = SoundSetAction[speech][i]; - if ( v8 ) - { - speechVariantArray[speechCount] = v8; + if ( SoundSetAction[speech][i] ) + { + speechVariantArray[speechCount] = SoundSetAction[speech][i]; speechCount++; } } @@ -568,17 +555,16 @@ if (numberOfSubvariants > 0) { pickedSoundID = rand() % numberOfSubvariants + 2 * (pickedVariant + 50 * uVoiceID) + 4998; - pAudioPlayer->PlaySound((SoundID)pickedSoundID, PID(OBJECT_Player, pPlayerNum + 39), 0, -1, 0, 0, (int)(pSoundVolumeLevels[uVoicesVolumeMultiplier] * 128.0f), 0); + pAudioPlayer->PlaySound((SoundID)pickedSoundID, PID(OBJECT_Player, uActiveCharacter + 39), 0, -1, 0, 0, (int)(pSoundVolumeLevels[uVoicesVolumeMultiplier] * 128.0f), 0); } } } for (int i = 0; i < 5; i++) { - v14 = SoundSetAction[speech][i + 3]; - if ( v14 ) - { - expressionVariantArray[expressionCount] = v14; + if ( SoundSetAction[speech][i + 3] ) + { + expressionVariantArray[expressionCount] = SoundSetAction[speech][i + 3]; expressionCount++; } } @@ -587,25 +573,16 @@ expression = (CHARACTER_EXPRESSION_ID)expressionVariantArray[rand() % expressionCount]; if (expression == CHARACTER_EXPRESSION_21 && pickedSoundID ) { - if ( (signed int)pSoundList->sNumSounds <= 0 ) - { - v17 = 0; - } - else - { - pSoundID = pSoundList->pSounds[0].uSoundID; - v17 = 0; + pSoundID = 0; + if ( pSoundList->sNumSounds ) + { for (int i = 0; i < pSoundList->sNumSounds; i++) { - v17 = i; - if (pSoundID == pickedSoundID) - { - break; - } - pSoundID += 120; + if (pSoundList->pSounds[i].uSoundID == pickedSoundID) + pSoundID = i; } } - if ( pSoundList->pSounds[v17].pSoundData[0] ) + if ( pSoundList->pSounds[pSoundID].pSoundData[0] ) expressionDuration = (sLastTrackLengthMS << 7) / 1000; } PlayEmotion(expression, expressionDuration); @@ -9382,7 +9359,7 @@ if ( v38 == OBJECT_Player && !qword_A750D8 ) { qword_A750D8 = 256i64; - word_A750E0 = 44; + PlayerSpeechID = SPEECH_44; word_A750E2 = uActorID + 1; } return; diff -r c0b273d33338 -r d071e0e9ba75 SpriteObject.cpp --- a/SpriteObject.cpp Mon Jul 22 15:23:43 2013 +0600 +++ b/SpriteObject.cpp Tue Jul 23 15:41:45 2013 +0600 @@ -53,46 +53,17 @@ //----- (0042F5ED) -------------------------------------------------------- int SpriteObject::Create(int yaw, int pitch, int a4, int a5) { - //SpriteObject *v5; // eax@1 signed int v6; // ebx@2 - //char *v7; // ecx@2 - //signed int result; // eax@6 - SpriteObject *v9; // ebx@7 - int v10; // edx@11 - int v11; // edi@18 - __int16 v12; // ax@18 int v13; // ST2C_4@20 - int v14; // eax@20 - int v15; // [sp-28h] [bp-38h]@14 - int v16; // [sp-24h] [bp-34h]@11 Vec3_int_ v17; // [sp-20h] [bp-30h]@11 - int *v18; // [sp-14h] [bp-24h]@11 - int *v19; // [sp-10h] [bp-20h]@11 - int *v20; // [sp-Ch] [bp-1Ch]@11 - //signed int v21; // [sp+8h] [bp-8h]@2 int angle; // [sp+Ch] [bp-4h]@1 - int a4a; // [sp+1Ch] [bp+Ch]@20 - int a4b; // [sp+1Ch] [bp+Ch]@20 int a5a; // [sp+20h] [bp+10h]@20 - //auto a1 = this; angle = yaw; - //v5 = a1; if (!uObjectDescID) return -1; v6 = 1000; - //v7 = (char *)&pSpriteObjects[0].uObjectDescID; - /*v21 = 0; - do - { - if ( !*(short *)v7 ) - break; - v7 += 112; - ++v6; - v21 = v6; - } - while ( (signed int)v7 < (signed int)((char *)&pObjectList->uNumObjects + 2) );*/ for (uint i = 0; i < MAX_SPRITE_OBJECTS; ++i) if (!pSpriteObjects[i].uObjectDescID) { @@ -104,89 +75,130 @@ return -1; field_64.x = vPosition.x; field_64.y = vPosition.y; - v9 = &pSpriteObjects[v6]; field_64.z = vPosition.z; assert(sizeof(SpriteObject) == 0x70); - memcpy(v9, this, sizeof(*this)); + memcpy(&pSpriteObjects[v6], this, sizeof(*this)); + if ( a5 == 0 ) + { + pSpriteObjects[v6].vVelocity.z = 0; + if ( a4 ) + { + v13 = (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; + a5a = (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; + pSpriteObjects[v6].vVelocity.x = (unsigned int)(v13 * a4) >> 16; + pSpriteObjects[v6].vVelocity.y = (unsigned int)(a5a * a4) >> 16; + pSpriteObjects[v6].vVelocity.z = (unsigned int)(stru_5C6E00->Sin(pitch) * a4) >> 16; + } + else + { + pSpriteObjects[v6].vVelocity.y = 0; + pSpriteObjects[v6].vVelocity.x = 0; + } + if ( v6 >= (signed int)uNumSpriteObjects ) + uNumSpriteObjects = v6 + 1; + return v6; + } if ( a5 == 1 ) { - v20 = &v9->vPosition.z; - v19 = &v9->vPosition.y; - v18 = (int *)&v9->vPosition; v17.x = vPosition.x; v17.y = vPosition.y; v17.z = vPosition.z; - v16 = 0; - v10 = stru_5C6E00->uIntegerHalfPi + v9->uFacing; - goto LABEL_16; + Vec3_int_::Rotate(24, stru_5C6E00->uIntegerHalfPi + pSpriteObjects[v6].uFacing, 0, v17, &pSpriteObjects[v6].vPosition.x, + &pSpriteObjects[v6].vPosition.y, &pSpriteObjects[v6].vPosition.z); + pSpriteObjects[v6].vVelocity.z = 0; + if ( a4 ) + { + v13 = (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; + a5a = (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; + pSpriteObjects[v6].vVelocity.x = (unsigned int)(v13 * a4) >> 16; + pSpriteObjects[v6].vVelocity.y = (unsigned int)(a5a * a4) >> 16; + pSpriteObjects[v6].vVelocity.z = (unsigned int)(stru_5C6E00->Sin(pitch) * a4) >> 16; + } + else + { + pSpriteObjects[v6].vVelocity.y = 0; + pSpriteObjects[v6].vVelocity.x = 0; + } + if ( v6 >= (signed int)uNumSpriteObjects ) + uNumSpriteObjects = v6 + 1; + return v6; } if ( a5 == 2 ) { - v20 = &v9->vPosition.z; - v19 = &v9->vPosition.y; - v18 = (int *)&v9->vPosition; - v17.x = vPosition.x; - v17.y = vPosition.y; - v17.z = vPosition.z; - v16 = 0; - v10 = stru_5C6E00->uIntegerHalfPi + v9->uFacing; - goto LABEL_14; - } - if ( a5 == 3 ) - { - v20 = &v9->vPosition.z; - v19 = &v9->vPosition.y; - v18 = (int *)&v9->vPosition; v17.x = vPosition.x; v17.y = vPosition.y; v17.z = vPosition.z; - v16 = 0; - v10 = v9->uFacing - stru_5C6E00->uIntegerHalfPi; -LABEL_14: - v15 = 8; -LABEL_17: - Vec3_int_::Rotate(v15, v10, v16, v17, v18, v19, v20); - goto LABEL_18; + Vec3_int_::Rotate(8, stru_5C6E00->uIntegerHalfPi + pSpriteObjects[v6].uFacing, 0, v17, &pSpriteObjects[v6].vPosition.x, + &pSpriteObjects[v6].vPosition.y, &pSpriteObjects[v6].vPosition.z); + pSpriteObjects[v6].vVelocity.z = 0; + if ( a4 ) + { + v13 = (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; + a5a = (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; + pSpriteObjects[v6].vVelocity.x = (unsigned int)(v13 * a4) >> 16; + pSpriteObjects[v6].vVelocity.y = (unsigned int)(a5a * a4) >> 16; + pSpriteObjects[v6].vVelocity.z = (unsigned int)(stru_5C6E00->Sin(pitch) * a4) >> 16; + } + else + { + pSpriteObjects[v6].vVelocity.y = 0; + pSpriteObjects[v6].vVelocity.x = 0; + } + if ( v6 >= (signed int)uNumSpriteObjects ) + uNumSpriteObjects = v6 + 1; + return v6; } - if ( a5 == 4 ) + if ( a5 == 3 ) { - v20 = &v9->vPosition.z; - v19 = &v9->vPosition.y; - v18 = (int *)&v9->vPosition; v17.x = vPosition.x; v17.y = vPosition.y; v17.z = vPosition.z; - v16 = 0; - v10 = v9->uFacing - stru_5C6E00->uIntegerHalfPi; -LABEL_16: - v15 = 24; - goto LABEL_17; + Vec3_int_::Rotate(8, pSpriteObjects[v6].uFacing - stru_5C6E00->uIntegerHalfPi, 0, v17, &pSpriteObjects[v6].vPosition.x, + &pSpriteObjects[v6].vPosition.y, &pSpriteObjects[v6].vPosition.z); + pSpriteObjects[v6].vVelocity.z = 0; + if ( a4 ) + { + v13 = (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; + a5a = (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; + pSpriteObjects[v6].vVelocity.x = (unsigned int)(v13 * a4) >> 16; + pSpriteObjects[v6].vVelocity.y = (unsigned int)(a5a * a4) >> 16; + pSpriteObjects[v6].vVelocity.z = (unsigned int)(stru_5C6E00->Sin(pitch) * a4) >> 16; + } + else + { + pSpriteObjects[v6].vVelocity.y = 0; + pSpriteObjects[v6].vVelocity.x = 0; + } + if ( v6 >= (signed int)uNumSpriteObjects ) + uNumSpriteObjects = v6 + 1; + return v6; } -LABEL_18: - v11 = a4; - v12 = 0; - if ( a4 ) + if ( a5 == 4 ) { - a4a = stru_5C6E00->Cos(angle); - v13 = (unsigned __int64)(a4a * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; - a4b = stru_5C6E00->Sin(angle); - a5a = (unsigned __int64)(a4b * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; - v14 = stru_5C6E00->Sin(pitch); - v9->vVelocity.x = (unsigned int)(v13 * v11) >> 16; - v9->vVelocity.y = (unsigned int)(a5a * v11) >> 16; - v12 = (unsigned int)(v14 * v11) >> 16; + v17.x = vPosition.x; + v17.y = vPosition.y; + v17.z = vPosition.z; + Vec3_int_::Rotate(24, pSpriteObjects[v6].uFacing - stru_5C6E00->uIntegerHalfPi, 0, v17, &pSpriteObjects[v6].vPosition.x, + &pSpriteObjects[v6].vPosition.y, &pSpriteObjects[v6].vPosition.z); + pSpriteObjects[v6].vVelocity.z = 0; + if ( a4 ) + { + v13 = (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; + a5a = (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; + pSpriteObjects[v6].vVelocity.x = (unsigned int)(v13 * a4) >> 16; + pSpriteObjects[v6].vVelocity.y = (unsigned int)(a5a * a4) >> 16; + pSpriteObjects[v6].vVelocity.z = (unsigned int)(stru_5C6E00->Sin(pitch) * a4) >> 16; + } + else + { + pSpriteObjects[v6].vVelocity.y = 0; + pSpriteObjects[v6].vVelocity.x = 0; + } + if ( v6 >= (signed int)uNumSpriteObjects ) + uNumSpriteObjects = v6 + 1; + return v6; } - else - { - v9->vVelocity.y = 0; - v9->vVelocity.x = 0; - } - v9->vVelocity.z = v12; - - if ( v6 >= (signed int)uNumSpriteObjects ) - uNumSpriteObjects = v6 + 1; - return v6; } //----- (00471C03) -------------------------------------------------------- @@ -970,94 +982,73 @@ // 46DF1A: using guessed type int __fastcall 46DF1A_collide_against_actor(int, int); //----- (00438E35) -------------------------------------------------------- -void SpriteObject::_438E35() +void SpriteObject::ExplosionTraps() { - SpriteObject *v1; // edi@1 MapInfo *pMapInfo; // esi@1 - int v3; // ebx@1 - int v4; // eax@1 - int v5; // ebx@1 - unsigned int v6; // ecx@1 + int dir_x; // ebx@1 int v7; // edx@2 - unsigned int v8; // edx@4 - unsigned int v9; // edx@6 unsigned int v10; // eax@7 signed int v11; // ebx@8 - Player **v12; // esi@18 signed int v13; // edi@20 - int v15; // [sp+Ch] [bp-Ch]@1 - int v16; // [sp+10h] [bp-8h]@1 - signed int v17; // [sp+14h] [bp-4h]@8 - int v18; // [sp+14h] [bp-4h]@14 + int dir_y; // [sp+Ch] [bp-Ch]@1 + int dir_z; // [sp+10h] [bp-8h]@1 + DAMAGE_TYPE pDamageType; // [sp+14h] [bp-4h]@14 - v1 = this; pMapInfo = &pMapStats->pInfos[pMapStats->GetMapInfo(pCurrentMapName.data())]; - v3 = abs(pParty->vPosition.x - v1->vPosition.x); - v15 = abs(pParty->vPosition.y - v1->vPosition.y); - v16 = abs(pParty->vPosition.z + pParty->sEyelevel - v1->vPosition.z); - v4 = v3; - v5 = v15; - v6 = v16; - if ( v4 < v15 ) + dir_x = abs(pParty->vPosition.x - this->vPosition.x); + dir_y = abs(pParty->vPosition.y - this->vPosition.y); + dir_z = abs(pParty->vPosition.z + pParty->sEyelevel - this->vPosition.z); + if ( dir_x < dir_y ) { - v7 = v4; - v4 = v15; - v5 = v7; + v7 = dir_x; + dir_x = dir_y; + dir_y = v7; } - if ( v4 < v16 ) + if ( dir_x < dir_z ) { - v8 = v4; - v4 = v16; - v6 = v8; + v7 = dir_x; + dir_x = dir_z; + dir_z = v7; } - if ( v5 < (signed int)v6 ) + if ( dir_y < dir_z ) { - v9 = v6; - v6 = v5; - v5 = v9; + v7 = dir_z; + dir_z = dir_y; + dir_y = v7; } - v10 = ((unsigned int)(11 * v5) >> 5) + (v6 >> 2) + v4; + v10 = ((unsigned int)(11 * dir_y) >> 5) + (dir_z / 4) + dir_x; if ( (signed int)v10 <= 768 ) { - v17 = 0; v11 = 5; if ( pMapInfo->Trap_D20 ) { - do - { - ++v17; + for ( uint i = 0; i < pMapInfo->Trap_D20; ++i ) v11 += rand() % 20 + 1; - } - while ( v17 < pMapInfo->Trap_D20 ); } - switch ( v1->uType ) + switch ( this->uType ) { - case 0x32Bu: - v18 = 0; + case 811: + pDamageType = DMGT_FIRE; + break; + case 812: + pDamageType = DMGT_ELECTR; break; - case 0x32Cu: - v18 = 1; + case 813: + pDamageType = DMGT_COLD; break; - case 0x32Du: - v18 = 2; + case 814: + pDamageType = DMGT_BODY; break; default: - //LOWORD(v10) = v1->uItemType - 814; - if ( v1->uType != 814 ) - return; - v18 = 8; - break; + return; } - v12 = &pPlayers[1]; - do + for ( uint i = 1; i <= 4; ++i ) { - if ( (*v12)->CanAct() && (v13 = (*v12)->GetPerception() + 20, rand() % v13 > 20) ) - (*v12)->PlaySound(SPEECH_6, 0); + if ( pPlayers[i]->CanAct() && (v13 = pPlayers[i]->GetPerception() + 20, rand() % v13 > 20) ) + pPlayers[i]->PlaySound(SPEECH_6, 0); else - (*v12)->ReceiveDamage(v11, (DAMAGE_TYPE)v18); - ++v12; + pPlayers[i]->ReceiveDamage(v11, pDamageType); } - while ( (signed int)v12 <= (signed int)&pPlayers[4] ); } } diff -r c0b273d33338 -r d071e0e9ba75 SpriteObject.h --- a/SpriteObject.h Mon Jul 22 15:23:43 2013 +0600 +++ b/SpriteObject.h Tue Jul 23 15:41:45 2013 +0600 @@ -16,7 +16,7 @@ SpriteObject(); int Create(int yaw, int pitch, int a4, int a5); void _46BEF1_apply_spells_aoe(); - void _438E35(); + void ExplosionTraps(); static void UpdateObject_fn0_BLV(unsigned int uLayingItemID); static void UpdateObject_fn0_ODM(unsigned int uLayingItemID); diff -r c0b273d33338 -r d071e0e9ba75 UI/UIShops.cpp --- a/UI/UIShops.cpp Mon Jul 22 15:23:43 2013 +0600 +++ b/UI/UIShops.cpp Tue Jul 23 15:41:45 2013 +0600 @@ -2698,7 +2698,7 @@ if ( v5 ) { qword_A750D8 = 256i64; - word_A750E0 = 80; + PlayerSpeechID = SPEECH_80; v4 = LOWORD(v7[rand() % v5]); word_A750E2 = v4; return; @@ -2721,7 +2721,7 @@ if ( v2 ) { qword_A750D8 = 256i64; - word_A750E0 = 80; + PlayerSpeechID = SPEECH_80; v4 = LOWORD(v7[rand() % v2]); word_A750E2 = v4; return; diff -r c0b273d33338 -r d071e0e9ba75 UI/UiGame.cpp --- a/UI/UiGame.cpp Mon Jul 22 15:23:43 2013 +0600 +++ b/UI/UiGame.cpp Tue Jul 23 15:41:45 2013 +0600 @@ -2201,7 +2201,7 @@ if ( qword_A750D8 <= 0 ) { if ( pPlayers[word_A750E2]->CanAct() ) - pPlayers[word_A750E2]->PlaySound((PlayerSpeech)word_A750E0, 0); + pPlayers[word_A750E2]->PlaySound(PlayerSpeechID, 0); qword_A750D8 = 0i64; } } diff -r c0b273d33338 -r d071e0e9ba75 mm7_6.cpp --- a/mm7_6.cpp Mon Jul 22 15:23:43 2013 +0600 +++ b/mm7_6.cpp Tue Jul 23 15:41:45 2013 +0600 @@ -1607,118 +1607,74 @@ //----- (0042F7EB) -------------------------------------------------------- bool __fastcall sub_42F7EB_DropItemAt(unsigned int uSpriteID, int x, int y, int z, int a4, int count, int a7, unsigned __int16 attributes, ItemGen *a9) { - unsigned int v9; // edi@1 - signed int v10; // edx@3 - char *v11; // ecx@4 - unsigned __int16 v12; // ax@7 - unsigned int v13; // edx@9 - char *v14; // ecx@10 - int v15; // esi@17 - int v16; // eax@18 - int v17; // edi@20 - int v18; // esi@20 - //SpriteObject a1a; // [sp+Ch] [bp-78h]@1 - int v21; // [sp+7Ch] [bp-8h]@1 - unsigned int v22; // [sp+80h] [bp-4h]@1 - - v9 = uSpriteID; - v21 = x; - v22 = uSpriteID; + unsigned __int16 pObjectDescID; // ax@7 + SpriteObject pSpellObject; // [sp+Ch] [bp-78h]@1 - SpriteObject a1a; // [sp+Ch] [bp-78h]@1 - //SpriteObject::SpriteObject(&a1a); - a1a.stru_24.Reset(); - + pSpellObject.stru_24.Reset(); if ( a9 ) - { - memcpy(&a1a.stru_24, a9, sizeof(a1a.stru_24)); - v9 = v22; - } - v10 = 0; - a1a.spell_skill = 0; - a1a.spell_level = 0; - a1a.spell_id = 0; - a1a.field_54 = 0; - a1a.uType = v9; + memcpy(&pSpellObject.stru_24, a9, sizeof(pSpellObject.stru_24)); + pSpellObject.spell_skill = 0; + pSpellObject.spell_level = 0; + pSpellObject.spell_id = 0; + pSpellObject.field_54 = 0; + pSpellObject.uType = uSpriteID; if ( (signed int)pObjectList->uNumObjects <= 0 ) - { -LABEL_7: - v12 = 0; - } + pObjectDescID = 0; else { - v11 = (char *)&pObjectList->pObjects->uObjectID; - while ( (short)v9 != *(short *)v11 ) + pObjectDescID = 0; + for ( uint i = 0; i < (signed int)pObjectList->uNumObjects; ++i ) { - ++v10; - v11 += 56; - if ( v10 >= (signed int)pObjectList->uNumObjects ) - goto LABEL_7; - } - v12 = v10; - } - a1a.uObjectDescID = v12; - a1a.vPosition.z = z; - a1a.vPosition.x = v21; - a1a.vPosition.y = y; - a1a.uSoundID = 0; - a1a.uAttributes = attributes; - a1a.uSectorID = pIndoor->GetSector(v21, y, z); - a1a.uSpriteFrameID = 0; - a1a.spell_caster_pid = 0; - a1a.spell_target_pid = 0; - if ( !(a1a.uAttributes & 0x10) ) - { - v13 = 0; - if ( (signed int)pItemsTable->uAllItemsCount > 0 ) - { - v14 = (char *)&pItemsTable->pItems[0].uSpriteID; - while ( *(short *)v14 != v9 ) - { - ++v13; - v14 += 48; - if ( (signed int)v13 >= (signed int)pItemsTable->uAllItemsCount ) - goto LABEL_16; - } - a1a.stru_24.uItemID = v13; + if ( (short)uSpriteID == pObjectList->pObjects[i].uObjectID ) + pObjectDescID = i; } } -LABEL_16: + pSpellObject.uObjectDescID = pObjectDescID; + pSpellObject.vPosition.x = x; + pSpellObject.vPosition.y = y; + pSpellObject.vPosition.z = z; + pSpellObject.uSoundID = 0; + pSpellObject.uAttributes = attributes; + pSpellObject.uSectorID = pIndoor->GetSector(x, y, z); + pSpellObject.uSpriteFrameID = 0; + pSpellObject.spell_caster_pid = 0; + pSpellObject.spell_target_pid = 0; + if ( !(pSpellObject.uAttributes & 0x10) ) + { + if ( pItemsTable->uAllItemsCount ) + { + for ( uint i = 0; i < pItemsTable->uAllItemsCount; ++i ) + { + if ( pItemsTable->pItems[i].uSpriteID == uSpriteID ) + pSpellObject.stru_24.uItemID = i; + } + } + } if ( a7 ) { - v15 = count; if ( count > 0 ) { - do + for ( uint i = count; i; --i ) { - a1a.uFacing = rand() % (signed int)stru_5C6E00->uIntegerDoublePi; - v16 = rand(); - a1a.Create( - (signed __int16)a1a.uFacing, - ((signed int)stru_5C6E00->uIntegerHalfPi >> 1) + (v16 % (signed int)stru_5C6E00->uIntegerHalfPi >> 1), - a4, - 0); - --v15; + pSpellObject.uFacing = rand() % (signed int)stru_5C6E00->uIntegerDoublePi; + pSpellObject.Create((signed __int16)pSpellObject.uFacing, + ((signed int)stru_5C6E00->uIntegerHalfPi / 2) + (rand() % ((signed int)stru_5C6E00->uIntegerHalfPi / 2)), a4, 0); + } - while ( v15 ); } } else { - v17 = count; - v18 = stru_5C6E00->uIntegerHalfPi; - a1a.uFacing = 0; + pSpellObject.uFacing = 0; if ( count > 0 ) { - do + for ( uint i = count; i; --i ) { - a1a.Create((signed __int16)a1a.uFacing, v18, a4, 0); - --v17; + pSpellObject.Create((signed __int16)pSpellObject.uFacing, stru_5C6E00->uIntegerHalfPi, a4, 0); } - while ( v17 ); } } - return 1; + return true; } //----- (0042F960) -------------------------------------------------------- diff -r c0b273d33338 -r d071e0e9ba75 mm7_data.cpp --- a/mm7_data.cpp Mon Jul 22 15:23:43 2013 +0600 +++ b/mm7_data.cpp Tue Jul 23 15:41:45 2013 +0600 @@ -1337,7 +1337,7 @@ std::array< std::array, 4> pTextures_PlayerFaces; std::array pPlayers; __int64 qword_A750D8; // weak -__int16 word_A750E0; // weak +enum PlayerSpeech PlayerSpeechID; __int16 word_A750E2; // weak std::array pClassNames; std::array aCharacterConditionNames; diff -r c0b273d33338 -r d071e0e9ba75 mm7_data.h --- a/mm7_data.h Mon Jul 22 15:23:43 2013 +0600 +++ b/mm7_data.h Tue Jul 23 15:41:45 2013 +0600 @@ -993,7 +993,7 @@ extern int dword_A75070; // weak extern std::array pPlayers; extern __int64 qword_A750D8; // weak -extern __int16 word_A750E0; // weak +extern enum PlayerSpeech PlayerSpeechID; extern __int16 word_A750E2; // weak extern std::array pClassNames; extern std::array aCharacterConditionNames;