Advertisement
Guest User

Untitled

a guest
Jun 25th, 2015
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.66 KB | None | 0 0
  1. #include "ScriptPCH.h"
  2. #include "DisableMgr.h"
  3.  
  4. class LearnSpellsOnLevelUp : public PlayerScript
  5. {
  6. public:
  7. std::vector<uint32> ignoreSpells;
  8.  
  9. LearnSpellsOnLevelUp() : PlayerScript("LearnSpellsOnLevelUp")
  10. {
  11. uint64 temp[] = {
  12. 64380, 23885, 23880, 44461, 25346, 10274, 10273, 8418,
  13. 8419, 7270, 7269, 7268, 54648, 12536, 24530, 70909,
  14. 12494, 57933, 24224, 27095, 27096, 27097, 27099, 32841,
  15. 56131, 56160, 56161, 48153, 34754, 64844, 64904, 48085,
  16. 33110, 48084, 28276, 27874, 27873, 7001, 49821, 53022,
  17. 47757, 47750, 47758, 47666, 53001, 52983, 52998, 52986,
  18. 52987, 52999, 52984, 53002, 53003, 53000, 52988, 52985,
  19. 42208, 42209, 42210, 42211, 42212, 42213, 42198, 42937,
  20. 42938, 12484, 12485, 12486, 44461, 55361, 55362, 34913,
  21. 43043, 43044, 38703, 38700, 27076, 42844, 42845, 64891,
  22. 25912, 25914, 25911, 25913, 25902, 25903, 27175, 27176,
  23. 33073, 33074, 48822, 48820, 48823, 48821, 20154, 25997,
  24. 20467, 20425, 67, 26017, 34471, 53254, 13812, 14314,
  25. 14315, 27026, 49064, 49065, 60202, 60210, 13797, 14298,
  26. 14299, 14300, 14301, 27024, 49053, 49054, 52399, 1742,
  27. 24453, 53548, 53562, 52016, 26064, 35346, 57386, 57389,
  28. 57390, 57391, 57392, 57393, 55509, 35886, 43339, 45297,
  29. 45298, 45299, 45300, 45301, 45302, 49268, 49269, 8349,
  30. 8502, 8503, 11306, 11307, 25535, 25537, 61650, 61654,
  31. 63685, 45284, 45286, 45287, 45288, 45289, 45290, 45291,
  32. 45292, 45293, 45294, 45295, 45296, 49239, 49240, 26364,
  33. 26365, 26366, 26367, 26369, 26370, 26363, 26371, 26372,
  34. 49278, 49279, 32176, 32175, 21169, 47206, 27285, 47833,
  35. 47836, 42223, 42224, 42225, 42226, 42218, 47817, 47818,
  36. 42231, 42232, 42233, 42230, 48466, 44203, 44205, 44206,
  37. 44207, 44208, 48444, 48445, 33891, 52374, 57532, 59921,
  38. 52372, 49142, 52375, 47633, 47632, 52373, 50536, 27214,
  39. 47822, 11682, 11681, 5857, 1010, 24907, 24905, 53227,
  40. 61391, 61390, 61388, 61387, 64801, 5421, 9635, 1178,
  41. 20186, 20185, 20184, 20187, 25899, 24406, 50581, 30708, 31801
  42. };
  43.  
  44. ignoreSpells = std::vector<uint32> (temp, temp + sizeof(temp)/sizeof(temp[0]));
  45. }
  46.  
  47. void OnLevelChanged(Player* player, uint8 oldLevel)
  48. {
  49. if (oldLevel < player->getLevel())
  50. LearnSpellsForNewLevel(player, oldLevel);
  51. }
  52.  
  53. bool IsIgnoredSpell(uint32 spellID)
  54. {
  55. for (std::vector<uint32>::const_iterator itr = ignoreSpells.begin(); itr != ignoreSpells.end(); ++itr)
  56. if (spellID == (*itr))
  57. return true;
  58. return false;
  59. }
  60.  
  61. void LearnSpellsForNewLevel(Player* player, uint8 level)
  62. {
  63. if (level == player->getLevel() + 1)
  64. return;
  65. uint32 family;
  66. switch(player->getClass())
  67. {
  68. case CLASS_ROGUE:
  69. family = SPELLFAMILY_ROGUE;
  70. break;
  71. case CLASS_DEATH_KNIGHT:
  72. family = SPELLFAMILY_DEATHKNIGHT;
  73. break;
  74. case CLASS_WARRIOR:
  75. family = SPELLFAMILY_WARRIOR;
  76. break;
  77. case CLASS_PRIEST:
  78. family = SPELLFAMILY_PRIEST;
  79. break;
  80. case CLASS_MAGE:
  81. family = SPELLFAMILY_MAGE;
  82. break;
  83. case CLASS_PALADIN:
  84. family = SPELLFAMILY_PALADIN;
  85. break;
  86. case CLASS_HUNTER:
  87. family = SPELLFAMILY_HUNTER;
  88. break;
  89. case CLASS_DRUID:
  90. family = SPELLFAMILY_DRUID;
  91. break;
  92. case CLASS_SHAMAN:
  93. family = SPELLFAMILY_SHAMAN;
  94. break;
  95. case CLASS_WARLOCK:
  96. family = SPELLFAMILY_WARLOCK;
  97. break;
  98. }
  99. for (uint32 i = 0; i < sSpellMgr->GetSpellInfoStoreSize(); ++i)
  100. {
  101. SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(i);
  102. if (!spellInfo)
  103. continue;
  104. if (spellInfo->SpellFamilyName != family)
  105. continue;
  106. if (IsIgnoredSpell(spellInfo->Id))
  107. continue;
  108. if (spellInfo->PowerType == POWER_FOCUS)
  109. continue;
  110. if (DisableMgr::IsDisabledFor(DISABLE_TYPE_SPELL, spellInfo->Id, player))
  111. continue;
  112. if ((spellInfo->AttributesEx7 & SPELL_ATTR7_ALLIANCE_ONLY && player->GetTeam() != ALLIANCE) || (spellInfo->AttributesEx7 & SPELL_ATTR7_HORDE_ONLY && player->GetTeam() != HORDE))
  113. continue;
  114. if (spellInfo->BaseLevel != level && sSpellMgr->IsSpellValid(spellInfo, player))
  115. continue;
  116.  
  117.  
  118. bool valid = false;
  119.  
  120. SkillLineAbilityMapBounds bounds = sSpellMgr->GetSkillLineAbilityMapBounds(spellInfo->Id);
  121. for (SkillLineAbilityMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr)
  122. {
  123. if (itr->second->spellId == spellInfo->Id && itr->second->racemask == 0 && itr->second->AutolearnType == 0)
  124. {
  125. valid = true;
  126. SpellInfo const* prevSpell = spellInfo->GetPrevRankSpell();
  127. if (prevSpell && !player->HasSpell(prevSpell->Id))
  128. {
  129. valid = false;
  130. break;
  131. }
  132. if (GetTalentSpellPos(itr->second->spellId))
  133. if (!prevSpell || !player->HasSpell(prevSpell->Id) || spellInfo->GetRank() == 1)
  134. valid = false;
  135. break;
  136. }
  137. }
  138.  
  139. if (valid)
  140. player->LearnSpell(spellInfo->Id, false);
  141. }
  142. LearnSpellsForNewLevel(player, ++level);
  143. }
  144. };
  145.  
  146. void AddSC_LearnSpellsOnLevelUp()
  147. {
  148. new LearnSpellsOnLevelUp();
  149. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement