692
|
1 #include "Viewport.h"
|
|
2
|
|
3 #include "Party.h"
|
|
4 #include "Indoor.h"
|
1051
|
5 #include "Math.h"
|
692
|
6 #include "mm7_data.h"
|
1297
|
7 #include "Actor.h"
|
|
8 #include "Outdoor.h"
|
|
9 #include "Events.h"
|
|
10 #include "BSPModel.h"
|
|
11 #include "Mouse.h"
|
|
12 #include "SpriteObject.h"
|
|
13 #include "ObjectList.h"
|
|
14 #include "DecorationList.h"
|
|
15 #include "texts.h"
|
|
16 #include "Game.h"
|
|
17 #include "Vis.h"
|
|
18 #include "LOD.h"
|
|
19 #include "GUIWindow.h"
|
|
20 #include "TurnEngine.h"
|
|
21 #include "stru123.h"
|
|
22 #include "MM7.h"
|
692
|
23
|
|
24
|
|
25 //----- (004C0262) --------------------------------------------------------
|
|
26 void Viewport::SetScreen( signed int sTL_X, signed int sTL_Y, signed int sBR_X, signed int sBR_Y )
|
|
27 {
|
|
28 unsigned int tl_x; // edx@1
|
|
29 unsigned int br_x; // esi@1
|
|
30 unsigned int tl_y; // edi@3
|
|
31 unsigned int br_y; // eax@3
|
|
32
|
|
33 tl_x = sTL_X;
|
|
34 br_x = sBR_X;
|
|
35 if ( sTL_X > sBR_X )
|
|
36 {
|
1027
|
37 __debugbreak(); // check this code
|
692
|
38 br_x = sBR_X ^ sTL_X ^ sBR_X; // swap x's
|
|
39 tl_x = br_x ^ sBR_X ^ sTL_X;
|
|
40 }
|
|
41 tl_y = sTL_Y;
|
|
42 br_y = sBR_Y;
|
711
|
43 if ( sTL_Y > sBR_Y )
|
692
|
44 {
|
1027
|
45 __debugbreak(); // check this code
|
692
|
46 br_y = sBR_Y ^ sTL_Y ^ sBR_Y; // swap y's
|
|
47 tl_y = br_y ^ sBR_Y ^ sTL_Y;
|
|
48 }
|
|
49 this->uScreen_TL_X = tl_x;
|
|
50 this->uScreen_TL_Y = tl_y;
|
|
51 this->uScreen_BR_X = br_x;
|
|
52 this->uScreen_BR_Y = br_y;
|
|
53 this->uScreenWidth = br_x - tl_x + 1;
|
693
|
54 this->uScreenHeight = br_y - tl_y + 1;
|
|
55 this->uScreenCenterX = (signed int)(br_x + tl_x) /2;
|
692
|
56 if ( pRenderer->pRenderD3D == 0 )
|
871
|
57 this->uScreenCenterY = this->uScreen_BR_Y - fixpoint_sub0(field_30, uScreenHeight);
|
692
|
58 else
|
693
|
59 this->uScreenCenterY = uScreenHeight/2;
|
692
|
60 SetViewport(this->uScreen_TL_X, this->uScreen_TL_Y, this->uScreen_BR_X, this->uScreen_BR_Y);
|
|
61 }
|
|
62
|
|
63 //----- (004C02F8) --------------------------------------------------------
|
|
64 void Viewport::_4C02F8(int a2)
|
|
65 {
|
|
66 this->field_30 = a2;
|
|
67 SetScreen(this->uScreen_TL_X, this->uScreen_TL_Y, this->uScreen_BR_X, this->uScreen_BR_Y);
|
|
68 }
|
|
69
|
|
70 //----- (004C0312) --------------------------------------------------------
|
693
|
71 void Viewport::SetViewport( signed int sTL_X, signed int sTL_Y, signed int sBR_X, signed int sBR_Y )
|
692
|
72 {
|
693
|
73 signed int tl_x; // ebx@1
|
|
74 signed int tl_y; // edi@3
|
|
75 signed int br_x; // edx@5
|
|
76 signed int br_y; // eax@7
|
692
|
77
|
693
|
78 tl_x = sTL_X;
|
|
79 if ( sTL_X < this->uScreen_TL_X )
|
|
80 tl_x = this->uScreen_TL_X;
|
|
81 tl_y = sTL_Y;
|
|
82 if ( sTL_Y < this->uScreen_TL_Y )
|
|
83 tl_y = this->uScreen_TL_Y;
|
|
84 br_x = sBR_X;
|
|
85 if ( sBR_X > this->uScreen_BR_X )
|
|
86 br_x = this->uScreen_BR_X;
|
|
87 br_y = sBR_Y;
|
|
88 if ( sBR_Y > this->uScreen_BR_Y )
|
|
89 br_y = this->uScreen_BR_Y;
|
|
90 this->uViewportTL_Y = tl_y;
|
|
91 this->uViewportTL_X = tl_x;
|
|
92 this->uViewportBR_X = br_x;
|
|
93 this->uViewportBR_Y = br_y;
|
692
|
94 }
|
|
95
|
|
96 //----- (00443219) --------------------------------------------------------
|
|
97 void ViewingParams::_443219()
|
|
98 {
|
693
|
99 this->sViewCenterY += 512;
|
|
100 AdjustPosition();
|
692
|
101 }
|
|
102
|
|
103 //----- (00443225) --------------------------------------------------------
|
|
104 void ViewingParams::_443225()
|
|
105 {
|
693
|
106 this->sViewCenterX -= 512;
|
|
107 AdjustPosition();
|
692
|
108 }
|
|
109
|
|
110 //----- (00443231) --------------------------------------------------------
|
|
111 void ViewingParams::_443231()
|
|
112 {
|
693
|
113 this->sViewCenterY -= 512;
|
|
114 AdjustPosition();
|
692
|
115 }
|
|
116
|
|
117 //----- (0044323D) --------------------------------------------------------
|
|
118 void ViewingParams::_44323D()
|
|
119 {
|
693
|
120 this->sViewCenterX += 512;
|
|
121 AdjustPosition();
|
692
|
122 }
|
|
123
|
|
124 //----- (00443249) --------------------------------------------------------
|
693
|
125 void ViewingParams::CenterOnParty()
|
692
|
126 {
|
|
127 int v1; // edx@1
|
|
128
|
|
129 v1 = (unsigned __int64)((signed __int64)this->field_2C << 15) >> 16;
|
|
130 this->field_2C = v1;
|
|
131 if ( v1 < 384 )
|
|
132 this->field_2C = 384;
|
693
|
133 this->sViewCenterX = pParty->vPosition.x;
|
|
134 this->sViewCenterY = pParty->vPosition.y;
|
|
135 AdjustPosition();
|
692
|
136 }
|
|
137
|
|
138 //----- (00443291) --------------------------------------------------------
|
693
|
139 void ViewingParams::CenterOnParty2()
|
692
|
140 {
|
|
141 int v1; // edx@1
|
|
142 int v2; // eax@1
|
|
143
|
|
144 v1 = 2 * this->field_2C;
|
|
145 v2 = 1536;
|
|
146 this->field_2C = v1;
|
|
147 if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor )
|
|
148 v2 = 3072;
|
|
149 if ( v1 > v2 )
|
|
150 this->field_2C = v2;
|
693
|
151 this->sViewCenterX = pParty->vPosition.x;
|
|
152 this->sViewCenterY = pParty->vPosition.y;
|
|
153 AdjustPosition();
|
692
|
154 }
|
|
155
|
|
156 //----- (004432E7) --------------------------------------------------------
|
693
|
157 void ViewingParams::AdjustPosition()
|
692
|
158 {
|
|
159 ViewingParams *v1; // esi@1
|
|
160 int v2; // ebx@1
|
|
161 signed int v3; // edx@1
|
|
162 int v4; // ecx@1
|
|
163 int v5; // edi@3
|
|
164 int v6; // eax@3
|
|
165 int v7; // eax@5
|
693
|
166
|
692
|
167
|
|
168 v1 = this;
|
711
|
169 v2 = this->indoor_center_y;
|
692
|
170 v3 = 88 >> this->field_2C / 384;
|
|
171 v4 = (44 - v3) << 9;
|
693
|
172 if ( v1->sViewCenterY > v2 + v4 )
|
|
173 v1->sViewCenterY = v2 + v4;
|
692
|
174
|
711
|
175 v5 = v1->indoor_center_x;
|
692
|
176 v6 = (v3 - 44) << 9;
|
693
|
177 if ( v1->sViewCenterX < v5 + v6 )
|
|
178 v1->sViewCenterX = v5 + v6;
|
692
|
179
|
|
180 v7 = v2 + v6;
|
693
|
181 if ( v1->sViewCenterY < v7 )
|
|
182 v1->sViewCenterY = v7;
|
692
|
183
|
693
|
184 if ( v1->sViewCenterX > v5 + v4 )
|
|
185 v1->sViewCenterX = v5 + v4;
|
692
|
186 }
|
|
187
|
|
188 //----- (00443343) --------------------------------------------------------
|
|
189 void ViewingParams::InitGrayPalette()
|
|
190 {
|
|
191 for (unsigned short i=0; i<256; ++i)
|
949
|
192 pPalette[i]=TargetColor(i, i, i);
|
692
|
193 }
|
|
194
|
|
195 //----- (00443365) --------------------------------------------------------
|
|
196 void ViewingParams::_443365()
|
1222
|
197 {
|
|
198 Vec3_short_ *v3; // eax@4
|
|
199 Vec3_short_ *v6; // eax@12
|
|
200 int minimum_y; // [sp+10h] [bp-10h]@2
|
|
201 int maximum_y; // [sp+14h] [bp-Ch]@2
|
|
202 int minimum_x; // [sp+18h] [bp-8h]@2
|
|
203 int maximum_x; // [sp+1Ch] [bp-4h]@2
|
692
|
204
|
1222
|
205 InitGrayPalette();
|
|
206 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
|
|
207 {
|
|
208 minimum_x = 0x40000000;
|
|
209 minimum_y = 0x40000000;
|
711
|
210
|
1222
|
211 maximum_x = -0x40000000;
|
|
212 maximum_y = -0x40000000;
|
|
213 for (int i=0; i<pIndoor->pMapOutlines->uNumOutlines; ++i)
|
|
214 {
|
|
215 v3 = &pIndoor->pVertices[pIndoor->pMapOutlines->pOutlines[i].uFace1ID];
|
711
|
216
|
1222
|
217 if ( v3->x < minimum_x )
|
|
218 minimum_x = v3->x;
|
|
219 if ( v3->x > maximum_x )
|
|
220 maximum_x = v3->x;
|
|
221 if ( v3->y < minimum_y )
|
|
222 minimum_y = v3->x;
|
|
223 if ( v3->y > maximum_y )
|
|
224 maximum_y = v3->x;
|
711
|
225
|
1222
|
226 v6 = &pIndoor->pVertices[pIndoor->pMapOutlines->pOutlines[i].uFace2ID];
|
|
227
|
|
228 if ( v6->x < minimum_x )
|
|
229 minimum_x = v3->x;
|
|
230 if ( v6->x > maximum_x )
|
|
231 maximum_x = v3->x;
|
711
|
232
|
1222
|
233 if ( v6->y < minimum_y )
|
|
234 minimum_y = v3->y;
|
|
235 if ( v6->y > maximum_y )
|
|
236 maximum_y = v3->y;
|
|
237 }
|
711
|
238
|
1222
|
239 uMinimapZoom = 1024;
|
|
240 indoor_center_x = (signed int)(minimum_x + maximum_x) / 2;
|
|
241 field_28 = 10;
|
|
242 indoor_center_y = (signed int)(minimum_y + maximum_y) / 2;
|
|
243 }
|
|
244 else
|
|
245 {
|
|
246 indoor_center_x = 0;
|
|
247 indoor_center_y = 0;
|
|
248 uMinimapZoom = _576E2C_current_minimap_zoom;
|
|
249 field_28 = dword_576E28;
|
|
250 }
|
|
251 field_2C = 384;
|
1297
|
252 }
|
|
253 //----- (0042213C) --------------------------------------------------------
|
|
254 void OnGameViewportClick()
|
|
255 {
|
|
256 signed int v0; // ebx@2
|
|
257 POINT *v1; // esi@3
|
|
258 signed int v6; // eax@14
|
|
259 char *v7; // esi@15
|
|
260 int v9; // eax@19
|
1321
|
261 unsigned int pTextureID; // eax@19
|
|
262 int pEventID; // ecx@21
|
1297
|
263 int v15; // ecx@29
|
|
264 signed int v16; // edx@30
|
|
265 int v18; // ebx@47
|
|
266 signed int v21; // eax@58
|
|
267 SpriteObject a1; // [sp+Ch] [bp-80h]@1
|
|
268 POINT a2; // [sp+84h] [bp-8h]@3
|
|
269
|
1321
|
270 int clickable_distance = 512;
|
|
271
|
1297
|
272 v1 = pMouse->GetCursorPos(&a2);
|
|
273 if ( pRenderer->pRenderD3D )
|
|
274 v0 = pGame->pVisInstance->get_picked_object_zbuf_val();
|
|
275 else
|
|
276 v0 = pRenderer->pActiveZBuffer[v1->x + pSRZBufferLineOffsets[v1->y]];
|
|
277
|
|
278 if ( PID_TYPE(v0) == OBJECT_Item)
|
|
279 {
|
|
280 a2.y = (signed int)(unsigned __int16)v0 >> 3;
|
|
281 v21 = (signed int)(unsigned __int16)v0 >> 3;
|
|
282 if ( !(pObjectList->pObjects[pSpriteObjects[v21].uObjectDescID].uFlags & 0x10) && a2.y < 1000 && pSpriteObjects[v21].uObjectDescID
|
|
283 && (unsigned int)v0 < 0x2000000 )
|
|
284 {
|
1321
|
285 if ( pItemsTable->pItems[pSpriteObjects[v21].stru_24.uItemID].uEquipType == 18 )
|
1297
|
286 {
|
1321
|
287 party_finds_gold(pSpriteObjects[v21].stru_24.uSpecEnchantmentType, 0);
|
1297
|
288 viewparams->bRedrawGameUI = 1;
|
|
289 }
|
|
290 else
|
|
291 {
|
1321
|
292 sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], pItemsTable->pItems[pSpriteObjects[v21].stru_24.uItemID].pUnidentifiedName);
|
1297
|
293 ShowStatusBarString(pTmpBuf2.data(), 2u);
|
1321
|
294 if ( pSpriteObjects[v21].stru_24.uItemID == 506 )
|
|
295 _449B7E_toggle_bit(pParty->_quest_bits, 184, 1);
|
|
296 if ( pSpriteObjects[v21].stru_24.uItemID == 455 )
|
|
297 _449B7E_toggle_bit(pParty->_quest_bits, 185, 1);
|
|
298 if ( !pParty->AddItem(&pSpriteObjects[v21].stru_24) )
|
|
299 pParty->SetHoldingItem(&pSpriteObjects[v21].stru_24);
|
1297
|
300 }
|
|
301 SpriteObject::OnInteraction(a2.y);
|
|
302 return;
|
|
303 }
|
|
304 if ( !pParty->pPickedItem.uItemID )
|
1321
|
305 return;
|
1328
|
306 __debugbreak();//no checker
|
1321
|
307 v6 = 0;
|
|
308 a1.uType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID;
|
|
309 if ( (signed int)pObjectList->uNumObjects <= 0 )
|
|
310 LOWORD(v6) = 0;
|
|
311 else
|
|
312 {
|
|
313 v7 = (char *)&pObjectList->pObjects->uObjectID;
|
|
314 while ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID != *(short *)v7 )
|
|
315 {
|
|
316 ++v6;
|
|
317 v7 += 56;
|
|
318 if ( v6 >= (signed int)pObjectList->uNumObjects )
|
|
319 {
|
|
320 LOWORD(v6) = 0;
|
|
321 break;
|
|
322 }
|
|
323 }
|
|
324 }
|
|
325 a1.uObjectDescID = v6;
|
|
326 a1.vPosition.y = pParty->vPosition.y;
|
|
327 a1.spell_caster_pid = OBJECT_Player;
|
|
328 a1.vPosition.x = pParty->vPosition.x;
|
|
329 a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z;
|
|
330 a1.uSoundID = 0;
|
|
331 a1.uFacing = 0;
|
|
332 a1.uAttributes = 8;
|
|
333 a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z);
|
|
334 a1.uSpriteFrameID = 0;
|
|
335 memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u);
|
|
336
|
|
337 extern int UnprojectX(int);
|
|
338 v9 = UnprojectX(v1->x);
|
|
339 a1.Create(pParty->sRotationY + v9, 184, 200, 0);
|
|
340 pTextureID = pIcons_LOD->LoadTexture(pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName, TEXTURE_16BIT_PALETTE);
|
|
341 if (pTextureID != -1)
|
|
342 pIcons_LOD->pTextures[pTextureID].Release();
|
|
343 pMouse->RemoveHoldingItem();
|
|
344 pIcons_LOD->SyncLoadedFilesCount();
|
|
345 return;
|
1297
|
346 }
|
1321
|
347 if ( PID_TYPE(v0) == OBJECT_Actor)
|
1297
|
348 {
|
1321
|
349 v16 = (signed int)(unsigned __int16)v0 >> 3;
|
|
350 a2.y = v16;
|
|
351 if ( pActors[v16].uAIState == 5 )
|
1297
|
352 {
|
1321
|
353 if ( (unsigned int)v0 < 0x2000000 )
|
|
354 {
|
|
355 stru_50C198.LootActor(&pActors[v16]);
|
|
356 return;
|
|
357 }
|
|
358 if ( !pParty->pPickedItem.uItemID )
|
|
359 return;
|
1328
|
360 __debugbreak();//no checker
|
1321
|
361 v6 = 0;
|
|
362 a1.uType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID;
|
|
363 if ( (signed int)pObjectList->uNumObjects <= 0 )
|
|
364 LOWORD(v6) = 0;
|
|
365 else
|
|
366 {
|
|
367 v7 = (char *)&pObjectList->pObjects->uObjectID;
|
|
368 while ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID != *(short *)v7 )
|
|
369 {
|
|
370 ++v6;
|
|
371 v7 += 56;
|
|
372 if ( v6 >= (signed int)pObjectList->uNumObjects )
|
|
373 {
|
|
374 LOWORD(v6) = 0;
|
|
375 break;
|
|
376 }
|
|
377 }
|
|
378 }
|
|
379 a1.uObjectDescID = v6;
|
|
380 a1.vPosition.y = pParty->vPosition.y;
|
|
381 a1.spell_caster_pid = OBJECT_Player;
|
|
382 a1.vPosition.x = pParty->vPosition.x;
|
|
383 a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z;
|
|
384 a1.uSoundID = 0;
|
|
385 a1.uFacing = 0;
|
|
386 a1.uAttributes = 8;
|
|
387 a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z);
|
|
388 a1.uSpriteFrameID = 0;
|
|
389 memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u);
|
|
390
|
|
391 extern int UnprojectX(int);
|
|
392 v9 = UnprojectX(v1->x);
|
|
393 a1.Create(pParty->sRotationY + v9, 184, 200, 0);
|
|
394 pTextureID = pIcons_LOD->LoadTexture(pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName, TEXTURE_16BIT_PALETTE);
|
|
395 if (pTextureID != -1)
|
|
396 pIcons_LOD->pTextures[pTextureID].Release();
|
|
397 pMouse->RemoveHoldingItem();
|
|
398 pIcons_LOD->SyncLoadedFilesCount();
|
|
399 return;
|
|
400 }
|
|
401 if ( GetAsyncKeyState(VK_SHIFT) >= 0 )
|
|
402 {
|
|
403 if ( !pActors[v16].GetActorsRelation(0) && !(BYTE2(pActors[v16].uAttributes) & 8) )
|
|
404 {
|
|
405 if ( HIWORD(v0) >= clickable_distance)
|
|
406 {
|
1297
|
407 if ( !pParty->pPickedItem.uItemID )
|
|
408 return;
|
1328
|
409 __debugbreak();//no checker
|
1321
|
410 v6 = 0;
|
|
411 a1.uType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID;
|
|
412 if ( (signed int)pObjectList->uNumObjects <= 0 )
|
|
413 LOWORD(v6) = 0;
|
|
414 else
|
|
415 {
|
|
416 v7 = (char *)&pObjectList->pObjects->uObjectID;
|
|
417 while ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID != *(short *)v7 )
|
|
418 {
|
|
419 ++v6;
|
|
420 v7 += 56;
|
|
421 if ( v6 >= (signed int)pObjectList->uNumObjects )
|
|
422 {
|
|
423 LOWORD(v6) = 0;
|
|
424 break;
|
|
425 }
|
|
426 }
|
|
427 }
|
|
428 a1.uObjectDescID = v6;
|
|
429 a1.vPosition.y = pParty->vPosition.y;
|
|
430 a1.spell_caster_pid = OBJECT_Player;
|
|
431 a1.vPosition.x = pParty->vPosition.x;
|
|
432 a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z;
|
|
433 a1.uSoundID = 0;
|
|
434 a1.uFacing = 0;
|
|
435 a1.uAttributes = 8;
|
|
436 a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z);
|
|
437 a1.uSpriteFrameID = 0;
|
|
438 memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u);
|
|
439
|
|
440 extern int UnprojectX(int);
|
|
441 v9 = UnprojectX(v1->x);
|
|
442 a1.Create(pParty->sRotationY + v9, 184, 200, 0);
|
|
443 pTextureID = pIcons_LOD->LoadTexture(pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName, TEXTURE_16BIT_PALETTE);
|
|
444 if (pTextureID != -1)
|
|
445 pIcons_LOD->pTextures[pTextureID].Release();
|
|
446 pMouse->RemoveHoldingItem();
|
|
447 pIcons_LOD->SyncLoadedFilesCount();
|
|
448 return;
|
|
449 }
|
|
450 if ( !pActors[v16].CanAct() )
|
|
451 return;
|
|
452 v18 = a2.y;
|
|
453 Actor::AI_FaceObject(a2.y, 4, 0, 0);
|
|
454 if ( !pActors[v16].sNPC_ID )
|
1297
|
455 {
|
1321
|
456 if ( pNPCStats->pGroups_copy[pActors[v16].uGroup] )
|
|
457 {
|
|
458 if ( pNPCStats->pCatchPhrases[pNPCStats->pGroups_copy[pActors[v16].uGroup]] )
|
|
459 {
|
|
460 pParty->uFlags |= 2u;
|
|
461 strcpy(byte_5B0938.data(), pNPCStats->pCatchPhrases[pNPCStats->pGroups_copy[pActors[v16].uGroup]]);
|
|
462 sub_4451A8_press_any_key(0, 0, 0);
|
|
463 }
|
|
464 }
|
|
465 return;
|
1297
|
466 }
|
1321
|
467 pMessageQueue_50CBD0->AddMessage(UIMSG_StartNPCDialogue, v18, 0);
|
1297
|
468 return;
|
|
469 }
|
1340
|
470 if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->turn_stage == 3 )
|
1321
|
471 {
|
1332
|
472 pTurnEngine->field_18 |= TE_FLAG_8;
|
1321
|
473 return;
|
|
474 }
|
|
475 pMessageQueue_50CBD0->AddMessage(UIMSG_Attack, 0, 0);
|
1297
|
476 }
|
|
477 else
|
|
478 {
|
1340
|
479 if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->turn_stage == 3 )
|
1297
|
480 {
|
1321
|
481 pParty->uFlags |= PARTY_FLAGS_1_FALLING;
|
|
482 return;
|
1297
|
483 }
|
1321
|
484 if ( uActiveCharacter && sub_427769_spell(pPlayers[uActiveCharacter]->uQuickSpell))
|
|
485 pMessageQueue_50CBD0->AddMessage(UIMSG_CastQuickSpell, 0, 0);
|
1297
|
486 }
|
|
487 return;
|
|
488 }
|
1321
|
489 if ( PID_TYPE(v0) == OBJECT_Decoration)
|
1297
|
490 {
|
1321
|
491 if ( (signed int)(((unsigned int)v0 >> 16) - pDecorationList->pDecorations[pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3].uDecorationDescID].uRadius) >= clickable_distance )
|
1297
|
492 {
|
1321
|
493 if ( !pParty->pPickedItem.uItemID )
|
|
494 return;
|
1328
|
495 __debugbreak();//no checker
|
1321
|
496 v6 = 0;
|
|
497 a1.uType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID;
|
|
498 if ( (signed int)pObjectList->uNumObjects <= 0 )
|
|
499 LOWORD(v6) = 0;
|
|
500 else
|
|
501 {
|
|
502 v7 = (char *)&pObjectList->pObjects->uObjectID;
|
|
503 while ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID != *(short *)v7 )
|
|
504 {
|
|
505 ++v6;
|
|
506 v7 += 56;
|
|
507 if ( v6 >= (signed int)pObjectList->uNumObjects )
|
|
508 {
|
|
509 LOWORD(v6) = 0;
|
|
510 break;
|
|
511 }
|
|
512 }
|
|
513 }
|
|
514 a1.uObjectDescID = v6;
|
|
515 a1.vPosition.y = pParty->vPosition.y;
|
|
516 a1.spell_caster_pid = OBJECT_Player;
|
|
517 a1.vPosition.x = pParty->vPosition.x;
|
|
518 a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z;
|
|
519 a1.uSoundID = 0;
|
|
520 a1.uFacing = 0;
|
|
521 a1.uAttributes = 8;
|
|
522 a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z);
|
|
523 a1.uSpriteFrameID = 0;
|
|
524 memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u);
|
|
525
|
|
526 extern int UnprojectX(int);
|
|
527 v9 = UnprojectX(v1->x);
|
|
528 a1.Create(pParty->sRotationY + v9, 184, 200, 0);
|
|
529 pTextureID = pIcons_LOD->LoadTexture(pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName, TEXTURE_16BIT_PALETTE);
|
|
530 if (pTextureID != -1)
|
|
531 pIcons_LOD->pTextures[pTextureID].Release();
|
|
532 pMouse->RemoveHoldingItem();
|
|
533 pIcons_LOD->SyncLoadedFilesCount();
|
1297
|
534 return;
|
|
535 }
|
1321
|
536 if ( !pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3].field_16_event_id )
|
|
537 {
|
|
538 if ( pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3].IsInteractive() )
|
|
539 {
|
|
540 v15 = stru_5E4C90._decor_events[pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3]._idx_in_stru123 - 75] + 380;
|
|
541 activeLevelDecoration = &pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3];
|
|
542 EventProcessor(v15, 0, 1);
|
|
543 activeLevelDecoration = NULL;
|
|
544 }
|
|
545 return;
|
|
546 }
|
|
547 pEventID = pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3].field_16_event_id;
|
1297
|
548 }
|
1321
|
549 if ( PID_TYPE(v0) == OBJECT_BModel && HIWORD(v0) < clickable_distance)
|
1297
|
550 {
|
1321
|
551 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
|
1297
|
552 {
|
1321
|
553 if ( !(pIndoor->pFaces[PID_ID(v0)].uAttributes & 0x2000000) )
|
|
554 {
|
|
555 if ( !pParty->pPickedItem.uItemID )
|
|
556 {
|
|
557 ShowNothingHereStatus();
|
1297
|
558 if ( !pParty->pPickedItem.uItemID )
|
|
559 return;
|
1321
|
560 }
|
1328
|
561 __debugbreak();//no checker
|
1321
|
562 v6 = 0;
|
|
563 a1.uType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID;
|
|
564 if ( (signed int)pObjectList->uNumObjects <= 0 )
|
|
565 LOWORD(v6) = 0;
|
|
566 else
|
1297
|
567 {
|
1321
|
568 v7 = (char *)&pObjectList->pObjects->uObjectID;
|
|
569 while ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID != *(short *)v7 )
|
1297
|
570 {
|
1321
|
571 ++v6;
|
|
572 v7 += 56;
|
|
573 if ( v6 >= (signed int)pObjectList->uNumObjects )
|
|
574 {
|
|
575 LOWORD(v6) = 0;
|
|
576 break;
|
|
577 }
|
1297
|
578 }
|
|
579 }
|
1321
|
580 a1.uObjectDescID = v6;
|
|
581 a1.vPosition.y = pParty->vPosition.y;
|
|
582 a1.spell_caster_pid = OBJECT_Player;
|
|
583 a1.vPosition.x = pParty->vPosition.x;
|
|
584 a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z;
|
|
585 a1.uSoundID = 0;
|
|
586 a1.uFacing = 0;
|
|
587 a1.uAttributes = 8;
|
|
588 a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z);
|
|
589 a1.uSpriteFrameID = 0;
|
|
590 memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u);
|
|
591
|
|
592 extern int UnprojectX(int);
|
|
593 v9 = UnprojectX(v1->x);
|
|
594 a1.Create(pParty->sRotationY + v9, 184, 200, 0);
|
|
595 pTextureID = pIcons_LOD->LoadTexture(pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName, TEXTURE_16BIT_PALETTE);
|
|
596 if (pTextureID != -1)
|
|
597 pIcons_LOD->pTextures[pTextureID].Release();
|
|
598 pMouse->RemoveHoldingItem();
|
|
599 pIcons_LOD->SyncLoadedFilesCount();
|
1297
|
600 return;
|
|
601 }
|
1321
|
602 pEventID = pIndoor->pFaceExtras[pIndoor->pFaces[PID_ID(v0)].uFaceExtraID].uEventID;
|
1297
|
603 }
|
1321
|
604 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
|
1297
|
605 {
|
1321
|
606 if ( !pOutdoor->pBModels[(signed int)(v0 & 0xFFFF) >> 9].pFaces[PID_ID(v0) & 0x3F].Clickable())
|
|
607 {
|
|
608 if ( !pParty->pPickedItem.uItemID )
|
|
609 {
|
|
610 ShowNothingHereStatus();
|
|
611 if ( !pParty->pPickedItem.uItemID )
|
|
612 return;
|
|
613 }
|
1328
|
614 __debugbreak();//no checker
|
1321
|
615 v6 = 0;
|
|
616 a1.uType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID;
|
|
617 if ( (signed int)pObjectList->uNumObjects <= 0 )
|
|
618 LOWORD(v6) = 0;
|
|
619 else
|
|
620 {
|
|
621 v7 = (char *)&pObjectList->pObjects->uObjectID;
|
|
622 while ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID != *(short *)v7 )
|
|
623 {
|
|
624 ++v6;
|
|
625 v7 += 56;
|
|
626 if ( v6 >= (signed int)pObjectList->uNumObjects )
|
|
627 {
|
|
628 LOWORD(v6) = 0;
|
|
629 break;
|
|
630 }
|
|
631 }
|
|
632 }
|
|
633 a1.uObjectDescID = v6;
|
|
634 a1.vPosition.y = pParty->vPosition.y;
|
|
635 a1.spell_caster_pid = OBJECT_Player;
|
|
636 a1.vPosition.x = pParty->vPosition.x;
|
|
637 a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z;
|
|
638 a1.uSoundID = 0;
|
|
639 a1.uFacing = 0;
|
|
640 a1.uAttributes = 8;
|
|
641 a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z);
|
|
642 a1.uSpriteFrameID = 0;
|
|
643 memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u);
|
|
644
|
|
645 extern int UnprojectX(int);
|
|
646 v9 = UnprojectX(v1->x);
|
|
647 a1.Create(pParty->sRotationY + v9, 184, 200, 0);
|
|
648 pTextureID = pIcons_LOD->LoadTexture(pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName, TEXTURE_16BIT_PALETTE);
|
|
649 if (pTextureID != -1)
|
|
650 pIcons_LOD->pTextures[pTextureID].Release();
|
|
651 pMouse->RemoveHoldingItem();
|
|
652 pIcons_LOD->SyncLoadedFilesCount();
|
|
653 return;
|
|
654 }
|
|
655 pEventID = pOutdoor->pBModels[(signed int)(v0 & 0xFFFF) >> 9].pFaces[PID_ID(v0) & 0x3F].sCogTriggeredID;
|
|
656 }
|
|
657 EventProcessor(pEventID, (unsigned __int16)v0, 1);
|
|
658 return;
|
1297
|
659 }
|
1321
|
660 if ( PID_TYPE(v0) != OBJECT_BModel || HIWORD(v0) >= clickable_distance )
|
1297
|
661 {
|
1321
|
662 if ( !pParty->pPickedItem.uItemID )
|
1297
|
663 return;
|
1328
|
664 __debugbreak();//no checker
|
1321
|
665 v6 = 0;
|
|
666 a1.uType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID;
|
|
667 if ( (signed int)pObjectList->uNumObjects <= 0 )
|
|
668 LOWORD(v6) = 0;
|
|
669 else
|
1297
|
670 {
|
1321
|
671 v7 = (char *)&pObjectList->pObjects->uObjectID;
|
|
672 while ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID != *(short *)v7 )
|
|
673 {
|
|
674 ++v6;
|
|
675 v7 += 56;
|
|
676 if ( v6 >= (signed int)pObjectList->uNumObjects )
|
|
677 {
|
|
678 LOWORD(v6) = 0;
|
|
679 break;
|
|
680 }
|
|
681 }
|
1297
|
682 }
|
1321
|
683 a1.uObjectDescID = v6;
|
|
684 a1.vPosition.y = pParty->vPosition.y;
|
|
685 a1.spell_caster_pid = OBJECT_Player;
|
|
686 a1.vPosition.x = pParty->vPosition.x;
|
|
687 a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z;
|
|
688 a1.uSoundID = 0;
|
|
689 a1.uFacing = 0;
|
|
690 a1.uAttributes = 8;
|
|
691 a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z);
|
|
692 a1.uSpriteFrameID = 0;
|
|
693 memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u);
|
|
694
|
|
695 extern int UnprojectX(int);
|
|
696 v9 = UnprojectX(v1->x);
|
|
697 a1.Create(pParty->sRotationY + v9, 184, 200, 0);
|
|
698 pTextureID = pIcons_LOD->LoadTexture(pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName, TEXTURE_16BIT_PALETTE);
|
|
699 if (pTextureID != -1)
|
|
700 pIcons_LOD->pTextures[pTextureID].Release();
|
|
701 pMouse->RemoveHoldingItem();
|
|
702 pIcons_LOD->SyncLoadedFilesCount();
|
|
703 return;
|
1297
|
704 }
|
|
705 }
|