Kernel_bin.Devour.cs 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. using System.IO;
  2. namespace FF8
  3. {
  4. public partial class Kernel_bin
  5. {
  6. /// <summary>
  7. /// Devour Data
  8. /// </summary>
  9. /// <see cref="https://github.com/alexfilth/doomtrain/wiki/Devour"/>
  10. public class Devour
  11. {
  12. public const int count = 16;
  13. public const int id = 28;
  14. public const int size = 12;
  15. public override string ToString() => Description;
  16. public FF8String Description { get; private set; }
  17. public float Amount { get; private set; }
  18. /// <summary>
  19. /// True for heal, False for damage
  20. /// </summary>
  21. public bool DMGorHEAL { get; private set; }
  22. public Statuses1 Statuses1 { get; private set; }
  23. public Statuses0 Statuses0 { get; private set; }
  24. private StatFlags StatFlags { get; set; }
  25. public byte HP { get; private set; }
  26. public void Read(BinaryReader br, int i)
  27. {
  28. Description = Memory.Strings.Read(Strings.FileID.KERNEL, id, i);
  29. br.BaseStream.Seek(2, SeekOrigin.Current);
  30. //0x0000 2 bytes Offset to devour description
  31. DMGorHEAL = br.ReadByte() == 0x1E ? true : false;
  32. //0x0002 1 byte Damage or heal HP and Status
  33. //0x1E - Cure
  34. //0x1F - Damage
  35. Quanity val = (Quanity)br.ReadByte();
  36. Amount = 0f;
  37. if ((val & Quanity._0625f) != 0) Amount += .0625f;
  38. if ((val & Quanity._1250f) != 0) Amount += .1250f;
  39. if ((val & Quanity._1f) != 0) Amount += 1f;
  40. if ((val & Quanity._25f) != 0) Amount += .25f;
  41. if ((val & Quanity._50f) != 0) Amount += .50f;
  42. //0x0003 1 byte HP Heal / DMG Quantity Flag
  43. //0x00 - 0 %
  44. //0x01 - 6.25 %
  45. //0x02 - 12.50 %
  46. //0x04 - 25 %
  47. //0x08 - 50 %
  48. //0x10 - 100 %
  49. Statuses1 = (Statuses1)br.ReadUInt32();
  50. //0x0004 4 bytes status_1; //statuses 8-39
  51. Statuses0 = (Statuses0)br.ReadUInt16();
  52. //0x0008 2 bytes status_0; //statuses 0-7
  53. StatFlags = (StatFlags)br.ReadByte();
  54. //0x000A 1 byte Raised Stat Flag
  55. //0x00 - None
  56. //0x01 - STR
  57. //0x02 - VIT
  58. //0x04 - MAG
  59. //0x08 - SPR
  60. //0x10 - SPD
  61. HP = br.ReadByte();
  62. //0x000B 1 byte Raised Stat HP Quantity
  63. }
  64. public static Devour[] Read(BinaryReader br)
  65. {
  66. var ret = new Devour[count];
  67. for (int i = 0; i < count; i++)
  68. {
  69. var tmp = new Devour();
  70. tmp.Read(br, i);
  71. ret[i] = tmp;
  72. }
  73. return ret;
  74. }
  75. }
  76. }
  77. }