0
|
1 #include "LayingItem.h"
|
|
2 #include "Party.h"
|
|
3 #include "TurnEngine.h"
|
|
4 #include "MapInfo.h"
|
|
5
|
|
6 #include "mm7_data.h"
|
|
7
|
|
8
|
|
9
|
|
10
|
|
11 size_t uNumLayingItems;
|
|
12 LayingItem pLayingItems[1000];
|
|
13
|
|
14
|
|
15 //----- (00438E35) --------------------------------------------------------
|
187
|
16 void LayingItem::_438E35()
|
0
|
17 {
|
|
18 LayingItem *v1; // edi@1
|
|
19 MapInfo *pMapInfo; // esi@1
|
|
20 int v3; // ebx@1
|
|
21 int v4; // eax@1
|
|
22 int v5; // ebx@1
|
|
23 unsigned int v6; // ecx@1
|
|
24 int v7; // edx@2
|
|
25 unsigned int v8; // edx@4
|
|
26 unsigned int v9; // edx@6
|
|
27 unsigned int v10; // eax@7
|
|
28 signed int v11; // ebx@8
|
|
29 Player **v12; // esi@18
|
|
30 signed int v13; // edi@20
|
|
31 int v15; // [sp+Ch] [bp-Ch]@1
|
|
32 int v16; // [sp+10h] [bp-8h]@1
|
|
33 signed int v17; // [sp+14h] [bp-4h]@8
|
|
34 int v18; // [sp+14h] [bp-4h]@14
|
|
35
|
|
36 v1 = this;
|
|
37 pMapInfo = &pMapStats->pInfos[pMapStats->GetMapInfo(pCurrentMapName)];
|
|
38 v3 = abs(pParty->vPosition.x - v1->vPosition.x);
|
|
39 v15 = abs(pParty->vPosition.y - v1->vPosition.y);
|
|
40 v16 = abs(pParty->vPosition.z + pParty->sEyelevel - v1->vPosition.z);
|
|
41 v4 = v3;
|
|
42 v5 = v15;
|
|
43 v6 = v16;
|
|
44 if ( v4 < v15 )
|
|
45 {
|
|
46 v7 = v4;
|
|
47 v4 = v15;
|
|
48 v5 = v7;
|
|
49 }
|
|
50 if ( v4 < v16 )
|
|
51 {
|
|
52 v8 = v4;
|
|
53 v4 = v16;
|
|
54 v6 = v8;
|
|
55 }
|
|
56 if ( v5 < (signed int)v6 )
|
|
57 {
|
|
58 v9 = v6;
|
|
59 v6 = v5;
|
|
60 v5 = v9;
|
|
61 }
|
|
62 v10 = ((unsigned int)(11 * v5) >> 5) + (v6 >> 2) + v4;
|
|
63 if ( (signed int)v10 <= 768 )
|
|
64 {
|
|
65 v17 = 0;
|
|
66 v11 = 5;
|
|
67 if ( pMapInfo->field_2E )
|
|
68 {
|
|
69 do
|
|
70 {
|
|
71 ++v17;
|
|
72 v11 += rand() % 20 + 1;
|
|
73 }
|
|
74 while ( v17 < pMapInfo->field_2E );
|
|
75 }
|
|
76 switch ( v1->uItemType )
|
|
77 {
|
|
78 case 0x32Bu:
|
|
79 v18 = 0;
|
|
80 break;
|
|
81 case 0x32Cu:
|
|
82 v18 = 1;
|
|
83 break;
|
|
84 case 0x32Du:
|
|
85 v18 = 2;
|
|
86 break;
|
|
87 default:
|
187
|
88 //LOWORD(v10) = v1->uItemType - 814;
|
0
|
89 if ( v1->uItemType != 814 )
|
187
|
90 return;
|
0
|
91 v18 = 8;
|
|
92 break;
|
|
93 }
|
|
94 v12 = &pPlayers[1];
|
|
95 do
|
|
96 {
|
|
97 if ( (*v12)->CanAct() && (v13 = (*v12)->GetPerception() + 20, rand() % v13 > 20) )
|
187
|
98 (*v12)->PlaySound(SPEECH_6, 0);
|
0
|
99 else
|
187
|
100 (*v12)->ReceiveDamage(v11, v18);
|
0
|
101 ++v12;
|
|
102 }
|
|
103 while ( (signed int)v12 <= (signed int)&pPlayers[4] );
|
|
104 }
|
|
105 }
|
|
106
|
|
107
|
|
108
|
|
109 //----- (0042F933) --------------------------------------------------------
|
|
110 void LayingItem::_42F933(unsigned int uLayingItemID)
|
|
111 {
|
|
112 unsigned int v1; // ecx@1
|
|
113 unsigned __int16 *pAttributes; // ecx@2
|
|
114 unsigned __int16 v3; // ax@2
|
|
115
|
|
116 __debugbreak(); // find out what's going on
|
|
117
|
|
118 v1 = uLayingItemID;
|
|
119 pLayingItems[v1].uObjectDescID = 0;
|
|
120 if ( pParty->bTurnBasedModeOn == 1 )
|
|
121 {
|
|
122 pAttributes = &pLayingItems[v1].uAttributes;
|
|
123 v3 = *pAttributes;
|
|
124 if ( *pAttributes & 4 )
|
|
125 {
|
|
126 LOBYTE(v3) = v3 & 0xFB;
|
|
127 --pTurnEngine->field_1C;
|
|
128 *pAttributes = v3;
|
|
129 }
|
|
130 }
|
|
131 }
|