Difference between revisions of "ForceActorValue - Actor"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>Selyb
m (Added a note.)
imported>DavidJCobb
(→‎Notes: More detailed explanation based on disassembly. TODO: What happens if we modify our example a bit? What happens if the base is 150, the current 120, and we force to 0?)
 
(One intermediate revision by one other user not shown)
Line 9: Line 9:
Function ForceActorValue(string asValueName, float afNewValue) native
Function ForceActorValue(string asValueName, float afNewValue) native
Function ForceAV(string asValueName, float afNewValue)
Function ForceAV(string asValueName, float afNewValue)
  ForceActorValue(asValueName, afNewValue)
EndFunction
</source>
</source>


Line 30: Line 32:


== Notes ==
== Notes ==
*This function modifies the current value as opposed to the base value. To set the base value see [[SetActorValue - Actor]]
* This function modifies the current value as opposed to the base value. To set the base value, see [[SetActorValue - Actor]].
** To elaborate on that a bit, this function modifies the "permanent modifier" described in the [[Actor Value]] documentation, and that affects how the current value is computed. If an actor has a base health of 125 and you force their health to 0, then the permanent modifier will be set to -125, and their current health will become 0. If you then set the base health to 150, they will still have a permanent modifier of -125, so their current health will instantly become 25 (150 - 125).


== See Also ==
== See Also ==

Latest revision as of 03:31, 4 November 2018

Member of: Actor Script

Forces the specified actor value to the passed-in value.

Syntax[edit | edit source]

Function ForceActorValue(string asValueName, float afNewValue) native
Function ForceAV(string asValueName, float afNewValue)
  ForceActorValue(asValueName, afNewValue)
EndFunction

Parameters[edit | edit source]

  • asValueName: The name of the actor value to force. Actor Value List
  • afNewValue: The new value to force the actor value to.

Return Value[edit | edit source]

None.

Examples[edit | edit source]

; Force the player's health to 50
Game.GetPlayer().ForceActorValue("health", 50.0)


; Force Jake's health to 10
Jake.ForceAV("Health", 10.0)

Notes[edit | edit source]

  • This function modifies the current value as opposed to the base value. To set the base value, see SetActorValue - Actor.
    • To elaborate on that a bit, this function modifies the "permanent modifier" described in the Actor Value documentation, and that affects how the current value is computed. If an actor has a base health of 125 and you force their health to 0, then the permanent modifier will be set to -125, and their current health will become 0. If you then set the base health to 150, they will still have a permanent modifier of -125, so their current health will instantly become 25 (150 - 125).

See Also[edit | edit source]