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:
hondacrx
2023-01-05 17:05:01 -05:00
parent 2e14438174
commit d644418262
6 changed files with 40 additions and 28 deletions
+3 -3
View File
@@ -505,9 +505,9 @@ namespace Framework.Constants
public enum PlayerRestState
{
Rested = 0x01,
NotRAFLinked = 0x02,
RAFLinked = 0x06
Rested = 1,
Normal = 2,
RAFLinked = 6
}
public enum CharacterCustomizeFlags
+13 -4
View File
@@ -50,12 +50,17 @@ namespace Game.Entities
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)
{
ChrRacesRecord race = CliDB.ChrRacesStorage.LookupByKey(GetRace());
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)
return questLevels.Value.MaxLevel;
@@ -69,11 +74,15 @@ namespace Game.Entities
{
if (quest == null)
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)
{
int minLevel = GetQuestMinLevel(quest);
int minLevel = GetQuestMinLevel(contentTuningId);
int maxLevel = questLevels.Value.MaxLevel;
int level = (int)GetLevel();
if (level >= minLevel)
+1 -1
View File
@@ -1798,7 +1798,7 @@ namespace Game.Entities
if (apply)
{
if (!HasAura((uint)spellId))
CastSpell(this, (uint)spellId, item);
CastSpell(this, (uint)spellId, new CastSpellExtraArgs().SetCastItem(item));
}
else
RemoveAurasDueToSpell((uint)spellId);
+2 -2
View File
@@ -246,8 +246,8 @@ namespace Game.Entities
SetWatchedFactionIndex(0xFFFFFFFF);
SetCustomizations(createInfo.Customizations);
SetRestState(RestTypes.XP, ((GetSession().IsARecruiter() || GetSession().GetRecruiterId() != 0) ? PlayerRestState.RAFLinked : PlayerRestState.NotRAFLinked));
SetRestState(RestTypes.Honor, PlayerRestState.NotRAFLinked);
SetRestState(RestTypes.XP, ((GetSession().IsARecruiter() || GetSession().GetRecruiterId() != 0) ? PlayerRestState.RAFLinked : PlayerRestState.Normal));
SetRestState(RestTypes.Honor, PlayerRestState.Normal);
SetNativeGender(createInfo.Sex);
SetInventorySlotCount(InventorySlots.DefaultSize);
+11 -13
View File
@@ -49,25 +49,23 @@ namespace Game.Entities
if (restBonus > rest_bonus_max)
restBonus = rest_bonus_max;
uint oldBonus = (uint)(_restBonus[(int)restType]);
_restBonus[(int)restType] = restBonus;
uint oldBonus = (uint)_restBonus[(int)restType];
if (oldBonus == restBonus)
PlayerRestState oldRestState = (PlayerRestState)(int)_player.m_activePlayerData.RestInfo[(int)restType].StateID;
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;
// 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.SetRestState(restType, newRestState);
}
public void AddRestBonus(RestTypes restType, float restBonus)
+10 -5
View File
@@ -367,12 +367,17 @@ namespace Game
}
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)
{
uint questLevel = (uint)player.GetQuestLevel(this);
uint questLevel = (uint)player.GetQuestLevel(contentTuningId);
QuestXPRecord questXp = CliDB.QuestXPStorage.LookupByKey(questLevel);
if (questXp == null || RewardXPDifficulty >= 10)
if (questXp == null || xpDifficulty >= 10)
return 0;
int diffFactor = (int)(2 * (questLevel - player.GetLevel()) + 12);
@@ -381,15 +386,15 @@ namespace Game
else if (diffFactor > 10)
diffFactor = 10;
uint xp = (uint)(diffFactor * questXp.Difficulty[RewardXPDifficulty] * RewardXPMultiplier / 10);
if (player.GetLevel() >= Global.ObjectMgr.GetMaxLevelForExpansion(PlayerConst.CurrentExpansion - 1) && player.GetSession().GetExpansion() == PlayerConst.CurrentExpansion && Expansion < (int)PlayerConst.CurrentExpansion)
uint xp = (uint)(diffFactor * questXp.Difficulty[xpDifficulty] * xpMultiplier / 10);
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 = RoundXPValue(xp);
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);
}