UOX3 Script Engine

Functions, Methods, Properties and Event handling

Item Related Methods

 

CreateDFNItem
Prototype
ITEM CreateDFNItem( socket, character, sectionToMake, [int Amount], [objectType], [bool inPack] );
ITEM CreateDFNItem( null, null, sectionToMake, [int Amount], [objectType], false, [worldNumber], [instanceID] );
PurposeSpawns an item from a DFN section number/id.
NotesParameters:
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: "ITEM", "SPAWNER"
bool inPack - True/false whether to spawn in pack or not (Optional - default is FALSE).
Function can also be used to add items without relying on a character. In this case, the socket and character parameters are null, the inPack parameter is false, and two additional parameters are provided - worldNumber and instanceID
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!" );
}

function onUseChecked( pUser, iUsed )
{
	var myItem = CreateDFNItem( null, null, "0x09d0", 10, "ITEM", false, iUsed.worldnumber, iUsed.instanceID );
	iUsed.TextMessage( "Oh my, 10 apples just spawned on top of me! Magic!" );
}

 

CreateBlankItem
Prototype
ITEM CreateBlankItem( socket, character, amount, itemName, itemID, colour, objectType, inPack );
PurposeSpawns a "blank" item with values from the UO client's tiledata file.
NotesParameters:
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: "ITEM", "SPAWNER"
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 );
PurposeFinds the root container of a provided item object, or item object serial - if any
NotesParameters:
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 );
PurposeGets part (1-4) of an object's serial.
Example of Usage
iSerial = myItem.GetSerial( 1 );

 

HasSpell
Prototype
bool HasSpell( spellNum );
PurposeScans 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( );
PurposeKills all timers of the Char.
Example of Usage
myItem.KillTimers;

 

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

 

OpenPlank
Prototype
void OpenPlank()
PurposeOpens the plank of a boat.
Example of Usage
myPlank.OpenPlank()

 

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

 

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

 

SetPoison
Prototype
void SetPoison ( poisonLevel );
PurposeSets 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 );
PurposePlays 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 );
PurposeStarts 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 );
PurposeCauses the object to begin glowing.
Example of Usage
myItem.Glow( pSock );

 

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

 

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

 

Dupe
Prototype
void Dupe( socket );
PurposeCreates 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)