diff --git a/src/game/DBCStructure.h b/src/game/DBCStructure.h index 421079593..44c54e69b 100644 --- a/src/game/DBCStructure.h +++ b/src/game/DBCStructure.h @@ -1456,7 +1456,7 @@ struct SpellEntry //uint32 SpellDifficultyId; // 239 3.3.0 // helpers - int32 CalculateSimpleValue(SpellEffectIndex eff) const { return EffectBasePoints[eff]+int32(1); } + int32 CalculateSimpleValue(SpellEffectIndex eff) const { return EffectBasePoints[eff] + int32(1); } uint32 const* GetEffectSpellClassMask(SpellEffectIndex effect) const { return EffectSpellClassMaskA + effect * 3; diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp index da73762d0..580b0c8ff 100644 --- a/src/game/Level2.cpp +++ b/src/game/Level2.cpp @@ -3989,7 +3989,7 @@ void ChatHandler::HandleLearnSkillRecipesHelper(Player* player,uint32 skill_id) if(!spellInfo || !SpellMgr::IsSpellValid(spellInfo,player,false)) continue; - player->learnSpell(skillLine->spellId, 0, false); + player->learnSpell(skillLine->spellId, false); } } @@ -4084,7 +4084,7 @@ bool ChatHandler::HandleLearnAllRecipesCommand(const char* args) HandleLearnSkillRecipesHelper(target,targetSkillInfo->id); uint16 maxLevel = target->GetPureMaxSkillValue(targetSkillInfo->id); - target->SetSkill(targetSkillInfo->id, maxLevel, maxLevel); + target->SetSkill(targetSkillInfo->id, target->GetSkillStep(targetSkillInfo->id), maxLevel, maxLevel); PSendSysMessage(LANG_COMMAND_LEARN_ALL_RECIPES, name.c_str()); return true; } diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index 57f243752..d32d12477 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -1118,7 +1118,7 @@ bool ChatHandler::HandleSetSkillCommand(const char* args) if( level <= 0 || level > max || max <= 0 ) return false; - target->SetSkill(skill, level, max); + target->SetSkill(skill, target->GetSkillStep(skill), level, max); PSendSysMessage(LANG_SET_SKILL, skill, sl->name[GetSessionDbcLocale()], tNameLink.c_str(), level, max); return true; @@ -1817,7 +1817,7 @@ bool ChatHandler::HandleLearnAllCommand(const char* /*args*/) continue; } - m_session->GetPlayer()->learnSpell(spell, 0, false); + m_session->GetPlayer()->learnSpell(spell, false); } SendSysMessage(LANG_COMMAND_LEARN_MANY_SPELLS); @@ -1857,7 +1857,7 @@ bool ChatHandler::HandleLearnAllGMCommand(const char* /*args*/) continue; } - m_session->GetPlayer()->learnSpell(spell, 0, false); + m_session->GetPlayer()->learnSpell(spell, false); } SendSysMessage(LANG_LEARNING_GM_SKILLS); @@ -1905,7 +1905,7 @@ bool ChatHandler::HandleLearnAllMySpellsCommand(const char* /*args*/) if(!SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer(),false)) continue; - m_session->GetPlayer()->learnSpell(i, 0, false); + m_session->GetPlayer()->learnSpell(i, false); } SendSysMessage(LANG_COMMAND_LEARN_CLASS_SPELLS); @@ -2037,7 +2037,7 @@ bool ChatHandler::HandleLearnAllLangCommand(const char* /*args*/) { // skipping UNIVERSAL language (0) for(int i = 1; i < LANGUAGES_COUNT; ++i) - m_session->GetPlayer()->learnSpell(lang_description[i].spell_id, 0, false); + m_session->GetPlayer()->learnSpell(lang_description[i].spell_id, false); SendSysMessage(LANG_COMMAND_LEARN_ALL_LANG); return true; @@ -2096,7 +2096,7 @@ bool ChatHandler::HandleLearnCommand(const char* args) if(allRanks) targetPlayer->learnSpellHighRank(spell); else - targetPlayer->learnSpell(spell, 0, false); + targetPlayer->learnSpell(spell, false); uint32 first_spell = sSpellMgr.GetFirstSpellInChain(spell); if(GetTalentSpellCost(first_spell)) diff --git a/src/game/NPCHandler.cpp b/src/game/NPCHandler.cpp index ce15d902d..f37c5e60e 100644 --- a/src/game/NPCHandler.cpp +++ b/src/game/NPCHandler.cpp @@ -243,11 +243,11 @@ void WorldSession::HandleTrainerBuySpellOpcode( WorldPacket & recv_data ) if(trainer_spell->IsCastable()) _player->CastSpell(_player, trainer_spell->spell, true); else - _player->learnSpell(spellId, 0, false); + _player->learnSpell(spellId, false); data.Initialize(SMSG_TRAINER_BUY_SUCCEEDED, 12); data << uint64(guid); - data << uint32(trainer_spell->spell); + data << uint32(spellId); // should be same as in packet from client SendPacket(&data); } diff --git a/src/game/Player.cpp b/src/game/Player.cpp index cf761cb24..16a64dc7f 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -3036,7 +3036,7 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen if(!IsInWorld() || disabled) // at spells loading, no output, but allow save addSpell(prev_spell, active, true, true, disabled); else // at normal learning - learnSpell(prev_spell, 0, true); + learnSpell(prev_spell, true); } PlayerSpell newspell; @@ -3133,7 +3133,7 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen } // add dependent skills - uint16 maxskill = GetMaxSkillValueForLevel(); + uint16 maxskill = GetMaxSkillValueForLevel(); SpellLearnSkillNode const* spellLearnSkill = sSpellMgr.GetSpellLearnSkill(spell_id); @@ -3152,7 +3152,7 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen if (skill_max_value < new_skill_max_value) skill_max_value = new_skill_max_value; - SetSkill(spellLearnSkill->skill,skill_value,skill_max_value); + SetSkill(spellLearnSkill->skill, spellLearnSkill->step, skill_value, skill_max_value); } else { @@ -3170,16 +3170,16 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen // lockpicking/runeforging special case, not have ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL ((pSkill->id==SKILL_LOCKPICKING || pSkill->id==SKILL_RUNEFORGING) && _spell_idx->second->max_value==0)) { - switch(GetSkillRangeType(pSkill,_spell_idx->second->racemask!=0)) + switch(GetSkillRangeType(pSkill, _spell_idx->second->racemask != 0)) { case SKILL_RANGE_LANGUAGE: - SetSkill(pSkill->id, 300, 300 ); + SetSkill(pSkill->id, GetSkillStep(pSkill->id), 300, 300 ); break; case SKILL_RANGE_LEVEL: - SetSkill(pSkill->id, 1, GetMaxSkillValueForLevel() ); + SetSkill(pSkill->id, GetSkillStep(pSkill->id), 1, GetMaxSkillValueForLevel() ); break; case SKILL_RANGE_MONO: - SetSkill(pSkill->id, 1, 1 ); + SetSkill(pSkill->id, GetSkillStep(pSkill->id), 1, 1 ); break; default: break; @@ -3198,7 +3198,7 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen if (!IsInWorld() || !itr2->second.active) // at spells loading, no output, but allow save addSpell(itr2->second.spell,itr2->second.active,true,true,false); else // at normal learning - learnSpell(itr2->second.spell, 0, true); + learnSpell(itr2->second.spell, true); } } @@ -3228,7 +3228,7 @@ bool Player::IsNeedCastPassiveSpellAtLearn(SpellEntry const* spellInfo) const return need_cast && (!spellInfo->CasterAuraState || HasAuraState(AuraState(spellInfo->CasterAuraState))); } -void Player::learnSpell(uint32 spell_id, uint32 triggeredBySpell, bool dependent) +void Player::learnSpell(uint32 spell_id, bool dependent) { PlayerSpellMap::iterator itr = m_spells.find(spell_id); @@ -3245,7 +3245,7 @@ void Player::learnSpell(uint32 spell_id, uint32 triggeredBySpell, bool dependent { PlayerSpellMap::iterator iter = m_spells.find(i->second); if (iter != m_spells.end() && iter->second.disabled) - learnSpell(i->second, 0, false); + learnSpell(i->second, false); } } @@ -3254,8 +3254,8 @@ void Player::learnSpell(uint32 spell_id, uint32 triggeredBySpell, bool dependent return; WorldPacket data(SMSG_LEARNED_SPELL, 6); - data << uint32((triggeredBySpell == 0) ? spell_id : triggeredBySpell); - data << uint16(0); + data << uint32(spell_id); + data << uint16(0); // 3.3.3 unk GetSession()->SendPacket(&data); } @@ -3272,7 +3272,7 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank, bo SpellChainMapNext const& nextMap = sSpellMgr.GetSpellChainNext(); for(SpellChainMapNext::const_iterator itr2 = nextMap.lower_bound(spell_id); itr2 != nextMap.upper_bound(spell_id); ++itr2) if(HasSpell(itr2->second) && !GetTalentSpellPos(itr2->second)) - removeSpell(itr2->second,disabled,false); + removeSpell(itr2->second, disabled, false); // re-search, it can be corrupted in prev loop itr = m_spells.find(spell_id); @@ -3327,7 +3327,7 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank, bo { uint32 prev_spell = sSpellMgr.GetPrevSpellInChain(spell_id); if(!prev_spell) // first rank, remove skill - SetSkill(spellLearnSkill->skill,0,0); + SetSkill(spellLearnSkill->skill, 0, 0, 0); else { // search prev. skill setting by spell ranks chain @@ -3339,7 +3339,7 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank, bo } if (!prevSkill) // not found prev skill setting, remove skill - SetSkill(spellLearnSkill->skill,0,0); + SetSkill(spellLearnSkill->skill, 0, 0, 0); else // set to prev. skill setting values { uint32 skill_value = GetPureSkillValue(prevSkill->skill); @@ -3353,7 +3353,7 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank, bo if (skill_max_value > new_skill_max_value) skill_max_value = new_skill_max_value; - SetSkill(prevSkill->skill,skill_value,skill_max_value); + SetSkill(prevSkill->skill, prevSkill->step, skill_value, skill_max_value); } } @@ -3372,14 +3372,14 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank, bo if(_spell_idx->second->learnOnGetSkill == ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL && pSkill->categoryId != SKILL_CATEGORY_CLASS ||// not unlearn class skills (spellbook/talent pages) // lockpicking/runeforging special case, not have ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL - ((pSkill->id==SKILL_LOCKPICKING || pSkill->id==SKILL_RUNEFORGING) && _spell_idx->second->max_value==0)) + ((pSkill->id == SKILL_LOCKPICKING || pSkill->id == SKILL_RUNEFORGING) && _spell_idx->second->max_value == 0)) { // not reset skills for professions and racial abilities - if ((pSkill->categoryId==SKILL_CATEGORY_SECONDARY || pSkill->categoryId==SKILL_CATEGORY_PROFESSION) && - (IsProfessionSkill(pSkill->id) || _spell_idx->second->racemask!=0)) + if ((pSkill->categoryId == SKILL_CATEGORY_SECONDARY || pSkill->categoryId == SKILL_CATEGORY_PROFESSION) && + (IsProfessionSkill(pSkill->id) || _spell_idx->second->racemask != 0)) continue; - SetSkill(pSkill->id, 0, 0 ); + SetSkill(pSkill->id, GetSkillStep(pSkill->id), 0, 0); } } } @@ -3401,7 +3401,7 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank, bo if (talentCosts) { if(learn_low_rank) - learnSpell(prev_id, 0, false); + learnSpell(prev_id, false); } // if ranked non-stackable spell: need activate lesser rank and update dendence state else if (cur_active && !SpellMgr::canStackSpellRanks(spellInfo) && sSpellMgr.GetSpellRank(spellInfo->Id) != 0) @@ -3420,7 +3420,7 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank, bo // now re-learn if need re-activate if (cur_active && !prev_itr->second.active && learn_low_rank) { - if (addSpell(prev_id,true,false,prev_itr->second.dependent,prev_itr->second.disabled)) + if (addSpell(prev_id, true, false, prev_itr->second.dependent, prev_itr->second.disabled)) { // downgrade spell ranks in spellbook and action bar WorldPacket data(SMSG_SUPERCEDED_SPELL, 4 + 4); @@ -5169,7 +5169,7 @@ bool Player::UpdateCraftSkill(uint32 spellid) if (spellEntry && spellEntry->Mechanic == MECHANIC_DISCOVERY) { if (uint32 discoveredSpell = GetSkillDiscoverySpell(_spell_idx->second->skillId, spellid, this)) - learnSpell(discoveredSpell, 0, false); + learnSpell(discoveredSpell, false); } uint32 craft_skill_gain = sWorld.getConfig(CONFIG_UINT32_SKILL_GAIN_CRAFTING); @@ -5454,7 +5454,7 @@ void Player::UpdateSkillsToMaxSkillsForLevel() // This functions sets a skill line value (and adds if doesn't exist yet) // To "remove" a skill line, set it's values to zero -void Player::SetSkill(uint32 id, uint16 currVal, uint16 maxVal) +void Player::SetSkill(uint16 id, uint16 step, uint16 currVal, uint16 maxVal) { if(!id) return; @@ -5466,19 +5466,19 @@ void Player::SetSkill(uint32 id, uint16 currVal, uint16 maxVal) { if(currVal) { - SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(itr->second.pos),MAKE_SKILL_VALUE(currVal,maxVal)); + SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(itr->second.pos), MAKE_SKILL_VALUE(currVal, maxVal)); if(itr->second.uState != SKILL_NEW) itr->second.uState = SKILL_CHANGED; learnSkillRewardedSpells(id, currVal); - GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL,id); - GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LEVEL,id); + GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL, id); + GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LEVEL, id); } else //remove { // clear skill fields - SetUInt32Value(PLAYER_SKILL_INDEX(itr->second.pos),0); - SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(itr->second.pos),0); - SetUInt32Value(PLAYER_SKILL_BONUS_INDEX(itr->second.pos),0); + SetUInt32Value(PLAYER_SKILL_INDEX(itr->second.pos), 0); + SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(itr->second.pos), 0); + SetUInt32Value(PLAYER_SKILL_BONUS_INDEX(itr->second.pos), 0); // mark as deleted or simply remove from map if not saved yet if(itr->second.uState != SKILL_NEW) @@ -5487,9 +5487,9 @@ void Player::SetSkill(uint32 id, uint16 currVal, uint16 maxVal) mSkillStatus.erase(itr); // remove all spells that related to this skill - for (uint32 j=0; jskillId==id) + if (pAbility->skillId == id) removeSpell(sSpellMgr.GetFirstSpellInChain(pAbility->spellId)); } } @@ -5504,14 +5504,11 @@ void Player::SetSkill(uint32 id, uint16 currVal, uint16 maxVal) sLog.outError("Skill not found in SkillLineStore: skill #%u", id); return; } - // enable unlearn button for primary professions only - if (pSkill->categoryId == SKILL_CATEGORY_PROFESSION) - SetUInt32Value(PLAYER_SKILL_INDEX(i), MAKE_PAIR32(id,1)); - else - SetUInt32Value(PLAYER_SKILL_INDEX(i), MAKE_PAIR32(id,0)); - SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i),MAKE_SKILL_VALUE(currVal,maxVal)); - GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL,id); - GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LEVEL,id); + + SetUInt32Value(PLAYER_SKILL_INDEX(i), MAKE_PAIR32(id, step)); + SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i),MAKE_SKILL_VALUE(currVal, maxVal)); + GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL, id); + GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LEVEL, id); // insert new entry or update if not deleted old entry yet if(itr != mSkillStatus.end()) @@ -5523,7 +5520,7 @@ void Player::SetSkill(uint32 id, uint16 currVal, uint16 maxVal) mSkillStatus.insert(SkillStatusMap::value_type(id, SkillStatusData(i, SKILL_NEW))); // apply skill bonuses - SetUInt32Value(PLAYER_SKILL_BONUS_INDEX(i),0); + SetUInt32Value(PLAYER_SKILL_BONUS_INDEX(i), 0); // temporary bonuses AuraList const& mModSkill = GetAurasByType(SPELL_AURA_MOD_SKILL); @@ -5553,6 +5550,18 @@ bool Player::HasSkill(uint32 skill) const return (itr != mSkillStatus.end() && itr->second.uState != SKILL_DELETED); } +uint16 Player::GetSkillStep(uint16 skill) const +{ + if(!skill) + return 0; + + SkillStatusMap::const_iterator itr = mSkillStatus.find(skill); + if(itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED) + return 0; + + return PAIR32_HIPART(GetUInt32Value(PLAYER_SKILL_INDEX(itr->second.pos))); +} + uint16 Player::GetSkillValue(uint32 skill) const { if(!skill) @@ -19214,7 +19223,7 @@ void Player::learnDefaultSpells() if(!IsInWorld()) // will send in INITIAL_SPELLS in list anyway at map add addSpell(tspell, true, true, true, false); else // but send in normal spell in game learn case - learnSpell(tspell, 0, true); + learnSpell(tspell, true); } } @@ -19331,7 +19340,7 @@ void Player::learnSkillRewardedSpells(uint32 skill_id, uint32 skill_value ) else if (!IsInWorld()) addSpell(pAbility->spellId, true, true, true, false); else - learnSpell(pAbility->spellId, 0, true); + learnSpell(pAbility->spellId, true); } } } @@ -20618,13 +20627,13 @@ bool Player::IsKnowHowFlyIn(uint32 mapid, uint32 zone) const struct DoPlayerLearnSpell { DoPlayerLearnSpell(Player& _player) : player(_player) {} - void operator() (uint32 spell_id) { player.learnSpell(spell_id, 0, false); } + void operator() (uint32 spell_id) { player.learnSpell(spell_id, false); } Player& player; }; void Player::learnSpellHighRank(uint32 spellid) { - learnSpell(spellid, 0, false); + learnSpell(spellid, false); DoPlayerLearnSpell worker(*this); sSpellMgr.doForHighRanks(spellid, worker); @@ -20715,21 +20724,21 @@ void Player::_LoadSkills(QueryResult *result) base_skill = 1; // skill mast be known and then > 0 in any case if(GetPureSkillValue (SKILL_FIRST_AID) < base_skill) - SetSkill(SKILL_FIRST_AID,base_skill, base_skill); + SetSkill(SKILL_FIRST_AID, 0, base_skill, base_skill); if(GetPureSkillValue (SKILL_AXES) < base_skill) - SetSkill(SKILL_AXES, base_skill,base_skill); + SetSkill(SKILL_AXES, 0, base_skill, base_skill); if(GetPureSkillValue (SKILL_DEFENSE) < base_skill) - SetSkill(SKILL_DEFENSE, base_skill,base_skill); + SetSkill(SKILL_DEFENSE, 0, base_skill, base_skill); if(GetPureSkillValue (SKILL_POLEARMS) < base_skill) - SetSkill(SKILL_POLEARMS, base_skill,base_skill); + SetSkill(SKILL_POLEARMS, 0, base_skill, base_skill); if(GetPureSkillValue (SKILL_SWORDS) < base_skill) - SetSkill(SKILL_SWORDS, base_skill,base_skill); + SetSkill(SKILL_SWORDS, 0, base_skill, base_skill); if(GetPureSkillValue (SKILL_2H_AXES) < base_skill) - SetSkill(SKILL_2H_AXES, base_skill,base_skill); + SetSkill(SKILL_2H_AXES, 0, base_skill, base_skill); if(GetPureSkillValue (SKILL_2H_SWORDS) < base_skill) - SetSkill(SKILL_2H_SWORDS, base_skill,base_skill); + SetSkill(SKILL_2H_SWORDS, 0, base_skill, base_skill); if(GetPureSkillValue (SKILL_UNARMED) < base_skill) - SetSkill(SKILL_UNARMED, base_skill,base_skill); + SetSkill(SKILL_UNARMED, 0, base_skill, base_skill); } } @@ -20975,7 +20984,7 @@ void Player::LearnTalent(uint32 talentId, uint32 talentRank) return; // learn! (other talent ranks will unlearned at learning) - learnSpell(spellid, 0, false); + learnSpell(spellid, false); sLog.outDetail("TalentID: %u Rank: %u Spell: %u\n", talentId, talentRank, spellid); // update free talent points diff --git a/src/game/Player.h b/src/game/Player.h index 53a06d8ce..413eaee69 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -1545,7 +1545,7 @@ class MANGOS_DLL_SPEC Player : public Unit void SendProficiency(uint8 pr1, uint32 pr2); void SendInitialSpells(); bool addSpell(uint32 spell_id, bool active, bool learning, bool dependent, bool disabled); - void learnSpell(uint32 spell_id, uint32 triggeredBySpell, bool dependent); + void learnSpell(uint32 spell_id, bool dependent); void removeSpell(uint32 spell_id, bool disabled = false, bool learn_low_rank = true, bool sendUpdate = true); void resetSpells(); void learnDefaultSpells(); @@ -1856,7 +1856,7 @@ class MANGOS_DLL_SPEC Player : public Unit void UpdateWeaponSkill (WeaponAttackType attType); void UpdateCombatSkills(Unit *pVictim, WeaponAttackType attType, bool defence); - void SetSkill(uint32 id, uint16 currVal, uint16 maxVal); + void SetSkill(uint16 id, uint16 step, uint16 currVal, uint16 maxVal); uint16 GetMaxSkillValue(uint32 skill) const; // max + perm. bonus + temp bonus uint16 GetPureMaxSkillValue(uint32 skill) const; // max uint16 GetSkillValue(uint32 skill) const; // skill value + perm. bonus + temp bonus @@ -1864,6 +1864,7 @@ class MANGOS_DLL_SPEC Player : public Unit uint16 GetPureSkillValue(uint32 skill) const; // skill value int16 GetSkillPermBonusValue(uint32 skill) const; int16 GetSkillTempBonusValue(uint32 skill) const; + uint16 GetSkillStep(uint16 skill) const; // 0...6 bool HasSkill(uint32 skill) const; void learnSkillRewardedSpells(uint32 id, uint32 value); diff --git a/src/game/SkillHandler.cpp b/src/game/SkillHandler.cpp index 8bcef3970..8c22a1566 100644 --- a/src/game/SkillHandler.cpp +++ b/src/game/SkillHandler.cpp @@ -87,5 +87,5 @@ void WorldSession::HandleUnlearnSkillOpcode(WorldPacket & recv_data) { uint32 skill_id; recv_data >> skill_id; - GetPlayer()->SetSkill(skill_id, 0, 0); + GetPlayer()->SetSkill(skill_id, 0, 0, 0); } diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 840c076ee..56ba367ff 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -2337,7 +2337,7 @@ void Aura::HandleAuraDummy(bool apply, bool Real) case 63624: // Learn a Second Talent Specialization // Teach Learn Talent Specialization Switches, required for client triggered casts, allow after 30 sec delay if (m_target->GetTypeId() == TYPEID_PLAYER) - ((Player*)m_target)->learnSpell(63680, 0, false); + ((Player*)m_target)->learnSpell(63680, false); return; case 63651: // Revert to One Talent Specialization // Teach Learn Talent Specialization Switches, remove diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 20de18a42..b93d33c2a 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -3940,7 +3940,7 @@ void Spell::EffectLearnSpell(SpellEffectIndex eff_idx) Player *player = (Player*)unitTarget; uint32 spellToLearn = ((m_spellInfo->Id==SPELL_ID_GENERIC_LEARN) || (m_spellInfo->Id==SPELL_ID_GENERIC_LEARN_PET)) ? damage : m_spellInfo->EffectTriggerSpell[eff_idx]; - player->learnSpell(spellToLearn, m_spellInfo->Id, false); + player->learnSpell(spellToLearn, false); sLog.outDebug( "Spell: Player %u has learned spell %u from NpcGUID=%u", player->GetGUIDLow(), spellToLearn, m_caster->GetGUIDLow() ); } @@ -4344,7 +4344,7 @@ void Spell::EffectLearnSkill(SpellEffectIndex eff_idx) uint32 skillid = m_spellInfo->EffectMiscValue[eff_idx]; uint16 skillval = ((Player*)unitTarget)->GetPureSkillValue(skillid); - ((Player*)unitTarget)->SetSkill(skillid, skillval ? skillval : 1, damage * 75); + ((Player*)unitTarget)->SetSkill(skillid, m_spellInfo->CalculateSimpleValue(eff_idx), skillval ? skillval : 1, damage * 75); } void Spell::EffectAddHonor(SpellEffectIndex /*eff_idx*/) @@ -5700,7 +5700,7 @@ void Spell::EffectScriptEffect(SpellEffectIndex eff_idx) // learn random explicit discovery recipe (if any) if (uint32 discoveredSpell = GetExplicitDiscoverySpell(m_spellInfo->Id, (Player*)m_caster)) - ((Player*)m_caster)->learnSpell(discoveredSpell, 0, false); + ((Player*)m_caster)->learnSpell(discoveredSpell, false); return; } diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp index 9fcf50f37..e8ebf6ba3 100644 --- a/src/game/SpellMgr.cpp +++ b/src/game/SpellMgr.cpp @@ -2113,15 +2113,16 @@ void SpellMgr::LoadSpellLearnSkills() for(int i = 0; i < MAX_EFFECT_INDEX; ++i) { - if(entry->Effect[i]==SPELL_EFFECT_SKILL) + if(entry->Effect[i] == SPELL_EFFECT_SKILL) { SpellLearnSkillNode dbc_node; dbc_node.skill = entry->EffectMiscValue[i]; + dbc_node.step = entry->CalculateSimpleValue(SpellEffectIndex(i)); if ( dbc_node.skill != SKILL_RIDING ) dbc_node.value = 1; else - dbc_node.value = entry->CalculateSimpleValue(SpellEffectIndex(i))*75; - dbc_node.maxvalue = entry->CalculateSimpleValue(SpellEffectIndex(i))*75; + dbc_node.value = dbc_node.step * 75; + dbc_node.maxvalue = dbc_node.step * 75; mSpellLearnSkills[spell] = dbc_node; ++dbc_count; diff --git a/src/game/SpellMgr.h b/src/game/SpellMgr.h index c50a35cf8..02f411a7f 100644 --- a/src/game/SpellMgr.h +++ b/src/game/SpellMgr.h @@ -664,9 +664,10 @@ typedef std::multimap SpellChainMapNext; // Spell learning properties (accessed using SpellMgr functions) struct SpellLearnSkillNode { - uint32 skill; - uint32 value; // 0 - max skill value for player level - uint32 maxvalue; // 0 - max skill value for player level + uint16 skill; + uint16 step; + uint16 value; // 0 - max skill value for player level + uint16 maxvalue; // 0 - max skill value for player level }; typedef std::map SpellLearnSkillMap; diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 267885a2c..aa104e097 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -11250,12 +11250,17 @@ int32 Unit::CalculateSpellDamage(SpellEntry const* spellProto, SpellEffectIndex int32 randomPoints = int32(spellProto->EffectDieSides[effect_index]); float comboDamage = spellProto->EffectPointsPerComboPoint[effect_index]; - // range can have positive and negative values, so order its for irand - int32 randvalue = 0 >= randomPoints - ? irand(randomPoints, 0) - : irand(0, randomPoints); + int32 value = basePoints; - int32 value = basePoints + randvalue; + if(randomPoints != 0) + { + // range can have positive and negative values, so order its for irand + int32 randvalue = (0 > randomPoints) + ? irand(randomPoints, 0) + : irand(0, randomPoints); + + basePoints += randvalue; + } // random damage if(comboDamage != 0 && unitPlayer && target && (target->GetGUID() == unitPlayer->GetComboTarget())) diff --git a/src/game/WorldSocket.cpp b/src/game/WorldSocket.cpp index edcbf72b5..f2a509e51 100644 --- a/src/game/WorldSocket.cpp +++ b/src/game/WorldSocket.cpp @@ -248,14 +248,14 @@ int WorldSocket::open (void *a) WorldPacket packet (SMSG_AUTH_CHALLENGE, 24); packet << uint32(1); // 1...31 packet << m_Seed; - packet << uint32(0xF3539DA3); // random data - packet << uint32(0x6E8547B9); // random data - packet << uint32(0x9A6AA2F8); // random data - packet << uint32(0xA4F170F4); // random data - packet << uint32(0xF3539DA3); // random data - packet << uint32(0x6E8547B9); // random data - packet << uint32(0x9A6AA2F8); // random data - packet << uint32(0xA4F170F4); // random data + + BigNumber seed1; + seed1.SetRand(16 * 8); + packet.append(seed1.AsByteArray(16), 16); // new encryption seeds + + BigNumber seed2; + seed1.SetRand(16 * 8); + packet.append(seed1.AsByteArray(16), 16); // new encryption seeds if (SendPacket (packet) == -1) return -1;