Lumberjacking need help

Need help with your JScripts? Got questions concerning the DFNs? Come forward, step inside :)
Post Reply
dragon slayer
UOX3 Guru
Posts: 776
Joined: Thu Dec 21, 2006 7:37 am
Has thanked: 4 times
Been thanked: 26 times

Lumberjacking need help

Post by dragon slayer »

Okay I'm tyring to create the new logs Uo has but I'm trying to make it so lumberjacking creates them when you chop a tree here is what i got but I'm hvaing problem making it check for skill level 80 and up to see if it can harvest new logs

Code: Select all

function onTimer( mChar, timerID )
{
	switch( timerID )
	{
	case 0:
		mChar.skillsused.lumberjacking = false;
		var socket = mChar.socket;
		if( socket )
		{
			var mResource = ResourceRegion( socket.clickX, socket.clickY, mChar.worldnumber );
			socket.clickX = 0;
			socket.clickY = 0;

			if( mChar.CheckSkill( 44, 0, 1000 ) )
			{
                                if( mChar.skills.lumberjacking > 650 )
                                {
                                    switch( RandomNumber( 0, 3 ) )
                                    {
                                          case 0: mResource.logAmount = mResource.logAmount-1;
				                  CreateBlankItem( socket, mChar, 10, "#", 0x1BE0, 0x0000, "ITEM", true );
				                  socket.SysMessage( GetDictionaryEntry( 1435, socket.Language ) ); break;
                                          case 1: mResource.logAmount = mResource.logAmount-1;
				                  var itemMade = CreateDFNItem( mChar.socket, mChar, "OakLog", 10, "ITEM", true );
				                  socket.SysMessage( GetDictionaryEntry( 1435, socket.Language ) ); break;
                                          case 2: mResource.logAmount = mResource.logAmount-1;
				                  CreateBlankItem( socket, mChar, 10, "#", 0x1BE0, 0x0000, "ITEM", true );
				                  socket.SysMessage( GetDictionaryEntry( 1435, socket.Language ) ); break;
                                          case 3: socket.SysMessage( GetDictionaryEntry( 842, socket.Language ) );
				                  if( RandomNumber( 0, 1 ) )	// 50% chance to destroy some resources
					          mResource.logAmount = mResource.logAmount-1;
			                   default:
                                     }
		                     break;
                                }
                                if( mChar.skills.lumberjacking > 800 )
                                {
                                    switch( RandomNumber( 0, 4 ) )
                                    {
                                          case 0: mResource.logAmount = mResource.logAmount-1;
				                  CreateBlankItem( socket, mChar, 10, "#", 0x1BE0, 0x0000, "ITEM", true );
				                  socket.SysMessage( GetDictionaryEntry( 1435, socket.Language ) ); break;
                                          case 1: mResource.logAmount = mResource.logAmount-1;
				                  var itemMade = CreateDFNItem( mChar.socket, mChar, "AshLog", 10, "ITEM", true );
				                  socket.SysMessage( GetDictionaryEntry( 1435, socket.Language ) ); break;
                                          case 2: mResource.logAmount = mResource.logAmount-1;
				                  CreateBlankItem( socket, mChar, 10, "#", 0x1BE0, 0x0000, "ITEM", true );
				                  socket.SysMessage( GetDictionaryEntry( 1435, socket.Language ) ); break;
                                          case 3: mResource.logAmount = mResource.logAmount-1;
				                  CreateBlankItem( socket, mChar, 10, "#", 0x1BE0, 0x0000, "ITEM", true );
				                  socket.SysMessage( GetDictionaryEntry( 1435, socket.Language ) ); break;
                                          case 4: socket.SysMessage( GetDictionaryEntry( 842, socket.Language ) );
				                  if( RandomNumber( 0, 1 ) )	// 50% chance to destroy some resources
					          mResource.logAmount = mResource.logAmount-1;
			                   default:
                                     }
		                     break;
                                }
                                else
                                   mResource.logAmount = mResource.logAmount-1;
				   CreateBlankItem( socket, mChar, 10, "#", 0x1BE0, 0x0000, "ITEM", true );
				   socket.SysMessage( GetDictionaryEntry( 1435, socket.Language ) ); break;
			}
			else
			{
				socket.SysMessage( GetDictionaryEntry( 842, socket.Language ) );
				if( RandomNumber( 0, 1 ) )	// 50% chance to destroy some resources
					mResource.logAmount = mResource.logAmount-1;
			}
		}
		break;
	case 1:
		if( mChar.isonhorse )
			mChar.DoAction( 0x1C );
		else
			mChar.DoAction( 0x0D );
	
		mChar.SoundEffect( 0x013E, true );

		mChar.StartTimer( 1500, 0, true );
		break;
	}
}
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

Not sure if this is the issue, but at first glance it appears that in both your switch( RandomNumber( 0, 4 ) ) locations, the final break; line is outside of the brackets, while I suspect they were meant for the default case, or? I'm thinking the script will always break out of the switch statements after the first skillcheck.

Also, as it's currently setup (if you fix the out of place break lines), the first log-spawning section will _always_ run if the character has skill over 650, including if he has skill over 800. If that's not ideal, I would move the 800 section above the 650, and then set it up like an if/else if case.

Like so:

Code: Select all

if( mChar.skills.lumberjacking > 800 )
{
}
else if( mChar.skills.lumberjacking > 650 )
{
}
else
{
}
-= Ho Eyo He Hum =-
dragon slayer
UOX3 Guru
Posts: 776
Joined: Thu Dec 21, 2006 7:37 am
Has thanked: 4 times
Been thanked: 26 times

Post by dragon slayer »

never thought about that hehe
Post Reply