mirror of
https://github.com/ACEmulator/ACE
synced 2026-08-17 12:26:06 -04:00
This will at least somewhat improve performance, as confirmed through microbenchmark testing. const fields are replaced with literal values in the Assembly's IL code, while static readonly fields may be optimized by the JIT, and is not guaranteed to happen. const fields may also lend themselves to stronger optimizations at runtime.
39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using ACE.Entity.Enum.Properties;
|
|
|
|
namespace ACE.Server.WorldObjects
|
|
{
|
|
public class SkillFormula
|
|
{
|
|
// everything else: melee weapons (including finesse), thrown weapons, atlatls
|
|
public const float DefaultMod = 0.011f;
|
|
|
|
// bows and crossbows
|
|
public const float BowMod = 0.008f;
|
|
|
|
public const float ArmorMod = 200.0f / 3.0f;
|
|
|
|
public static float GetAttributeMod(int currentSkill, bool isBow = false)
|
|
{
|
|
var factor = isBow ? BowMod : DefaultMod;
|
|
|
|
return Math.Max(1.0f + (currentSkill - 55) * factor, 1.0f);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Converts AL from an additive linear value
|
|
/// to a scaled damage multiplier
|
|
/// </summary>
|
|
public static float CalcArmorMod(float armorLevel)
|
|
{
|
|
if (armorLevel > 0)
|
|
return ArmorMod / (armorLevel + ArmorMod);
|
|
else if (armorLevel < 0)
|
|
return 1.0f - armorLevel / ArmorMod;
|
|
else
|
|
return 1.0f;
|
|
}
|
|
}
|
|
}
|