SkillFunction.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using Mir2Assistant.Common.Models;
  2. using Mir2Assistant.Utils;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Security.Cryptography;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace Mir2Assistant.Common.Functions;
  10. /// <summary>
  11. /// 技能
  12. /// </summary>
  13. public static class SkillFunction
  14. {
  15. /// <summary>
  16. /// 读取角色技能列表
  17. /// </summary>
  18. /// <param name="gameInstance"></param>
  19. public static void ReadSkills(MirGameInstanceModel gameInstance)
  20. {
  21. Task.Run(() =>
  22. {
  23. bool isXF = false;
  24. gameInstance.Skills.Clear();
  25. var memoryUtils = gameInstance!.MemoryUtils!;
  26. var addr = memoryUtils.GetMemoryAddress(gameInstance.MirConfig["技能基址"], 0x4, 0);
  27. while (memoryUtils.ReadToInt(addr) != 0)
  28. {
  29. var length = (byte)memoryUtils.ReadToChar(memoryUtils.GetMemoryAddress(addr, 0));
  30. if (length <= 0 || length > 12)
  31. {
  32. break;
  33. }
  34. var skill = new SkillModel
  35. {
  36. Addr = memoryUtils.ReadToInt(addr),
  37. Length = length,
  38. Name = memoryUtils.ReadToString(memoryUtils.GetMemoryAddress(addr, 1), length),
  39. Type = (byte)memoryUtils.ReadToChar(memoryUtils.GetMemoryAddress(addr, 15)),
  40. };
  41. if(!isXF && skill.Type == 4)
  42. {
  43. skill.IsXF = true;
  44. isXF = true;
  45. }
  46. gameInstance.Skills.Add(skill);
  47. addr += 4;
  48. }
  49. });
  50. }
  51. /// <summary>
  52. /// 技能CAll
  53. /// </summary>
  54. public static void SkillCall(MirGameInstanceModel gameInstance, int skillAddr)
  55. {
  56. SendMirCall.Send(gameInstance, 2001, [skillAddr, gameInstance!.MirConfig["技能CALL地址"]]);
  57. }
  58. }