SHOW:
|
|
- or go back to the newest paste.
| 1 | // Made by Rochet2 | |
| 2 | - | #include "ScriptPCH.h" |
| 2 | + | #include "Common.h" |
| 3 | #include "ScriptMgr.h" | |
| 4 | #include "Creature.h" | |
| 5 | #include "Player.h" | |
| 6 | #include "ScriptedGossip.h" | |
| 7 | #include "Pet.h" | |
| 8 | #include "World.h" | |
| 9 | #include "Log.h" | |
| 10 | ||
| 11 | ||
| 12 | class PRESTIGE_NPC : public CreatureScript | |
| 13 | {
| |
| 14 | public: | |
| 15 | PRESTIGE_NPC() : CreatureScript("PRESTIGE_NPC") { }
| |
| 16 | ||
| 17 | bool OnGossipHello(Player* player, Creature* creature) | |
| 18 | {
| |
| 19 | player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_CHAT, "Exchange level 80 to 100k gold", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2, "WARNING!\nThis will reset your level to 1", 0, false); | |
| 20 | player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Nevermind", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); | |
| 21 | player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID()); | |
| 22 | return true; | |
| 23 | } | |
| 24 | ||
| 25 | bool OnGossipSelect(Player* player, Creature* creature, uint32 sender, uint32 action) | |
| 26 | {
| |
| 27 | player->PlayerTalkClass->ClearMenus(); | |
| 28 | player->CLOSE_GOSSIP_MENU(); | |
| 29 | if (sender == GOSSIP_SENDER_MAIN && action == GOSSIP_ACTION_INFO_DEF + 2) | |
| 30 | {
| |
| 31 | if (player->getLevel() != 80) | |
| 32 | player->GetSession()->SendNotification("You need to be level 80");
| |
| 33 | else | |
| 34 | {
| |
| 35 | if (ResetPlayerLevel(player)) | |
| 36 | {
| |
| 37 | player->ModifyMoney(1000000000); | |
| 38 | for (uint8 slot = SLOT_HEAD; slot < SLOT_EMPTY; slot++) | |
| 39 | {
| |
| 40 | if (player->CanUseItem(player->GetItemByPos(NULL_BAG, slot)) != EQUIP_ERR_OK) | |
| 41 | player->SetVisibleItemSlot(slot, NULL); | |
| 42 | } | |
| 43 | player->GetSession()->LogoutPlayer(true); | |
| 44 | } | |
| 45 | else | |
| 46 | player->GetSession()->SendNotification("ERROR: can not reset level");
| |
| 47 | } | |
| 48 | } | |
| 49 | return true; | |
| 50 | } | |
| 51 | ||
| 52 | bool ResetPlayerLevel(Player* player) | |
| 53 | {
| |
| 54 | if (!HandleResetStatsOrLevelHelper(player)) | |
| 55 | return false; | |
| 56 | ||
| 57 | uint8 oldLevel = player->getLevel(); | |
| 58 | ||
| 59 | // set starting level | |
| 60 | uint32 startLevel = player->getClass() != CLASS_DEATH_KNIGHT | |
| 61 | ? sWorld->getIntConfig(CONFIG_START_PLAYER_LEVEL) | |
| 62 | : sWorld->getIntConfig(CONFIG_START_HEROIC_PLAYER_LEVEL); | |
| 63 | ||
| 64 | - | player->resetSpells(true); |
| 64 | + | |
| 65 | player->SetLevel(startLevel); | |
| 66 | player->InitRunes(); | |
| 67 | player->InitStatsForLevel(true); | |
| 68 | player->InitTaxiNodesForLevel(); | |
| 69 | player->InitGlyphsForLevel(); | |
| 70 | player->InitTalentForLevel(); | |
| 71 | player->SetUInt32Value(PLAYER_XP, 0); | |
| 72 | player->ResetSpells(true); | |
| 73 | ||
| 74 | player->_ApplyAllLevelScaleItemMods(true); | |
| 75 | ||
| 76 | // reset level for pet | |
| 77 | if (Pet* pet = player->GetPet()) | |
| 78 | pet->SynchronizeLevelWithOwner(); | |
| 79 | ||
| 80 | sScriptMgr->OnPlayerLevelChanged(player, oldLevel); | |
| 81 | - | sLog->outError("Class %u not found in DBC (Wrong DBC files?)", player->getClass());
|
| 81 | + | |
| 82 | } | |
| 83 | ||
| 84 | bool HandleResetStatsOrLevelHelper(Player* player) | |
| 85 | {
| |
| 86 | ChrClassesEntry const* classEntry = sChrClassesStore.LookupEntry(player->getClass()); | |
| 87 | if (!classEntry) | |
| 88 | {
| |
| 89 | TC_LOG_ERROR("misc", "Class %u not found in DBC (Wrong DBC files?)", player->getClass());
| |
| 90 | return false; | |
| 91 | } | |
| 92 | ||
| 93 | uint8 powerType = classEntry->powerType; | |
| 94 | ||
| 95 | // reset m_form if no aura | |
| 96 | if (!player->HasAuraType(SPELL_AURA_MOD_SHAPESHIFT)) | |
| 97 | player->SetShapeshiftForm(FORM_NONE); | |
| 98 | ||
| 99 | player->SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, DEFAULT_WORLD_OBJECT_SIZE); | |
| 100 | player->SetFloatValue(UNIT_FIELD_COMBATREACH, DEFAULT_COMBAT_REACH); | |
| 101 | ||
| 102 | player->setFactionForRace(player->getRace()); | |
| 103 | ||
| 104 | player->SetUInt32Value(UNIT_FIELD_BYTES_0, ((player->getRace()) | (player->getClass() << 8) | (player->getGender() << 16) | (powerType << 24))); | |
| 105 | ||
| 106 | // reset only if player not in some form; | |
| 107 | if (player->GetShapeshiftForm() == FORM_NONE) | |
| 108 | player->InitDisplayIds(); | |
| 109 | ||
| 110 | player->SetByteValue(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP); | |
| 111 | ||
| 112 | player->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE); | |
| 113 | ||
| 114 | //-1 is default value | |
| 115 | player->SetUInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX, uint32(-1)); | |
| 116 | ||
| 117 | //player->SetUInt32Value(PLAYER_FIELD_BYTES, 0xEEE00000); | |
| 118 | return true; | |
| 119 | } | |
| 120 | }; | |
| 121 | ||
| 122 | void AddSC_PRESTIGE_NPC() | |
| 123 | {
| |
| 124 | new PRESTIGE_NPC(); | |
| 125 | } |