PenUltima Online

It is currently Sat Sep 06, 2008 9:14 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Sand mining
PostPosted: Tue Aug 22, 2006 7:28 am 
Offline

Joined: Thu Aug 10, 2006 6:38 am
Posts: 30
ok problem with minig for sand.

says
you fail to find any sand
after lots of loops says no sand left there

any once got anyideas
Code:
use uo;
use os;
use util;
use cfgfile;

include "include/client";
include "include/attributes";
include "include/classes";
include "include/objtype";
include "include/utility";
include "include/itemutil";
include "include/random";
include "include/autoloop";


const UACTION_PICK   := 0x0b;
const DEFAULT_POINTS   := 100;
const POINTS_MULTIPLIER   := 15;
const NUM_PERFORM   := 4;
const MAX_CHANCE   := 155;


program use_picktool( character, tool )

   if( !ReserveItem( tool ) )
      return;
   endif

   if( tool.objtype != UOBJ_SHOVEL && !IsEquipped( character, tool ) )
      SendSysMessage( character, "You must equip it to mine." );
      return;
   endif

   SendSysMessage( character, "Select a place to mine." );

   var use_on := TargetCoordinates( character );
   if (!use_on)
      return;
   endif

   var distt := coordist( character.x, character.y, use_on.x, use_on.y );
   if( distt > 2 )
      SendSysMessage( character, "That is too far away." );
      return;
   endif

  Autoloop_init( character );

  while (Autoloop_more() && not character.dead)

   var info := GetMapInfo( use_on.x, use_on.y );
   var result;

// horrible hack for crafters cave
   if( IsSwamp( info.landtile ) )
      SendSysMessage( character, "You start mining..." );
      result := DigForClay( character, use_on, info );

   elseif( IsMinable( info.landtile, use_on.objtype ) )
      SendSysMessage( character, "You start mining..." );
      result := MineForOre( character, use_on, info, tool );
   
   elseif( IsSand( info.landtile ) )
      SendSysMessage( character, "You start mining..." );
      result := DigForSand( character, use_on, info );
   
   else
      SendSysMessage( character, "You can't mine or dig anything there." );
      return;
   endif

   sleep( 1 );


   /*
       result > 0  - Success   - autoloop goes on
       result = 0  - Failure   - autoloop goes on
       result < 0  - Exausthed   - autoloop stops
   */

   if( result > 0)
      DoSomething( character, tool );

                /*** If tool is broken, autolooping have to stop ***/
                if (!tool)
                        Autoloop_finish();
                        SendSysMessage( character, "You stop mining." );
                        return;
                endif
        elseif (result < 0)
                /*** No more to dig here! ****/
                Autoloop_finish();
                SendSysMessage( character, "You stop mining." );
                return;
   endif

endwhile

Autoloop_finish();
SendSysMessage( character, "You stop mining." );

endprogram



function GetStuff( character, oreamount, tool )

   var to_make_colored := CInt( GetEffectiveSkill( character, SKILLID_MINING ) / 5 ) + 35;
   var crafter := GetObjProperty( character, CLASSEID_CRAFTER );

   var tool_bon   := GetObjProperty( tool, "MiningBonus" );
   if( tool_bon )
      to_make_colored := CInt(to_make_colored + (10 * tool_bon ));
      oreamount   := CInt(oreamount * tool_bon);
   endif

   if( to_make_colored > 75 )
      to_make_colored := 75;
   endif

   if( crafter )
      to_make_colored := CInt( to_make_colored * CLASSE_BONUS );
      if( to_make_colored > 90 )
         to_make_colored := 90;
      endif
   endif

   if( RandomDiceStr("1d100") <= to_make_colored )
      MakeColoredOre( character, oreamount, tool );
   else
      if( crafter )
         oreamount := CInt( oreamount * CLASSE_BONUS );
      endif
   
      CreateItemInBackpack( character, UOBJ_IRON_ORE, oreamount );
      SendSysMessage( character, "You put " + oreamount + " iron ore in your backpack." );
   endif
 
