# UOX3 Script Engine

### Functions, Methods, Properties and Event handling

### Item Related Methods

CreateDFNItem
Prototype |
    ITEM CreateDFNItem( socket, character, sectionToMake, [int Amount], [objectType], [bool inPack] );
Purpose | Spawns an item from a DFN section number/id.
Notes | Parameters: socket - socket to refresh to (and ensure weight is added) character - required to know the pack/character to spawn it to sectionToMake - section # to spawn from int Amount - Amount of items to spawn (Optional) objectType - specify the type of object being added: "BASEOBJ" "CHARACTER", "ITEM", "SPAWNER", "MULTI", "BOAT" bool inPack - True/false whether to spawn in pack or not (Optional - default is FALSE).
Example of Usage |
    function onUseChecked( pUser, iUsed )
    {
    	var myItem = CreateDFNItem( pUser.socket, pUser, "0x09d0", 10, "ITEM", true );
    	pUser.SysMessage( "Oh my, 10 apples just appeared in my backpack! Magic!" );
    }

CreateBlankItem
Prototype |
    ITEM CreateBlankItem( socket, character, amount, itemName, itemID, colour, objectType, inPack );
Purpose | Spawns a "blank" item with values from the UO client's tiledata file.
Notes | Parameters: socket - socket to refresh to (and ensure weight is added) character - required to know the pack/character to spawn it to amount - The amount of items to spawn itemName - the name to give to the newly spawned item itemID - itemID(hex) to spawn item from colour - colour of the spawned item objectType - specify the type of object being added: "BASEOBJ" "CHARACTER", "ITEM", "SPAWNER", "MULTI", "BOAT" inPack - True/false whether to spawn in pack or not bSend - Whether or not to send update to all players
Example of Usage |
    function onUseChecked( pUser, iUsed )
    {
    	var myItem = CreateBlankItem( pUser.socket, pUser, 10, "apple", 0x09d0, 0x0, "ITEM", true );
    	pUser.SysMessage( "Oh my, 10 apples just appeared in my backpack! Magic!" );
    }

FindRootContainer
Prototype |
    ITEM FindRootContainer( iObj );
    ITEM FindRootContainer( iObjSerial );
Purpose | Finds the root container of a provided item object, or item object serial - if any
Notes | Parameters: iObj - item to find root container for iObjSerial - item serial to find root container for
Example of Usage |
    function onUseChecked( pUser, iUsed )
    {
    	var rootContainer = FindRootContainer( iUsed );
    	if( ValidateObject( rootContainer ))
    		pUser.TextMessage( "The item is in a container! The root container's name is " + rootContainer.name );
    	else
    		pUser.TextMessage( "The item has no root container." );
    }

GetSerial
Prototype |
    int GetSerial( part );
Purpose | Gets part (1-4) of an object's serial.
Example of Usage |
    iSerial = myItem.GetSerial( 1 );

HasSpell
Prototype |
    bool HasSpell( spellNum );
Purpose | Scans through player's contents to see if they have spellNum in the first spellbook encountered
Example of Usage |
    if(myPlayer.HasSpell( 0 )==1);

InRange
Prototype |
    bool InRange( trgObj, distance );
Purpose | Returns true if the distance to trgObj is less than distance
Example of Usage |
    if( myItem.InRange( trgObj, 18 ))
    	{
    		myItem.TextMessage( "I'm within range!" );
    	}

KillTimers
Prototype |
    bool Killtimers( );
Purpose | Kills all timers of the Char.
Example of Usage |
    myItem.KillTimers;

LockDown
Prototype |
    void LockDown( );
Purpose | Locks item down (sets movable value to 3).
Example of Usage |
    myItem.LockDown();

OpenPlank
Prototype |
    void OpenPlank()
Purpose | Opens the plank of a boat.
Example of Usage |
    myPlank.OpenPlank()

RemoveSpell
Prototype |
    void RemoveSpell( spellNum );
Purpose | Removes spellNum from player's spellbook
Example of Usage |
    myItem.RemoveSpell( 0 );

SetCont
Prototype |
    void SetCont( object );
Purpose | Sets the container of the item to the specified object.
Example of Usage |
    myItem.SetCont( mChar );

SetPoison
Prototype |
    void SetPoison ( poisonLevel );
Purpose | Sets a specified level of posion for an item/weapon.
Example of Usage |
    myItem.SetPoison( 2 );
    //Applies level 2 poison to item

SoundEffect
Prototype |
    void SoundEffect( soundID, bAllHear );
Purpose | Plays a sound from Character. SoundID is the full ID of the sound to play. If bAllHear is TRUE, then everyone nearby hears it. If it's false, then only the Character hears it. NOTE: Soundlist
Example of Usage |
    myItem.SoundEffect( 568, TRUE );

StartTimer
Prototype |
    void StartTimer( numMiliSec, timerID, callBack );
Purpose | Starts a timer that will elapse after numHundredthsOfSec seconds pass, for an item tItem. timerID must be between 0 and 100. Resulting onTimer event will be triggered. Which script it triggers in depends on the (optional, defaults to false) third parameter, which can be true (calls back to existing script), false (calls back into object's script) or an int (scriptID to call back to). This optional parameter defaults to false if not specified.
Example of Usage |
    myItem.StartTimer( 600, 0, true );
    myChar.StartTimer( 1200, 0, false ); //Timer calls back to existing script
    myChar.StartTimer( 1200, 0, 2012 ); //Timer calls back to script with ID 2012

Glow
Prototype |
    void Glow( socket );
Purpose | Causes the object to begin glowing.
Example of Usage |
    myItem.Glow( pSock );

UnGlow
Prototype |
    void UnGlow( socket );
Purpose | Causes the object to stop glowing.
Example of Usage |
    myItem.UnGlow( pSock );

PlaceInPack
Prototype |
    void PlaceInPack();
Purpose | Randomly sets the placement of an item inside the container it is in.
Example of Usage |
    myItem.PlaceInPack();

Dupe
Prototype |
    void Dupe( socket );
Purpose | Creates a duplicate of the item in character's pack
Example of Usage |
    myItem.Dupe( mySock );

Carve
Prototype |
    void Carve( socket );
Purpose | Makes the character belonging to socket carve up a corpse
Example of Usage |
    myCorpse.Carve( socket );

Refresh
Prototype |
    void Refresh();
Purpose | Causes the item to be refreshed to sockets that can see it
Example of Usage |
    myItem.Refresh();

©Copyright 2000-2001 WWW.UOX3.NET (Daniel Stratton/Matthew Randall)