Working on crafting fixes
This commit is contained in:
@@ -392,18 +392,43 @@ public class CraftingHandler
|
||||
CraftingLevelAtCreation = skill.Level
|
||||
};
|
||||
|
||||
// Calculate skill quality bonus
|
||||
// Formula creates a curve where you need to significantly overlevel the recipe to get perfect rolls
|
||||
// At required level: ~10% chance for max
|
||||
// At 2x required level: ~40% chance
|
||||
// At 4x required level: ~75% chance
|
||||
// At 10x required level: ~95% chance
|
||||
float levelRatio = (float)skill.Level / Math.Max(1, recipe.RequiredLevel);
|
||||
float skillBonus = Math.Min(0.95f, (levelRatio - 1f) / 10f); // Caps at 95% to keep some RNG
|
||||
skillBonus = Math.Max(0.05f, skillBonus); // Minimum 5% chance
|
||||
// Calculate skill quality bonus using EXPONENTIAL scaling
|
||||
// Every time you double the level requirement, your chance for perfect rolls increases exponentially
|
||||
//
|
||||
// Example: Recipe requires level 1, has 5 stats rolling 1-100 each
|
||||
// - At level 1 (1x): ~0.1% chance per stat = 0.00000000001% for all 5 perfect (basically impossible)
|
||||
// - At level 2 (2x): ~1% chance per stat = 0.000000001% for all 5 perfect (extremely rare)
|
||||
// - At level 4 (4x): ~10% chance per stat = 0.001% for all 5 perfect (very rare)
|
||||
// - At level 8 (8x): ~30% chance per stat = 0.24% for all 5 perfect (rare)
|
||||
// - At level 16 (16x): ~60% chance per stat = 7.7% for all 5 perfect (uncommon)
|
||||
// - At level 32 (32x): ~85% chance per stat = 44% for all 5 perfect (common)
|
||||
// - At level 64 (64x): ~95% chance per stat = 77% for all 5 perfect (very common)
|
||||
//
|
||||
// Formula: skillBonus = 1 - (0.999^(2^doublings))
|
||||
// This creates exponential growth where each doubling significantly increases your odds
|
||||
|
||||
_log.LogInformation("Skill bonus: {SkillBonus:F2} (level {Level} / required {Required}, ratio {Ratio:F2})",
|
||||
skillBonus, skill.Level, recipe.RequiredLevel, levelRatio);
|
||||
float levelRatio = (float)skill.Level / Math.Max(1, recipe.RequiredLevel);
|
||||
|
||||
// Calculate how many times we've doubled the requirement (log base 2)
|
||||
double doublings = Math.Log(levelRatio, 2);
|
||||
|
||||
// Exponential formula: each doubling dramatically increases quality
|
||||
// Using 0.999 as base means at exactly the requirement you have ~0.1% chance
|
||||
// At 2x (1 doubling) = ~1% chance
|
||||
// At 4x (2 doublings) = ~10% chance
|
||||
// At 8x (3 doublings) = ~30% chance
|
||||
// At 16x (4 doublings) = ~60% chance
|
||||
double exponentialFactor = Math.Pow(2, doublings);
|
||||
float skillBonus = (float)(1.0 - Math.Pow(0.999, exponentialFactor));
|
||||
|
||||
// Cap at 99% to keep some RNG element even at extreme overleveling
|
||||
skillBonus = Math.Min(0.99f, skillBonus);
|
||||
|
||||
// Ensure minimum of 0.1% chance even at minimum level
|
||||
skillBonus = Math.Max(0.001f, skillBonus);
|
||||
|
||||
_log.LogInformation("Skill bonus: {SkillBonus:F4} (level {Level} / required {Required}, ratio {Ratio:F2}x, doublings {Doublings:F2})",
|
||||
skillBonus, skill.Level, recipe.RequiredLevel, levelRatio, doublings);
|
||||
|
||||
int totalRolled = 0;
|
||||
int maxPossibleTotal = 0;
|
||||
|
||||
@@ -139,8 +139,12 @@
|
||||
{
|
||||
<span class="absolute bottom-0 right-0 bg-black/80 text-white text-[10px] px-0.5 rounded-tl">@item.Quantity</span>
|
||||
}
|
||||
@if (item.CraftedItem != null)
|
||||
{
|
||||
<span class="absolute top-0 left-0 text-cyan-400 text-[10px] font-bold">⚒️</span>
|
||||
}
|
||||
<div class="absolute left-full ml-1 top-0 z-50 hidden group-hover:block">
|
||||
@await Html.PartialAsync("_ItemTooltip", item.ItemDefinition)
|
||||
@await Html.PartialAsync("_CharacterItemTooltip", item)
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
@@ -221,7 +225,7 @@
|
||||
{
|
||||
var item = Model.EquippedItems.FirstOrDefault(i => i.EquipSlot == slot.Item1);
|
||||
<div class="flex items-center gap-2 p-1.5 bg-gray-800 rounded group relative">
|
||||
<div class="w-8 h-8 bg-gray-900 rounded border border-gray-700 flex items-center justify-center flex-shrink-0">
|
||||
<div class="w-8 h-8 bg-gray-900 rounded border border-gray-700 flex items-center justify-center flex-shrink-0 relative">
|
||||
@if (item?.ItemDefinition != null && !string.IsNullOrEmpty(item.ItemDefinition.SpritePath))
|
||||
{
|
||||
<img src="@Model.CdnBaseUrl/downloads/@item.ItemDefinition.SpritePath" class="w-6 h-6 object-contain" />
|
||||
@@ -230,17 +234,25 @@
|
||||
{
|
||||
<span class="text-gray-600 text-[10px]">@slot.Item2.Substring(0, 1)</span>
|
||||
}
|
||||
@if (item?.CraftedItem != null)
|
||||
{
|
||||
<span class="absolute -top-1 -right-1 text-cyan-400 text-[10px] font-bold">⚒️</span>
|
||||
}
|
||||
</div>
|
||||
<div class="flex-1 min-w-0">
|
||||
<p class="text-[10px] text-gray-500">@slot.Item2</p>
|
||||
<p class="text-xs @(item != null ? "text-white" : "text-gray-600 italic") truncate">
|
||||
@(item?.ItemDefinition?.Name ?? "Empty")
|
||||
@if (item?.CraftedItem != null)
|
||||
{
|
||||
<span class="text-cyan-400 text-[10px]">(Q@(item.CraftedItem.QualityRating)%)</span>
|
||||
}
|
||||
</p>
|
||||
</div>
|
||||
@if (item?.ItemDefinition != null)
|
||||
{
|
||||
<div class="absolute right-full mr-1 top-0 z-50 hidden group-hover:block">
|
||||
@await Html.PartialAsync("_ItemTooltip", item.ItemDefinition)
|
||||
@await Html.PartialAsync("_CharacterItemTooltip", item)
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,187 @@
|
||||
@model DataServer.Data.Entities.DungeonCharacterItem
|
||||
@using DataServer.Data.Enums
|
||||
|
||||
@{
|
||||
var def = Model.ItemDefinition;
|
||||
if (def == null) return;
|
||||
|
||||
var rarityColor = def.Rarity switch
|
||||
{
|
||||
ItemRarity.Uncommon => "text-green-400",
|
||||
ItemRarity.Rare => "text-blue-400",
|
||||
ItemRarity.Epic => "text-purple-400",
|
||||
ItemRarity.Legendary => "text-orange-400",
|
||||
_ => "text-gray-300"
|
||||
};
|
||||
|
||||
var rarityBg = def.Rarity switch
|
||||
{
|
||||
ItemRarity.Uncommon => "border-green-600",
|
||||
ItemRarity.Rare => "border-blue-600",
|
||||
ItemRarity.Epic => "border-purple-600",
|
||||
ItemRarity.Legendary => "border-orange-600",
|
||||
_ => "border-gray-600"
|
||||
};
|
||||
|
||||
// Calculate total stats (base + crafted)
|
||||
var (totalStr, totalInt, totalWis, totalEnd, totalDex, totalHealth, totalMana) = Model.GetTotalStats(def);
|
||||
var craftedItem = Model.CraftedItem;
|
||||
var hasCraftedStats = craftedItem != null;
|
||||
|
||||
int totalMinDamage = def.MinDamage + (craftedItem?.RolledBonusMinDamage ?? 0);
|
||||
int totalMaxDamage = def.MaxDamage + (craftedItem?.RolledBonusMaxDamage ?? 0);
|
||||
int totalArmor = def.Armor + (craftedItem?.RolledBonusArmor ?? 0);
|
||||
}
|
||||
|
||||
<div class="bg-gray-900 border @rarityBg rounded-lg p-3 w-64 shadow-xl">
|
||||
<!-- Header -->
|
||||
<div class="mb-2">
|
||||
<p class="font-semibold @rarityColor">
|
||||
@if (!string.IsNullOrEmpty(craftedItem?.CustomName))
|
||||
{
|
||||
@craftedItem.CustomName
|
||||
}
|
||||
else
|
||||
{
|
||||
@def.Name
|
||||
}
|
||||
</p>
|
||||
<p class="text-xs text-gray-500">@def.Type • @def.Rarity</p>
|
||||
@if (hasCraftedStats)
|
||||
{
|
||||
<p class="text-xs text-cyan-400">⚒️ Crafted (Quality: @craftedItem!.QualityRating%)</p>
|
||||
<p class="text-xs text-gray-500">by @craftedItem.CrafterName</p>
|
||||
}
|
||||
</div>
|
||||
|
||||
@if (!string.IsNullOrEmpty(def.Description))
|
||||
{
|
||||
<p class="text-xs text-gray-400 italic mb-2">@def.Description</p>
|
||||
}
|
||||
|
||||
<!-- Weapon Stats -->
|
||||
@if (totalMinDamage > 0 || totalMaxDamage > 0)
|
||||
{
|
||||
<div class="text-sm mb-2">
|
||||
<span class="text-white">@totalMinDamage - @totalMaxDamage</span>
|
||||
<span class="text-gray-500">@def.DamageTypeKey Damage</span>
|
||||
@if (hasCraftedStats && (craftedItem!.RolledBonusMinDamage > 0 || craftedItem.RolledBonusMaxDamage > 0))
|
||||
{
|
||||
<span class="text-cyan-400 text-xs block">+@craftedItem.RolledBonusMinDamage-@craftedItem.RolledBonusMaxDamage (crafted)</span>
|
||||
}
|
||||
@if (def.AttackRange > 0)
|
||||
{
|
||||
<span class="text-gray-500 block text-xs">Range: @def.AttackRange</span>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- Armor Stats -->
|
||||
@if (totalArmor > 0)
|
||||
{
|
||||
<div class="text-sm mb-2 space-y-1">
|
||||
<p>
|
||||
<span class="text-gray-500">Armor:</span>
|
||||
<span class="text-white">@totalArmor</span>
|
||||
@if (hasCraftedStats && craftedItem!.RolledBonusArmor > 0)
|
||||
{
|
||||
<span class="text-cyan-400 text-xs">(+@craftedItem.RolledBonusArmor crafted)</span>
|
||||
}
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- Stat Bonuses -->
|
||||
@{
|
||||
var bonuses = new List<(string name, int baseValue, int craftedValue, int total, string color)>();
|
||||
if (totalStr != 0) bonuses.Add(("STR", def.BonusStrength, craftedItem?.RolledBonusStrength ?? 0, totalStr, "text-red-400"));
|
||||
if (totalInt != 0) bonuses.Add(("INT", def.BonusIntelligence, craftedItem?.RolledBonusIntelligence ?? 0, totalInt, "text-blue-400"));
|
||||
if (totalWis != 0) bonuses.Add(("WIS", def.BonusWisdom, craftedItem?.RolledBonusWisdom ?? 0, totalWis, "text-purple-400"));
|
||||
if (totalEnd != 0) bonuses.Add(("END", def.BonusEndurance, craftedItem?.RolledBonusEndurance ?? 0, totalEnd, "text-green-400"));
|
||||
if (totalDex != 0) bonuses.Add(("DEX", def.BonusDexterity, craftedItem?.RolledBonusDexterity ?? 0, totalDex, "text-yellow-400"));
|
||||
if (totalHealth != 0) bonuses.Add(("HP", def.BonusHealth, craftedItem?.RolledBonusHealth ?? 0, totalHealth, "text-green-300"));
|
||||
if (totalMana != 0) bonuses.Add(("Mana", def.BonusMana, craftedItem?.RolledBonusMana ?? 0, totalMana, "text-blue-300"));
|
||||
}
|
||||
@if (bonuses.Any())
|
||||
{
|
||||
<div class="text-sm mb-2 space-y-0.5">
|
||||
@foreach (var bonus in bonuses)
|
||||
{
|
||||
var sign = bonus.total > 0 ? "+" : "";
|
||||
<p class="@bonus.color">
|
||||
@sign@bonus.total @bonus.name
|
||||
@if (bonus.craftedValue > 0)
|
||||
{
|
||||
<span class="text-cyan-400 text-xs">(+@bonus.craftedValue crafted)</span>
|
||||
}
|
||||
</p>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- Consumable Effects -->
|
||||
@if (def.HealAmount > 0 || def.ManaRestore > 0 || def.StaminaRestore > 0)
|
||||
{
|
||||
<div class="text-sm mb-2 space-y-0.5 text-green-400">
|
||||
@if (def.HealAmount > 0)
|
||||
{
|
||||
<p>Restores @def.HealAmount HP</p>
|
||||
}
|
||||
@if (def.ManaRestore > 0)
|
||||
{
|
||||
<p>Restores @def.ManaRestore Mana</p>
|
||||
}
|
||||
@if (def.StaminaRestore > 0)
|
||||
{
|
||||
<p>Restores @def.StaminaRestore Stamina</p>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- Requirements -->
|
||||
@{
|
||||
var reqs = new List<string>();
|
||||
if (def.RequiredLevel > 1) reqs.Add($"Level {def.RequiredLevel}");
|
||||
if (def.RequiredStrength > 0) reqs.Add($"{def.RequiredStrength} STR");
|
||||
if (def.RequiredIntelligence > 0) reqs.Add($"{def.RequiredIntelligence} INT");
|
||||
if (def.RequiredWisdom > 0) reqs.Add($"{def.RequiredWisdom} WIS");
|
||||
if (def.RequiredDexterity > 0) reqs.Add($"{def.RequiredDexterity} DEX");
|
||||
}
|
||||
@if (reqs.Any())
|
||||
{
|
||||
<div class="text-xs text-red-400 mt-2 pt-2 border-t border-gray-700">
|
||||
Requires: @string.Join(", ", reqs)
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- Special -->
|
||||
@if (def.IsTeleportScroll)
|
||||
{
|
||||
<p class="text-xs text-cyan-400 mt-1">Teleport Scroll</p>
|
||||
}
|
||||
@if (def.TeachesSpellId.HasValue)
|
||||
{
|
||||
<p class="text-xs text-cyan-400 mt-1">Teaches a spell</p>
|
||||
}
|
||||
|
||||
<!-- Stack Info -->
|
||||
@if (def.Stackable && Model.Quantity > 1)
|
||||
{
|
||||
<p class="text-xs text-gray-500 mt-2">Quantity: @Model.Quantity / @def.MaxStack</p>
|
||||
}
|
||||
|
||||
<!-- Equip Slot -->
|
||||
@if (def.EquipSlot.HasValue)
|
||||
{
|
||||
<p class="text-xs text-gray-500 mt-1">Slot: @def.EquipSlot</p>
|
||||
}
|
||||
|
||||
<!-- Item IDs -->
|
||||
<p class="text-xs text-gray-600 mt-2">
|
||||
Item ID: @Model.Id
|
||||
@if (hasCraftedStats)
|
||||
{
|
||||
<span class="block">Craft ID: @craftedItem!.Id</span>
|
||||
}
|
||||
</p>
|
||||
</div>
|
||||
Reference in New Issue
Block a user