Serverlands

TemplateNPC.h

Jan 15th, 2022 (edited)
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 8.70 KB | None | 0 0
  1. /*
  2. Full credit goes to Mindsear -> https://www.ac-web.org/forums/member.php?303304-mindsear | https://github.com/mindsear
  3. Original file: https://github.com/mindsear/TemplateNPC/blob/master/TemplateNPC.h
  4.  
  5. Updated by Dandi, Discord: Dandi#2828
  6. https://serverlands.com
  7. */
  8.  
  9.  
  10. #ifndef TALENT_FUNCTIONS_H
  11. #define TALENT_FUNCTIONS_H
  12.  
  13. #include "Define.h"
  14. #include "Player.h"
  15.  
  16. enum Spells
  17. {
  18.     Amani_War_Bear = 43688,
  19.     Artisan_Riding = 34091,
  20.     Cold_Weather_Flying = 54197,
  21.     Teach_Learn_Talent_Specialization_Switches = 63680,
  22.     Learn_a_Second_Talent_Specialization = 63624
  23. };
  24.  
  25. enum templateSpells
  26. {
  27.     PLATE_MAIL = 750,
  28.     MAIL = 8737
  29. };
  30.  
  31. enum WeaponProficiencies
  32. {
  33.     BLOCK = 107,
  34.     BOWS = 264,
  35.     CROSSBOWS = 5011,
  36.     DAGGERS = 1180,
  37.     FIST_WEAPONS = 15590,
  38.     GUNS = 266,
  39.     ONE_H_AXES = 196,
  40.     ONE_H_MACES = 198,
  41.     ONE_H_SWORDS = 201,
  42.     POLEARMS = 200,
  43.     SHOOT = 5019,
  44.     STAVES = 227,
  45.     TWO_H_AXES = 197,
  46.     TWO_H_MACES = 199,
  47.     TWO_H_SWORDS = 202,
  48.     WANDS = 5009,
  49.     THROW_WAR = 2567
  50. };
  51.  
  52. static void LearnWeaponSkills(Player* player)
  53. {
  54.     WeaponProficiencies wepSkills[] = {
  55.         BLOCK, BOWS, CROSSBOWS, DAGGERS, FIST_WEAPONS, GUNS, ONE_H_AXES, ONE_H_MACES,
  56.         ONE_H_SWORDS, POLEARMS, SHOOT, STAVES, TWO_H_AXES, TWO_H_MACES, TWO_H_SWORDS, WANDS, THROW_WAR
  57.     };
  58.  
  59.     uint32 size = 17;
  60.  
  61.     for (uint32 i = 0; i < size; ++i)
  62.         if (player->HasSpell(wepSkills[i]))
  63.             continue;
  64.  
  65.     switch (player->GetClass())
  66.     {
  67.     case CLASS_WARRIOR:
  68.         player->LearnSpell(THROW_WAR, false);
  69.         player->LearnSpell(TWO_H_SWORDS, false);
  70.         player->LearnSpell(TWO_H_MACES, false);
  71.         player->LearnSpell(TWO_H_AXES, false);
  72.         player->LearnSpell(STAVES, false);
  73.         player->LearnSpell(POLEARMS, false);
  74.         player->LearnSpell(ONE_H_SWORDS, false);
  75.         player->LearnSpell(ONE_H_MACES, false);
  76.         player->LearnSpell(ONE_H_AXES, false);
  77.         player->LearnSpell(GUNS, false);
  78.         player->LearnSpell(FIST_WEAPONS, false);
  79.         player->LearnSpell(DAGGERS, false);
  80.         player->LearnSpell(CROSSBOWS, false);
  81.         player->LearnSpell(BOWS, false);
  82.         player->LearnSpell(BLOCK, false);
  83.         break;
  84.     case CLASS_PRIEST:
  85.         player->LearnSpell(WANDS, false);
  86.         player->LearnSpell(STAVES, false);
  87.         player->LearnSpell(SHOOT, false);
  88.         player->LearnSpell(ONE_H_MACES, false);
  89.         player->LearnSpell(DAGGERS, false);
  90.         break;
  91.     case CLASS_PALADIN:
  92.         player->LearnSpell(TWO_H_SWORDS, false);
  93.         player->LearnSpell(TWO_H_MACES, false);
  94.         player->LearnSpell(TWO_H_AXES, false);
  95.         player->LearnSpell(POLEARMS, false);
  96.         player->LearnSpell(ONE_H_SWORDS, false);
  97.         player->LearnSpell(ONE_H_MACES, false);
  98.         player->LearnSpell(ONE_H_AXES, false);
  99.         player->LearnSpell(BLOCK, false);
  100.         break;
  101.     case CLASS_ROGUE:
  102.         player->LearnSpell(ONE_H_SWORDS, false);
  103.         player->LearnSpell(ONE_H_MACES, false);
  104.         player->LearnSpell(ONE_H_AXES, false);
  105.         player->LearnSpell(GUNS, false);
  106.         player->LearnSpell(FIST_WEAPONS, false);
  107.         player->LearnSpell(DAGGERS, false);
  108.         player->LearnSpell(CROSSBOWS, false);
  109.         player->LearnSpell(BOWS, false);
  110.         break;
  111.     case CLASS_DEATH_KNIGHT:
  112.         player->LearnSpell(TWO_H_SWORDS, false);
  113.         player->LearnSpell(TWO_H_MACES, false);
  114.         player->LearnSpell(TWO_H_AXES, false);
  115.         player->LearnSpell(POLEARMS, false);
  116.         player->LearnSpell(ONE_H_SWORDS, false);
  117.         player->LearnSpell(ONE_H_MACES, false);
  118.         player->LearnSpell(ONE_H_AXES, false);
  119.         break;
  120.     case CLASS_MAGE:
  121.         player->LearnSpell(WANDS, false);
  122.         player->LearnSpell(STAVES, false);
  123.         player->LearnSpell(SHOOT, false);
  124.         player->LearnSpell(ONE_H_SWORDS, false);
  125.         player->LearnSpell(DAGGERS, false);
  126.         break;
  127.     case CLASS_SHAMAN:
  128.         player->LearnSpell(TWO_H_MACES, false);
  129.         player->LearnSpell(TWO_H_AXES, false);
  130.         player->LearnSpell(STAVES, false);
  131.         player->LearnSpell(ONE_H_MACES, false);
  132.         player->LearnSpell(ONE_H_AXES, false);
  133.         player->LearnSpell(FIST_WEAPONS, false);
  134.         player->LearnSpell(DAGGERS, false);
  135.         player->LearnSpell(BLOCK, false);
  136.         break;
  137.     case CLASS_HUNTER:
  138.         player->LearnSpell(THROW_WAR, false);
  139.         player->LearnSpell(TWO_H_SWORDS, false);
  140.         player->LearnSpell(TWO_H_AXES, false);
  141.         player->LearnSpell(STAVES, false);
  142.         player->LearnSpell(POLEARMS, false);
  143.         player->LearnSpell(ONE_H_SWORDS, false);
  144.         player->LearnSpell(ONE_H_AXES, false);
  145.         player->LearnSpell(GUNS, false);
  146.         player->LearnSpell(FIST_WEAPONS, false);
  147.         player->LearnSpell(DAGGERS, false);
  148.         player->LearnSpell(CROSSBOWS, false);
  149.         player->LearnSpell(BOWS, false);
  150.         break;
  151.     case CLASS_DRUID:
  152.         player->LearnSpell(TWO_H_MACES, false);
  153.         player->LearnSpell(STAVES, false);
  154.         player->LearnSpell(POLEARMS, false);
  155.         player->LearnSpell(ONE_H_MACES, false);
  156.         player->LearnSpell(FIST_WEAPONS, false);
  157.         player->LearnSpell(DAGGERS, false);
  158.         break;
  159.     case CLASS_WARLOCK:
  160.         player->LearnSpell(WANDS, false);
  161.         player->LearnSpell(STAVES, false);
  162.         player->LearnSpell(SHOOT, false);
  163.         player->LearnSpell(ONE_H_SWORDS, false);
  164.         player->LearnSpell(DAGGERS, false);
  165.         break;
  166.     default:
  167.         break;
  168.     }
  169.     player->UpdateWeaponsSkillsToMaxSkillsForLevel();
  170.  
  171. }
  172.  
  173. struct TalentTemplate
  174. {
  175.     std::string    playerClass;
  176.     std::string    playerSpec;
  177.     uint32         talentId;
  178. };
  179.  
  180. struct GlyphTemplate
  181. {
  182.     std::string    playerClass;
  183.     std::string    playerSpec;
  184.     uint8          slot;
  185.     uint32         glyph;
  186. };
  187.  
  188. struct HumanGearTemplate
  189. {
  190.     std::string    playerClass;
  191.     std::string    playerSpec;
  192.     uint8          pos;
  193.     uint32         itemEntry;
  194.     uint32         enchant;
  195.     uint32         socket1;
  196.     uint32         socket2;
  197.     uint32         socket3;
  198.     uint32         bonusEnchant;
  199.     uint32         prismaticEnchant;
  200. };
  201.  
  202. struct AllianceGearTemplate
  203. {
  204.     std::string    playerClass;
  205.     std::string    playerSpec;
  206.     uint8          pos;
  207.     uint32         itemEntry;
  208.     uint32         enchant;
  209.     uint32         socket1;
  210.     uint32         socket2;
  211.     uint32         socket3;
  212.     uint32         bonusEnchant;
  213.     uint32         prismaticEnchant;
  214. };
  215.  
  216. struct HordeGearTemplate
  217. {
  218.     std::string    playerClass;
  219.     std::string    playerSpec;
  220.     uint8          pos;
  221.     uint32         itemEntry;
  222.     uint32         enchant;
  223.     uint32         socket1;
  224.     uint32         socket2;
  225.     uint32         socket3;
  226.     uint32         bonusEnchant;
  227.     uint32         prismaticEnchant;
  228. };
  229.  
  230. typedef std::vector<HumanGearTemplate*> HumanGearContainer;
  231. typedef std::vector<AllianceGearTemplate*> AllianceGearContainer;
  232. typedef std::vector<HordeGearTemplate*> HordeGearContainer;
  233.  
  234. typedef std::vector<TalentTemplate*> TalentContainer;
  235. typedef std::vector<GlyphTemplate*> GlyphContainer;
  236.  
  237. class sTemplateNPC
  238. {
  239. public:
  240.     static sTemplateNPC* instance()
  241.     {
  242.         static sTemplateNPC* instance = new sTemplateNPC();
  243.         return instance;
  244.     }
  245.     void LoadTalentsContainer();
  246.     void LoadGlyphsContainer();
  247.  
  248.     void LoadHumanGearContainer();
  249.     void LoadAllianceGearContainer();
  250.     void LoadHordeGearContainer();
  251.  
  252.     void ApplyGlyph(Player* player, uint8 slot, uint32 glyphID);
  253.     void RemoveAllGlyphs(Player* player);
  254.     void ApplyBonus(Player* player, Item* item, EnchantmentSlot slot, uint32 bonusEntry);
  255.  
  256.     bool OverwriteTemplate(Player* /*player*/, std::string& /*playerSpecStr*/);
  257.     void ExtractGearTemplateToDB(Player* /*player*/, std::string& /*playerSpecStr*/);
  258.     void ExtractTalentTemplateToDB(Player* /*player*/, std::string& /*playerSpecStr*/);
  259.     void ExtractGlyphsTemplateToDB(Player* /*player*/, std::string& /*playerSpecStr*/);
  260.     bool CanEquipTemplate(Player* /*player*/, std::string& /*playerSpecStr*/);
  261.  
  262.     std::string GetClassString(Player* /*player*/);
  263.     std::string sTalentsSpec;
  264.  
  265.     void LearnTemplateTalents(Player* /*player*/);
  266.     void LearnTemplateGlyphs(Player* /*player*/);
  267.     void EquipTemplateGear(Player* /*player*/);
  268.  
  269.     void LearnPlateMailSpells(Player* /*player*/);
  270.  
  271.     GlyphContainer m_GlyphContainer;
  272.     TalentContainer m_TalentContainer;
  273.  
  274.     HumanGearContainer m_HumanGearContainer;
  275.     AllianceGearContainer m_AllianceGearContainer;
  276.     HordeGearContainer m_HordeGearContainer;
  277. };
  278. #define sTemplateNpcMgr sTemplateNPC::instance()
  279. #endif
  280.  
Add Comment
Please, Sign In to add comment