Advertisement
Guest User

asdasd

a guest
Apr 24th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.89 KB | None | 0 0
  1. @@ -4783,11 +4783,12 @@ class npc_class_reminder : public CreatureScript
  2.  
  3.          enum GossipMenuOptions
  4.          {
  5.              GOSSIP_REWARD_ACHIEVEMENT       = GOSSIP_ACTION_INFO_DEF + 1,
  6.              GOSSIP_FIX_FACTIONCHANGE_QUESTS = GOSSIP_ACTION_INFO_DEF + 2,
  7. -            GOSSIP_FIX_FACTIONCHANGE_ITEMS  = GOSSIP_ACTION_INFO_DEF + 3
  8. +            GOSSIP_FIX_FACTIONCHANGE_ITEMS  = GOSSIP_ACTION_INFO_DEF + 3,
  9. +            GOSSIP_FIX_ART_ITEMS            = GOSSIP_ACTION_INFO_DEF + 4
  10.          };
  11.  
  12.          enum eAchievements
  13.          {
  14.              ImprovingOnHistory = 10459
  15. @@ -4818,15 +4819,95 @@ class npc_class_reminder : public CreatureScript
  16.  
  17.              p_Player->PlayerTalkClass->SendCloseGossip();
  18.              return true;
  19.          }
  20.  
  21. +        bool OnGossipSelect(Player* p_Player, Creature* p_Creature, uint32 p_Sender, uint32 p_Action) override
  22. +        {
  23. +            p_Player->PlayerTalkClass->ClearMenus();
  24. +            if (p_Sender == eTradeskill::GOSSIP_SENDER_MAIN)
  25. +            {
  26. +                switch (p_Action)
  27. +                {
  28. +                    case GossipMenuOptions::GOSSIP_FIX_ART_ITEMS:
  29. +                    {
  30. +                        std::map<uint32 /* player spec*/, std::pair<uint32 /*child*/, uint32 /*main*/> > data;
  31. +
  32. +                        data[SpecIndex::SPEC_DEMON_HUNTER_VENGEANCE] = std::make_pair(127830, 127829);
  33. +                        data[SpecIndex::SPEC_WARRIOR_PROTECTION] = std::make_pair(128288, 128289);
  34. +                        data[SpecIndex::SPEC_DK_FROST] = std::make_pair(128293, 128292);
  35. +                        data[SpecIndex::SPEC_ROGUE_SUBTLETY] = std::make_pair(128479, 128476);
  36. +                        data[SpecIndex::SPEC_DRUID_GUARDIAN] = std::make_pair(128822, 128821);
  37. +                        data[SpecIndex::SPEC_DEMON_HUNTER_HAVOC] = std::make_pair(128831, 128832);
  38. +                        data[SpecIndex::SPEC_DRUID_FERAL] = std::make_pair(128859, 128860);
  39. +                        data[SpecIndex::SPEC_PALADIN_PROTECTION] = std::make_pair(128867, 128866);
  40. +                        data[SpecIndex::SPEC_ROGUE_ASSASSINATION] = std::make_pair(128869, 128870);
  41. +                        data[SpecIndex::SPEC_SHAMAN_ENHANCEMENT] = std::make_pair(128873, 128819);
  42. +                        data[SpecIndex::SPEC_SHAMAN_RESTORATION] = std::make_pair(128934, 128911);
  43. +                        data[SpecIndex::SPEC_SHAMAN_ELEMENTAL] = std::make_pair(128936, 128935);
  44. +                        data[SpecIndex::SPEC_MONK_WINDWALKER] = std::make_pair(133948, 128940);
  45. +                        data[SpecIndex::SPEC_PRIEST_SHADOW] = std::make_pair(128827, 133958);
  46. +                        data[SpecIndex::SPEC_ROGUE_OUTLAW] = std::make_pair(134552, 128872);
  47. +                        data[SpecIndex::SPEC_WARRIOR_FURY] = std::make_pair(128908, 134553);
  48. +                        data[SpecIndex::SPEC_WARLOCK_DEMONOLOGY] = std::make_pair(137246, 128943);
  49. +
  50. +
  51. +                        auto itr = data.find(p_Player->GetActiveSpecializationID());
  52. +                        if (itr == data.end())
  53. +                        {
  54. +                            ChatHandler(p_Player).PSendSysMessage("Cannot find your spec");
  55. +                            break;
  56. +                        }
  57. +
  58. +                        if (p_Player->GetItemCount(itr->second.second) != 1)
  59. +                        {
  60. +                            ChatHandler(p_Player).PSendSysMessage("You have no or more than one main items");
  61. +                            break;
  62. +                        }
  63. +
  64. +                        std::list<Item*> items;
  65. +                        GetAllItems(p_Player, itr->second.first, items);
  66. +                        if (items.empty())
  67. +                        {
  68. +                            ChatHandler(p_Player).PSendSysMessage("You have no child items");
  69. +                            break;
  70. +                        }
  71. +
  72. +                        Item* l_MainItem = p_Player->GetItemByEntry(itr->second.second);
  73. +                        if (l_MainItem == nullptr)
  74. +                        {
  75. +                            ChatHandler(p_Player).PSendSysMessage("Cannot find main item");
  76. +                            break;
  77. +                        }
  78. +                      
  79. +                       std::ostringstream ss;
  80. +                       for (Item* p_ChildItem : items)
  81. +                       {
  82. +                           if (p_ChildItem->HasFlag(ITEM_FIELD_DYNAMIC_FLAGS, ITEM_FIELD_FLAG_CHILD)
  83. +                             && p_ChildItem->GetGuidValue(ITEM_FIELD_CREATOR) != 0
  84. +                             && p_ChildItem->GetGuidValue(ITEM_FIELD_CREATOR) != l_MainItem->GetGUID())
  85. +                            {
  86. +                                ss << "Update " << p_ChildItem->GetGUID() << " creator " << l_MainItem->GetGUID();  
  87. +                                p_ChildItem->SetGuidValue(ITEM_FIELD_CREATOR,
  88. +                                    l_MainItem->GetGUID());
  89. +                                p_ChildItem->SetState(ITEM_CHANGED, p_Player);
  90. +                            }
  91. +                        }
  92. +                        
  93. +                        p_Player->SaveToDB();
  94. +                        sLog->outError(LOG_FILTER_GENERAL, ss.str().c_str());
  95. +                        p_Player->AddDelayedEvent([p_Player]() -> void
  96. +                        {
  97. +                            p_Player->GetSession()->KickPlayer();
  98. +                        }, 1000);
  99. +
  100. +                        break;
  101. +                    }
  102. +                    default:
  103. +                        break;
  104. +                }
  105. +            }
  106. +
  107. +            p_Player->PlayerTalkClass->SendCloseGossip();
  108. +            return true;
  109. +        }
  110. +
  111. +        void GetAllItems(Player* p_Player, uint32 p_Entry, std::list<Item*>& p_Items) const
  112. +        {
  113. +            // in inventory
  114. +            for (int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; ++i)
  115. +                if (Item* pItem = p_Player->GetItemByPos(INVENTORY_SLOT_BAG_0, i))
  116. +                    if (pItem->GetEntry() == p_Entry)
  117. +                        p_Items.push_back(pItem);
  118. +
  119. +            for (int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i)
  120. +            if (Bag* pBag = p_Player->GetBagByPos(i))
  121. +                for (uint32 j = 0; j < pBag->GetBagSize(); ++j)
  122. +                    if (Item* pItem = pBag->GetItemByPos(j))
  123. +                        if (pItem->GetEntry() == p_Entry)
  124. +                            p_Items.push_back(pItem);
  125. +
  126. +            for (int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_BAG_END; ++i)
  127. +                if (Item* pItem = p_Player->GetItemByPos(INVENTORY_SLOT_BAG_0, i))
  128. +                    if (pItem->GetEntry() == p_Entry)
  129. +                        p_Items.push_back(pItem);
  130. +
  131. +            for (uint8 i = CHILD_EQUIPMENT_SLOT_START; i < CHILD_EQUIPMENT_SLOT_END; ++i)
  132. +                if (Item* pItem = p_Player->GetItemByPos(INVENTORY_SLOT_BAG_0, i))
  133. +                    if (pItem->GetEntry() == p_Entry)
  134. +                        p_Items.push_back(pItem);
  135. +        }
  136. +
  137.          bool OnGossipHello(Player* p_Player, Creature* p_Creature) override
  138.          {
  139.              if (p_Player->getLevel() > 10)
  140.              {
  141.                  p_Player->ADD_GOSSIP_ITEM_EXTENDED(GossipOptionIcon::GOSSIP_ICON_CHAT, "Try to complete broken achievement.", eTradeskill::GOSSIP_SENDER_MAIN, GossipMenuOptions::GOSSIP_REWARD_ACHIEVEMENT, "Please, input a number of an achievement. ", 0, true);
  142. +                p_Player->ADD_GOSSIP_ITEM_EXTENDED(GossipOptionIcon::GOSSIP_ICON_CHAT, "Try to fix items after merging.", eTradeskill::GOSSIP_SENDER_MAIN, GossipMenuOptions::GOSSIP_FIX_ART_ITEMS, "You should have an active spec for the artifact weapon. You will be disconnected after the fix. Continue?", 1, false);
  143.              }
  144.  
  145.              p_Player->SEND_GOSSIP_MENU(p_Player->GetGossipTextId(p_Creature), p_Creature->GetGUID());
  146.              return true;
  147.          };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement