private List<Monster> MonsterList()
{
List<Monster> monsterList = new List<Monster>();
API.ReadProcessMemory(openprocess, EnvBase + EnvMonsterOffset, out EnvMonsterBase, 4, 0);//获取周围怪物基址
API.ReadProcessMemory(openprocess, EnvMonsterBase + EnvMonsterNumOffset, out EnvMonsterNum, 4, 0);//获取怪物数目
API.ReadProcessMemory(openprocess, EnvMonsterBase + EnvMonsterListFirstOffset, out EnvMonsterListFirst, 4, 0);//获取怪物列表首地址
for (int i = 0; i < EnvMonsterNum; i++)
{
Monster monster = new Monster();
API.ReadProcessMemory(openprocess, EnvMonsterListFirst + (MonsterBaseOffset * i), out MonsterBase, 4, 0);
if (MonsterBase>0)
{
API.ReadProcessMemory(openprocess, MonsterBase + MonsterInfoOffset, out MonsterInfo, 4, 0);
API.ReadProcessMemory(openprocess, MonsterInfo + MonsterIDOffset, out MonsterID, 4, 0);
API.ReadProcessMemory(openprocess, MonsterInfo + MonsterHPOffset, out MonsterHP, 4, 0);
API.ReadProcessMemory(openprocess, MonsterInfo + MonsterMaxHPOffset + MonsterMaxHPSecondOffset, out MonsterMaxHP, 4, 0);
API.ReadProcessMemory(openprocess, MonsterInfo + MonsterGradeOffset, out MonsterGrade, 4, 0);
//API.ReadProcessMemory(openprocess, MonsterInfo + MonsterDistanceOffset, out MonsterDistance, 4, 0);
API.ReadProcessMemory(openprocess, MonsterInfo + MonsterClassOffset, out MonsterClass, 4, 0);
API.ReadProcessMemory(openprocess, MonsterInfo + MonsterXOffset, out MonsterX, 4, 0);
API.ReadProcessMemory(openprocess, MonsterInfo + MonsterYOffset, out MonsterY, 4, 0);
API.ReadProcessMemory(openprocess, MonsterInfo + MonsterZOffset, out MonsterZ, 4, 0);
API.ReadProcessMemory(openprocess, MonsterInfo + MonsterNameFirstOffset, out MonsterNameFirst, 4, 0);
API.ReadProcessMemory(openprocess, MonsterInfo + MonsterStatusOffset + MonsterStatusSecondOffset, out MonsterStatus, 4, 0);
API.ReadProcessMemory(openprocess, MonsterNameFirst, out MonsterNameByte[0], 64, 0);
monster.MonsterBase = MonsterBase;
monster.MonsterClass = MonsterClass;
//此处换成人与怪的距离
//monster.MonsterDistance = MonsterDistance.ToString();
//怪物真正的坐标
MonsterX = (int)(MonsterX / 10) + 400;
MonsterY = (int)(MonsterY / 10) + 550;
MonsterZ = (int)(MonsterZ / 10);
Person person = this.GetPerson();
int XX = (int)Math.Abs(person.PersonX - MonsterX);
int YY = (int)Math.Abs(person.PersonY - MonsterY);
int ZZ = (int)Math.Abs(person.PersonZ - MonsterZ);
int Distance = (int)Math.Sqrt(XX * XX + YY * YY + ZZ * ZZ);
monster.MonsterDistance = Distance;
monster.MonsterGrade = MonsterGrade;
monster.MonsterHP = MonsterHP;
monster.MonsterID = MonsterID;
monster.MonsterMaxHP = MonsterMaxHP;
//monster.MonsterName = MonsterNameByte.ToString();
monster.MonsterName = Encoding.Unicode.GetString(MonsterNameByte);
monster.MonsterX = (int)MonsterX;
monster.MonsterY = (int)MonsterY;
monster.MonsterZ = (int)MonsterZ;
monster.MonsterStatus = MonsterStatus;
monsterList.Add(monster);
}
}
return monsterList;
}