Jar of honey

Want to contribute to the Ultima Offline eXperiment? Submit your JS/DFN/Code fixes and/or other UOX3 improvements here!
Post Reply
dragon slayer
UOX3 Guru
Posts: 776
Joined: Thu Dec 21, 2006 7:37 am
Has thanked: 4 times
Been thanked: 26 times

Jar of honey

Post by dragon slayer »

I have created this script so we can use jar of honey on dough and flour to make a few needed cooking items.

jarhoney.js

Code: Select all

function onUseChecked ( pUser, iUsed ) 
{
	// get users socket
	var srcSock = pUser.socket;

	// is it in users pack?
	if( iUsed.container != null )
	{
		var iPackOwner = GetPackOwner( iUsed, 0 );
		if( iPackOwner.serial != pUser.serial )
		{
			pUser.SysMessage( "This has to be in your backpack!" );
		}
		else
			srcSock.CustomTarget( 0, "What do you want to use the Jar of Honey with?" );
	}
	else
		pUser.SysMessage( "This has to be in your backpack!" );
	return false;
}

function onCallback0( tSock, targSerial )
{
        var resourceType = 0; 
        var resourceName = ""; 
        var bottleType = 0; 
        var bottleName = ""; 
        var doughName = "";

	var pUser = tSock.currentChar;
	var StrangeByte   = tSock.GetWord( 1 );
	var targX	= tSock.GetWord( 11 );
	var targY	= tSock.GetWord( 13 );
	var targZ	= tSock.GetSByte( 16 );
	var tileID	= tSock.GetWord( 17 );
	if( tileID == 0 || ( StrangeByte == 0 && targSerial.isChar ))
	{ //Target is a Maptile/Character
		pUser.SysMessage("You cannot use your Jar of Honey on that!");
	}
        if( tileID == 0x103D ) 
        {
          resourceType = 0x103D; 
          resourceName = "dough"; 
          bottleType = 0x9ec;
          bottleName = "Jar Honey"; 
          doughName = "sweetdough"; 
        } 
        if( tileID == 0xa1e ) 
        {
          resourceType = 0xa1e; 
          resourceName = "Bowl Flour"; 
          bottleType = 0x9ec;
          bottleName = "Jar Honey"; 
          doughName = "0x103f"; 
        } 
        var iMakeResource = pUser.ResourceCount( bottleType );
        if( iMakeResource > 0 ) 
        { 
          if( resourceType ) 
          { 
             var iMakeResource2 = pUser.ResourceCount( resourceType );
             if( iMakeResource2 > 0 ) 
             { 
                pUser.UseResource( 1, resourceType );
                pUser.UseResource( 1, bottleType ); 
                   // check the skill 
                   if( !pUser.CheckSkill( 13, 0, 300 ) ) 
                   { 
                      pUser.SysMessage( "You failed to mix the Jar of Honey" ); 
                      return; 
                   } 
                   var itemMade = CreateDFNItem( pUser.socket, pUser, doughName, 1, "ITEM", true );
                    pUser.SysMessage( "You have mixed very well!" ); 
             } 
             else 
                pUser.SysMessage( "You don't seem to have any " +resourceName+ "!" ); 
          } 
        }
}
Now cooking.dfn file add this

Code: Select all

[dough]
{
get=base_item
name=dough
id=0x103D
weight=100
}

[sweetdough]
{
get=base_item
name=sweet dough
id=0x103D
weight=100
COLOR=0x150
}

[JarHoney]
{
get=base_item
name=Jar of Honey
id=0x9ec
weight=100
script=111
}

[BowlFlour]
{
get=base_item
name=Bowl of Flour
id=0xa1e
weight=100
}
Post Reply