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