Advertisement
Guest User

Untitled

a guest
Jun 2nd, 2016
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. //This function is called just before the players level changes
  2. void OnPlayerLevelChanged(Player* player, uint8 oldLevel, uint8 newLevel)
  3. {
  4. // Define newlevel, trainderID, teamID
  5. uint32 newlevel = newLevel;
  6. uint32 trainerID;
  7. uint32 teamID = player->GetTeamId();
  8. // Select the correct trainer for class and faction
  9. switch (player->getClass())
  10. {
  11. case CLASS_WARRIOR:
  12. if (teamID == TEAM_ALLIANCE)
  13. {
  14. trainerID = 17504;
  15. } else
  16. trainerID = 985;
  17. break;
  18. case CLASS_ROGUE:
  19. if (teamID == TEAM_ALLIANCE)
  20. {
  21. trainerID = 13283;
  22. }
  23. else
  24. trainerID = 3401;
  25. break;
  26. case CLASS_SHAMAN:
  27. if (teamID == TEAM_ALLIANCE)
  28. {
  29. trainerID = 20407;
  30. }
  31. else
  32. trainerID = 13417;
  33. break;
  34. case CLASS_PRIEST:
  35. if (teamID == TEAM_ALLIANCE)
  36. {
  37. trainerID = 11406;
  38. }
  39. else
  40. trainerID = 16658;
  41. break;
  42. case CLASS_MAGE:
  43. if (teamID == TEAM_ALLIANCE)
  44. {
  45. trainerID = 7312;
  46. }
  47. else
  48. trainerID = 16653;
  49. break;
  50. case CLASS_WARLOCK:
  51. if (teamID == TEAM_ALLIANCE)
  52. {
  53. trainerID = 5172;
  54. }
  55. else
  56. trainerID = 16648;
  57. break;
  58. case CLASS_HUNTER:
  59. if (teamID == TEAM_ALLIANCE)
  60. {
  61. trainerID = 5516;
  62. }
  63. else
  64. trainerID = 3039;
  65. break;
  66. case CLASS_DRUID:
  67. if (teamID == TEAM_ALLIANCE)
  68. {
  69. trainerID = 5504;
  70. }
  71. else
  72. trainerID = 16655;
  73. break;
  74. case CLASS_PALADIN:
  75. if (teamID == TEAM_ALLIANCE)
  76. {
  77. trainerID = 20407;
  78. }
  79. else
  80. trainerID = 16681;
  81. break;
  82. }
  83.  
  84. QueryResult_AutoPtr result = WorldDatabase.PQuery("SELECT spell FROM npc_trainer WHERE reqlevel BETWEEN 1 AND %i AND entry = %i", newlevel, trainerID);
  85.  
  86. if (!result)
  87. {
  88. return;
  89. }
  90.  
  91. do
  92. {
  93. Field* fields = result->Fetch();
  94.  
  95. uint32 spellID = fields[0].GetUInt32();
  96.  
  97. SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellID);
  98.  
  99. if (!spellInfo)
  100. continue;
  101.  
  102. // skip wrong class/race skills
  103. if (!player->IsSpellFitByClassAndRace(spellInfo->Id))
  104. continue;
  105.  
  106. // Skip known spells
  107. if (player->HasSpell(spellInfo->Id))
  108. continue;
  109.  
  110. // skip spells with first rank learned as talent (and all talents then also)
  111. if (GetTalentSpellCost(sSpellMgr.GetFirstSpellInChain(spellInfo->Id)) > 0)
  112. continue;
  113.  
  114. // skip broken spells
  115. if (!SpellMgr::IsSpellValid(spellInfo, player, false))
  116. continue;
  117.  
  118. player->LearnSpell(spellInfo->Id);
  119. } while (result->NextRow());
  120.  
  121. return;
  122. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement