Kernel_bin.Command_abilities.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using System.Collections.Generic;
  2. using System.IO;
  3. namespace FF8
  4. {
  5. public partial class Kernel_bin
  6. {
  7. /// <summary>
  8. /// Command Abilities
  9. /// </summary>
  10. /// <see cref="https://github.com/alexfilth/doomtrain/wiki/Command-abilities"/>
  11. public class Command_abilities : Ability
  12. {
  13. public new const int count = 19;
  14. public new const int id = 12;
  15. public Icons.ID icon { get; protected set; } = Icons.ID.Ability_Command;
  16. public byte Index { get; private set; }
  17. public byte[] Unknown0 { get; private set; }
  18. public Battle_Commands BattleCommand { get; set; }
  19. private Dictionary<int, int> convert = new Dictionary<int, int>
  20. {
  21. {0,2},
  22. {1,3},
  23. {2,6},
  24. {3,4},
  25. {4,0},
  26. {5,29},
  27. {6,30},
  28. {7,24},
  29. {8,25},
  30. {9,23},
  31. {10,28},
  32. {11,26},
  33. {12,32},
  34. {13,27},
  35. {14,33},
  36. {15,34},
  37. {16,31},
  38. {17,7},
  39. {18,38},
  40. };
  41. public override void Read(BinaryReader br, int i)
  42. {
  43. if(convert.ContainsKey(i))
  44. BattleCommand = BattleCommands[convert[i]];
  45. Name = Memory.Strings.Read(Strings.FileID.KERNEL, id, i * 2);
  46. //0x0000 2 bytes Offset to name
  47. Description = Memory.Strings.Read(Strings.FileID.KERNEL, id, i * 2 + 1);
  48. //0x0002 2 bytes Offset to description
  49. AP = br.ReadByte();
  50. //0x0004 1 byte AP Required to learn ability
  51. Index = br.ReadByte();
  52. //0x0005 1 byte Index to Battle commands
  53. Unknown0 = br.ReadBytes(2);
  54. //0x0006 2 bytes Unknown/ Unused
  55. }
  56. public static Dictionary<Abilities,Command_abilities> Read(BinaryReader br)
  57. {
  58. Dictionary<Abilities, Command_abilities> ret = new Dictionary<Abilities, Command_abilities>(count);
  59. for (int i = 0; i < count; i++)
  60. {
  61. var tmp = new Command_abilities();
  62. tmp.Read(br, i);
  63. ret[(Abilities)(i+ (int)Abilities.Magic)] = tmp;
  64. }
  65. return ret;
  66. }
  67. }
  68. }
  69. }