endfunction


function MakeColoredOre( character, oreamount, tool )

   var skill   := GetEffectiveSkill( character, SKILLID_MINING );
   var maxamount := CInt( skill / 30 );
   
   var tool_bon   := GetObjProperty( tool, "MiningBonus" );
   if( tool_bon )
      maxamount   := CInt(maxamount * tool_bon);
   endif

   if( oreamount > maxamount )
      oreamount := maxamount;

   endif

   if( oreamount < 1 )
      oreamount := 1;
   endif

   var chance   := RandomDiceStr( "1d" + MAX_CHANCE );
   var cfg   := ReadConfigFile( "itemdesc" );
   if (!cfg)
      return;
   endif
   
   var thekeys   := GetConfigStringKeys( cfg );
   var possibles   := {};
   var min_chance:= MAX_CHANCE * 2;
   var the_ore;

   if( Random(2) )
      var bonus   := CInt( skill / 4 );
      var to_mod   := 80;
      if( GetObjProperty( character, CLASSEID_CRAFTER ) )
         bonus      := CInt( bonus * CLASSE_BONUS );
         oreamount   := CInt( oreamount * CLASSE_BONUS );
         to_mod      := CInt( to_mod / CLASSE_BONUS );
      endif
   
      if( tool_bon )
         bonus  := CInt(bonus + (6 * tool_bon));
         to_mod := CInt(to_mod - (5 * tool_bon));
      endif

      if( chance > to_mod )
         chance := chance - bonus;
      endif
   endif

   foreach key in thekeys
      if (!key)
         return;
      endif

      var the_chance := CInt( cfg[key].HarvestChance );
      if( the_chance && chance <= the_chance )
         if( CheckSkill( character, SKILLID_MINING, CInt(cfg[key].HarvestDiff), 0 ) )
            possibles.append( key );
         endif
      endif
   endforeach

   if( len( possibles ) )
      //set_critical(1);
      foreach key in possibles
         if (!key)
            return;
         endif
         var hchance := CInt( cfg[key].HarvestChance );
         if( hchance < min_chance )
            the_ore := key;
            min_chance := hchance;
         endif
      endforeach
      //set_critical(0);
      CreateItemInBackpack( character, CInt(the_ore), CInt(oreamount) );
      SendSysMessage( character, "You put " + CInt(oreamount) + " " + cfg[the_ore].desc + " in your backpack." );
   else
      SendSysMessage( character, "You fail to find any coloured ore." );
   endif

endfunction



function DigForClay( character, use_on, info )

   var initial_x   := character.x;
   var initial_y   := character.y;

   var tdiff := GetHarvestDifficulty( "clay", use_on.x, use_on.y, info.landtile );
   var clay_amount := HarvestResource( "clay", use_on.x, use_on.y, 1, 2 );
   if( !clay_amount )
      SendSysMessage(character, "There's no clay left there.");
      return -1; //was 0, modified by Jaleem
   endif

   var i;
   for( i := 1; i <= NUM_PERFORM; i := i + 1 )
      PerformAction( character, UACTION_PICK );
      PlaySoundEffect( character, SFX_PICK );
      sleep(1);
      if( character.x != initial_x || character.y != initial_y )
         return 0;
      endif
   endfor

   if( CheckSkill( character, SKILLID_MINING, tdiff, tdiff * POINTS_MULTIPLIER ) )

      var theamount;
      if( clay_amount < 2 )
         theamount := 1;
      
      else
         theamount := Random(6)+1;
      endif
      
      var theclay := CreateItemInBackpack( character, UOBJ_CLAY, theamount );
      SendSysMessage( character, "You put " + theamount + " blocks of clay in your backpack." );
      
   else
      SendSysMessage( character, "You fail to find any clay." );
      return 0;
   endif

   return 1;

endfunction



