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