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
Line 29: Line 29:
  endif
  endif
  if ( GetArmorType Armor )
  if ( GetArmorType Armor )
  let ActorValueCode := 1
  let ActorValueCode := 18
else
let ActorValueCode := 27
  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 )

Revision as of 16:00, 3 June 2010

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

  • 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 reference, this function returns -1.

Code

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 := 18
	else
		let ActorValueCode := 27
	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

GetEffectiveSkill