Reagent Farming v4.0

Got any custom JavaScript additions/tweaks you think other people would like to see? Post 'em 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

Reagent Farming v4.0

Post by dragon slayer »

Version 4.0
1 Fixed some bugs that could of popped up when farming them.
2 Removed some out dated lines.
3 Added onCreateDFN when seedling is created the start timer begings.
4 Changed plant names to seedlings when starting out. then grows into blank plant.
5 Added All new msgs when harvesting and planting seeds.
6 Added Skill check in harvesting plants.
7 changed skill check on plants from 200 to 50
Attachments
reagentfarming.zip
Version 4.0
(8.13 KiB) Downloaded 85 times
Last edited by dragon slayer on Tue Dec 27, 2011 10:33 am, edited 4 times in total.
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 »

blank
Last edited by dragon slayer on Tue Dec 27, 2011 10:35 am, edited 1 time in total.
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 »

blank
Last edited by dragon slayer on Tue Dec 27, 2011 10:34 am, edited 1 time in total.
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 »

Last thing You need to do is edit your swords.js file so you can use sharp objects to cut this babies :)

so open your sword.js file

and put this line of code in

Code: Select all

				else if( tileID == 0x18DD )	// Mandrake
					CutMandrake( socket, mChar, ourObj );
				else if( tileID == 0x18E3 )	// Garlic
					CutGarlic( socket, mChar, ourObj );
				else if( tileID == 0x18E7 )	// Nightshade
					CutNightshade( socket, mChar, ourObj );
				else if( tileID == 0x18EB )	// Ginseng
					CutGinseng( socket, mChar, ourObj );
now add they functions for those

Code: Select all

function CutMandrake( socket, mChar, ourObj )
{
	var ownerObj = GetPackOwner( ourObj, 0 );
	if( ownerObj && mChar.serial == ownerObj.serial )
	{
		var itemMade = CreateDFNItem( mChar.socket, mChar, "0x0f86", 1, "ITEM", true );
		mChar.SysMessage( "You cut the Mandrake!" );
		if( ourObj.amount > 1 )
			ourObj.amount = ourObj.amount-1;
		else
			ourObj.Delete();
	}
	else
		socket.SysMessage( GetDictionaryEntry( 775, socket.Language ) );
}

function CutGarlic( socket, mChar, ourObj )
{
	var ownerObj = GetPackOwner( ourObj, 0 );
	if( ownerObj && mChar.serial == ownerObj.serial )
	{
		var itemMade = CreateDFNItem( mChar.socket, mChar, "0x0f84", 1, "ITEM", true );
		mChar.SysMessage( "You cut the Garlic!" );
		if( ourObj.amount > 1 )
			ourObj.amount = ourObj.amount-1;
		else
			ourObj.Delete();
	}
	else
		socket.SysMessage( GetDictionaryEntry( 775, socket.Language ) );
}

function CutNightshade( socket, mChar, ourObj )
{
	var ownerObj = GetPackOwner( ourObj, 0 );
	if( ownerObj && mChar.serial == ownerObj.serial )
	{
		var itemMade = CreateDFNItem( mChar.socket, mChar, "0x0f88", 1, "ITEM", true );
		mChar.SysMessage( "You cut the Nightshade!" );
		if( ourObj.amount > 1 )
			ourObj.amount = ourObj.amount-1;
		else
			ourObj.Delete();
	}
	else
		socket.SysMessage( GetDictionaryEntry( 775, socket.Language ) );
}

function CutGinseng( socket, mChar, ourObj )
{
	var ownerObj = GetPackOwner( ourObj, 0 );
	if( ownerObj && mChar.serial == ownerObj.serial )
	{
		var itemMade = CreateDFNItem( mChar.socket, mChar, "0x0f85", 1, "ITEM", true );
		mChar.SysMessage( "You cut the Ginseng!" );
		if( ourObj.amount > 1 )
			ourObj.amount = ourObj.amount-1;
		else
			ourObj.Delete();
	}
	else
		socket.SysMessage( GetDictionaryEntry( 775, socket.Language ) );
}
Now you should be all done. Happy Farming reagents
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 »

Nice :) One tip though: You can possibly combine both your "plant" and "harvest" scripts into one, if you check in the onUseChecked() function for the ID of the item used, and then split out into two custom-functions based on whether it's a seed or a harvestable object.

Example:

