Advertisement
cgm2k7

Scritp_auto_equipe.h

Oct 15th, 2014
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 14.79 KB | None | 0 0
  1. #include "ScriptPCH.h"
  2. #include "Language.h"
  3.  
  4. uint32 SIg[] = {
  5.     64380, 23885, 23880, 44461, 25346, 10274, 10273, 8418, 8419, 7270, 7269, 7268, 54648, 12536, 24530, 70909,
  6.     12494, 57933, 24224, 27095, 27096, 27097, 27099, 32841, 56131, 56160, 56161, 48153, 34754, 64844, 64904, 48085,
  7.     33110, 48084, 28276, 27874, 27873, 7001, 49821, 53022, 47757, 47750, 47758, 47666, 53001, 52983, 52998, 52986,
  8.     52987, 52999, 52984, 53002, 53003, 53000, 52988, 52985, 42208, 42209, 42210, 42211, 42212, 42213, 42198, 42937,
  9.     42938, 12484, 12485, 12486, 44461, 55361, 55362, 34913, 43043, 43044, 38703, 38700, 27076, 42844, 42845, 64891,
  10.     25912, 25914, 25911, 25913, 25902, 25903, 27175, 27176, 33073, 33074, 48822, 48820, 48823, 48821, 20154, 25997,
  11.     20467, 20425, 67, 26017, 34471, 53254, 13812, 14314, 14315, 27026, 49064, 49065, 60202, 60210, 13797, 14298,
  12.     14299, 14300, 14301, 27024, 49053, 49054, 52399, 1742, 24453, 53548, 53562, 52016, 26064, 35346, 57386, 57389,
  13.     57390, 57391, 57392, 57393, 55509, 35886, 43339, 45297, 45298, 45299, 45300, 45301, 45302, 49268, 49269, 8349,
  14.     8502, 8503, 11306, 11307, 25535, 25537, 61650, 61654, 63685, 45284, 45286, 45287, 45288, 45289, 45290, 45291,
  15.     45292, 45293, 45294, 45295, 45296, 49239, 49240, 26364, 26365, 26366, 26367, 26369, 26370, 26363, 26371, 26372,
  16.     49278, 49279, 32176, 32175, 21169, 47206, 27285, 47833, 47836, 42223, 42224, 42225, 42226, 42218, 47817, 47818,
  17.     42231, 42232, 42233, 42230, 48466, 44203, 44205, 44206, 44207, 44208, 48444, 48445, 33891, 52374, 57532, 59921,
  18.     52372, 49142, 52375, 47633, 47632, 52373, 50536, 27214, 47822, 11682, 11681, 5857, 1010, 24907, 24905, 53227,
  19.     61391, 61390, 61388, 61387, 64801, 5421, 9635, 1178, 20186, 20185, 20184, 20187, 25899, 24406, 50581, 30708,
  20.     8946, 42459, 23455, 48076
  21. };
  22. uint32 SRestante[][99]
  23. {       // Warrior
  24.     { 3127, 264, 266, 5011, 15590, 200, 227, 2567, 674, 750, 12678 },
  25.         //DK
  26.     { 198, 199, 3714, 53323, 53331, 53341, 53342, 53343, 53344, 54446, 54447, 62158, 70164 },
  27.     //Druid
  28.     { 15590, 200, 5225, 20719, 62600 },
  29.     // Hunter
  30.     { 674, 42459, 8737, 15590, 2567, 227, 266, 5011, 200, 201, 1462, 3127, 6197, 19885 },
  31.     // mage
  32.     { 1180, 201, /*Alliance->*/ 3562, 3561, 3565, 11416, 11419, 32266, 32271, 33690, 33691, 49359, 49360, /*Horde->*/ 3563, 3566, 3567, 11417, 11418, 11420, 32272, 35715, 35717, 32267, 49358, 49361 },
  33.     //==Fim spell Mage======================================================================
  34.     // paladin
  35.     { 750, 200, 196, 197, 199, 3127, 48950 },
  36.     //Rogue
  37.     { 264, 15590, 5011, 201, 196, 198, 3127, 2836 },
  38.     //Shaman
  39.     { 8737, 1180, 15590, 196, 197, 199, 6196, 66842, 66843, 66844 },
  40.     //Warlock
  41.     { 201, 5500, 5784, 29858, 33388, 47836 },
  42. };
  43.  
  44. std::vector<uint32> SpellsPIguinorar = std::vector<uint32>(SIg, SIg + sizeof(SIg) / sizeof(SIg[0]));
  45.  
  46. bool GetSpellIguinorar(uint32 IDspell)
  47. {
  48.     for (std::vector<uint32>::const_iterator itr = SpellsPIguinorar.begin(); itr != SpellsPIguinorar.end(); ++itr)
  49.     if (IDspell == (*itr))
  50.         return true;
  51.     return false;
  52. }
  53. bool SpellsRestante(Player* player, uint32 SpellClasses)
  54. {
  55.     uint8 pLevel = player->getLevel() + 1;
  56.     switch (SpellClasses = player->getClass())
  57.     {
  58.     case CLASS_WARRIOR:
  59.         for (int i = 0; i < 11; i++)
  60.         {
  61.             player->LearnSpell(SRestante[0][i], false);
  62.         }
  63.         if (player->HasSpell(12294))
  64.             player->LearnSpell(47486, false);
  65.  
  66.         if (player->HasSpell(20243))
  67.             player->LearnSpell(47498, false);
  68.  
  69.         break;
  70.     case CLASS_DEATH_KNIGHT:
  71.         for (int i = 0; i < 13; i++)
  72.         {
  73.             player->LearnSpell(SRestante[1][i], false);
  74.         }
  75.         if (player->HasSpell(55050)) //Heart Strike Rank 1
  76.             player->LearnSpell(55262, false);
  77.  
  78.         if (player->HasSpell(49143)) //Frost Strike Rank 1
  79.             player->LearnSpell(55268, false);
  80.  
  81.         if (player->HasSpell(49184)) //Howling Blast Rank 1
  82.             player->LearnSpell(51411, false);
  83.  
  84.         if (player->HasSpell(55090)) //Scourge Strike Rank 1
  85.             player->LearnSpell(55271, false);
  86.  
  87.         if (player->HasSpell(49158)) //Corpse Explosion Rank 1
  88.             player->LearnSpell(51328, false);
  89.  
  90.         if (player->GetFreeTalentPoints() == +25){
  91.             player->CastSpell(player, 26410, false);
  92.             player->ResetTalents();
  93.             player->SetFreeTalentPoints(71);
  94.             player->SendTalentsInfoData(false);
  95.         }
  96.         break;
  97.     case CLASS_DRUID:
  98.         for (int i = 0; i < 5; i++)
  99.         {
  100.             player->LearnSpell(SRestante[2][i], false);
  101.         }
  102.         if (player->HasSpell(50516)) //Typhoon Rank 1
  103.             player->LearnSpell(61384, false);
  104.  
  105.         if (player->HasSpell(48505)) //Starfall Rank 1
  106.             player->LearnSpell(53201, false);
  107.  
  108.         if (player->HasSpell(5570)) //Insect Swarm Rank 1
  109.             player->LearnSpell(48468, false);
  110.  
  111.         if (player->HasSpell(48438)) //Wild Growth Rank 1
  112.             player->LearnSpell(53251, false);
  113.  
  114.         if (player->HasSpell(33876) && player->HasSpell(33878) && player->HasSpell(33917))
  115.         {
  116.             player->LearnSpell(48564, false);
  117.             player->LearnSpell(48566, false);
  118.         }
  119.         if (player->HasSpell(5487))
  120.             player->LearnSpell(9634, false);
  121.         break;
  122.     case CLASS_HUNTER:
  123.         for (int i = 0; i < 14; i++)
  124.         {
  125.             player->LearnSpell(SRestante[3][i], false);
  126.         }
  127.         if (player->HasSpell(19386)) //Wyvern String Rank 1
  128.             player->LearnSpell(49012, false);
  129.  
  130.         if (player->HasSpell(53301)) //Explosive Shot Rank 1
  131.             player->LearnSpell(60053, false);
  132.  
  133.         if (player->HasSpell(19306)) //Conter Attack Rank 1
  134.             player->LearnSpell(48999, false);
  135.  
  136.         if (player->HasSpell(19434)) //Aimed Shot Rank 1
  137.             player->LearnSpell(49050, false);
  138.         break;
  139.     case CLASS_MAGE:
  140.         for (int i = 0; i < 25; i++)
  141.         {
  142.             SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(SRestante[4][i]);
  143.             if (!spellInfo) continue;
  144.             if (!(pLevel > spellInfo->SpellLevel)) continue;
  145.  
  146.             if (!player->GetSession()->GetPlayer()->IsSpellFitByClassAndRace(SRestante[4][i])) continue;
  147.  
  148.             player->LearnSpell(SRestante[4][i], false);
  149.         }
  150.         if (player->HasSpell(44425)) //Arcane Barrage Rank 1
  151.             player->LearnSpell(44781, false);
  152.  
  153.         if (player->HasSpell(11113)) //Blast Wave Rank 1
  154.             player->LearnSpell(42945, false);
  155.  
  156.         if (player->HasSpell(31661)) //Dragon Breath  Rank 1
  157.             player->LearnSpell(42950, false);
  158.  
  159.         if (player->HasSpell(44457)) //Living Bomb Rank 1
  160.             player->LearnSpell(55360, false);
  161.  
  162.         if (player->HasSpell(11366)) //Pyroblast Rank 1
  163.             player->LearnSpell(42891, false);
  164.  
  165.         if (player->HasSpell(11426)) //Ice Barrier Rank 1
  166.             player->LearnSpell(43039, false);
  167.  
  168.         break;
  169.     case CLASS_PALADIN:
  170.         for (int i = 0; i < 7; i++)
  171.         {
  172.             SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(SRestante[5][i]);
  173.             if (!spellInfo) continue;
  174.             if (!(pLevel > spellInfo->SpellLevel)) continue;
  175.             if (player->HasSpell(SRestante[5][i])) continue;
  176.  
  177.             player->LearnSpell(SRestante[5][i], false);
  178.         }
  179.         if (player->GetTeam() == ALLIANCE) // spell só para alliance
  180.         {
  181.             player->LearnSpell(31801, false);
  182.             player->LearnSpell(13819, false);
  183.             player->LearnSpell(23214, false);
  184.         }
  185.         else{ // spell só para Horde
  186.             player->LearnSpell(53736, false);
  187.             player->LearnSpell(34769, false);
  188.             player->LearnSpell(34767, false);
  189.         }
  190.         if (player->HasSpell(20925)) //Holy Shield Rank 1
  191.             player->LearnSpell(48952, false);
  192.  
  193.         if (player->HasSpell(20473)) //Holy Shock Rank 1
  194.             player->LearnSpell(48825, false);
  195.  
  196.         if (player->HasSpell(31935)) //Avengers Shield Rank 1
  197.             player->LearnSpell(48827, false);
  198.  
  199.         if (player->HasSpell(20911)) //Blessing of Sanctuary Rank 1
  200.             player->LearnSpell(25899, false);
  201.  
  202.         /* Devido ao bug de paladin nesta nova core que tem duas [Seal of Righteousness]
  203.         Não achei outra  forma de resolver este bug dessa nova core 11/09/2014.
  204.         Esta spell abaixo é somente para remover o bug dessa core 11/09/2014. As cores anteriores não tem este bug.
  205.         */      // Remover Bug: [Seal of Righteousness]
  206.         player->RemoveSpell(20154, true); // este comando dever ser retirada se aplica este script em outras cores.
  207.         break;
  208.     case CLASS_PRIEST:
  209.         if (player->HasSpell(34914)) //Vampiric Touch Rank 1
  210.             player->LearnSpell(48160, false);
  211.  
  212.         if (player->HasSpell(47540)) //Penance Rank 1
  213.             player->LearnSpell(53007, false);
  214.  
  215.         if (player->HasSpell(724)) //LightWell Rank 1
  216.             player->LearnSpell(48087, false);
  217.  
  218.         if (player->HasSpell(19236)) //Desperate Prayer Rank 1
  219.             player->LearnSpell(48173, false);
  220.  
  221.         if (player->HasSpell(34861)) //Circle Of healing Rank 1
  222.             player->LearnSpell(48089, false);
  223.  
  224.         if (player->HasSpell(15407)) //Mind Flay Rank 1
  225.             player->LearnSpell(48156, false);
  226.  
  227.         player->LearnSpell(1180, false); // Weapon Daggers
  228.         break;
  229.     case CLASS_ROGUE:
  230.         for (int i = 0; i < 6; i++)
  231.         {
  232.             player->LearnSpell(SRestante[6][i], false);
  233.         }
  234.         if (player->HasSpell(16511)) //Hemorrhage Rank 1
  235.             player->LearnSpell(48660, false);
  236.  
  237.         if (player->HasSpell(1329)) //Mutilate Rank 1
  238.             player->LearnSpell(48666, false);
  239.         break;
  240.     case CLASS_SHAMAN:
  241.         for (int i = 0; i < 10; i++)
  242.         {
  243.             player->LearnSpell(SRestante[7][i], false);
  244.         }
  245.         if (player->GetTeam() == ALLIANCE)
  246.         {
  247.             player->LearnSpell(32182, false);
  248.         }
  249.         else{ // Horde
  250.             player->LearnSpell(2825, false);
  251.         }
  252.         if (player->HasSpell(61295)) //Riptide Rank 1
  253.             player->LearnSpell(61301, false);
  254.  
  255.         if (player->HasSpell(974)) //Earth Shield Rank 1
  256.             player->LearnSpell(49284, false);
  257.  
  258.         if (player->HasSpell(30706)) //Totem of Wrath Rank 1
  259.             player->LearnSpell(57722, false);
  260.  
  261.         if (player->HasSpell(51490)) //TunderStorm Rank 1
  262.             player->LearnSpell(59159, false);
  263.         break;
  264.     case CLASS_WARLOCK:
  265.         for (int i = 0; i < 6; i++)
  266.         {
  267.             player->LearnSpell(SRestante[8][i], false);
  268.         }
  269.         if (player->HasSpell(17877)) //ShadowBurn Rank 1
  270.             player->LearnSpell(47827, false);
  271.  
  272.         if (player->HasSpell(30283)) //ShadowFury Rank 1
  273.             player->LearnSpell(47847, false);
  274.  
  275.         if (player->HasSpell(50796)) //Chaos Bolt Rank 1
  276.             player->LearnSpell(59172, false);
  277.  
  278.         if (player->HasSpell(30108)) //Unstable Affliction Rank 1
  279.             player->LearnSpell(47843, false);
  280.  
  281.         if (player->HasSpell(48181)) //Spell Haunt Rank 1
  282.             player->LearnSpell(59164, false);
  283.  
  284.         if (player->HasSpell(18220)) //Dark Pact Rank 1
  285.             player->LearnSpell(59092, false);
  286.         break;
  287.     default:
  288.         break;
  289.     }
  290.     return true;
  291. }
  292.  
  293. bool TreinarSpell_autoEquipe(Player* player, uint8 plevelup)
  294. {  
  295.     if (plevelup == player->getLevel() + 1)
  296.         return true;
  297.     ChrClassesEntry const* classEntry = sChrClassesStore.LookupEntry(player->GetSession()->GetPlayer()->getClass());
  298.     if (!classEntry)
  299.         return true;
  300.     uint32 family = classEntry->spellfamily;
  301.  
  302.     for (uint32 i = 0; i < sSkillLineAbilityStore.GetNumRows(); ++i)
  303.     {
  304.         SkillLineAbilityEntry const* entry = sSkillLineAbilityStore.LookupEntry(i);
  305.         if (!entry)
  306.             continue;
  307.  
  308.         SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(entry->spellId);
  309.         if (!spellInfo) continue;
  310.  
  311.         // skip server-side/triggered spells
  312.         if (spellInfo->SpellLevel == 0) continue;
  313.  
  314.         // skip wrong class/race skills
  315.         if (!player->GetSession()->GetPlayer()->IsSpellFitByClassAndRace(spellInfo->Id)) continue;
  316.  
  317.         // skip other spell families
  318.         if (spellInfo->SpellFamilyName != family) continue;
  319.  
  320.         // Pulas spells não validas ou spell de talentos que não poder ser treinado de imediato
  321.         // OBS: Lembre de quando distripuir seus talentos volte no npc para treinar as spell de talentos...
  322.         if (GetSpellIguinorar(spellInfo->Id))   continue;
  323.  
  324.         // skip spells with first rank learned as talent (and all talents then also)
  325.         if (GetTalentSpellCost(spellInfo->GetFirstRankSpell()->Id) > 0) continue;
  326.  
  327.         // skip broken spells
  328.         if (!SpellMgr::IsSpellValid(spellInfo, player->GetSession()->GetPlayer(), false)) continue;
  329.  
  330.         // Spell Restante e Spell de Talentos
  331.         if (!SpellsRestante(player, plevelup)) continue;
  332.  
  333.         // Não inclui Teleports, mounts and other spells.
  334.         if ((spellInfo->AttributesEx7 & SPELL_ATTR7_HORDE_ONLY && player->GetTeam() != HORDE)
  335.             || (spellInfo->AttributesEx7 & SPELL_ATTR7_ALLIANCE_ONLY && player->GetTeam() != ALLIANCE)) continue;
  336.  
  337.         // Add spell de acordo com o level. Skip spell level inválido
  338.         if (spellInfo->BaseLevel != plevelup && sSpellMgr->IsSpellValid(spellInfo, player)) continue;
  339.  
  340.         bool VAbilidades = false;
  341.         SkillLineAbilityMapBounds Limitar = sSpellMgr->GetSkillLineAbilityMapBounds(spellInfo->Id);
  342.         for (SkillLineAbilityMap::const_iterator itr = Limitar.first; itr != Limitar.second; ++itr)
  343.         {
  344.             if (itr->second->spellId == spellInfo->Id && itr->second->racemask == 0 && itr->second->AutolearnType == 0)
  345.             {
  346.                 VAbilidades = true;
  347.                 SpellInfo const* prevSpell = spellInfo->GetPrevRankSpell();
  348.                 if (prevSpell && !player->HasSpell(prevSpell->Id))
  349.                 {
  350.                     VAbilidades = false;
  351.                     break;
  352.                 }
  353.                 if (GetTalentSpellPos(itr->second->spellId))
  354.                 if (!prevSpell || !player->HasSpell(prevSpell->Id) || spellInfo->GetRank() == 1)
  355.                     VAbilidades = false;
  356.                 break;
  357.             }
  358.         }
  359.         if (VAbilidades){
  360.             if (player->HasSpell(spellInfo->Id)) continue;
  361.             player->GetSession()->GetPlayer()->LearnSpell(spellInfo->Id, false);
  362.         }
  363.     }
  364.     TreinarSpell_autoEquipe(player, ++plevelup); // Add spell de acordo com o level
  365.     //player->UpdateAllStats();
  366.     player->UpdateSkillsToMaxSkillsForLevel();
  367.     player->CastSpell(player, 47445, false); // Spell só para visual      
  368.     return true;
  369. }
  370.  
  371. uint32 Tipo_de_Talentos = 0; // spec 1,2,3
  372. struct LearnTalentosData
  373. {  
  374.     uint32 spellTalentos;
  375.     uint32 pClass;
  376.     uint32 pTalentoTipo;
  377. };
  378. std::vector<LearnTalentosData> LearnTalentosLista;
  379. bool CarregarAutoEquipeSpellTalentos()
  380. {
  381.     LearnTalentosLista.clear();
  382.  
  383.     TC_LOG_INFO("server.loading", "Carregando spellTalentos para AutoEquipe...");
  384.     uint32 sMSTime = getMSTime();
  385.  
  386.     QueryResult resultados = CharacterDatabase.PQuery("SELECT pTalentoTipo, spellTalentos, pClass FROM `character_talent_autoequipe`");
  387.     if (!resultados)
  388.         return true;
  389.     uint16 contador = 0;
  390.     do
  391.     {
  392.         Field* fields = resultados->Fetch();
  393.         LearnTalentosData SpellTalents;
  394.         SpellTalents.pTalentoTipo = fields[0].GetUInt32();
  395.         SpellTalents.spellTalentos = fields[1].GetUInt32();
  396.         SpellTalents.pClass = fields[2].GetUInt32();
  397.  
  398.         LearnTalentosLista.push_back(SpellTalents);
  399.         ++contador;
  400.     } while (resultados->NextRow());
  401.  
  402.     TC_LOG_INFO("server.loading", ">> Carregadas %u spellTalentos para AutoEquipe em %u ms", contador, GetMSTimeDiffToNow(sMSTime));
  403.  
  404.     return true;
  405. }
  406.  
  407. bool LearnTalentos(Player* player) //, uint32 acao)
  408. {
  409.     uint32 pClass = player->getClassMask();
  410.    
  411.     player->ResetTalents();
  412.     //player->SetFreeTalentPoints(player->CalculateTalentsPoints());
  413.  
  414.     for (uint32 i = 0; i < LearnTalentosLista.size(); ++i)
  415.     {
  416.         LearnTalentosData &SpellTalents = LearnTalentosLista[i];
  417.                        
  418.         if (!(SpellTalents.pClass & pClass)) continue;
  419.  
  420.         if (!(SpellTalents.pTalentoTipo == Tipo_de_Talentos)) continue;
  421.  
  422.         player->RemoveSpell(SpellTalents.spellTalentos, true, false);
  423.  
  424.         //if (player->HasTalent(SpellTalents.spellTalentos, 0)) continue;
  425.  
  426.         player->AddTalent(SpellTalents.spellTalentos,0,true);
  427.         player->LearnSpell(SpellTalents.spellTalentos,false);
  428.     }
  429.     player->SetFreeTalentPoints(0);
  430.  
  431.     Tipo_de_Talentos = NULL;
  432.     return true;
  433.  
  434. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement