public void DisplayEnemyHP() { int maxHP = 0; EnemyInfo maxPointer = null; if (lastCheck.AddSeconds(1) < DateTime.Now) { lastCheck = DateTime.Now; List <EnemyInfo> enemies = Memory.GetEnemyInfo(); foreach (EnemyInfo info in enemies) { if (enemyInfo.Add(info)) { if (info.HP > maxHP && info.HP > 100 && info.HP != 999) { maxHP = info.HP; maxPointer = info; } } } } int oldHP = 0; foreach (EnemyInfo info in enemyInfo) { oldHP = info.UpdateHP(Memory.Program); if (oldHP != info.HP && info.HP < 5000 && info.HP > 0) { currentEnemy = info; changed = true; break; } } if (maxHP > 0 && maxHP < 5000) { currentEnemy = maxPointer; changed = true; } if (changed) { if (chkEnemyInvincible.Checked && currentEnemy.HP > 0) { currentEnemy.UpdateHP(Memory.Program, oldHP); } Memory.UpdateGeoCounter(true, currentEnemy.HP < 0 ? 0 : currentEnemy.HP); changed = false; } }
public List <EnemyInfo> GetEnemyInfo() { List <EnemyInfo> enemies = new List <EnemyInfo>(); int size = playmakerFSM.Read <int>(Program, 0x0, 0xc); IntPtr basePointer = (IntPtr)playmakerFSM.Read <uint>(Program, 0x0, 0x8); for (int x = 0; x < size; x++) { IntPtr fsmPtr = (IntPtr)Program.Read <uint>(basePointer, 0x10 + x * 4, 0xc); if (fsmPtr == IntPtr.Zero) { continue; } int fsmLength = Program.Read <int>(fsmPtr, 0x14, 0x8); byte fsmChar = Program.Read <byte>(fsmPtr, 0x14, 0xc); if (fsmLength != 20 || fsmChar != (byte)'h') { continue; } EnemyInfo info = new EnemyInfo(); info.Pointer = Program.Read <uint>(fsmPtr, 0x28, 0xc); int infoSize = Program.Read <int>((IntPtr)info.Pointer, 0xc); if (infoSize == 0) { continue; } info.HPIndex = -1; for (int i = 0; i < infoSize; i++) { fsmLength = Program.Read <int>((IntPtr)info.Pointer, 0x10 + i * 4, 0x8, 0x8); fsmChar = Program.Read <byte>((IntPtr)info.Pointer, 0x10 + i * 4, 0x8, 0xc); if (fsmLength != 2 || fsmChar != (byte)'H') { continue; } info.HPIndex = i; info.HP = Program.Read <int>((IntPtr)info.Pointer, 0x10 + i * 4, 0x14); } if (info.HPIndex >= 0) { enemies.Add(info); } } return(enemies); }