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;
} }
+12 -10
View File
@@ -563,7 +563,7 @@ namespace Game.Entities
vehicleRoot = vehicleRoot.GetVehicleBase(); vehicleRoot = vehicleRoot.GetVehicleBase();
} }
} }
public Creature GetVehicleCreatureBase() public Creature GetVehicleCreatureBase()
{ {
Unit veh = GetVehicleBase(); Unit veh = GetVehicleBase();
@@ -891,7 +891,7 @@ namespace Game.Entities
return str; return str;
} }
public Guardian GetGuardianPet() public Guardian GetGuardianPet()
{ {
ObjectGuid pet_guid = GetPetGUID(); ObjectGuid pet_guid = GetPetGUID();
@@ -1315,12 +1315,12 @@ namespace Game.Entities
else else
return true; return true;
} }
public bool IsPossessedByPlayer() public bool IsPossessedByPlayer()
{ {
return HasUnitState(UnitState.Possessed) && GetCharmerGUID().IsPlayer(); return HasUnitState(UnitState.Possessed) && GetCharmerGUID().IsPlayer();
} }
public bool IsPossessing() public bool IsPossessing()
{ {
Unit u = GetCharmed(); Unit u = GetCharmed();
@@ -1857,7 +1857,7 @@ namespace Game.Entities
public Gender GetGender() { return (Gender)(byte)m_unitData.Sex; } public Gender GetGender() { return (Gender)(byte)m_unitData.Sex; }
public void SetGender(Gender sex) { SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.Sex), (byte)sex); } public void SetGender(Gender sex) { SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.Sex), (byte)sex); }
public virtual Gender GetNativeGender() { return GetGender(); } public virtual Gender GetNativeGender() { return GetGender(); }
public virtual void SetNativeGender(Gender gender) { SetGender(gender); } public virtual void SetNativeGender(Gender gender) { SetGender(gender); }
public void RecalculateObjectScale() public void RecalculateObjectScale()
@@ -1869,7 +1869,7 @@ namespace Game.Entities
} }
public virtual float GetNativeObjectScale() { return 1.0f; } public virtual float GetNativeObjectScale() { return 1.0f; }
public uint GetDisplayId() { return m_unitData.DisplayID; } public uint GetDisplayId() { return m_unitData.DisplayID; }
public virtual void SetDisplayId(uint modelId, float displayScale = 1f) public virtual void SetDisplayId(uint modelId, float displayScale = 1f)
@@ -1995,7 +1995,7 @@ namespace Game.Entities
public void SetBattlePetCompanionGUID(ObjectGuid guid) { SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.BattlePetCompanionGUID), guid); } public void SetBattlePetCompanionGUID(ObjectGuid guid) { SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.BattlePetCompanionGUID), guid); }
public ObjectGuid GetDemonCreatorGUID() { return m_unitData.DemonCreator; } public ObjectGuid GetDemonCreatorGUID() { return m_unitData.DemonCreator; }
public void SetDemonCreatorGUID(ObjectGuid guid) { SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.DemonCreator), guid); } public void SetDemonCreatorGUID(ObjectGuid guid) { SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.DemonCreator), guid); }
public ObjectGuid GetCharmerGUID() { return m_unitData.CharmedBy; } public ObjectGuid GetCharmerGUID() { return m_unitData.CharmedBy; }
public Unit GetCharmer() { return m_charmer; } public Unit GetCharmer() { return m_charmer; }
@@ -2097,7 +2097,7 @@ namespace Game.Entities
else else
{ {
var raceEntry = CliDB.ChrRacesStorage.LookupByKey(GetRace()); var raceEntry = CliDB.ChrRacesStorage.LookupByKey(GetRace());
return (CreatureType)raceEntry.CreatureType; return (CreatureType)raceEntry.CreatureType;
} }
} }
else else
@@ -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;
@@ -2266,7 +2268,7 @@ namespace Game.Entities
} }
public AnimTier GetAnimTier() { return (AnimTier)(byte)m_unitData.AnimTier; } public AnimTier GetAnimTier() { return (AnimTier)(byte)m_unitData.AnimTier; }
public void SetAnimTier(AnimTier animTier, bool notifyClient = true) public void SetAnimTier(AnimTier animTier, bool notifyClient = true)
{ {
SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.AnimTier), (byte)animTier); SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.AnimTier), (byte)animTier);
@@ -2507,7 +2509,7 @@ namespace Game.Entities
} }
} }
} }
Player player = victim.ToPlayer(); Player player = victim.ToPlayer();
if (player != null && player.GetCommandStatus(PlayerCommandStates.God)) if (player != null && player.GetCommandStatus(PlayerCommandStates.God))
return 0; return 0;
-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:
+14 -5
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;
// Double chances for elites uint skinningSkill = player.GetProfessionSkillForExp(skill, contentTuning.ExpansionID);
m_caster.ToPlayer().UpdateGatherSkill(skill, (uint)damage, (uint)reqValue, (uint)(creature.IsElite() ? 2 : 1)); if (skinningSkill == 0)
return;
uint pureSkillValue = player.GetPureSkillValue(skinningSkill);
if (pureSkillValue != 0)
{
// Double chances for elites
player.UpdateGatherSkill(skinningSkill, pureSkillValue, (uint)reqValue, creature.IsElite() ? 2 : 1u);
}
} }
} }