function DigForSand( character, use_on, info )

   var initial_x   := character.x;
   var initial_y   := character.y;

   var tdiff := GetHarvestDifficulty( "sand", use_on.x, use_on.y, info.landtile );
   var sandamount := HarvestResource( "sand", use_on.x, use_on.y, 1, 2 );
   if( !sandamount )
      SendSysMessage(character, "There's no sand left there.");
      return -1; //was 0, modified by Jaleem
   endif
   
   var i;
   for( i := 1; i <= NUM_PERFORM; i := i + 1 )
      PerformAction( character, UACTION_PICK );
      PlaySoundEffect( character, SFX_HAMMER );
      sleep(1);
      if( character.x != initial_x || character.y != initial_y )
         return 0;
      endif
   endfor

   if( CheckSkill( character, SKILLID_MINING, tdiff, tdiff * POINTS_MULTIPLIER ) )

      var theamount;
      if( sandamount < 2 )
         theamount := 1;
      
      else
         theamount := Random(6)+1;
      endif
   
      var thesand := CreateItemInBackpack( character, UOBJ_SAND, theamount );
      SendSysMessage( character, "You put " + theamount + " units of sand in your backpack." );

   else
      SendSysMessage( character, "You fail to find any sand." );
      return 0;
   endif

   return 1;

endfunction



function MineForOre( character, use_on, info, tool )

   var initial_x   := character.x;
   var initial_y   := character.y;
   var oreamount := HarvestResource( "ore", use_on.x, use_on.y, 1, CInt( GetEffectiveSkill( character, SKILLID_MINING ) / 15 )+1 );
   if( !oreamount )
      SendSysMessage( character, "There's no ore left there.");
      return -1; //was 0, modified by Jaleem
   endif

   var i;
   for( i := 1; i <= NUM_PERFORM; i := i + 1 )
      PerformAction( character, UACTION_PICK );
      PlaySoundEffect( character, SFX_HAMMER );
      sleep(1);
      if( character.x != initial_x || character.y != initial_y )
         return 0;
      endif
   endfor

   if( CheckSkill( character, SKILLID_MINING, -1, DEFAULT_POINTS ) )
      GetStuff( character, oreamount, tool );
   else
      SendSysMessage( character, "You fail to find any ore." );
      return 0;
   endif

   return 1;

endfunction


function DoSomething( character, tool )



   var tnum  := Random(100)+1;
   var bonus := CInt( GetEffectiveSkill( character, SKILLID_MINING ) / 30 );
   if( GetObjProperty( character, CLASSEID_CRAFTER ) )
      bonus := CInt( bonus * CLASSE_BONUS ) + 1;
   endif

   tnum := tnum + bonus;


   var tool_bon   := GetObjProperty( tool, "MiningBonus" );
   if( tool_bon )
      tnum := CInt(tnum + (2 * tool_bon));
   endif

   var msg;
   var objtype;
   var amount := 1;


   case( tnum )
      1:
      2: 
      3:
      4:   if (!tool_bon)
            msg := "Oh no your tool breaks!";
            DestroyTheItem( character, tool );
            break;
         endif

      98:   objtype := 0x6003;
         msg := "You discover a tattered map!";
         break;
   
      99:   objtype := 0x0f25;
         msg := "You find a chunk of fossilized sap!";
         break;
      
      100:   objtype := 0xc503;
         msg := "You find a piece of elusive NEW ZULU ORE!";
         break;
      
      105:   objtype := 0x0f30;
         msg := "You find a diamond!";
         break;
   
      106:   objtype := 0xc503;
         msg := "You find a piece of elusive NEW ZULU ORE!";
         break;
      
      107:   if( Random(15) < 1 )
            case(RandomInt(3))
               0:   objtype := 0xc538;
                  msg := "You find a strange looking blue gem!";
                  break;
               1:   objtype := 0xc539;
                  msg := "You find a strange looking red gem!";
                  break;
               2:   objtype := 0xc53a;
                  msg := "You find a glowing bright white gem!";
                  break;
            endcase
         endif
         break;

      108:   if( Random(5) < 1 )
            objtype := 0xc538;
            msg := "You find a strange looking blue gem!";
            break;
         endif

      109:   if( Random(10) < 1 )
            objtype := 0xc539;
            msg := "You find a strange looking red gem!";
            break;
         endif

      110:   if( Random(15) < 1 )
            objtype := 0xc53a;
            msg := "You find a glowing bright white gem!";
         endif
         break;
   
   endcase

   if( objtype )
      if( CreateItemInBackpack( character, objtype, amount ) )
         if( msg )
            SendSysMessage( character, msg );
         endif
      endif
   elseif( msg )
      SendSysMessage( character, msg );
   endif

