Difference between revisions of "GetEffectiveArmorAR"

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search
imported>Low Post
(New page: __NOTOC__ A User Function for use with Oblivion Script Extender '''Syntax:''' (effectiveArmorAR:short) reference.Call GetEffectiveArmorAR Armo...)
 
imported>Low Post
 
(2 intermediate revisions by the same user not shown)
Line 10: Line 10:
*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.
*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]]
*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 reference, this function returns -1.
*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==
==Code==
Line 29: Line 29:
  endif
  endif
  if ( GetArmorType Armor )
  if ( GetArmorType Armor )
  let ActorValueCode := 1
  let ActorValueCode := ( ActorValueToCode HeavyArmor )
else
let ActorValueCode := ( ActorValueToCode LightArmor )
  endif
  endif
  let Skill := ( Call [[GetEffectiveSkill]] ActorValueCode )
  let Skill := ( Call [[GetEffectiveSkill]] ActorValueCode )
  let value := ( gstiSkill / 100 )
  let value := ( Skill / 100 )
  let value *= ( GetGameSetting fArmorRatingMax ) - ( GetGameSetting fArmorRatingBase )
  let value *= ( GetGameSetting fArmorRatingMax ) - ( GetGameSetting fArmorRatingBase )
  let value += ( GetGameSetting fArmorRatingBase )
  let value += ( GetGameSetting fArmorRatingBase )

Latest revision as of 12:37, 20 March 2011

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