Mercurial > mm7
changeset 2138:7cc14d9d966d
1
author | Ritor1 |
---|---|
date | Thu, 02 Jan 2014 09:11:01 +0600 |
parents | a290d9fbdc95 |
children | f9b55be70c1b |
files | AudioPlayer.cpp AudioPlayer.h Events.cpp Indoor.cpp Indoor.h Items.h Outdoor.cpp Outdoor.h SpriteObject.cpp Viewport.cpp mm7_3.cpp mm7_4.cpp mm7_data.cpp mm7_data.h |
diffstat | 14 files changed, 1665 insertions(+), 2266 deletions(-) [+] |
line wrap: on
line diff
--- a/AudioPlayer.cpp Tue Dec 03 16:35:57 2013 +0600 +++ b/AudioPlayer.cpp Thu Jan 02 09:11:01 2014 +0600 @@ -321,30 +321,17 @@ //----- (004A9D79) -------------------------------------------------------- void SoundList::_4A9D79(int a2) { - SoundList *v2; // esi@1 - int v3; // edi@1 - signed int i; // ebx@1 - SoundDesc *v5; // eax@2 - SOUND_DESC_TYPE v6; // ecx@2 - void *v7; // eax@5 - - v2 = this; - v3 = 0; - for ( i = 0; i < (signed int)v2->sNumSounds; ++v3 ) + for ( int i = 0; i < (signed int)this->sNumSounds; ++i ) { - v5 = &v2->pSounds[v3]; - v6 = v5->eType; - if ( v6 != SOUND_DESC_SYSTEM && (a2 || v6 != SOUND_DESC_LOCK) ) + if ( this->pSounds[i].eType != SOUND_DESC_SYSTEM && (a2 || this->pSounds[i].eType != SOUND_DESC_LOCK) ) { - v7 = v5->pSoundData[0]; - if ( v7 ) + if ( this->pSounds[i].pSoundData[0] ) { - ReleaseSoundData(v7); - v2->pSounds[v3].pSoundData[0] = 0; + ReleaseSoundData(this->pSounds[i].pSoundData[0]); + this->pSounds[i].pSoundData[0] = 0; } - v2->pSounds[v3].uFlags &= ~SOUND_DESC_SYSTEM; + this->pSounds[i].uFlags &= ~SOUND_DESC_SYSTEM; } - ++i; } } @@ -373,19 +360,15 @@ //----- (004A9E3D) -------------------------------------------------------- void SoundList::ToFile() { - SoundList *v1; // esi@1 FILE *v2; // eax@1 - FILE *v3; // edi@1 - v1 = this; v2 = fopen("data\\dsounds.bin", "wb"); - v3 = v2; if ( !v2 ) Error("Unable to save dsounds.bin!"); - fwrite(v1, 4u, 1u, v2); - fwrite(v1->pSounds, 0x78u, v1->sNumSounds, v3); - fclose(v3); + fwrite(this, 4, 1, v2); + fwrite(this->pSounds, 0x78u, this->sNumSounds, v2); + fclose(v2); } //----- (004A9E89) -------------------------------------------------------- @@ -415,7 +398,6 @@ //----- (004A9ED0) -------------------------------------------------------- int SoundList::FromFileTxt(const char *Args) { - SoundList *v2; // ebx@1 __int32 v3; // edi@1 FILE *v4; // eax@1 unsigned int v5; // esi@3 @@ -435,11 +417,10 @@ FILE *File; // [sp+2F8h] [bp-4h]@1 unsigned int Argsa; // [sp+304h] [bp+8h]@3 - v2 = this; free(this->pSounds); v3 = 0; - v2->pSounds = 0; - v2->sNumSounds = 0; + this->pSounds = 0; + this->sNumSounds = 0; v4 = fopen(Args, "r"); File = v4; if ( !v4 ) @@ -460,15 +441,15 @@ v5 = Argsa; v3 = 0; } - v2->sNumSounds = v5; + this->sNumSounds = v5; v6 = malloc(120 * v5); - v2->pSounds = (SoundDesc *)v6; + this->pSounds = (SoundDesc *)v6; if ( v6 == (void *)v3 ) Error("SoundListClass::load - Out of Memory!"); - memset(v6, v3, 120 * v2->sNumSounds); + memset(v6, v3, 120 * this->sNumSounds); v7 = File; - v2->sNumSounds = v3; + this->sNumSounds = v3; fseek(v7, v3, v3); for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) ) { @@ -476,38 +457,34 @@ memcpy(&v19, txt_file_frametable_parser(&Buf, &v18), sizeof(v19)); if ( v19.uPropCount && *v19.pProperties[0] != 47 ) { - sprintf(v2->pSounds[v2->sNumSounds].pSoundName, "%s", v19.pProperties[0]); + sprintf(this->pSounds[this->sNumSounds].pSoundName, "%s", v19.pProperties[0]); v9 = atoi(v19.pProperties[1]); v10 = v19.pProperties[2]; - v2->pSounds[v2->sNumSounds].uSoundID = v9; + this->pSounds[this->sNumSounds].uSoundID = v9; if ( _stricmp(v10, "system") ) { if ( _stricmp(v19.pProperties[2], "swap") ) { v11 = _stricmp(v19.pProperties[2], "lock"); - v12 = v2->pSounds; + v12 = this->pSounds; v13 = v11 == 0; - v14 = v2->sNumSounds; + v14 = this->sNumSounds; if ( v13 ) v12[v14].eType = SOUND_DESC_LOCK; else v12[v14].eType = SOUND_DESC_LEVEL; } else - { - v2->pSounds[v2->sNumSounds].eType = SOUND_DESC_SWAP; - } + this->pSounds[this->sNumSounds].eType = SOUND_DESC_SWAP; } else - { - v2->pSounds[v2->sNumSounds].eType = SOUND_DESC_SYSTEM; - } + this->pSounds[this->sNumSounds].eType = SOUND_DESC_SYSTEM; if ( v19.uPropCount >= 4 && !_stricmp(v19.pProperties[3], "3D") ) { - v15 = (int)&v2->pSounds[v2->sNumSounds].uFlags; + v15 = (int)&this->pSounds[this->sNumSounds].uFlags; *(int *)v15 |= SOUND_DESC_SWAP; } - ++v2->sNumSounds; + ++this->sNumSounds; } } fclose(File); @@ -721,22 +698,42 @@ int start_channel = 0, end_channel = 0; - +v62 = start_channel; assert(sound_id < pSoundList->sNumSounds); - SoundDesc* sound_desc = pSoundList->pSounds + sound_id; + SoundDesc* sound_desc = &pSoundList->pSounds[sound_id]; if (!b3DSoundInitialized || sound_desc->Is3D()) { if (!a3) // generic sound like from UI { start_channel = 10; end_channel = 12; - goto LABEL_133; + for (v62 = start_channel; v62 <= end_channel; ++v62) + { + MixerChannel* channel = pMixerChannels + v62; + if (AIL_sample_status(channel->hSample) == AIL::Sample::Done) + { + AIL_end_sample(channel->hSample); + if (channel->uSourceTrackIdx) + FreeChannel(channel); + break; + } + } } else if (a3 == -1) // exclusive sounds - can override { start_channel = 13; end_channel = 13; - goto LABEL_133; + for (v62 = start_channel; v62 <= end_channel; ++v62) + { + MixerChannel* channel = pMixerChannels + v62; + if (AIL_sample_status(channel->hSample) == AIL::Sample::Done) + { + AIL_end_sample(channel->hSample); + if (channel->uSourceTrackIdx) + FreeChannel(channel); + break; + } + } } else { @@ -744,7 +741,17 @@ { start_channel = 14; end_channel = 14; - goto LABEL_123; + for (uint i = 0; i < uMixerChannels; ++i) + { + MixerChannel* channel = &pMixerChannels[i]; + if (channel->source_pid == a3 && AIL_sample_status(channel->hSample) == AIL::Sample::Playing) + { + 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); + } + } } else { @@ -757,7 +764,17 @@ { start_channel = 10; end_channel = 12; - goto LABEL_133; + for (v62 = start_channel; v62 <= end_channel; ++v62) + { + MixerChannel* channel = pMixerChannels + v62; + if (AIL_sample_status(channel->hSample) == AIL::Sample::Done) + { + AIL_end_sample(channel->hSample); + if (channel->uSourceTrackIdx) + FreeChannel(channel); + break; + } + } } break; @@ -772,8 +789,19 @@ sample_volume = GetSoundStrengthByDistanceFromParty(actor->vPosition.x, actor->vPosition.y, actor->vPosition.z); if (!sample_volume) return; - goto LABEL_123; + for (uint i = 0; i < uMixerChannels; ++i) + { + MixerChannel* channel = &pMixerChannels[i]; + if (channel->source_pid == a3 && AIL_sample_status(channel->hSample) == AIL::Sample::Playing) + { + 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); + } + } } + break; case OBJECT_Decoration: { @@ -786,7 +814,17 @@ sample_volume = GetSoundStrengthByDistanceFromParty(decor->vPosition.x, decor->vPosition.y, decor->vPosition.z); if (!sample_volume) return; - goto LABEL_123; + for (uint i = 0; i < uMixerChannels; ++i) + { + MixerChannel* channel = &pMixerChannels[i]; + if (channel->source_pid == a3 && AIL_sample_status(channel->hSample) == AIL::Sample::Playing) + { + 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); + } + } } break; @@ -801,7 +839,17 @@ sample_volume = GetSoundStrengthByDistanceFromParty(object->vPosition.x, object->vPosition.y, object->vPosition.z); if (!sample_volume) return; - goto LABEL_123; + for (uint i = 0; i < uMixerChannels; ++i) + { + MixerChannel* channel = &pMixerChannels[i]; + if (channel->source_pid == a3 && AIL_sample_status(channel->hSample) == AIL::Sample::Playing) + { + 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); + } + } } break; @@ -809,7 +857,17 @@ { start_channel = 8; end_channel = 9; - goto LABEL_123; + for (uint i = 0; i < uMixerChannels; ++i) + { + MixerChannel* channel = &pMixerChannels[i]; + if (channel->source_pid == a3 && AIL_sample_status(channel->hSample) == AIL::Sample::Playing) + { + 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); + } + } } break; @@ -818,33 +876,6 @@ } } } -LABEL_123: - for (uint i = 0; i < uMixerChannels; ++i) - { - MixerChannel* channel = &pMixerChannels[i]; - if (channel->source_pid == a3 && - AIL_sample_status(channel->hSample) == AIL::Sample::Playing) - { - 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; - for (v62 = start_channel; v62 <= end_channel; ++v62) - { - MixerChannel* channel = pMixerChannels + v62; - if (AIL_sample_status(channel->hSample) == AIL::Sample::Done) - { - AIL_end_sample(channel->hSample); - if (channel->uSourceTrackIdx) - FreeChannel(channel); - break; - } - } /*if ( start_channel <= end_channel) { pMixerChannel2 = &pAudioPlayer->pMixerChannels[start_channel]; @@ -861,9 +892,9 @@ } LABEL_140:*/ - if (v62 > end_channel) // no free channel - occupy the quitest one + if (start_channel > end_channel) // no free channel - occupy the quitest one { - v62 = -1; + start_channel = -1; int min_volume = sample_volume; for (uint i = start_channel; i <= end_channel; ++i) @@ -874,7 +905,7 @@ if (volume < min_volume) { min_volume = volume; - v62 = i; + start_channel = i; } } /*v65 = start_channel; @@ -1804,12 +1835,7 @@ //----- (004AB71F) -------------------------------------------------------- void AudioPlayer::StopChannels(int uStartChannel, int uEndChannel) { - //AudioPlayer *v3; // esi@1 int v4; // ecx@1 - //AudioPlayer_3DSample *v5; // edi@4 - int v6; // ebx@12 - MixerChannel *pChannel; // edi@14 - //_STREAM *v8; // esi@23 int v9; // [sp+4h] [bp-4h]@3 if ( bPlayerReady ) @@ -1819,41 +1845,36 @@ v9 = 0; if ( uNum3DSamples > 0 ) { - //v5 = p3DSamples;//;(char *)&p3DSamples[0].field_8; for ( v4 = 0; v4 < uNum3DSamples; ++v4 ) { if ( (uStartChannel == -1 || v4 < uStartChannel || v4 > uEndChannel) - && p3DSamples[v4].field_8 - && pSoundList->pSounds[p3DSamples[v4].field_8].eType != SOUND_DESC_SYSTEM) + && p3DSamples[v4].field_8 + && pSoundList->pSounds[p3DSamples[v4].field_8].eType != SOUND_DESC_SYSTEM) { AIL_end_3D_sample(p3DSamples[v4].hSample); _4ABF23(&p3DSamples[v4]); p3DSamples[v4].field_4 = 0; v4 = v9; } - //v5 += 16; v9 = v4; } } } if ( hDigDriver && uMixerChannels > 0 ) { - pChannel = pMixerChannels; - for ( v6 = 0; v6 < uMixerChannels; ++v6 ) + for ( int i = 0; i < uMixerChannels; ++i ) { - if ( (uStartChannel == -1 || v6 < uStartChannel || v6 > uEndChannel) - && pSoundList->pSounds[pChannel->uSourceTrackIdx].eType != SOUND_DESC_SYSTEM) + if ( (uStartChannel == -1 || i < uStartChannel || i > uEndChannel) + && pSoundList->pSounds[pMixerChannels[i].uSourceTrackIdx].eType != SOUND_DESC_SYSTEM) { - AIL_end_sample(pChannel->hSample); - FreeChannel(pChannel); - pChannel->source_pid = 0; + AIL_end_sample(pMixerChannels[i].hSample); + FreeChannel(&pMixerChannels[i]); + pMixerChannels[i].source_pid = 0; } - ++pChannel; } } if (hSequence) AIL_end_sequence(hSequence); - //v8 = hStream; if (hStream) AIL_pause_stream(hStream, 1); } @@ -1886,7 +1907,7 @@ char v5; // dl@5 _PROVIDER *v6; // eax@9 //HWND v7; // ST00_4@9 - MixerChannel *pChannel; // edi@14 + //MixerChannel *pChannel; // edi@14 _SAMPLE *v9; // eax@15 //_REDBOOK *v10; // eax@19 //int v11; // ecx@21 @@ -1954,19 +1975,11 @@ } } } - if ( uMixerChannels > 0 ) + for ( v3; v3 < uMixerChannels; ++v3 ) { - pChannel = pMixerChannels; - do - { - v9 = AIL_allocate_sample_handle(hDigDriver); - pChannel->hSample = v9; - if ( !v9 ) - break; - ++v3; - ++pChannel; - } - while ( v3 < uMixerChannels ); + pMixerChannels[v3].hSample = AIL_allocate_sample_handle(hDigDriver); + if ( !pMixerChannels[v3].hSample ) + break; } uMixerChannels = v3; if ( bPlayerReady ) @@ -2197,19 +2210,11 @@ { LABEL_16: pSoundList->UnloadSound(pChannel->uSourceTrackIdx, 1); - v10 = 0; - if ( num_same_sound_on_channels > 0 ) + for ( v10 = 0; v10 < num_same_sound_on_channels; v10++ ) { - do - { - v11 = v14[v10]; - v12 = 16 * (v14[v10++] + 47); - pMixerChannels[v11].uSourceTrackID = 0; - //v13 = __OFSUB__(v10, num_same_sound_on_channels); - //v6 = v10 - num_same_sound_on_channels < 0; - *(unsigned int *)((char *)&bEAXSupported + v12) = 0; - } - while (v10 < num_same_sound_on_channels); + v12 = 16 * (v14[v10] + 47); + pMixerChannels[v14[v10]].uSourceTrackID = 0; + *(unsigned int *)((char *)&bEAXSupported + v12) = 0; } } }
--- a/AudioPlayer.h Tue Dec 03 16:35:57 2013 +0600 +++ b/AudioPlayer.h Thu Jan 02 09:11:01 2014 +0600 @@ -79,6 +79,7 @@ SOUND_8 = 0x8, SOUND_24 = 24, SOUND_error = 27, + SOUND_RunAlongWater = 63, SOUND_RunAlong3DModel = 64, SOUND_Button = 66, SOUND_67 = 67, @@ -90,6 +91,7 @@ SOUND_83 = 83, SOUND_84 = 84, SOUND_85 = 85, + SOUND_WalkAlongWater = 102, SOUND_WalkAlong3DModel = 103, SOUND_Arcomage_LoseResources = 0x78, SOUND_Arcomage_AddResources = 0x79,
--- a/Events.cpp Tue Dec 03 16:35:57 2013 +0600 +++ b/Events.cpp Thu Jan 02 09:11:01 2014 +0600 @@ -1337,12 +1337,9 @@ //v7 = ""; break; case EVENT_ChangeDoorState: - sub_449A49_door_switch_animation(_evt->v5, _evt->v6); + Door_switch_animation(_evt->v5, _evt->v6); ++curr_seq_num; v4 = v124; - - //v6 = v123; - //v7 = ""; break; case EVENT_OpenChest: if ( !Chest::Open(_evt->v5) )
--- a/Indoor.cpp Tue Dec 03 16:35:57 2013 +0600 +++ b/Indoor.cpp Thu Jan 02 09:11:01 2014 +0600 @@ -41,7 +41,7 @@ #include "texts.h" #include "GUIWindow.h" #include "Level/Decoration.h" - +#include "Overlays.h" @@ -3980,10 +3980,10 @@ int v38; // edx@62 //int v44; // [sp+20h] [bp-20h]@10 bool v47; // [sp+24h] [bp-1Ch]@43 - bool v48; // [sp+28h] [bp-18h]@10 + bool current_vertices_Y; // [sp+28h] [bp-18h]@10 bool v49; // [sp+28h] [bp-18h]@41 - bool v50; // [sp+2Ch] [bp-14h]@12 - signed int v53; // [sp+30h] [bp-10h]@10 + bool next_vertices_Y; // [sp+2Ch] [bp-14h]@12 + signed int number_hits; // [sp+30h] [bp-10h]@10 signed int v54; // [sp+30h] [bp-10h]@41 signed int v55; // [sp+34h] [bp-Ch]@1 @@ -3992,8 +3992,8 @@ static int blv_floor_id[50]; // 00721200 static int blv_floor_level[50]; // 007212C8 - static __int16 word_721390_ys[104]; // idb - static __int16 word_721460_xs[104]; // idb + static __int16 blv_floor_face_vert_coord_Y[104]; // word_721390_ys + static __int16 blv_floor_face_vert_coord_X[104]; // word_721460_xs BLVSector* pSector = &pIndoor->pSectors[uSectorID]; v55 = 0; @@ -4009,48 +4009,48 @@ { for (uint j = 0; j < pFloor->uNumVertices; ++j) { - word_721460_xs[2 * j] = pFloor->pXInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j]].x; - word_721460_xs[2 * j + 1] = pFloor->pXInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j + 1]].x; - word_721390_ys[2 * j] = pFloor->pYInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j]].y; - word_721390_ys[2 * j + 1] = pFloor->pYInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j + 1]].y; + blv_floor_face_vert_coord_X[2 * j] = pFloor->pXInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j]].x; + blv_floor_face_vert_coord_X[2 * j + 1] = pFloor->pXInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j + 1]].x; + blv_floor_face_vert_coord_Y[2 * j] = pFloor->pYInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j]].y; + blv_floor_face_vert_coord_Y[2 * j + 1] = pFloor->pYInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j + 1]].y; } - word_721460_xs[2 * pFloor->uNumVertices] = word_721460_xs[0]; - word_721390_ys[2 * pFloor->uNumVertices] = word_721390_ys[0]; - - v50 = word_721390_ys[0] >= y; - v53 = 0; + blv_floor_face_vert_coord_X[2 * pFloor->uNumVertices] = blv_floor_face_vert_coord_X[0]; + blv_floor_face_vert_coord_Y[2 * pFloor->uNumVertices] = blv_floor_face_vert_coord_Y[0]; + + next_vertices_Y = blv_floor_face_vert_coord_Y[0] >= y; + number_hits = 0; for (uint j = 0; j < 2 * pFloor->uNumVertices; ++j) { - if (v53 >= 2) + if (number_hits >= 2) break; - v48 = v50; - v50 = word_721390_ys[j + 1] >= y; - - v13 = i; - if (v48 == v50) - continue; - - v14 = word_721460_xs[j + 1] >= x ? 0 : 2; - v15 = v14 | (word_721460_xs[j] < x); - - if (v15 == 3) - continue; - else if (!v15) - ++v53; - else - { - long long a_div_b = fixpoint_div(y - word_721390_ys[j], word_721390_ys[j + 1] - word_721390_ys[j]); - long long res = fixpoint_mul((signed int)word_721460_xs[j + 1] - (signed int)word_721460_xs[j], a_div_b); - - if (res + word_721460_xs[j] >= x) - ++v53; + current_vertices_Y = next_vertices_Y; + next_vertices_Y = blv_floor_face_vert_coord_Y[j + 1] >= y; + + v13 = i; + if (current_vertices_Y == next_vertices_Y) + continue; + + v14 = blv_floor_face_vert_coord_X[j + 1] >= x ? 0 : 2; + v15 = v14 | (blv_floor_face_vert_coord_X[j] < x); + + if (v15 == 3) + continue; + else if (!v15) + ++number_hits; + else + { + long long a_div_b = fixpoint_div(y - blv_floor_face_vert_coord_Y[j], blv_floor_face_vert_coord_Y[j + 1] - blv_floor_face_vert_coord_Y[j]); + long long res = fixpoint_mul((signed int)blv_floor_face_vert_coord_X[j + 1] - (signed int)blv_floor_face_vert_coord_X[j], a_div_b); + + if (res + blv_floor_face_vert_coord_X[j] >= x) + ++number_hits; } } - if ( v53 == 1 ) + if ( number_hits == 1 ) { if ( v55 >= 50 ) break; @@ -4086,35 +4086,35 @@ { for (uint j = 0; j < portal->uNumVertices; ++j) { - word_721460_xs[2 * j] = portal->pXInterceptDisplacements[j] + pIndoor->pVertices[portal->pVertexIDs[j]].x; - word_721460_xs[2 * j + 1] = portal->pXInterceptDisplacements[j + 1] + pIndoor->pVertices[portal->pVertexIDs[j + 1]].x; - word_721390_ys[2 * j] = portal->pYInterceptDisplacements[j] + pIndoor->pVertices[portal->pVertexIDs[j]].y; - word_721390_ys[2 * j + 1] = portal->pYInterceptDisplacements[j + 1] + pIndoor->pVertices[portal->pVertexIDs[j + 1]].y; + blv_floor_face_vert_coord_X[2 * j] = portal->pXInterceptDisplacements[j] + pIndoor->pVertices[portal->pVertexIDs[j]].x; + blv_floor_face_vert_coord_X[2 * j + 1] = portal->pXInterceptDisplacements[j + 1] + pIndoor->pVertices[portal->pVertexIDs[j + 1]].x; + blv_floor_face_vert_coord_Y[2 * j] = portal->pYInterceptDisplacements[j] + pIndoor->pVertices[portal->pVertexIDs[j]].y; + blv_floor_face_vert_coord_Y[2 * j + 1] = portal->pYInterceptDisplacements[j + 1] + pIndoor->pVertices[portal->pVertexIDs[j + 1]].y; } - word_721460_xs[2 * portal->uNumVertices] = word_721460_xs[0]; - word_721390_ys[2 * portal->uNumVertices] = word_721390_ys[0]; + blv_floor_face_vert_coord_X[2 * portal->uNumVertices] = blv_floor_face_vert_coord_X[0]; + blv_floor_face_vert_coord_Y[2 * portal->uNumVertices] = blv_floor_face_vert_coord_Y[0]; v54 = 0; - v47 = word_721390_ys[0] >= y; + v47 = blv_floor_face_vert_coord_Y[0] >= y; for (uint j = 0; j < 2 * portal->uNumVertices; ++j) { v49 = v47; if ( v54 >= 2 ) break; - v47 = word_721390_ys[j + 1] >= y; + v47 = blv_floor_face_vert_coord_Y[j + 1] >= y; if ( v49 != v47 ) { - v28 = word_721460_xs[j + 1] >= x ? 0 : 2; - v29 = v28 | (word_721460_xs[j] < x); + v28 = blv_floor_face_vert_coord_X[j + 1] >= x ? 0 : 2; + v29 = v28 | (blv_floor_face_vert_coord_X[j] < x); if ( v29 != 3 ) { if ( !v29 ) ++v54; else { - long long a_div_b = fixpoint_div(y - word_721390_ys[j], word_721390_ys[j + 1] - word_721390_ys[j]); - long long res = fixpoint_mul(word_721460_xs[j + 1] - word_721460_xs[j], a_div_b); - if (res + word_721460_xs[j] >= x) + long long a_div_b = fixpoint_div(y - blv_floor_face_vert_coord_Y[j], blv_floor_face_vert_coord_Y[j + 1] - blv_floor_face_vert_coord_Y[j]); + long long res = fixpoint_mul(blv_floor_face_vert_coord_X[j + 1] - blv_floor_face_vert_coord_X[j], a_div_b); + if (res + blv_floor_face_vert_coord_X[j] >= x) ++v54; } } @@ -6893,4 +6893,521 @@ }*/ } return 0; +} +//----- (00472866) -------------------------------------------------------- +void BLV_ProcessPartyActions() +{ + int v1; // ebx@1 + int v2; // edi@1 + double v10; // st7@27 + unsigned int v12; // eax@49 + double v13; // st7@50 + int v17; // eax@62 + double v18; // st7@62 + int v19; // ST40_4@62 + int v20; // eax@65 + double v21; // st7@65 + int v22; // ST40_4@65 + int v23; // eax@66 + double v24; // st7@66 + int v25; // ST40_4@66 + int v26; // eax@67 + double v27; // st7@67 + int v28; // ST40_4@67 + int new_party_z; // esi@96 + int v38; // eax@96 + int v39; // ecx@106 + int v40; // eax@106 + int v42; // eax@120 + BLVFace *pFace; // esi@126 + int v46; // ecx@133 + int v52; // eax@140 + int v54; // ebx@146 + int v63; // [sp-8h] [bp-68h]@75 + int v65; // [sp-4h] [bp-64h]@75 + unsigned int uFaceEvent; // [sp+14h] [bp-4Ch]@1 + bool party_running_flag; // [sp+1Ch] [bp-44h]@1 + bool bFeatherFall; // [sp+24h] [bp-3Ch]@15 + unsigned int uSectorID; // [sp+28h] [bp-38h]@1 + bool party_walking_flag; // [sp+2Ch] [bp-34h]@1 + unsigned int uFaceID; // [sp+30h] [bp-30h]@1 + int v80; // [sp+34h] [bp-2Ch]@1 + int v82; // [sp+3Ch] [bp-24h]@47 + int _view_angle; // [sp+40h] [bp-20h]@47 + int bJumping; // [sp+44h] [bp-1Ch]@1 + int new_party_y; // [sp+48h] [bp-18h]@1 + int new_party_x; // [sp+4Ch] [bp-14h]@1 + int party_z; // [sp+50h] [bp-10h]@1 + int angle; // [sp+5Ch] [bp-4h]@47 + + uFaceEvent = 0; + //v89 = pParty->uFallSpeed; + v1 = 0; + v2 = 0; + new_party_x = pParty->vPosition.x; + new_party_y = pParty->vPosition.y; + party_z = pParty->vPosition.z; + uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); + party_running_flag = false; + party_walking_flag = false; + bJumping = false; + + uFaceID = -1; + int 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; + } + + 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; + pParty->uFallStartY = blv_prev_party_y; + return; + } + } + + blv_prev_party_x = pParty->vPosition.x; + blv_prev_party_z = pParty->vPosition.y; + blv_prev_party_y = pParty->vPosition.z; + if (!pParty->bTurnBasedModeOn) + { + int v67 = GetTickCount() / 500; + if (dword_720CDC != v67 ) + { + dword_4F8580[3 * dword_4F8580[1]] = pParty->vPosition.x; + dword_4F8580[3 * dword_4F8580[2]] = pParty->vPosition.y; + dword_4F8580[3 * dword_4F8580[3]] = pParty->vPosition.z; + if ( dword_4F8580[0] > 60 ) + dword_4F8580[0] = 1; + } + dword_720CDC = v67; + } + + uint fall_start; + if (!pParty->FeatherFallActive()) + { + bFeatherFall = false; + if (!pParty->pPlayers[0].WearsItemAnyWhere(ITEM_ARTIFACT_LADYS_ESCORT) && // grants feather fall + !pParty->pPlayers[1].WearsItemAnyWhere(ITEM_ARTIFACT_LADYS_ESCORT) && + !pParty->pPlayers[2].WearsItemAnyWhere(ITEM_ARTIFACT_LADYS_ESCORT) && + !pParty->pPlayers[3].WearsItemAnyWhere(ITEM_ARTIFACT_LADYS_ESCORT)) + { + fall_start = pParty->uFallStartY; + } + } + else + { + fall_start = floor_level; + bFeatherFall = true; + 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 + if (!pParty->pPlayers[i].HasEnchantedItemEquipped(72) && !pParty->pPlayers[i].WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, EQUIP_BOOTS)) + { + pParty->pPlayers[i].ReceiveDamage((pParty->uFallStartY - party_z) * (0.1f * pParty->pPlayers[i].GetMaxHealth()) / 256, DMGT_PHISYCAL); + v10 = (double)(20 - pParty->pPlayers[i].GetParameterBonus(pParty->pPlayers[i].GetActualEndurance())) * flt_6BE3A4_debug_recmod1 * 2.133333333333333; + pParty->pPlayers[i].SetRecoveryTime((signed __int64)v10); + } + } + } + + if ( party_z > floor_level + 1 ) + bJumping = 1; + + bool jumping_up = false; + + if ( party_z - floor_level <= 32 ) + { + pParty->uFallStartY = party_z; + 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) + { + if (pIndoor->pFaces[uFaceID].uAttributes & FACE_PRESSURE_PLATE) + uFaceEvent = pIndoor->pFaceExtras[pIndoor->pFaces[uFaceID].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) + / 180)) >> 16; + while ( pPartyActionQueue->uNumActions ) + { + switch ( pPartyActionQueue->Next() ) + { + case PARTY_TurnLeft: + if (uTurnSpeed) + angle = stru_5C6E00->uDoublePiMask & (angle + uTurnSpeed); + else + angle = stru_5C6E00->uDoublePiMask & (angle + (int)(v82 * fTurnSpeedMultiplier)); + break; + case PARTY_TurnRight: + if (uTurnSpeed) + angle = stru_5C6E00->uDoublePiMask & (angle - uTurnSpeed); + else + angle = stru_5C6E00->uDoublePiMask & (angle - (int)(v82 * fTurnSpeedMultiplier)); + break; + + case PARTY_FastTurnLeft: + if (uTurnSpeed) + angle = stru_5C6E00->uDoublePiMask & (angle + uTurnSpeed); + else + angle = stru_5C6E00->uDoublePiMask & (angle + (int)(2.0f * fTurnSpeedMultiplier * (double)v82)); + break; + + case PARTY_FastTurnRight: + 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 -= fixpoint_mul(stru_5C6E00->Sin(angle), pParty->uWalkSpeed * fWalkSpeedMultiplier / 2); + v1 += fixpoint_mul(stru_5C6E00->Cos(angle), pParty->uWalkSpeed * fWalkSpeedMultiplier / 2); + party_walking_flag = true; + break; + case PARTY_StrafeRight: + v2 += fixpoint_mul(stru_5C6E00->Sin(angle), pParty->uWalkSpeed * fWalkSpeedMultiplier / 2); + v1 -= fixpoint_mul(stru_5C6E00->Cos(angle), pParty->uWalkSpeed * fWalkSpeedMultiplier / 2); + party_walking_flag = true; + break; + case PARTY_WalkForward: + v2 += fixpoint_mul(stru_5C6E00->Cos(angle), 5 * pParty->uWalkSpeed * fWalkSpeedMultiplier); + v1 += fixpoint_mul(stru_5C6E00->Sin(angle), 5 * pParty->uWalkSpeed * fWalkSpeedMultiplier); + party_walking_flag = true; + break; + case PARTY_WalkBackward: + v2 -= fixpoint_mul(stru_5C6E00->Cos(angle), pParty->uWalkSpeed * fBackwardWalkSpeedMultiplier); + v1 -= fixpoint_mul(stru_5C6E00->Sin(angle), pParty->uWalkSpeed * fBackwardWalkSpeedMultiplier); + party_walking_flag = true; + break; + case PARTY_RunForward: + v2 += fixpoint_mul(stru_5C6E00->Cos(angle), 2 * pParty->uWalkSpeed * fWalkSpeedMultiplier); + v1 += fixpoint_mul(stru_5C6E00->Sin(angle), 2 * pParty->uWalkSpeed * fWalkSpeedMultiplier); + party_running_flag = true; + break; + case PARTY_RunBackward: + //v32 = stru_5C6E00->SinCos(angle); + //v33 = (double)v81; + //v88 = (double)v81; + v2 -= fixpoint_mul(stru_5C6E00->Cos(angle), pParty->uWalkSpeed * fBackwardWalkSpeedMultiplier); + //v34 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi); + v1 -= fixpoint_mul(stru_5C6E00->Sin(angle), pParty->uWalkSpeed * fBackwardWalkSpeedMultiplier); + party_running_flag = true; + break; + case PARTY_LookUp: + _view_angle += (signed __int64)(flt_6BE150_look_up_down_dangle * 25.0); + if ( _view_angle > 128 ) + _view_angle = 128; + if ( uActiveCharacter ) + pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)SPEECH_63, 0); + break; + case PARTY_LookDown: + _view_angle += (signed __int64)(flt_6BE150_look_up_down_dangle * -25.0); + if ( _view_angle < -128 ) + _view_angle = -128; + if ( uActiveCharacter ) + pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)SPEECH_64, 0); + break; + case PARTY_CenterView: + _view_angle = 0; + break; + case PARTY_Jump: + 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); + } + break; + default: + break; + } + } + pParty->sRotationY = angle; + pParty->sRotationX = _view_angle; + if ( bJumping ) + { + pParty->uFallSpeed += -2 * pEventTimer->uTimeElapsed * GetGravityStrength(); + if ( bJumping && pParty->uFallSpeed <= 0 ) + { + if ( pParty->uFallSpeed < -500 && !pParty->bFlying ) + { + for ( uint pl = 1; pl <= 4; pl++ ) + { + if ( !pPlayers[pl]->HasEnchantedItemEquipped(72) + && !pPlayers[pl]->WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, EQUIP_BOOTS) ) //was 8 + pPlayers[pl]->PlayEmotion(CHARACTER_EXPRESSION_SCARED, 0); + } + } + } + else + pParty->uFallStartY = party_z; + } + else + { + if ( pIndoor->pFaces[uFaceID].pFacePlane_old.vNormal.z < 32768 ) + { + pParty->uFallSpeed -= pEventTimer->uTimeElapsed * GetGravityStrength(); + pParty->uFallStartY = party_z; + } + else + { + if (! (pParty->uFlags & PARTY_FLAGS_1_LANDING) ) + pParty->uFallSpeed = 0; + pParty->uFallStartY = party_z; + } + } + if ( v2 * v2 + v1 * v1 < 400 ) + { + v1 = 0; + v2 = 0; + } + + stru_721530.field_84 = -1; + stru_721530.field_70 = 0; + stru_721530.prolly_normal_d = pParty->field_14_radius; + stru_721530.field_8_radius = pParty->field_14_radius / 2; + stru_721530.field_0 = 1; + stru_721530.height = pParty->uPartyHeight - 32; + for ( uint i = 0; i < 100; i++ ) + { + new_party_z = party_z; + stru_721530.position.x = new_party_x; + stru_721530.position.y = new_party_y; + stru_721530.position.z = stru_721530.height + party_z + 1; + + stru_721530.normal.x = new_party_x; + stru_721530.normal.y = new_party_y; + stru_721530.normal.z = stru_721530.prolly_normal_d + party_z + 1; + + stru_721530.velocity.x = v2; + stru_721530.velocity.y = v1; + stru_721530.velocity.z = pParty->uFallSpeed; + + stru_721530.uSectorID = uSectorID; + v38 = 0; + if ( pParty->bTurnBasedModeOn == true && pTurnEngine->turn_stage == 3 ) + v38 = 13312; + if ( stru_721530._47050A(v38) ) + break; + for ( uint j = 0; j < 100; ++j ) + { + _46E44E_collide_against_faces_and_portals(1); + _46E0B2_collide_against_decorations(); + for ( v80 = 0; v80 < (signed int)uNumActors; ++v80 ) + Actor::_46DF1A_collide_against_actor(v80, 0); + if ( _46F04E_collide_against_portals() ) + break; + } + if ( stru_721530.field_7C >= stru_721530.field_6C ) + { + v39 = stru_721530.normal2.x; + uSectorID = stru_721530.normal2.y; + v40 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1; + } + else + { + v39 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.x) >> 16) + new_party_x; + uSectorID = new_party_y + ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.y) >> 16); + v40 = new_party_z + ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.z) >> 16); + } + v42 = collide_against_floor(v39, uSectorID, v40 + 40, &stru_721530.uSectorID, &uFaceID); + if ( v42 == -30000 || v42 - new_party_z > 128 ) + return; + if ( stru_721530.field_7C >= stru_721530.field_6C ) + { + new_party_x = stru_721530.normal2.x; + new_party_y = stru_721530.normal2.y; + new_party_z = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1; + break; + } + new_party_x += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.x) >> 16; + new_party_y += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.y) >> 16; + uSectorID = stru_721530.uSectorID; + stru_721530.field_70 += stru_721530.field_7C; + unsigned long long v87 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.z) >> 16) + new_party_z; + if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Actor) + { + if ( SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) >= 0 + && (SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime)) ) + pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset(); + viewparams->bRedrawGameUI = true; + } + else if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration) + { + v54 = stru_5C6E00->Atan2(new_party_x - pLevelDecorations[stru_721530.uFaceID >> 3].vPosition.x, + new_party_y - pLevelDecorations[stru_721530.uFaceID >> 3].vPosition.y); + v2 = (unsigned __int64)(stru_5C6E00->Cos(v54) * (signed __int64)integer_sqrt(v2 * v2 + v1 * v1)) >> 16; + v1 = (unsigned __int64)(stru_5C6E00->Sin(v54) * (signed __int64)integer_sqrt(v2 * v2 + v1 * v1)) >> 16; + } + else + { + if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_BModel) + { + pFace = &pIndoor->pFaces[(signed int)stru_721530.uFaceID >> 3]; + if ( pFace->uPolygonType == POLYGON_Floor ) + { + if ( pParty->uFallSpeed < 0 ) + pParty->uFallSpeed = 0; + v87 = pIndoor->pVertices[*pFace->pVertexIDs].z + 1; + if ( pParty->uFallStartY - v87 < 512 ) + pParty->uFallStartY = v87; + if ( v2 * v2 + v1 * v1 < 400 ) + { + v1 = 0; + v2 = 0; + } + if ( pParty->floor_face_pid != PID_ID(stru_721530.uFaceID) && BYTE3(pFace->uAttributes) & 4 ) + uFaceEvent = pIndoor->pFaceExtras[pFace->uFaceExtraID].uEventID; + } + else + { + v46 = pParty->uFallSpeed * pFace->pFacePlane_old.vNormal.z; + if ( pFace->uPolygonType != POLYGON_InBetweenFloorAndWall ) + { + v80 = abs(v1 * pFace->pFacePlane_old.vNormal.y + v46 + v2 * pFace->pFacePlane_old.vNormal.x) >> 16; + if ((stru_721530.speed >> 3) > v80 ) + v80 = stru_721530.speed >> 3; + v2 += (unsigned __int64)(v80 * (signed __int64)pFace->pFacePlane_old.vNormal.x) >> 16; + v1 += (unsigned __int64)(v80 * (signed __int64)pFace->pFacePlane_old.vNormal.y) >> 16; + pParty->uFallSpeed += (unsigned __int64)(v80 * (signed __int64)pFace->pFacePlane_old.vNormal.z) >> 16; + //v80 = pFace->pFacePlane_old.vNormal.y; + v52 = stru_721530.prolly_normal_d - ((pFace->pFacePlane_old.dist + + v87 * pFace->pFacePlane_old.vNormal.z + + new_party_y * pFace->pFacePlane_old.vNormal.y + + new_party_x * pFace->pFacePlane_old.vNormal.x) >> 16); + if ( v52 > 0 ) + { + new_party_x += v52 * pFace->pFacePlane_old.vNormal.x >> 16; + new_party_y += v52 * pFace->pFacePlane_old.vNormal.y >> 16; + v87 += v52 * pFace->pFacePlane_old.vNormal.z >> 16; + } + if ( pParty->floor_face_pid != PID_ID(stru_721530.uFaceID) && BYTE3(pFace->uAttributes) & 4 ) + uFaceEvent = pIndoor->pFaceExtras[pFace->uFaceExtraID].uEventID; + } + if ( pFace->uPolygonType == POLYGON_InBetweenFloorAndWall ) + { + v80 = abs(v1 * pFace->pFacePlane_old.vNormal.y + v46 + v2 * pFace->pFacePlane_old.vNormal.x) >> 16; + if ((stru_721530.speed >> 3) > v80 ) + v80 = stru_721530.speed >> 3; + v2 += (unsigned __int64)(v80 * (signed __int64)pFace->pFacePlane_old.vNormal.x) >> 16; + v1 += (unsigned __int64)(v80 * (signed __int64)pFace->pFacePlane_old.vNormal.y) >> 16; + pParty->uFallSpeed += (unsigned __int64)(v80 * (signed __int64)pFace->pFacePlane_old.vNormal.z) >> 16; + if ( v2 * v2 + v1 * v1 >= 400 ) + { + if ( pParty->floor_face_pid != PID_ID(stru_721530.uFaceID) && BYTE3(pFace->uAttributes) & 4 ) + uFaceEvent = pIndoor->pFaceExtras[pFace->uFaceExtraID].uEventID; + } + else + { + v2 = 0; + v1 = 0; + pParty->uFallSpeed = 0; + } + } + } + } + } + v2 = (unsigned __int64)(58500i64 * v2) >> 16; + v1 = (unsigned __int64)(58500i64 * v1) >> 16; + //++v83; + pParty->uFallSpeed = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16; + //if ( v83 >= 100 ) + //{ + //new_party_z = v87; + //break; + //} + } + + // //Âîñïðîèçâåäåíèå çâóêîâ õîäüáû/áåãà------------------------- + uint pX_ = pParty->vPosition.x - new_party_x; + uint pY_ = pParty->vPosition.y - new_party_y; + uint pZ_ = pParty->vPosition.z - new_party_z; + if ( bWalkSound && pParty->walk_sound_timer <= 0 ) + { + pAudioPlayer->_4AA258(804);//stop sound + if ( party_running_flag && (!bJumping || jumping_up) ) //äëÿ áåãà + { + if ( integer_sqrt(pX_ * pX_ + pY_ * pY_ + pZ_ * pZ_) >= 16 ) + { + if ( on_water ) + pAudioPlayer->PlaySound(SOUND_RunAlongWater, 804, 1, -1, 0, 0, 0, 0); + else if ( BYTE2(pIndoor->pFaces[uFaceID].uAttributes) & 0x20 ) + pAudioPlayer->PlaySound((SoundID)50, 804, 1, -1, 0, 0, 0, 0); + else + pAudioPlayer->PlaySound(SOUND_RunAlong3DModel, 804, 1, -1, 0, 0, 0, 0); + pParty->walk_sound_timer = 64; + } + } + else if ( party_walking_flag && (!bJumping || jumping_up) )//äëÿ õîäüáû + { + if ( integer_sqrt(pX_ * pX_ + pY_ * pY_ + pZ_ * pZ_) >= 8 ) + { + if ( on_water ) + pAudioPlayer->PlaySound(SOUND_WalkAlongWater, 804, 1, -1, 0, 0, 0, 0); + else if ( BYTE2(pIndoor->pFaces[uFaceID].uAttributes) & 0x20 ) + pAudioPlayer->PlaySound((SoundID)89, 804, 1, -1, 0, 0, 0, 0); + else + pAudioPlayer->PlaySound(SOUND_WalkAlong3DModel, 804, 1, -1, 0, 0, 0, 0); + pParty->walk_sound_timer = 64; + } + } + } + if ( integer_sqrt(pX_ * pX_ + pY_ * pY_ + pZ_ * pZ_) < 8 )//îòêëþ÷èòü çâóê õîäüáû ïðè îñòàíîâêå + pAudioPlayer->_4AA258(804); + //------------------------------------------------------------- + if ( !bJumping || jumping_up ) + pParty->uFlags &= ~PARTY_FLAGS_1_FALLING; + else + pParty->uFlags |= PARTY_FLAGS_1_FALLING; + pParty->uFlags &= ~0x200; + pParty->vPosition.x = new_party_x; + pParty->vPosition.z = new_party_z; + pParty->vPosition.y = new_party_y; + //pParty->uFallSpeed = v89; + if ( !bJumping && BYTE3(pIndoor->pFaces[uFaceID].uAttributes) & 0x40 ) + pParty->uFlags |= 0x200; + if (uFaceEvent) + EventProcessor(uFaceEvent, 0, 1); } \ No newline at end of file
--- a/Indoor.h Tue Dec 03 16:35:57 2013 +0600 +++ b/Indoor.h Thu Jan 02 09:11:01 2014 +0600 @@ -235,7 +235,7 @@ #define FACE_TEXTURE_FRAME 0x00004000 // Texture ID is a frameset from TextureFrameTable, otherwise BitmapID #define FACE_OUTLINED 0x00010000 // outline face edges #define FACE_TEXTURE_FLOW 0x00040000 // The texture moves slowly. For horizontal facets only. -#define FACE_INDOOR_SKY 0x00400000 +#define FACE_INDOOR_SKY 0x00400000 #define FACE_CLICKABLE 0x02000000 // Event can be triggered by clicking on the facet. #define FACE_PRESSURE_PLATE 0x04000000 // Event can be triggered by stepping on the facet. #define FACE_ETHEREAL 0x20000000 // Untouchable. You can pass through it.
--- a/Items.h Tue Dec 03 16:35:57 2013 +0600 +++ b/Items.h Thu Jan 02 09:11:01 2014 +0600 @@ -30,6 +30,7 @@ ITEM_AURA_EFFECT_BLUE = 0x20,//32 ITEM_AURA_EFFECT_GREEN = 0x40,//64 ITEM_AURA_EFFECT_PURPLE = 0x80,//128 + ITEM_ENCHANT_ANIMATION = 0xF0,//240 ITEM_STOLEN = 0x100, ITEM_HARDENED = 0x200, };
--- a/Outdoor.cpp Tue Dec 03 16:35:57 2013 +0600 +++ b/Outdoor.cpp Thu Jan 02 09:11:01 2014 +0600 @@ -3152,12 +3152,11 @@ int v24; // eax@36 signed int v25; // ecx@38 int result; // eax@42 - signed int v27; // ecx@43 + signed int current_floor_level; // ecx@43 int v28; // edi@44 signed int v29; // edx@44 int v30; // esi@45 int v31; // eax@45 - ODMFace *v32; // eax@57 int v33; // ecx@59 int v36; // [sp+14h] [bp-2Ch]@24 int v38; // [sp+1Ch] [bp-24h]@2 @@ -3168,7 +3167,7 @@ bool next_vertices_Y; // [sp+34h] [bp-Ch]@24 signed int v46; // [sp+3Ch] [bp-4h]@1 signed int number_hits; // [sp+58h] [bp+18h]@22 - signed int v49; // [sp+58h] [bp+18h]@43 + signed int next_floor_level; // [sp+58h] [bp+18h]@43 v46 = 1; dword_721160[0] = -1; @@ -3187,23 +3186,24 @@ for ( pFaceNum = 0; pFaceNum < pBModel->uNumFaces; ++pFaceNum ) { pFace = &pBModel->pFaces[pFaceNum]; + if ( pFace->Ethereal() ) + continue; if ( (pFace->uPolygonType == POLYGON_Floor || pFace->uPolygonType == POLYGON_InBetweenFloorAndWall) - && !(pFace->uAttributes & 0x20000000) && X <= pFace->pBoundingBox.x2 && X >= pFace->pBoundingBox.x1 && Y <= pFace->pBoundingBox.y2 && Y >= pFace->pBoundingBox.y1 ) { for ( uint i = 0; i < pFace->uNumVertices; ++i) { - FloorFaceVertCoord_X[2 * i] = pFace->pXInterceptDisplacements[i] + pBModel->pVertices.pVertices[pFace->pVertexIDs[i]].x; - FloorFaceVertCoord_Y[2 * i] = pFace->pXInterceptDisplacements[i] + pBModel->pVertices.pVertices[pFace->pVertexIDs[i]].y; - FloorFaceVertCoord_X[2 * i + 1] = pFace->pXInterceptDisplacements[i + 1] + pBModel->pVertices.pVertices[pFace->pVertexIDs[i + 1]].x; - FloorFaceVertCoord_Y[2 * i + 1] = pFace->pXInterceptDisplacements[i + 1] + pBModel->pVertices.pVertices[pFace->pVertexIDs[i + 1]].y; + odm_floor_face_vert_coord_X[2 * i] = pFace->pXInterceptDisplacements[i] + pBModel->pVertices.pVertices[pFace->pVertexIDs[i]].x; + odm_floor_face_vert_coord_Y[2 * i] = pFace->pXInterceptDisplacements[i] + pBModel->pVertices.pVertices[pFace->pVertexIDs[i]].y; + odm_floor_face_vert_coord_X[2 * i + 1] = pFace->pXInterceptDisplacements[i + 1] + pBModel->pVertices.pVertices[pFace->pVertexIDs[i + 1]].x; + odm_floor_face_vert_coord_Y[2 * i + 1] = pFace->pXInterceptDisplacements[i + 1] + pBModel->pVertices.pVertices[pFace->pVertexIDs[i + 1]].y; } - FloorFaceVertCoord_X[2 * pFace->uNumVertices] = FloorFaceVertCoord_X[0]; - FloorFaceVertCoord_Y[2 * pFace->uNumVertices] = FloorFaceVertCoord_Y[0]; - - current_vertices_Y = FloorFaceVertCoord_Y[0] >= Y; + odm_floor_face_vert_coord_X[2 * pFace->uNumVertices] = odm_floor_face_vert_coord_X[0]; + odm_floor_face_vert_coord_Y[2 * pFace->uNumVertices] = odm_floor_face_vert_coord_Y[0]; + + current_vertices_Y = odm_floor_face_vert_coord_Y[0] >= Y; number_hits = 0; if ( 2 * pFace->uNumVertices > 0 ) { @@ -3211,21 +3211,22 @@ { if ( number_hits >= 2 ) break; - v36 = FloorFaceVertCoord_Y[i + 1]; - next_vertices_Y = FloorFaceVertCoord_Y[i + 1] >= Y; + //v36 = odm_floor_face_vert_coord_Y[i + 1]; + next_vertices_Y = odm_floor_face_vert_coord_Y[i + 1] >= Y; if ( current_vertices_Y != next_vertices_Y )//ïðîâåðêà ïî Y { - v18 = FloorFaceVertCoord_X[i + 1] >= X ? 0 : 2; - v19 = v18 | (FloorFaceVertCoord_X[i] < X); + v18 = odm_floor_face_vert_coord_X[i + 1] >= X ? 0 : 2; + v19 = v18 | (odm_floor_face_vert_coord_X[i] < X); if ( v19 != 3 ) { if ( !v19 ) ++number_hits; else { - LODWORD(v23) = (Y - FloorFaceVertCoord_Y[i]) << 16; - HIDWORD(v23) = (Y - FloorFaceVertCoord_Y[i]) >> 16; - v22 = ((((FloorFaceVertCoord_X[i + 1] - FloorFaceVertCoord_X[i]) * v23 / (v36 - FloorFaceVertCoord_Y[i])) >> 16) + FloorFaceVertCoord_X[i]); + LODWORD(v23) = (Y - odm_floor_face_vert_coord_Y[i]) << 16; + HIDWORD(v23) = (Y - odm_floor_face_vert_coord_Y[i]) >> 16; + v22 = ((((odm_floor_face_vert_coord_X[i + 1] - odm_floor_face_vert_coord_X[i]) * v23 / (odm_floor_face_vert_coord_Y[i + 1] + - odm_floor_face_vert_coord_Y[i])) >> 16) + odm_floor_face_vert_coord_X[i]); if ( v22 >= X) ++number_hits; } @@ -3259,51 +3260,43 @@ *bmodel_pid = 0; return odm_floor_level[0]; } - v27 = 0; + current_floor_level = 0; + v29 = 0; if ( v46 <= 1 ) *bmodel_pid = 0; else { - //v29 = 1; - for ( v49 = 1; v49 < v46; ++v49 ) + current_floor_level = odm_floor_level[0]; + for ( uint i = 1; i < v46; ++i ) { - if ( odm_floor_level[v49] == odm_floor_level[0] ) - { - v27 = v49; - //++v29; - break; - } - if ( odm_floor_level[0] > Z + 5 ) + next_floor_level = odm_floor_level[i]; + if ( current_floor_level <= Z + 5 ) { - if ( odm_floor_level[v49] >= odm_floor_level[0] ) + if ( next_floor_level > current_floor_level && next_floor_level <= Z + 5 ) { - //++v29; - break; + current_floor_level = next_floor_level; + v29 = i; } - v27 = v49; - //++v29; - break; } - if ( odm_floor_level[v49] > odm_floor_level[0] && odm_floor_level[v49] <= Z + 5 ) + else if ( next_floor_level < current_floor_level ) { - v27 = v49; - //++v29; + current_floor_level = next_floor_level; + v29 = i; } } - if ( !v27 ) + if ( !v29 ) *bmodel_pid = 0; else - *bmodel_pid = dword_721110[v27] | (dword_721160[v27] << 6); + *bmodel_pid = dword_721110[v29] | (dword_721160[v29] << 6); } - if ( v27 ) + if ( v29 ) { - v32 = &pOutdoor->pBModels[dword_721160[v27]].pFaces[dword_721110[v27]]; *pIsOnWater = false; - if ( v32->Fluid()) + if ( pOutdoor->pBModels[dword_721160[v29]].pFaces[dword_721110[v29]].Fluid()) *pIsOnWater = true; } - if ( odm_floor_level[v27] >= odm_floor_level[0] ) - odm_floor_level[0] = odm_floor_level[v27]; + if ( odm_floor_level[v29] >= odm_floor_level[0] ) + odm_floor_level[0] = odm_floor_level[v29]; return odm_floor_level[0]; } @@ -3652,7 +3645,7 @@ { int v1; // edi@1 int v2; // ebx@1 - int v3; // eax@14 + int floor_level; // eax@14 int v6; // esi@45 ODMFace *face; // ecx@45 signed int v33; // eax@143 @@ -3670,28 +3663,16 @@ BSPModel *pModel; // eax@203 ODMFace *pODMFace; // esi@203 int v48; // eax@203 - char v49; // zf@203 - char v50; // sf@203 - unsigned __int8 v51; // of@203 - int v52; // eax@203 BSPModel *v54; // eax@215 int v55; // eax@217 - signed int v56; // ebx@228 - int v57; // eax@228 BSPModel *v58; // eax@228 unsigned __int64 v59; // qax@228 BSPModel *v60; // eax@228 unsigned __int64 v61; // qax@228 int v62; // eax@241 - unsigned int v65; // ebx@263 unsigned int v66; // esi@263 - int v67; // eax@263 signed int v68; // ecx@263 int v69; // eax@263 - int v70; // ebx@271 - int v71; // esi@271 - int v72; // edi@271 - int v73; // eax@271 unsigned int v76; // edi@293 bool v77; // edx@297 bool v78; // ecx@303 @@ -3717,7 +3698,7 @@ bool bFeatherFall; // [sp+28h] [bp-6Ch]@4 int v105; // [sp+2Ch] [bp-68h]@24 bool bWaterWalk; // [sp+30h] [bp-64h]@1 - int v109; // [sp+3Ch] [bp-58h]@28 + int ceiling_height; // [sp+3Ch] [bp-58h]@28 int v110; // [sp+40h] [bp-54h]@180 int v111; // [sp+44h] [bp-50h]@14 bool hovering; // [sp+48h] [bp-4Ch]@1 @@ -3732,7 +3713,6 @@ int pZ; // [sp+74h] [bp-20h]@1 bool party_walking_flag; // [sp+78h] [bp-1Ch]@1 int _angle_y; // [sp+7Ch] [bp-18h]@48 - int v126; // [sp+80h] [bp-14h]@48 int v128; // [sp+88h] [bp-Ch]@1 int v129; // [sp+8Ch] [bp-8h]@92 @@ -3780,15 +3760,16 @@ int bmodel_standing_on_pid; int is_on_water = false; - v3 = ODM_GetFloorLevel(pX, pY, pZ, pParty->uPartyHeight, &is_on_water, &bmodel_standing_on_pid, bWaterWalk); + floor_level = ODM_GetFloorLevel(pX, pY, pZ, pParty->uPartyHeight, &is_on_water, &bmodel_standing_on_pid, bWaterWalk); int is_not_on_bmodel = bmodel_standing_on_pid == 0; - v111 = v3; + v111 = floor_level; if ( bFeatherFall ) - pParty->uFallStartY = v3; + pParty->uFallStartY = floor_level; else - v3 = pParty->uFallStartY; - if ( v3 - pZ > 512 && !bFeatherFall && pZ <= v111 + 1 ) + floor_level = pParty->uFallStartY; + + if ( floor_level - pZ > 512 && !bFeatherFall && pZ <= v111 + 1 )//ïàäåíèå íà 3D Model { if (pParty->uFlags & PARTY_FLAGS_1_LANDING) { @@ -3803,18 +3784,17 @@ v105 = 20 - pParty->pPlayers[i].GetParameterBonus(pParty->pPlayers[i].GetActualEndurance()); pParty->pPlayers[i].SetRecoveryTime((signed __int64)((double)v105 * flt_6BE3A4_debug_recmod1 * 2.133333333333333)); } - //} - //while ( (signed int)v4 <= (signed int)&pPlayers[4] ); } } - v109 = -1; + + ceiling_height = -1; if ( pParty->bFlying ) - v109 = GetCeilingHeight(pX, pY, pZ + pParty->uPartyHeight, (int)&v102); + ceiling_height = GetCeilingHeight(pX, pY, pZ + pParty->uPartyHeight, (int)&v102);//âûñîòà ïîòîëêà //v107 = bmodel_standing_on_pid == 0; v105 = v111 + 1; if ( pZ <= v111 + 1 ) { - v109 = -1; + ceiling_height = -1; pParty->bFlying = false; } else @@ -3849,7 +3829,7 @@ if ( BYTE3(face[v6].uAttributes) & 4 ) { pParty->floor_face_pid = PID(OBJECT_BModel, bmodel_standing_on_pid); - v103 = face[v6].sCogTriggeredID; + v103 = face[v6].sCogTriggeredID; // } } } @@ -3859,7 +3839,7 @@ _walk_speed = pParty->uWalkSpeed; _angle_y = pParty->sRotationY; _angle_x = pParty->sRotationX; - v126 = pEventTimer->dt_in_some_format; + //v126 = pEventTimer->dt_in_some_format; /*v119 = (Player **)((unsigned __int64)(pEventTimer->dt_in_some_format * (signed __int64)((signed int)(pParty->field_20_prolly_turn_speed * stru_5C6E00->uIntegerPi) @@ -3894,16 +3874,16 @@ v2 = 0; pParty->uFallSpeed = 0; *(float *)&v128 = 0.0; - if ( v102 && pZ < v109 && (signed int)(pParty->uPartyHeight + pZ) >= v109 )//ñâåðèòü ñ èäà(îøèáêà) + if ( v102 && pZ < ceiling_height && (signed int)(pParty->uPartyHeight + pZ) >= ceiling_height )//ñòîëêíîâåíèå ñ ïîòîëêîì(îøèáêà) { pParty->field_6E0 = 0; pParty->field_6E4 = 0; pPartyActionQueue->uNumActions = 0; pParty->uFlags |= PARTY_FLAGS_1_LANDING; - pParty->vPosition.z = v109 - pParty->uPartyHeight - 31; + pParty->vPosition.z = ceiling_height - pParty->uPartyHeight - 31; pParty->field_6F0 = pZ; pParty->bFlying = false; - pZ = v109 - pParty->uPartyHeight - 31; + pZ = ceiling_height - pParty->uPartyHeight - 31; v113 = pParty->field_6F0; } pParty->uFallSpeed = 0; @@ -4136,7 +4116,7 @@ case PARTY_Jump: if ( (!partyAtHighSlope || bmodel_standing_on_pid) && !hovering && pParty->field_24 && !(pParty->uFlags & 4) && !(BYTE1(pParty->uFlags) & 2) ) { - v126 = pParty->field_24 << 6; + //v126 = pParty->field_24 << 6; hovering = true; pParty->uFallSpeed = (signed __int64)((double)(pParty->field_24 << 6) * 1.5 + (double)pParty->uFallSpeed); } @@ -4159,15 +4139,14 @@ } } -//LABEL_123: pParty->sRotationY = _angle_y; pParty->sRotationX = _angle_x; if ( pZ < v111 || pParty->bFlying) { if ( pParty->bFlying ) { - v126 = stru_5C6E00->Cos(GetTickCount()); - v129 = (unsigned __int64)(4i64 * v126) >> 16; + //v126 = stru_5C6E00->Cos(GetTickCount()); + v129 = (unsigned __int64)(4i64 * stru_5C6E00->Cos(GetTickCount())) >> 16; pZ = v113 + v129; if ( pModel ) pZ = v113; @@ -4244,45 +4223,45 @@ } } else - { -//LABEL_150: - pParty->uFallStartY = pZ; - } + pParty->uFallStartY = pZ; if ( v2 * v2 + v1 * v1 < 400 && !partyAtHighSlope ) { *(float *)&v128 = 0.0; v2 = 0; } +//--------------------------------------------------------------------- stru_721530.field_84 = -1; stru_721530.field_70 = 0; stru_721530.prolly_normal_d = pParty->field_14_radius; stru_721530.field_8_radius = pParty->field_14_radius >> 1; - v126 = 0; stru_721530.field_0 = 1; stru_721530.height = pParty->uPartyHeight - 32; - do + for ( uint i = 0; i < 100; i++ ) { stru_721530.position.x = pX; + stru_721530.position.y = pY; + stru_721530.position.z = stru_721530.height + pZ + 1; + stru_721530.normal.x = pX; - stru_721530.velocity.x = v2; - stru_721530.position.y = pY; stru_721530.normal.y = pY; stru_721530.normal.z = stru_721530.prolly_normal_d + pZ + 1; - stru_721530.position.z = stru_721530.height + pZ + 1; + + stru_721530.velocity.x = v2; stru_721530.velocity.y = v128; stru_721530.velocity.z = pParty->uFallSpeed; - v36 = 0; + stru_721530.uSectorID = 0; - if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->turn_stage == 3 ) + v36 = 0; + if ( pParty->bTurnBasedModeOn == true && pTurnEngine->turn_stage == 3 ) v36 = 13312; if ( stru_721530._47050A(v36) ) break; - _46E889_collide_against_bmodels(1u); + _46E889_collide_against_bmodels(1); v37 = WorldPosToGridCellZ(pParty->vPosition.y); v38 = WorldPosToGridCellX(pParty->vPosition.x); _46E26D_collide_against_sprites(v38, v37); - _46ED8A_collide_against_sprite_objects(4u); + _46ED8A_collide_against_sprite_objects(4); for ( i = 0; i < (signed int)uNumActors; ++i ) Actor::_46DF1A_collide_against_actor(i, 0); if ( stru_721530.field_7C >= stru_721530.field_6C ) @@ -4305,43 +4284,43 @@ pModel = (BSPModel *)IsTerrainSlopeTooHigh(_angle_x, pY); v42 = IsTerrainSlopeTooHigh(pX, _angle_y); is_not_on_bmodel = false; - v118 = v42; + //v118 = v42; if ( !v97 && !v110 && !bmodel_standing_on_pid ) is_not_on_bmodel = true; v43 = 1; v44 = 1; if ( bUnderwater || !is_not_on_bmodel ) - { - pX = _angle_x; - if ( v43 ) - pY = _angle_y; - } - else - { - if ( pModel && v129 > pZ ) - v44 = 0; - if ( v118 && v119 > pZ ) - v43 = 0; - if ( v44 ) - { - pX = _angle_x; - if ( v43 ) - pY = _angle_y; - } - else if ( v43 ) - pY = _angle_y; - else - { - pModel = (BSPModel *)ODM_GetFloorLevel(_angle_x, _angle_y, v40, pParty->uPartyHeight, &is_on_water, &bmodel_standing_on_pid, 0); - if ( IsTerrainSlopeTooHigh(_angle_x, _angle_y) && (signed int)pModel <= pZ ) - { - v43 = 1; - pX = _angle_x; - if ( v43 ) - pY = _angle_y; - } - } - } + { + pX = _angle_x; + if ( v43 ) + pY = _angle_y; + } + else + { + if ( pModel && v129 > pZ ) + v44 = 0; + if ( v42 && v119 > pZ ) + v43 = 0; + if ( v44 ) + { + pX = _angle_x; + if ( v43 ) + pY = _angle_y; + } + else if ( v43 ) + pY = _angle_y; + else + { + pModel = (BSPModel *)ODM_GetFloorLevel(_angle_x, _angle_y, v40, pParty->uPartyHeight, &is_on_water, &bmodel_standing_on_pid, 0); + if ( IsTerrainSlopeTooHigh(_angle_x, _angle_y) && (signed int)pModel <= pZ ) + { + v43 = 1; + pX = _angle_x; + if ( v43 ) + pY = _angle_y; + } + } + } if ( stru_721530.field_7C >= stru_721530.field_6C ) { if ( !is_not_on_bmodel ) @@ -4363,29 +4342,22 @@ pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset(); viewparams->bRedrawGameUI = true; - v2 = (unsigned __int64)(58500i64 * v2) >> 16; - pModel = (BSPModel *)58500; - v128 = (unsigned __int64)(58500i64 * v128) >> 16; - v122 = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16; - ++v126; - pParty->uFallSpeed = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16; - continue; - } + v2 = (unsigned __int64)(58500i64 * v2) >> 16; + pModel = (BSPModel *)58500; + v128 = (unsigned __int64)(58500i64 * v128) >> 16; + v122 = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16; + pParty->uFallSpeed = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16; + continue; + } if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration) { - v56 = integer_sqrt(v2 * v2 + v128 * v128); - v118 = v56; - v57 = stru_5C6E00->Atan2(_angle_x - pLevelDecorations[(signed int)stru_721530.uFaceID >> 3].vPosition.x, + //v118 = integer_sqrt(v2 * v2 + v128 * v128); + v129 = stru_5C6E00->Atan2(_angle_x - pLevelDecorations[(signed int)stru_721530.uFaceID >> 3].vPosition.x, _angle_y - pLevelDecorations[(signed int)stru_721530.uFaceID >> 3].vPosition.y); - v129 = v57; - v58 = (BSPModel *)stru_5C6E00->Cos(v57); - pModel = v58; - v59 = (signed int)v58 * (signed __int64)v56; + v59 = (signed int)stru_5C6E00->Cos(v129) * (signed __int64)integer_sqrt(v2 * v2 + v128 * v128); v122 = v59 >> 16; v2 = v59 >> 16; - v60 = (BSPModel *)stru_5C6E00->Sin(v129); - pModel = v60; - v61 = (signed int)v60 * (signed __int64)v118; + v61 = (signed int)stru_5C6E00->Sin(v129) * (signed __int64)integer_sqrt(v2 * v2 + v128 * v128); v122 = v61 >> 16; v128 = v61 >> 16; } @@ -4395,15 +4367,10 @@ { pParty->bFlying = false; pModel = &pOutdoor->pBModels[(signed int)stru_721530.uFaceID >> 9]; - //v127 = v46; pODMFace = &pModel->pFaces[((signed int)stru_721530.uFaceID >> 3) & 0x3F]; v48 = pODMFace->pBoundingBox.z2 - pODMFace->pBoundingBox.z1; - v51 = __OFSUB__(v48, 32); - v49 = v48 == 32; - v50 = v48 - 32 < 0; - v52 = pODMFace->pFacePlane.vNormal.z; - v129 = (unsigned __int8)(v50 ^ v51 | v49); - v119 = v52 < 46378; + v129 = v48 <= 32; + v119 = pODMFace->pFacePlane.vNormal.z < 46378; if ( bUnderwater == 1 ) v119 = 0; if ( pODMFace->uPolygonType == POLYGON_Floor ) @@ -4419,33 +4386,27 @@ if ( pParty->floor_face_pid != v45 && (pODMFace->uAttributes & FACE_PRESSURE_PLATE)) { pParty->floor_face_pid = v45; - v103 = pODMFace->sCogTriggeredID; + v103 = pODMFace->sCogTriggeredID; // } v2 = (unsigned __int64)(58500i64 * v2) >> 16; pModel = (BSPModel *)58500; v128 = (unsigned __int64)(58500i64 * v128) >> 16; v122 = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16; - ++v126; pParty->uFallSpeed = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16; continue; } if ( !v129 && (pODMFace->uPolygonType != POLYGON_InBetweenFloorAndWall || v119) )// óï¸ðñÿ â ñòîëá { - v118 = abs(v128 * pODMFace->pFacePlane.vNormal.y + pParty->uFallSpeed * v52 + v2 * pODMFace->pFacePlane.vNormal.x) >> 16; + v118 = abs(v128 * pODMFace->pFacePlane.vNormal.y + + pParty->uFallSpeed * pODMFace->pFacePlane.vNormal.z + + v2 * pODMFace->pFacePlane.vNormal.x) >> 16; if ((stru_721530.speed >> 3) > v118 ) v118 = stru_721530.speed >> 3; - v129 = (unsigned __int64)(v118 * (signed __int64)pODMFace->pFacePlane.vNormal.x) >> 16; - _walk_speed = (unsigned __int64)(v118 * (signed __int64)pODMFace->pFacePlane.vNormal.y) >> 16; + v2 += (unsigned __int64)(v118 * (signed __int64)pODMFace->pFacePlane.vNormal.x) >> 16; + v128 += (unsigned __int64)(v118 * (signed __int64)pODMFace->pFacePlane.vNormal.y) >> 16; v54 = 0; if ( !v119 ) - { - pModel = (BSPModel *)pODMFace->pFacePlane.vNormal.z; - pModel = (BSPModel *)((unsigned __int64)(v118 * (signed __int64)(signed int)pModel) >> 16); - v54 = pModel; - } - pParty->uFallSpeed += (int)v54; - v128 += _walk_speed; - v2 += v129; + pParty->uFallSpeed += (unsigned __int64)(v118 * (signed __int64)(signed int)pODMFace->pFacePlane.vNormal.z) >> 16; v55 = stru_721530.prolly_normal_d - ((signed int)(pODMFace->pFacePlane.dist + v122 * pODMFace->pFacePlane.vNormal.z @@ -4458,72 +4419,62 @@ if ( !v119 ) pZ = v122 + (pODMFace->pFacePlane.vNormal.z * v55 >> 16); } -//LABEL_220: - v45 = stru_721530.uFaceID; - if ( pParty->floor_face_pid != v45 && BYTE3(pODMFace->uAttributes) & 4 ) - { - pParty->floor_face_pid = v45; - v103 = pODMFace->sCogTriggeredID; - } - v2 = (unsigned __int64)(58500i64 * v2) >> 16; - pModel = (BSPModel *)58500; - v128 = (unsigned __int64)(58500i64 * v128) >> 16; - v122 = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16; - ++v126; - pParty->uFallSpeed = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16; - continue; + if ( pParty->floor_face_pid != stru_721530.uFaceID && BYTE3(pODMFace->uAttributes) & 4 ) + { + pParty->floor_face_pid = stru_721530.uFaceID; + v103 = pODMFace->sCogTriggeredID; // + } + v2 = (unsigned __int64)(58500i64 * v2) >> 16; + pModel = (BSPModel *)58500; + v128 = (unsigned __int64)(58500i64 * v128) >> 16; + v122 = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16; + pParty->uFallSpeed = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16; + continue; } - v118 = abs(v128 * pODMFace->pFacePlane.vNormal.y + pParty->uFallSpeed * v52 + v2 * pODMFace->pFacePlane.vNormal.x) >> 16; + v118 = abs(v128 * pODMFace->pFacePlane.vNormal.y + + pParty->uFallSpeed * pODMFace->pFacePlane.vNormal.z + v2 * pODMFace->pFacePlane.vNormal.x) >> 16; if ((stru_721530.speed >> 3) > v118 ) v118 = stru_721530.speed >> 3; - v122 = pODMFace->pFacePlane.vNormal.x; - v122 = (unsigned __int64)(v118 * (signed __int64)(signed int)v122) >> 16; - pModel = (BSPModel *)pODMFace->pFacePlane.vNormal.y; - pModel = (BSPModel *)((unsigned __int64)(v118 * (signed __int64)(signed int)pModel) >> 16); - v129 = pODMFace->pFacePlane.vNormal.z; - v129 = (unsigned __int64)(v118 * (signed __int64)v129) >> 16; - pParty->uFallSpeed += v129; - v2 += v122; - v128 += (int)pModel; + v2 += (unsigned __int64)(v118 * (signed __int64)(signed int)pODMFace->pFacePlane.vNormal.x) >> 16; + v128 += (unsigned __int64)(v118 * (signed __int64)(signed int)pODMFace->pFacePlane.vNormal.y) >> 16; + pParty->uFallSpeed += (unsigned __int64)(v118 * (signed __int64)pODMFace->pFacePlane.vNormal.z) >> 16; if ( v2 * v2 + v128 * v128 >= 400 ) - { - v45 = stru_721530.uFaceID; - if ( pParty->floor_face_pid != v45 && BYTE3(pODMFace->uAttributes) & 4 ) - { - pParty->floor_face_pid = v45; - v103 = pODMFace->sCogTriggeredID; - } - v2 = (unsigned __int64)(58500i64 * v2) >> 16; - pModel = (BSPModel *)58500; - v128 = (unsigned __int64)(58500i64 * v128) >> 16; - v122 = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16; - ++v126; - pParty->uFallSpeed = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16; - continue; - } + { + if ( pParty->floor_face_pid != stru_721530.uFaceID && BYTE3(pODMFace->uAttributes) & 4 ) + { + pParty->floor_face_pid = stru_721530.uFaceID; + v103 = pODMFace->sCogTriggeredID; // + } + v2 = (unsigned __int64)(58500i64 * v2) >> 16; + pModel = (BSPModel *)58500; + v128 = (unsigned __int64)(58500i64 * v128) >> 16; + v122 = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16; + //++v126; + pParty->uFallSpeed = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16; + continue; + } v2 = 0; pParty->uFallSpeed = 0; *(float *)&v128 = 0.0; } } -//LABEL_234: v2 = (unsigned __int64)(58500i64 * v2) >> 16; pModel = (BSPModel *)58500; v128 = (unsigned __int64)(58500i64 * v128) >> 16; v122 = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16; - ++v126; pParty->uFallSpeed = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16; } - while ( v126 < 100 ); - + + //Âîñïðîèçâåäåíèå çâóêîâ õîäüáû/áåãà------------------------ + v122 = abs(pParty->vPosition.x - pX); + uint pY_ = abs(pParty->vPosition.y - pY); + v62 = abs(pParty->vPosition.z - pZ); if ( bWalkSound && pParty->walk_sound_timer <= 0 ) { - v122 = abs(pParty->vPosition.x - pX); - v126 = abs(pParty->vPosition.y - pY); - v62 = abs(pParty->vPosition.z - pZ); - if ( integer_sqrt(v122 * v122 + v126 * v126 + v62 * v62) >= 8 ) + pAudioPlayer->_4AA258(804);//stop sound + if ( party_running_flag && (!hovering || high_fall_flag) ) { - if ( party_running_flag && (!hovering || !high_fall_flag) ) + if ( integer_sqrt(v122 * v122 + pY_ * pY_ + v62 * v62) >= 16 ) { if ( !is_not_on_bmodel && !(BYTE1(pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].uAttributes) & 0x20) ) @@ -4533,8 +4484,12 @@ v87 = pOutdoor->GetSoundIdByPosition(WorldPosToGridCellX(pParty->vPosition.x), WorldPosToGridCellZ(pParty->vPosition.y) - 1, 1); pAudioPlayer->PlaySound((SoundID)v87, 804, 1, -1, 0, 0, 0, 0);//áåã ïî çåìëå } + pParty->walk_sound_timer = 96;//òàéìåð äëÿ áåãà } - else if ( party_walking_flag && (!hovering || !high_fall_flag) ) + } + else if( party_walking_flag && (!hovering || high_fall_flag) ) + { + if ( integer_sqrt(v122 * v122 + pY_ * pY_ + v62 * v62) >= 8 ) { if ( is_not_on_bmodel || BYTE1(pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].uAttributes) & 0x20 ) @@ -4544,60 +4499,52 @@ } else pAudioPlayer->PlaySound(SOUND_WalkAlong3DModel, 804, 1, -1, 0, 0, 0, 0);// õîæäåíèå íà 3D Modelè + pParty->walk_sound_timer = 144;//òàéìåð äëÿ õîäüáû } } - else - { - pAudioPlayer->_4AA258(804); - pParty->walk_sound_timer = 64; - } } - + if ( integer_sqrt(v122 * v122 + pY_ * pY_ + v62 * v62) < 8 )//îòêëþ÷èòü çâóê õîäüáû ïðè îñòàíîâêå + pAudioPlayer->_4AA258(804); +//------------------------------------------------------------------------ if ( !hovering || !high_fall_flag ) pParty->uFlags &= ~PARTY_FLAGS_1_FALLING; else pParty->uFlags |= PARTY_FLAGS_1_FALLING; - v126 = WorldPosToGridCellX(pParty->vPosition.x); - v65 = WorldPosToGridCellZ(pParty->vPosition.y) - 1; + int pMap_X = WorldPosToGridCellX(pParty->vPosition.x); + int pMap_Y = WorldPosToGridCellZ(pParty->vPosition.y) - 1; unsigned int v114_a = WorldPosToGridCellX(pX); v66 = WorldPosToGridCellZ(pY) - 1; - pModel = (BSPModel *)((~(unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo(v126, v65) >> 1) & 1); - v122 = (~(unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo(v114_a, v65) >> 1) & 1; - v67 = pOutdoor->ActuallyGetSomeOtherTileInfo(v126, v66); + pModel = (BSPModel *)((~(unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo(pMap_X, pMap_Y) >> 1) & 1); + v122 = (~(unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo(v114_a, pMap_Y) >> 1) & 1; v68 = 0; - v69 = (~(unsigned int)v67 >> 1) & 1; - if ( v114_a == v126 && v66 == v65 && v122 && v69 ) + v69 = (~(unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo(pMap_X, v66) >> 1) & 1; + if ( v114_a == pMap_X && v66 == pMap_Y && v122 && v69 ) v68 = 1; if ( !is_not_on_bmodel ) v68 = 1; if ( v68 ) { - v70 = pZ; - v71 = pX; - v72 = pY; - //pParty->uFallSpeed = v121; - v73 = pZ; pParty->vPosition.x = pX; pParty->vPosition.y = pY; pParty->vPosition.z = pZ; pParty->field_6F0 = v113; if ( pZ > 8160 ) { - v73 = 8160; + pZ = 8160; pParty->uFallStartY = 8160; pParty->vPosition.z = 8160; } - if ( !v103 - || (EventProcessor(v103, 0, 1), pParty->vPosition.x == v71) - && pParty->vPosition.y == v72 - && (v73 = pParty->vPosition.z, pParty->vPosition.z == v70) ) + if ( !v103 //ïàäåíèå íà çåìëþ + || (EventProcessor(v103, 0, 1), pParty->vPosition.x == pX) + && pParty->vPosition.y == pY + && pParty->vPosition.z == pZ ) { - if ( v73 < v111 ) + if ( pParty->vPosition.z < v111 ) { pParty->uFallSpeed = 0; - v73 = v105; + //v73 = v105; pParty->vPosition.z = v105; - if ( pParty->uFallStartY - v70 > 512 && !bFeatherFall && v70 <= v105 && !bUnderwater )//Fall to the ground(ïàäåíèå íà çåìëþ ñ âûñîòû) + if ( pParty->uFallStartY - pZ > 512 && !bFeatherFall && pZ <= v105 && !bUnderwater )//Fall to the ground(ïàäåíèå íà çåìëþ ñ âûñîòû) { if ( pParty->uFlags & PARTY_FLAGS_1_LANDING ) { @@ -4608,22 +4555,22 @@ for ( uint i = 1; i <= 4; ++i ) { v110 = pPlayers[i]->GetMaxHealth(); - pPlayers[i]->ReceiveDamage((signed int)((pParty->uFallStartY - v70) * (unsigned __int64)(signed __int64)((double)v110 * 0.1)) / 256, + pPlayers[i]->ReceiveDamage((signed int)((pParty->uFallStartY - pZ) * (unsigned __int64)(signed __int64)((double)v110 * 0.1)) / 256, DMGT_PHISYCAL); v110 = 20 - pPlayers[i]->GetParameterBonus(pPlayers[i]->GetActualEndurance()); pPlayers[i]->SetRecoveryTime((signed __int64)((double)v110 * flt_6BE3A4_debug_recmod1 * 2.133333333333333)); } - v73 = pParty->vPosition.z; + //v73 = pParty->vPosition.z; } } - pParty->uFallStartY = v70; + pParty->uFallStartY = pZ; } - if ( v102 && v73 < v109 ) + if ( v102 && pParty->vPosition.z < ceiling_height ) { - if ( (signed int)(pParty->uPartyHeight + v73) >= v109 ) + if ( (signed int)(pParty->uPartyHeight + pParty->vPosition.z) >= ceiling_height ) { - pParty->vPosition.z = v109 - pParty->uPartyHeight - 1; - pParty->field_6F0 = v109 - pParty->uPartyHeight - 1; + pParty->vPosition.z = ceiling_height - pParty->uPartyHeight - 1; + pParty->field_6F0 = ceiling_height - pParty->uPartyHeight - 1; } } pParty->uFlags &= ~0x204; @@ -4639,26 +4586,21 @@ if ( !pParty->bFlying && high_fall_flag && !bWaterWalk ) { if ( pModel ) + v78 = v69 != 0; + else { - v78 = v69 != 0; + party_drowning_flag = true; + v78 = true; } - else - { - party_drowning_flag = true; - v78 = 1; - } } else - v78 = 1; -//LABEL_306: + v78 = true; + if ( v77 ) - { pParty->vPosition.x = pX; - } if ( v78 ) - { pParty->vPosition.y = pY; - } + if ( v78 || v77) { if ( bWaterWalk ) @@ -4684,7 +4626,7 @@ pAudioPlayer->_4AA258(804); pParty->walk_sound_timer = 64; } -//LABEL_318: + v81 = pZ; v82 = pZ; pParty->vPosition.z = pZ; @@ -4703,12 +4645,13 @@ if ( pParty->vPosition.z <= pTerrainHeight + 1 )//ïîëîæåíèå ãðóïïû âñåãäà +1 pParty->uFlags |= PARTY_FLAGS_1_WATER_DAMAGE; } - if ( !v103 + + if ( !v103//ïàäåíèå íà âîäó || (EventProcessor(v103, 0, 1), pParty->vPosition.x == pX) && pParty->vPosition.y == pY && (v82 = pParty->vPosition.z, pParty->vPosition.z == v81) ) { - if ( v82 < v111 ) + if ( pParty->vPosition.z < v111 ) { v82 = v105; pParty->uFallSpeed = 0; @@ -4734,10 +4677,10 @@ } pParty->uFallStartY = v81; } - if ( v102 && v82 < v109 && (signed int)(pParty->uPartyHeight + v82) >= v109 ) + if ( v102 && v82 < ceiling_height && (signed int)(pParty->uPartyHeight + v82) >= ceiling_height ) { - pParty->vPosition.z = v82 + pParty->uPartyHeight - v109 + 1; - pParty->field_6F0 = v82 + pParty->uPartyHeight - v109 + 1; + pParty->vPosition.z = v82 + pParty->uPartyHeight - ceiling_height + 1; + pParty->field_6F0 = v82 + pParty->uPartyHeight - ceiling_height + 1; } } }
--- a/Outdoor.h Tue Dec 03 16:35:57 2013 +0600 +++ b/Outdoor.h Thu Jan 02 09:11:01 2014 +0600 @@ -89,6 +89,7 @@ inline bool Portal() const {return (uAttributes & FACE_PORTAL) != 0;} inline bool Fluid() const {return (uAttributes & FACE_FLUID) != 0;} inline bool Clickable() const {return (uAttributes & FACE_CLICKABLE) != 0;} + inline bool Ethereal() const {return (uAttributes & FACE_ETHEREAL) != 0;} struct Plane_int_ pFacePlane; int zCalc1;
--- a/SpriteObject.cpp Tue Dec 03 16:35:57 2013 +0600 +++ b/SpriteObject.cpp Thu Jan 02 09:11:01 2014 +0600 @@ -206,26 +206,14 @@ //----- (00471C03) -------------------------------------------------------- void SpriteObject::UpdateObject_fn0_ODM(unsigned int uLayingItemID) { - //SpriteObject *v1; // esi@1 ObjectDesc *object; // ebx@1 - signed int v3; // edx@1 - int v4; // ecx@1 - int v5; // ST04_4@1 int v6; // eax@1 int v7; // ecx@1 int v8; // edi@1 int v9; // eax@4 - __int16 v10; // ax@7 - int v11; // edx@11 - int v12; // ecx@11 - signed int v13; // edx@14 - signed int v14; // edx@16 - int v15; // eax@24 - int v16; // eax@25 int v17; // ST10_4@25 - signed int v18; // eax@25 - signed int v19; // eax@28 - Actor *v20; // edi@31 + //signed int v19; // eax@28 + //Actor *v20; // edi@31 int v21; // eax@41 int v22; // ecx@43 __int16 v23; // bx@45 @@ -235,16 +223,16 @@ int v27; // eax@52 __int16 v28; // cx@55 int v29; // eax@55 - signed int v30; // edi@59 - BSPModel *v31; // ecx@61 - ODMFace *v32; // edi@61 + //signed int v30; // edi@59 + BSPModel *bmodel; // ecx@61 + ODMFace *face; // edi@61 int v33; // eax@62 int v34; // ecx@62 int v35; // eax@63 int v36; // ecx@67 __int16 v37; // ax@67 int v38; // eax@72 - int v39; // eax@72 + //int v39; // eax@72 unsigned __int64 v40; // qax@72 int v41; // eax@72 unsigned __int8 v42; // sf@74 @@ -258,7 +246,6 @@ int v50; // [sp+10h] [bp-98h]@52 Vec3_int_ v51; // [sp+14h] [bp-94h]@11 Particle_sw Dst; // [sp+20h] [bp-88h]@45 - unsigned int uLayingItemID_; // [sp+88h] [bp-20h]@1 int v54; // [sp+8Ch] [bp-1Ch]@1 int v55; // [sp+90h] [bp-18h]@1 int v56; // [sp+94h] [bp-14h]@11 @@ -267,16 +254,11 @@ int on_water; // [sp+A0h] [bp-8h]@1 int v60; // [sp+A4h] [bp-4h]@11 - uLayingItemID_ = uLayingItemID; - //v1 = &pSpriteObjects[uLayingItemID]; v58 = 0; object = &pObjectList->pObjects[pSpriteObjects[uLayingItemID].uObjectDescID]; v57 = IsTerrainSlopeTooHigh(pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y); - v3 = pSpriteObjects[uLayingItemID].vPosition.y; - v4 = pSpriteObjects[uLayingItemID].vPosition.x; - v5 = object->uHeight; v55 = 0; - v6 = ODM_GetFloorLevel(v4, v3, pSpriteObjects[uLayingItemID].vPosition.z, v5, &on_water, &v55, 0); + v6 = ODM_GetFloorLevel(pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, object->uHeight, &on_water, &v55, 0); v7 = v6; v54 = v6; v8 = v6 + 1; @@ -286,16 +268,15 @@ { v9 = v6 + 60; if ( v55 ) - v9 = v7 + 30; + v9 = v6 + 30; sub_42F960_create_object(pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, v9); - SpriteObject::OnInteraction(uLayingItemID_); + SpriteObject::OnInteraction(uLayingItemID); } } else { v58 = 1; } - v10 = object->uFlags; if ( !(object->uFlags & OBJECT_DESC_NO_GRAVITY) ) { if ( v58 ) @@ -305,10 +286,8 @@ } if ( v57 ) { - v11 = pSpriteObjects[uLayingItemID].vPosition.y; - v12 = pSpriteObjects[uLayingItemID].vPosition.x; pSpriteObjects[uLayingItemID].vPosition.z = v8; - ODM_GetTerrainNormalAt(v12, v11, &v51); + ODM_GetTerrainNormalAt(pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, &v51); pSpriteObjects[uLayingItemID].vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength(); v56 = abs(v51.y * pSpriteObjects[uLayingItemID].vVelocity.y + v51.z * pSpriteObjects[uLayingItemID].vVelocity.z + v51.x * pSpriteObjects[uLayingItemID].vVelocity.x) >> 16; //v60 = ((unsigned __int64)(v56 * (signed __int64)v51.x) >> 16); @@ -320,11 +299,11 @@ v7 = v54; goto LABEL_13; } - if ( v10 & 0x40 ) + if ( object->uFlags & OBJECT_DESC_INTERACTABLE ) { if ( pSpriteObjects[uLayingItemID].vPosition.z < v7 ) pSpriteObjects[uLayingItemID].vPosition.z = v8; - if ( !_46BFFA_check_object_intercept(uLayingItemID_, 0) ) + if ( !_46BFFA_check_object_intercept(uLayingItemID, 0) ) return; } pSpriteObjects[uLayingItemID].vPosition.z = v8; @@ -334,31 +313,29 @@ pSpriteObjects[uLayingItemID].vVelocity.x = fixpoint_mul(58500, pSpriteObjects[uLayingItemID].vVelocity.x); pSpriteObjects[uLayingItemID].vVelocity.y = fixpoint_mul(58500, pSpriteObjects[uLayingItemID].vVelocity.y); pSpriteObjects[uLayingItemID].vVelocity.z = fixpoint_mul(58500, pSpriteObjects[uLayingItemID].vVelocity.z); - - if ( (pSpriteObjects[uLayingItemID].vVelocity.y * pSpriteObjects[uLayingItemID].vVelocity.y + pSpriteObjects[uLayingItemID].vVelocity.x * pSpriteObjects[uLayingItemID].vVelocity.x) < 400 ) - { - - pSpriteObjects[uLayingItemID].vVelocity.y = 0; - pSpriteObjects[uLayingItemID].vVelocity.x = 0; - memset(&Dst, 0, 0x68u); - Dst.x = (double)pSpriteObjects[uLayingItemID].vPosition.x; - Dst.y = (double)pSpriteObjects[uLayingItemID].vPosition.y; - Dst.z = (double)pSpriteObjects[uLayingItemID].vPosition.z; - Dst.r = 0.0; - Dst.g = 0.0; - Dst.b = 0.0; - if (object->uFlags & OBJECT_DESC_TRIAL_FIRE ) + if ( (pSpriteObjects[uLayingItemID].vVelocity.y * pSpriteObjects[uLayingItemID].vVelocity.y + + pSpriteObjects[uLayingItemID].vVelocity.x * pSpriteObjects[uLayingItemID].vVelocity.x) < 400 ) { - Dst.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8; - Dst.uDiffuse = 0xFF3C1E; - Dst.timeToLive = (unsigned __int8)(rand() & 0x80) + 128; - Dst.uTextureID = pBitmaps_LOD->LoadTexture("effpar01", TEXTURE_DEFAULT); - Dst.flt_28 = 1.0; - pGame->pParticleEngine->AddParticle(&Dst); - } - else if ( object->uFlags & OBJECT_DESC_TRIAL_LINE) - { - + pSpriteObjects[uLayingItemID].vVelocity.y = 0; + pSpriteObjects[uLayingItemID].vVelocity.x = 0; + memset(&Dst, 0, 0x68u); + Dst.x = (double)pSpriteObjects[uLayingItemID].vPosition.x; + Dst.y = (double)pSpriteObjects[uLayingItemID].vPosition.y; + Dst.z = (double)pSpriteObjects[uLayingItemID].vPosition.z; + Dst.r = 0.0; + Dst.g = 0.0; + Dst.b = 0.0; + if (object->uFlags & OBJECT_DESC_TRIAL_FIRE ) + { + Dst.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8; + Dst.uDiffuse = 0xFF3C1E; + Dst.timeToLive = (unsigned __int8)(rand() & 0x80) + 128; + Dst.uTextureID = pBitmaps_LOD->LoadTexture("effpar01", TEXTURE_DEFAULT); + Dst.flt_28 = 1.0; + pGame->pParticleEngine->AddParticle(&Dst); + } + else if ( object->uFlags & OBJECT_DESC_TRIAL_LINE) + { Dst.type = ParticleType_Line; Dst.uDiffuse = rand(); Dst.timeToLive = 64; @@ -366,46 +343,41 @@ Dst.flt_28 = 1.0; pGame->pParticleEngine->AddParticle(&Dst); } - else if ( object->uFlags & OBJECT_DESC_TRIAL_PARTICLE ) - { - Dst.type = ParticleType_Bitmap | ParticleType_8; - Dst.uDiffuse = rand(); - Dst.timeToLive = (unsigned __int8)(rand() & 0x80) + 128; - Dst.uTextureID = pBitmaps_LOD->LoadTexture("effpar03", TEXTURE_DEFAULT); - Dst.flt_28 = 1.0; - pGame->pParticleEngine->AddParticle(&Dst); + else if ( object->uFlags & OBJECT_DESC_TRIAL_PARTICLE ) + { + Dst.type = ParticleType_Bitmap | ParticleType_8; + Dst.uDiffuse = rand(); + Dst.timeToLive = (unsigned __int8)(rand() & 0x80) + 128; + Dst.uTextureID = pBitmaps_LOD->LoadTexture("effpar03", TEXTURE_DEFAULT); + Dst.flt_28 = 1.0; + pGame->pParticleEngine->AddParticle(&Dst); + } + return; } - return; - } } LABEL_13: - if ( pSpriteObjects[uLayingItemID].vPosition.z > v7 - && (v13 = pSpriteObjects[uLayingItemID].vPosition.x, v13 >= -0x8000) - && v13 <= 0x8000 - && (v14 = pSpriteObjects[uLayingItemID].vPosition.y, v14 >= -0x8000) - && v14 <= 0x8000 - && pSpriteObjects[uLayingItemID].vPosition.z <= 13000 + if ( pSpriteObjects[uLayingItemID].vPosition.x >= -0x8000 && pSpriteObjects[uLayingItemID].vPosition.x <= 0x8000 + && pSpriteObjects[uLayingItemID].vPosition.y >= -0x8000 && pSpriteObjects[uLayingItemID].vPosition.y <= 0x8000 + && pSpriteObjects[uLayingItemID].vPosition.z > v7 && pSpriteObjects[uLayingItemID].vPosition.z <= 13000 || !(object->uFlags & OBJECT_DESC_INTERACTABLE) ) goto LABEL_92; if ( pSpriteObjects[uLayingItemID].vPosition.z < v7 ) pSpriteObjects[uLayingItemID].vPosition.z = v8; - if ( _46BFFA_check_object_intercept(uLayingItemID_, 0) ) + if ( _46BFFA_check_object_intercept(uLayingItemID, 0) ) { LABEL_92: stru_721530.field_0 = 0; - v55 = 0; stru_721530.prolly_normal_d = object->uRadius; stru_721530.height = object->uHeight; stru_721530.field_8_radius = 0; stru_721530.field_70 = 0; - while ( 1 ) + for ( v55 = 0; v55 < 100; ++v55 ) { stru_721530.position.x = pSpriteObjects[uLayingItemID].vPosition.x; stru_721530.normal.x = stru_721530.position.x; - v15 = pSpriteObjects[uLayingItemID].vPosition.y; stru_721530.uSectorID = 0; - stru_721530.position.y = v15; - stru_721530.normal.y = v15; + stru_721530.position.y = pSpriteObjects[uLayingItemID].vPosition.y; + stru_721530.normal.y = pSpriteObjects[uLayingItemID].vPosition.y; stru_721530.position.z = pSpriteObjects[uLayingItemID].vPosition.z + stru_721530.prolly_normal_d + 1; stru_721530.normal.z = stru_721530.position.z; stru_721530.velocity.x = pSpriteObjects[uLayingItemID].vVelocity.x; @@ -414,24 +386,19 @@ if ( stru_721530._47050A(0) ) return; _46E889_collide_against_bmodels(0); - v16 = WorldPosToGridCellZ(pSpriteObjects[uLayingItemID].vPosition.y); - v18 = WorldPosToGridCellX(pSpriteObjects[uLayingItemID].vPosition.x); - _46E26D_collide_against_sprites(v18, v16); + _46E26D_collide_against_sprites(WorldPosToGridCellX(pSpriteObjects[uLayingItemID].vPosition.x), WorldPosToGridCellZ(pSpriteObjects[uLayingItemID].vPosition.y)); if (PID_TYPE(pSpriteObjects[uLayingItemID].spell_caster_pid) != OBJECT_Player) _46EF01_collision_chech_player(0); if (PID_TYPE(pSpriteObjects[uLayingItemID].spell_caster_pid) == OBJECT_Actor) { - v19 = PID_ID(pSpriteObjects[uLayingItemID].spell_caster_pid); - if (( v19 >= 0 )&&( v19 < (signed int)(uNumActors - 1) )) + if (( PID_ID(pSpriteObjects[uLayingItemID].spell_caster_pid) >= 0 ) + &&( PID_ID(pSpriteObjects[uLayingItemID].spell_caster_pid) < (signed int)(uNumActors - 1) )) { - - v20 = &pActors[v19]; - for (v56 =0; v56 < uNumActors; ++v56) - { - if ( v20->GetActorsRelation(&pActors[v56]) ) - Actor::_46DF1A_collide_against_actor(v56, 0); - - } + for (v56 =0; v56 < uNumActors; ++v56) + { + if ( pActors[PID_ID(pSpriteObjects[uLayingItemID].spell_caster_pid)].GetActorsRelation(&pActors[v56]) ) + Actor::_46DF1A_collide_against_actor(v56, 0); + } } } else @@ -449,7 +416,7 @@ else v44 = v54 + 60; sub_42F960_create_object(pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, v44); - SpriteObject::OnInteraction(uLayingItemID_); + SpriteObject::OnInteraction(uLayingItemID); return; } if ( stru_721530.field_7C >= stru_721530.field_6C ) @@ -510,30 +477,28 @@ { if ( v29 < v54 ) pSpriteObjects[uLayingItemID].vPosition.z = v54 + 1; - if ( !_46BFFA_check_object_intercept(uLayingItemID_, stru_721530.uFaceID) ) + if ( !_46BFFA_check_object_intercept(uLayingItemID, stru_721530.uFaceID) ) return; } - v30 = (signed int)PID_ID(stru_721530.uFaceID); if (PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration) break; if (PID_TYPE(stru_721530.uFaceID) == OBJECT_BModel) { - v31 = &pOutdoor->pBModels[(signed int)stru_721530.uFaceID >> 9]; - v32 = &v31->pFaces[v30 & 0x3F]; - if ( v32->uPolygonType != 3 ) + bmodel = &pOutdoor->pBModels[(signed int)stru_721530.uFaceID >> 9]; + face = &bmodel->pFaces[PID_ID(stru_721530.uFaceID) & 0x3F]; + if ( face->uPolygonType != POLYGON_Floor ) { - v56 = abs(v32->pFacePlane.vNormal.z * pSpriteObjects[uLayingItemID].vVelocity.z + v32->pFacePlane.vNormal.y * pSpriteObjects[uLayingItemID].vVelocity.y - + v32->pFacePlane.vNormal.x * pSpriteObjects[uLayingItemID].vVelocity.x) >> 16; + v56 = abs(face->pFacePlane.vNormal.x * pSpriteObjects[uLayingItemID].vVelocity.x + + face->pFacePlane.vNormal.y * pSpriteObjects[uLayingItemID].vVelocity.y + + face->pFacePlane.vNormal.z * pSpriteObjects[uLayingItemID].vVelocity.z) >> 16; if ( (stru_721530.speed >> 3) > v56 ) v56 = stru_721530.speed >> 3; - v57 = v32->pFacePlane.vNormal.x; - v57 = (unsigned __int64)(v56 * (signed __int64)v57) >> 16; - v58 = v32->pFacePlane.vNormal.y; - v58 = (unsigned __int64)(v56 * (signed __int64)v58) >> 16; - v60 = ((unsigned __int64)(v56 * (signed __int64)v32->pFacePlane.vNormal.z) >> 16); + v57 = (unsigned __int64)(v56 * (signed __int64)face->pFacePlane.vNormal.x) >> 16; + v58 = (unsigned __int64)(v56 * (signed __int64)face->pFacePlane.vNormal.y) >> 16; + v60 = (unsigned __int64)(v56 * (signed __int64)face->pFacePlane.vNormal.z) >> 16; pSpriteObjects[uLayingItemID].vVelocity.x += 2 * v57; pSpriteObjects[uLayingItemID].vVelocity.y += 2 * v58; - if ( v32->pFacePlane.vNormal.z <= 32000 ) + if ( face->pFacePlane.vNormal.z <= 32000 ) { v37 = 2 * (short)v60; } @@ -545,17 +510,16 @@ v37 = (unsigned int)(32000 * v36) >> 16; } pSpriteObjects[uLayingItemID].vVelocity.z += v37; - if ( BYTE3(v32->uAttributes) & 0x10 ) - EventProcessor(v32->sCogTriggeredID, 0, 1); + if ( BYTE3(face->uAttributes) & 0x10 ) + EventProcessor(face->sCogTriggeredID, 0, 1); goto LABEL_74; } - v33 = v31->pVertices.pVertices[v32->pVertexIDs[0]].z; - v34 = pSpriteObjects[uLayingItemID].vVelocity.x; - pSpriteObjects[uLayingItemID].vPosition.z = v33 + 1; - if ( pSpriteObjects[uLayingItemID].vVelocity.y * pSpriteObjects[uLayingItemID].vVelocity.y + v34 * v34 >= 400 ) + pSpriteObjects[uLayingItemID].vPosition.z = bmodel->pVertices.pVertices[face->pVertexIDs[0]].z + 1; + if ( pSpriteObjects[uLayingItemID].vVelocity.x * pSpriteObjects[uLayingItemID].vVelocity.x + + pSpriteObjects[uLayingItemID].vVelocity.y * pSpriteObjects[uLayingItemID].vVelocity.y >= 400 ) { - if ( BYTE3(v32->uAttributes) & 0x10 ) - EventProcessor(v32->sCogTriggeredID, 0, 1); + if ( BYTE3(face->uAttributes) & 0x10 ) + EventProcessor(face->sCogTriggeredID, 0, 1); goto LABEL_74; } LOWORD(v35) = 0; @@ -564,29 +528,16 @@ pSpriteObjects[uLayingItemID].vVelocity.y = v35; } LABEL_74: - pSpriteObjects[uLayingItemID].vVelocity.x = (signed __int16)((unsigned __int64)(58500i64 * (signed __int64)(signed int)pSpriteObjects[uLayingItemID].vVelocity.x) >> 16); - pSpriteObjects[uLayingItemID].vVelocity.y = (signed __int16)((unsigned __int64)(58500i64 * (signed __int64)(signed int)pSpriteObjects[uLayingItemID].vVelocity.y) >> 16); - pSpriteObjects[uLayingItemID].vVelocity.z = (signed __int16)((unsigned __int64)(58500i64 * (signed __int64)(signed int)pSpriteObjects[uLayingItemID].vVelocity.z) >> 16); - - ++v55; - //v43 = __OFSUB__(v55, 100); - // v42 = v55 - 100 < 0; - if (v55>=100 )//!(v42 ^ v43) - return; + pSpriteObjects[uLayingItemID].vVelocity.x = fixpoint_mul(58500, pSpriteObjects[uLayingItemID].vVelocity.x); + pSpriteObjects[uLayingItemID].vVelocity.y = fixpoint_mul(58500, pSpriteObjects[uLayingItemID].vVelocity.y); + pSpriteObjects[uLayingItemID].vVelocity.z = fixpoint_mul(58500, pSpriteObjects[uLayingItemID].vVelocity.z); } - v57 = integer_sqrt(pSpriteObjects[uLayingItemID].vVelocity.y * pSpriteObjects[uLayingItemID].vVelocity.y + pSpriteObjects[uLayingItemID].vVelocity.x * pSpriteObjects[uLayingItemID].vVelocity.x); - v38 = stru_5C6E00->Atan2(pSpriteObjects[uLayingItemID].vPosition.x - pLevelDecorations[v30].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y - pLevelDecorations[v30].vPosition.y); - v56 = v38; - v39 = stru_5C6E00->Cos(v38); - // v60 = v39; - v40 = v39 * (signed __int64)v57; - v58 = v40 >> 16; - pSpriteObjects[uLayingItemID].vVelocity.x = WORD1(v40); - v41 = stru_5C6E00->Sin(v56 - stru_5C6E00->uIntegerHalfPi); - // v60 = v41; - v35 = (unsigned __int64)(v41 * (signed __int64)v57) >> 16; - v58 = v35; - pSpriteObjects[uLayingItemID].vVelocity.y = v35; + v57 = integer_sqrt(pSpriteObjects[uLayingItemID].vVelocity.x * pSpriteObjects[uLayingItemID].vVelocity.x + + pSpriteObjects[uLayingItemID].vVelocity.y * pSpriteObjects[uLayingItemID].vVelocity.y); + v38 = stru_5C6E00->Atan2(pSpriteObjects[uLayingItemID].vPosition.x - pLevelDecorations[PID_ID(stru_721530.uFaceID)].vPosition.x, + pSpriteObjects[uLayingItemID].vPosition.y - pLevelDecorations[PID_ID(stru_721530.uFaceID)].vPosition.y); + pSpriteObjects[uLayingItemID].vVelocity.x = (unsigned __int64)(stru_5C6E00->Cos(v38) * (signed __int64)v57) >> 16; + pSpriteObjects[uLayingItemID].vVelocity.y = (unsigned __int64)(stru_5C6E00->Sin(v38 - stru_5C6E00->uIntegerHalfPi) * (signed __int64)v57) >> 16; goto LABEL_74; } } @@ -596,53 +547,28 @@ { SpriteObject *pSpriteObject; // esi@1 ObjectDesc *pObject; // edi@1 - //int v3; // ST08_4@1 - //__int16 v4; // ax@5 - __int16 v5; // ax@7 - BLVFace *v6; // ecx@11 - BLVFace *v7; // eax@11 - signed int v8; // ebx@12 int v9; // ecx@16 __int16 v10; // di@18 - char v11; // al@19 - //int v12; // eax@25 - int v13; // eax@31 int v14; // ebx@34 signed int v15; // ebx@46 - BLVFace *v16; // edi@48 int v17; // eax@50 int v18; // eax@52 int v19; // ecx@52 Vec3_short_ *v20; // ecx@53 - //int v21; // ecx@57 __int16 v22; // ax@57 int v23; // edi@62 - //int v24; // edi@62 - //int v25; // eax@62 - //unsigned __int64 v26; // qax@62 unsigned __int8 v27; // sf@64 unsigned __int8 v28; // of@64 __int16 v29; // di@67 char v30; // al@68 - const char *v31; // [sp-8h] [bp-98h]@19 - const char *v32; // [sp-8h] [bp-98h]@68 - enum TEXTURE_TYPE v33; // [sp-4h] [bp-94h]@19 - enum TEXTURE_TYPE v34; // [sp-4h] [bp-94h]@68 Particle_sw Dst; // [sp+Ch] [bp-84h]@18 - //unsigned int uLayingItemID_; // [sp+74h] [bp-1Ch]@1 - //ObjectDesc *v37; // [sp+78h] [bp-18h]@1 unsigned int uFaceID; // [sp+7Ch] [bp-14h]@4 int v39; // [sp+80h] [bp-10h]@33 - Actor *v39b; int v40; // [sp+84h] [bp-Ch]@28 - //int v41; // [sp+88h] [bp-8h]@34 - int v42; // [sp+8Ch] [bp-4h]@4 + int v42; // [sp+8Ch] [bp-4h]@4 - //uLayingItemID_ = uLayingItemID; pSpriteObject = &pSpriteObjects[uLayingItemID]; pObject = &pObjectList->pObjects[pSpriteObject->uObjectDescID]; - //v3 = pSpriteObject->vPosition.x; - //v37 = &pObjectList->pObjects[pSpriteObject->uObjectDescID]; pSpriteObject->uSectorID = pIndoor->GetSector(pSpriteObject->vPosition.x, pSpriteObject->vPosition.y, pSpriteObject->vPosition.z); v42 = BLV_GetFloorLevel(pSpriteObject->vPosition.x, pSpriteObject->vPosition.y, pSpriteObject->vPosition.z, pSpriteObject->uSectorID, &uFaceID); if ( abs(pSpriteObject->vPosition.x) > 32767 @@ -655,82 +581,56 @@ SpriteObject::OnInteraction(uLayingItemID); return; } - v5 = pObject->uFlags; - if ( v5 & 0x20 ) + if ( pObject->uFlags & OBJECT_DESC_NO_GRAVITY )//íå ïàäàþùèå îáúåêòû { -LABEL_24: - v8 = 0; LABEL_25: - stru_721530.field_0 = v8; - uFaceID = v8; + stru_721530.field_0 = 0; stru_721530.prolly_normal_d = pObject->uRadius; - stru_721530.field_84 = -1; stru_721530.height = pObject->uHeight; - stru_721530.field_8_radius = v8; - stru_721530.field_70 = v8; - while ( 1 ) + stru_721530.field_8_radius = 0; + stru_721530.field_70 = 0; + for ( uFaceID = 0; uFaceID < 100; uFaceID++ ) { stru_721530.position.x = pSpriteObject->vPosition.x; + stru_721530.position.y = pSpriteObject->vPosition.y; + stru_721530.position.z = stru_721530.prolly_normal_d + pSpriteObject->vPosition.z + 1; + stru_721530.normal.x = stru_721530.position.x; - stru_721530.position.y = pSpriteObject->vPosition.y; stru_721530.normal.y = stru_721530.position.y; - stru_721530.position.z = stru_721530.prolly_normal_d + pSpriteObject->vPosition.z + 1; stru_721530.normal.z = stru_721530.position.z; + stru_721530.velocity.x = pSpriteObject->vVelocity.x; stru_721530.velocity.y = pSpriteObject->vVelocity.y; stru_721530.velocity.z = pSpriteObject->vVelocity.z; + stru_721530.uSectorID = pSpriteObject->uSectorID; - if ( stru_721530._47050A(v8) ) + if ( stru_721530._47050A(0) ) return; - v40 = v8; - do + + for ( v40 = 0; v40 < 100; ++v40 ) { _46E44E_collide_against_faces_and_portals(0); _46E0B2_collide_against_decorations(); if (PID_TYPE(pSpriteObject->spell_caster_pid) != OBJECT_Player) _46EF01_collision_chech_player(1); - v13 = pSpriteObject->spell_caster_pid; - v42 = v8; - if (PID_TYPE(v13) == OBJECT_Actor) + if (PID_TYPE(pSpriteObject->spell_caster_pid) == OBJECT_Actor) { - if ( (signed int)uNumActors > v8 ) + for ( v42 = 0; v42 < (signed int)uNumActors; ++v42 ) { - v39b = pActors.data();//[0].word_000086_some_monster_id; - do - { - //v41 = pActors[v1->field_58 >> 3].pMonsterInfo.uID - 1; - //v14 = (signed __int64)((double)v41 * 0.3333333333333333); - //v41 = *(short *)(v39 - 38) - 1; - //if ( v14 != (unsigned int)(signed __int64)((double)v41 * 0.3333333333333333) ) - if( pActors[pSpriteObject->spell_caster_pid >> 3].pMonsterInfo.uID != v39b->pMonsterInfo.uID ) - //not sure: pMonsterList->pMonsters[v39b->word_000086_some_monster_id-1].uToHitRadius - Actor::_46DF1A_collide_against_actor(v42, pMonsterList->pMonsters[v39b->word_000086_some_monster_id-1].uToHitRadius); - ++v42; - ++v39b;// += 836; - } - while ( v42 < (signed int)uNumActors ); - v8 = 0; + if( pActors[pSpriteObject->spell_caster_pid >> 3].pMonsterInfo.uID != pActors[v42].pMonsterInfo.uID ) + //not sure: pMonsterList->pMonsters[v39b->word_000086_some_monster_id-1].uToHitRadius + Actor::_46DF1A_collide_against_actor(v42, pMonsterList->pMonsters[pActors[v42].word_000086_some_monster_id-1].uToHitRadius); } } else { - if ( (signed int)uNumActors > v8 ) - { - v39b = pActors.data();//[0].word_000086_some_monster_id; - do - { - Actor::_46DF1A_collide_against_actor(v42++, pMonsterList->pMonsters[v39b->word_000086_some_monster_id-1].uToHitRadius); - ++v39b; - } - while ( v42 < (signed int)uNumActors ); - } + for ( v42 = 0; v42 < (signed int)uNumActors; v42++ ) + Actor::_46DF1A_collide_against_actor(v42, pMonsterList->pMonsters[pActors[v42].word_000086_some_monster_id-1].uToHitRadius); } if ( _46F04E_collide_against_portals() ) break; - ++v40; } - while ( v40 < 100 ); if ( stru_721530.field_7C >= stru_721530.field_6C ) { pSpriteObject->vPosition.x = stru_721530.normal2.x; @@ -739,44 +639,42 @@ pSpriteObject->uSectorID = LOWORD(stru_721530.uSectorID); if ( !(HIBYTE(pObject->uFlags) & 1) ) return; - memset(&Dst, v8, 0x68u); - v29 = pObject->uFlags; + memset(&Dst, 0, 0x68u); Dst.x = (double)pSpriteObject->vPosition.x; Dst.y = (double)pSpriteObject->vPosition.y; Dst.z = (double)pSpriteObject->vPosition.z; Dst.r = 0.0; Dst.g = 0.0; Dst.b = 0.0; - if ( v29 & 0x200 ) + if ( pObject->uFlags & OBJECT_DESC_TRIAL_FIRE ) { Dst.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8; Dst.uDiffuse = 0xFF3C1E; - v30 = rand(); - v34 = (TEXTURE_TYPE)v8; - v32 = "effpar01"; + Dst.timeToLive = (unsigned __int8)(rand() & 0x80) + 128; + Dst.uTextureID = pBitmaps_LOD->LoadTexture("effpar01", TEXTURE_DEFAULT); + Dst.flt_28 = 1.0; + pGame->pParticleEngine->AddParticle(&Dst); + return; } - else + else if ( pObject->uFlags & OBJECT_DESC_TRIAL_LINE ) { - if ( v29 & 0x400 ) - { - Dst.type = ParticleType_Line; - Dst.uDiffuse = rand(); - Dst.timeToLive = 64; - Dst.uTextureID = v8; - Dst.flt_28 = 1.0; - pGame->pParticleEngine->AddParticle(&Dst); - return; - } + Dst.type = ParticleType_Line; + Dst.uDiffuse = rand(); + Dst.timeToLive = 64; + Dst.uTextureID = 0; + Dst.flt_28 = 1.0; + pGame->pParticleEngine->AddParticle(&Dst); + return; + } + else if ( pObject->uFlags & OBJECT_DESC_TRIAL_PARTICLE) + { Dst.type = ParticleType_Bitmap | ParticleType_8; Dst.uDiffuse = rand(); - v30 = rand(); - v34 = (TEXTURE_TYPE)v8; - v32 = "effpar03"; + Dst.timeToLive = (unsigned __int8)(rand() & 0x80) + 128; + Dst.uTextureID = pBitmaps_LOD->LoadTexture("effpar03", TEXTURE_DEFAULT); + Dst.flt_28 = 1.0; + pGame->pParticleEngine->AddParticle(&Dst); } - Dst.timeToLive = (unsigned __int8)(v30 & 0x80) + 128; - Dst.uTextureID = pBitmaps_LOD->LoadTexture(v32, v34); - Dst.flt_28 = 1.0; - pGame->pParticleEngine->AddParticle(&Dst); return; } //v40 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.x) >> 16; @@ -787,7 +685,7 @@ pSpriteObject->vPosition.z += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.z); pSpriteObject->uSectorID = stru_721530.uSectorID; stru_721530.field_70 += stru_721530.field_7C; - if ( pObject->uFlags & 0x40 && !_46BFFA_check_object_intercept(uLayingItemID, stru_721530.uFaceID) ) + if ( pObject->uFlags & OBJECT_DESC_INTERACTABLE && !_46BFFA_check_object_intercept(uLayingItemID, stru_721530.uFaceID) ) return; v15 = (signed int)stru_721530.uFaceID >> 3; if (PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration) @@ -798,145 +696,129 @@ pSpriteObject->vVelocity.x = fixpoint_mul(stru_5C6E00->Cos(v23), v40); pSpriteObject->vVelocity.y = fixpoint_mul(stru_5C6E00->Sin(v23), v40); } - else + if (PID_TYPE(stru_721530.uFaceID) == OBJECT_BModel) { - if (PID_TYPE(stru_721530.uFaceID) != OBJECT_BModel) - goto LABEL_64; stru_721530.field_84 = (signed int)PID_ID(stru_721530.uFaceID); - v16 = &pIndoor->pFaces[v15]; - if ( v16->uPolygonType != 3 ) + if ( pIndoor->pFaces[v15].uPolygonType != POLYGON_Floor ) { - v42 = abs(v16->pFacePlane_old.vNormal.x * pSpriteObject->vVelocity.x + v16->pFacePlane_old.vNormal.z * pSpriteObject->vVelocity.z - + v16->pFacePlane_old.vNormal.y * pSpriteObject->vVelocity.y) >> 16; + v42 = abs(pIndoor->pFaces[v15].pFacePlane_old.vNormal.x * pSpriteObject->vVelocity.x + + pIndoor->pFaces[v15].pFacePlane_old.vNormal.y * pSpriteObject->vVelocity.y + + pIndoor->pFaces[v15].pFacePlane_old.vNormal.z * pSpriteObject->vVelocity.z) >> 16; if ( (stru_721530.speed >> 3) > v42 ) v42 = stru_721530.speed >> 3; - pSpriteObject->vVelocity.x += 2 * fixpoint_mul(v42, v16->pFacePlane_old.vNormal.x); - pSpriteObject->vVelocity.y += 2 * fixpoint_mul(v42, v16->pFacePlane_old.vNormal.y); - v39 = fixpoint_mul(v42, v16->pFacePlane_old.vNormal.z); - if ( v16->pFacePlane_old.vNormal.z <= 32000 ) - { + pSpriteObject->vVelocity.x += 2 * fixpoint_mul(v42, pIndoor->pFaces[v15].pFacePlane_old.vNormal.x); + pSpriteObject->vVelocity.y += 2 * fixpoint_mul(v42, pIndoor->pFaces[v15].pFacePlane_old.vNormal.y); + v39 = fixpoint_mul(v42, pIndoor->pFaces[v15].pFacePlane_old.vNormal.z); + if ( pIndoor->pFaces[v15].pFacePlane_old.vNormal.z <= 32000 ) v22 = 2 * v39; - } else { pSpriteObject->vVelocity.z += v39; v22 = fixpoint_mul(32000, v39); } pSpriteObject->vVelocity.z += v22; - if ( BYTE3(v16->uAttributes) & 0x10 ) - EventProcessor(pIndoor->pFaceExtras[v16->uFaceExtraID].uEventID, 0, 1); - goto LABEL_63; + if ( BYTE3(pIndoor->pFaces[v15].uAttributes) & 0x10 ) + EventProcessor(pIndoor->pFaceExtras[pIndoor->pFaces[v15].uFaceExtraID].uEventID, 0, 1); + pSpriteObject->vVelocity.x = fixpoint_mul(58500, pSpriteObject->vVelocity.x); + pSpriteObject->vVelocity.y = fixpoint_mul(58500, pSpriteObject->vVelocity.y); + pSpriteObject->vVelocity.z = fixpoint_mul(58500, pSpriteObject->vVelocity.z); + continue; } - if ( pObject->uFlags & 0x80 ) + if ( pObject->uFlags & OBJECT_DESC_BOUNCE ) { - v17 = -pSpriteObject->vVelocity.z >> 1; + v17 = -pSpriteObject->vVelocity.z / 2; pSpriteObject->vVelocity.z = v17; if ( (signed __int16)v17 < 10 ) pSpriteObject->vVelocity.z = 0; - if ( BYTE3(v16->uAttributes) & 0x10 ) - EventProcessor(pIndoor->pFaceExtras[v16->uFaceExtraID].uEventID, 0, 1); - goto LABEL_63; + if ( BYTE3(pIndoor->pFaces[v15].uAttributes) & 0x10 ) + EventProcessor(pIndoor->pFaceExtras[pIndoor->pFaces[v15].uFaceExtraID].uEventID, 0, 1); + pSpriteObject->vVelocity.x = fixpoint_mul(58500, pSpriteObject->vVelocity.x); + pSpriteObject->vVelocity.y = fixpoint_mul(58500, pSpriteObject->vVelocity.y); + pSpriteObject->vVelocity.z = fixpoint_mul(58500, pSpriteObject->vVelocity.z); + continue; } - v18 = pSpriteObject->vVelocity.y; - v19 = pSpriteObject->vVelocity.x; pSpriteObject->vVelocity.z = 0; - if ( v19 * v19 + v18 * v18 >= 400 ) + if ( pSpriteObject->vVelocity.x * pSpriteObject->vVelocity.x + pSpriteObject->vVelocity.y * pSpriteObject->vVelocity.y >= 400 ) { - if ( BYTE3(v16->uAttributes) & 0x10 ) - EventProcessor(pIndoor->pFaceExtras[v16->uFaceExtraID].uEventID, 0, 1); - goto LABEL_63; + if ( BYTE3(pIndoor->pFaces[v15].uAttributes) & 0x10 ) + EventProcessor(pIndoor->pFaceExtras[pIndoor->pFaces[v15].uFaceExtraID].uEventID, 0, 1); + pSpriteObject->vVelocity.x = fixpoint_mul(58500, pSpriteObject->vVelocity.x); + pSpriteObject->vVelocity.y = fixpoint_mul(58500, pSpriteObject->vVelocity.y); + pSpriteObject->vVelocity.z = fixpoint_mul(58500, pSpriteObject->vVelocity.z); + continue; } - v20 = pIndoor->pVertices; pSpriteObject->vVelocity.z = 0; pSpriteObject->vVelocity.y = 0; pSpriteObject->vVelocity.x = 0; - pSpriteObject->vPosition.z = v20[*v16->pVertexIDs].z + 1; + pSpriteObject->vPosition.z = pIndoor->pVertices[*pIndoor->pFaces[v15].pVertexIDs].z + 1; } -LABEL_63: - //v2 = v37; -LABEL_64: pSpriteObject->vVelocity.x = fixpoint_mul(58500, pSpriteObject->vVelocity.x); pSpriteObject->vVelocity.y = fixpoint_mul(58500, pSpriteObject->vVelocity.y); pSpriteObject->vVelocity.z = fixpoint_mul(58500, pSpriteObject->vVelocity.z); - ++uFaceID; - v28 = __OFSUB__(uFaceID, 100); - v27 = uFaceID - 100 < 0; - if ( !(v27 ^ v28) ) - return; - v8 = 0; } } + //äëÿ ïàäàþùèõ îáúåêòîâ(äëÿ ïðèìåðà âûáðîñ âåùè èç èíâåíòàðÿ) if ( v42 <= pSpriteObject->vPosition.z - 3 ) { pSpriteObject->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength(); - goto LABEL_24; + goto LABEL_25; } - if ( !(v5 & 0x40) || _46BFFA_check_object_intercept(uLayingItemID, 0) ) + if ( !(pObject->uFlags & OBJECT_DESC_INTERACTABLE) || _46BFFA_check_object_intercept(uLayingItemID, 0) ) { - v6 = pIndoor->pFaces; pSpriteObject->vPosition.z = v42 + 1; - v7 = &v6[uFaceID]; - if ( v7->uPolygonType == 3 ) - { - v8 = 0; + if ( pIndoor->pFaces[uFaceID].uPolygonType == POLYGON_Floor ) pSpriteObject->vVelocity.z = 0; - } else { - if ( v7->pFacePlane_old.vNormal.z < 45000 ) + if ( pIndoor->pFaces[uFaceID].pFacePlane_old.vNormal.z < 45000 ) pSpriteObject->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength(); - v8 = 0; } pSpriteObject->vVelocity.x = fixpoint_mul(58500, pSpriteObject->vVelocity.x); pSpriteObject->vVelocity.y = fixpoint_mul(58500, pSpriteObject->vVelocity.y); pSpriteObject->vVelocity.z = fixpoint_mul(58500, pSpriteObject->vVelocity.z); - v9 = pSpriteObject->vVelocity.x; - if ( v9 * v9 + pSpriteObject->vVelocity.y * pSpriteObject->vVelocity.y < 400 ) + if ( pSpriteObject->vVelocity.x * pSpriteObject->vVelocity.x + pSpriteObject->vVelocity.y * pSpriteObject->vVelocity.y < 400 ) { - pSpriteObject->vVelocity.z = v8; - pSpriteObject->vVelocity.y = v8; - pSpriteObject->vVelocity.x = v8; - if ( !(pObject->uFlags & 1) ) + pSpriteObject->vVelocity.x = 0; + pSpriteObject->vVelocity.y = 0; + pSpriteObject->vVelocity.z = 0; + if ( !(pObject->uFlags & OBJECT_DESC_NO_SPRITE) ) return; - memset(&Dst, v8, 0x68u); - v10 = pObject->uFlags; + memset(&Dst, 0, 0x68u); Dst.x = (double)pSpriteObject->vPosition.x; Dst.y = (double)pSpriteObject->vPosition.y; Dst.z = (double)pSpriteObject->vPosition.z; Dst.r = 0.0; Dst.g = 0.0; Dst.b = 0.0; - if ( v10 & 0x200 ) + if ( pObject->uFlags & OBJECT_DESC_TRIAL_FIRE ) { Dst.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8; Dst.uDiffuse = 0xFF3C1E; Dst.flt_28 = 1.0; - v11 = rand(); - v33 = (TEXTURE_TYPE)v8; - v31 = "effpar01"; + Dst.timeToLive = (unsigned __int8)(rand() & 0x80) + 128; + Dst.uTextureID = pBitmaps_LOD->LoadTexture("effpar01", TEXTURE_DEFAULT); + pGame->pParticleEngine->AddParticle(&Dst); + return; } - else + else if ( pObject->uFlags & OBJECT_DESC_TRIAL_LINE ) { - if ( v10 & 0x400 ) - { - Dst.type = ParticleType_Line; - Dst.uDiffuse = rand(); - Dst.timeToLive = 64; - Dst.uTextureID = v8; - Dst.flt_28 = 1.0; - pGame->pParticleEngine->AddParticle(&Dst); - return; - } + Dst.type = ParticleType_Line; + Dst.uDiffuse = rand(); + Dst.timeToLive = 64; + Dst.uTextureID = 0; + Dst.flt_28 = 1.0; + pGame->pParticleEngine->AddParticle(&Dst); + return; + } + else if ( pObject->uFlags & OBJECT_DESC_TRIAL_PARTICLE) + { Dst.type = ParticleType_Bitmap | ParticleType_8; Dst.uDiffuse = rand(); Dst.flt_28 = 1.0; - v11 = rand(); - v33 = (TEXTURE_TYPE)v8; - v31 = "effpar03"; + Dst.timeToLive = (unsigned __int8)(rand() & 0x80) + 128; + Dst.uTextureID = pBitmaps_LOD->LoadTexture("effpar03", TEXTURE_DEFAULT); + pGame->pParticleEngine->AddParticle(&Dst); } - Dst.timeToLive = (unsigned __int8)(v11 & 0x80) + 128; - Dst.uTextureID = pBitmaps_LOD->LoadTexture(v31, v33); - pGame->pParticleEngine->AddParticle(&Dst); return; } goto LABEL_25; @@ -1032,16 +914,16 @@ //----- (0042FA22) -------------------------------------------------------- void CompactLayingItemsList() - { - int new_obj_pos=0; +{ + int new_obj_pos = 0; - for (int i=0; i<MAX_SPRITE_OBJECTS; ++i) - { - if (pSpriteObjects[i].uObjectDescID) - memcpy(&pSpriteObjects[new_obj_pos++], &pSpriteObjects[i],sizeof(SpriteObject)); - } - uNumSpriteObjects = new_obj_pos; - } + for (int i=0; i < MAX_SPRITE_OBJECTS; ++i) + { + if (pSpriteObjects[i].uObjectDescID) + memcpy(&pSpriteObjects[new_obj_pos++], &pSpriteObjects[i],sizeof(SpriteObject)); + } + uNumSpriteObjects = new_obj_pos; +} //----- (00408896) -------------------------------------------------------- void InitializeSpriteObjects() { @@ -1049,31 +931,27 @@ { SpriteObject* item = &pSpriteObjects[i]; - if (item->uType && - (item->uSoundID & 8 || pObjectList->pObjects[item->uType].uFlags & 0x10)) + if (item->uType && (item->uSoundID & 8 || pObjectList->pObjects[item->uType].uFlags & OBJECT_DESC_UNPICKABLE)) SpriteObject::OnInteraction(i); } } //----- (0046BEF1) -------------------------------------------------------- void SpriteObject::_46BEF1_apply_spells_aoe() { - SpriteObject *v1; // edi@1 - Actor *v2; // esi@2 - __int16 v3; // fps@4 - unsigned __int8 v4; // c0@4 - unsigned __int8 v5; // c3@4 - signed int v6; // [sp+8h] [bp-4h]@1 + //SpriteObject *v1; // edi@1 + //Actor *v2; // esi@2 + //__int16 v3; // fps@4 + //unsigned __int8 v4; // c0@4 + //unsigned __int8 v5; // c3@4 + //signed int v6; // [sp+8h] [bp-4h]@1 - int v7,v8,v9,v10,v11; - - v6 = 0; - v1 = this; + int v7,v9,v10,v11; + __debugbreak();//Ritor1 if ( (signed int)uNumActors > 0 ) { - v2 = pActors.data();//[0].vPosition.y; - do + for ( uint i = 0; i < uNumActors; ++i ) { - if ( v2->CanAct() ) + if ( pActors[i].CanAct() ) { //UNDEF(v3); //.text:0046BF26 movsx eax, word ptr [esi-2] @@ -1081,17 +959,17 @@ //.text:0046BF31 mov [ebp+var_8], eax //.text:0046BF37 fild [ebp+var_8] // v7 pushed to stack - v7 = v2->vPosition.x - this->vPosition.x; + v7 = pActors[i].vPosition.x - this->vPosition.x; //.text:0046BF2D movsx ecx, word ptr [esi+2] - v8 = v2->vPosition.z; + //v8 = pActors[i].vPosition.z; //.text:0046BF34 movsx eax, word ptr [esi] //.text:0046BF3A sub eax, [edi+8] //.text:0046BF3D mov [ebp+var_8], eax //.text:0046BF44 fild [ebp+var_8] // v9 pushed to stack - v9 = v2->vPosition.y - this->vPosition.y; + v9 = pActors[i].vPosition.y - this->vPosition.y; //.text:0046BF40 movsx eax, word ptr [esi-6] //.text:0046BF47 sar eax, 1 @@ -1101,12 +979,12 @@ //.text:0046BF51 fild [ebp+var_8] //.text:0046BF58 fld st // v10 pushed to stack, two times - v10 = v2->uActorHeight / 2 + v8 - this->vVelocity.y; + v10 = pActors[i].uActorHeight / 2 + pActors[i].vPosition.z - this->vVelocity.y; //.text:0046BF54 movsx eax, word ptr [esi-8] //.text:0046BF5A add eax, 100h //.text:0046BF63 mov ecx, eax - v11 = this->vVelocity.x; + //v11 = this->vVelocity.x; //.text:0046BF5F fmul st, st(1) // stack: v10*v10, v10, v9, v7 @@ -1118,7 +996,7 @@ // stack: v7*v9, v10*v10, v10, v9, v7 //.text:0046BF67 imul ecx, eax - v11 = v11 * v11; + v11 = this->vVelocity.x * this->vVelocity.x; //.text:0046BF6A faddp st(1), st // stack: v10*v10+v7*v9, v10, v9, v7 @@ -1148,23 +1026,16 @@ //.text:0046BF83 fstp st //.text:0046BF85 jnz short loc_46BFDD - if ( v11 >= v10*v10+v7*v9+v7*v7 ) + if ( v11 >= v7 * v7 + v9 * v9 + v10 * v10 ) { - if ( stru_50C198.GetMagicalResistance(v2, 0xAu) ) + if ( stru_50C198.GetMagicalResistance(&pActors[i], 0xAu) ) { - v2->pActorBuffs[v1->spell_id].Apply( - pParty->uTimePlayed + (signed int)(signed __int64)((double)(v1->spell_level << 7) * 0.033333335), - v1->spell_skill, - 4u, - 0, - 0); - HIWORD(v2->uAttributes) |= 8u; + pActors[i].pActorBuffs[this->spell_id].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(this->spell_level << 7) * 0.033333335), + this->spell_skill, 4, 0, 0); + HIWORD(pActors[i].uAttributes) |= 8; } } } - ++v6; - ++v2; } - while ( v6 < (signed int)uNumActors ); } } \ No newline at end of file
--- a/Viewport.cpp Tue Dec 03 16:35:57 2013 +0600 +++ b/Viewport.cpp Thu Jan 02 09:11:01 2014 +0600 @@ -669,7 +669,7 @@ { if ( !pParty->pPickedItem.uItemID ) return; - __debugbreak();//no checker + //__debugbreak();//no checker v6 = 0; a1.uType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; if ( (signed int)pObjectList->uNumObjects <= 0 )
--- a/mm7_3.cpp Tue Dec 03 16:35:57 2013 +0600 +++ b/mm7_3.cpp Thu Jan 02 09:11:01 2014 +0600 @@ -58,18 +58,12 @@ unsigned __int8 v6; // sf@12 unsigned __int8 v7; // of@12 int result; // eax@14 - //BLVSector *v9; // ebx@15 - int v10; // ecx@15 + //int v10; // ecx@15 int pFloor; // eax@16 - //BLVFace *v12; // ebp@16 - int v13; // eax@24 - int v14; // esi@24 int v15; // eax@24 int v16; // edx@25 int v17; // eax@29 unsigned int v18; // eax@33 - int v19; // eax@35 - int v20; // edx@35 int v21; // eax@35 int v22; // ecx@36 int v23; // eax@40 @@ -79,24 +73,19 @@ int i; // [sp+18h] [bp-40h]@1 int a10; // [sp+1Ch] [bp-3Ch]@1 int v29; // [sp+20h] [bp-38h]@14 - int v30; // [sp+24h] [bp-34h]@35 - int v31; // [sp+28h] [bp-30h]@24 int v32; // [sp+2Ch] [bp-2Ch]@15 int pSectorsArray[10]; // [sp+30h] [bp-28h]@1 pSector = &pIndoor->pSectors[stru_721530.uSectorID]; - v2 = 0; + i = 1; a10 = b1; pSectorsArray[0] = stru_721530.uSectorID; - for ( i = 1; v2 < pSector->uNumPortals; ++v2 ) + for ( v2 = 0; v2 < pSector->uNumPortals; ++v2 ) { pFace = &pIndoor->pFaces[pSector->pPortals[v2]]; - if ( stru_721530.sMaxX <= pFace->pBounding.x2 - && stru_721530.sMinX >= pFace->pBounding.x1 - && stru_721530.sMaxY <= pFace->pBounding.y2 - && stru_721530.sMinY >= pFace->pBounding.y1 - && stru_721530.sMaxZ <= pFace->pBounding.z2 - && stru_721530.sMinZ >= pFace->pBounding.z1 + if ( stru_721530.sMaxX <= pFace->pBounding.x2 && stru_721530.sMinX >= pFace->pBounding.x1 + && stru_721530.sMaxY <= pFace->pBounding.y2 && stru_721530.sMinY >= pFace->pBounding.y1 + && stru_721530.sMaxZ <= pFace->pBounding.z2 && stru_721530.sMinZ >= pFace->pBounding.z1 && abs((pFace->pFacePlane_old.dist + stru_721530.normal.x * pFace->pFacePlane_old.vNormal.x + stru_721530.normal.y * pFace->pFacePlane_old.vNormal.y @@ -112,51 +101,35 @@ } } result = 0; - v29 = 0; - if ( i > 0 ) + for ( v29 = 0; v29 < i; v29++ ) { - while ( 1 ) + pSector = &pIndoor->pSectors[pSectorsArray[v29]]; + v32 = pSector->uNumFloors + pSector->uNumWalls + pSector->uNumCeilings; + for ( v26 = 0; v26 < v32; v26++ ) { - pSector = &pIndoor->pSectors[pSectorsArray[result]]; - v10 = 0; - v32 = pSector->uNumFloors + pSector->uNumWalls + pSector->uNumCeilings; - v26 = 0; - if ( v32 > 0 ) - break; -LABEL_46: - result = v29++ + 1; - if ( v29 >= i ) - return result; - } - while ( 1 ) - { - pFloor = pSector->pFloors[v10]; - pFace = &pIndoor->pFaces[pFloor]; - if ( pFace->Portal() - || stru_721530.sMaxX > pFace->pBounding.x2 - || stru_721530.sMinX < pFace->pBounding.x1 - || stru_721530.sMaxY > pFace->pBounding.y2 - || stru_721530.sMinY < pFace->pBounding.y1 - || stru_721530.sMaxZ > pFace->pBounding.z2 - || stru_721530.sMinZ < pFace->pBounding.z1 - || pFloor == stru_721530.field_84 ) - goto LABEL_45; - v13 = pFace->pFacePlane_old.vNormal.y; - v14 = pFace->pFacePlane_old.dist; - v31 = v13; - v15 = (stru_721530.normal.x * pFace->pFacePlane_old.vNormal.x + v14 + stru_721530.normal.y * v13 - + stru_721530.normal.z * pFace->pFacePlane_old.vNormal.z) >> 16; + pFloor = pSector->pFloors[v26]; + pFace = &pIndoor->pFaces[pSector->pFloors[v26]]; + if ( !pFace->Portal() + && stru_721530.sMaxX <= pFace->pBounding.x2 && stru_721530.sMinX >= pFace->pBounding.x1 + && stru_721530.sMaxY <= pFace->pBounding.y2 && stru_721530.sMinY >= pFace->pBounding.y1 + && stru_721530.sMaxZ <= pFace->pBounding.z2 && stru_721530.sMinZ >= pFace->pBounding.z1 + && pFloor != stru_721530.field_84 ) + { + v15 = ( pFace->pFacePlane_old.dist + stru_721530.normal.x * pFace->pFacePlane_old.vNormal.x + + stru_721530.normal.y * pFace->pFacePlane_old.vNormal.y + + stru_721530.normal.z * pFace->pFacePlane_old.vNormal.z ) >> 16; if ( v15 > 0 ) { - v16 = (stru_721530.normal2.y * v31 + pFace->pFacePlane_old.dist + stru_721530.normal2.z * pFace->pFacePlane_old.vNormal.z - + stru_721530.normal2.x * pFace->pFacePlane_old.vNormal.x) >> 16; + v16 = ( pFace->pFacePlane_old.dist + stru_721530.normal2.x * pFace->pFacePlane_old.vNormal.x + + stru_721530.normal2.y * pFace->pFacePlane_old.vNormal.y + + stru_721530.normal2.z * pFace->pFacePlane_old.vNormal.z ) >> 16; if ( v15 <= stru_721530.prolly_normal_d || v16 <= stru_721530.prolly_normal_d ) { if ( v16 <= v15 ) { a3 = stru_721530.field_6C; if ( sub_47531C(stru_721530.prolly_normal_d, &a3, stru_721530.normal.x, stru_721530.normal.y, stru_721530.normal.z, - stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, pFace, a10) ) + stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, pFace, a10) ) { v17 = a3; } @@ -180,18 +153,14 @@ } LABEL_34: if ( !(stru_721530.field_0 & 1) - || (v19 = pFace->pFacePlane_old.vNormal.x, - v20 = pFace->pFacePlane_old.vNormal.y, - v30 = v19, - v21 = (stru_721530.position.x * v19 + pFace->pFacePlane_old.dist + stru_721530.position.y * v20 - + stru_721530.position.z * pFace->pFacePlane_old.vNormal.z) >> 16, - v21 <= 0) - || (v22 = (stru_721530.field_4C * v30 + pFace->pFacePlane_old.dist + stru_721530.field_50 * v20 - + stru_721530.field_54 * pFace->pFacePlane_old.vNormal.z) >> 16, - v21 > stru_721530.prolly_normal_d) - && v22 > stru_721530.prolly_normal_d - || v22 > v21 ) - goto LABEL_45; + || (v21 = ( pFace->pFacePlane_old.dist + stru_721530.position.x * pFace->pFacePlane_old.vNormal.x + + stru_721530.position.y * pFace->pFacePlane_old.vNormal.y + + stru_721530.position.z * pFace->pFacePlane_old.vNormal.z) >> 16, v21 <= 0) + || (v22 = ( pFace->pFacePlane_old.dist + stru_721530.field_4C * pFace->pFacePlane_old.vNormal.x + + stru_721530.field_50 * pFace->pFacePlane_old.vNormal.y + + stru_721530.field_54 * pFace->pFacePlane_old.vNormal.z) >> 16, v21 > stru_721530.prolly_normal_d) + && v22 > stru_721530.prolly_normal_d || v22 > v21 ) + continue; a3 = stru_721530.field_6C; if ( sub_47531C(stru_721530.field_8_radius, &a3, stru_721530.position.x, stru_721530.position.y, stru_721530.position.z, stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, pFace, a10) ) @@ -213,11 +182,9 @@ stru_721530.uFaceID = v24; } } -LABEL_45: - v10 = v26++ + 1; - if ( v26 >= v32 ) - goto LABEL_46; + } } + result = v29 + 1; } return result; } @@ -227,259 +194,150 @@ int __fastcall _46E889_collide_against_bmodels(unsigned int ecx0) { int result; // eax@1 - BSPModel *v2; // ecx@3 int v3; // ebx@9 - ODMFace *v4; // eax@11 - int v5; // edi@17 - int v6; // esi@17 - unsigned int v7; // ecx@17 int v8; // eax@19 int v9; // ecx@20 int v10; // eax@24 - int v11; // ST18_4@25 - int v12; // ST1C_4@25 - int v13; // ST0C_4@25 unsigned int v14; // eax@28 int v15; // eax@30 int v16; // ecx@31 unsigned int v17; // eax@36 - int v18; // ST18_4@41 - int v19; // ST1C_4@41 - int v20; // ST0C_4@41 int v21; // eax@42 unsigned int v22; // eax@43 - //BLVFace f; // [sp+Ch] [bp-7Ch]@1 - int v24; // [sp+6Ch] [bp-1Ch]@9 int a11; // [sp+70h] [bp-18h]@1 - unsigned int v26; // [sp+74h] [bp-14h]@2 - unsigned int v27; // [sp+78h] [bp-10h]@10 - BSPModel *v28; // [sp+7Ch] [bp-Ch]@3 int a10; // [sp+80h] [bp-8h]@1 int a2; // [sp+84h] [bp-4h]@23 a11 = ecx0; BLVFace f; // [sp+Ch] [bp-7Ch]@1 - //BLVFace::BLVFace(&f); result = 0; - a10 = 0; - if ( (signed int)pOutdoor->uNumBModels > 0 ) + for ( a10 = 0; a10 < (signed int)pOutdoor->uNumBModels; ++a10 ) { - v26 = 0; - while ( 1 ) + if ( stru_721530.sMaxX <= pOutdoor->pBModels[a10].sMaxX && stru_721530.sMinX >= pOutdoor->pBModels[a10].sMinX + && stru_721530.sMaxY <= pOutdoor->pBModels[a10].sMaxY && stru_721530.sMinY >= pOutdoor->pBModels[a10].sMinY + && stru_721530.sMaxZ <= pOutdoor->pBModels[a10].sMaxZ && stru_721530.sMinZ >= pOutdoor->pBModels[a10].sMinZ ) { - v2 = &pOutdoor->pBModels[v26 / 0xBC]; - v28 = &pOutdoor->pBModels[v26 / 0xBC]; - if ( stru_721530.sMaxX <= pOutdoor->pBModels[v26 / 0xBC].sMaxX ) + for ( v3 = 0; v3 < pOutdoor->pBModels[a10].uNumFaces; ++v3 ) { - if ( stru_721530.sMinX >= v2->sMinX ) + if ( stru_721530.sMaxX <= pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.x2 && stru_721530.sMinX >= pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.x1 + && stru_721530.sMaxY <= pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.y2 && stru_721530.sMinY >= pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.y1 + && stru_721530.sMaxZ <= pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.z2 && stru_721530.sMinZ >= pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.z1 ) { - if ( stru_721530.sMaxY <= v2->sMaxY ) + f.pFacePlane_old.vNormal.x = pOutdoor->pBModels[a10].pFaces[v3].pFacePlane.vNormal.x; + f.pFacePlane_old.vNormal.y = pOutdoor->pBModels[a10].pFaces[v3].pFacePlane.vNormal.y; + f.pFacePlane_old.vNormal.z = pOutdoor->pBModels[a10].pFaces[v3].pFacePlane.vNormal.z; + f.pFacePlane_old.dist = pOutdoor->pBModels[a10].pFaces[v3].pFacePlane.dist; + f.uAttributes = pOutdoor->pBModels[a10].pFaces[v3].uAttributes; + f.pBounding.x1 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.x1; + f.pBounding.y1 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.y1; + f.pBounding.z1 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.z1; + f.pBounding.x2 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.x2; + f.pBounding.y2 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.y2; + f.pBounding.z2 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.z2; + f.zCalc1 = pOutdoor->pBModels[a10].pFaces[v3].zCalc1; + f.zCalc2 = pOutdoor->pBModels[a10].pFaces[v3].zCalc2; + f.zCalc3 = pOutdoor->pBModels[a10].pFaces[v3].zCalc3; + f.pXInterceptDisplacements = pOutdoor->pBModels[a10].pFaces[v3].pXInterceptDisplacements; + f.pYInterceptDisplacements = pOutdoor->pBModels[a10].pFaces[v3].pYInterceptDisplacements; + f.pZInterceptDisplacements = pOutdoor->pBModels[a10].pFaces[v3].pZInterceptDisplacements; + f.uPolygonType = (PolygonType)pOutdoor->pBModels[a10].pFaces[v3].uPolygonType; + f.uNumVertices = pOutdoor->pBModels[a10].pFaces[v3].uNumVertices; + f.uBitmapID = pOutdoor->pBModels[a10].pFaces[v3].uTextureID; + f.pVertexIDs = pOutdoor->pBModels[a10].pFaces[v3].pVertexIDs; + if ( !f.Ethereal() && !f.Portal() ) { - if ( stru_721530.sMinY >= v2->sMinY ) + v8 = (f.pFacePlane_old.dist + f.pFacePlane_old.vNormal.x * stru_721530.normal.x + + f.pFacePlane_old.vNormal.y * stru_721530.normal.y + + f.pFacePlane_old.vNormal.z * stru_721530.normal.z ) >> 16; + if ( v8 > 0 ) { - if ( stru_721530.sMaxZ <= v2->sMaxZ ) + v9 = (f.pFacePlane_old.dist + f.pFacePlane_old.vNormal.x * stru_721530.normal2.x + + f.pFacePlane_old.vNormal.y * stru_721530.normal2.y + + f.pFacePlane_old.vNormal.z * stru_721530.normal2.z) >> 16; + if ( v8 <= stru_721530.prolly_normal_d || v9 <= stru_721530.prolly_normal_d ) { - if ( stru_721530.sMinZ >= v2->sMinZ ) + if ( v9 <= v8 ) { - v3 = 0; - v24 = v2->uNumFaces; - if ( v24 > 0 ) - break; + a2 = stru_721530.field_6C; + if ( sub_4754BF(stru_721530.prolly_normal_d, &a2, stru_721530.normal.x, stru_721530.normal.y, stru_721530.normal.z, + stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, &f, a10, a11) ) + { + v10 = a2; + } + else + { + a2 = stru_721530.prolly_normal_d + stru_721530.field_6C; + if ( !sub_475F30( &a2, &f, stru_721530.normal.x, stru_721530.normal.y, stru_721530.normal.z, + stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, a10) ) + goto LABEL_29; + v10 = a2 - stru_721530.prolly_normal_d; + a2 -= stru_721530.prolly_normal_d; + } + if ( v10 < stru_721530.field_7C ) + { + stru_721530.field_7C = v10; + v14 = 8 * (v3 | (a10 << 6)); + LOBYTE(v14) = v14 | 6; + stru_721530.uFaceID = v14; + } + } + } + } +LABEL_29: + if ( stru_721530.field_0 & 1 ) + { + v15 = (f.pFacePlane_old.dist + f.pFacePlane_old.vNormal.x * stru_721530.position.x + + f.pFacePlane_old.vNormal.y * stru_721530.position.y + + f.pFacePlane_old.vNormal.z * stru_721530.position.z) >> 16; + if ( v15 > 0 ) + { + v16 = (f.pFacePlane_old.dist + f.pFacePlane_old.vNormal.x * stru_721530.field_4C + + f.pFacePlane_old.vNormal.y * stru_721530.field_50 + + f.pFacePlane_old.vNormal.z * stru_721530.field_54) >> 16; + if ( v15 <= stru_721530.prolly_normal_d || v16 <= stru_721530.prolly_normal_d ) + { + if ( v16 <= v15 ) + { + a2 = stru_721530.field_6C; + if ( sub_4754BF(stru_721530.field_8_radius, &a2, stru_721530.position.x, stru_721530.position.y, stru_721530.position.z, + stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, &f, a10, a11) ) + { + if ( a2 < stru_721530.field_7C ) + { + stru_721530.field_7C = a2; + v17 = 8 * (v3 | (a10 << 6)); + LOBYTE(v17) = v17 | 6; + stru_721530.uFaceID = v17; + } + } + else + { + a2 = stru_721530.field_6C + stru_721530.field_8_radius; + if ( sub_475F30(&a2, &f, stru_721530.position.x, stru_721530.position.y, stru_721530.position.z, + stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, a10) ) + { + v21 = a2 - stru_721530.prolly_normal_d; + a2 -= stru_721530.prolly_normal_d; + if ( a2 < stru_721530.field_7C ) + { + stru_721530.field_7C = v21; + v22 = 8 * (v3 | (a10 << 6)); + LOBYTE(v22) = v22 | 6; + stru_721530.uFaceID = v22; + } + } + } + } } } } } } } -LABEL_39: - ++a10; - v26 += 188; - result = a10; - if ( a10 >= (signed int)pOutdoor->uNumBModels ) - return result; } - v27 = 0; - while ( 1 ) - { - v4 = &v2->pFaces[v27 / 0x134]; - if ( stru_721530.sMaxX > v4->pBoundingBox.x2 - || stru_721530.sMinX < v4->pBoundingBox.x1 - || stru_721530.sMaxY > v4->pBoundingBox.y2 - || stru_721530.sMinY < v4->pBoundingBox.y1 - || stru_721530.sMaxZ > v4->pBoundingBox.z2 - || stru_721530.sMinZ < v4->pBoundingBox.z1 ) - goto LABEL_38; - f.pFacePlane_old.vNormal.x = v4->pFacePlane.vNormal.x; - f.pFacePlane_old.vNormal.y = v4->pFacePlane.vNormal.y; - v5 = v4->pFacePlane.vNormal.z; - f.pFacePlane_old.vNormal.z = v4->pFacePlane.vNormal.z; - v6 = v4->pFacePlane.dist; - f.pFacePlane_old.dist = v4->pFacePlane.dist; - v7 = v4->uAttributes; - f.uAttributes = v7; - f.pBounding.x1 = v4->pBoundingBox.x1; - f.pBounding.y1 = v4->pBoundingBox.y1; - f.pBounding.z1 = v4->pBoundingBox.z1; - f.pBounding.x2 = v4->pBoundingBox.x2; - f.pBounding.y2 = v4->pBoundingBox.y2; - f.pBounding.z2 = v4->pBoundingBox.z2; - f.zCalc1 = v4->zCalc1; - f.zCalc2 = v4->zCalc2; - f.zCalc3 = v4->zCalc3; - f.pXInterceptDisplacements = v4->pXInterceptDisplacements; - f.pYInterceptDisplacements = v4->pYInterceptDisplacements; - f.pZInterceptDisplacements = v4->pZInterceptDisplacements; - f.uPolygonType = (PolygonType)v4->uPolygonType; - f.uNumVertices = v4->uNumVertices; - f.uBitmapID = v4->uTextureID; - f.pVertexIDs = v4->pVertexIDs; - if ( !(v7 & 0x20000000) ) - { - if ( !(v7 & 1) ) - break; - } -LABEL_37: - v2 = v28; -LABEL_38: - v27 += 308; - ++v3; - if ( v3 >= v24 ) - goto LABEL_39; - } - v8 = (v5 * stru_721530.normal.z - + v6 - + f.pFacePlane_old.vNormal.y * stru_721530.normal.y - + f.pFacePlane_old.vNormal.x * stru_721530.normal.x) >> 16; - if ( v8 > 0 ) - { - v9 = (v5 * stru_721530.normal2.z - + v6 - + f.pFacePlane_old.vNormal.y * stru_721530.normal2.y - + f.pFacePlane_old.vNormal.x * stru_721530.normal2.x) >> 16; - if ( v8 <= stru_721530.prolly_normal_d || v9 <= stru_721530.prolly_normal_d ) - { - if ( v9 <= v8 ) - { - a2 = stru_721530.field_6C; - if ( sub_4754BF( - stru_721530.prolly_normal_d, - &a2, - stru_721530.normal.x, - stru_721530.normal.y, - stru_721530.normal.z, - stru_721530.direction.x, - stru_721530.direction.y, - stru_721530.direction.z, - &f, - a10, - a11) ) - { - v10 = a2; - } - else - { - v11 = stru_721530.direction.y; - v12 = stru_721530.direction.z; - v13 = stru_721530.normal.y; - a2 = stru_721530.prolly_normal_d + stru_721530.field_6C; - if ( !sub_475F30( - &a2, - &f, - stru_721530.normal.x, - v13, - stru_721530.normal.z, - stru_721530.direction.x, - v11, - v12, - a10) ) - goto LABEL_29; - v10 = a2 - stru_721530.prolly_normal_d; - a2 -= stru_721530.prolly_normal_d; - } - if ( v10 < stru_721530.field_7C ) - { - stru_721530.field_7C = v10; - v14 = 8 * (v3 | (a10 << 6)); - LOBYTE(v14) = v14 | 6; - stru_721530.uFaceID = v14; - } - } - } - } -LABEL_29: - if ( stru_721530.field_0 & 1 ) - { - v15 = (f.pFacePlane_old.vNormal.z * stru_721530.position.z - + f.pFacePlane_old.dist - + f.pFacePlane_old.vNormal.y * stru_721530.position.y - + f.pFacePlane_old.vNormal.x * stru_721530.position.x) >> 16; - if ( v15 > 0 ) - { - v16 = (f.pFacePlane_old.vNormal.z * stru_721530.field_54 - + f.pFacePlane_old.dist - + f.pFacePlane_old.vNormal.y * stru_721530.field_50 - + f.pFacePlane_old.vNormal.x * stru_721530.field_4C) >> 16; - if ( v15 <= stru_721530.prolly_normal_d || v16 <= stru_721530.prolly_normal_d ) - { - if ( v16 <= v15 ) - { - a2 = stru_721530.field_6C; - if ( sub_4754BF(stru_721530.field_8_radius, - &a2, - stru_721530.position.x, - stru_721530.position.y, - stru_721530.position.z, - stru_721530.direction.x, - stru_721530.direction.y, - stru_721530.direction.z, - &f, - a10, - a11) ) - { - if ( a2 < stru_721530.field_7C ) - { - stru_721530.field_7C = a2; - v17 = 8 * (v3 | (a10 << 6)); - LOBYTE(v17) = v17 | 6; - stru_721530.uFaceID = v17; - } - } - else - { - v18 = stru_721530.direction.y; - v19 = stru_721530.direction.z; - v20 = stru_721530.position.y; - a2 = stru_721530.field_6C + stru_721530.field_8_radius; - if ( sub_475F30(&a2, - &f, - stru_721530.position.x, - v20, - stru_721530.position.z, - stru_721530.direction.x, - v18, - v19, - a10) ) - { - v2 = v28; - v21 = a2 - stru_721530.prolly_normal_d; - a2 -= stru_721530.prolly_normal_d; - if ( a2 < stru_721530.field_7C ) - { - stru_721530.field_7C = v21; - v22 = 8 * (v3 | (a10 << 6)); - LOBYTE(v22) = v22 | 6; - stru_721530.uFaceID = v22; - } - goto LABEL_38; - } - } - } - } - } - } - goto LABEL_37; + result = a10; } return result; } @@ -509,75 +367,41 @@ //----- (0046ED8A) -------------------------------------------------------- void __fastcall _46ED8A_collide_against_sprite_objects(unsigned int _this) { - int v1; // ebx@2 - ObjectDesc *v2; // edx@4 - int v3; // esi@5 - int v4; // ecx@5 - int v5; // eax@7 - int v6; // edi@9 - int v7; // edx@9 - int v8; // edi@11 - int v9; // ebx@11 + ObjectDesc *object; // edx@4 int v10; // ecx@12 int v11; // esi@13 - signed int v12; // [sp+0h] [bp-14h]@1 - int v13; // [sp+4h] [bp-10h]@9 - char *v14; // [sp+8h] [bp-Ch]@2 - unsigned int v15; // [sp+10h] [bp-4h]@1 - - v15 = 0; - v12 = _this; + if ( (signed int)uNumSpriteObjects > 0 ) { - v1 = (int)&pSpriteObjects[0].uObjectDescID; - v14 = (char *)&pSpriteObjects[0].uObjectDescID; - do + for ( uint i = 0; i < uNumSpriteObjects; ++i ) { - if ( *(short *)v1 ) + if ( pSpriteObjects[i].uObjectDescID ) { - v2 = &pObjectList->pObjects[*(short *)v1]; - if ( !(v2->uFlags & 2) ) + object = &pObjectList->pObjects[pSpriteObjects[i].uObjectDescID]; + if ( !(object->uFlags & OBJECT_DESC_NO_COLLISION) ) { - v3 = v2->uRadius; - v4 = *(int *)(v1 + 2); - if ( stru_721530.sMaxX <= v4 + v3 ) + if ( stru_721530.sMaxX <= pSpriteObjects[i].vPosition.x + object->uRadius + && stru_721530.sMinX >= pSpriteObjects[i].vPosition.x - object->uRadius + && stru_721530.sMaxY <= pSpriteObjects[i].vPosition.y + object->uRadius + && stru_721530.sMinY >= pSpriteObjects[i].vPosition.y - object->uRadius + && stru_721530.sMaxZ <= pSpriteObjects[i].vPosition.z + object->uHeight + && stru_721530.sMinZ >= pSpriteObjects[i].vPosition.z ) { - if ( stru_721530.sMinX >= v4 - v3 ) + if ( abs(((pSpriteObjects[i].vPosition.x - stru_721530.normal.x) * stru_721530.direction.y + - (pSpriteObjects[i].vPosition.y - stru_721530.normal.y) * stru_721530.direction.x) >> 16) <= object->uHeight + + stru_721530.prolly_normal_d ) { - v5 = *(int *)(v1 + 6); - if ( stru_721530.sMaxY <= v5 + v3 ) + v10 = ((pSpriteObjects[i].vPosition.x - stru_721530.normal.x) * stru_721530.direction.x + + (pSpriteObjects[i].vPosition.y - stru_721530.normal.y) * stru_721530.direction.y) >> 16; + if ( v10 > 0 ) { - if ( stru_721530.sMinY >= v5 - v3 ) + v11 = stru_721530.normal.z + ((unsigned __int64)(stru_721530.direction.z * (signed __int64)v10) >> 16); + if ( v11 >= pSpriteObjects[i].vPosition.z - stru_721530.prolly_normal_d ) { - v6 = v2->uHeight; - v7 = *(int *)(v1 + 10); - v13 = v6; - if ( stru_721530.sMaxZ <= v7 + v6 ) + if ( v11 <= object->uHeight + stru_721530.prolly_normal_d + pSpriteObjects[i].vPosition.z ) { - if ( stru_721530.sMinZ >= v7 ) - { - v8 = v4 - stru_721530.normal.x; - v9 = v5 - stru_721530.normal.y; - if ( abs(((v4 - stru_721530.normal.x) * stru_721530.direction.y - - (v5 - stru_721530.normal.y) * stru_721530.direction.x) >> 16) <= v3 - + stru_721530.prolly_normal_d ) - { - v10 = (v8 * stru_721530.direction.x + v9 * stru_721530.direction.y) >> 16; - if ( v10 > 0 ) - { - v11 = stru_721530.normal.z - + ((unsigned __int64)(stru_721530.direction.z * (signed __int64)v10) >> 16); - if ( v11 >= *(int *)(v14 + 10) - stru_721530.prolly_normal_d ) - { - if ( v11 <= v13 + stru_721530.prolly_normal_d + *(int *)(v14 + 10) ) - { - if ( v10 < stru_721530.field_7C ) - sub_46DEF2(v12, v15); - } - } - } - } - } + if ( v10 < stru_721530.field_7C ) + sub_46DEF2(_this, i); } } } @@ -585,11 +409,7 @@ } } } - ++v15; - v1 = (int)(v14 + 112); - v14 += 112; } - while ( (signed int)v15 < (signed int)uNumSpriteObjects ); } } @@ -612,51 +432,39 @@ v1 = 2 * pParty->field_14_radius; result = pParty->vPosition.x; v9 = pParty->uPartyHeight; - if ( stru_721530.sMaxX <= pParty->vPosition.x + 2 * pParty->field_14_radius ) + if ( stru_721530.sMaxX <= pParty->vPosition.x + v1 && stru_721530.sMinX >= pParty->vPosition.x - v1 + && stru_721530.sMaxY <= pParty->vPosition.y + v1 && stru_721530.sMinY >= pParty->vPosition.y - v1 + && stru_721530.sMaxZ <= (signed int)(pParty->vPosition.z + pParty->uPartyHeight) + && stru_721530.sMinZ >= pParty->vPosition.z ) { - if ( stru_721530.sMinX >= pParty->vPosition.x - v1 ) + v3 = stru_721530.prolly_normal_d + v1; + v11 = pParty->vPosition.x - stru_721530.normal.x; + v4 = ((pParty->vPosition.x - stru_721530.normal.x) * stru_721530.direction.y + - (pParty->vPosition.y - stru_721530.normal.y) * stru_721530.direction.x) >> 16; + v10 = pParty->vPosition.y - stru_721530.normal.y; + result = abs(((pParty->vPosition.x - stru_721530.normal.x) * stru_721530.direction.y + - (pParty->vPosition.y - stru_721530.normal.y) * stru_721530.direction.x) >> 16); + if ( result <= stru_721530.prolly_normal_d + v1 ) { - if ( stru_721530.sMaxY <= pParty->vPosition.y + v1 ) + result = v10 * stru_721530.direction.y; + v5 = (v10 * stru_721530.direction.y + v11 * stru_721530.direction.x) >> 16; + if ( v5 > 0 ) { - if ( stru_721530.sMinY >= pParty->vPosition.y - v1 ) + v6 = ((unsigned __int64)(stru_721530.direction.z * (signed __int64)v5) >> 16) + stru_721530.normal.z; + result = pParty->vPosition.z; + if ( v6 >= pParty->vPosition.z ) { - if ( stru_721530.sMaxZ <= (signed int)(pParty->vPosition.z + pParty->uPartyHeight) ) + result = v9 + pParty->vPosition.z; + if ( v6 <= (signed int)(v9 + pParty->vPosition.z) || v8 ) { - if ( stru_721530.sMinZ >= pParty->vPosition.z ) + result = integer_sqrt(v3 * v3 - v4 * v4); + v7 = v5 - integer_sqrt(v3 * v3 - v4 * v4); + if ( v7 < 0 ) + v7 = 0; + if ( v7 < stru_721530.field_7C ) { - v3 = stru_721530.prolly_normal_d + v1; - v11 = pParty->vPosition.x - stru_721530.normal.x; - v4 = ((pParty->vPosition.x - stru_721530.normal.x) * stru_721530.direction.y - - (pParty->vPosition.y - stru_721530.normal.y) * stru_721530.direction.x) >> 16; - v10 = pParty->vPosition.y - stru_721530.normal.y; - result = abs(((pParty->vPosition.x - stru_721530.normal.x) * stru_721530.direction.y - - (pParty->vPosition.y - stru_721530.normal.y) * stru_721530.direction.x) >> 16); - if ( result <= v3 ) - { - result = v10 * stru_721530.direction.y; - v5 = (v10 * stru_721530.direction.y + v11 * stru_721530.direction.x) >> 16; - if ( v5 > 0 ) - { - v6 = ((unsigned __int64)(stru_721530.direction.z * (signed __int64)v5) >> 16) + stru_721530.normal.z; - result = pParty->vPosition.z; - if ( v6 >= pParty->vPosition.z ) - { - result = v9 + pParty->vPosition.z; - if ( v6 <= (signed int)(v9 + pParty->vPosition.z) || v8 ) - { - result = integer_sqrt(v3 * v3 - v4 * v4); - v7 = v5 - result; - if ( v7 < 0 ) - v7 = 0; - if ( v7 < stru_721530.field_7C ) - { - stru_721530.field_7C = v7; - stru_721530.uFaceID = 4; - } - } - } - } - } + stru_721530.field_7C = v7; + stru_721530.uFaceID = 4; } } } @@ -669,76 +477,51 @@ //----- (0046F04E) -------------------------------------------------------- int _46F04E_collide_against_portals() { - BLVSector *v0; // ecx@1 unsigned int v1; // eax@1 - int v2; // eax@2 - BLVFace *v3; // eax@3 + BLVFace *face; // eax@3 int v4; // ecx@9 int v5; // edx@9 signed int result; // eax@21 - BLVFace *v7; // eax@22 - signed int v8; // [sp+0h] [bp-14h]@1 - BLVSector *v9; // [sp+4h] [bp-10h]@1 unsigned int v10; // [sp+8h] [bp-Ch]@1 int a3; // [sp+Ch] [bp-8h]@13 int v12; // [sp+10h] [bp-4h]@15 - v8 = 0; - v0 = &pIndoor->pSectors[stru_721530.uSectorID]; v1 = 0xFFFFFFu; v10 = 0xFFFFFFu; - v9 = v0; - if ( v0->uNumPortals > 0 ) + for ( uint i = 0; i < pIndoor->pSectors[stru_721530.uSectorID].uNumPortals; ++i ) { - do + if ( pIndoor->pSectors[stru_721530.uSectorID].pPortals[i] != stru_721530.field_80 ) { - v2 = v0->pPortals[v8]; - if ( v2 != stru_721530.field_80 ) + face = &pIndoor->pFaces[pIndoor->pSectors[stru_721530.uSectorID].pPortals[i]]; + if ( stru_721530.sMaxX <= face->pBounding.x2 && stru_721530.sMinX >= face->pBounding.x1 + && stru_721530.sMaxY <= face->pBounding.y2 && stru_721530.sMinY >= face->pBounding.y1 + && stru_721530.sMaxZ <= face->pBounding.z2 && stru_721530.sMinZ >= face->pBounding.z1 ) { - v3 = &pIndoor->pFaces[v2]; - if ( stru_721530.sMaxX <= v3->pBounding.x2 ) + v4 = (stru_721530.normal.x * face->pFacePlane_old.vNormal.x + face->pFacePlane_old.dist + + stru_721530.normal.y * face->pFacePlane_old.vNormal.y + + stru_721530.normal.z * face->pFacePlane_old.vNormal.z) >> 16; + v5 = (stru_721530.normal2.z * face->pFacePlane_old.vNormal.z + face->pFacePlane_old.dist + + stru_721530.normal2.x * face->pFacePlane_old.vNormal.x + + stru_721530.normal2.y * face->pFacePlane_old.vNormal.y) >> 16; + if ( (v4 < stru_721530.prolly_normal_d || v5 < stru_721530.prolly_normal_d) + && (v4 > -stru_721530.prolly_normal_d || v5 > -stru_721530.prolly_normal_d) + && (a3 = stru_721530.field_6C, sub_475D85(&stru_721530.normal, &stru_721530.direction, &a3, face)) + && a3 < (signed int)v10 ) { - if ( stru_721530.sMinX >= v3->pBounding.x1 - && stru_721530.sMaxY <= v3->pBounding.y2 - && stru_721530.sMinY >= v3->pBounding.y1 - && stru_721530.sMaxZ <= v3->pBounding.z2 - && stru_721530.sMinZ >= v3->pBounding.z1 ) - { - v4 = (stru_721530.normal.x * v3->pFacePlane_old.vNormal.x + v3->pFacePlane_old.dist - + stru_721530.normal.y * v3->pFacePlane_old.vNormal.y - + stru_721530.normal.z * v3->pFacePlane_old.vNormal.z) >> 16; - v5 = (stru_721530.normal2.z * v3->pFacePlane_old.vNormal.z + v3->pFacePlane_old.dist - + stru_721530.normal2.x * v3->pFacePlane_old.vNormal.x - + stru_721530.normal2.y * v3->pFacePlane_old.vNormal.y) >> 16; - if ( (v4 < stru_721530.prolly_normal_d || v5 < stru_721530.prolly_normal_d) - && (v4 > -stru_721530.prolly_normal_d || v5 > -stru_721530.prolly_normal_d) - && (a3 = stru_721530.field_6C, sub_475D85(&stru_721530.normal, &stru_721530.direction, &a3, v3)) - && a3 < (signed int)v10 ) - { - v0 = v9; - v10 = a3; - v12 = v9->pPortals[v8]; - } - else - { - v0 = v9; - } - } + v10 = a3; + v12 = pIndoor->pSectors[stru_721530.uSectorID].pPortals[i]; } } - ++v8; } - while ( v8 < v0->uNumPortals ); - v1 = v10; } + v1 = v10; if ( stru_721530.field_7C >= (signed int)v1 && (signed int)v1 <= stru_721530.field_6C ) { stru_721530.field_80 = v12; - v7 = &pIndoor->pFaces[v12]; - if ( v7->uSectorID == stru_721530.uSectorID ) - stru_721530.uSectorID = v7->uBackSectorID; + if ( pIndoor->pFaces[v12].uSectorID == stru_721530.uSectorID ) + stru_721530.uSectorID = pIndoor->pFaces[v12].uBackSectorID; else - stru_721530.uSectorID = v7->uSectorID; + stru_721530.uSectorID = pIndoor->pFaces[v12].uSectorID; stru_721530.field_7C = 268435455; result = 0; } @@ -860,61 +643,28 @@ //----- (004706C6) -------------------------------------------------------- void UpdateActors_ODM() { - Actor *v0; // esi@2 - AIState uAIState; // ax@2 - //unsigned int v2; // ecx@6 int v3; // ebx@6 - //int v4; // eax@8 int v5; // eax@10 int v6; // ecx@10 - //signed int v7; // ebx@10 signed int v8; // ebx@17 - //unsigned __int8 v9; // zf@17 unsigned __int8 v10; // sf@17 unsigned __int16 v11; // ax@21 - //int v12; // eax@29 - //unsigned __int64 v13; // qax@29 - //int v14; // eax@30 - //unsigned __int64 v15; // qax@30 - int v16; // eax@33 - //int v17; // edi@34 - //int v18; // edx@42 - //int v19; // ecx@42 __int16 v20; // ax@42 - //int v21; // ebx@42 - //int v22; // edi@42 - //int v23; // ecx@42 - //__int16 v24; // ax@42 int v25; // eax@45 signed int v26; // ecx@50 - //int v27; // eax@52 int v28; // eax@54 signed int v29; // ebx@57 signed int v30; // eax@57 int v31; // edi@57 signed int i; // ebx@57 unsigned int v33; // ecx@58 - //int v34; // ebx@64 int v35; // edi@64 int v36; // eax@64 - //unsigned __int16 v37; // cx@66 - signed int v38; // edx@71 unsigned int v39; // edi@71 - BSPModel *v40; // eax@75 - ODMFace *v41; // edi@75 - int v42; // ebx@76 - int v43; // ecx@77 - int v44; // edx@77 - __int16 v45; // dx@82 + ODMFace *face; // edi@75 int v46; // ecx@82 signed int v47; // ebx@85 int v48; // edi@85 - int v49; // edi@85 - //int v50; // eax@85 - //unsigned __int64 v51; // qax@85 - //unsigned __int8 v52; // zf@87 - //unsigned __int8 v53; // sf@87 - // unsigned __int8 v54; // of@104 int v55; // eax@107 unsigned int v56; // edi@107 int v57; // ST10_4@107 @@ -925,10 +675,7 @@ Vec3_int_ v62; // [sp+Ch] [bp-44h]@42 int v63; // [sp+18h] [bp-38h]@64 int v64; // [sp+1Ch] [bp-34h]@64 - int v65; // [sp+20h] [bp-30h]@2 - int v66; // [sp+24h] [bp-2Ch]@2 bool v67; // [sp+28h] [bp-28h]@10 - //unsigned int v68; // [sp+2Ch] [bp-24h]@10 unsigned int v69; // [sp+30h] [bp-20h]@6 unsigned int v70; // [sp+34h] [bp-1Ch]@10 int v71; // [sp+38h] [bp-18h]@62 @@ -941,49 +688,38 @@ for (v75 = 0; v75 < uNumActors; ++v75) { - v0 = &pActors[v75]; - v66 = v0->vPosition.x; - v65 = v0->vPosition.y; - uAIState = v0->uAIState; - if ( uAIState == Removed || uAIState == Disabled || uAIState == Summoned || !v0->uMovementSpeed ) - { - continue; - } + if ( pActors[v75].uAIState == Removed || pActors[v75].uAIState == Disabled || pActors[v75].uAIState == Summoned + || !pActors[v75].uMovementSpeed ) + continue; v3 = 0; v69 = 0; - if ( MonsterStats::BelongsToSupertype(v0->pMonsterInfo.uID, MONSTER_SUPERTYPE_WATER_ELEMENTAL) ) + if ( MonsterStats::BelongsToSupertype(pActors[v75].pMonsterInfo.uID, MONSTER_SUPERTYPE_WATER_ELEMENTAL) ) v3 = 1; - v0->uSectorID = 0; - uIsFlying = v0->pMonsterInfo.uFlying; - if ( !v0->CanAct() ) + pActors[v75].uSectorID = 0; + uIsFlying = pActors[v75].pMonsterInfo.uFlying; + if ( !pActors[v75].CanAct() ) uIsFlying = 0; - v70 = IsTerrainSlopeTooHigh(v0->vPosition.x, v0->vPosition.y); - v5 = ODM_GetFloorLevel( - v0->vPosition.x, - v0->vPosition.y, - v0->vPosition.z, - v0->uActorHeight, - &uIsOnWater, - (int *)&v69, - v3); - v6 = v0->vPosition.z; + v70 = IsTerrainSlopeTooHigh(pActors[v75].vPosition.x, pActors[v75].vPosition.y); + v5 = ODM_GetFloorLevel(pActors[v75].vPosition.x, pActors[v75].vPosition.y, pActors[v75].vPosition.z, + pActors[v75].uActorHeight, &uIsOnWater, (int *)&v69, v3); + v6 = pActors[v75].vPosition.z; uIsAboveFloor = 0; v67 = v69 == 0; if ( v6 > v5 + 1 ) uIsAboveFloor = 1; - if ( uAIState == Dead && uIsOnWater && !uIsAboveFloor ) + if ( pActors[v75].uAIState == Dead && uIsOnWater && !uIsAboveFloor ) { - v0->uAIState = Removed; - continue; + pActors[v75].uAIState = Removed; + continue; } - if ( v0->uCurrentActionAnimation == ANIM_Walking ) + if ( pActors[v75].uCurrentActionAnimation == ANIM_Walking ) { - v8 = v0->uMovementSpeed; - if ( (signed __int64)v0->pActorBuffs[ACTOR_BUFF_SLOWED].uExpireTime > 0 ) + v8 = pActors[v75].uMovementSpeed; + if ( (signed __int64)pActors[v75].pActorBuffs[ACTOR_BUFF_SLOWED].uExpireTime > 0 ) { v8 = (signed __int64)((double)v8 * 0.5); } - if ( uAIState == Fleeing || uAIState == Pursuing ) + if ( pActors[v75].uAIState == Fleeing || pActors[v75].uAIState == Pursuing ) { v8 *= 2; } @@ -992,100 +728,97 @@ if ( v8 > 1000 ) v8 = 1000; - v0->vVelocity.x = fixpoint_mul(stru_5C6E00->Cos(v0->uYawAngle), v8); - v0->vVelocity.y = fixpoint_mul(stru_5C6E00->Sin(v0->uYawAngle), v8); + pActors[v75].vVelocity.x = fixpoint_mul(stru_5C6E00->Cos(pActors[v75].uYawAngle), v8); + pActors[v75].vVelocity.y = fixpoint_mul(stru_5C6E00->Sin(pActors[v75].uYawAngle), v8); if ( uIsFlying ) { - v0->vVelocity.z = fixpoint_mul(stru_5C6E00->Sin(v0->uPitchAngle), v8); + pActors[v75].vVelocity.z = fixpoint_mul(stru_5C6E00->Sin(pActors[v75].uPitchAngle), v8); } //v7 = v68; } else { - v0->vVelocity.x = fixpoint_mul(55000, v0->vVelocity.x); - v0->vVelocity.y = fixpoint_mul(55000, v0->vVelocity.y); + pActors[v75].vVelocity.x = fixpoint_mul(55000, pActors[v75].vVelocity.x); + pActors[v75].vVelocity.y = fixpoint_mul(55000, pActors[v75].vVelocity.y); if ( uIsFlying ) - { - v0->vVelocity.z = fixpoint_mul(55000, v0->vVelocity.z); - } + pActors[v75].vVelocity.z = fixpoint_mul(55000, pActors[v75].vVelocity.z); } - if ( v0->vPosition.z < v5 ) + if ( pActors[v75].vPosition.z < v5 ) { - v16 = uIsFlying; - v0->vPosition.z = v5; - v0->vVelocity.z = v16 != 0 ? 0x14 : 0; + pActors[v75].vPosition.z = v5; + pActors[v75].vVelocity.z = uIsFlying != 0 ? 0x14 : 0; } //v17 = 0; if ( !uIsAboveFloor || uIsFlying ) { if ( v70 && !uIsAboveFloor && v67 ) { - v0->vPosition.z = v5; - ODM_GetTerrainNormalAt(v0->vPosition.x, v0->vPosition.y, &v62); + pActors[v75].vPosition.z = v5; + ODM_GetTerrainNormalAt(pActors[v75].vPosition.x, pActors[v75].vPosition.y, &v62); v20 = GetGravityStrength(); //v21 = v62.y; //v22 = v62.z; //v23 = v62.y * v0->vVelocity.y; - v0->vVelocity.z += -8 * LOWORD(pEventTimer->uTimeElapsed) * v20; - int v73 = abs(v62.x * v0->vVelocity.x + v62.z * v0->vVelocity.z + v62.y * v0->vVelocity.y) >> 16; + pActors[v75].vVelocity.z += -8 * LOWORD(pEventTimer->uTimeElapsed) * v20; + int v73 = abs(v62.x * pActors[v75].vVelocity.x + v62.z * pActors[v75].vVelocity.z + v62.y * pActors[v75].vVelocity.y) >> 16; //v72b = v21; - v0->vVelocity.x += fixpoint_mul(v73, v62.x); - v0->vVelocity.y += fixpoint_mul(v73, v62.y); - v0->vVelocity.z += fixpoint_mul(v73, v62.z); + pActors[v75].vVelocity.x += fixpoint_mul(v73, v62.x); + pActors[v75].vVelocity.y += fixpoint_mul(v73, v62.y); + pActors[v75].vVelocity.z += fixpoint_mul(v73, v62.z); //v17 = 0; } } else { - v0->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength(); + pActors[v75].vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength(); } - if ( pParty->armageddon_timer != 0 && v0->CanAct() ) + if ( pParty->armageddon_timer != 0 && pActors[v75].CanAct() ) { - v0->vVelocity.x += rand() % 100 - 50; - v0->vVelocity.y += rand() % 100 - 50; - v0->vVelocity.z += rand() % 100 - 20; + pActors[v75].vVelocity.x += rand() % 100 - 50; + pActors[v75].vVelocity.y += rand() % 100 - 50; + pActors[v75].vVelocity.z += rand() % 100 - 20; v25 = rand(); - v0->uAIState = Stunned; - v0->uYawAngle += v25 % 32 - 16; - v0->UpdateAnimation(); + pActors[v75].uAIState = Stunned; + pActors[v75].uYawAngle += v25 % 32 - 16; + pActors[v75].UpdateAnimation(); } - if ( v0->vVelocity.x * v0->vVelocity.x + v0->vVelocity.y * v0->vVelocity.y < 400 && v70 == 0 ) + if ( pActors[v75].vVelocity.x * pActors[v75].vVelocity.x + pActors[v75].vVelocity.y * pActors[v75].vVelocity.y < 400 && v70 == 0 ) { - v0->vVelocity.y = 0; - v0->vVelocity.x = 0; + pActors[v75].vVelocity.y = 0; + pActors[v75].vVelocity.x = 0; } stru_721530.field_0 = 1; if ( !uIsFlying ) v26 = 40; else - v26 = v0->uActorRadius; + v26 = pActors[v75].uActorRadius; stru_721530.field_84 = -1; stru_721530.field_8_radius = v26; stru_721530.prolly_normal_d = v26; - stru_721530.height = v0->uActorHeight; + stru_721530.height = pActors[v75].uActorHeight; stru_721530.field_70 = 0; - v69 = 0; - while ( 1 ) + + for ( v69 = 0; v69 < 100; ++v69 ) { - stru_721530.position.x = v0->vPosition.x; + stru_721530.position.x = pActors[v75].vPosition.x; stru_721530.normal.x = stru_721530.position.x; - stru_721530.position.y = v0->vPosition.y; + stru_721530.position.y = pActors[v75].vPosition.y; stru_721530.normal.y = stru_721530.position.y; - v28 = v0->vPosition.z; + v28 = pActors[v75].vPosition.z; stru_721530.normal.z = v28 + v26 + 1; stru_721530.position.z = v28 - v26 + stru_721530.height - 1; if ( stru_721530.position.z < stru_721530.normal.z ) stru_721530.position.z = v28 + v26 + 1; - stru_721530.velocity.x = v0->vVelocity.x; + stru_721530.velocity.x = pActors[v75].vVelocity.x; stru_721530.uSectorID = 0; - stru_721530.velocity.y = v0->vVelocity.y; - stru_721530.velocity.z = v0->vVelocity.z; + stru_721530.velocity.y = pActors[v75].vVelocity.y; + stru_721530.velocity.z = pActors[v75].vVelocity.z; if ( stru_721530._47050A(0) ) break; - _46E889_collide_against_bmodels(1u); - v29 = WorldPosToGridCellZ(v0->vPosition.y); - v30 = WorldPosToGridCellX(v0->vPosition.x); + _46E889_collide_against_bmodels(1); + v29 = WorldPosToGridCellZ(pActors[v75].vPosition.y); + v30 = WorldPosToGridCellX(pActors[v75].vPosition.x); _46E26D_collide_against_sprites(v30, v29); _46EF01_collision_chech_player(0); _46ED8A_collide_against_sprite_objects(PID(OBJECT_Actor,v75)); @@ -1101,182 +834,159 @@ v70 = fixpoint_mul(stru_721530.field_7C, stru_721530.direction.z); //v34 = 0; v35 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1; - v36 = ODM_GetFloorLevel(stru_721530.normal2.x, - stru_721530.normal2.y, + v36 = ODM_GetFloorLevel(stru_721530.normal2.x, stru_721530.normal2.y, stru_721530.normal2.z - stru_721530.prolly_normal_d - 1, - v0->uActorHeight, - (int *)&v63, - &v64, - 0); + pActors[v75].uActorHeight, (int *)&v63, &v64, 0); if ( uIsOnWater ) { if ( v35 < v36 + 60 ) { - if ( uAIState == Dead || uAIState == Dying || uAIState == Removed || uAIState == Disabled ) + if ( pActors[v75].uAIState == Dead || pActors[v75].uAIState == Dying || pActors[v75].uAIState == Removed + || pActors[v75].uAIState == Disabled ) { if ( v64 ) v61 = v36 + 30; else v61 = v5 + 60; - sub_42F960_create_object(v0->vPosition.x, v0->vPosition.y, v61); - v0->uAIState = Removed; + sub_42F960_create_object(pActors[v75].vPosition.x, pActors[v75].vPosition.y, v61); + pActors[v75].uAIState = Removed; return; } } } if ( stru_721530.field_7C >= stru_721530.field_6C ) { - v0->vPosition.x = LOWORD(stru_721530.normal2.x); - v0->vPosition.y = LOWORD(stru_721530.normal2.y); - v0->vPosition.z = LOWORD(stru_721530.normal2.z) - LOWORD(stru_721530.prolly_normal_d) - 1; + pActors[v75].vPosition.x = LOWORD(stru_721530.normal2.x); + pActors[v75].vPosition.y = LOWORD(stru_721530.normal2.y); + pActors[v75].vPosition.z = LOWORD(stru_721530.normal2.z) - LOWORD(stru_721530.prolly_normal_d) - 1; break; } //v72b = fixpoint_mul(stru_721530.field_7C, stru_721530.field_58.x); - v0->vPosition.x += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.x); + pActors[v75].vPosition.x += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.x); //v72b = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16; - v0->vPosition.y += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.y); + pActors[v75].vPosition.y += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.y); //v72b = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16; - v0->vPosition.z += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.z); - v38 = stru_721530.uFaceID; + pActors[v75].vPosition.z += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.z); stru_721530.field_70 += stru_721530.field_7C; - v39 = PID_ID(v38); - switch ( PID_TYPE(v38) ) + v39 = PID_ID(stru_721530.uFaceID); + switch ( PID_TYPE(stru_721530.uFaceID) ) { case OBJECT_Actor: if ( pTurnEngine->turn_stage != 2 && pTurnEngine->turn_stage != 3 || pParty->bTurnBasedModeOn != 1 ) { //if(pParty->bTurnBasedModeOn == 1) //v34 = 0; - if ( v0->pMonsterInfo.uHostilityType ) + if ( pActors[v75].pMonsterInfo.uHostilityType ) { if ( v71 == 0 ) - { - Actor::AI_Flee(v75, v38, 0, (AIDirection *)0); - } - else - { - Actor::AI_StandOrBored(v75, 4, 0, (AIDirection *)0); - } + Actor::AI_Flee(v75, stru_721530.uFaceID, 0, (AIDirection *)0); + else + Actor::AI_StandOrBored(v75, 4, 0, (AIDirection *)0); } else if ( v71 ) - { Actor::AI_StandOrBored(v75, 4, 0, (AIDirection *)0); - } - else if ( pActors[v39].pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Friendly ) - { - Actor::AI_Flee(v75, v38, 0, (AIDirection *)0); - } - else - { - Actor::AI_FaceObject(v75, v38, 0, (AIDirection *)0); - } + else if ( pActors[v39].pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Friendly ) + Actor::AI_Flee(v75, stru_721530.uFaceID, 0, (AIDirection *)0); + else + Actor::AI_FaceObject(v75, stru_721530.uFaceID, 0, (AIDirection *)0); } break; case OBJECT_Player: - if ( !v0->GetActorsRelation(0) ) + if ( !pActors[v75].GetActorsRelation(0) ) { - v38 = stru_721530.uFaceID; - Actor::AI_FaceObject(v75, v38, 0, (AIDirection *)0); + Actor::AI_FaceObject(v75, stru_721530.uFaceID, 0, (AIDirection *)0); break; } //v52 = HIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) == 0; //v53 = SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) < 0; - v0->vVelocity.y = 0; - v0->vVelocity.x = 0; + pActors[v75].vVelocity.y = 0; + pActors[v75].vVelocity.x = 0; //if ( !v53 && (!(v53 | v52) || LODWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) > 0) ) - if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime < 0) + if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime < 0) pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset(); viewparams->bRedrawGameUI = 1; break; case OBJECT_Decoration: - v47 = integer_sqrt(v0->vVelocity.x * v0->vVelocity.x + v0->vVelocity.y * v0->vVelocity.y); - v48 = stru_5C6E00->Atan2( - v0->vPosition.x - pLevelDecorations[v39].vPosition.x, - v0->vPosition.y - pLevelDecorations[v39].vPosition.y); - v49 = v48; - v0->vVelocity.x = fixpoint_mul(stru_5C6E00->Cos(v48), v47); - v0->vVelocity.y = fixpoint_mul(stru_5C6E00->Sin(v48), v47); + v47 = integer_sqrt(pActors[v75].vVelocity.x * pActors[v75].vVelocity.x + pActors[v75].vVelocity.y * pActors[v75].vVelocity.y); + v48 = stru_5C6E00->Atan2( pActors[v75].vPosition.x - pLevelDecorations[v39].vPosition.x, + pActors[v75].vPosition.y - pLevelDecorations[v39].vPosition.y); + //v49 = v48; + pActors[v75].vVelocity.x = fixpoint_mul(stru_5C6E00->Cos(v48), v47); + pActors[v75].vVelocity.y = fixpoint_mul(stru_5C6E00->Sin(v48), v47); break; case OBJECT_BModel: - v40 = &pOutdoor->pBModels[v38 >> 9]; - v41 = &v40->pFaces[v39 & 0x3F]; - if ( !(v41->uAttributes & 0x20000000) ) + face = &pOutdoor->pBModels[stru_721530.uFaceID >> 9].pFaces[v39 & 0x3F]; + if ( !face->Ethereal() ) { - v42 = v41->uPolygonType; - if ( v42 == 3 ) + if ( face->uPolygonType == 3 ) { - v43 = v0->vVelocity.y; - v44 = v0->vVelocity.x; - v0->vVelocity.z = 0; - v0->vPosition.z = LOWORD(v40->pVertices.pVertices[v41->pVertexIDs[0]].z) + 1; - if ( v44 * v44 + v43 * v43 < 400 ) + pActors[v75].vVelocity.z = 0; + pActors[v75].vPosition.z = LOWORD(pOutdoor->pBModels[stru_721530.uFaceID >> 9].pVertices.pVertices[face->pVertexIDs[0]].z) + 1; + if ( pActors[v75].vVelocity.x * pActors[v75].vVelocity.x + + pActors[v75].vVelocity.y * pActors[v75].vVelocity.y < 400 ) { - v0->vVelocity.y = 0; - v0->vVelocity.x = 0; + pActors[v75].vVelocity.y = 0; + pActors[v75].vVelocity.x = 0; } } else { - v72b = abs(v41->pFacePlane.vNormal.y * v0->vVelocity.y + v41->pFacePlane.vNormal.z * v0->vVelocity.z - + v41->pFacePlane.vNormal.x * v0->vVelocity.x) >> 16; + v72b = abs(face->pFacePlane.vNormal.y * pActors[v75].vVelocity.y + face->pFacePlane.vNormal.z * pActors[v75].vVelocity.z + + face->pFacePlane.vNormal.x * pActors[v75].vVelocity.x) >> 16; if ( (stru_721530.speed >> 3) > v72b ) v72b = stru_721530.speed >> 3; - v0->vVelocity.x += fixpoint_mul(v72b, v41->pFacePlane.vNormal.x); - v0->vVelocity.y += fixpoint_mul(v72b, v41->pFacePlane.vNormal.y); - v0->vVelocity.z += fixpoint_mul(v72b, v41->pFacePlane.vNormal.z); - if ( v42 != 4 ) + pActors[v75].vVelocity.x += fixpoint_mul(v72b, face->pFacePlane.vNormal.x); + pActors[v75].vVelocity.y += fixpoint_mul(v72b, face->pFacePlane.vNormal.y); + pActors[v75].vVelocity.z += fixpoint_mul(v72b, face->pFacePlane.vNormal.z); + if ( face->uPolygonType != 4 ) { - v45 = v0->vPosition.z; v46 = stru_721530.prolly_normal_d - - ((v41->pFacePlane.dist - + v41->pFacePlane.vNormal.x * v0->vPosition.x - + v41->pFacePlane.vNormal.y * v0->vPosition.y - + v41->pFacePlane.vNormal.z * v0->vPosition.z) >> 16); + - ((face->pFacePlane.dist + + face->pFacePlane.vNormal.x * pActors[v75].vPosition.x + + face->pFacePlane.vNormal.y * pActors[v75].vPosition.y + + face->pFacePlane.vNormal.z * pActors[v75].vPosition.z) >> 16); if ( v46 > 0 ) { - v0->vPosition.x += (unsigned int)(v46 * v41->pFacePlane.vNormal.x) >> 16; - v0->vPosition.y += (unsigned int)(v46 * v41->pFacePlane.vNormal.y) >> 16; - v0->vPosition.z = v45 + ((unsigned int)(v46 * v41->pFacePlane.vNormal.z) >> 16); + pActors[v75].vPosition.x += (unsigned int)(v46 * face->pFacePlane.vNormal.x) >> 16; + pActors[v75].vPosition.y += (unsigned int)(v46 * face->pFacePlane.vNormal.y) >> 16; + pActors[v75].vPosition.z += (unsigned int)(v46 * face->pFacePlane.vNormal.z) >> 16; } - v0->uYawAngle = stru_5C6E00->Atan2(v0->vVelocity.x, v0->vVelocity.y); + pActors[v75].uYawAngle = stru_5C6E00->Atan2(pActors[v75].vVelocity.x, pActors[v75].vVelocity.y); } } } break; } - v0->vVelocity.x = fixpoint_mul(58500, v0->vVelocity.x); - v0->vVelocity.y = fixpoint_mul(58500, v0->vVelocity.y); - v0->vVelocity.z = fixpoint_mul(58500, v0->vVelocity.z); - - ++v69; - if ( v69 >= 100 ) - break; + pActors[v75].vVelocity.x = fixpoint_mul(58500, pActors[v75].vVelocity.x); + pActors[v75].vVelocity.y = fixpoint_mul(58500, pActors[v75].vVelocity.y); + pActors[v75].vVelocity.z = fixpoint_mul(58500, pActors[v75].vVelocity.z); + v26 = stru_721530.prolly_normal_d; } - v58 = ((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(WorldPosToGridCellX(v66), WorldPosToGridCellZ(v65) - 1) >> 1) & 1; - v59 = ((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(WorldPosToGridCellX(v0->vPosition.x), WorldPosToGridCellZ(v0->vPosition.y) - 1) >> 1) & 1; - if ( WorldPosToGridCellX(v66) == WorldPosToGridCellX(v0->vPosition.x) - && WorldPosToGridCellZ(v65) == WorldPosToGridCellZ(v0->vPosition.y) - && v58 - || v67 != 0 ) + + v58 = ((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(WorldPosToGridCellX(pActors[v75].vPosition.x), WorldPosToGridCellZ(pActors[v75].vPosition.y) - 1) >> 1) & 1; + v59 = ((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(WorldPosToGridCellX(pActors[v75].vPosition.x), WorldPosToGridCellZ(pActors[v75].vPosition.y) - 1) >> 1) & 1; + if ( WorldPosToGridCellX(pActors[v75].vPosition.x) == WorldPosToGridCellX(pActors[v75].vPosition.x) + && WorldPosToGridCellZ(pActors[v75].vPosition.y) == WorldPosToGridCellZ(pActors[v75].vPosition.y) + && v58 || v67 != 0 ) { - if ( MonsterStats::BelongsToSupertype(v0->pMonsterInfo.uID, MONSTER_SUPERTYPE_WATER_ELEMENTAL) ) + if ( MonsterStats::BelongsToSupertype(pActors[v75].pMonsterInfo.uID, MONSTER_SUPERTYPE_WATER_ELEMENTAL) ) { v58 = v58 == 0; v59 = v59 == 0; } if ( !uIsFlying && v58 && !v59 ) { - v0->vPosition.x = v66; - v0->vPosition.y = v65; - if ( v0->CanAct() ) + pActors[v75].vPosition.x = pActors[v75].vPosition.x; + pActors[v75].vPosition.y = pActors[v75].vPosition.y; + if ( pActors[v75].CanAct() ) { - v0->uYawAngle -= 32; - v0->uCurrentActionTime = 0; - v0->uCurrentActionLength = 128; - v0->uAIState = Fleeing; + pActors[v75].uYawAngle -= 32; + pActors[v75].uCurrentActionTime = 0; + pActors[v75].uCurrentActionLength = 128; + pActors[v75].uAIState = Fleeing; } } } @@ -1290,13 +1000,11 @@ //unsigned int v1; // edi@1 //char *v2; // esi@2 //__int16 v3; // dx@5 - ObjectDesc *v4; // eax@5 + ObjectDesc *object; // eax@5 int v5; // ecx@6 __int16 v6; // cx@7 signed int v7; // eax@9 - __int16 v8; // cx@14 - __int16 v9; // dx@14 - unsigned int v10; // ecx@16 + //unsigned int v10; // ecx@16 signed int v11; // eax@17 int v12; // edi@27 int v13; // eax@27 @@ -1321,47 +1029,45 @@ item->uAttributes &= ~OBJECT_40; else { - //v3 = item->uObjectDescID; - v4 = &pObjectList->pObjects[item->uObjectDescID]; + object = &pObjectList->pObjects[item->uObjectDescID]; if (item->AttachedToActor()) { v5 = PID_ID(item->spell_target_pid); - item->vPosition.x = pActors[v5].vPosition.x; + item->vPosition.x = pActors[v5].vPosition.x; item->vPosition.y = pActors[v5].vPosition.y; item->vPosition.z = pActors[v5].vPosition.z + pActors[v5].uActorHeight; - if ( !item->uObjectDescID || (v6 = LOWORD(pEventTimer->uTimeElapsed) + item->uSpriteFrameID, item->uSpriteFrameID = v6, !(v4->uFlags & 4)) ) + if ( !item->uObjectDescID ) continue; - if ( v6 >= 0 ) + item->uSpriteFrameID += pEventTimer->uTimeElapsed; + if ( !(object->uFlags & OBJECT_DESC_TEMPORARY)) + continue; + if ( item->uSpriteFrameID >= 0 ) { - v7 = v4->uLifetime; - if (item->uAttributes & 2) + v7 = object->uLifetime; + if (item->uAttributes & ITEM_BROKEN) v7 = item->field_20; - if ( v6 < v7 ) + if ( item->uSpriteFrameID < v7 ) continue; } - v10 = i; - SpriteObject::OnInteraction(v10); - continue; + SpriteObject::OnInteraction(i); + continue; } if ( item->uObjectDescID ) { - v8 = LOWORD(pEventTimer->uTimeElapsed) + item->uSpriteFrameID; - item->uSpriteFrameID = v8; - v9 = v4->uFlags; - if ( v9 & 4 ) - { - if ( v8 < 0 ) - { - v10 = i; - SpriteObject::OnInteraction(v10); - continue; - } - v11 = v4->uLifetime; - if (item->uAttributes & 2) - v11 = item->field_20; - } - if ( !(v9 & 4) || v8 < v11 ) + item->uSpriteFrameID += pEventTimer->uTimeElapsed; + if ( object->uFlags & OBJECT_DESC_TEMPORARY ) + { + if ( item->uSpriteFrameID < 0 ) + { + SpriteObject::OnInteraction(i); + continue; + } + v11 = object->uLifetime; + if (item->uAttributes & ITEM_BROKEN) + v11 = item->field_20; + } + if ( !(object->uFlags & OBJECT_DESC_TEMPORARY) || item->uSpriteFrameID < v11 ) { if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) SpriteObject::UpdateObject_fn0_BLV(i); @@ -1395,23 +1101,17 @@ v0 = (unsigned int)(11 * v14) >> 5; if ( (signed int)(v0 + (v15 >> 2) + v13) <= 5120 ) continue; - v10 = i; - SpriteObject::OnInteraction(v10); + SpriteObject::OnInteraction(i); continue; } - v10 = i; - if ( !(v9 & 0x40) ) - { - SpriteObject::OnInteraction(v10); + if ( !(object->uFlags & OBJECT_DESC_INTERACTABLE) ) + { + SpriteObject::OnInteraction(i); continue; - } + } _46BFFA_check_object_intercept(i, PID(OBJECT_Item,i)); } } - //v2 += 112; - //v1 = v20++ + 1; - //} - //while ( v20 < (signed int)uNumSpriteObjects ); } } @@ -1451,623 +1151,15 @@ return result; } -//----- (00472866) -------------------------------------------------------- -void BLV_ProcessPartyActions() +//----- (0047531C) -------------------------------------------------------- +bool sub_47531C(int a1, int *a2, int pos_x, int pos_y, int pos_z, int dir_x, int dir_y, int dir_z, BLVFace *face, int a10) { - int v1; // ebx@1 - int v2; // edi@1 - //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 v17; // eax@62 - double v18; // st7@62 - int v19; // ST40_4@62 - int v20; // eax@65 - double v21; // st7@65 - int v22; // ST40_4@65 - int v23; // eax@66 - double v24; // st7@66 - int v25; // ST40_4@66 - int v26; // eax@67 - double v27; // st7@67 - int v28; // ST40_4@67 - unsigned int v35; // eax@74 - int v36; // ecx@88 - int new_party_z; // esi@96 - int v38; // eax@96 - int v39; // ecx@106 - int v40; // eax@106 - Player **v41; // esi@113 - int v42; // eax@120 - signed int v43; // ecx@123 - BLVFace *v44; // esi@126 - PolygonType v45; // al@126 - int v46; // ecx@133 - char v47; // zf@133 - int v48; // eax@133 - int v49; // ST40_4@136 - int v50; // ST40_4@140 - int v51; // eax@140 - int v52; // eax@140 - signed int v53; // edi@146 - int v54; // ebx@146 - int v55; // ST30_4@146 - AudioPlayer *v56; // ecx@162 - SoundID v57; // [sp-20h] [bp-80h]@163 - signed int v58; // [sp-1Ch] [bp-7Ch]@161 - unsigned int v59; // [sp-18h] [bp-78h]@161 - signed int v60; // [sp-14h] [bp-74h]@161 - signed int v61; // [sp-10h] [bp-70h]@161 - int v62; // [sp-Ch] [bp-6Ch]@161 - int v63; // [sp-8h] [bp-68h]@75 - 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 v69; // [sp+10h] [bp-50h]@140 - unsigned int uFaceEvent; // [sp+14h] [bp-4Ch]@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 - bool bFeatherFall; // [sp+24h] [bp-3Ch]@15 - unsigned int uSectorID; // [sp+28h] [bp-38h]@1 - int v78; // [sp+2Ch] [bp-34h]@1 - unsigned int uFaceID; // [sp+30h] [bp-30h]@1 - int v80; // [sp+34h] [bp-2Ch]@1 - int v81; // [sp+38h] [bp-28h]@47 - int v82; // [sp+3Ch] [bp-24h]@47 - int _view_angle; // [sp+40h] [bp-20h]@47 - int bJumping; // [sp+44h] [bp-1Ch]@1 - int new_party_y; // [sp+48h] [bp-18h]@1 - int new_party_x; // [sp+4Ch] [bp-14h]@1 - int party_z; // [sp+50h] [bp-10h]@1 - //int v89; // [sp+58h] [bp-8h]@1 - int angle; // [sp+5Ch] [bp-4h]@47 - - uFaceEvent = 0; - //v89 = pParty->uFallSpeed; - v1 = 0; - v2 = 0; - new_party_x = pParty->vPosition.x; - new_party_y = pParty->vPosition.y; - party_z = pParty->vPosition.z; - uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); - v72 = 0; - v78 = 0; - bJumping = 0; - - uFaceID = -1; - int 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; - } - - 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; - pParty->uFallStartY = blv_prev_party_y; - return; - } - } - - blv_prev_party_x = pParty->vPosition.x; - blv_prev_party_z = pParty->vPosition.y; - blv_prev_party_y = pParty->vPosition.z; - if (!pParty->bTurnBasedModeOn) - { - int v67 = GetTickCount() / 500; - if (dword_720CDC != v67 ) - { - dword_4F8580[3 * dword_4F8580[1]] = pParty->vPosition.x; - dword_4F8580[3 * dword_4F8580[2]] = pParty->vPosition.y; - dword_4F8580[3 * dword_4F8580[3]] = pParty->vPosition.z; - if ( dword_4F8580[0] > 60 ) - dword_4F8580[0] = 1; - } - dword_720CDC = v67; - } - - uint fall_start; - if (!pParty->FeatherFallActive()) - { - bFeatherFall = false; - if (!pParty->pPlayers[0].WearsItemAnyWhere(ITEM_ARTIFACT_LADYS_ESCORT) && // grants feather fall - !pParty->pPlayers[1].WearsItemAnyWhere(ITEM_ARTIFACT_LADYS_ESCORT) && - !pParty->pPlayers[2].WearsItemAnyWhere(ITEM_ARTIFACT_LADYS_ESCORT) && - !pParty->pPlayers[3].WearsItemAnyWhere(ITEM_ARTIFACT_LADYS_ESCORT)) - { - fall_start = pParty->uFallStartY; - } - } - else - { - fall_start = floor_level; - bFeatherFall = true; - 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 - Player* player = &pParty->pPlayers[i]; - if (!player->HasEnchantedItemEquipped(72) && !player->WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, EQUIP_BOOTS)) - { - player->ReceiveDamage((pParty->uFallStartY - party_z) * (0.1f * player->GetMaxHealth()) / 256, DMGT_PHISYCAL); - v10 = (double)(20 - player->GetParameterBonus(player->GetActualEndurance())) * flt_6BE3A4_debug_recmod1 * 2.133333333333333; - player->SetRecoveryTime((signed __int64)v10); - } - } - } - - if ( party_z > floor_level + 1 ) - bJumping = 1; - - bool jumping_up = false; - - if ( party_z - floor_level <= 32 ) - { - pParty->uFallStartY = party_z; - 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) - { - BLVFace* 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) - / 180)) >> 16; -//LABEL_87: - while ( pPartyActionQueue->uNumActions ) - { - switch ( pPartyActionQueue->Next() ) - { - case PARTY_TurnLeft: - if (uTurnSpeed) - angle = stru_5C6E00->uDoublePiMask & (angle + uTurnSpeed); - else - angle = stru_5C6E00->uDoublePiMask & (angle + (int)(v82 * fTurnSpeedMultiplier)); - break; - case PARTY_TurnRight: - if (uTurnSpeed) - angle = stru_5C6E00->uDoublePiMask & (angle - uTurnSpeed); - else - angle = stru_5C6E00->uDoublePiMask & (angle - (int)(v82 * fTurnSpeedMultiplier)); - break; - - case PARTY_FastTurnLeft: - if (uTurnSpeed) - angle = stru_5C6E00->uDoublePiMask & (angle + uTurnSpeed); - else - angle = stru_5C6E00->uDoublePiMask & (angle + (int)(2.0f * fTurnSpeedMultiplier * (double)v82)); - break; - - case PARTY_FastTurnRight: - 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 -= fixpoint_mul(stru_5C6E00->Sin(angle), v81 * fWalkSpeedMultiplier / 2); - v1 += fixpoint_mul(stru_5C6E00->Cos(angle), v81 * fWalkSpeedMultiplier / 2); - v78 = 1; - break; - case PARTY_StrafeRight: - v2 += fixpoint_mul(stru_5C6E00->Sin(angle), v81 * fWalkSpeedMultiplier / 2); - v1 -= fixpoint_mul(stru_5C6E00->Cos(angle), v81 * fWalkSpeedMultiplier / 2); - v78 = 1; - break; - case PARTY_WalkForward: - v2 += fixpoint_mul(stru_5C6E00->Cos(angle), 5 * v81 * fWalkSpeedMultiplier); - v1 += fixpoint_mul(stru_5C6E00->Sin(angle), 5 * v81 * fWalkSpeedMultiplier); - v78 = 1; - break; - case PARTY_WalkBackward: - v2 -= fixpoint_mul(stru_5C6E00->Cos(angle), v81 * fBackwardWalkSpeedMultiplier); - v1 -= fixpoint_mul(stru_5C6E00->Sin(angle), v81 * fBackwardWalkSpeedMultiplier); - v78 = 1; - break; - case PARTY_RunForward: - v2 += fixpoint_mul(stru_5C6E00->Cos(angle), 2 * v81 * fWalkSpeedMultiplier); - v1 += fixpoint_mul(stru_5C6E00->Sin(angle), 2 * v81 * fWalkSpeedMultiplier); - v72 = 1; - break; - case PARTY_RunBackward: - //v32 = stru_5C6E00->SinCos(angle); - //v33 = (double)v81; - //v88 = (double)v81; - v2 -= fixpoint_mul(stru_5C6E00->Cos(angle), v81 * fBackwardWalkSpeedMultiplier); - //v34 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi); - v1 -= fixpoint_mul(stru_5C6E00->Sin(angle), v81 * fBackwardWalkSpeedMultiplier); - v72 = 1; - break; - case PARTY_LookUp: - _view_angle += (signed __int64)(flt_6BE150_look_up_down_dangle * 25.0); - if ( _view_angle > 128 ) - _view_angle = 128; - v35 = uActiveCharacter; - if ( uActiveCharacter ) - pPlayers[v35]->PlaySound((PlayerSpeech)SPEECH_63, 0); - break; - case PARTY_LookDown: - _view_angle += (signed __int64)(flt_6BE150_look_up_down_dangle * -25.0); - if ( _view_angle < -128 ) - _view_angle = -128; - v35 = uActiveCharacter; - if ( uActiveCharacter ) - pPlayers[v35]->PlaySound((PlayerSpeech)SPEECH_64, 0); - break; - case PARTY_CenterView: - _view_angle = 0; - break; - case PARTY_Jump: - 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); - } - break; - default: - break; - } - } - v36 = 0; - pParty->sRotationY = angle; - pParty->sRotationX = _view_angle; - if ( bJumping ) - { - pParty->uFallSpeed += -2 * pEventTimer->uTimeElapsed * GetGravityStrength(); - if ( bJumping != v36 && pParty->uFallSpeed <= v36 ) - { - if ( pParty->uFallSpeed < -500 && !pParty->bFlying ) - { - v41 = &pPlayers[1]; - do - { - if ( !(*v41)->HasEnchantedItemEquipped(72) && !(*v41)->WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, EQUIP_BOOTS) ) //was 8 - (*v41)->PlayEmotion(CHARACTER_EXPRESSION_SCARED, 0); - ++v41; - } - while ( (signed int)v41 <= (signed int)&pPlayers[4] ); - } - } - else - pParty->uFallStartY = party_z; - } - else - { - if ( pIndoor->pFaces[uFaceID].pFacePlane_old.vNormal.z < 32768 ) - { - pParty->uFallSpeed -= pEventTimer->uTimeElapsed * GetGravityStrength(); - pParty->uFallStartY = party_z; - } - else - { - if (! (pParty->uFlags & PARTY_FLAGS_1_LANDING) ) - pParty->uFallSpeed = 0; - pParty->uFallStartY = party_z; - } - } - if ( v2 * v2 + v1 * v1 < 400 ) - { - v1 = 0; - v2 = 0; - } - stru_721530.field_84 = -1; - stru_721530.field_70 = 0; - stru_721530.prolly_normal_d = pParty->field_14_radius; - stru_721530.field_8_radius = pParty->field_14_radius / 2; - int v83 = 0; - stru_721530.field_0 = 1; - stru_721530.height = pParty->uPartyHeight - 32; - while ( 1 ) - { - new_party_z = party_z; - stru_721530.position.x = new_party_x; - stru_721530.normal.x = new_party_x; - stru_721530.velocity.x = v2; - stru_721530.position.y = new_party_y; - stru_721530.normal.y = new_party_y; - stru_721530.velocity.y = v1; - stru_721530.normal.z = stru_721530.prolly_normal_d + party_z + 1; - stru_721530.position.z = stru_721530.height + party_z + 1; - stru_721530.velocity.z = pParty->uFallSpeed; - stru_721530.uSectorID = uSectorID; - v38 = 0; - if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->turn_stage == 3 ) - v38 = 13312; - if ( stru_721530._47050A(v38) ) - break; - v73 = 0; - do - { - _46E44E_collide_against_faces_and_portals(1u); - _46E0B2_collide_against_decorations(); - for ( v80 = 0; v80 < (signed int)uNumActors; ++v80 ) - Actor::_46DF1A_collide_against_actor(v80, 0); - if ( _46F04E_collide_against_portals() ) - break; - ++v73; - } - while ( v73 < 100 ); - if ( stru_721530.field_7C >= stru_721530.field_6C ) - { - v39 = stru_721530.normal2.x; - uSectorID = stru_721530.normal2.y; - v40 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1; - } - else - { - v39 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.x) >> 16) + new_party_x; - uSectorID = new_party_y + ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.y) >> 16); - v40 = new_party_z + ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.z) >> 16); - } - v42 = collide_against_floor(v39, uSectorID, v40 + 40, &stru_721530.uSectorID, &uFaceID); - if ( v42 == -30000 || v42 - new_party_z > 128 ) - return; - if ( stru_721530.field_7C >= stru_721530.field_6C ) - { - new_party_x = stru_721530.normal2.x; - new_party_y = stru_721530.normal2.y; - new_party_z = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1; - break; - } - new_party_x += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.x) >> 16; - new_party_y += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.y) >> 16; - v43 = stru_721530.uFaceID; - uSectorID = stru_721530.uSectorID; - stru_721530.field_70 += stru_721530.field_7C; - unsigned long long v87 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.z) >> 16) + new_party_z; - if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Actor) - { - if ( SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) >= 0 - && (SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime)) ) - pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset(); - viewparams->bRedrawGameUI = 1; - } - else if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration) - { - v53 = integer_sqrt(v2 * v2 + v1 * v1); - v80 = v53; - v54 = stru_5C6E00->Atan2(new_party_x - pLevelDecorations[stru_721530.uFaceID >> 3].vPosition.x, - new_party_y - pLevelDecorations[stru_721530.uFaceID >> 3].vPosition.y); - v2 = (unsigned __int64)(stru_5C6E00->Cos(v54) * (signed __int64)v53) >> 16; - v55 = stru_5C6E00->Sin(v54); - v1 = (unsigned __int64)(v55 * (signed __int64)v80) >> 16; - } - else - { - if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_BModel) - { - v44 = &pIndoor->pFaces[(signed int)stru_721530.uFaceID >> 3]; - v45 = v44->uPolygonType; - if ( v45 == 3 ) - { - if ( pParty->uFallSpeed < 0 ) - pParty->uFallSpeed = 0; - v87 = pIndoor->pVertices[*v44->pVertexIDs].z + 1; - if ( pParty->uFallStartY - v87 < 512 ) - pParty->uFallStartY = v87; - if ( v2 * v2 + v1 * v1 < 400 ) - { - v1 = 0; - v2 = 0; - } - if ( pParty->floor_face_pid != PID_ID(v43) && BYTE3(v44->uAttributes) & 4 ) - uFaceEvent = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID; - } - else - { - v46 = pParty->uFallSpeed * v44->pFacePlane_old.vNormal.z; - v47 = v45 == 4; - v48 = v44->pFacePlane_old.vNormal.x; - if ( !v47 ) - { - v80 = abs(v1 * v44->pFacePlane_old.vNormal.y + v46 + v2 * v48) >> 16; - if ((stru_721530.speed >> 3) > v80 ) - v80 = stru_721530.speed >> 3; - v50 = (unsigned __int64)(v80 * (signed __int64)v44->pFacePlane_old.vNormal.x) >> 16; - v81 = v44->pFacePlane_old.vNormal.y; - v81 = (unsigned __int64)(v80 * (signed __int64)v81) >> 16; - v82 = v44->pFacePlane_old.vNormal.z; - v82 = (unsigned __int64)(v80 * (signed __int64)v82) >> 16; - v2 += v50; - pParty->uFallSpeed += v82; - v74 = v44->pFacePlane_old.vNormal.z; - v51 = v44->pFacePlane_old.vNormal.y; - v69 = v44->pFacePlane_old.vNormal.x; - v80 = v51; - v1 += v81; - v52 = stru_721530.prolly_normal_d - ((v44->pFacePlane_old.dist + v87 * v74 + new_party_y * v51 + new_party_x * v69) >> 16); - if ( v52 > 0 ) - { - new_party_x += v52 * v69 >> 16; - new_party_y += v52 * v80 >> 16; - v87 += v52 * v74 >> 16; - } - v43 = stru_721530.uFaceID; - if ( pParty->floor_face_pid != PID_ID(v43) && BYTE3(v44->uAttributes) & 4 ) - uFaceEvent = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID; - } - else - { - v80 = abs(v1 * v44->pFacePlane_old.vNormal.y + v46 + v2 * v48) >> 16; - if ((stru_721530.speed >> 3) > v80 ) - v80 = stru_721530.speed >> 3; - v49 = (unsigned __int64)(v80 * (signed __int64)v44->pFacePlane_old.vNormal.x) >> 16; - v81 = v44->pFacePlane_old.vNormal.y; - v81 = (unsigned __int64)(v80 * (signed __int64)v81) >> 16; - v82 = v44->pFacePlane_old.vNormal.z; - v82 = (unsigned __int64)(v80 * (signed __int64)v82) >> 16; - v2 += v49; - v1 += v81; - pParty->uFallSpeed += v82; - if ( v2 * v2 + v1 * v1 >= 400 ) - { - v43 = stru_721530.uFaceID; - if ( pParty->floor_face_pid != PID_ID(v43) && BYTE3(v44->uAttributes) & 4 ) - uFaceEvent = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID; - } - else - { - v2 = 0; - v1 = 0; - pParty->uFallSpeed = 0; - } - } - } - } - } - v2 = (unsigned __int64)(58500i64 * v2) >> 16; - v1 = (unsigned __int64)(58500i64 * v1) >> 16; - ++v83; - pParty->uFallSpeed = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16; - if ( v83 >= 100 ) - { - new_party_z = v87; - break; - } - } - 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 ) - { - pAudioPlayer->_4AA258(804); - pParty->walk_sound_timer = 64; - } - else if ( v72 && (!bJumping || jumping_up) ) - { - v66 = 0; - v64 = 0; - v62 = 0; - v61 = 0; - v60 = -1; - v59 = 1; - v58 = 804; - if ( !on_water ) - { - v56 = pAudioPlayer; - if ( BYTE2(pIndoor->pFaces[uFaceID].uAttributes) & 0x20 ) - v57 = (SoundID)50; - else - v57 = (SoundID)64; - pAudioPlayer->PlaySound(v57, v58, v59, v60, v61, v62, v64, v66); - } - else - { - v57 = (SoundID)63; - v56 = pAudioPlayer; - pAudioPlayer->PlaySound(v57, v58, v59, v60, v61, v62, v64, v66); - } - } - else if ( v78 && (!bJumping || jumping_up) ) - { - v66 = 0; - v64 = 0; - v62 = 0; - v61 = 0; - v60 = -1; - v59 = 1; - v58 = 804; - if ( on_water ) - { - v57 = (SoundID)102; - v56 = pAudioPlayer; - } - else - { - v56 = pAudioPlayer; - if ( BYTE2(pIndoor->pFaces[uFaceID].uAttributes) & 0x20 ) - v57 = (SoundID)89; - else - v57 = (SoundID)103; - } - pAudioPlayer->PlaySound(v57, v58, v59, v60, v61, v62, v64, v66); - } - else - { - pAudioPlayer->_4AA258(804); - pParty->walk_sound_timer = 64; - } - } - if ( !bJumping || jumping_up ) - pParty->uFlags &= ~PARTY_FLAGS_1_FALLING; - else - pParty->uFlags |= PARTY_FLAGS_1_FALLING; - pParty->uFlags &= ~0x200; - pParty->vPosition.x = new_party_x; - pParty->vPosition.z = new_party_z; - pParty->vPosition.y = new_party_y; - //pParty->uFallSpeed = v89; - if ( !bJumping && BYTE3(pIndoor->pFaces[uFaceID].uAttributes) & 0x40 ) - pParty->uFlags |= 0x200; - if (uFaceEvent) - EventProcessor(uFaceEvent, 0, 1); -} - -//----- (0047531C) -------------------------------------------------------- -bool __fastcall sub_47531C(int a1, int *a2, int a3, int a4, int a5, int a6, int a7, int a8, BLVFace *a9, int a10) -{ - BLVFace *v10; // ebx@1 int v11; // ST1C_4@3 int v12; // edi@3 int v13; // esi@3 int v14; // edi@4 signed __int64 v15; // qtt@6 __int16 v16; // si@7 - int *v18; // [sp+Ch] [bp-Ch]@1 - int v19; // [sp+10h] [bp-8h]@1 int a7a; // [sp+30h] [bp+18h]@7 int a9b; // [sp+38h] [bp+20h]@3 int a9a; // [sp+38h] [bp+20h]@3 @@ -2075,32 +1167,29 @@ signed int a10a; // [sp+3Ch] [bp+24h]@4 int a10c; // [sp+3Ch] [bp+24h]@5 - v10 = a9; - v18 = a2; - v19 = a1; - if ( a10 && BYTE3(a9->uAttributes) & 0x20 ) + if ( a10 && face->Ethereal() ) return 0; - v11 = (unsigned __int64)(a6 * (signed __int64)a9->pFacePlane_old.vNormal.x) >> 16; - a10b = (unsigned __int64)(a7 * (signed __int64)a9->pFacePlane_old.vNormal.y) >> 16; - a9b = (unsigned __int64)(a8 * (signed __int64)a9->pFacePlane_old.vNormal.z) >> 16; + v11 = (unsigned __int64)(dir_x * (signed __int64)face->pFacePlane_old.vNormal.x) >> 16; + a10b = (unsigned __int64)(dir_y * (signed __int64)face->pFacePlane_old.vNormal.y) >> 16; + a9b = (unsigned __int64)(dir_z * (signed __int64)face->pFacePlane_old.vNormal.z) >> 16; v12 = v11 + a9b + a10b; a9a = v11 + a9b + a10b; v13 = (a1 << 16) - - a3 * v10->pFacePlane_old.vNormal.x - - a4 * v10->pFacePlane_old.vNormal.y - - a5 * v10->pFacePlane_old.vNormal.z - - v10->pFacePlane_old.dist; + - pos_x * face->pFacePlane_old.vNormal.x + - pos_y * face->pFacePlane_old.vNormal.y + - pos_z * face->pFacePlane_old.vNormal.z + - face->pFacePlane_old.dist; if ( abs((a1 << 16) - - a3 * v10->pFacePlane_old.vNormal.x - - a4 * v10->pFacePlane_old.vNormal.y - - a5 * v10->pFacePlane_old.vNormal.z - v10->pFacePlane_old.dist) >= a1 << 16 ) + - pos_x * face->pFacePlane_old.vNormal.x + - pos_y * face->pFacePlane_old.vNormal.y + - pos_z * face->pFacePlane_old.vNormal.z - face->pFacePlane_old.dist) >= a1 << 16 ) { a10c = abs(v13) >> 14; if ( a10c > abs(v12) ) return 0; LODWORD(v15) = v13 << 16; HIDWORD(v15) = v13 >> 16; - v14 = v19; + v14 = a1; a10a = v15 / a9a; } else @@ -2108,36 +1197,29 @@ a10a = 0; v14 = abs(v13) >> 16; } - v16 = a4 + ((unsigned int)((unsigned __int64)(a10a * (signed __int64)a7) >> 16) >> 16); - LOWORD(a7a) = (short)a3 - + ((unsigned int)((unsigned __int64)(a10a * (signed __int64)a6) >> 16) >> 16) - - ((unsigned int)(v14 * v10->pFacePlane_old.vNormal.x) >> 16); - HIWORD(a7a) = v16 - ((unsigned int)(v14 * v10->pFacePlane_old.vNormal.y) >> 16); - if ( !sub_475665( - v10, - a7a, - (short)a5 - + ((unsigned int)((unsigned __int64)(a10a * (signed __int64)a8) >> 16) >> 16) - - ((unsigned int)(v14 * v10->pFacePlane_old.vNormal.z) >> 16)) ) + v16 = pos_y + ((unsigned int)((unsigned __int64)(a10a * (signed __int64)dir_y) >> 16) >> 16); + LOWORD(a7a) = (short)pos_x + + ((unsigned int)((unsigned __int64)(a10a * (signed __int64)dir_x) >> 16) >> 16) + - ((unsigned int)(v14 * face->pFacePlane_old.vNormal.x) >> 16); + HIWORD(a7a) = v16 - ((unsigned int)(v14 * face->pFacePlane_old.vNormal.y) >> 16); + if ( !sub_475665(face, a7a, (short)pos_z + ((unsigned int)((unsigned __int64)(a10a * (signed __int64)dir_z) >> 16) >> 16) + - ((unsigned int)(v14 * face->pFacePlane_old.vNormal.z) >> 16)) ) return 0; - *v18 = a10a >> 16; + *a2 = a10a >> 16; if ( a10a >> 16 < 0 ) - *v18 = 0; + *a2 = 0; return 1; } //----- (004754BF) -------------------------------------------------------- -bool __fastcall sub_4754BF(int a1, int *a2, int a3, int a4, int a5, int a6, int a7, int a8, BLVFace *a9, int a10, int a11) +bool sub_4754BF(int a1, int *a2, int X, int Y, int Z, int dir_x, int dir_y, int dir_z, BLVFace *face, int a10, int a11) { - BLVFace *v11; // ebx@1 int v12; // ST1C_4@3 int v13; // edi@3 int v14; // esi@3 int v15; // edi@4 signed __int64 v16; // qtt@6 __int16 v17; // si@7 - int *v19; // [sp+Ch] [bp-Ch]@1 - int v20; // [sp+10h] [bp-8h]@1 int a7a; // [sp+30h] [bp+18h]@7 int a1b; // [sp+38h] [bp+20h]@3 int a1a; // [sp+38h] [bp+20h]@3 @@ -2145,32 +1227,29 @@ signed int a11a; // [sp+40h] [bp+28h]@4 int a11c; // [sp+40h] [bp+28h]@5 - v11 = a9; - v19 = a2; - v20 = a1; - if ( a11 && BYTE3(a9->uAttributes) & 0x20 ) - return 0; - v12 = (unsigned __int64)(a6 * (signed __int64)a9->pFacePlane_old.vNormal.x) >> 16; - a11b = (unsigned __int64)(a7 * (signed __int64)a9->pFacePlane_old.vNormal.y) >> 16; - a1b = (unsigned __int64)(a8 * (signed __int64)a9->pFacePlane_old.vNormal.z) >> 16; + if ( a11 && face->Ethereal() ) + return false; + v12 = (unsigned __int64)(dir_x * (signed __int64)face->pFacePlane_old.vNormal.x) >> 16; + a11b = (unsigned __int64)(dir_y * (signed __int64)face->pFacePlane_old.vNormal.y) >> 16; + a1b = (unsigned __int64)(dir_z * (signed __int64)face->pFacePlane_old.vNormal.z) >> 16; v13 = v12 + a1b + a11b; a1a = v12 + a1b + a11b; v14 = (a1 << 16) - - a3 * v11->pFacePlane_old.vNormal.x - - a4 * v11->pFacePlane_old.vNormal.y - - a5 * v11->pFacePlane_old.vNormal.z - - v11->pFacePlane_old.dist; + - X * face->pFacePlane_old.vNormal.x + - Y * face->pFacePlane_old.vNormal.y + - Z * face->pFacePlane_old.vNormal.z + - face->pFacePlane_old.dist; if ( abs((a1 << 16) - - a3 * v11->pFacePlane_old.vNormal.x - - a4 * v11->pFacePlane_old.vNormal.y - - a5 * v11->pFacePlane_old.vNormal.z - v11->pFacePlane_old.dist) >= a1 << 16 ) + - X * face->pFacePlane_old.vNormal.x + - Y * face->pFacePlane_old.vNormal.y + - Z * face->pFacePlane_old.vNormal.z - face->pFacePlane_old.dist) >= a1 << 16 ) { a11c = abs(v14) >> 14; if ( a11c > abs(v13) ) - return 0; + return false; LODWORD(v16) = v14 << 16; HIDWORD(v16) = v14 >> 16; - v15 = v20; + v15 = a1; a11a = v16 / a1a; } else @@ -2178,23 +1257,18 @@ a11a = 0; v15 = abs(v14) >> 16; } - v17 = a4 + ((unsigned int)((unsigned __int64)(a11a * (signed __int64)a7) >> 16) >> 16); - LOWORD(a7a) = (short)a3 - + ((unsigned int)((unsigned __int64)(a11a * (signed __int64)a6) >> 16) >> 16) - - ((unsigned int)(v15 * v11->pFacePlane_old.vNormal.x) >> 16); - HIWORD(a7a) = v17 - ((unsigned int)(v15 * v11->pFacePlane_old.vNormal.y) >> 16); - if ( !sub_4759C9( - v11, - a10, - a7a, - (short)a5 - + ((unsigned int)((unsigned __int64)(a11a * (signed __int64)a8) >> 16) >> 16) - - ((unsigned int)(v15 * v11->pFacePlane_old.vNormal.z) >> 16)) ) - return 0; - *v19 = a11a >> 16; + v17 = Y + ((unsigned int)((unsigned __int64)(a11a * (signed __int64)dir_y) >> 16) >> 16); + LOWORD(a7a) = (short)X + + ((unsigned int)((unsigned __int64)(a11a * (signed __int64)dir_x) >> 16) >> 16) + - ((unsigned int)(v15 * face->pFacePlane_old.vNormal.x) >> 16); + HIWORD(a7a) = v17 - ((unsigned int)(v15 * face->pFacePlane_old.vNormal.y) >> 16); + if ( !sub_4759C9(face, a10, a7a, (short)Z + ((unsigned int)((unsigned __int64)(a11a * (signed __int64)dir_z) >> 16) >> 16) + - ((unsigned int)(v15 * face->pFacePlane_old.vNormal.z) >> 16)) ) + return false; + *a2 = a11a >> 16; if ( a11a >> 16 < 0 ) - *v19 = 0; - return 1; + *a2 = 0; + return true; } //----- (00475665) -------------------------------------------------------- @@ -2346,12 +1420,12 @@ //----- (004759C9) -------------------------------------------------------- bool __fastcall sub_4759C9(BLVFace *a1, int a2, int a3, __int16 a4) { - unsigned int v4; // eax@1 - int v5; // edx@4 + //unsigned int v4; // eax@1 + //int v5; // edx@4 __int16 v6; // si@4 - int v7; // edx@9 + //int v7; // edx@9 __int16 v8; // si@9 - int v9; // edx@13 + //int v9; // edx@13 __int16 v10; // si@13 int v11; // esi@14 bool v12; // edi@14 @@ -2372,9 +1446,9 @@ Vec3_int_ **a4c; // [sp+30h] [bp+Ch]@12 signed int a4d; // [sp+30h] [bp+Ch]@14 - v4 = a1->uAttributes; + //v4 = a1->uAttributes; v22 = 0; - if ( BYTE1(v4) & 1 ) + if ( BYTE1(a1->uAttributes) & 1 ) { v23 = (signed __int16)a3; v24 = SHIWORD(a3); @@ -2383,11 +1457,11 @@ a4a = &pOutdoor->pBModels[a2].pVertices.pVertices; do { - v5 = 2 * v22; + //v5 = 2 * v22; word_720A70_intercepts_xs_plus_xs[2 * v22] = a1->pXInterceptDisplacements[v22] + LOWORD((*a4a)[a1->pVertexIDs[v22]].x); word_7209A0_intercepts_ys_plus_ys[2 * v22] = a1->pYInterceptDisplacements[v22] + LOWORD((*a4a)[a1->pVertexIDs[v22]].y); word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = a1->pXInterceptDisplacements[v22 + 1] + LOWORD((*a4a)[a1->pVertexIDs[v22 + 1]].x); - word_7209A0_intercepts_ys_plus_ys[v5 + 1] = v6 = a1->pYInterceptDisplacements[v22 + 1] + LOWORD((*a4a)[a1->pVertexIDs[v22 + 1]].y); + word_7209A0_intercepts_ys_plus_ys[2 * v22 + 1] = v6 = a1->pYInterceptDisplacements[v22 + 1] + LOWORD((*a4a)[a1->pVertexIDs[v22 + 1]].y); ++v22; } while ( v22 < a1->uNumVertices ); @@ -2395,7 +1469,7 @@ } else { - if ( BYTE1(v4) & 2 ) + if ( BYTE1(a1->uAttributes) & 2 ) { v23 = (signed __int16)a3; v24 = a4; @@ -2404,11 +1478,11 @@ a4b = &pOutdoor->pBModels[a2].pVertices.pVertices; do { - v7 = 2 * v22; + //v7 = 2 * v22; word_720A70_intercepts_xs_plus_xs[2 * v22] = a1->pXInterceptDisplacements[v22] + LOWORD((*a4b)[a1->pVertexIDs[v22]].x); word_7209A0_intercepts_ys_plus_ys[2 * v22] = a1->pZInterceptDisplacements[v22] + LOWORD((*a4b)[a1->pVertexIDs[v22]].z); word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = a1->pXInterceptDisplacements[v22 + 1] + LOWORD((*a4b)[a1->pVertexIDs[v22 + 1]].x); - word_7209A0_intercepts_ys_plus_ys[v7 + 1] = v8 = a1->pZInterceptDisplacements[v22 + 1] + LOWORD((*a4b)[a1->pVertexIDs[v22 + 1]].z); + word_7209A0_intercepts_ys_plus_ys[2 * v22 + 1] = v8 = a1->pZInterceptDisplacements[v22 + 1] + LOWORD((*a4b)[a1->pVertexIDs[v22 + 1]].z); ++v22; } while ( v22 < a1->uNumVertices ); @@ -2423,11 +1497,11 @@ a4c = &pOutdoor->pBModels[a2].pVertices.pVertices; do { - v9 = 2 * v22; + //v9 = 2 * v22; word_720A70_intercepts_xs_plus_xs[2 * v22] = a1->pYInterceptDisplacements[v22] + LOWORD((*a4c)[a1->pVertexIDs[v22]].y); word_7209A0_intercepts_ys_plus_ys[2 * v22] = a1->pZInterceptDisplacements[v22] + LOWORD((*a4c)[a1->pVertexIDs[v22]].z); word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = a1->pYInterceptDisplacements[v22 + 1] + LOWORD((*a4c)[a1->pVertexIDs[v22 + 1]].y); - word_7209A0_intercepts_ys_plus_ys[v9 + 1] = v10 = a1->pZInterceptDisplacements[v22 + 1] + LOWORD((*a4c)[a1->pVertexIDs[v22 + 1]].z); + word_7209A0_intercepts_ys_plus_ys[2 * v22 + 1] = v10 = a1->pZInterceptDisplacements[v22 + 1] + LOWORD((*a4c)[a1->pVertexIDs[v22 + 1]].z); ++v22; } while ( v22 < a1->uNumVertices ); @@ -2543,7 +1617,7 @@ //----- (00475F30) -------------------------------------------------------- bool __fastcall sub_475F30(int *a1, BLVFace *a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9) { - BLVFace *v9; // ebx@1 + //BLVFace *v9; // ebx@1 int v10; // ST20_4@2 int v11; // ST28_4@2 int v12; // ST24_4@2 @@ -2554,14 +1628,14 @@ int v17; // ST20_4@9 signed __int64 v18; // qtt@10 int v19; // ST14_4@11 - int *v21; // [sp+14h] [bp-10h]@1 + //int *v21; // [sp+14h] [bp-10h]@1 int v22; // [sp+1Ch] [bp-8h]@2 int v23; // [sp+1Ch] [bp-8h]@10 signed int v24; // [sp+20h] [bp-4h]@10 - v9 = a2; - v21 = a1; - if ( BYTE3(a2->uAttributes) & 0x20 + //v9 = a2; + //v21 = a1; + if ( a2->Ethereal() || (v10 = (unsigned __int64)(a6 * (signed __int64)a2->pFacePlane_old.vNormal.x) >> 16, v11 = (unsigned __int64)(a7 * (signed __int64)a2->pFacePlane_old.vNormal.y) >> 16, v12 = (unsigned __int64)(a8 * (signed __int64)a2->pFacePlane_old.vNormal.z) >> 16, @@ -2585,16 +1659,13 @@ } v17 = abs(-(a2->pFacePlane_old.dist + v15 + a3 * a2->pFacePlane_old.vNormal.x + a5 * a2->pFacePlane_old.vNormal.z)) >> 14; if ( v17 > abs(v14) - || (LODWORD(v18) = v16 << 16, HIDWORD(v18) = v16 >> 16, v24 = v18 / v22, v23 = v18 / v22, v23 > *v21 << 16) + || (LODWORD(v18) = v16 << 16, HIDWORD(v18) = v16 >> 16, v24 = v18 / v22, v23 = v18 / v22, v23 > *a1 << 16) || (LOWORD(v19) = a3 + (((unsigned int)((unsigned __int64)(v23 * (signed __int64)a6) >> 16) + 32768) >> 16), HIWORD(v19) = a4 + (((unsigned int)((unsigned __int64)(v23 * (signed __int64)a7) >> 16) + 32768) >> 16), - !sub_4759C9( - v9, - a9, - v19, + !sub_4759C9(a2, a9, v19, a5 + (((unsigned int)((unsigned __int64)(v23 * (signed __int64)a8) >> 16) + 32768) >> 16))) ) return 0; - *v21 = v24 >> 16; + *a1 = v24 >> 16; return 1; } @@ -5725,98 +4796,94 @@ } } - - //----- (00449A49) -------------------------------------------------------- -__int16 __fastcall sub_449A49_door_switch_animation(unsigned int uDoorID, int a2) +void Door_switch_animation(unsigned int uDoorID, int a2) { - int v2; // eax@1 - int v3; // ebx@1 - signed int v4; // esi@2 - int v5; // edx@2 - BLVDoor *v6; // ecx@8 - unsigned int v7; // edx@18 - signed int v8; // esi@19 - int v9; // eax@19 - //char Args; // [sp+Ch] [bp-78h]@6 - - LOWORD(v2) = LOWORD(pIndoor->pDoors); - v3 = a2; + int old_state; // eax@1 + signed int door_id; // esi@2 + if ( !pIndoor->pDoors ) - return v2; - v4 = 0; - v5 = (int)&pIndoor->pDoors->uDoorID; - do + return; + for ( door_id = 0; door_id < 200; ++door_id ) { - if ( *(int *)v5 == uDoorID ) + if ( pIndoor->pDoors[door_id].uDoorID == uDoorID ) break; - ++v4; - v5 += 80; } - while ( v4 < 200 ); - if ( v4 >= 200 ) + if ( door_id >= 200 ) { Error("Unable to find Door ID: %i!", uDoorID); } - v6 = &pIndoor->pDoors[v4]; - if ( v3 == 2 ) + old_state = pIndoor->pDoors[door_id].uState; + if ( a2 == 2 ) { - LOWORD(v2) = v6->uState; - if ( (short)v2 == 3 || (short)v2 == 1 ) - return v2; - if ( (short)v2 ) - goto LABEL_14; + if ( pIndoor->pDoors[door_id].uState == BLVDoor::Closing || pIndoor->pDoors[door_id].uState == BLVDoor::Opening ) + return; + if ( pIndoor->pDoors[door_id].uState ) + { + if ( pIndoor->pDoors[door_id].uState != BLVDoor::Closed && pIndoor->pDoors[door_id].uState != BLVDoor::Closing ) + { + pIndoor->pDoors[door_id].uState = BLVDoor::Closing; + if ( old_state == BLVDoor::Open ) + { + pIndoor->pDoors[door_id].uTimeSinceTriggered = 0; + return; + } + if ( pIndoor->pDoors[door_id].uTimeSinceTriggered != 15360 ) + { + pIndoor->pDoors[door_id].uTimeSinceTriggered = (pIndoor->pDoors[door_id].uMoveLength << 7) / pIndoor->pDoors[door_id].uOpenSpeed + - ((signed int)(pIndoor->pDoors[door_id].uTimeSinceTriggered * pIndoor->pDoors[door_id].uCloseSpeed) + / 128 << 7) / pIndoor->pDoors[door_id].uOpenSpeed; + return; + } + pIndoor->pDoors[door_id].uTimeSinceTriggered = 15360; + } + return; + } } else { - if ( !v3 ) + if ( a2 == 0 ) { -LABEL_14: - LOWORD(v2) = v6->uState; - if ( (short)v2 && (short)v2 != 3 ) + if ( pIndoor->pDoors[door_id].uState != BLVDoor::Closed && pIndoor->pDoors[door_id].uState != BLVDoor::Closing ) { - v6->uState = BLVDoor::Closing; - if ( (short)v2 == 2 ) + pIndoor->pDoors[door_id].uState = BLVDoor::Closing; + if ( old_state == BLVDoor::Open ) { -LABEL_17: - v6->uTimeSinceTriggered = 0; - return v2; + pIndoor->pDoors[door_id].uTimeSinceTriggered = 0; + return; } - v7 = v6->uTimeSinceTriggered; - v2 = 15360; - if ( v7 != 15360 ) + if ( pIndoor->pDoors[door_id].uTimeSinceTriggered != 15360 ) { - v8 = v6->uOpenSpeed; - v9 = v6->uCloseSpeed; -LABEL_26: - v2 = (v6->uMoveLength << 7) / v8 - ((signed int)(v7 * v9) / 128 << 7) / v8; - goto LABEL_27; + pIndoor->pDoors[door_id].uTimeSinceTriggered = (pIndoor->pDoors[door_id].uMoveLength << 7) / pIndoor->pDoors[door_id].uOpenSpeed + - ((signed int)(pIndoor->pDoors[door_id].uTimeSinceTriggered * pIndoor->pDoors[door_id].uCloseSpeed) + / 128 << 7) / pIndoor->pDoors[door_id].uOpenSpeed; + return; } - goto LABEL_27; + pIndoor->pDoors[door_id].uTimeSinceTriggered = 15360; } - return v2; + return; } - if ( v3 != 1 ) - return v2; + if ( a2 != 1 ) + return; } - LOWORD(v2) = v6->uState; - if ( (short)v2 != 2 && (short)v2 != 1 ) + if ( old_state != BLVDoor::Open && old_state != BLVDoor::Opening ) { - v6->uState = BLVDoor::Opening; - if ( !(short)v2 ) - goto LABEL_17; - v7 = v6->uTimeSinceTriggered; - v2 = 15360; - if ( v7 != 15360 ) + pIndoor->pDoors[door_id].uState = BLVDoor::Opening; + if ( old_state == BLVDoor::Closed ) + { + pIndoor->pDoors[door_id].uTimeSinceTriggered = 0; + return; + } + if ( pIndoor->pDoors[door_id].uTimeSinceTriggered != 15360 ) { - v8 = v6->uCloseSpeed; - v9 = v6->uOpenSpeed; - goto LABEL_26; + pIndoor->pDoors[door_id].uTimeSinceTriggered = (pIndoor->pDoors[door_id].uMoveLength << 7) / pIndoor->pDoors[door_id].uCloseSpeed + - ((signed int)(pIndoor->pDoors[door_id].uTimeSinceTriggered * pIndoor->pDoors[door_id].uOpenSpeed) + / 128 << 7) / pIndoor->pDoors[door_id].uCloseSpeed; + return; } -LABEL_27: - v6->uTimeSinceTriggered = v2; + pIndoor->pDoors[door_id].uTimeSinceTriggered = 15360; } - return v2; + return; } //----- (00449B57) -------------------------------------------------------- @@ -5845,9 +4912,8 @@ strcpy(GameUI_Footer_TimedString.data(), pString); GameUI_Footer_TimeLeft = 1000 * uNumSeconds + GetTickCount(); - for (int i = pFontLucida->GetLineWidth(GameUI_Footer_TimedString.data()); - i > 450; - i = pFontLucida->GetLineWidth(GameUI_Footer_TimedString.data()) ) + for (int i = pFontLucida->GetLineWidth(GameUI_Footer_TimedString.data()); i > 450; + i = pFontLucida->GetLineWidth(GameUI_Footer_TimedString.data()) ) GameUI_Footer_TimedString[strlen(GameUI_Footer_TimedString.data()) - 1] = 0; } @@ -5888,19 +4954,15 @@ void mm7__vector_constructor(void *a1, int objSize, int numObjs, int ( *constructor)(int)) { void *v4; // esi@2 - int v5; // edi@2 - - if ( numObjs - 1 >= 0 ) + + if ( numObjs > 0 ) { v4 = a1; - v5 = numObjs; - do + for ( int i = numObjs; i; --i ) { constructor((int)v4); v4 = (char *)v4 + objSize; - --v5; } - while ( v5 ); } }
--- a/mm7_4.cpp Tue Dec 03 16:35:57 2013 +0600 +++ b/mm7_4.cpp Thu Jan 02 09:11:01 2014 +0600 @@ -578,7 +578,7 @@ //for lich if ( pParty->pPlayers[v49].classType == PLAYER_CLASS_LICH ) { - for ( v31 = 0; v31 < 138; ++v31 ) + for ( v31 = 0; v31 < 126; ++v31 ) { if ( pParty->pPlayers[v49].pInventoryItemList[v31].uItemID == ITEM_LICH_JAR_FULL ) lich_jar_flag = true;
--- a/mm7_data.cpp Tue Dec 03 16:35:57 2013 +0600 +++ b/mm7_data.cpp Thu Jan 02 09:11:01 2014 +0600 @@ -1234,8 +1234,8 @@ std::array<int, 20> dword_720E80; std::array<int, 20> dword_720ED0; std::array<int, 20> ceiling_height_level; -std::array<__int16, 777> FloorFaceVertCoord_Y; // idb -std::array<__int16, 777> FloorFaceVertCoord_X; // idb +std::array<__int16, 104> odm_floor_face_vert_coord_Y; // word_720F70 +std::array<__int16, 104> odm_floor_face_vert_coord_X; // word_721040 std::array<int, 777> dword_721110; // idb std::array<int, 777> dword_721160; // idb std::array<int, 20> odm_floor_level; // idb
--- a/mm7_data.h Tue Dec 03 16:35:57 2013 +0600 +++ b/mm7_data.h Thu Jan 02 09:11:01 2014 +0600 @@ -908,8 +908,8 @@ extern std::array<int, 20> dword_720E80; extern std::array<int, 20> dword_720ED0; extern std::array<int, 20> ceiling_height_level; -extern std::array<__int16, 777> FloorFaceVertCoord_Y; // idb -extern std::array<__int16, 777> FloorFaceVertCoord_X; // idb +extern std::array<__int16, 104> odm_floor_face_vert_coord_Y; // word_720F70 +extern std::array<__int16, 104> odm_floor_face_vert_coord_X; // word_721040 extern std::array<int, 777> dword_721110; // idb extern std::array<int, 777> dword_721160; // idb extern std::array<int, 20> odm_floor_level; // idb dword_7211B0 @@ -1312,8 +1312,8 @@ int collide_against_floor_approximate(int x, int y, int z, unsigned int *pSectorID, unsigned int *pFaceID); // idb void BLV_ProcessPartyActions(); void ODM_ProcessPartyActions(); -bool __fastcall sub_47531C(int a1, int *a2, int a3, int a4, int a5, int a6, int a7, int a8, struct BLVFace *a9, int a10); -bool __fastcall sub_4754BF(int a1, int *a2, int a3, int a4, int a5, int a6, int a7, int a8, struct BLVFace *a9, int a10, int a11); +bool sub_47531C(int a1, int *a2, int pos_x, int pos_y, int pos_z, int dir_x, int dir_y, int dir_z, struct BLVFace *face, int a10); +bool sub_4754BF(int a1, int *a2, int X, int Y, int Z, int dir_x, int dir_y, int dir_z, struct BLVFace *face, int a10, int a11); int sub_475665(struct BLVFace *_this, int a2, __int16 a3); bool __fastcall sub_4759C9(struct BLVFace *a1, int a2, int a3, __int16 a4); bool __fastcall sub_475D85(Vec3_int_ *a1, Vec3_int_ *a2, int *a3, struct BLVFace *a4); @@ -1338,7 +1338,7 @@ void OnTimer(int); void __fastcall sub_448CF4_spawn_monsters(__int16 typeindex, __int16 level, int count, int x, int y, int z, int group, unsigned int uUniqueName); void __fastcall EventCastSpell(int uSpellID, int uSkillLevel, int uSkill, int fromx, int fromy, int fromz, int tox, int toy, int toz);//sub_448DF8 -__int16 __fastcall sub_449A49_door_switch_animation(unsigned int uDoorID, int a2); // idb +void Door_switch_animation(unsigned int uDoorID, int a2); // idb: sub_449A49 bool _449B57_test_bit(unsigned __int8 *a1, __int16 a2); void _449B7E_toggle_bit(unsigned char *pArray, __int16 a2, unsigned __int16 bToggle); // idb void ShowStatusBarString(const char *pString, unsigned int uNumSeconds);