endfunction


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 22, 2006 9:10 am 
Online

Joined: Sat Feb 04, 2006 5:49 pm
Posts: 749
Location: Chicago, IL USA
I think its because you use HarvestResource to do your checks which even if it doesnt give it to your character, its still taking it away from the resources that are there. My scripts take this a little differently. My scripts check if GetHarvestDifficulty == error to see if any resources are there or not and it doesnt do HarvestResource until it actually gives you the resources.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 22, 2006 10:34 pm 
Offline

Joined: Thu Feb 02, 2006 1:41 pm
Posts: 1127
Location: Southern Central USA
First make sure you've setup sand as a resource in your resource.cfg file in \pol\config

Code:
   ResourceType      sand


Then in that same folder you need a file called sand.cfg that looks something like this:

Code:
# Note, regions found later in the file override those found earlier.

Global
{
     InitialUnits    10000
landtile 0x0016
landtile 0x0017
landtile 0x0018
landtile 0x0019
landtile 0x001A
landtile 0x001B
landtile 0x001C
landtile 0x001D
landtile 0x001E
landtile 0x001F
landtile 0x0020
landtile 0x0021
landtile 0x0022
landtile 0x0023
landtile 0x0024
landtile 0x0025
landtile 0x0026
landtile 0x0027
landtile 0x0028
landtile 0x0029
landtile 0x002A
landtile 0x002B
landtile 0x002C
landtile 0x002D
landtile 0x002E
landtile 0x002F
landtile 0x0030
landtile 0x0031
landtile 0x0032
landtile 0x0033
landtile 0x0034
landtile 0x0035
landtile 0x0036
landtile 0x0037
landtile 0x0038
landtile 0x0039
landtile 0x003A
landtile 0x003B
landtile 0x003C
landtile 0x003D
landtile 0x003E
landtile 0x003F
landtile 0x0040
landtile 0x0041
landtile 0x0042
landtile 0x0043
landtile 0x0044
landtile 0x0045
landtile 0x0046
landtile 0x0047
landtile 0x0048
landtile 0x0049
landtile 0x004A
landtile 0x004B
landtile 0x011E
landtile 0x011F
landtile 0x0120
landtile 0x0121
landtile 0x0122
landtile 0x0123
landtile 0x0124
landtile 0x0125
landtile 0x0126
landtile 0x0127
landtile 0x0128
landtile 0x0129
landtile 0x012A
landtile 0x012B
landtile 0x012C
landtile 0x012D
landtile 0x0192
landtile 0x0193
landtile 0x0194
landtile 0x0195
landtile 0x0196
landtile 0x0197
landtile 0x0198
landtile 0x0199
landtile 0x019A
landtile 0x019B
landtile 0x019C
landtile 0x019D
landtile 0x019E
landtile 0x019F
landtile 0x01A0
landtile 0x01A1
landtile 0x01A2
landtile 0x01A3
landtile 0x01A4
landtile 0x01A5
landtile 0x01A6
landtile 0x01A7
landtile 0x01A8
landtile 0x01A9
landtile 0x01AA
landtile 0x01AB
landtile 0x01B9
landtile 0x01BA
landtile 0x01BB
landtile 0x01BC
landtile 0x01BD
landtile 0x01BE
landtile 0x01BF
landtile 0x01C0
landtile 0x01C1
landtile 0x01C2
landtile 0x01C3
landtile 0x01C4
landtile 0x01C5
landtile 0x01C6
landtile 0x01C7
landtile 0x01C8
landtile 0x01C9
landtile 0x01CA
landtile 0x01CB
landtile 0x01CC
landtile 0x01CD
landtile 0x01CE
landtile 0x01CF
landtile 0x01D0
landtile 0x01D1
landtile 0x0282
landtile 0x0283
landtile 0x0284
landtile 0x0285
landtile 0x0286
landtile 0x0287
landtile 0x0288
landtile 0x0289
landtile 0x028A
landtile 0x028B
landtile 0x028C
landtile 0x028D
landtile 0x028E
landtile 0x028F
landtile 0x0290
landtile 0x0291
landtile 0x03B7
landtile 0x03B8
landtile 0x03B9
landtile 0x03BA
landtile 0x03BB
landtile 0x03BC
landtile 0x03BD
landtile 0x03BE
landtile 0x03BF
landtile 0x03C0
landtile 0x03C1
landtile 0x03C2
landtile 0x03C3
landtile 0x03C4
landtile 0x03C5
landtile 0x03C6
landtile 0x03C7
landtile 0x03C8
landtile 0x03C9
landtile 0x03CA
landtile 0x064B
landtile 0x064C
landtile 0x064D
landtile 0x064E
landtile 0x064F
landtile 0x0650
landtile 0x0651
landtile 0x0652
landtile 0x0653
landtile 0x0654
landtile 0x0655
landtile 0x0656
landtile 0x0657
landtile 0x0658
landtile 0x0659
landtile 0x065A
landtile 0x065B
landtile 0x065C
landtile 0x065D
landtile 0x065E
landtile 0x065F
landtile 0x0660
landtile 0x0661
landtile 0x0662
landtile 0x0663
landtile 0x0664
landtile 0x0665
landtile 0x0666
landtile 0x0667
landtile 0x0668
landtile 0x0669
landtile 0x066A
landtile 0x066B
landtile 0x066C
landtile 0x066D
landtile 0x066E
landtile 0x066F
landtile 0x0670
landtile 0x0671
landtile 0x0672

}

