【クラスPCとは】
- FFACE非依存で、MP、HPなどを取得するクラスです。rcm氏のXIACEの別ソリューションです。
- SendTextをメソッドに取り込む等直感的に記述できるようにしてます。
【ソース】
- public unsafe class PC
- {
- public int HP, MP, TP, HPP, MPP, area, status;
- public bool fighting;
-
- [System.Runtime.InteropServices.DllImport("kernel32.dll")]
- private extern static IntPtr OpenProcess(uint dwDesiredAccess, bool bInheritHandle, int dwProcessId);
-
- //win32api CloseHandle用
- [System.Runtime.InteropServices.DllImport("kernel32.dll")]
- private extern static bool CloseHandle(IntPtr hObject);
-
- //win32api ReadProcessMemory用
- [System.Runtime.InteropServices.DllImport("kernel32.dll")]
- private extern static bool ReadProcessMemory(IntPtr hProcess, int lpBaseAddress, void* lpBuffer, int nSize, int* lpNumberOfBytesRead);
-
-
- public IntPtr handle = (IntPtr)null;
- public int baseaddr = 0;
- Windower.MainFunctions w;
-
- public PC(Process p, Windower.MainFunctions warg)
- {
- w = warg;
-
- foreach (ProcessModule m in p.Modules)
- {
- if (m.ModuleName == "FFXiMain.dll")
- {
- baseaddr = m.BaseAddress.ToInt32();
- break;
- }
- }
- const int PROCESS_ALL_ACCESS = 0x1F0FFF;
- handle = OpenProcess(PROCESS_ALL_ACCESS, false, p.Id);
-
-
- }
-
- public void Do(string command, double waitsec)
- {
- int milisec = (int)waitsec * 1000;
- w.SendText(command);
- Thread.Sleep(milisec);
- }
-
- public void Do(string command)
- {
- Do(command, 0.1);
- }
-
- public void update()
- {
- HpMpStruct HpMpTp = new HpMpStruct();
- ReadProcessMemory(handle, baseaddr + 0x8ccb6c
- , &HpMpTp, Marshal.SizeOf(HpMpTp), null);
- byte[] charaNameBuff = new byte[20];
- for (int i = 0; i < 20; i++)
- {
- charaNameBuff[i] = HpMpTp.name[i];
- if (HpMpTp.name[i] == 0) break;
- }
- string charName = Encoding.Default.GetString(charaNameBuff).Replace("\0", "");
-
- HP = HpMpTp.HP;
- MP = HpMpTp.MP;
- TP = HpMpTp.TP;
- HPP = HpMpTp.HPP;
- MPP = HpMpTp.MPP;
- area = HpMpTp.area;
-
- byte bstatus;
- ReadProcessMemory(handle, baseaddr + 0x536790
- , &bstatus, 1, null);
- status = bstatus;
-
- fighting = false;
- if (1 == status) fighting = true;
-
- }
-
- unsafe struct HpMpStruct
- {
- internal fixed byte name[20];
- internal fixed byte dummy[12];
- internal int HP;
- internal int MP;
- internal int TP ;
- internal byte HPP;
- internal byte MPP;
- internal byte area;
- }
-
-
- public bool Icon(int se)
- {
- int IconAddr = 0;
- ReadProcessMemory(handle, baseaddr + 0x57d57c, &IconAddr, 4, null);
-
- IconStruct icons = new IconStruct();
- ReadProcessMemory(handle, IconAddr + 644, &icons, Marshal.SizeOf(icons), null);
-
- for (Byte i = 0; i < icons.Count; i++)
- {
- if (icons.IconArray[i] == se) return true;
- }
- return false;
- }
-
- public bool Icon(i se)
- {
- return Icon((int)se);
- }
-
-
- internal unsafe struct IconStruct
- {
- internal fixed short IconArray[32];
- internal fixed byte SelfCut[32];
- internal fixed byte unkown[4];
- internal short Count;
- }
-
-
-
- }
-
- public enum i : short
- {
- KO = 0,
- Weakness = 1,
- Sleep = 2,
- Poison = 3,
- Paralysis = 4,
- Blindness = 5,
- Silence = 6,
- <以下略>
- }
-