Difference between revisions of "UpdateWeight - Actor"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>Bot Owned
(Created page with "Category:Scripting Category:Papyrus Category:SKSE '''SKSE Member of:''' Actor Script Visually updates the actors weight. == Syntax == <source lang="papyrus">...")
 
imported>Bot Owned
m (→‎Examples: rearranged alittle for a bit more clarity)
 
Line 22: Line 22:
float PlayerOrigWeight = PlayerRef.GetWeight() ;Collect the Player's original weight.
float PlayerOrigWeight = PlayerRef.GetWeight() ;Collect the Player's original weight.
float PlayerNewWeight = Utility.RandomFloat(0.0, 100.0)
float PlayerNewWeight = Utility.RandomFloat(0.0, 100.0)
PlayerRef.GetActorBase().SetWeight(PlayerNewWeight) ;Set Player's weight to a random float between 0.0 and 100.0.
Float NeckDelta = (PlayerOrigWeight / 100) - (PlayerNewWeight / 100) ;Work out the neckdelta.
Float NeckDelta = (PlayerOrigWeight / 100) - (PlayerNewWeight / 100) ;Work out the neckdelta.
PlayerRef.GetActorBase().SetWeight(PlayerNewWeight) ;Set Player's weight to a random float between 0.0 and 100.0.
PlayerRef.UpdateWeight(NeckDelta) ;Apply the changes.
PlayerRef.UpdateWeight(NeckDelta) ;Apply the changes.
</source>
</source>

Latest revision as of 00:51, 1 June 2013

SKSE Member of: Actor Script

Visually updates the actors weight.

Syntax[edit | edit source]

Function UpdateWeight(float neckDelta) native

Parameters[edit | edit source]

  • neckDelta: The neck delta is found by using the following equation (oldWeight / 100) - (newWeight / 100)

Return Value[edit | edit source]

None

Examples[edit | edit source]

	Actor PlayerRef = Game.GetPlayer()
	float PlayerOrigWeight = PlayerRef.GetWeight() ;Collect the Player's original weight.
	float PlayerNewWeight = Utility.RandomFloat(0.0, 100.0)
	Float NeckDelta = (PlayerOrigWeight / 100) - (PlayerNewWeight / 100) ;Work out the neckdelta.
	
	PlayerRef.GetActorBase().SetWeight(PlayerNewWeight) ;Set Player's weight to a random float between 0.0 and 100.0.
	PlayerRef.UpdateWeight(NeckDelta) ;Apply the changes.

Notes[edit | edit source]

  • DO NOT use this function while mounted. You will not crash, but physics will break resulting in you and your mount flying around violently until you dismount, or die from falling damage.
  • Neck changes are player persistent but using this function on any other actor is session persistent only.
  • Weight changes are persistent for all Actors, and as such it's important to keep track of any non-player Actor's original weight when using this function on them.

See Also[edit | edit source]