Region The Whole World
{
    UnitsPerArea        50
    SecondsPerRegrow    30
    Capacity            200000
    Range               0 0 5119 4095
}



Then I would suggest following CWOs suggestion of moving the HarvestResource line after the CheckSkill line along with the check for availability of sand..

Then change the line if( !sandamount ) to if(sandamount == error).

Here is the script with the changes:

Code:
use uo;
use os;
use util;
use cfgfile;

include "include/client";
include "include/attributes";
include "include/classes";
include "include/objtype";
include "include/utility";
include "include/itemutil";
include "include/random";
include "include/autoloop";


const UACTION_PICK   := 0x0b;
const DEFAULT_POINTS   := 100;
const POINTS_MULTIPLIER   := 15;
const NUM_PERFORM   := 4;
const MAX_CHANCE   := 155;


program use_picktool( character, tool )

   if( !ReserveItem( tool ) )
      return;
   endif

   if( tool.objtype != UOBJ_SHOVEL && !IsEquipped( character, tool ) )
      SendSysMessage( character, "You must equip it to mine." );
      return;
   endif

   SendSysMessage( character, "Select a place to mine." );

   var use_on := TargetCoordinates( character );
   if (!use_on)
      return;
   endif

   var distt := coordist( character.x, character.y, use_on.x, use_on.y );
   if( distt > 2 )
      SendSysMessage( character, "That is too far away." );
      return;
   endif

  Autoloop_init( character );

  while (Autoloop_more() && not character.dead)

   var info := GetMapInfo( use_on.x, use_on.y );
   var result;

