Advertisement
Guest User

Untitled

a guest
Aug 26th, 2013
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1. #include "ScriptPCH.h"
  2. #define TYPE_NON_COMBAT_PET 12
  3. class remover : public WorldScript
  4. {
  5. public:
  6. remover() : WorldScript("remover") {}
  7. void OnStartup()
  8. {
  9. SpellInfoMap spellInfo;
  10. spellInfo.resize(sSpellStore.GetNumRows(), NULL);
  11. for(int i = 0; i < sSpellStore.GetNumRows(); ++i)
  12. {
  13. if (SpellEntry const* spellEntry = sSpellStore.LookupEntry(i))
  14. spellInfo[i] = new SpellInfo(spellEntry);
  15. }
  16.  
  17. sLog->outError(LOG_FILTER_GENERAL, "loaded %u spells, checking for all mounting spells...", spellInfo.size());
  18.  
  19. std::vector<uint32> mountedSpells;
  20.  
  21. for(SpellInfoMap::iterator itr = spellInfo.begin(); itr != spellInfo.end(); ++itr)
  22. {
  23. for(int i = 0; i < MAX_SPELL_EFFECTS; ++i)
  24. if(*itr && (*itr)->Effects[i].ApplyAuraName == SPELL_AURA_MOUNTED)
  25. mountedSpells.push_back((*itr)->Id);
  26. }
  27.  
  28. sLog->outError(LOG_FILTER_GENERAL, "Found %u mounted spells, removing these spells from players...", mountedSpells.size());
  29.  
  30. uint32 counter = 0;
  31.  
  32. for(std::vector<uint32>::iterator itr = mountedSpells.begin(); itr != mountedSpells.end(); ++itr)
  33. {
  34. QueryResult result = CharacterDatabase.PQuery("SELECT * FROM `character_spell` WHERE `spell` = %u", *itr);
  35. if(!result)
  36. continue;
  37. CharacterDatabase.PExecute("DELETE FROM `character_spell` WHERE `spell` = %u", *itr);
  38. ++counter;
  39. }
  40.  
  41. sLog->outError(LOG_FILTER_GENERAL, "Removed %u spell(s) from characters", counter);
  42.  
  43. counter = 0;
  44.  
  45. sLog->outError(LOG_FILTER_GENERAL, "Checking for companions...");
  46.  
  47. std::vector<uint32> companionSpells;
  48.  
  49. for(SpellInfoMap::iterator itr = spellInfo.begin(); itr != spellInfo.end(); ++itr)
  50. {
  51. if(SpellEntry const* spellEntry = sSpellStore.LookupEntry((*itr)->Id))
  52. {
  53. for(int i = 0; i < 3; ++i)
  54. {
  55. if(const CreatureTemplate* creatureTemplate = sObjectMgr->GetCreatureTemplate(spellEntry->EffectMiscValue[i]))
  56. if(creatureTemplate->type == TYPE_NON_COMBAT_PET)
  57. companionSpells.push_back((*itr)->Id);
  58. }
  59. }
  60. }
  61.  
  62. sLog->outError(LOG_FILTER_GENERAL, "Found %u companion spells, removing them from every character..", companionSpells.size());
  63.  
  64. for(std::vector<uint32>::iterator itr = companionSpells.begin(); itr != companionSpells.end(); ++itr)
  65. {
  66. QueryResult result = CharacterDatabase.PQuery("SELECT * FROM `character_spell` WHERE `spell` = %u", *itr);
  67. if(!result)
  68. continue;
  69. CharacterDatabase.PExecute("DELETE FROM `character_spell` WHERE `spell` = %u", *itr);
  70. ++counter;
  71. }
  72.  
  73. sLog->outError(LOG_FILTER_GENERAL, "Removed %u spell(s) from characters", counter);
  74. }
  75. };
  76.  
  77. void AddSC_remover()
  78. {
  79. new remover;
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement