GetEffectiveArmorAR

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search

A User Function for use with Oblivion Script Extender

Syntax:

(effectiveArmorAR:short) reference.Call GetEffectiveArmorAR Armor:ref CurrentHealth:float

Returns the effective armor rating, adjusted by the effective skill of the calling actor.

Notes[edit | edit source]

  • This function must be called on a reference (Ref.call <function>)
  • CurrentHealth is the value returned by GetCurrentHealth and/or GetEquippedCurrentHealth. If you want the armor rating of an undamaged armor, just use 1 as the second parameter.
  • This function requires the User Function GetEffectiveSkill
  • If the ref passed as the first argument is not an armor, or this function is not called on a NPC/Player reference, this function returns -1.

Code[edit | edit source]

scn GetEffectiveArmorAR

int ActorValueCode
int EffectiveAR
int Skill
float CurrentHealth
float value
float value2
ref Armor

Begin Function { Armor, CurrentHealth }
	if Eval ( !IsActor ) || ( GetIsCreature ) || ( !IsArmor Armor )
		SetFunctionValue -1
		Return
	endif
	if ( GetArmorType Armor )
		let ActorValueCode := ( ActorValueToCode HeavyArmor )
	else
		let ActorValueCode := ( ActorValueToCode LightArmor )
	endif
	let Skill := ( Call GetEffectiveSkill ActorValueCode )
	let value := ( Skill / 100 )
	let value *= ( GetGameSetting fArmorRatingMax ) - ( GetGameSetting fArmorRatingBase )
	let value += ( GetGameSetting fArmorRatingBase )
	let CurrentHealth /= ( GetObjectHealth Armor )
	let value2 := ( ( GetGameSetting fArmorRatingConditionMult ) * CurrentHealth )
	let value *= ( value2 + ( GetGameSetting fArmorRatingConditionBase ) )
	let value *= ( GetArmorAR Armor )
	let EffectiveAR := ( Floor value )
	let EffectiveAR += !EffectiveAR
	SetFunctionValue EffectiveAR
End

See Also[edit | edit source]

GetEffectiveSkill