How to use the Add Actor Value Mult entry point

From GECK
Jump to: navigation, search

Preamble

The Add Actor Value Mult entry point operation is available when defining perk effects in the GECK, but is completely broken by default: the GECK does not allow changing the actor value to use away from the default Aggression. An external tool like FNVEdit can be used to change the actor value, but regardless of this the perks using it fail to work inside the game. Or rather appear to.

In reality, its code is further broken due to what appears like an inversion of how the specified values (actor value and multiplier) are applied in game. So instead of performing the stated operation:

final value = value + ( (perk owner's actor value amount) * (multiplier) )

The game reads it as:

final value = value + ( (perk owner's  amount of the multiplier read as actor value code) * (actor value's code) )

If the defined multiplier is not a whole integer corresponding to a valid actor value code, the operation will thus fail. Even if it is, it will most likely be the incorrect one. And the actor value code acting as a multiplier also prevents the operation from doing anything sensible.

Example

You want to use this entry point operation for a weapon that does bonus damage depending on your character's Charisma value (actor value code 8). You create a new perk, added when you equip the weapon, that uses the Calculate Weapon Damage entry point, the Add Actor Value Mult operation, and a 10 multiplier. Afterwards, you fix it in FNVEdit, changing the Aggression actor value to Charisma. So your weapon supposedly does 10 extra damage with each point you have in Charisma.

In the game, your weapon's damage is listed as 30 by default. Your character has a 5 in Charisma, and a 1 in Agility (bad foreshadowing). You expect the displayed damage when you equip your weapon to be:

displayed damage = 30 + (5 * 10) = 80

But instead it's being displayed as 38. What's going on?

What is happening due to the above bug, is that the actor value being used in the calculation is actually your Agility (actor value code 10, the value of the multiplier), while the actor value code for Charisma is being used as the multiplier. So the weapon's calculated damage is actually:

displayed damage = 30 + (1 * 8) = 38

Had you used any fractional multiplier instead of 10, it wouldn't even be read as an actor value, and the perk wouldn't even do anything.

And thus, with the cause of the problem being clear, a solution can be applied, with the perk manipulating functions of JIP LN.

Solution

Basically, you have to use a script to swap where the actor value code and the multiplier are placed in the perk. Knowing the perk effect index where the Add Actor Value Mult operation is, use SetNthPerkEntryValue1 to define the multiplier, and SetNthPerkEntryValue2 to define the actor value code. The perk will now work correctly... pending an engine fix.

So again, lets imagine you defined the above's example perk as myWeaponPerk. You could fix it as soon as the game boots with a running quest script like this:

Begin MenuMode 4
	if GetGameRestarted
		SetNthPerkEntryValue1 myWeaponPerk 0 10
		SetNthPerkEntryValue2 myWeaponPerk 0 8
	endif
End