Class FormulaHelper
Common formulas used throughout game.
Where the exact formula is unknown, a "best effort" approximation will be used.
Most formula can be overridden by registering a new method matching the appropriate delegate signature.
Other signatures can be added upon demand.
Inheritance
FormulaHelper
Assembly: Assembly-CSharp.dll
public static class FormulaHelper
Fields
|
Improve this Doc
View Source
Declaration
public const int classicFrameUpdate = 980
Field Value
|
Improve this Doc
View Source
Declaration
public static float specialInfectionChance
Field Value
Methods
|
Improve this Doc
View Source
Declaration
public static int AdjustWeaponAttackDamage(DaggerfallEntity attacker, DaggerfallEntity target, int damage, int weaponAnimTime, DaggerfallUnityItem weapon)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static int AdjustWeaponHitChanceMod(DaggerfallEntity attacker, DaggerfallEntity target, int hitChanceMod, int weaponAnimTime, DaggerfallUnityItem weapon)
Parameters
Returns
|
Improve this Doc
View Source
Applies condition damage to an item based on physical hit damage.
Declaration
public static void ApplyConditionDamageThroughPhysicalHit(DaggerfallUnityItem item, DaggerfallEntity owner, int damage)
Parameters
|
Improve this Doc
View Source
Declaration
public static int ApplyRegionalPriceAdjustment(int cost)
Parameters
Type |
Name |
Description |
Int32 |
cost |
|
Returns
|
Improve this Doc
View Source
Declaration
public static int ApplyTargetCostMultiplier(int cost, TargetTypes targetType)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static int BonusPool()
Returns
|
Improve this Doc
View Source
Declaration
public static int CalculateAdjustmentsToHit(DaggerfallEntity attacker, DaggerfallEntity target)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static int CalculateAdrenalineRushToHit(DaggerfallEntity attacker, DaggerfallEntity target)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static int CalculateArmorToHit(DaggerfallEntity target, int struckBodyPart)
Parameters
Returns
|
Improve this Doc
View Source
Calculate the damage caused by an attack.
Declaration
public static int CalculateAttackDamage(DaggerfallEntity attacker, DaggerfallEntity target, bool isEnemyFacingAwayFromPlayer, int weaponAnimTime, DaggerfallUnityItem weapon)
Parameters
Type |
Name |
Description |
DaggerfallEntity |
attacker |
Attacking entity
|
DaggerfallEntity |
target |
Target entity
|
Boolean |
isEnemyFacingAwayFromPlayer |
Whether enemy is facing away from player, used for backstabbing
|
Int32 |
weaponAnimTime |
Time the weapon animation lasted before the attack in ms, used for bow drawing
|
DaggerfallUnityItem |
weapon |
The weapon item being used
|
Returns
Type |
Description |
Int32 |
Damage inflicted to target, can be 0 for a miss or ineffective hit
|
|
Improve this Doc
View Source
Declaration
public static int CalculateBackstabChance(PlayerEntity player, DaggerfallEntity target, bool isEnemyFacingAwayFromPlayer)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static int CalculateBackstabDamage(int damage, int backstabbingLevel)
Parameters
Type |
Name |
Description |
Int32 |
damage |
|
Int32 |
backstabbingLevel |
|
Returns
|
Improve this Doc
View Source
Declaration
public static int CalculateBankLoanRepayment(int amount, int regionIndex)
Parameters
Type |
Name |
Description |
Int32 |
amount |
|
Int32 |
regionIndex |
|
Returns
|
Improve this Doc
View Source
Declaration
public static int CalculateCasterLevel(DaggerfallEntity caster, IEntityEffect effect)
Parameters
Returns
|
Improve this Doc
View Source
Reversed from classic. Calculates cost of casting a spell. This cost is also used
to lower item condition when equipping an item whith a "Cast when held" effect.
For now this is only being used for enchanted items, because there is other code for entity-cast spells.
Declaration
public static int CalculateCastingCost(SpellRecord.SpellRecordData spell, bool enchantingItem = true)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static int CalculateClimbingChance(PlayerEntity player, int basePercentSuccess)
Parameters
Returns
|
Improve this Doc
View Source
Calculate the cost of something in a given shop.
Declaration
public static int CalculateCost(int baseValue, int shopQuality, int conditionPercentage = -1)
Parameters
Type |
Name |
Description |
Int32 |
baseValue |
Base value
|
Int32 |
shopQuality |
Shop quality 0-20
|
Int32 |
conditionPercentage |
Condition of item as a percentage, -1 indicates condition not applicable
|
Returns
Type |
Description |
Int32 |
Shop specific cost
|
|
Improve this Doc
View Source
Declaration
public static int CalculateDaedraSummoningChance(int daedraRep, int bonus)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static int CalculateDaedraSummoningCost(int npcRep)
Parameters
Type |
Name |
Description |
Int32 |
npcRep |
|
Returns
|
Improve this Doc
View Source
CalculateEffectCosts(EffectEntry, DaggerfallEntity)
Calculate effect costs from an EffectEntry.
Declaration
public static FormulaHelper.SpellCost CalculateEffectCosts(EffectEntry effectEntry, DaggerfallEntity casterEntity = null)
Parameters
Returns
|
Improve this Doc
View Source
Calculates effect costs from an IEntityEffect and custom settings.
Declaration
public static FormulaHelper.SpellCost CalculateEffectCosts(IEntityEffect effect, EffectSettings settings, DaggerfallEntity casterEntity = null)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static bool CalculateEnemyPacification(PlayerEntity player, DFCareer.Skills languageSkill)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static int CalculateExteriorLockpickingChance(int lockvalue, int lockpickingSkill)
Parameters
Type |
Name |
Description |
Int32 |
lockvalue |
|
Int32 |
lockpickingSkill |
|
Returns
|
Improve this Doc
View Source
Declaration
public static int CalculateFatigueRecoveryRate(int maxFatigue)
Parameters
Type |
Name |
Description |
Int32 |
maxFatigue |
|
Returns
|
Improve this Doc
View Source
Declaration
public static int CalculateHandToHandAttackDamage(DaggerfallEntity attacker, DaggerfallEntity target, int damageModifier, bool player)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static int CalculateHandToHandMaxDamage(int handToHandSkill)
Parameters
Type |
Name |
Description |
Int32 |
handToHandSkill |
|
Returns
|
Improve this Doc
View Source
Declaration
public static int CalculateHandToHandMinDamage(int handToHandSkill)
Parameters
Type |
Name |
Description |
Int32 |
handToHandSkill |
|
Returns
|
Improve this Doc
View Source
Declaration
public static int CalculateHealthRecoveryRate(PlayerEntity player)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static int CalculateHitPointsPerLevelUp(PlayerEntity player)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static int CalculateInteriorLockpickingChance(int level, int lockvalue, int lockpickingSkill)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static int CalculateItemIdentifyCost(int baseItemValue, IGuild guild)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static int CalculateItemRepairCost(int baseItemValue, int shopQuality, int condition, int max, IGuild guild)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static int CalculateItemRepairTime(int condition, int max)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static int CalculateMaxBankLoan()
Returns
|
Improve this Doc
View Source
Declaration
public static int CalculatePickpocketingChance(PlayerEntity player, EnemyEntity target)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static int CalculatePlayerLevel(int startingLevelUpSkillsSum, int currentLevelUpSkillsSum)
Parameters
Type |
Name |
Description |
Int32 |
startingLevelUpSkillsSum |
|
Int32 |
currentLevelUpSkillsSum |
|
Returns
|
Improve this Doc
View Source
Declaration
public static FormulaHelper.ToHitAndDamageMods CalculateProficiencyModifiers(DaggerfallEntity attacker, DaggerfallUnityItem weapon)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static FormulaHelper.ToHitAndDamageMods CalculateRacialModifiers(DaggerfallEntity attacker, DaggerfallUnityItem weapon, PlayerEntity player)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static int CalculateRoomCost(int daysToRent)
Parameters
Type |
Name |
Description |
Int32 |
daysToRent |
|
Returns
|
Improve this Doc
View Source
Declaration
public static int CalculateShopliftingChance(PlayerEntity player, int shopQuality, int weightAndNumItems)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static int CalculateSkillsToHit(DaggerfallEntity attacker, DaggerfallEntity target)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static int CalculateSkillUsesForAdvancement(int skillValue, int skillAdvancementMultiplier, float careerAdvancementMultiplier, int level)
Parameters
Type |
Name |
Description |
Int32 |
skillValue |
|
Int32 |
skillAdvancementMultiplier |
|
Single |
careerAdvancementMultiplier |
|
Int32 |
level |
|
Returns
|
Improve this Doc
View Source
Declaration
public static int CalculateSpellPointRecoveryRate(PlayerEntity player)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static int CalculateStatsToHit(DaggerfallEntity attacker, DaggerfallEntity target)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static int CalculateStealthChance(float distanceToTarget, DaggerfallEntityBehaviour target)
Parameters
Returns
|
Improve this Doc
View Source
CalculateStruckBodyPart()
Declaration
public static int CalculateStruckBodyPart()
Returns
|
Improve this Doc
View Source
Calculates whether an attack on a target is successful or not.
Declaration
public static bool CalculateSuccessfulHit(DaggerfallEntity attacker, DaggerfallEntity target, int chanceToHitMod, int struckBodyPart)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static FormulaHelper.ToHitAndDamageMods CalculateSwingModifiers(FPSWeapon onscreenWeapon)
Parameters
Type |
Name |
Description |
FPSWeapon |
onscreenWeapon |
|
Returns
|
Improve this Doc
View Source
Declaration
public static int CalculateTempleBlessing(int donationAmount, int deityRep)
Parameters
Type |
Name |
Description |
Int32 |
donationAmount |
|
Int32 |
deityRep |
|
Returns
|
Improve this Doc
View Source
CalculateTotalEffectCosts(EffectEntry[], TargetTypes, DaggerfallEntity, Boolean)
Performs complete gold and spellpoint costs for an array of effects.
Also calculates multipliers for target type.
Declaration
public static FormulaHelper.SpellCost CalculateTotalEffectCosts(EffectEntry[] effectEntries, TargetTypes targetType, DaggerfallEntity casterEntity = null, bool minimumCastingCost = false)
Parameters
Type |
Name |
Description |
EffectEntry[] |
effectEntries |
EffectEntry array for spell.
|
TargetTypes |
targetType |
Target type of spell.
|
DaggerfallEntity |
casterEntity |
Caster entity. Assumed to be player if null.
|
Boolean |
minimumCastingCost |
Spell point always costs minimum (e.g. from vampirism). Do not set true for reflection/absorption cost calculations.
|
Returns
|
Improve this Doc
View Source
Declaration
public static int CalculateTradePrice(int cost, int shopQuality, bool selling)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static int CalculateWeaponAttackDamage(DaggerfallEntity attacker, DaggerfallEntity target, int damageModifier, int weaponAnimTime, DaggerfallUnityItem weapon)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static int CalculateWeaponMaxDamage(Weapons weapon)
Parameters
Type |
Name |
Description |
Weapons |
weapon |
|
Returns
|
Improve this Doc
View Source
Declaration
public static int CalculateWeaponMinDamage(Weapons weapon)
Parameters
Type |
Name |
Description |
Weapons |
weapon |
|
Returns
|
Improve this Doc
View Source
Declaration
public static int CalculateWeaponToHit(DaggerfallUnityItem weapon)
Parameters
Returns
|
Improve this Doc
View Source
Allocate any equipment damage from a strike, and reduce item condition.
Declaration
public static void DamageEquipment(DaggerfallEntity attacker, DaggerfallEntity target, int damage, DaggerfallUnityItem weapon, int struckBodyPart)
Parameters
|
Improve this Doc
View Source
Declaration
public static int DamageModifier(int strength)
Parameters
Type |
Name |
Description |
Int32 |
strength |
|
Returns
|
Improve this Doc
View Source
Declaration
public static void FatigueDamage(EnemyEntity attacker, DaggerfallEntity target, int damage)
Parameters
|
Improve this Doc
View Source
Declaration
public static float GetArmorEnchantmentMultiplier(ArmorMaterialTypes armorMaterial)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static int GetBonusOrPenaltyByEnemyType(DaggerfallEntity attacker, DaggerfallEntity target)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static float GetBowCooldownTime(PlayerEntity player)
Parameters
Returns
|
Improve this Doc
View Source
Reversed from classic. Used wih calculating cost of casting a spell.
This uses the spell's settings for chance, duration and magnitude together with coefficients for that effect
to get the cost of the effect, before the range type modifier is applied.
Declaration
public static int getCostFromSettings(int settingsType, int effectNumber, SpellRecord.SpellRecordData spellData, ushort[] coefficients)
Parameters
Returns
|
Improve this Doc
View Source
Gets DFCareer.EffectFlags from an effect.
Note: If effect is not instanced by a bundle then it will not have an element type.
Declaration
public static DFCareer.EffectFlags GetEffectFlags(IEntityEffect effect)
Parameters
Returns
|
Improve this Doc
View Source
Gets a resistance element based on effect element.
Declaration
public static DFCareer.Elements GetElementType(IEntityEffect effect)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static int GetHolidayId(uint gameMinutes, int regionIndex)
Parameters
Type |
Name |
Description |
UInt32 |
gameMinutes |
|
Int32 |
regionIndex |
|
Returns
|
Improve this Doc
View Source
Gets the maximum enchantment capacity for any item.
Declaration
public static int GetItemEnchantmentPower(DaggerfallUnityItem item)
Parameters
Returns
Type |
Description |
Int32 |
Item max enchantment power.
|
|
Improve this Doc
View Source
Declaration
public static float GetMeleeWeaponAnimTime(PlayerEntity player, WeaponTypes weaponType, ItemHands weaponHands)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static int GetResistanceModifier(DFCareer.EffectFlags effectFlags, DaggerfallEntity target)
Parameters
Returns
|
Improve this Doc
View Source
Reversed from classic. Calculates enchantment point/gold value for a spell being attached to an item.
Declaration
public static int GetSpellEnchantPtCost(int spellIndex)
Parameters
Type |
Name |
Description |
Int32 |
spellIndex |
Index of spell in SPELLS.STD.
|
Returns
|
Improve this Doc
View Source
Declaration
public static DFCareer.ToleranceFlags GetToleranceFlag(DFCareer.Tolerance tolerance)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static VampireClans GetVampireClan(int regionIndex)
Parameters
Type |
Name |
Description |
Int32 |
regionIndex |
|
Returns
|
Improve this Doc
View Source
Declaration
public static float GetWeaponEnchantmentMultiplier(WeaponMaterialTypes weaponMaterial)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static int HealingRateModifier(int endurance)
Parameters
Type |
Name |
Description |
Int32 |
endurance |
|
Returns
|
Improve this Doc
View Source
Declaration
public static int HitPointsModifier(int endurance)
Parameters
Type |
Name |
Description |
Int32 |
endurance |
|
Returns
|
Improve this Doc
View Source
Inflict a classic disease onto player.
Declaration
public static void InflictDisease(DaggerfallEntity attacker, DaggerfallEntity target, Diseases[] diseaseList)
Parameters
Type |
Name |
Description |
DaggerfallEntity |
attacker |
Source entity. Can be the same as target
|
DaggerfallEntity |
target |
Target entity - must be player.
|
Diseases[] |
diseaseList |
Array of disease indices matching Diseases enum.
|
|
Improve this Doc
View Source
Inflict a classic poison onto entity.
Declaration
public static void InflictPoison(DaggerfallEntity attacker, DaggerfallEntity target, Poisons poisonType, bool bypassResistance)
Parameters
|
Improve this Doc
View Source
Declaration
public static bool IsItemStackable(DaggerfallUnityItem item)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static int MagicResist(int willpower)
Parameters
Type |
Name |
Description |
Int32 |
willpower |
|
Returns
|
Improve this Doc
View Source
Declaration
public static int MaxEncumbrance(int strength)
Parameters
Type |
Name |
Description |
Int32 |
strength |
|
Returns
|
Improve this Doc
View Source
Declaration
public static int MaxStatValue()
Returns
|
Improve this Doc
View Source
Declaration
public static int ModifyEffectAmount(IEntityEffect sourceEffect, DaggerfallEntity target, int amount)
Parameters
Returns
|
Improve this Doc
View Source
Execute special monster attack effects.
Declaration
public static void OnMonsterHit(EnemyEntity attacker, DaggerfallEntity target, int damage)
Parameters
|
Improve this Doc
View Source
Gets a random armor material based on player level.
Declaration
public static ArmorMaterialTypes RandomArmorMaterial(int playerLevel)
Parameters
Type |
Name |
Description |
Int32 |
playerLevel |
Player level, possibly adjusted.
|
Returns
|
Improve this Doc
View Source
Declaration
public static void RandomizeInitialRegionalPrices(ref PlayerEntity.RegionDataRecord[] regionData)
Parameters
|
Improve this Doc
View Source
Gets a random material based on player level.
Note, this is called by default RandomArmorMaterial function.
Declaration
public static WeaponMaterialTypes RandomMaterial(int playerLevel)
Parameters
Type |
Name |
Description |
Int32 |
playerLevel |
Player level, possibly adjusted.
|
Returns
|
Improve this Doc
View Source
Registers an override for a formula using a generic System.Func{T}
callback
with the same signature as the method it overrides
(i.e. RegisterOverride{Func{int, int, float}}("FormulaName", (a, b) => (float)a / b);
).
The invocation will fail if signature is not correct, meaning if the delegate
is not one of the variation of Func
with the expected arguments.
Declaration
public static void RegisterOverride<TDelegate>(Mod provider, string formulaName, TDelegate formula)
where TDelegate : class
Parameters
Type |
Name |
Description |
Mod |
provider |
The mod that provides this override; used to enforce load order.
|
String |
formulaName |
The name of the method that provides the formula.
|
TDelegate |
formula |
A callback that implements the formula.
|
Type Parameters
Name |
Description |
TDelegate |
One of the available generic Func delegates.
|
Exceptions
|
Improve this Doc
View Source
Declaration
public static int RollEnemyClassMaxHealth(int level, int hitPointsPerLevel)
Parameters
Type |
Name |
Description |
Int32 |
level |
|
Int32 |
hitPointsPerLevel |
|
Returns
|
Improve this Doc
View Source
Declaration
public static int RollMaxHealth(PlayerEntity player)
Parameters
Returns
|
Improve this Doc
View Source
Roll for random spawn in dungeons.
Declaration
public static int RollRandomSpawn_Dungeon()
Returns
Type |
Description |
Int32 |
0 to generate a spawn. >0 to not generate a spawn.
|
|
Improve this Doc
View Source
Roll for random spawn in location area at night.
Declaration
public static int RollRandomSpawn_LocationNight()
Returns
Type |
Description |
Int32 |
0 to generate a spawn. >0 to not generate a spawn.
|
|
Improve this Doc
View Source
Roll for random spawn in wilderness during daylight hours.
Declaration
public static int RollRandomSpawn_WildernessDay()
Returns
Type |
Description |
Int32 |
0 to generate a spawn. >0 to not generate a spawn.
|
|
Improve this Doc
View Source
Roll for random spawn in wilderness at night.
Declaration
public static int RollRandomSpawn_WildernessNight()
Returns
Type |
Description |
Int32 |
0 to generate a spawn. >0 to not generate a spawn.
|
|
Improve this Doc
View Source
Declaration
public static int SavingThrow(DFCareer.Elements elementType, DFCareer.EffectFlags effectFlags, DaggerfallEntity target, int modifier)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static int SavingThrow(IEntityEffect sourceEffect, DaggerfallEntity target)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static int SpellPoints(int intelligence, float multiplier)
Parameters
Type |
Name |
Description |
Int32 |
intelligence |
|
Single |
multiplier |
|
Returns
|
Improve this Doc
View Source
Declaration
public static int ToHitModifier(int agility)
Parameters
Type |
Name |
Description |
Int32 |
agility |
|
Returns
|
Improve this Doc
View Source
Declaration
public static void UpdateRegionalPrices(ref PlayerEntity.RegionDataRecord[] regionData, int times)
Parameters