Clone of Bael'Zharon's Respite @ https://github.com/boardwalk/bzr

SkillTable.cpp 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * Bael'Zharon's Respite
  3. * Copyright (C) 2014 Daniel Skorupski
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along
  15. * with this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  17. */
  18. #include "resource/SkillTable.h"
  19. #include "BinReader.h"
  20. #include "Core.h"
  21. #include "DatFile.h"
  22. SkillTable::SkillTable()
  23. {
  24. vector<uint8_t> data = Core::get().portalDat().read(0x0e000004);
  25. BinReader reader(data.data(), data.size());
  26. uint32_t resourceId = reader.readInt();
  27. assert(resourceId == 0x0e000004);
  28. UNUSED(resourceId);
  29. uint16_t numSkills = reader.readShort();
  30. uint16_t unk1 = reader.readShort();
  31. assert(unk1 == 0x20);
  32. UNUSED(unk1);
  33. for(uint16_t i = 0; i < numSkills; i++)
  34. {
  35. uint32_t id = reader.readInt();
  36. Skill& skill = skills_[id];
  37. skill.description = reader.readString();
  38. skill.name = reader.readString();
  39. skill.icon = reader.readInt();
  40. assert((skill.icon & 0xFF000000) == 0x06000000);
  41. skill.trainCost = reader.readInt();
  42. skill.specCost = reader.readInt();
  43. skill.category = (SkillCategory::Value)reader.readInt();
  44. uint32_t unk2 = reader.readInt();
  45. assert(unk2 == 1);
  46. UNUSED(unk2);
  47. uint32_t charGenUse = reader.readInt();
  48. assert(charGenUse == 1 || charGenUse == 2);
  49. skill.usableUntrained = (charGenUse == 1);
  50. uint32_t minLevel = reader.readInt();
  51. assert(minLevel == 0);
  52. UNUSED(minLevel);
  53. uint32_t hasAttrib1 = reader.readInt();
  54. assert(hasAttrib1 == 0 || hasAttrib1 == 1);
  55. UNUSED(hasAttrib1);
  56. uint32_t hasAttrib2 = reader.readInt();
  57. assert(hasAttrib2 == 0 || hasAttrib2 == 1);
  58. UNUSED(hasAttrib2);
  59. skill.attribDivisor = reader.readInt();
  60. skill.attrib1 = (AttributeType::Value)reader.readInt();
  61. skill.attrib2 = (AttributeType::Value)reader.readInt();
  62. /*double upperBound = */reader.readDouble();
  63. /*double lowerBound = */reader.readDouble();
  64. double learnMod = reader.readDouble();
  65. assert(learnMod == 1.0);
  66. UNUSED(learnMod);
  67. }
  68. assert(reader.remaining() == 0);
  69. }