Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Made by Rochet2
- #include "Common.h"
- #include "ScriptMgr.h"
- #include "Creature.h"
- #include "Player.h"
- #include "ScriptedGossip.h"
- #include "Pet.h"
- #include "World.h"
- #include "Log.h"
- class PRESTIGE_NPC : public CreatureScript
- {
- public:
- PRESTIGE_NPC() : CreatureScript("PRESTIGE_NPC") { }
- bool OnGossipHello(Player* player, Creature* creature)
- {
- 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);
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Nevermind", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
- player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
- return true;
- }
- bool OnGossipSelect(Player* player, Creature* creature, uint32 sender, uint32 action)
- {
- player->PlayerTalkClass->ClearMenus();
- player->CLOSE_GOSSIP_MENU();
- if (sender == GOSSIP_SENDER_MAIN && action == GOSSIP_ACTION_INFO_DEF + 2)
- {
- if (player->getLevel() != 80)
- player->GetSession()->SendNotification("You need to be level 80");
- else
- {
- if (ResetPlayerLevel(player))
- {
- player->ModifyMoney(1000000000);
- for (uint8 slot = SLOT_HEAD; slot < SLOT_EMPTY; slot++)
- {
- if (player->CanUseItem(player->GetItemByPos(NULL_BAG, slot)) != EQUIP_ERR_OK)
- player->SetVisibleItemSlot(slot, NULL);
- }
- player->GetSession()->LogoutPlayer(true);
- }
- else
- player->GetSession()->SendNotification("ERROR: can not reset level");
- }
- }
- return true;
- }
- bool ResetPlayerLevel(Player* player)
- {
- if (!HandleResetStatsOrLevelHelper(player))
- return false;
- uint8 oldLevel = player->getLevel();
- // set starting level
- uint32 startLevel = player->getClass() != CLASS_DEATH_KNIGHT
- ? sWorld->getIntConfig(CONFIG_START_PLAYER_LEVEL)
- : sWorld->getIntConfig(CONFIG_START_HEROIC_PLAYER_LEVEL);
- player->_ApplyAllLevelScaleItemMods(false);
- player->SetLevel(startLevel);
- player->InitRunes();
- player->InitStatsForLevel(true);
- player->InitTaxiNodesForLevel();
- player->InitGlyphsForLevel();
- player->InitTalentForLevel();
- player->SetUInt32Value(PLAYER_XP, 0);
- player->ResetSpells(true);
- player->_ApplyAllLevelScaleItemMods(true);
- // reset level for pet
- if (Pet* pet = player->GetPet())
- pet->SynchronizeLevelWithOwner();
- sScriptMgr->OnPlayerLevelChanged(player, oldLevel);
- return true;
- }
- bool HandleResetStatsOrLevelHelper(Player* player)
- {
- ChrClassesEntry const* classEntry = sChrClassesStore.LookupEntry(player->getClass());
- if (!classEntry)
- {
- TC_LOG_ERROR("misc", "Class %u not found in DBC (Wrong DBC files?)", player->getClass());
- return false;
- }
- uint8 powerType = classEntry->powerType;
- // reset m_form if no aura
- if (!player->HasAuraType(SPELL_AURA_MOD_SHAPESHIFT))
- player->SetShapeshiftForm(FORM_NONE);
- player->SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, DEFAULT_WORLD_OBJECT_SIZE);
- player->SetFloatValue(UNIT_FIELD_COMBATREACH, DEFAULT_COMBAT_REACH);
- player->setFactionForRace(player->getRace());
- player->SetUInt32Value(UNIT_FIELD_BYTES_0, ((player->getRace()) | (player->getClass() << 8) | (player->getGender() << 16) | (powerType << 24)));
- // reset only if player not in some form;
- if (player->GetShapeshiftForm() == FORM_NONE)
- player->InitDisplayIds();
- player->SetByteValue(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP);
- player->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE);
- //-1 is default value
- player->SetUInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX, uint32(-1));
- //player->SetUInt32Value(PLAYER_FIELD_BYTES, 0xEEE00000);
- return true;
- }
- };
- void AddSC_PRESTIGE_NPC()
- {
- new PRESTIGE_NPC();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement