Traits.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 __Traits__
  17. #define __Traits__
  18. #include <vector>
  19. #include <map>
  20. #include "../../common/Mutex.h"
  21. #include "../../common/types.h"
  22. #include "../../common/EQPacket.h"
  23. class Client;
  24. struct TraitData
  25. {
  26. int32 spellID;
  27. int8 level;
  28. int8 classReq;
  29. int8 raceReq;
  30. bool isTrait;
  31. bool isInate;
  32. bool isFocusEffect;
  33. bool isTraining;
  34. int8 tier;
  35. int8 group;
  36. int32 item_id;
  37. };
  38. #define TRAITS_ATTRIBUTES 0
  39. #define TRAITS_COMBAT 1
  40. #define TRAITS_NONCOMBAT 2
  41. #define TRAITS_POOLS 3
  42. #define TRAITS_RESIST 4
  43. #define TRAITS_TRADESKILL 5
  44. class MasterTraitList
  45. {
  46. public:
  47. MasterTraitList();
  48. ~MasterTraitList();
  49. bool IdentifyNextTrait(Client* client, map <int8, vector<TraitData*> >* traitList, vector<TraitData*>* collectTraits, vector<TraitData*>* tieredTraits, std::map<int32, int8>* previousMatchedSpells, bool omitFoundMatches = false);
  50. bool ChooseNextTrait(Client* client);
  51. int16 GetSpellCount(Client* client, map <int8, vector<TraitData*> >* traits, bool onlyCharTraits = false);
  52. bool IsPlayerAllowedTrait(Client* client, TraitData* trait);
  53. bool GenerateTraitLists(Client* client, map <int8, map <int8, vector<TraitData*> > >* sortedTraitList, map <int8, vector<TraitData*> >* classTraining,
  54. map <int8, vector<TraitData*> >* raceTraits, map <int8, vector<TraitData*> >* innateRaceTraits, map <int8, vector<TraitData*> >* focusEffects, int16 max_level = 0, int8 trait_group = 255);
  55. /// <summary>Sorts the traits for the given client and creats and sends the trait packet.</summary>
  56. /// <param name='client'>The Client calling this function</param>
  57. /// <returns>EQ2Packet*</returns>
  58. EQ2Packet* GetTraitListPacket(Client* client);
  59. /// <summary>Add trait data to the global list.</summary>
  60. /// <param name='data'>The trait data to add.</param>
  61. void AddTrait(TraitData* data);
  62. /// <summary>Get the total number of traits in the global list.</summary>
  63. int Size();
  64. /// <summary>Get the trait data for the given spell.</summary>
  65. /// <param name='spellID'>Spell ID to get trait data for.</param>
  66. TraitData* GetTrait(int32 spellID);
  67. /// <summary>Get the trait data for the given item.</summary>
  68. /// <param name='itemID'>Item ID to map to the trait data.</param>
  69. TraitData* GetTraitByItemID(int32 itemID);
  70. /// <summary>Empties the master trait list</summary>
  71. void DestroyTraits();
  72. private:
  73. vector <TraitData*> TraitList;
  74. Mutex MMasterTraitList;
  75. };
  76. #endif