// horrible hack for crafters cave
   if( IsSwamp( info.landtile ) )
      SendSysMessage( character, "You start mining..." );
      result := DigForClay( character, use_on, info );

   elseif( IsMinable( info.landtile, use_on.objtype ) )
      SendSysMessage( character, "You start mining..." );
      result := MineForOre( character, use_on, info, tool );
   
   elseif( IsSand( info.landtile ) )
      SendSysMessage( character, "You start mining..." );
      result := DigForSand( character, use_on, info );
   
   else
      SendSysMessage( character, "You can't mine or dig anything there." );
      return;
   endif

   sleep( 1 );


   /*
       result > 0  - Success   - autoloop goes on
       result = 0  - Failure   - autoloop goes on
       result < 0  - Exausthed   - autoloop stops
   */

   if( result > 0)
      DoSomething( character, tool );

                /*** If tool is broken, autolooping have to stop ***/
                if (!tool)
                        Autoloop_finish();
                        SendSysMessage( character, "You stop mining." );
                        return;
                endif
        elseif (result < 0)
                /*** No more to dig here! ****/
                Autoloop_finish();
                SendSysMessage( character, "You stop mining." );
                return;
   endif

endwhile

Autoloop_finish();
SendSysMessage( character, "You stop mining." );

endprogram



function GetStuff( character, oreamount, tool )

   var to_make_colored := CInt( GetEffectiveSkill( character, SKILLID_MINING ) / 5 ) + 35;
   var crafter := GetObjProperty( character, CLASSEID_CRAFTER );

   var tool_bon   := GetObjProperty( tool, "MiningBonus" );
   if( tool_bon )
      to_make_colored := CInt(to_make_colored + (10 * tool_bon ));
      oreamount   := CInt(oreamount * tool_bon);
   endif

   if( to_make_colored > 75 )
      to_make_colored := 75;
   endif

   if( crafter )
      to_make_colored := CInt( to_make_colored * CLASSE_BONUS );
      if( to_make_colored > 90 )
         to_make_colored := 90;
      endif
   endif

   if( RandomDiceStr("1d100") <= to_make_colored )
      MakeColoredOre( character, oreamount, tool );
   else
      if( crafter )
         oreamount := CInt( oreamount * CLASSE_BONUS );
      endif
   
      CreateItemInBackpack( character, UOBJ_IRON_ORE, oreamount );
      SendSysMessage( character, "You put " + oreamount + " iron ore in your backpack." );
   endif
 
endfunction


function MakeColoredOre( character, oreamount, tool )

   var skill   := GetEffectiveSkill( character, SKILLID_MINING );
   var maxamount := CInt( skill / 30 );
   
   var tool_bon   := GetObjProperty( tool, "MiningBonus" );
   if( tool_bon )
      maxamount   := CInt(maxamount * tool_bon);
   endif

   if( oreamount > maxamount )
      oreamount := maxamount;

   endif

   if( oreamount < 1 )
      oreamount := 1;
   endif

   var chance   := RandomDiceStr( "1d" + MAX_CHANCE );
   var cfg   := ReadConfigFile( "itemdesc" );
   if (!cfg)
      return;
   endif
   
   var thekeys   := GetConfigStringKeys( cfg );
   var possibles   := {};
   var min_chance:= MAX_CHANCE * 2;
   var the_ore;

   if( Random(2) )
      var bonus   := CInt( skill / 4 );
      var to_mod   := 80;
      if( GetObjProperty( character, CLASSEID_CRAFTER ) )
         bonus      := CInt( bonus * CLASSE_BONUS );
         oreamount   := CInt( oreamount * CLASSE_BONUS );
         to_mod      := CInt( to_mod / CLASSE_BONUS );
      endif
   
      if( tool_bon )
         bonus  := CInt(bonus + (6 * tool_bon));
         to_mod := CInt(to_mod - (5 * tool_bon));
      endif

      if( chance > to_mod )
         chance := chance - bonus;
      endif
   endif

   foreach key in thekeys
      if (!key)
         return;
      endif

      var the_chance := CInt( cfg[key].HarvestChance );
      if( the_chance && chance <= the_chance )
         if( CheckSkill( character, SKILLID_MINING, CInt(cfg[key].HarvestDiff), 0 ) )
            possibles.append( key );
         endif
      endif
   endforeach

   if( len( possibles ) )
      //set_critical(1);
      foreach key in possibles
         if (!key)
            return;
         endif
         var hchance := CInt( cfg[key].HarvestChance );
         if( hchance < min_chance )
            the_ore := key;
            min_chance := hchance;
         endif
      endforeach
      //set_critical(0);
      CreateItemInBackpack( character, CInt(the_ore), CInt(oreamount) );
      SendSysMessage( character, "You put " + CInt(oreamount) + " " + cfg[the_ore].desc + " in your backpack." );
   else
      SendSysMessage( character, "You fail to find any coloured ore." );
   endif