Code: Select all

function onUseChecked( pUser, iUsed )
{
	if( iUsed.id == 0x04a9 )
		plantSeed( pUser, iUsed );
	else if( iUsed.id == 0x13fb )
		harvestSeed( pUser, iUsed );
	return false;
}

function plantSeed( pUser, iUsed )
{
}

function harvestSeed( pUser, iUsed )
{
}
Just a suggestion to make setup a bit easier. :)
-= 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 »

i never knew that hehe

ill have to build a new script for all that :)
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 »

bump updated
Blue Dragon
UOX3 Apprentice
Posts: 159
Joined: Mon Jan 09, 2012 1:43 am
Has thanked: 0
Been thanked: 0

Post by Blue Dragon »

I tried using this script and I had problems, perhaps because they changed some IDs.

This would be my mandrake seed.

Code: Select all

[sementemandrakeroot]
{ 
GET=base_item
NAME=Semente de Mandrake Root
ID=0x0f7f
COLOR=1114
PILEABLE=1
DECAY=1
RESTOCK=15
VALUE=30 90
SCRIPT=5080
}
This would be my mandrake seedling

Code: Select all

[plantamandrake]
{
get=base_item
name=Planta de Mandrake
id=0x0C61
weight=5
decay=0
SCRIPT=5080
movable=2
}
The rest just changed the name and nothing else.

Well, because after the put scritp the mandrake, the seeds come with different graphics, it seems the is graphic of seedling, but color is brown? In addition to changing the chart, it is not intended to seed, it would be the generator or the like reagents.

One thing I did was change the your seeds ID's for the ID of my seed. And it i used a variable that is:

var = MandrakeSementeID 0x0f7f;

var resourceGrowthDelay = 60000;
var maxResource = 6;

var MandrakeSementeID = 0x0f7f;


function onUseChecked( pUser, iUsed )
{
    if( iUsed.id == MandrakeSementeID )
    plantSeed( pUser, iUsed );
 
    else if( iUsed.id == 0x18DF || 0x0C61 )
    harvestSeed( pUser, iUsed );
    return false;
}


function plantSeed( pUser, iUsed )
{
    var socket = pUser.socket;
    if( socket && iUsed && iUsed.isItem )
    {
        var itemOwner = GetPackOwner( iUsed, 0 );
        if( itemOwner == null || itemOwner.serial != pUser.serial )
        {
        pUser.SysMessage( "O item deve estar em sua mochila." );
        return false;
        }

        else if( iUsed.type != 15 )
        {
        var targMsg = GetDictionaryEntry( 443, socket.Language );
        socket.CustomTarget( 1, targMsg );
        }
        else
    return true;       
    }
return false;
}


function harvestSeed( pUser, iUsed )
{
    var isInRange = pUser.InRange( iUsed, 3 );

    if( !isInRange )
    {
    pUser.SysMessage( "You are too far away to harvest anything." );
    return false;
    }

        if( iUsed.id == 0x0C61 )
        {
            pUser.SysMessage( "Essa planta ainda esta muito jovem para a colheita." );
            return false;
        }
        var Mandrake = iUsed.GetTag("Mandrake");
        var MandrakeCount = iUsed.GetTag("MandrakeCounter");

        if (Mandrake == 0)
        {    
            pUser.SysMessage( "Essa planta ainda esta muito jovem para a colheita." );
            return false;
        }
        if( Mandrake == 1 )
        {
            if( pUser.skills[13] > 200 )
            {

            iUsed.SoundEffect( 0x0050, true );
            var loot = RollDice( 1, 3, 0, 4 );
            if( loot == 2 )
        pUser.SysMessage( "Voce nao conseguiu efetuar a colheita." );
            if( loot == 3 || loot == 1 )
            {
        pUser.SysMessage( "Voce colheu Mandrake." );
        var itemMade = CreateDFNItem( pUser.socket, pUser, "0x18EB", 1, "ITEM", true );
        MandrakeCount--;
        iUsed.SetTag( "MandrakeCounter", MandrakeCount );
        if( MandrakeCount == 1)
        pUser.SysMessage( "Existe "+MandrakeCount+" Mandrake para colher." );
        else
        pUser.SysMessage( "There are "+MandrakeCount+" ripe Mandrakes left to pick." );
        if( MandrakeCount == 0 )
        {
        iUsed.id = 0x0C61;
        iUsed.SetTag( "Mandrake", 0 );
        iUsed.StartTimer( resourceGrowthDelay, 1, true );
        }
            }
            return false;
            }
            else
            pUser.SysMessage( "Voce nao tem ideia de como fazer a colheita dessa planta." );
            return;
   }
}


