mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Spells: Implemented SPELL_EFFECT_GIVE_EXPERIENCE and SPELL_EFFECT_GIVE_RESTED_EXPERIENCE_BONUS
This commit is contained in:
@@ -491,8 +491,8 @@ bool Player::Create(ObjectGuid::LowType guidlow, WorldPackets::Character::Charac
|
||||
SetWatchedFactionIndex(-1);
|
||||
|
||||
SetCustomizations(Trinity::Containers::MakeIteratorPair(createInfo->Customizations.begin(), createInfo->Customizations.end()));
|
||||
SetRestState(REST_TYPE_XP, (GetSession()->IsARecruiter() || GetSession()->GetRecruiterId() != 0) ? REST_STATE_RAF_LINKED : REST_STATE_NOT_RAF_LINKED);
|
||||
SetRestState(REST_TYPE_HONOR, REST_STATE_NOT_RAF_LINKED);
|
||||
SetRestState(REST_TYPE_XP, (GetSession()->IsARecruiter() || GetSession()->GetRecruiterId() != 0) ? REST_STATE_RAF_LINKED : REST_STATE_NORMAL);
|
||||
SetRestState(REST_TYPE_HONOR, REST_STATE_NORMAL);
|
||||
SetNativeGender(Gender(createInfo->Sex));
|
||||
SetInventorySlotCount(INVENTORY_DEFAULT_SIZE);
|
||||
|
||||
@@ -7999,7 +7999,7 @@ void Player::ApplyItemObtainSpells(Item* item, bool apply)
|
||||
if (apply)
|
||||
{
|
||||
if (!HasAura(spellId))
|
||||
CastSpell(this, spellId, item);
|
||||
CastSpell(this, spellId, CastSpellExtraArgs().SetCastItem(item));
|
||||
}
|
||||
else
|
||||
RemoveAurasDueToSpell(spellId);
|
||||
@@ -14082,11 +14082,16 @@ uint32 Player::GetDefaultGossipMenuForSource(WorldObject* source)
|
||||
|
||||
int32 Player::GetQuestMinLevel(Quest const* quest) const
|
||||
{
|
||||
if (Optional<ContentTuningLevels> questLevels = sDB2Manager.GetContentTuningData(quest->GetContentTuningId(), m_playerData->CtrOptions->ContentTuningConditionMask))
|
||||
return GetQuestMinLevel(quest->GetContentTuningId());
|
||||
}
|
||||
|
||||
int32 Player::GetQuestMinLevel(uint32 contentTuningId) const
|
||||
{
|
||||
if (Optional<ContentTuningLevels> questLevels = sDB2Manager.GetContentTuningData(contentTuningId, m_playerData->CtrOptions->ContentTuningConditionMask))
|
||||
{
|
||||
ChrRacesEntry const* race = sChrRacesStore.AssertEntry(GetRace());
|
||||
FactionTemplateEntry const* raceFaction = sFactionTemplateStore.AssertEntry(race->FactionID);
|
||||
int32 questFactionGroup = sContentTuningStore.AssertEntry(quest->GetContentTuningId())->GetScalingFactionGroup();
|
||||
int32 questFactionGroup = sContentTuningStore.AssertEntry(contentTuningId)->GetScalingFactionGroup();
|
||||
if (questFactionGroup && raceFaction->FactionGroup != questFactionGroup)
|
||||
return questLevels->MaxLevel;
|
||||
|
||||
@@ -14101,9 +14106,14 @@ int32 Player::GetQuestLevel(Quest const* quest) const
|
||||
if (!quest)
|
||||
return 0;
|
||||
|
||||
if (Optional<ContentTuningLevels> questLevels = sDB2Manager.GetContentTuningData(quest->GetContentTuningId(), m_playerData->CtrOptions->ContentTuningConditionMask))
|
||||
return GetQuestLevel(quest->GetContentTuningId());
|
||||
}
|
||||
|
||||
int32 Player::GetQuestLevel(uint32 contentTuningId) const
|
||||
{
|
||||
if (Optional<ContentTuningLevels> questLevels = sDB2Manager.GetContentTuningData(contentTuningId, m_playerData->CtrOptions->ContentTuningConditionMask))
|
||||
{
|
||||
int32 minLevel = GetQuestMinLevel(quest);
|
||||
int32 minLevel = GetQuestMinLevel(contentTuningId);
|
||||
int32 maxLevel = questLevels->MaxLevel;
|
||||
int32 level = GetLevel();
|
||||
if (level >= minLevel)
|
||||
|
||||
@@ -1552,7 +1552,9 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
|
||||
/*********************************************************/
|
||||
|
||||
int32 GetQuestMinLevel(Quest const* quest) const;
|
||||
int32 GetQuestMinLevel(uint32 contentTuningId) const;
|
||||
int32 GetQuestLevel(Quest const* quest) const;
|
||||
int32 GetQuestLevel(uint32 contentTuningId) const;
|
||||
void PrepareQuestMenu(ObjectGuid guid);
|
||||
void SendPreparedQuest(WorldObject* source);
|
||||
bool IsActiveQuest(uint32 quest_id) const;
|
||||
|
||||
@@ -63,25 +63,23 @@ void RestMgr::SetRestBonus(RestTypes restType, float restBonus)
|
||||
if (restBonus > rest_bonus_max)
|
||||
restBonus = rest_bonus_max;
|
||||
|
||||
uint32 oldBonus = uint32(_restBonus[restType]);
|
||||
_restBonus[restType] = restBonus;
|
||||
|
||||
uint32 oldBonus = uint32(_restBonus[restType]);
|
||||
if (oldBonus == uint32(restBonus))
|
||||
PlayerRestState oldRestState = static_cast<PlayerRestState>(*_player->m_activePlayerData->RestInfo[restType].StateID);
|
||||
PlayerRestState newRestState = REST_STATE_NORMAL;
|
||||
|
||||
if (affectedByRaF && _player->GetsRecruitAFriendBonus(true) && (_player->GetSession()->IsARecruiter() || _player->GetSession()->GetRecruiterId() != 0))
|
||||
newRestState = REST_STATE_RAF_LINKED;
|
||||
else if (_restBonus[restType] >= 1)
|
||||
newRestState = REST_STATE_RESTED;
|
||||
|
||||
if (oldBonus == uint32(restBonus) && oldRestState == newRestState)
|
||||
return;
|
||||
|
||||
// update data for client
|
||||
if (affectedByRaF && _player->GetsRecruitAFriendBonus(true) && (_player->GetSession()->IsARecruiter() || _player->GetSession()->GetRecruiterId() != 0))
|
||||
_player->SetRestState(restType, REST_STATE_RAF_LINKED);
|
||||
else
|
||||
{
|
||||
if (_restBonus[restType] > 10)
|
||||
_player->SetRestState(restType, REST_STATE_RESTED);
|
||||
else if (_restBonus[restType] <= 1)
|
||||
_player->SetRestState(restType, REST_STATE_NOT_RAF_LINKED);
|
||||
}
|
||||
|
||||
// RestTickUpdate
|
||||
_player->SetRestThreshold(restType, uint32(_restBonus[restType]));
|
||||
_player->SetRestState(restType, newRestState);
|
||||
}
|
||||
|
||||
void RestMgr::AddRestBonus(RestTypes restType, float restBonus)
|
||||
|
||||
@@ -40,11 +40,12 @@ enum PlayerRestInfoOffsets : uint8
|
||||
MAX_REST_INFO
|
||||
};
|
||||
|
||||
// Exhaustion.db2 ids
|
||||
enum PlayerRestState : uint8
|
||||
{
|
||||
REST_STATE_RESTED = 0x01,
|
||||
REST_STATE_NOT_RAF_LINKED = 0x02,
|
||||
REST_STATE_RAF_LINKED = 0x06
|
||||
REST_STATE_RESTED = 1,
|
||||
REST_STATE_NORMAL = 2,
|
||||
REST_STATE_RAF_LINKED = 6
|
||||
};
|
||||
|
||||
enum RestFlag : uint32
|
||||
@@ -75,9 +76,10 @@ public:
|
||||
|
||||
void Update(time_t now);
|
||||
|
||||
float CalcExtraPerSec(RestTypes restType, float bubble) const;
|
||||
|
||||
protected:
|
||||
void LoadRestBonus(RestTypes restType, PlayerRestState state, float restBonus);
|
||||
float CalcExtraPerSec(RestTypes restType, float bubble) const;
|
||||
|
||||
private:
|
||||
Player* _player;
|
||||
|
||||
@@ -356,12 +356,17 @@ void Quest::LoadConditionalConditionalQuestCompletionLog(Field* fields)
|
||||
}
|
||||
|
||||
uint32 Quest::XPValue(Player const* player) const
|
||||
{
|
||||
return XPValue(player, GetContentTuningId(), _rewardXPDifficulty, _rewardXPMultiplier, _expansion);
|
||||
}
|
||||
|
||||
uint32 Quest::XPValue(Player const* player, uint32 contentTuningId, uint32 xpDifficulty, float xpMultiplier /*= 1.0f*/, int32 expansion /*= -1*/)
|
||||
{
|
||||
if (player)
|
||||
{
|
||||
uint32 questLevel = player->GetQuestLevel(this);
|
||||
uint32 questLevel = player->GetQuestLevel(contentTuningId);
|
||||
QuestXPEntry const* questXp = sQuestXPStore.LookupEntry(questLevel);
|
||||
if (!questXp || _rewardXPDifficulty >= 10)
|
||||
if (!questXp || xpDifficulty >= 10)
|
||||
return 0;
|
||||
|
||||
int32 diffFactor = 2 * (questLevel - player->GetLevel()) + 12;
|
||||
@@ -370,15 +375,15 @@ uint32 Quest::XPValue(Player const* player) const
|
||||
else if (diffFactor > 10)
|
||||
diffFactor = 10;
|
||||
|
||||
uint32 xp = diffFactor * questXp->Difficulty[_rewardXPDifficulty] * _rewardXPMultiplier / 10;
|
||||
if (player->GetLevel() >= GetMaxLevelForExpansion(CURRENT_EXPANSION - 1) && player->GetSession()->GetExpansion() == CURRENT_EXPANSION && _expansion < CURRENT_EXPANSION)
|
||||
uint32 xp = diffFactor * questXp->Difficulty[xpDifficulty] * xpMultiplier / 10;
|
||||
if (player->GetLevel() >= GetMaxLevelForExpansion(CURRENT_EXPANSION - 1) && player->GetSession()->GetExpansion() == CURRENT_EXPANSION && expansion >= 0 && expansion < CURRENT_EXPANSION)
|
||||
xp = uint32(xp / 9.0f);
|
||||
|
||||
xp = RoundXPValue(xp);
|
||||
|
||||
if (sWorld->getIntConfig(CONFIG_MIN_QUEST_SCALED_XP_RATIO))
|
||||
{
|
||||
uint32 minScaledXP = RoundXPValue(questXp->Difficulty[_rewardXPDifficulty] * _rewardXPMultiplier) * sWorld->getIntConfig(CONFIG_MIN_QUEST_SCALED_XP_RATIO) / 100;
|
||||
uint32 minScaledXP = RoundXPValue(questXp->Difficulty[xpDifficulty] * xpMultiplier) * sWorld->getIntConfig(CONFIG_MIN_QUEST_SCALED_XP_RATIO) / 100;
|
||||
xp = std::max(minScaledXP, xp);
|
||||
}
|
||||
|
||||
|
||||
@@ -505,6 +505,7 @@ class TC_GAME_API Quest
|
||||
void LoadConditionalConditionalQuestCompletionLog(Field* fields);
|
||||
|
||||
uint32 XPValue(Player const* player) const;
|
||||
static uint32 XPValue(Player const* player, uint32 contentTuningId, uint32 xpDifficulty, float xpMultiplier = 1.0f, int32 expansion = -1);
|
||||
uint32 MoneyValue(Player const* player) const;
|
||||
uint32 MaxMoneyValue() const;
|
||||
uint32 GetMaxMoneyReward() const;
|
||||
|
||||
@@ -378,6 +378,8 @@ class TC_GAME_API Spell
|
||||
void EffectAddGarrisonFollower();
|
||||
void EffectActivateGarrisonBuilding();
|
||||
void EffectGrantBattlePetLevel();
|
||||
void EffectGiveExperience();
|
||||
void EffectGiveRestedExperience();
|
||||
void EffectHealBattlePetPct();
|
||||
void EffectEnableBattlePets();
|
||||
void EffectChangeBattlePetQuality();
|
||||
|
||||
Reference in New Issue
Block a user