Mercurial > mm7
comparison Chest.cpp @ 1406:d071e0e9ba75
Explosion Traps fix
author | Ritor1 |
---|---|
date | Tue, 23 Jul 2013 15:41:45 +0600 |
parents | c0b273d33338 |
children | d4f57df4c299 |
comparison
equal
deleted
inserted
replaced
1405:c0b273d33338 | 1406:d071e0e9ba75 |
---|---|
41 | 41 |
42 | 42 |
43 //----- (0042041E) -------------------------------------------------------- | 43 //----- (0042041E) -------------------------------------------------------- |
44 bool Chest::Open( signed int uChestID ) | 44 bool Chest::Open( signed int uChestID ) |
45 { | 45 { |
46 //char *v1; // edi@5 | 46 unsigned int pMapID; // eax@8 |
47 unsigned int v2; // eax@8 | 47 int pRandom; // edx@16 |
48 GUIWindow *v3; // eax@15 | |
49 int v5; // edx@16 | |
50 int v6; // eax@16 | 48 int v6; // eax@16 |
51 ODMFace *v7; // eax@19 | 49 ODMFace *pODMFace; // eax@19 |
52 int v8; // edx@19 | 50 BLVFace *pBLVFace; // eax@20 |
53 int v9; // edi@19 | 51 int pObjectX; // ebx@21 |
54 signed int v10; // ebx@19 | 52 int pObjectZ; // edi@21 |
55 int v11; // ecx@19 | 53 double dir_x; // st7@23 |
56 int v12; // eax@19 | 54 double dir_y; // st6@23 |
57 BLVFace *v13; // eax@20 | |
58 int v14; // ebx@21 | |
59 int v15; // edi@21 | |
60 int v16; // ecx@22 | |
61 __int64 v17; // qax@22 | |
62 double v18; // st7@23 | |
63 double v19; // st6@23 | |
64 double v20; // st7@23 | 55 double v20; // st7@23 |
65 int v21; // ecx@26 | 56 int pDepth; // ecx@26 |
66 char v22[12]; // ST4C_12@28 | 57 Vec3_int_ v; // ST4C_12@28 |
67 unsigned int *v23; // edi@28 | 58 bool flag_shout; // edi@28 |
68 unsigned __int16 v24; // di@28 | 59 int pSpriteID[4]; // [sp+84h] [bp-40h]@16 |
69 signed int v25; // ecx@28 | |
70 char *v26; // edx@29 | |
71 unsigned __int16 v27; // ax@32 | |
72 //SpriteObject a1; // [sp+14h] [bp-B0h]@28 | |
73 int v29[4]; // [sp+84h] [bp-40h]@16 | |
74 //int v30; // [sp+88h] [bp-3Ch]@16 | |
75 //int v31; // [sp+8Ch] [bp-38h]@16 | |
76 //int v32; // [sp+90h] [bp-34h]@16 | |
77 float v33; // [sp+94h] [bp-30h]@23 | |
78 //char *v34; // [sp+98h] [bp-2Ch]@5 | |
79 int v35; // [sp+9Ch] [bp-28h]@16 | |
80 Vec3_int_ pOut; // [sp+A0h] [bp-24h]@28 | 60 Vec3_int_ pOut; // [sp+A0h] [bp-24h]@28 |
81 int a4; // [sp+ACh] [bp-18h]@1 | 61 int pObjectY; // [sp+B0h] [bp-14h]@21 |
82 int v38; // [sp+B0h] [bp-14h]@21 | |
83 int sRotX; // [sp+B4h] [bp-10h]@23 | 62 int sRotX; // [sp+B4h] [bp-10h]@23 |
84 float v40; // [sp+B8h] [bp-Ch]@23 | 63 float dir_z; // [sp+BCh] [bp-8h]@23 |
85 float v41; // [sp+BCh] [bp-8h]@23 | |
86 int sRotY; // [sp+C0h] [bp-4h]@8 | 64 int sRotY; // [sp+C0h] [bp-4h]@8 |
87 | 65 SpriteObject pSpellObject; // [sp+14h] [bp-B0h]@28 |
88 //a4 = uChestID; | 66 |
89 assert(uChestID < 20); | 67 assert( uChestID < 20 ); |
90 if ((uChestID <0)&&(uChestID >=20) ) | 68 if ( ( uChestID < 0 ) && ( uChestID >= 20 ) ) |
91 return false; | 69 return false; |
92 auto chest = &pChests[uChestID]; | 70 auto chest = &pChests[uChestID]; |
93 | 71 |
94 ++pIcons_LOD->uTexturePacksCount; | 72 ++pIcons_LOD->uTexturePacksCount; |
95 if (!pIcons_LOD->uNumPrevLoadedFiles) | 73 if (!pIcons_LOD->uNumPrevLoadedFiles) |
96 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; | 74 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; |
97 | 75 |
98 | |
99 //v1 = (char *)&pChests[uChestID].uFlags; | |
100 //v34 = v1; | |
101 if (!chest->Initialized()) | 76 if (!chest->Initialized()) |
102 Chest::PlaceItems(uChestID); | 77 Chest::PlaceItems(uChestID); |
103 | 78 |
104 if ( !uActiveCharacter ) | 79 if ( !uActiveCharacter ) |
105 return 0; | 80 return false; |
106 *(float *)&sRotY = 0.0; | 81 flag_shout = false; |
107 v2 = pMapStats->GetMapInfo(pCurrentMapName.data()); | 82 pMapID = pMapStats->GetMapInfo(pCurrentMapName.data()); |
108 if ( !chest->Trapped() || !v2 ) | 83 if ( chest->Trapped() && pMapID ) |
109 goto LABEL_12; | 84 { |
110 if ( pPlayers[uActiveCharacter]->GetDisarmTrap() < 2 * pMapStats->pInfos[v2].LockX5 ) | 85 if ( pPlayers[uActiveCharacter]->GetDisarmTrap() < 2 * pMapStats->pInfos[pMapID].LockX5 ) |
111 { | 86 { |
112 v29[0] = 811; | 87 pSpriteID[0] = 811; |
113 v29[1] = 812; | 88 pSpriteID[1] = 812; |
114 v29[2] = 813; | 89 pSpriteID[2] = 813; |
115 v29[3] = 814; | 90 pSpriteID[3] = 814; |
116 v5 = rand() % 4; | 91 pRandom = rand() % 4; |
117 v6 = PID_ID(EvtTargetObj); | 92 v6 = PID_ID(EvtTargetObj); |
118 v35 = v5; | 93 if ( PID_TYPE(EvtTargetObj) == OBJECT_Decoration) |
119 if ( PID_TYPE(EvtTargetObj) == OBJECT_Decoration) | 94 { |
120 { | 95 pObjectX = pLevelDecorations[v6].vPosition.x; |
121 v16 = v6; | 96 pObjectY = pLevelDecorations[v6].vPosition.y; |
122 v14 = pLevelDecorations[v6].vPosition.x; | 97 pObjectZ = pLevelDecorations[v6].vPosition.z + ( pDecorationList->pDecorations[pLevelDecorations[v6].uDecorationDescID].uDecorationHeight / 2 ); |
123 v38 = pLevelDecorations[v6].vPosition.y; | 98 } |
124 v17 = pDecorationList->pDecorations[pLevelDecorations[v6].uDecorationDescID].uDecorationHeight; | 99 if ( PID_TYPE(EvtTargetObj) == OBJECT_BModel) |
125 v15 = pLevelDecorations[v16].vPosition.z + (((signed int)v17 - HIDWORD(v17)) >> 1); | 100 { |
126 } | 101 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) |
127 else | 102 { |
128 { | 103 pODMFace = &pOutdoor->pBModels[EvtTargetObj >> 9].pFaces[(EvtTargetObj >> 3) & 0x3F]; |
129 if ( PID_TYPE(EvtTargetObj) != OBJECT_BModel) | 104 pObjectX = ( pODMFace->pBoundingBox.x1 + pODMFace->pBoundingBox.x2 ) / 2; |
130 goto LABEL_12; | 105 pObjectY = ( pODMFace->pBoundingBox.y1 + pODMFace->pBoundingBox.y2 ) / 2; |
131 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) | 106 pObjectZ = ( pODMFace->pBoundingBox.z1 + pODMFace->pBoundingBox.z2 ) / 2; |
132 { | 107 } |
133 v7 = &pOutdoor->pBModels[EvtTargetObj >> 9].pFaces[(EvtTargetObj >> 3) & 0x3F]; | 108 else//Indoor |
134 v8 = v7->pBoundingBox.y1; | 109 { |
135 v9 = v7->pBoundingBox.z2; | 110 pBLVFace = &pIndoor->pFaces[v6]; |
136 v10 = v7->pBoundingBox.x1 + v7->pBoundingBox.x2; | 111 pObjectX = ( pBLVFace->pBounding.x1 + pBLVFace->pBounding.x2 ) / 2; |
137 v11 = v7->pBoundingBox.y2; | 112 pObjectY = ( pBLVFace->pBounding.y1 + pBLVFace->pBounding.y2 ) / 2; |
138 v12 = v7->pBoundingBox.z1; | 113 pObjectZ = ( pBLVFace->pBounding.z1 + pBLVFace->pBounding.z2 ) / 2; |
114 } | |
115 } | |
116 dir_x = (double)pParty->vPosition.x - (double)pObjectX; | |
117 dir_y = (double)pParty->vPosition.y - (double)pObjectY; | |
118 dir_z = ( (double)pParty->sEyelevel + (double)pParty->vPosition.z ) - (double)pObjectZ; | |
119 v20 = sqrt( (dir_x * dir_x) + (dir_y * dir_y) + (dir_z * dir_z) ); | |
120 if ( v20 <= 1.0 ) | |
121 { | |
122 *(float *)&sRotX = 0.0; | |
123 *(float *)&sRotY = 0.0; | |
139 } | 124 } |
140 else | 125 else |
141 { | 126 { |
142 v13 = &pIndoor->pFaces[v6]; | 127 sRotY = (signed __int64)sqrt(dir_x * dir_x + dir_y * dir_y); |
143 v8 = v13->pBounding.y1; | 128 sRotX = stru_5C6E00->Atan2((signed __int64)dir_x, (signed __int64)dir_y); |
144 v9 = v13->pBounding.z2; | 129 sRotY = stru_5C6E00->Atan2(dir_y * dir_y, (signed __int64)dir_z); |
145 v10 = v13->pBounding.x1 + v13->pBounding.x2; | 130 } |
146 v11 = v13->pBounding.y2; | 131 pDepth = 256; |
147 v12 = v13->pBounding.z1; | 132 if ( v20 < 256.0 ) |
148 } | 133 pDepth = (signed __int64)v20 / 4; |
149 v14 = v10 >> 1; | 134 v.x = pObjectX; |
150 v38 = (v8 + v11) >> 1; | 135 v.y = pObjectY; |
151 v15 = (v12 + v9) >> 1; | 136 v.z = pObjectZ; |
152 } | 137 Vec3_int_::Rotate(pDepth, sRotX, sRotY, v, &pOut.x, &pOut.z, &pOut.y); |
153 v18 = (double)pParty->vPosition.x - (double)v14; | 138 sub_42F7EB_DropItemAt(pSpriteID[pRandom], pOut.x, pOut.z, pOut.y, 0, 1, 0, 48, 0); |
154 *(float *)&a4 = v18; | 139 |
155 v19 = (double)pParty->vPosition.y - (double)v38; | 140 pSpellObject.stru_24.Reset(); |
156 v33 = v19; | 141 pSpellObject.spell_skill = 0; |
157 v41 = (double)pParty->sEyelevel + (double)pParty->vPosition.z - (double)v15; | 142 pSpellObject.spell_level = 0; |
158 *(float *)&sRotY = v19 * v19; | 143 pSpellObject.spell_id = 0; |
159 *(float *)&sRotX = v18 * v18; | 144 pSpellObject.field_54 = 0; |
160 v20 = sqrt(v41 * v41 + *(float *)&sRotX + *(float *)&sRotY); | 145 pSpellObject.uType = pSpriteID[pRandom]; |
161 v40 = v20; | 146 pSpellObject.uObjectDescID = 0; |
162 if ( v20 <= 1.0 ) | 147 if ( pObjectList->uNumObjects ) |
163 { | 148 { |
164 *(float *)&sRotX = 0.0; | 149 for ( uint i = 0; i < (signed int)pObjectList->uNumObjects; ++i ) |
165 *(float *)&sRotY = 0.0; | 150 { |
166 } | 151 if ( pSpriteID[pRandom] == pObjectList->pObjects[i].uObjectID ) |
167 else | 152 pSpellObject.uObjectDescID = i; |
168 { | 153 } |
169 sRotY = (signed __int64)sqrt(*(float *)&sRotX + *(float *)&sRotY); | 154 } |
170 sRotX = stru_5C6E00->Atan2((signed __int64)*(float *)&a4, (signed __int64)v33); | 155 pSpellObject.vPosition.y = pOut.z; |
171 sRotY = stru_5C6E00->Atan2(sRotY, (signed __int64)v41); | 156 pSpellObject.vPosition.x = pOut.x; |
172 } | 157 pSpellObject.vPosition.z = pOut.y; |
173 v21 = 256; | 158 pSpellObject.uSoundID = 0; |
174 if ( v40 < 256.0 ) | 159 pSpellObject.uAttributes = 48; |
175 v21 = (signed __int64)v40 / 4; | 160 pSpellObject.uSectorID = pIndoor->GetSector(pOut.x, pOut.z, pOut.y); |
176 *(int *)&v22[8] = v15; | 161 pSpellObject.uSpriteFrameID = 0; |
177 *(_QWORD *)v22 = __PAIR__(v38, v14); | 162 pSpellObject.spell_caster_pid = 0; |
178 Vec3_int_::Rotate(v21, sRotX, sRotY, *(Vec3_int_ *)v22, &pOut.x, &pOut.z, &pOut.y); | 163 pSpellObject.spell_target_pid = 0; |
179 v23 = (unsigned int *)(&v29 + v35); | 164 pSpellObject.uFacing = 0; |
180 sub_42F7EB_DropItemAt(*v23, pOut.x, pOut.z, pOut.y, 0, 1, 0, 0x30u, 0); | 165 pSpellObject.Create(0, 0, 0, 0); |
181 | 166 pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0); |
182 SpriteObject a1; // [sp+14h] [bp-B0h]@28 | 167 pSpellObject.ExplosionTraps(); |
183 //SpriteObject::SpriteObject(&a1); | 168 chest->uFlags &= 0xFEu; |
184 | 169 if ( uActiveCharacter && !qword_A750D8 && !dword_507CD8 ) |
185 a1.stru_24.Reset(); | 170 { |
186 v24 = *(short *)v23; | 171 qword_A750D8 = 256i64; |
187 v25 = 0; | 172 PlayerSpeechID = SPEECH_5; |
188 a1.spell_skill = 0; | 173 word_A750E2 = uActiveCharacter; |
189 a1.spell_level = 0; | 174 } |
190 a1.spell_id = 0; | 175 pIcons_LOD->RemoveTexturesPackFromTextureList(); |
191 a1.field_54 = 0; | 176 dword_507CD8 = 0; |
192 a1.uType = v24; | 177 return false; |
193 if ( (signed int)pObjectList->uNumObjects <= 0 ) | 178 } |
194 { | 179 chest->uFlags &= 0xFEu; |
195 LABEL_32: | 180 flag_shout = true; |
196 v27 = 0; | 181 } |
197 } | |
198 else | |
199 { | |
200 v26 = (char *)&pObjectList->pObjects->uObjectID; | |
201 while ( v24 != *(short *)v26 ) | |
202 { | |
203 ++v25; | |
204 v26 += 56; | |
205 if ( v25 >= (signed int)pObjectList->uNumObjects ) | |
206 goto LABEL_32; | |
207 } | |
208 v27 = v25; | |
209 } | |
210 a1.uObjectDescID = v27; | |
211 a1.vPosition.y = pOut.z; | |
212 a1.vPosition.x = pOut.x; | |
213 a1.vPosition.z = pOut.y; | |
214 a1.uSoundID = 0; | |
215 a1.uAttributes = 48; | |
216 a1.uSectorID = pIndoor->GetSector(pOut.x, pOut.z, pOut.y); | |
217 a1.uSpriteFrameID = 0; | |
218 a1.spell_caster_pid = 0; | |
219 a1.spell_target_pid = 0; | |
220 a1.uFacing = 0; | |
221 a1.Create(0, 0, 0, 0); | |
222 pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0); | |
223 a1._438E35(); | |
224 chest->SetInitialized(false);//*v34 &= 0xFEu; | |
225 if ( uActiveCharacter && !qword_A750D8 && !dword_507CD8 ) | |
226 { | |
227 qword_A750D8 = 256i64; | |
228 word_A750E0 = 5; | |
229 word_A750E2 = uActiveCharacter; | |
230 } | |
231 pIcons_LOD->RemoveTexturesPackFromTextureList(); | |
232 dword_507CD8 = 0; | |
233 return 0; | |
234 } | |
235 chest->SetInitialized(false);//*v1 &= 0xFEu; | |
236 sRotY = 1; | |
237 LABEL_12: | |
238 pAudioPlayer->StopChannels(-1, -1); | 182 pAudioPlayer->StopChannels(-1, -1); |
239 pAudioPlayer->PlaySound(SOUND_OpenChest, 0, 0, -1, 0, 0, 0, 0); | 183 pAudioPlayer->PlaySound(SOUND_OpenChest, 0, 0, -1, 0, 0, 0, 0); |
240 if ( *(float *)&sRotY != 0.0 ) | 184 if ( flag_shout == true ) |
241 { | 185 { |
242 if ( !dword_507CD8 ) | 186 if ( !dword_507CD8 ) |
243 pPlayers[uActiveCharacter]->PlaySound(SPEECH_4, 0); | 187 pPlayers[uActiveCharacter]->PlaySound(SPEECH_4, 0); |
244 } | 188 } |
245 dword_507CD8 = 0; | 189 dword_507CD8 = 0; |
246 | |
247 pChestWindow = pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_Chest, uChestID, 0); | 190 pChestWindow = pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_Chest, uChestID, 0); |
248 | 191 pBtn_ExitCancel = pChestWindow->CreateButton(471, 445, 169, 35, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[79], pIcons_LOD->GetTexture(uExitCancelTextureId), 0);// Exit |
249 pBtn_ExitCancel = pChestWindow->CreateButton(471, 445, 169, 35, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[79], pIcons_LOD->GetTexture(uExitCancelTextureId), 0);// Exit | 192 pChestWindow->CreateButton( 7, 8, 460, 343, 1, 0, UIMSG_CHEST_ClickItem, 0, 0, "", 0); |
250 pChestWindow->CreateButton( 7, 8, 460, 343, 1, 0, UIMSG_CHEST_ClickItem, 0, 0, "", 0); | |
251 | |
252 pCurrentScreen = SCREEN_CHEST; | 193 pCurrentScreen = SCREEN_CHEST; |
253 pEventTimer->Pause(); | 194 pEventTimer->Pause(); |
254 return 1; | 195 return true; |
255 } | 196 } |
256 | 197 |
257 //----- (0042092D) -------------------------------------------------------- | 198 //----- (0042092D) -------------------------------------------------------- |
258 void Chest::DrawChestUI(signed int uChestID) | 199 void Chest::DrawChestUI(signed int uChestID) |
259 { | 200 { |