Difference between revisions of "TempClone - Form"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>Egocarib
m (reworded a note for clarity)
imported>Egocarib
m (corrected errors in example)
 
Line 20: Line 20:
<source lang="papyrus">
<source lang="papyrus">
   ;...
   ;...
   ActorBase ab = SomeBandit.GetActorBase()
   ActorBase banditBase = SomeBandit.GetActorBase()
   CombatStyle cs = ab.GetCombatStyle().TempClone()
   Form csForm = banditBase.GetCombatStyle() as Form
   newCS.SetMeleeMult(0.1)
  CombatStyle newCS = csForm.TempClone() as CombatStyle
   newCS.SetMagicMult(2.5)
   newCS.SetMeleeMult(0.1) ;reduce preference for melee attacks
   ab.SetCombatStyle(newCS)
   newCS.SetMagicMult(2.5) ;increase preference for magic attacks
   banditBase.SetCombatStyle(newCS)
   ;...
   ;...
</source>
</source>

Latest revision as of 00:22, 14 January 2014

SKSE Member of: Form Script

Creates a temporary clone of this form. (This function requires SKSE)

Syntax[edit | edit source]

Form Function TempClone() native

Parameters[edit | edit source]

None

Return Value[edit | edit source]

Returns a new Form type that is a clone of the Form it was called on.

Examples[edit | edit source]

   ;...
   ActorBase banditBase = SomeBandit.GetActorBase()
   Form csForm = banditBase.GetCombatStyle() as Form
   CombatStyle newCS = csForm.TempClone() as CombatStyle
   newCS.SetMeleeMult(0.1) ;reduce preference for melee attacks
   newCS.SetMagicMult(2.5) ;increase preference for magic attacks
   banditBase.SetCombatStyle(newCS)
   ;...

Notes[edit | edit source]

  • The clone will only exist for the current play session. Attempting to store the cloned Form in a variable for longer periods of time will not work, and may lead to game instability when your script attempts to access the form after a game reload.
  • This does not work on all types - you may get back a valid form with initialized default data rather than data copied from the source.
  • TempClone does work for cloning CombatStyle Forms.