endfunction



function DigForClay( character, use_on, info )

   var initial_x   := character.x;
   var initial_y   := character.y;

   var tdiff := GetHarvestDifficulty( "clay", use_on.x, use_on.y, info.landtile );
   var clay_amount := HarvestResource( "clay", use_on.x, use_on.y, 1, 2 );
   if( !clay_amount )
      SendSysMessage(character, "There's no clay left there.");
      return -1; //was 0, modified by Jaleem
   endif

   var i;
   for( i := 1; i <= NUM_PERFORM; i := i + 1 )
      PerformAction( character, UACTION_PICK );
      PlaySoundEffect( character, SFX_PICK );
      sleep(1);
      if( character.x != initial_x || character.y != initial_y )
         return 0;
      endif
   endfor

   if( CheckSkill( character, SKILLID_MINING, tdiff, tdiff * POINTS_MULTIPLIER ) )

      var theamount;
      if( clay_amount < 2 )
         theamount := 1;
       
      else
         theamount := Random(6)+1;
      endif
       
      var theclay := CreateItemInBackpack( character, UOBJ_CLAY, theamount );
      SendSysMessage( character, "You put " + theamount + " blocks of clay in your backpack." );
       
   else
      SendSysMessage( character, "You fail to find any clay." );
      return 0;
   endif

   return 1;

endfunction



function DigForSand( character, use_on, info )

   var initial_x   := character.x;
   var initial_y   := character.y;

   var tdiff := GetHarvestDifficulty( "sand", use_on.x, use_on.y, info.landtile );
   if( !sandamount )
      SendSysMessage(character, "There's no sand left there.");
      return -1; //was 0, modified by Jaleem
   endif
   
   var i;
   for( i := 1; i <= NUM_PERFORM; i := i + 1 )
      PerformAction( character, UACTION_PICK );
      PlaySoundEffect( character, SFX_HAMMER );
      sleep(1);
      if( character.x != initial_x || character.y != initial_y )
         return 0;
      endif
   endfor

   if( CheckSkill( character, SKILLID_MINING, tdiff, tdiff * POINTS_MULTIPLIER ) )

      var theamount;
      var sandamount := HarvestResource( "sand", use_on.x, use_on.y, 1, 2 );
      if( !sandamount )
         SendSysMessage(character, "There's no sand left there.");
         return -1; //was 0, modified by Jaleem
      endif
      if( sandamount < 2 )
         theamount := 1;
       
      else
         theamount := Random(6)+1;
      endif
   
      var thesand := CreateItemInBackpack( character, UOBJ_SAND, theamount );
      SendSysMessage( character, "You put " + theamount + " units of sand in your backpack." );

   else
      SendSysMessage( character, "You fail to find any sand." );
      return 0;
   endif

   return 1;

endfunction



