-
Notifications
You must be signed in to change notification settings - Fork 1
/
Monsters.cpp
223 lines (197 loc) · 6.17 KB
/
Monsters.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
#include "DevilPK.h"
#include "ArrayEx.h"
int AreaLocaleIds[] = {0, 5055, 5054, 5053, 5052, 5051, 5050, 5049, 3714, 5047, 5046, 5045, 5044, 5043, 5042, 5041, 5040, 5039, 5038, 5037, 5036, 5035, 5034, 5033, 5032, 5031, 5030, 5029, 5028, 5027, 5026, 5025, 5024, 5023, 5022, 5021, 5020, 5019, 5018, 788, 852, 851, 850, 849, 848, 847, 846, 845, 844, 843, 842, 841, 840, 839, 838, 837, 836, 835, 834, 833, 832, 831, 830, 829, 828, 827, 826, 826, 826, 826, 826, 826, 826, 825, 824, 820, 819, 818, 817, 816, 815, 814, 813, 812, 810, 811, 809, 808, 806, 805, 807, 804, 845, 844, 803, 802, 801, 800, 799, 798, 797, 796, 795, 790, 792, 793, 794, 791, 789, 22646, 22647, 22648, 22649, 22650, 22651, 22652, 22653, 22654, 22655, 22656, 22657, 22660, 21865, 21866, 21867, 22658, 22659, 22662, 22663, 22664, 22665, 22667, 22666, 11155, 11156, 11157, 5018};
void DrawMonsters ()
{
//Grab Player Unit and check if valid
UnitAny *pPlayer = D2CLIENT_GetPlayerUnit ();
if (!pPlayer)
return;
int dwLevelNo = pPlayer->pPath->pRoom1->pRoom2->pLevel->dwLevelNo;
if ((dwLevelNo == 1) || (dwLevelNo == 40) || (dwLevelNo == 75) || (dwLevelNo == 103) || (dwLevelNo == 109))
return;
for (Room1 *pRoom = pPlayer->pAct->pRoom1; pRoom; pRoom = pRoom->pRoomNext)
{
for (UnitAny *pUnit = pRoom->pUnitFirst; pUnit; pUnit = pUnit->pListNext)
{
if (!IsValidMonster(pUnit))
continue;
if (pUnit->dwType == UNIT_MONSTER)
if(cfg.DrawMonsters)
{
int Color = cfg.MonsterColor;
if (pUnit->pMonsterData->fBoss & 1 || pUnit->pMonsterData->fChamp & 1)
Color = cfg.ChampionMonsterColor;
char nMonTxt[40] = "";
if (D2COMMON_GetUnitStat(pUnit, 36, 0) + 300 > 399)//Physical
strcat_s(nMonTxt, "ÿc4i");
if (D2COMMON_GetUnitStat(pUnit, 43, 0) + 300 > 399)//Cold
strcat_s(nMonTxt, "ÿc3i");
if (D2COMMON_GetUnitStat(pUnit, 39, 0) + 300 > 399)//Fire
strcat_s(nMonTxt, "ÿc1i");
if (D2COMMON_GetUnitStat(pUnit, 41, 0) + 300 > 399)//Light
strcat_s(nMonTxt, "ÿc9i");
if (D2COMMON_GetUnitStat(pUnit, 45, 0) + 300 > 399)//Poison
strcat_s(nMonTxt, "ÿc2i");
if (D2COMMON_GetUnitStat(pUnit, 37, 0) + 300 > 399)//Magic
strcat_s(nMonTxt, "ÿc8i");
if(cfg.DrawMonsters)
{
DrawCross(pUnit->pPath->xPos, pUnit->pPath->yPos, Color, true);
if(cfg.DrawImunities)
if (strlen(nMonTxt) > 0)
TextHook(pUnit->pPath->xPos - 3, pUnit->pPath->yPos, 0, true, 6, 2, "%s", nMonTxt);
}
}
int missileColor = -1;
if (pPlayer->dwUnitId == pUnit->dwOwnerId)
missileColor = cfg.MyMissile;
if ((pUnit->dwOwnerType == UNIT_PLAYER) && (missileColor == -1))
{
switch (GetPvPStatus(pUnit->dwOwnerId))
{
case PVP_NEUTRAL:
{
missileColor = cfg.NeutralMissile; //153;
}
break;
case PVP_HOSTILE:
{
missileColor = cfg.EnemyMissile; //98;
}
break;
case PVP_FRIENDLY:
{
missileColor = cfg.FriendMissile; //132;
}
break;
}
}
if ((pUnit->dwOwnerType == UNIT_MONSTER) && (missileColor == -1))
{
UnitAny *pOwner = D2CLIENT_FindServerSideUnit(pUnit->dwOwnerId, pUnit->dwOwnerType);
if (!pOwner)
missileColor = 98;
else if (D2CLIENT_GetMonsterOwner(pOwner->dwUnitId) != -1)
{
switch (GetPvPStatus(D2CLIENT_GetMonsterOwner(pOwner->dwUnitId)))
{
case PVP_NEUTRAL:
{
missileColor = 153;
}
break;
case PVP_HOSTILE:
{
missileColor = 98;
}
break;
case PVP_FRIENDLY:
{
missileColor = 132;
}
break;
}
}
}
if (pUnit->dwType != UNIT_MONSTER)
{
if(cfg.DrawMissiles)
BoxHook(pUnit->pPath->xPos - 3, pUnit->pPath->yPos - 3, 3, 3, missileColor, 5, true);
}
}
}
}
VOID DrawAutomapText()
{
UnitAny *pUnit = D2CLIENT_GetPlayerUnit();
wchar_t* pLocaleText;
if (!LevelNames.IsEmpty ())
{
int townLevels[6] = {1, 40, 75, 103, 109, 132};
for (int i = 0; i < LevelNames.GetSize(); i++)
{
LevelNameInfo* pInfo = LevelNames.ElementAt(i);
if (pInfo->nAct != pUnit->dwAct)
continue;
char nLevelName[70];
pLocaleText = D2LANG_GetLocaleText(AreaLocaleIds[pInfo->nLevelId]);
WToC(pLocaleText, nLevelName);
if(pInfo->nLevelId== pUnit->pAct->pMisc->dwStaffTombLevel)
{
strcat_s(nLevelName, sizeof(nLevelName), "ÿc2*");
}
if(pInfo->nLevelId== pUnit->pAct->pMisc->dwStaffTombLevel)
{
if(pInfo->nX==12508)
{
cfg.RealTombX=1;
}
if(pInfo->nX==12514)
{
cfg.RealTombX=2;
}
if(pInfo->nX==12513)
{
cfg.RealTombX=3;
}
if(pInfo->nX==12519)
{
cfg.RealTombX=4;
}
if(pInfo->nX==12617)
{
cfg.RealTombX=5;
}
if(pInfo->nX==12698)
{
cfg.RealTombX=6;
}
if(pInfo->nX==12779)
{
cfg.RealTombX=7;
}
}
if(cfg.LevelNames)
{
TextHook(pInfo->nX, pInfo->nY, 0, true, 6, 1, "%s", nLevelName);
}
}
}
}
BOOL IsValidMonster(UnitAny *pUnit)
{
if (!pUnit)
return false;
if ((pUnit->dwMode == 0) || (pUnit->dwMode == 12))
return false;
if ((pUnit->dwTxtFileNo >= 110) && (pUnit->dwTxtFileNo <= 113) || (pUnit->dwTxtFileNo == 608) && (pUnit->dwMode == 8))
return false;
if ((pUnit->dwTxtFileNo == 68) && (pUnit->dwMode == 14))
return false;
if (((pUnit->dwTxtFileNo == 258) || (pUnit->dwTxtFileNo == 261)) && (pUnit->dwMode == 14))
return false;
DWORD badMonIds[] = {227, 283, 326, 327, 328, 329, 330, 410, 411, 412, 413, 414, 415, 416, 366, 406,
351, 352, 353, 266, 408, 516, 517, 518, 519, 522, 523, 543, 543, 545, 574};
for (DWORD n = 0; n < ArraySize(badMonIds) - 1; n++)
{
if (pUnit->dwTxtFileNo == badMonIds[n])
return false;
}
if (D2COMMON_GetUnitStat(pUnit, 172, 0) == 2)
return false;
wchar_t* name = D2CLIENT_GetUnitName(pUnit);
char tmp[52];
WToC(name, tmp);
if ((strcmp(tmp,"an evil force") == 0) || (strcmp(tmp, "dummy") == 0))
return false;
return true;
}
DWORD __declspec(naked) __fastcall D2CLIENT_GetUnitName_STUB(DWORD UnitAny)
{
__asm
{
mov eax, ecx
jmp D2CLIENT_GetUnitName_I
}
}