Advertisement
Guest User

Paranoia updated version

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