Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //This function is called just before the players level changes
- void OnPlayerLevelChanged(Player* player, uint8 oldLevel, uint8 newLevel)
- {
- // Define newlevel, trainderID, teamID
- uint32 newlevel = newLevel;
- uint32 trainerID;
- uint32 teamID = player->GetTeamId();
- // Select the correct trainer for class and faction
- switch (player->getClass())
- {
- case CLASS_WARRIOR:
- if (teamID == TEAM_ALLIANCE)
- {
- trainerID = 17504;
- } else
- trainerID = 985;
- break;
- case CLASS_ROGUE:
- if (teamID == TEAM_ALLIANCE)
- {
- trainerID = 13283;
- }
- else
- trainerID = 3401;
- break;
- case CLASS_SHAMAN:
- if (teamID == TEAM_ALLIANCE)
- {
- trainerID = 20407;
- }
- else
- trainerID = 13417;
- break;
- case CLASS_PRIEST:
- if (teamID == TEAM_ALLIANCE)
- {
- trainerID = 11406;
- }
- else
- trainerID = 16658;
- break;
- case CLASS_MAGE:
- if (teamID == TEAM_ALLIANCE)
- {
- trainerID = 7312;
- }
- else
- trainerID = 16653;
- break;
- case CLASS_WARLOCK:
- if (teamID == TEAM_ALLIANCE)
- {
- trainerID = 5172;
- }
- else
- trainerID = 16648;
- break;
- case CLASS_HUNTER:
- if (teamID == TEAM_ALLIANCE)
- {
- trainerID = 5516;
- }
- else
- trainerID = 3039;
- break;
- case CLASS_DRUID:
- if (teamID == TEAM_ALLIANCE)
- {
- trainerID = 5504;
- }
- else
- trainerID = 16655;
- break;
- case CLASS_PALADIN:
- if (teamID == TEAM_ALLIANCE)
- {
- trainerID = 20407;
- }
- else
- trainerID = 16681;
- break;
- }
- QueryResult_AutoPtr result = WorldDatabase.PQuery("SELECT spell FROM npc_trainer WHERE reqlevel BETWEEN 1 AND %i AND entry = %i", newlevel, trainerID);
- if (!result)
- {
- return;
- }
- do
- {
- Field* fields = result->Fetch();
- uint32 spellID = fields[0].GetUInt32();
- SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellID);
- if (!spellInfo)
- continue;
- // skip wrong class/race skills
- if (!player->IsSpellFitByClassAndRace(spellInfo->Id))
- continue;
- // Skip known spells
- if (player->HasSpell(spellInfo->Id))
- continue;
- // skip spells with first rank learned as talent (and all talents then also)
- if (GetTalentSpellCost(sSpellMgr.GetFirstSpellInChain(spellInfo->Id)) > 0)
- continue;
- // skip broken spells
- if (!SpellMgr::IsSpellValid(spellInfo, player, false))
- continue;
- player->LearnSpell(spellInfo->Id);
- } while (result->NextRow());
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement