stat fix
This commit is contained in:
@@ -96,9 +96,11 @@ public static class CombatCalculator
|
||||
damage *= (1 - playerResist);
|
||||
}
|
||||
|
||||
// 3. Endurance provides flat damage reduction
|
||||
float enduranceReduction = player.Endurance * 0.5f; // 0.5 flat reduction per END
|
||||
damage = Math.Max(1, damage - enduranceReduction);
|
||||
// 3. Endurance provides percentage damage reduction (capped at 50%)
|
||||
// Formula: END / (END + 100) gives diminishing returns
|
||||
float enduranceReduction = player.Endurance / (float)(player.Endurance + 100);
|
||||
enduranceReduction = Math.Min(enduranceReduction, 0.50f); // Cap at 50% reduction
|
||||
damage *= (1.0f - enduranceReduction);
|
||||
|
||||
int finalDamage = Math.Max(1, (int)damage);
|
||||
|
||||
|
||||
@@ -621,6 +621,54 @@ public sealed partial class DungeonHandler : IClientMessageHandler
|
||||
db.Entry(character).Property(c => c.UnspentStatPoints).IsModified = true;
|
||||
await db.SaveChangesAsync(ct);
|
||||
|
||||
// If player is in dungeon, update their stats in simulation immediately
|
||||
if (session.State == PlayerState.InDungeon && session.DungeonId.HasValue)
|
||||
{
|
||||
if (_dungeons.TryGetValue(session.DungeonId.Value, out var dungeon))
|
||||
{
|
||||
if (dungeon.Simulation.Players.TryGetValue(session.CharacterId, out var player))
|
||||
{
|
||||
// Recalculate combat stats with new base stats
|
||||
var equippedItems = await db.DungeonCharacterItems
|
||||
.Include(i => i.ItemDefinition)
|
||||
.Include(i => i.CraftedItem)
|
||||
.Where(i => i.CharacterId == character.Id && i.IsEquipped)
|
||||
.ToListAsync(ct);
|
||||
|
||||
var newStats = DungeonCharacterStats.GetCombatStats(character, equippedItems);
|
||||
|
||||
// Update player instance stats
|
||||
player.Strength = newStats.Strength;
|
||||
player.Intelligence = newStats.Intelligence;
|
||||
player.Wisdom = newStats.Wisdom;
|
||||
player.Endurance = newStats.Endurance;
|
||||
player.Dexterity = newStats.Dexterity;
|
||||
player.Armor = newStats.Armor;
|
||||
player.MoveSpeed = newStats.MoveSpeed;
|
||||
player.AttackSpeed = newStats.AttackSpeed;
|
||||
|
||||
// Update max health/mana/stamina and heal the difference
|
||||
float oldMaxHealth = player.MaxHealth;
|
||||
float oldMaxMana = player.MaxMana;
|
||||
float oldMaxStamina = player.MaxStamina;
|
||||
|
||||
player.MaxHealth = newStats.MaxHealth;
|
||||
player.MaxMana = newStats.MaxMana;
|
||||
player.MaxStamina = newStats.MaxStamina;
|
||||
|
||||
// Heal the difference when max increases
|
||||
if (newStats.MaxHealth > oldMaxHealth)
|
||||
player.Health = Math.Min(newStats.MaxHealth, player.Health + (newStats.MaxHealth - oldMaxHealth));
|
||||
if (newStats.MaxMana > oldMaxMana)
|
||||
player.Mana = Math.Min(newStats.MaxMana, player.Mana + (newStats.MaxMana - oldMaxMana));
|
||||
if (newStats.MaxStamina > oldMaxStamina)
|
||||
player.Stamina = Math.Min(newStats.MaxStamina, player.Stamina + (newStats.MaxStamina - oldMaxStamina));
|
||||
|
||||
Console.WriteLine($"[StatAllocate] Updated {character.Name}'s stats in dungeon - STR:{player.Strength} INT:{player.Intelligence} WIS:{player.Wisdom} END:{player.Endurance} DEX:{player.Dexterity}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await SendAsync(connection, DungeonOpCodes.HUB_STATE, GetHubState(character), ct);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user