Advertisement
Guest User

Untitled

a guest
Jul 29th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.35 KB | None | 0 0
  1. #include "ScriptMgr.h"
  2.  
  3. struct ClassSpec
  4. {
  5.     uint32 gossip_action_id;
  6.     Classes plrClass;
  7.     const char* specName;
  8.     uint32 spells[3];
  9. };
  10.  
  11. std::vector<ClassSpec> Class_Specializations =
  12. {
  13.     {
  14.         1,
  15.         CLASS_PALADIN,
  16.         "Holy",
  17.         {
  18.             19746,
  19.             7328,
  20.             31836
  21.         }
  22.     },
  23.     {
  24.         2,
  25.         CLASS_PALADIN,
  26.         "Protection",
  27.         {
  28.             25780,
  29.             26573,
  30.             20925
  31.         }
  32.     },
  33.     {
  34.         3,
  35.         CLASS_PALADIN,
  36.         "Retribution",
  37.         {
  38.             20271,
  39.             35395,
  40.             7294
  41.         }
  42.     },
  43.     {
  44.         4,
  45.         CLASS_DRUID,
  46.         "Balance",
  47.         {
  48.             5176,
  49.             8921
  50.         }
  51.     },
  52.     {
  53.         5,
  54.         CLASS_DRUID,
  55.         "Feral (Cat)",
  56.         {
  57.             768,
  58.             1082,
  59.             22568
  60.         }
  61.     },
  62.     {
  63.         6,
  64.         CLASS_DRUID,
  65.         "Feral (Bear)",
  66.         {
  67.             5487,
  68.             6807,
  69.             6795
  70.         }
  71.     },
  72.     {
  73.         7,
  74.         CLASS_DRUID,
  75.         "Restoration",
  76.         {
  77.             5185,
  78.             774
  79.         }
  80.     },
  81. };
  82.  
  83.  
  84. class TalentSpecNPC : public CreatureScript
  85. {
  86. public:
  87.     TalentSpecNPC() : CreatureScript("TalentSpecNPC") { }
  88.  
  89.     bool OnGossipHello(Player* player, Creature* creature)
  90.     {
  91.         for (auto itr = Class_Specializations.begin(); itr != Class_Specializations.end(); ++itr)
  92.         {
  93.             if (player->getClass() == itr->plrClass)
  94.             {
  95.                 std::ostringstream ss;
  96.                 const SpellInfo* info;
  97.                 ss << itr->specName << "\n";
  98.  
  99.                 for (int i = 0; i < (sizeof(itr->spells) / sizeof(uint32)); i++)
  100.                 {
  101.                     info = sSpellMgr->GetSpellInfo(itr->spells[i]);
  102.                     if(info)
  103.                         ss << info->SpellName[sWorld->GetDefaultDbcLocale()] << "\n";
  104.                 }
  105.                 player->ADD_GOSSIP_ITEM(0, ss.str(), GOSSIP_SENDER_MAIN, itr->gossip_action_id);
  106.             }
  107.         }
  108.         player->PlayerTalkClass->SendGossipMenu(1, creature->GetGUID());
  109.         return true;
  110.     }
  111.  
  112.     bool OnGossipSelect(Player* player, Creature* creature, uint32 sender, uint32 action)
  113.     {
  114.         for (auto itr = Class_Specializations.begin(); itr != Class_Specializations.end(); ++itr)
  115.         {
  116.             if (action == itr->gossip_action_id)
  117.             {
  118.                 for (int i = 0; i < sizeof(itr->spells) / sizeof(uint32); i++)
  119.                 {
  120.                     player->LearnSpell(itr->spells[i], false);
  121.                 }
  122.             }
  123.  
  124.             if (itr->plrClass == player->getClass() && itr->gossip_action_id != action)
  125.             {
  126.                 for (int i = 0; i < sizeof(itr->spells) / sizeof(uint32); i++)
  127.                 {
  128.                     if (player->HasSpell(itr->spells[i]))
  129.                         player->RemoveSpell(itr->spells[i], true, false);
  130.                 }
  131.             }
  132.         }
  133.         player->PlayerTalkClass->SendCloseGossip();
  134.         return true;
  135.     }
  136. };
  137.  
  138. void AddSC_TalentSpecNPC()
  139. {
  140.     new TalentSpecNPC();
  141. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement