-
Notifications
You must be signed in to change notification settings - Fork 23
/
NPCStruc.cs
337 lines (311 loc) · 13 KB
/
NPCStruc.cs
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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static EnumsMobsNPC;
using static System.Diagnostics.DebuggableAttribute;
public class NPCStruc
{
Form1 Form1_0;
public long NPCPointerLocation = 0;
public byte[] NPCdatastruc = new byte[144];
public uint txtFileNo = 0;
public long pPathPtr = 0;
public ushort itemx = 0;
public ushort itemy = 0;
public ushort xPosFinal = 0;
public ushort yPosFinal = 0;
public byte[] pPath = new byte[144];
public ushort xPosFinal_Overlay = 0;
public ushort yPosFinal_Overlay = 0;
public void SetForm1(Form1 form1_1)
{
Form1_0 = form1_1;
}
public List<int> NPC_IDs = new List<int>();
public List<int[]> GetAllNPCNearby()
{
Form1_0.PatternsScan_0.scanForUnitsPointer("NPC");
List<int[]> npcPositions2 = new List<int[]>();
NPC_IDs = new List<int>();
try
{
foreach (var ThisCurrentPointer in Form1_0.PatternsScan_0.AllNPCPointers)
{
NPCPointerLocation = ThisCurrentPointer.Key;
if (NPCPointerLocation > 0)
{
NPCdatastruc = new byte[144];
Form1_0.Mem_0.ReadRawMemory(NPCPointerLocation, ref NPCdatastruc, 144);
uint txtFileNoO = BitConverter.ToUInt32(NPCdatastruc, 4);
GetUnitPathDataOverlay();
if (getTownNPC((int)txtFileNoO) != ""
&& getTownNPC((int)txtFileNoO) != "DeadCorpse")
{
/*if (DebuggingMobs)
{
Form1_0.AppendTextDebugMobs("ID:" + txtFileNoO + "(" + Form1_0.NPCStruc_0.getNPC_ID((int)txtFileNoO) + ") at:" + xPosFinal + ", " + yPosFinal + " - HP:" + MobsHP + Environment.NewLine);
}*/
//Console.WriteLine("found near mob " + Form1_0.NPCStruc_0.getNPC_ID((int)txtFileNoO) + " at: " + xPosFinal + ", " + yPosFinal + " HP:" + MobsHP);
if (xPosFinal_Overlay != 0 && yPosFinal_Overlay != 0)
{
npcPositions2.Add(new int[2] { (int)xPosFinal_Overlay, (int)yPosFinal_Overlay });
NPC_IDs.Add((int)txtFileNoO);
}
}
}
}
}
catch
{
Form1_0.method_1("Couldn't 'GetAllNPCNearby()'", Color.OrangeRed);
}
return npcPositions2;
}
public void GetUnitPathDataOverlay()
{
pPathPtr = BitConverter.ToInt64(NPCdatastruc, 0x38);
//pPath = new byte[144];
pPath = new byte[0x08];
Form1_0.Mem_0.ReadRawMemory(pPathPtr, ref pPath, pPath.Length);
ushort itemx2 = BitConverter.ToUInt16(pPath, 0x02);
ushort itemy2 = BitConverter.ToUInt16(pPath, 0x06);
ushort xPosOffset = BitConverter.ToUInt16(pPath, 0x00);
ushort yPosOffset = BitConverter.ToUInt16(pPath, 0x04);
int xPosOffsetPercent = (xPosOffset / 65536); //get percentage
int yPosOffsetPercent = (yPosOffset / 65536); //get percentage
xPosFinal_Overlay = (ushort)(itemx2 + xPosOffsetPercent);
yPosFinal_Overlay = (ushort)(itemy2 + yPosOffsetPercent);
}
public bool GetNPC(string MobName)
{
try
{
txtFileNo = 0;
Form1_0.PatternsScan_0.scanForUnitsPointer("NPC");
foreach (var ThisCurrentPointer in Form1_0.PatternsScan_0.AllNPCPointers)
{
NPCPointerLocation = ThisCurrentPointer.Key;
if (NPCPointerLocation > 0)
{
NPCdatastruc = new byte[144];
Form1_0.Mem_0.ReadRawMemory(NPCPointerLocation, ref NPCdatastruc, 144);
txtFileNo = BitConverter.ToUInt32(NPCdatastruc, 4);
GetUnitPathData();
//Console.WriteLine((int)txtFileNo + " at: " + xPosFinal + ", " + yPosFinal);
if (Regex.Replace(((EnumsMobsNPC.MonsterType)((int)txtFileNo)).ToString(), @"[\d-]", string.Empty) == MobName)
{
if (xPosFinal != 0 && yPosFinal != 0)
{
return true;
}
}
}
}
}
catch
{
Form1_0.method_1("Couldn't 'GetNPC()'", Color.OrangeRed);
}
return false;
}
public void GetUnitPathData()
{
pPathPtr = BitConverter.ToInt64(NPCdatastruc, 0x38);
//pPath = new byte[144];
pPath = new byte[0x08];
Form1_0.Mem_0.ReadRawMemory(pPathPtr, ref pPath, pPath.Length);
itemx = BitConverter.ToUInt16(pPath, 0x02);
itemy = BitConverter.ToUInt16(pPath, 0x06);
ushort xPosOffset = BitConverter.ToUInt16(pPath, 0x00);
ushort yPosOffset = BitConverter.ToUInt16(pPath, 0x04);
int xPosOffsetPercent = (xPosOffset / 65536); //get percentage
int yPosOffsetPercent = (yPosOffset / 65536); //get percentage
xPosFinal = (ushort)(itemx + xPosOffsetPercent);
yPosFinal = (ushort)(itemy + yPosOffsetPercent);
//string SavePathh = Form1_0.ThisEndPath + "DumpItempPathStruc";
//File.Create(SavePathh).Dispose();
//File.WriteAllBytes(SavePathh, pPath);
}
public string getOthersNPC(int txtFileNo)
{
switch (txtFileNo)
{
case 146: return "DeckardCain";
case 244: return "DeckardCain";
case 245: return "DeckardCain";
case 246: return "DeckardCain";
case 251: return "Tyrael";
case 367: return "Tyrael";
case 521: return "Tyrael";
case 265: return "DeckardCain";
case 520: return "DeckardCain";
case 512: return "Anya";
case 527: return "Anya";
}
return "";
}
public string getTownNPC(int txtFileNo)
{
switch (txtFileNo)
{
case 146: return "DeckardCain";
case 154: return "Charsi";
case 147: return "Gheed";
//case 150: return "Kashya";
case 155: return "Warriv";
case 148: return "Akara";
case 244: return "DeckardCain";
case 210: return "Meshif";
case 175: return "Warriv";
case 199: return "Elzix";
case 198: return "Greiz";
case 177: return "Drognan";
case 178: return "Fara";
case 201: return "Jerhyn";
case 202: return "Lysander";
case 176: return "Atma";
case 200: return "Geglash";
case 331: return "Kaelan";
case 245: return "DeckardCain";
case 264: return "Meshif";
case 255: return "Ormus";
case 252: return "Asheara";
case 254: return "Alkor";
case 253: return "Hratli";
case 297: return "Natalya";
case 246: return "DeckardCain";
case 251: return "Tyrael";
case 338: return "DeadCorpse";
case 367: return "Tyrael";
case 521: return "Tyrael";
case 257: return "Halbu";
case 405: return "Jamella";
case 265: return "DeckardCain";
case 520: return "DeckardCain";
case 512: return "Anya";
case 527: return "Anya";
case 515: return "Qual-Kehk";
case 513: return "Malah";
case 511: return "Larzuk";
case 514: return "Nihlathak Town";
case 266: return "navi";
case 408: return "Malachai";
case 406: return "Izual";
case 803: return "Nihlatak";
}
return "";
}
// certain NPCs we don't want to see such as mercs
public int HideNPC(int txtFileNo)
{
switch (txtFileNo)
{
case 0: return 1; //UNKOWN
case 1: return 1; //Skeleton
case 3: return 1; //UNKOWN
//case 23: return 1; //WarpedFallen
case 149: return 1; //Chicken
case 150: return 1; //Kashya
case 151: return 1; //Rat
case 152: return 1; //Rogue
case 153: return 1; //HellMeteor
case 157: return 1; //Bird
case 158: return 1; //Bird2
case 159: return 1; //Bat
case 194: return 1; //Hadriel
case 195: return 1; //Act2Male
case 196: return 1; //Act2Female
case 197: return 1; //Act2Child
case 179: return 1; //Cow
case 185: return 1; //Camel
case 203: return 1; //Act2Guard
case 204: return 1; //Act2Vendor
case 205: return 1; //Act2Vendor2
case 227: return 1; //Maggot
case 268: return 1; //Bug
case 269: return 1; //Scorpion
// case 271: return 1; //Rogue2
case 272: return 1; //Rogue3
case 283: return 1; //Larva
case 293: return 1; //Familiar
case 294: return 1; //Act3Male
case 289: return 1; //ClayGolem
case 290: return 1; //BloodGolem
case 291: return 1; //IronGolem
case 292: return 1; //FireGolem
case 296: return 1; //Act3Female
case 318: return 1; //Snake
case 319: return 1; //Parrot
case 320: return 1; //Fish
case 321: return 1; //EvilHole
case 322: return 1; //EvilHole2
case 323: return 1; //EvilHole3
case 324: return 1; //EvilHole4
case 325: return 1; //EvilHole5
case 326: return 1; //FireboltTrap
case 327: return 1; //HorzMissileTrap
case 328: return 1; //VertMissileTrap
case 329: return 1; //PoisonCloudTrap
case 330: return 1; //LightningTrap
case 332: return 1; //InvisoSpawner
// case 338: return 1; //Guard or DEAD BODY!!!
case 339: return 1; //MiniSpider
case 344: return 1; //BoneWall
case 351: return 1; //Hydra
case 352: return 1; //Hydra2
case 353: return 1; //Hydra3
case 355: return 1; //SevenTombs
case 356: return 1; //??
case 357: return 1; //Valkyrie
case 359: return 1; //IronWolf
case 363: return 1; //NecroSkeleton
case 364: return 1; //NecroMage
case 366: return 1; //CompellingOrb},
case 370: return 1; //SpiritMummy
case 377: return 1; //Act2Guard4
case 378: return 1; //Act2Guard5
case 392: return 1; //Window
case 393: return 1; //Window2
case 401: return 1; //MephistoSpirit
case 410: return 1; //WakeOfDestruction
case 411: return 1; //ChargedBoltSentry
case 412: return 1; //LightningSentry
case 413: return 1; //LightningSentry
case 414: return 1; //InvisiblePet
case 415: return 1; //InfernoSentry
case 416: return 1; //DeathSentry
case 417: return 1; //ShadowWarrior
case 418: return 1; //ShadowMaster
case 419: return 1; //DruidHawk
case 420: return 1; //DruidSpiritWolf
case 421: return 1; //DruidFenris
case 422: return 1; //spiritofbarbs heartofwolverine
case 423: return 1; //HeartOfWolverine
case 424: return 1; //OakSage
case 425: return 1; //Druid Plague Poppy
case 426: return 1; //Druid Cycle of Life
case 427: return 1; //Druid Something
case 428: return 1; //DruidBear
case 430: return 1; //Necro Wolf
case 431: return 1; //Necro Bear
case 543: return 1; //BaalThrone
case 559: return 1; //Baal Crab at portal
case 562: return 1; //Baal spawned legs on ground
case 563: return 1; //Baal spawned legs on ground
case 564: return 1; //Baal spawned legs on ground
case 565: return 1; //BaalThrone Something...
case 566: return 1; //Baal spawned legs on ground
case 567: return 1; //InjuredBarbarian
case 568: return 1; //InjuredBarbarian2
case 569: return 1; //InjuredBarbarian3
case 570: return 1; //Baalclone
case 574: return 1; //BaalThrone Something...
case 711: return 1; //DemonHole
}
return 0;
}
}