9
3

Skills.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /*
  2. EQ2Emulator: Everquest II Server Emulator
  3. Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
  4. This file is part of EQ2Emulator.
  5. EQ2Emulator 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 3 of the License, or
  8. (at your option) any later version.
  9. EQ2Emulator 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. You should have received a copy of the GNU General Public License
  14. along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #ifndef __EQ2_SKILLS_H__
  17. #define __EQ2_SKILLS_H__
  18. #include <map>
  19. #include "../common/ConfigReader.h"
  20. #include "../common/types.h"
  21. #include "MutexMap.h"
  22. #define SKILL_TYPE_COMBAT 1
  23. #define SKILL_TYPE_SPELLCASTING 2
  24. #define SKILL_TYPE_AVOIDANCE 3
  25. #define SKILL_TYPE_HARVESTING 6
  26. #define SKILL_TYPE_ARTISAN 7
  27. #define SKILL_TYPE_CRAFTSMAN 8
  28. #define SKILL_TYPE_OUTFITTER 9
  29. #define SKILL_TYPE_SCHOLAR 10
  30. #define SKILL_TYPE_GENERAL 12
  31. #define SKILL_ID_SCULPTING 1039865549
  32. #define SKILL_ID_FLETCHING 3076004370
  33. #define SKILL_ID_ARTISTRY 3881305672
  34. #define SKILL_ID_TAILORING 2082133324
  35. #define SKILL_ID_METALSHAPING 3108933728
  36. #define SKILL_ID_METALWORKING 4032608519
  37. #define SKILL_ID_SCRIBING 773137566
  38. #define SKILL_ID_CHEMISTRY 2557647574
  39. #define SKILL_ID_ARTIFICING 3330500131
  40. /* Each SkillBonus is comprised of multiple possible skill bonus values. This is so one spell can modify
  41. more than one skill */
  42. struct SkillBonusValue {
  43. int32 skill_id;
  44. float value;
  45. };
  46. struct SkillBonus {
  47. int32 spell_id;
  48. map<int32, SkillBonusValue*> skills;
  49. };
  50. class Skill{
  51. public:
  52. Skill();
  53. Skill(Skill* skill);
  54. int32 skill_id;
  55. int16 current_val;
  56. int16 previous_val;
  57. int16 max_val;
  58. int32 skill_type;
  59. int8 display;
  60. EQ2_16BitString short_name;
  61. EQ2_16BitString name;
  62. EQ2_16BitString description;
  63. bool save_needed;
  64. int CheckDisarmSkill(int16 targetLevel, int8 chest_difficulty=0);
  65. };
  66. class MasterSkillList{
  67. public:
  68. MasterSkillList();
  69. ~MasterSkillList();
  70. void AddSkill(Skill* skill);
  71. int16 GetSkillCount();
  72. EQ2Packet* GetPopulateSkillsPacket(int16 version);
  73. map<int32, Skill*>* GetAllSkills();
  74. Skill* GetSkill(int32 skill_id);
  75. Skill* GetSkillByName(const char* skill_name);
  76. private:
  77. map<int32, Skill*> skills;
  78. map<int16, EQ2Packet*> populate_packets;
  79. };
  80. class PlayerSkillList{
  81. public:
  82. PlayerSkillList();
  83. ~PlayerSkillList();
  84. void RemoveSkill(Skill* skill);
  85. void AddSkill(Skill* new_skill);
  86. bool CheckSkillIncrease(Skill* skill);
  87. Skill* GetSkillByName(const char* name);
  88. bool HasSkill(int32 skill_id);
  89. Skill* GetSkill(int32 skill_id);
  90. void IncreaseSkill(Skill* skill, int16 amount);
  91. void IncreaseSkill(int32 skill_id, int16 amount);
  92. void DecreaseSkill(Skill* skill, int16 amount);
  93. void DecreaseSkill(int32 skill_id, int16 amount);
  94. void SetSkill(Skill* skill, int16 value);
  95. void SetSkill(int32 skill_id, int16 value);
  96. void IncreaseSkillCap(Skill* skill, int16 amount);
  97. void IncreaseSkillCap(int32 skill_id, int16 amount);
  98. void DecreaseSkillCap(Skill* skill, int16 amount);
  99. void DecreaseSkillCap(int32 skill_id, int16 amount);
  100. void SetSkillCap(Skill* skill, int16 value);
  101. void SetSkillCap(int32 skill_id, int16 value);
  102. void IncreaseAllSkillCaps(int16 value);
  103. void IncreaseSkillCapsByType(int8 type, int16 value);
  104. void SetSkillCapsByType(int8 type, int16 value);
  105. void AddSkillUpdateNeeded(Skill* skill);
  106. void AddSkillBonus(int32 spell_id, int32 skill_id, float value);
  107. SkillBonus* GetSkillBonus(int32 spell_id);
  108. void RemoveSkillBonus(int32 spell_id);
  109. int16 CalculateSkillValue(int32 skill_id, int16 current_val);
  110. int16 CalculateSkillMaxValue(int32 skill_id, int16 max_val);
  111. EQ2Packet* GetSkillPacket(int16 version);
  112. vector<Skill*>* GetSaveNeededSkills();
  113. vector<Skill*>* GetSkillUpdates();
  114. map<int32, Skill*>* GetAllSkills();
  115. bool HasSkillUpdates();
  116. private:
  117. volatile bool has_updates;
  118. Mutex MSkillUpdates;
  119. int16 packet_count;
  120. uchar* orig_packet;
  121. int16 orig_packet_size;
  122. uchar* xor_packet;
  123. map<int32, Skill*> skills;
  124. map<string, Skill*> name_skill_map;
  125. vector<Skill*> skill_updates;
  126. MutexMap<int32, SkillBonus*> skill_bonus_list;
  127. };
  128. #endif