/// <summary> /// 暂存当前标点 /// </summary> public void SaveWaymark() { tempMarks = new WayMarks(); Waymark ReadWaymark(IntPtr addr, WaymarkID id) => new() { X = Memory.Read <float>(addr), Y = Memory.Read <float>(addr + 0x4), Z = Memory.Read <float>(addr + 0x8), Active = Memory.Read <byte>(addr + 0x1C) == 1, ID = id }; try { tempMarks.A = ReadWaymark(Waymarks + 0x00, WaymarkID.A); tempMarks.B = ReadWaymark(Waymarks + 0x20, WaymarkID.B); tempMarks.C = ReadWaymark(Waymarks + 0x40, WaymarkID.C); tempMarks.D = ReadWaymark(Waymarks + 0x60, WaymarkID.D); tempMarks.One = ReadWaymark(Waymarks + 0x80, WaymarkID.One); tempMarks.Two = ReadWaymark(Waymarks + 0xA0, WaymarkID.Two); tempMarks.Three = ReadWaymark(Waymarks + 0xC0, WaymarkID.Three); tempMarks.Four = ReadWaymark(Waymarks + 0xE0, WaymarkID.Four); PluginUI.Log("暂存当前标点"); } catch (Exception ex) { throw new Exception("保存标记错误:" + ex.Message); } }
private void DoMarkingByActorID(uint ActorID, MarkType markingType, bool localOnly = false) { var combatant = FFXIV_ACT_Plugin.DataRepository.GetCombatantList().FirstOrDefault(i => i.ID == ActorID); if (combatant == null) { throw new Exception($"未能找到{ActorID}"); } PluginUI.Log($"ActorID={ActorID:X},markingType={(int)markingType},LocalOnly={localOnly}"); var assemblyLock = Memory.Executor.AssemblyLock; var flag = false; try { Monitor.Enter(assemblyLock, ref flag); if (!localOnly) { _ = Memory.CallInjected64 <char>(MarkingFunc, MarkingController, markingType, ActorID); } else //本地标点的markingType从0开始,因此需要-1 { _ = Memory.CallInjected64 <char>(LocalMarkingFunc, MarkingController, markingType - 1, ActorID, 0); } } finally { if (flag) { Monitor.Exit(assemblyLock); } } }
public void DoWaymarks(string waymarksStr) { if (!isReady) { PluginUI.Log("执行错误:接收到指令,但是没有对应的游戏进程"); throw new Exception("没有对应的游戏进程"); } if (waymarksStr == "") { throw new Exception("指令为空"); } switch (waymarksStr.ToLower()) { case "save": case "backup": SaveWaymark(); break; case "load": case "restore": LoadWaymark(); break; default: var waymarks = JsonConvert.DeserializeObject <WayMarks>(waymarksStr); PluginUI.Log(waymarksStr); DoWaymarks(waymarks); break; } }
/// <summary> /// 恢复暂存标点 /// </summary> public void LoadWaymark() { if (tempMarks == null) { return; } DoWaymarks(tempMarks); PluginUI.Log("恢复暂存标点"); }
public void DoTextCommand(string command) { if (!isReady) { PluginUI.Log("执行错误:接收到指令,但是没有对应的游戏进程"); throw new Exception("没有对应的游戏进程"); } if (command == "") { throw new Exception("指令为空"); } PluginUI.Log(command); var assemblyLock = Memory.Executor.AssemblyLock; var flag = false; try { Monitor.Enter(assemblyLock, ref flag); var array = Encoding.UTF8.GetBytes(command); using AllocatedMemory allocatedMemory = Memory.CreateAllocatedMemory(400), allocatedMemory2 = Memory.CreateAllocatedMemory(array.Length + 30); allocatedMemory2.AllocateOfChunk("cmd", array.Length); allocatedMemory2.WriteBytes("cmd", array); allocatedMemory.AllocateOfChunk <IntPtr>("cmdAddress"); allocatedMemory.AllocateOfChunk <long>("t1"); allocatedMemory.AllocateOfChunk <long>("tLength"); allocatedMemory.AllocateOfChunk <long>("t3"); allocatedMemory.Write("cmdAddress", allocatedMemory2.Address); allocatedMemory.Write("t1", 0x40); allocatedMemory.Write("tLength", array.Length + 1); allocatedMemory.Write("t3", 0x00); _ = Memory.CallInjected64 <int>(ProcessChatBoxPtr, RaptureModule, allocatedMemory.Address, UiModule); } finally { if (flag) { Monitor.Exit(assemblyLock); } } }
public void DoSendKey(string command) { if (!isReady) { PluginUI.Log("执行错误:接收到指令,但是没有对应的游戏进程"); throw new Exception("没有对应的游戏进程"); } if (command == "") { throw new Exception("指令为空"); } Log($"收到按键:{command}"); try { var keycode = int.Parse(command); SendKeycode(keycode); } catch (Exception ex) { throw new Exception($"发送按键失败:{ex}"); } }
public void DoMarking(string command) { if (!isReady) { PluginUI.Log("执行错误:接收到指令,但是没有对应的游戏进程"); throw new Exception("没有对应的游戏进程"); } if (command == "") { throw new Exception("指令为空"); } var mark = JsonConvert.DeserializeObject <Marking>(command); if (mark?.MarkType == null) { throw new Exception("标记错误"); } uint actorID = 0xE000000; actorID = mark.ActorID ?? GetActorIDByName(mark.Name); DoMarkingByActorID(actorID, mark.MarkType.Value, mark.LocalOnly); }