User:JRoush

From the Oblivion ConstructionSet Wiki
Revision as of 23:45, 12 May 2009 by imported>JRoush (→‎Mystery Traits)
Jump to navigation Jump to search

Notes on Scripting

General Scripting

Adding or removing (possibly any modifying of) effects in an enchantment (or, presumably, a spell) that is currently affecting an actor results in CTD. Instead, we must cloneform the enchantment and use that instead. Previous testing gives me hope that the game might garbage collect unused formids.

Modifications to non-cloned forms (e.g. changes to name, etc) do not appear to stick upon reloading the game. Dynamically generated spells must be cloned, or else the base forms modified in script every time the game is reloaded.

Cloned forms are not removed when the mod is deactivated. Since there is no way for the average player to remove cloned spells from spell merchants, a "cleanup" script must be provided to do so. - makes the whole use of cloned spells unattractive -

GetOwner appears to work only on references (not items in a container). There is a stolen flag, I believe, but not sure how to set it.

Moveto and PositionCell don't transfer meshes. the 'usual' workarounds assume transfer to the current cell, and don't work for destination cells that aren't loaded.

Menu Scripting

Traits of the form <user#> are parameters set by the game enigne. The visible manifestations (text, slider position, etc.) are usually set to derive from these inputs. As of OBSE v0017 modifying most traits from scripts will destroy derivative relationships; it appears that some values (e.g. quantity slider traits) are safe to modify. Modifying the <user#> traits directly one can "fake" user input; in particular spell/potion names and slider bar positions. Derivative relationships are reloaded when the menu is. Note that the HUD (and possibly the inventory) reloads only after exiting to the main menu; changes to the HUD will persist until then.

The Arrow + Enter keys can normally be used to navigate menus. I haven't found (or seriously looked for) a way to determine which tile is the focus of a keyboard event. It looks like the focus is *either* keyboard or mouse based, and transitions from one to the other are inconsistent or bugged. At any rate, OBSE v0017 GetActiveUIComponent* functions work only for tiles focused on by the mouse. Also, arrow+enter menu navigation is NOT based on mapped controls and cannot be disabled using Disablekey. It CAN be disabled by removing all traits of the form <xbutton>, <xleft>, <xright>, etc. from the menu in question, but not by simply setting them to zero in scripts. This is a problem because an errant keystrokes can apparently derail a ClickMenuButton call, which makes setting up long chains of automated click events unfeasible.

The GetCursorPos function is a bit dodgy. Returned positions are not consistent, and seem to depend on integrated movement history. This, combined with the lack of a function to get screen resolution, makes it impractical for use in menus (specifically, I couldn't use it to script in a custom slider bar).

Oblivion XML

Elements

  • <menu>
  • <image>
  • <rect>
  • <text>
  • <template>

Each element in the list should have a name="" trait in the opening tag.

General Traits

  • <id> (int or &generic;) - links an element to a particular aspect of the menu class in the game engine. The game expects, for each menu class, that certain ids will be present, and treats them specially. For example, clicking on element id#14 in the alchemy menu will create a new potion, regardless of the name or (I think) the type of the element.
  • <user##> (variable) - parameters set/read by game engine, specific to the menu and element in question
  • <x>,<y> (int) - coordinates (in pixels) of upper left corner (most elements), or center for center justified text elements
  • <height>,<width> (int) - size (in pixels) of element
  • <depth> (byte) - visibility ordering; element with highest depth is drawn on top
  • <visible> (boolean) - element is rendered
  • <locus> (boolean) - x,y coords are taken to be relative to the position of the first parent with locus set to true
  • <alpha> (byte) - transparency of element (greater = more opaque)

Element Specific Traits

  • <class> (entity) - menu element - specifies in game class to associate with menu
  • <filename> (string) - image elements - location of texture file, relative to Oblivion\Data\Textures
  • <zoom> (int) - image elements - scaling factor for textures (percentage), use -1 to force fit entire texture
  • <cropx>,<cropy> (int) - pixels to crop from top and left of texture (applied after zoom settings)
  • <red>,<green>,<blue> (byte) - text elements - color of text (greater = more intense)
  • <font> (byte) - text elements - in game font used (1-5)
  • <justify> (&left;, &right;, &center;) - text elements - text alignment
  • <string> (string) - text elements - actual contents
  • <wrapwidth> (int) - text elements - width (in pixels) at which text will break to a new line

Input Related Traits

  • <target> (boolean) - element can be a target of mouse focus
  • <clicksound> (byte) - game click sound to use for mouse-targetable elements
  • <mousover> (boolean) - set by the game engine for targetable elements - only true when the element has mouse focus

Meta Traits

Elements in this list may be given literal values, or derive values from traits of another element given by a src="" trait="" in the opening tag. Sources can be literal names, or include the functions "me()", "parent()", "child()", or "sibling()". Processing within a given level (these traits may be nested) starts with the first trait and continues with each trait modifying the current value at that level.

<x>
    <!-- Place this element to the left of 'some_element' -->
    <!-- with a gap of 4+2=6 pixels between them, or at -->
    <!-- the far left edge of the screen (x=0) -->
    <copy src="some_element" trait="x"/>
    <sub src="me()" trait="width"/>
    <sub>
        <copy> 2 </copy>
        <add> 4 </add>
    </sub>
    <max> 0 </max>
</x>
  • <add>,<sub>,<mult>,<div> - perform algebraic functions
  • <onlyif>,<onlyifnot> - replaces with zero if the trait value not is true or false, respectively
  • <lt>,<gt>,<eq> - replaces with zero if not less than, greater than, or equal to trait value, respectively
  • <min>,<max> - replaces with trait value if greater than or less than, respectively
  • <copy> - replaces with trait value.
  • <include> - Includes an XML file. must specify a src="", where the source is the file path relative to Oblivion\Data\Menus\Prefabs

Mystery Traits

Not sure what these are for yet

  • <clips>
  • <stackingtype>
  • <menufade>