Altering damage dealt through script

Post » Tue Jun 21, 2011 3:25 pm

I have a couple of mods that use OnHit event handlers to alter the damage an actor receives in melee combat. The thing is, I try to replicate in them the same formulas that the game uses to calculate damage, but my results are only a good approximation at best: I can't factor for things like damage multiplier to and from the player due to game difficulty, or consistently apply skill caps.

This is an OnHit handler that I use for applying a 'silver multiplier'
	let weapon := attacker.GetEquippedObject 16	let name := $weapon	If (CompareModelPath "silver" weapon || sv_Count "silver" weapon > 0 || CompareModelPath "mithril" weapon || sv_Count "mithril" weapon > 0)		let damage := (GetAttackDamage weapon)*(GetGS fDamageWeaponMult)		If GetWeaponType weapon != 5			let attribute := 0			If GetWeaponType weapon < 2				let skill := 14			Else				let skill := 16			EndIf		Else			let attribute := 3			let skill := 28		EndIf		let damage *= ((GetGS fDamageStrengthBase) + (attacker.GetAVC attribute)*0.01*(GetGS fDamageStrengthMult))*((GetGS fDamageSkillBase) + (attacker.GetAVC skill)*0.01*(GetGS fDamageSkillMult))*((GetGS fDamageWeaponConditionBase) + (((attacker.GetEquippedCurrentHealth 16)/(GetObjectHealth weapon))*(GetGS fDamageWeaponConditionMult)))		let damage += attacker.GetAV AttackBonus		If target.IsBlocking			let block := (((target.GetAV Block)*(GetGS fBlockSkillMult)*0.01) + (GetGS fBlockSkillBase))			If (target.GetEquippedObject 13 == 0)				if target.GetEquippedObject 16					let block *= (GetGS fBlockAmountWeaponMult)				else					let block *= (GetGS fBlockAmountHandToHandMult)				endif			Endif			if block > (GetGS fBlockMax)				let block := (GetGS fBlockMax)			endif		EndIf		let resist := (100 - target.GetAV ReflectDamage)*0.01*(100 - target.GetArmorRating)*0.01		If resist > 0 && block < 1			let damage *= -1*resist*(1 - block)		Else			Return		EndIf		let damage *= fSilverVampireMult		If damage < 0			If target.GetAV Health > -damage				target.ModAV2 Health damage			Else				target.Kill attacker			Endif		EndIf	EndIf

I'm not very sure if it actually works with bows at all. And it doesn't take the damage multiplier from game difficulty into account, which I don't know how to calculate.
Is there some better, less cumbersome way for doing this? Basically detecting the actual damage value an actor has sustained in a blow and being able to do stuff with it, instead of using all that formula to figure out how much damage the actor should have received in the last blow.
User avatar
Crystal Birch
 
Posts: 3416
Joined: Sat Mar 03, 2007 3:34 pm

Post » Tue Jun 21, 2011 4:57 am

I have a couple of mods that use OnHit event handlers to alter the damage an actor receives in melee combat. The thing is, I try to replicate in them the same formulas that the game uses to calculate damage, but my results are only a good approximation at best: I can't factor for things like damage multiplier to and from the player due to game difficulty, or consistently apply skill caps.

This is an OnHit handler that I use for applying a 'silver multiplier'
[...]
I'm not very sure if it actually works with bows at all. And it doesn't take the damage multiplier from game difficulty into account, which I don't know how to calculate.
Is there some better, less cumbersome way for doing this? Basically detecting the actual damage value an actor has sustained in a blow and being able to do stuff with it, instead of using all that formula to figure out how much damage the actor should have received in the last blow.

Note that GetIgnoresResistance can be used to check if a weapon is silver. Also, SetEquippedWeaponPoison might be an interesting way to do this. You could also use an OnHealthDamage handler, which gives you the attacker and the damage dealt.

The UESP wikip http://www.uesp.net/wiki/Oblivion:The_Complete_Damage_Formula page is not great, but basically seems to have most of it right. It says that the governing attribute for bows is agility, not strength. It also mentions fatigue as a factor... see http://cs.elderscrolls.com/constwiki/index.php/Fatigue_Game_Settings and look for FatigueFactor for the game settings actually used in the Damage Formula.

I have no idea how game difficulty factors in... the docs mention a few related settings but don't seem to explain what effect they have. The settings I can see on the http://cs.elderscrolls.com/constwiki/index.php/Category:Settings page would suggest something like this;

DamageOffset = fDifficultyDamageMultiplier*difficulty

Where difficulty defaults to fDifficultyDefaultValue = http://forums.bethsoft.com/index.php?/topic/1203226-altering-damage-dealt-through-script/0 and ranges from fDifficultyMinValue = -1 to fDifficultyMaxValue = 1. Exactly where/how this damage offset is applied I have no idea. Since it ranges from -5 to +5 I suspect it's an offset, not a multiplier... but you'll need to experiment to find out. I suggest setting the relevant game settings to different prime number values, and then testing with different difficulty values. You then have to guess theoretical formula's and see if the measured numbers correspond with your theory formulas.
User avatar
Ells
 
Posts: 3430
Joined: Thu Aug 10, 2006 9:03 pm


Return to IV - Oblivion