function MineForOre( character, use_on, info, tool )

   var initial_x   := character.x;
   var initial_y   := character.y;
   var oreamount := HarvestResource( "ore", use_on.x, use_on.y, 1, CInt( GetEffectiveSkill( character, SKILLID_MINING ) / 15 )+1 );
   if( !oreamount )
      SendSysMessage( character, "There's no ore left there.");
      return -1; //was 0, modified by Jaleem
   endif

   var i;
   for( i := 1; i <= NUM_PERFORM; i := i + 1 )
      PerformAction( character, UACTION_PICK );
      PlaySoundEffect( character, SFX_HAMMER );
      sleep(1);
      if( character.x != initial_x || character.y != initial_y )
         return 0;
      endif
   endfor

   if( CheckSkill( character, SKILLID_MINING, -1, DEFAULT_POINTS ) )
      GetStuff( character, oreamount, tool );
   else
      SendSysMessage( character, "You fail to find any ore." );
      return 0;
   endif

   return 1;

endfunction


function DoSomething( character, tool )



   var tnum  := Random(100)+1;
   var bonus := CInt( GetEffectiveSkill( character, SKILLID_MINING ) / 30 );
   if( GetObjProperty( character, CLASSEID_CRAFTER ) )
      bonus := CInt( bonus * CLASSE_BONUS ) + 1;
   endif

   tnum := tnum + bonus;


   var tool_bon   := GetObjProperty( tool, "MiningBonus" );
   if( tool_bon )
      tnum := CInt(tnum + (2 * tool_bon));
   endif

   var msg;
   var objtype;
   var amount := 1;


   case( tnum )
      1:
      2: 
      3:
      4:   if (!tool_bon)
            msg := "Oh no your tool breaks!";
            DestroyTheItem( character, tool );
            break;
         endif

      98:   objtype := 0x6003;
         msg := "You discover a tattered map!";
         break;
   
      99:   objtype := 0x0f25;
         msg := "You find a chunk of fossilized sap!";
         break;
       
      100:   objtype := 0xc503;
         msg := "You find a piece of elusive NEW ZULU ORE!";
         break;
       
      105:   objtype := 0x0f30;
         msg := "You find a diamond!";
         break;
   
      106:   objtype := 0xc503;
         msg := "You find a piece of elusive NEW ZULU ORE!";
         break;
       
      107:   if( Random(15) < 1 )
            case(RandomInt(3))
               0:   objtype := 0xc538;
                  msg := "You find a strange looking blue gem!";
                  break;
               1:   objtype := 0xc539;
                  msg := "You find a strange looking red gem!";
                  break;
               2:   objtype := 0xc53a;
                  msg := "You find a glowing bright white gem!";
                  break;
            endcase
         endif
         break;

      108:   if( Random(5) < 1 )
            objtype := 0xc538;
            msg := "You find a strange looking blue gem!";
            break;
         endif

      109:   if( Random(10) < 1 )
            objtype := 0xc539;
            msg := "You find a strange looking red gem!";
            break;
         endif

      110:   if( Random(15) < 1 )
            objtype := 0xc53a;
            msg := "You find a glowing bright white gem!";
         endif
         break;
   
   endcase

   if( objtype )
      if( CreateItemInBackpack( character, objtype, amount ) )
         if( msg )
            SendSysMessage( character, msg );
         endif
      endif
   elseif( msg )
      SendSysMessage( character, msg );
   endif

endfunction


Try that and see if it works. Oh and be sure your character has enough skill to mine for sand and that her backpack is not full.

_________________
Sincerely,
Yukiko

I know you think you understand what you thought I said but what you heard is not exactly what I meant.

Titus 2:13


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 23, 2006 6:12 am 
Online

Joined: Sat Feb 04, 2006 5:49 pm
Posts: 749
Location: Chicago, IL USA
remove the conditional statement after the GetHarvestDifficulty otherwise you'll have compile errors.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 23, 2006 8:58 am 
Offline

Joined: Thu Aug 10, 2006 6:38 am
Posts: 30
sorry boys its actually working the way privious scirpters wanted.. u can only mine sand on the edges of beaches and sand cliffs

Thx any way guys u were a great help.

nice to see plz helping so much

if any 1 gets same prob or needs fix pm me.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Style based on FI Subice by phpBBservice.nl