function onCreateDFN( objMade, objType )
{
   if( objType == 0 )
   {
      if( objMade.id = 0x0C61 )
      {
          objMade.SetTag( "Mandrake", 0 );
          objMade.StartTimer( resourceGrowthDelay, 1, true );
      }
    }
}


function onCallback1( socket, ourObj)
{
    var mChar = socket.currentChar;

    if( mChar && mChar.isChar )
    {
        var tileID = 0;
        if( socket.GetByte( 1 ) )
        {
            tileID = socket.GetWord( 17 );
            if( !tileID )
                tileID = GetTileIDAtMapCoord( socket.GetWord( 11 ), socket.GetWord( 13 ), mChar.worldNumber );
        }
        else if( ourObj && ourObj.isItem )
            tileID = ourObj.id;
           

        if( tileID != 0 )
        {
            if(tileID == 0x0009 || tileID == 0x0010 || tileID == 0x0011 || tileID == 0x0012 || tileID == 0x0013 ||
               tileID == 0x0014 || tileID == 0x0015 )
            {  
                   var iMakeResource = mChar.ResourceCount( MandrakeSementeID );
                   if( iMakeResource < 1 )
                   {
                mChar.SysMessage( "You don't seem to have any more Mandrake seeds." );
                return;
                   }
                   if( mChar.skills[13] < 50 )
                   {
                mChar.SysMessage( "You are not skilled enough to do that." );
                return;
                   }
                   if( mChar.isonhorse )
                   {
                mChar.SysMessage( "You cannot plant a seed while mounted." );
                return false;
                   }
                   mChar.UseResource( 1, MandrakeSementeID, 1114 ); // uses up a resource (amount, item ID, item colour)
                   mChar.SoundEffect( 0x0021, true );
                   if( !mChar.CheckSkill( 13, 100, 500 ) )
                   {
                mChar.SysMessage( "You dropped the seed" );
                return;
                   }
                           targX = socket.GetWord( 11 );
                           targY = socket.GetWord( 13 );
                           targZ = socket.GetSByte( 16 ) + GetTileHeight( socket.GetWord( 17 ) );
                           var itemFound = FindItem( targX, targY, targZ, mChar.worldnumber, 0x1397 );  
                           if( itemFound && itemFound.x == targX && itemFound.y == targY )
                               mChar.SysMessage( "There is already a crop growing here." );
                           else
                           {
                               var itemMade = CreateDFNItem( mChar.socket, mChar, "Mandrakespawner", 1, "SPAWNER", false );
                               itemMade.Teleport( targX, targY, targZ );
                               mChar.SysMessage( "You plant the seed." );
                               return;
                           }

            }
            else
                socket.SysMessage( "This seed will not grow here." );
        }
        else
            socket.SysMessage( "This seed will not grow here." );
    }
}


function onTimer( iUsed, timerID )
{
   if( timerID == 1 )
   {
      iUsed.id = 0x0C61;
      iUsed.StartTimer( 60000, 2, true);
   }
   if( timerID == 2 )
   {
      iUsed.id = 0x18DF;    
      iUsed.StartTimer( 60000, 4, true );
   }
   if( timerID == 4 )
   {
      iUsed.id = 0x18DF;
      iUsed.name ="Mandrake Plant";
      iUsed.SetTag("MandrakeCounter", maxResource);    
      iUsed.SetTag("Mandrake", 1);
   }
}
What would be wrong there?
Blue Dragon
UOX3 Apprentice
Posts: 159
Joined: Mon Jan 09, 2012 1:43 am
Has thanked: 0
Been thanked: 0

Post by Blue Dragon »

Edit: Double Post
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 »

Well after i started to make ahomestead package for uox3 i made the famring totaly better. i was going to go back redo the reagent farming and never got around to it... I still need to do all that :) so this script is getting a heavy overhual
Blue Dragon
UOX3 Apprentice
Posts: 159
Joined: Mon Jan 09, 2012 1:43 am
Has thanked: 0
Been thanked: 0

Post by Blue Dragon »

Tense :shock:
Post Reply