Page 1 of 1

Lumberjacking need help

Posted: Wed Dec 07, 2011 3:10 am
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;
	}
}

Posted: Wed Dec 07, 2011 7:25 am
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
{
}

Posted: Thu Dec 08, 2011 2:42 am
by dragon slayer
never thought about that hehe