Core/Skinning: Update correct skinning skill according to creature expansion

Port From (https://github.com/TrinityCore/TrinityCore/commit/229a7ac79d38b9db76387f92e846c04c151ad3aa)
This commit is contained in:
hondacrx
2023-04-05 08:22:24 -04:00
parent 6361e60c8b
commit d3297b96a2
4 changed files with 45 additions and 63 deletions
+19 -40
View File
@@ -1305,20 +1305,25 @@ namespace Game.Entities
return false; return false;
} }
public bool UpdateGatherSkill(uint SkillId, uint SkillValue, uint RedLevel, uint Multiplicator = 1, WorldObject obj = null) public bool UpdateGatherSkill(uint skillId, uint skillValue, uint redLevel, uint multiplicator = 1, WorldObject obj = null)
{ {
return UpdateGatherSkill((SkillType)SkillId, SkillValue, RedLevel, Multiplicator, obj); return UpdateGatherSkill((SkillType)skillId, skillValue, redLevel, multiplicator, obj);
} }
public bool UpdateGatherSkill(SkillType SkillId, uint SkillValue, uint RedLevel, uint Multiplicator = 1, WorldObject obj = null) public bool UpdateGatherSkill(SkillType skillId, uint skillValue, uint redLevel, uint multiplicator = 1, WorldObject obj = null)
{ {
Log.outDebug(LogFilter.Player, "UpdateGatherSkill(SkillId {0} SkillLevel {1} RedLevel {2})", SkillId, SkillValue, RedLevel); Log.outDebug(LogFilter.Player, $"UpdateGatherSkill(SkillId {skillId} SkillLevel {skillValue} RedLevel {redLevel})");
uint gathering_skill_gain = WorldConfig.GetUIntValue(WorldCfg.SkillGainGathering); SkillLineRecord skillEntry = CliDB.SkillLineStorage.LookupByKey(skillId);
if (skillEntry == null)
return false;
uint grayLevel = RedLevel + 100; uint gatheringSkillGain = WorldConfig.GetUIntValue(WorldCfg.SkillGainGathering);
uint greenLevel = RedLevel + 50;
uint yellowLevel = RedLevel + 25; uint baseSkillLevelStep = 30;
uint yellowLevel = redLevel + baseSkillLevelStep;
uint greenLevel = yellowLevel + baseSkillLevelStep;
uint grayLevel = greenLevel + baseSkillLevelStep;
GameObject go = obj?.ToGameObject(); GameObject go = obj?.ToGameObject();
if (go != null) if (go != null)
@@ -1333,46 +1338,20 @@ namespace Game.Entities
} }
// For skinning and Mining chance decrease with level. 1-74 - no decrease, 75-149 - 2 times, 225-299 - 8 times // For skinning and Mining chance decrease with level. 1-74 - no decrease, 75-149 - 2 times, 225-299 - 8 times
switch (SkillId) switch ((SkillType)skillEntry.ParentSkillLineID)
{ {
case SkillType.Herbalism: case SkillType.Herbalism:
case SkillType.ClassicHerbalism: return UpdateSkillPro(skillId, SkillGainChance(skillValue, grayLevel, greenLevel, yellowLevel) * (int)multiplicator, gatheringSkillGain);
case SkillType.OutlandHerbalism:
case SkillType.NorthrendHerbalism:
case SkillType.CataclysmHerbalism:
case SkillType.PandariaHerbalism:
case SkillType.DraenorHerbalism:
case SkillType.LegionHerbalism:
case SkillType.KulTiranHerbalism:
case SkillType.Jewelcrafting:
case SkillType.Inscription:
return UpdateSkillPro(SkillId, SkillGainChance(SkillValue, grayLevel, greenLevel, yellowLevel) * (int)Multiplicator, gathering_skill_gain);
case SkillType.Skinning: case SkillType.Skinning:
case SkillType.ClassicSkinning:
case SkillType.OutlandSkinning:
case SkillType.NorthrendSkinning:
case SkillType.CataclysmSkinning:
case SkillType.PandariaSkinning:
case SkillType.DraenorSkinning:
case SkillType.LegionSkinning:
case SkillType.KulTiranSkinning:
if (WorldConfig.GetIntValue(WorldCfg.SkillChanceSkinningSteps) == 0) if (WorldConfig.GetIntValue(WorldCfg.SkillChanceSkinningSteps) == 0)
return UpdateSkillPro(SkillId, SkillGainChance(SkillValue, grayLevel, greenLevel, yellowLevel) * (int)Multiplicator, gathering_skill_gain); return UpdateSkillPro(skillId, SkillGainChance(skillValue, grayLevel, greenLevel, yellowLevel) * (int)multiplicator, gatheringSkillGain);
else else
return UpdateSkillPro(SkillId, (int)(SkillGainChance(SkillValue, grayLevel, greenLevel, yellowLevel) * Multiplicator) >> (int)(SkillValue / WorldConfig.GetIntValue(WorldCfg.SkillChanceSkinningSteps)), gathering_skill_gain); return UpdateSkillPro(skillId, (int)(SkillGainChance(skillValue, grayLevel, greenLevel, yellowLevel) * multiplicator) >> (int)(skillValue / WorldConfig.GetIntValue(WorldCfg.SkillChanceSkinningSteps)), gatheringSkillGain);
case SkillType.Mining: case SkillType.Mining:
case SkillType.ClassicMining:
case SkillType.OutlandMining:
case SkillType.NorthrendMining:
case SkillType.CataclysmMining:
case SkillType.PandariaMining:
case SkillType.DraenorMining:
case SkillType.LegionMining:
case SkillType.KulTiranMining:
if (WorldConfig.GetIntValue(WorldCfg.SkillChanceMiningSteps) == 0) if (WorldConfig.GetIntValue(WorldCfg.SkillChanceMiningSteps) == 0)
return UpdateSkillPro(SkillId, SkillGainChance(SkillValue, grayLevel, greenLevel, yellowLevel) * (int)Multiplicator, gathering_skill_gain); return UpdateSkillPro(skillId, SkillGainChance(skillValue, grayLevel, greenLevel, yellowLevel) * (int)multiplicator, gatheringSkillGain);
else else
return UpdateSkillPro(SkillId, (int)(SkillGainChance(SkillValue, grayLevel, greenLevel, yellowLevel) * Multiplicator) >> (int)(SkillValue / WorldConfig.GetIntValue(WorldCfg.SkillChanceMiningSteps)), gathering_skill_gain); return UpdateSkillPro(skillId, (int)(SkillGainChance(skillValue, grayLevel, greenLevel, yellowLevel) * multiplicator) >> (int)(skillValue / WorldConfig.GetIntValue(WorldCfg.SkillChanceMiningSteps)), gatheringSkillGain);
} }
return false; return false;
} }
+2
View File
@@ -2122,6 +2122,8 @@ namespace Game.Entities
public bool IsTotem() { return UnitTypeMask.HasAnyFlag(UnitTypeMask.Totem); } public bool IsTotem() { return UnitTypeMask.HasAnyFlag(UnitTypeMask.Totem); }
public bool IsVehicle() { return UnitTypeMask.HasAnyFlag(UnitTypeMask.Vehicle); } public bool IsVehicle() { return UnitTypeMask.HasAnyFlag(UnitTypeMask.Vehicle); }
public uint GetContentTuning() { return m_unitData.ContentTuningID; }
public void AddUnitState(UnitState f) public void AddUnitState(UnitState f)
{ {
m_state |= f; m_state |= f;
-8
View File
@@ -5180,14 +5180,6 @@ namespace Game.Spells
if (loot != null && (!loot.IsLooted() || loot.loot_type == LootType.Skinning)) if (loot != null && (!loot.IsLooted() || loot.loot_type == LootType.Skinning))
return SpellCastResult.TargetNotLooted; return SpellCastResult.TargetNotLooted;
SkillType skill = creature.GetCreatureTemplate().GetRequiredLootSkill();
ushort skillValue = m_caster.ToPlayer().GetSkillValue(skill);
uint TargetLevel = m_targets.GetUnitTarget().GetLevelForTarget(m_caster);
int ReqValue = (int)(skillValue < 100 ? (TargetLevel - 10) * 10 : TargetLevel * 5);
if (ReqValue > skillValue)
return SpellCastResult.LowCastlevel;
break; break;
} }
case SpellEffectName.OpenLock: case SpellEffectName.OpenLock:
+13 -4
View File
@@ -3450,6 +3450,7 @@ namespace Game.Spells
loot.FillLoot(creature.GetCreatureTemplate().SkinLootId, LootStorage.Skinning, player, true); loot.FillLoot(creature.GetCreatureTemplate().SkinLootId, LootStorage.Skinning, player, true);
player.SendLoot(loot); player.SendLoot(loot);
// This formula is still used (10.0.5.48526)
if (skill == SkillType.Skinning) if (skill == SkillType.Skinning)
{ {
int reqValue; int reqValue;
@@ -3478,12 +3479,20 @@ namespace Game.Spells
else else
reqValue = 900; reqValue = 900;
// TODO: Specialize skillid for each expansion ContentTuningRecord contentTuning = CliDB.ContentTuningStorage.LookupByKey(creature.GetContentTuning());
// new db field? if (contentTuning == null)
// tied to one of existing expansion fields in creature_template? return;
uint skinningSkill = player.GetProfessionSkillForExp(skill, contentTuning.ExpansionID);
if (skinningSkill == 0)
return;
uint pureSkillValue = player.GetPureSkillValue(skinningSkill);
if (pureSkillValue != 0)
{
// Double chances for elites // Double chances for elites
m_caster.ToPlayer().UpdateGatherSkill(skill, (uint)damage, (uint)reqValue, (uint)(creature.IsElite() ? 2 : 1)); player.UpdateGatherSkill(skinningSkill, pureSkillValue, (uint)reqValue, creature.IsElite() ? 2 : 1u);
}
} }
} }