annotate LayingItem.cpp @ 186:0a0eb74e8e95

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