Difference between revisions of "User:DavidJCobb/Miscellany"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>DavidJCobb
(→‎Unsorted facts: Important info for testing mods, and for making clean saves.)
imported>DavidJCobb
(pruning, removing gamesas, etc)
 
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
This page contains miscellaneous information about Skyrim modding that I've found during my glorious adventures through the Internet. Please lemme know if I link to any sources this wiki isn't cool with. __FORCETOC__
miscellanous information; outdated
 
__FORCETOC__


== Scripting ==
== Scripting ==
=== Changing a player's Speed Multiplier (SpeedMult) ===
=== Changing a player's Speed Multiplier (SpeedMult) ===
:''Source:'' [http://www.gamesas.com/dynamic-walk-speed-script-t253947.html '''gamesas:''' Dynamic Walk Speed Script]
Changes to the player's Speed Multiplier [[Actor Value|actor value]] don't take effect unless you prompt the game engine to take notice. This issue applies to both scripted changes and changes triggered by a "Value Modifier" [[Magic Effect|magic effect]]. There are two ways to force the game to actually use a changed SpeedMult:
Changes to the player's Speed Multiplier [[Actor Value|actor value]] don't take effect unless you prompt the game engine to take notice. This issue applies to both scripted changes and changes triggered by a "Value Modifier" [[Magic Effect|magic effect]]. There are two ways to force the game to actually use a changed SpeedMult:


Line 10: Line 10:
* Modify the player's carry weight actor value. Adding and then removing 0.1 works.
* Modify the player's carry weight actor value. Adding and then removing 0.1 works.


=== Detecting invalid references ===
=== Issues with optional function arguments ===
:''Source:'' [http://www.gamesas.com/suspended-stack-count-over-our-warning-threshold-t348345.html '''gamesas:''' Suspended stack count is over our warning threshold...]
When you compile a function with optional script arguments, the argument data is updated for the containing script only. If other scripts make cross-script calls to your function, those functions must be recompiled in order for their calls to work properly. Otherwise...
 
It's possible for your mod to reference (by variable or Alias) a Form from another mod. If that mod is uninstalled, your reference will break. Tests like <code>kMyObject is ObjectReference</code> will return true, but attempts to access any functions or data on the variable will throw errors. What you must do instead is:
 
  Int iFormID = kSomeReference.GetFormId()
  If iFormID && kSomeReference is ObjectReference
      ;
      ; we're cool bro
      ;
  Else
      ;
      ; CODE RED
      ;
  EndIf
 
=== Detecting references created at run-time ===
:''Source:'' [http://afkmods.iguanadons.net/index.php?/topic/3941-how-to-distinguish-run-time-created-actors-from-hand-placed-ones/ '''AFKMods:''' How to distinguish run-time created actors from hand-placed ones ? ]
 
If the reference is an Actor, you can't! The base game can create actors to fill quest aliases, it seems.
 
As for other kinds of references? I'll look into that later.


* If you just added the optional arguments, the other scripts will be unaware of them unless recompiled; you will receive Papyrus errors whining about an "incorrect number of arguments passed."
* If you changed the optional arguments' default values, the other scripts will use the old default values until recompiled.


== Papyrus errors ==
== Papyrus errors ==
Line 51: Line 33:
Occurs when old script data (baked into a savegame) has malfunctioned badly enough for the game engine to just throw it out.
Occurs when old script data (baked into a savegame) has malfunctioned badly enough for the game engine to just throw it out.


=== Variable loaded from save could not be found on the actual object ===
:''Source:'' [http://afkmods.iguanadons.net/index.php?/topic/3822-help-with-script-log-errors/#entry148638 '''AFKMods:''' Help with script log "errors" ]
Apparently the result of scripts being updated.


== Fun with multi-threading! ==
    [11/17/2013 - 02:59:23AM] warning: Variable ::WVAAliasStorage_var on script DLC1_QF_DLC1EclipseAttack2_01017648 loaded from save not found within the actual object. This variable will be skipped.
"Fun" may not be the right word to use here, actually.
 
=== Conditions are interruptible ===
::''Source:'' [http://afkmods.iguanadons.net/index.php?/topic/3781-the-critter-thread/page-7#entry149921 '''AFKMods:''' The critter thread]
Conditions like the following are inherently unreliable due to how Papyrus handles threading.
 
  If kMyObjectReference && !kMyObjectReference.isDeleted() && !kMyObjectReference.isDisabled()
  EndIf
 
<code>IsDeleted()</code> and <code>IsDisabled()</code> are delayed functions (as opposed to [[:Category:Non-delayed Native Function|non-delayed functions]]), so Papyrus may actually pause the current script ''in the middle of this If statement'' to run them. During that time, another thread can set the ObjectReference variable to None. Per the scripter's comments in the source, this can lead to two kinds of errors:
 
* <code>kMyObjectReference.IsDisabled()</code> gets treated as <code>None.IsDisabled()</code>. This is invalid and returns <code>None</code>.
* That returned <code>None</code> is then inverted with <code>!</code>, which is also invalid. This yields Papyrus log errors of the form:
*: <pre>warning: Assigning None to a non-object variable named "::temp33"</pre>
 
The lesson to learn here is that even a single If statement can be interrupted and hosed by multithreading.
 
Makes me wonder if something like the following might work:
 
  If kMyObjectReference && !kMyObjectReference.isDeleted() && kMyObjectReference && !kMyObjectReference.isDisabled()
  EndIf
 
 
=== Delayed functions are interruptible ===
Just about every native function that isn't [[:Category:Non-delayed Native Function|listed here]] is interruptible. Every moment you call these functions is a moment your script can be interrupted. This produces all sorts of "fun" oddities.
 
<ul>
  <li><code>Delete()</code> is a delayed function. Your attempt to delete an object can be interrupted by another attempt to delete that same object, resulting in your interrupted call failing (it's treated as <code>None.Delete()</code>).</li>
  <li>
      The <code>x</code>, <code>y</code>, and <code>z</code> "properties" on ObjectReferences [http://afkmods.iguanadons.net/index.php?/topic/3781-the-critter-thread/page-8#entry150159 are actually interruptible functions]. As such, code blocks like the following can fail:
      <source lang="Papyrus">Int iCoordX = kMyObjectReference.x ; due to multi-threading, this code may be interrupted here...
Int iCoordY = kMyObjectReference.y ; ...and by the time the code resumes, kMyObjectReference could've been screwed with</source>
  </li>
</ul>
 
 
=== Other things to remember ===
* Cross-script function calls are interruptible. Your precious <code>Debug.Trace(...)</code> statements actually ''can'' affect things.




== Unsorted facts ==
== Unsorted facts ==
* If you wish to borrow critter behaviors for a script, be careful. I've been reading through USKP discussions and apparently, Bethesda's critter scripts were broke as ''hell.'' Seems like the USKP rebuilds most critter behaviors almost from scratch.
* If you wish to borrow critter behaviors for a script, be careful. I've been reading through USKP discussions and apparently, Bethesda's critter scripts were very buggy. Seems like the USKP rebuilds most critter behaviors almost from scratch.
* [http://afkmods.iguanadons.net/index.php?/topic/3781-the-critter-thread/page-3#entry149560 "Translate routines will operate properly in unloaded areas."] This, in regards to animating and moving critters like moths.
* [http://afkmods.iguanadons.net/index.php?/topic/3781-the-critter-thread/page-3#entry149560 "Translate routines will operate properly in unloaded areas."] This, in regards to animating and moving critters like moths.
** Even though translations work in unloaded cells without 3D loaded, [http://afkmods.iguanadons.net/index.php?/topic/3781-the-critter-thread/page-4#entry149598 "<code>StopTranslation()</code> requires the cell attached and loaded 3D. There's no reason for it, but it throws an error without it!"]
** Even though translations work in unloaded cells without 3D loaded, [http://afkmods.iguanadons.net/index.php?/topic/3781-the-critter-thread/page-4#entry149598 "<code>StopTranslation()</code> requires the cell attached and loaded 3D. There's no reason for it, but it throws an error without it!"]
Line 100: Line 47:
** [http://afkmods.iguanadons.net/index.php?/topic/3781-the-critter-thread/page-4#entry149599 There is reason to doubt that translate routines actually do operate properly in unloaded areas.] It's possible that they don't properly unlock the translated object (allowing for deletion) unless the cell is attached.
** [http://afkmods.iguanadons.net/index.php?/topic/3781-the-critter-thread/page-4#entry149599 There is reason to doubt that translate routines actually do operate properly in unloaded areas.] It's possible that they don't properly unlock the translated object (allowing for deletion) unless the cell is attached.
* [http://afkmods.iguanadons.net/index.php?/topic/3781-the-critter-thread/page-2#entry149454 When an ingredient is sold or consumed, "it will have the deleted flag set already, and won't have a parent cell or 3D."]
* [http://afkmods.iguanadons.net/index.php?/topic/3781-the-critter-thread/page-2#entry149454 When an ingredient is sold or consumed, "it will have the deleted flag set already, and won't have a parent cell or 3D."]
*[http://afkmods.iguanadons.net/index.php?/topic/3781-the-critter-thread/page-6#entry149699 Critter animations]: butterflies and moths use <code>fTakeOff</code>, while dragonflies and fireflies can use <code>fTakeOff</code> or <code>TakeOff</code>.
* [http://afkmods.iguanadons.net/index.php?/topic/3781-the-critter-thread/page-6#entry149699 Critter animations]: butterflies and moths use <code>fTakeOff</code>, while dragonflies and fireflies can use <code>fTakeOff</code> or <code>TakeOff</code>.
*You cannot [[GetAnimationVariableFloat - ObjectReference|get animation variables]] for an object [http://afkmods.iguanadons.net/index.php?/topic/3781-the-critter-thread/page-9#entry150430 if its 3D isn't loaded].
* [http://afkmods.iguanadons.net/index.php?/topic/3781-the-critter-thread/page-10#entry150967 "We're just going to have to live with the fact the game engine unloads 3D at unexplained times without warning."]
* When a persistent ObjectReference is removed from the game world (e.g. sold to a merchant), [http://afkmods.iguanadons.net/index.php?/topic/3717-skyrim-the-papyrus-function-getparentcell-and-what-may-happen-when-it-runs-on-a-persistent-reference/ its GetParentCell() method may return the cell from which it originated.] It may also return other nonsense results, so try to avoid using the method on a persistent reference.
* [http://afkmods.iguanadons.net/index.php?/topic/3676-skyrim-information-baked-into-saves/#entry145982 Among other things, this post describes best practices for working with vanilla Actors in a mod.]
** Do note [http://afkmods.iguanadons.net/index.php?/topic/3676-skyrim-information-baked-into-saves/page-2#entry145986 the replies], though.
* [http://afkmods.iguanadons.net/index.php?/topic/3676-skyrim-information-baked-into-saves/page-3#entry147426 "Scripts that are fragments for packages never go away, and seem to begin executing on a None package with no conditions."]
* [http://afkmods.iguanadons.net/index.php?/topic/3676-skyrim-information-baked-into-saves/page-3#entry147426 "Scripts that are fragments for packages never go away, and seem to begin executing on a None package with no conditions."]
* [http://afkmods.iguanadons.net/index.php?/topic/3676-skyrim-information-baked-into-saves/page-3#entry147468 Reportedly,] Skyrim will actually write to your save file when loading it, if it detects that a new mod with script content has been added. (Those scripts will be baked into the save.) This has significant ramifications for testing out script-based mods (to see if you should keep them), and for making "clean saves."
* [http://afkmods.iguanadons.net/index.php?/topic/3694-disabling-persistent-references-a-remarkable-solution/ Apparently, one can disable a persistent reference using a method discussed here.]


=== Unsorted edge-cases ===
=== Unsorted edge-cases ===
* Be careful about handling things OnCellAttach and OnCellDetach in Riften. [http://afkmods.iguanadons.net/index.php?/topic/3781-the-critter-thread/page-8#entry150257 The city's walkways have you cross back and forth across a cell boundary.]
* Be careful about handling things OnCellAttach and OnCellDetach in Riften. [http://afkmods.iguanadons.net/index.php?/topic/3781-the-critter-thread/page-8#entry150257 The city's walkways have you cross back and forth across a cell boundary.]
** ''The use case dealt with here involves deleting critters when you leave their containing cells. The scripter's attempted solution was to add a timed delay (using OnUpdateGameTime) to the deletion. Return to the cell before the timer has elapsed, and the critter is reused -- the deletion is canceled.''
** ''The use case dealt with here involves deleting critters when you leave their containing cells. The scripter's attempted solution was to add a timed delay (using OnUpdateGameTime) to the deletion. Return to the cell before the timer has elapsed, and the critter is reused -- the deletion is canceled.''
* You may run into a peculiar problem when passing through a load door: [http://forums.bethsoft.com/topic/1514401-detection-of-null-cells-when-going-through-load-doors-how/#entry23901128 cells that are unloaded by the game can still exist as "valid" Papyrus Cell objects.] They'll be recognized as Cells rather than as Nones, but attempts to call ''most'' native methods on them will fail. Effectively, it's the bizarre difference between something that's ''null'' and something that's ''None''.
** Surprisingly, <code>kMyBrokenCell.GetFormID()</code> will still return a null cell's proper ID, even though the cell object is broken.
** Comparing <code>kMyBrokenCell</code> to <code>Game.GetForm(kMyBrokenCell.GetFormID())</code> reportedly returns False when dealing with a null cell. This would make sense: an existing Papyrus Cell object can lose its underlying cell and still exist, but you probably cannot create a ''new'' Papyrus Cell object from a lost cell.
=== Unsorted engine bugs ===
* [http://afkmods.iguanadons.net/index.php?/topic/3921-horses-bugged-in-water/ Ride a horse into water, get it to swim, dismount, and remount. It'll use land physics while in water.]
* [http://afkmods.iguanadons.net/index.php?/topic/3997-merchant-gold-reset-bug/#entry151915 Reloading a savegame won't reset a merchant's gold.]
* [http://forums.nexusmods.com/index.php?/topic/781746-problems-with-light-sources-flickeringturning-on-and-off/#entry6272032 If too many light sources are around in a single area, then surfaces and objects will flicker between lit and unlit as the camera moves. This is due to an engine limitation.]
=== Unsorted best practices ===
* [http://afkmods.iguanadons.net/index.php?/topic/3909-is-stable-ugridstoload-by-altimor-useful-even-for-grids-left-at-5/?p=149945 Don't change uGridsToLoad. It will overburden the scripting engine.]
* [http://afkmods.iguanadons.net/index.php?/topic/3998-quicksavingquickloading-in-skyrim/#entry151919 Quicksaves aren't quite the suitcase nuke they're made out to be. Still, use some basic caution with them.]
=== Unsorted lessons ===
* [http://afkmods.iguanadons.net/index.php?/topic/3863-mgritual04questscript-unendingcontinuous-papyrus-log-errors/ A 10MB Papyrus log.] This is why you should be careful with update events.
=== Unsorted things to look into ===
* [http://afkmods.iguanadons.net/index.php?/topic/3794-flora-respawn-vmad/#entry147720 OnCellAttach reportedly unreliable (Oct 2013).]
* [http://afkmods.iguanadons.net/index.php?/topic/3974-where-do-dragons-go-when-they-die/ Dying dragons reportedly fly to Labyrinthian.]
* [http://afkmods.iguanadons.net/index.php?/topic/3834-selling-silver-weapons/ Once sold, Silver weapons are never cleared from merchant inventories (Nov 2013).]

Latest revision as of 02:58, 20 March 2017

miscellanous information; outdated


Scripting[edit | edit source]

Changing a player's Speed Multiplier (SpeedMult)[edit | edit source]

Changes to the player's Speed Multiplier actor value don't take effect unless you prompt the game engine to take notice. This issue applies to both scripted changes and changes triggered by a "Value Modifier" magic effect. There are two ways to force the game to actually use a changed SpeedMult:

  • Modify the player's inventory. Silently adding and then removing an item should do the trick.
  • Modify the player's carry weight actor value. Adding and then removing 0.1 works.

Issues with optional function arguments[edit | edit source]

When you compile a function with optional script arguments, the argument data is updated for the containing script only. If other scripts make cross-script calls to your function, those functions must be recompiled in order for their calls to work properly. Otherwise...

  • If you just added the optional arguments, the other scripts will be unaware of them unless recompiled; you will receive Papyrus errors whining about an "incorrect number of arguments passed."
  • If you changed the optional arguments' default values, the other scripts will use the old default values until recompiled.

Papyrus errors[edit | edit source]

Samples of Papyrus logs and errors that I haven't often seen posted on the web, along with meanings when known.

Baked script data is outdated[edit | edit source]

Source: AFKMods: The critter thread
warning: Function <name> in stack frame <number> in stack <number> differs from the in-game resource files - using version from save

Occurs when an old version of a script is baked into a savegame.

Baked script data malfunctioning badly enough to be dropped[edit | edit source]

Source: AFKMods: The critter thread
[02/09/2014 - 03:33:25PM] error: Failed to read basic script data for critterFish attached to  (FF002ABA)
[02/09/2014 - 03:33:25PM] error: Unable to load object 0x1305E1E0 from save game
[02/09/2014 - 03:33:25PM] Errors occurred while loading the Papyrus save game data

Occurs when old script data (baked into a savegame) has malfunctioned badly enough for the game engine to just throw it out.

Variable loaded from save could not be found on the actual object[edit | edit source]

Source: AFKMods: Help with script log "errors"

Apparently the result of scripts being updated.

   [11/17/2013 - 02:59:23AM] warning: Variable ::WVAAliasStorage_var on script DLC1_QF_DLC1EclipseAttack2_01017648 loaded from save not found within the actual object. This variable will be skipped.


Unsorted facts[edit | edit source]

Unsorted edge-cases[edit | edit source]

  • Be careful about handling things OnCellAttach and OnCellDetach in Riften. The city's walkways have you cross back and forth across a cell boundary.
    • The use case dealt with here involves deleting critters when you leave their containing cells. The scripter's attempted solution was to add a timed delay (using OnUpdateGameTime) to the deletion. Return to the cell before the timer has elapsed, and the critter is reused -- the deletion is canceled.
  • You may run into a peculiar problem when passing through a load door: cells that are unloaded by the game can still exist as "valid" Papyrus Cell objects. They'll be recognized as Cells rather than as Nones, but attempts to call most native methods on them will fail. Effectively, it's the bizarre difference between something that's null and something that's None.
    • Surprisingly, kMyBrokenCell.GetFormID() will still return a null cell's proper ID, even though the cell object is broken.
    • Comparing kMyBrokenCell to Game.GetForm(kMyBrokenCell.GetFormID()) reportedly returns False when dealing with a null cell. This would make sense: an existing Papyrus Cell object can lose its underlying cell and still exist, but you probably cannot create a new Papyrus Cell object from a lost cell.

Unsorted engine bugs[edit | edit source]

Unsorted best practices[edit | edit source]


Unsorted lessons[edit | edit source]


Unsorted things to look into[edit | edit source]