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