Core/Spells: Implemented SPELL_EFFECT_GIVE_EXPERIENCE and SPELL_EFFECT_GIVE_RESTED_EXPERIENCE_BONUS
Port From (https://github.com/TrinityCore/TrinityCore/commit/ade34a7f484dfcc7e41eddfd1014e7728c8dc2c1)
This commit is contained in:
@@ -505,9 +505,9 @@ namespace Framework.Constants
|
|||||||
|
|
||||||
public enum PlayerRestState
|
public enum PlayerRestState
|
||||||
{
|
{
|
||||||
Rested = 0x01,
|
Rested = 1,
|
||||||
NotRAFLinked = 0x02,
|
Normal = 2,
|
||||||
RAFLinked = 0x06
|
RAFLinked = 6
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum CharacterCustomizeFlags
|
public enum CharacterCustomizeFlags
|
||||||
|
|||||||
@@ -50,12 +50,17 @@ namespace Game.Entities
|
|||||||
|
|
||||||
public int GetQuestMinLevel(Quest quest)
|
public int GetQuestMinLevel(Quest quest)
|
||||||
{
|
{
|
||||||
var questLevels = Global.DB2Mgr.GetContentTuningData(quest.ContentTuningId, m_playerData.CtrOptions.GetValue().ContentTuningConditionMask);
|
return GetQuestMinLevel(quest.ContentTuningId);
|
||||||
|
}
|
||||||
|
|
||||||
|
int GetQuestMinLevel(uint contentTuningId)
|
||||||
|
{
|
||||||
|
var questLevels = Global.DB2Mgr.GetContentTuningData(contentTuningId, m_playerData.CtrOptions.GetValue().ContentTuningConditionMask);
|
||||||
if (questLevels.HasValue)
|
if (questLevels.HasValue)
|
||||||
{
|
{
|
||||||
ChrRacesRecord race = CliDB.ChrRacesStorage.LookupByKey(GetRace());
|
ChrRacesRecord race = CliDB.ChrRacesStorage.LookupByKey(GetRace());
|
||||||
FactionTemplateRecord raceFaction = CliDB.FactionTemplateStorage.LookupByKey(race.FactionID);
|
FactionTemplateRecord raceFaction = CliDB.FactionTemplateStorage.LookupByKey(race.FactionID);
|
||||||
int questFactionGroup = CliDB.ContentTuningStorage.LookupByKey(quest.ContentTuningId).GetScalingFactionGroup();
|
int questFactionGroup = CliDB.ContentTuningStorage.LookupByKey(contentTuningId).GetScalingFactionGroup();
|
||||||
if (questFactionGroup != 0 && raceFaction.FactionGroup != questFactionGroup)
|
if (questFactionGroup != 0 && raceFaction.FactionGroup != questFactionGroup)
|
||||||
return questLevels.Value.MaxLevel;
|
return questLevels.Value.MaxLevel;
|
||||||
|
|
||||||
@@ -69,11 +74,15 @@ namespace Game.Entities
|
|||||||
{
|
{
|
||||||
if (quest == null)
|
if (quest == null)
|
||||||
return 0;
|
return 0;
|
||||||
|
return GetQuestLevel(quest.ContentTuningId);
|
||||||
|
}
|
||||||
|
|
||||||
var questLevels = Global.DB2Mgr.GetContentTuningData(quest.ContentTuningId, m_playerData.CtrOptions.GetValue().ContentTuningConditionMask);
|
public int GetQuestLevel(uint contentTuningId)
|
||||||
|
{
|
||||||
|
var questLevels = Global.DB2Mgr.GetContentTuningData(contentTuningId, m_playerData.CtrOptions.GetValue().ContentTuningConditionMask);
|
||||||
if (questLevels.HasValue)
|
if (questLevels.HasValue)
|
||||||
{
|
{
|
||||||
int minLevel = GetQuestMinLevel(quest);
|
int minLevel = GetQuestMinLevel(contentTuningId);
|
||||||
int maxLevel = questLevels.Value.MaxLevel;
|
int maxLevel = questLevels.Value.MaxLevel;
|
||||||
int level = (int)GetLevel();
|
int level = (int)GetLevel();
|
||||||
if (level >= minLevel)
|
if (level >= minLevel)
|
||||||
|
|||||||
@@ -1798,7 +1798,7 @@ namespace Game.Entities
|
|||||||
if (apply)
|
if (apply)
|
||||||
{
|
{
|
||||||
if (!HasAura((uint)spellId))
|
if (!HasAura((uint)spellId))
|
||||||
CastSpell(this, (uint)spellId, item);
|
CastSpell(this, (uint)spellId, new CastSpellExtraArgs().SetCastItem(item));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
RemoveAurasDueToSpell((uint)spellId);
|
RemoveAurasDueToSpell((uint)spellId);
|
||||||
|
|||||||
@@ -246,8 +246,8 @@ namespace Game.Entities
|
|||||||
SetWatchedFactionIndex(0xFFFFFFFF);
|
SetWatchedFactionIndex(0xFFFFFFFF);
|
||||||
|
|
||||||
SetCustomizations(createInfo.Customizations);
|
SetCustomizations(createInfo.Customizations);
|
||||||
SetRestState(RestTypes.XP, ((GetSession().IsARecruiter() || GetSession().GetRecruiterId() != 0) ? PlayerRestState.RAFLinked : PlayerRestState.NotRAFLinked));
|
SetRestState(RestTypes.XP, ((GetSession().IsARecruiter() || GetSession().GetRecruiterId() != 0) ? PlayerRestState.RAFLinked : PlayerRestState.Normal));
|
||||||
SetRestState(RestTypes.Honor, PlayerRestState.NotRAFLinked);
|
SetRestState(RestTypes.Honor, PlayerRestState.Normal);
|
||||||
SetNativeGender(createInfo.Sex);
|
SetNativeGender(createInfo.Sex);
|
||||||
SetInventorySlotCount(InventorySlots.DefaultSize);
|
SetInventorySlotCount(InventorySlots.DefaultSize);
|
||||||
|
|
||||||
|
|||||||
@@ -49,25 +49,23 @@ namespace Game.Entities
|
|||||||
if (restBonus > rest_bonus_max)
|
if (restBonus > rest_bonus_max)
|
||||||
restBonus = rest_bonus_max;
|
restBonus = rest_bonus_max;
|
||||||
|
|
||||||
|
uint oldBonus = (uint)(_restBonus[(int)restType]);
|
||||||
_restBonus[(int)restType] = restBonus;
|
_restBonus[(int)restType] = restBonus;
|
||||||
|
|
||||||
uint oldBonus = (uint)_restBonus[(int)restType];
|
PlayerRestState oldRestState = (PlayerRestState)(int)_player.m_activePlayerData.RestInfo[(int)restType].StateID;
|
||||||
if (oldBonus == restBonus)
|
PlayerRestState newRestState = PlayerRestState.Normal;
|
||||||
|
|
||||||
|
if (affectedByRaF && _player.GetsRecruitAFriendBonus(true) && (_player.GetSession().IsARecruiter() || _player.GetSession().GetRecruiterId() != 0))
|
||||||
|
newRestState = PlayerRestState.RAFLinked;
|
||||||
|
else if (_restBonus[(int)restType] >= 1)
|
||||||
|
newRestState = PlayerRestState.Rested;
|
||||||
|
|
||||||
|
if (oldBonus == restBonus && oldRestState == newRestState)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// update data for client
|
// update data for client
|
||||||
if (affectedByRaF && _player.GetsRecruitAFriendBonus(true) && (_player.GetSession().IsARecruiter() || _player.GetSession().GetRecruiterId() != 0))
|
|
||||||
_player.SetRestState(restType, PlayerRestState.RAFLinked);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (_restBonus[(int)restType] > 10)
|
|
||||||
_player.SetRestState(restType, PlayerRestState.Rested);
|
|
||||||
else if (_restBonus[(int)restType] <= 1)
|
|
||||||
_player.SetRestState(restType, PlayerRestState.NotRAFLinked);
|
|
||||||
}
|
|
||||||
|
|
||||||
// RestTickUpdate
|
|
||||||
_player.SetRestThreshold(restType, (uint)_restBonus[(int)restType]);
|
_player.SetRestThreshold(restType, (uint)_restBonus[(int)restType]);
|
||||||
|
_player.SetRestState(restType, newRestState);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddRestBonus(RestTypes restType, float restBonus)
|
public void AddRestBonus(RestTypes restType, float restBonus)
|
||||||
|
|||||||
@@ -367,12 +367,17 @@ namespace Game
|
|||||||
}
|
}
|
||||||
|
|
||||||
public uint XPValue(Player player)
|
public uint XPValue(Player player)
|
||||||
|
{
|
||||||
|
return XPValue(player, ContentTuningId, RewardXPDifficulty, RewardXPMultiplier, Expansion);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static uint XPValue(Player player, uint contentTuningId, uint xpDifficulty, float xpMultiplier = 1.0f, int expansion = -1)
|
||||||
{
|
{
|
||||||
if (player)
|
if (player)
|
||||||
{
|
{
|
||||||
uint questLevel = (uint)player.GetQuestLevel(this);
|
uint questLevel = (uint)player.GetQuestLevel(contentTuningId);
|
||||||
QuestXPRecord questXp = CliDB.QuestXPStorage.LookupByKey(questLevel);
|
QuestXPRecord questXp = CliDB.QuestXPStorage.LookupByKey(questLevel);
|
||||||
if (questXp == null || RewardXPDifficulty >= 10)
|
if (questXp == null || xpDifficulty >= 10)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int diffFactor = (int)(2 * (questLevel - player.GetLevel()) + 12);
|
int diffFactor = (int)(2 * (questLevel - player.GetLevel()) + 12);
|
||||||
@@ -381,15 +386,15 @@ namespace Game
|
|||||||
else if (diffFactor > 10)
|
else if (diffFactor > 10)
|
||||||
diffFactor = 10;
|
diffFactor = 10;
|
||||||
|
|
||||||
uint xp = (uint)(diffFactor * questXp.Difficulty[RewardXPDifficulty] * RewardXPMultiplier / 10);
|
uint xp = (uint)(diffFactor * questXp.Difficulty[xpDifficulty] * xpMultiplier / 10);
|
||||||
if (player.GetLevel() >= Global.ObjectMgr.GetMaxLevelForExpansion(PlayerConst.CurrentExpansion - 1) && player.GetSession().GetExpansion() == PlayerConst.CurrentExpansion && Expansion < (int)PlayerConst.CurrentExpansion)
|
if (player.GetLevel() >= Global.ObjectMgr.GetMaxLevelForExpansion(PlayerConst.CurrentExpansion - 1) && player.GetSession().GetExpansion() == PlayerConst.CurrentExpansion && expansion >= 0 && expansion < (int)PlayerConst.CurrentExpansion)
|
||||||
xp = (uint)(xp / 9.0f);
|
xp = (uint)(xp / 9.0f);
|
||||||
|
|
||||||
xp = RoundXPValue(xp);
|
xp = RoundXPValue(xp);
|
||||||
|
|
||||||
if (WorldConfig.GetUIntValue(WorldCfg.MinQuestScaledXpRatio) != 0)
|
if (WorldConfig.GetUIntValue(WorldCfg.MinQuestScaledXpRatio) != 0)
|
||||||
{
|
{
|
||||||
uint minScaledXP = RoundXPValue((uint)(questXp.Difficulty[RewardXPDifficulty] * RewardXPMultiplier)) * WorldConfig.GetUIntValue(WorldCfg.MinQuestScaledXpRatio) / 100;
|
uint minScaledXP = RoundXPValue((uint)(questXp.Difficulty[xpDifficulty] * xpMultiplier)) * WorldConfig.GetUIntValue(WorldCfg.MinQuestScaledXpRatio) / 100;
|
||||||
xp = Math.Max(minScaledXP, xp);
|
xp = Math.Max(minScaledXP, xp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user