fix: Fixes exceptional crafting chance (#1136)

This commit is contained in:
mark1145 2022-08-06 23:53:02 +10:00 committed by GitHub
parent 41cc7e60d9
commit bc746dbf14
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 15 deletions

View file

@ -813,8 +813,7 @@ namespace Server.Engines.Craft
public bool CheckSkills(
Mobile from, Type typeRes, CraftSystem craftSystem, ref int quality, out bool allRequiredSkills
) =>
CheckSkills(from, typeRes, craftSystem, ref quality, out allRequiredSkills, true);
) => CheckSkills(from, typeRes, craftSystem, ref quality, out allRequiredSkills, true);
public bool CheckSkills(
Mobile from, Type typeRes, CraftSystem craftSystem, ref int quality,
@ -873,19 +872,15 @@ namespace Server.Engines.Craft
return 0;
}
double chance = craftSystem.GetChanceAtMin(this) + (valMainSkill - minMainSkill) / (maxMainSkill - minMainSkill) *
(1.0 - craftSystem.GetChanceAtMin(this));
var minChance = craftSystem.GetChanceAtMin(this);
if (allRequiredSkills && from.Talisman is BaseTalisman talisman && talisman.Skill == craftSystem.MainSkill)
double chance = minChance + (valMainSkill - minMainSkill) / (maxMainSkill - minMainSkill) * (1.0 - minChance);
if (from.Talisman is BaseTalisman talisman && talisman.Skill == craftSystem.MainSkill)
{
chance += talisman.SuccessBonus / 100.0;
}
if (allRequiredSkills && valMainSkill >= maxMainSkill)
{
chance = 1.0;
}
return chance;
}
@ -914,7 +909,7 @@ namespace Server.Engines.Craft
var chance = GetSuccessChance(from, typeRes, craftSystem, false, out var allRequiredSkills);
if (!allRequiredSkills || !(chance >= 0.0))
if (!allRequiredSkills || chance <= 0.0)
{
from.EndAction<CraftSystem>();
from.SendGump(

View file

@ -79,10 +79,8 @@ namespace Server.Items
if (allRequiredSkills && chance >= 0.0)
{
pm.SendLocalizedMessage(
1073451,
r.TextDefinition.ToString()
); // You have learned a new recipe: ~1_RECIPE~
// You have learned a new recipe: ~1_RECIPE~
pm.SendLocalizedMessage(1073451, r.TextDefinition.ToString());
pm.AcquireRecipe(r);
Delete();
}