Kernel_bin.Devour.cs 3.1 KB

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