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) --------------------------------------------------------
|
|
16 __int16 LayingItem::_438E35()
|
|
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.z - v1->vPosition.y);
|
|
40 v16 = abs(pParty->vPosition.y + 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:
|
|
88 LOWORD(v10) = v1->uItemType - 814;
|
|
89 if ( v1->uItemType != 814 )
|
|
90 return v10;
|
|
91 v18 = 8;
|
|
92 break;
|
|
93 }
|
|
94 v12 = &pPlayers[1];
|
|
95 do
|
|
96 {
|
|
97 if ( (*v12)->CanAct() && (v13 = (*v12)->GetPerception() + 20, rand() % v13 > 20) )
|
|
98 LOWORD(v10) = (*v12)->PlaySound(6, 0);
|
|
99 else
|
|
100 LOWORD(v10) = (*v12)->ReceiveDamage(v11, v18);
|
|
101 ++v12;
|
|
102 }
|
|
103 while ( (signed int)v12 <= (signed int)&pPlayers[4] );
|
|
104 }
|
|
105 return v10;
|
|
106 }
|
|
107
|
|
108
|
|
109
|
|
110 //----- (0042F933) --------------------------------------------------------
|
|
111 void LayingItem::_42F933(unsigned int uLayingItemID)
|
|
112 {
|
|
113 unsigned int v1; // ecx@1
|
|
114 unsigned __int16 *pAttributes; // ecx@2
|
|
115 unsigned __int16 v3; // ax@2
|
|
116
|
|
117 v1 = uLayingItemID;
|
|
118 pLayingItems[v1].uObjectDescID = 0;
|
|
119 if ( pParty->bTurnBasedModeOn == 1 )
|
|
120 {
|
|
121 pAttributes = &pLayingItems[v1].uAttributes;
|
|
122 v3 = *pAttributes;
|
|
123 if ( *pAttributes & 4 )
|
|
124 {
|
|
125 LOBYTE(v3) = v3 & 0xFB;
|
|
126 --pTurnEngine->field_1C;
|
|
127 *pAttributes = v3;
|
|
128 }
|
|
129 }
|
|
130 }
|