I'm using the SVN distro99 yes. Atrazés update TortoiseSVN, as Austin guided in another post.
Code: Select all
/*
Maintened by *Edwards
For FantasiaShard.com
Edwards@FantasiaShard.com
2008-10-17
Last Modifications 2008-12-13
* Fixed a check distance between of mobile & targ
Last Modifications 2009-01-18
* Verifications of the codes
* Mobile will now face targ
Last Modifications 2009-07-31
* Added useItem_check()
Last Modifications 2009-11-24
* Added check with LOS
* Added Play_mining_effects()
* Changed mining loop to random
* Fixed message with wrong amount of ressource shown
* Added landtiles.inc
* Cleaned codes for better performances
Last Modifications 2010-01-07
* Added check if mobile is in noDamage area will get a penalty for amount harvested
Last Modifications 2010-03-19
* Added Autoloop to mining
*/
use uo;
use os;
use util;
include "include/client";
include "include/facings";
include "include/itemUtil";
include "include/landtiles";
include ":areas:managment";
include ":attributes:attributes";
include ":autoloop:autoloop";
include ":classes:classes";
include ":crafting:crafting";
const NO_DAMAGE_BONUS := 1.50;
const HARVEST_BONUS := 2.5;
program skill_Mining( mobile, shovel )
if( shovel.objtype == 0x0f39 )
if( !useItem_check( mobile, shovel, ITEM_INCONTAINER ))
return 0;
endif
else
EquipItem( mobile, shovel );
if( !useItem_check( mobile, shovel, ITEM_EQUIPPED ))
return 0;
endif
endif
SendSysMessage( mobile, "Select a place to mine." );
var targ := TargetCoordinates( mobile );
if( !targ )
SendSysMessage( mobile, "Cancelled." );
return 0;
elseif( CoordinateDistance( mobile.x, mobile.y, targ.x, targ.y ) > 2 )
SendSysMessage( mobile, "This is too far away." );
return 0;
elseif( !CheckLosAt( mobile, targ.x, targ.y, targ.z ))
SendSysMessage( mobile, "You cannot see that." );
return 0;
endif
var info := GetMapInfo( targ.x, targ.y ),
mine_amount,
tile;
SendAutoLoop( mobile );
SendSysMessage( mobile, "You start mining...", 3, 89 );
var x := mobile.x,
y := mobile.y;
while( AutoLoop( mobile ))
if( IsSwamp( info.landtile ))
tile := "clay";
mine_amount := HarvestResource( "clay", targ.x, targ.y, 1, 2, targ.realm );
if( !mine_amount )
SendSysMessage( mobile, "There's no clay left there." );
return 0;
endif
elseif( IsSand( info.landtile ))
tile := "sand";
mine_amount := HarvestResource( "sand", targ.x, targ.y, 1, 2, targ.realm );
if( !mine_amount )
SendSysMessage( mobile, "There's no sand left there." );
return 0;
endif
elseif( IsMinable( info.landtile, targ.objtype ))
tile := "ore";
mine_amount := HarvestResource( "ore", targ.x, targ.y, 1, 2, targ.realm );
if( !mine_amount )
SendSysMessage( mobile, "There's no ore left there." );
return 0;
endif
else
SendSysMessage( mobile, "You cannot mine or dig anything there." );
return 0;
endif
var delay := RandomInt( 4 ) + 2;
while( delay )
if( x != mobile.x || y != mobile.y || !shovel )
SendSysMessage( mobile, "You stop mining." );
return 0;
endif
Play_mining_effects( mobile, targ );
delay -= 1;
endwhile
var ore_amount := CInt( GetOreAmount( mobile, shovel ) * HARVEST_BONUS );
if( tile == "clay" )
if( SkillCheck( mobile, MINING, -1 ) > 0 )
var clay := CreateItemInBackpack( mobile, 0xee19, CInt( ore_amount ));
if( !clay )
SendSysMessage( mobile, "You fail to find any usable clay." );
else
SendSysMessage( mobile, "You put "+ore_amount+" blocks of clay in your backpack." );
endif
else
SendSysMessage( mobile, "You fail to find any usable clay." );
endif
elseif( tile == "sand" )
if( SkillCheck( mobile, MINING, -1 ) > 0 )
var clay := CreateItemInBackpack( mobile, 0xee18, CInt( ore_amount ));
if( !clay )
SendSysMessage( mobile, "You fail to find any usable sand." );
else
SendSysMessage( mobile, "You put "+ore_amount+" units of sand in your backpack." );
endif
else
SendSysMessage( mobile, "You fail to find any usable sand." );
endif
elseif( tile == "ore" )
GetRessource( mobile, ore_amount, shovel );
endif
CheckToolWear( mobile, shovel, MINING );
endwhile
EndAutoLoop( mobile );
SendSysMessage( mobile, "You stop mining...", 3, 89 );
return 1;
endprogram
function GetRessource( mobile, ore_amount, shovel )
var colored_chances := CInt( AP_GetSkill( mobile, MINING ) * ClasseBonus( mobile, CRAFTER )),
objtype;
if( RandomInt( 75 ) <= colored_chances )
objtype := GetOre( mobile );
else
objtype := 0x19B8;
ore_amount *= 2;
endif
if( SkillCheck( mobile, MINING, -1 ) > 0 )
createOres( mobile, objtype, ore_amount );
else
SpecialEffects( mobile, shovel );
endif
return 1;
endfunction
function createOres( mobile, objtype, amount )
var ores := CreateItemInBackpack( mobile, objtype, CInt( amount ));
if( !ores )
CreateItemAtLocation( mobile.x, mobile.y, mobile.z, objtype, CInt( amount ), mobile.realm );
endif
SendSysMessage( mobile, "You put "+CInt( amount )+" "+GetRessourceName( ores )+" in your backpack." );
return 1;
endfunction
function GetOre( mobile )
var cfg := ReadConfigFile( ":ores:itemdesc" );
if( cfg.errortext )
SendSysMessage( mobile, "Error reading config <:ores:itemdesc> -->"+cfg.errortext );
return 0;
endif
var the_keys := GetConfigStringKeys( cfg ),
possibles := array{};
foreach key in the_keys
var harvest := CInt( cfg[key].HarvestChance ),
difficulty := CInt( cfg[key].Difficulty );
if( !harvest )
//Skip sand definition in itemdesc
continue;
endif
if( RandomInt( 155 ) >= harvest )
if( SkillCheck( mobile, MINING, difficulty, 0, ADV_DISABLE ) > 0 )
possibles.Append( key );
endif
endif
SleepMS(5);
endforeach
return CInt( possibles.RandomEntry() );
endfunction
function GetOreAmount( mobile, shovel )
var skill := AP_GetSkill( mobile, MINING ),
max_amount := CInt( RandomDiceRoll( "1d"+CInt( skill / 40 )+"+1" ) * ClasseBonus( mobile, CRAFTER ));
var bonus := GetObjProperty( shovel, "MiningBonus" );
if( bonus )
max_amount *= bonus;
endif
if( !A_IsIn( mobile, AREAS_NO_DAMAGE ))
max_amount *= NO_DAMAGE_BONUS;
endif
if( max_amount < 1 )
max_amount := 1;
endif
return CInt( max_amount );
endfunction
function GetRessourceName( item )
var name := item.desc;
if( item.amount > 1 )
var i := Len( name ),
amount := item.amount,
count := 2;
while( CInt( amount / 10 ))
count += 1;
amount := CInt( amount / 10 );
SleepMS(5);
endwhile
name := name[count+1, i-count];
endif
return name;
endfunction
function SpecialEffects( mobile, shovel )
var bonus := CInt(( AP_GetSkill( mobile, MINING ) / 10 ) * ClasseBonus( mobile, CRAFTER ));
if( bonus < 1 )
bonus := 1;
endif
var chance := RandomInt( 100 ) + bonus;
var shovel_bonus := GetObjProperty( shovel, "MiningBonus" );
if( shovel_bonus )
chance += 5;
endif
var found := 0;
case( CInt( chance ))
30: CreateItemInBackpack( mobile, 0x14ED, 1 );
SendSysMessage( mobile, "You put TreasureMap in your backpack." );
found := 1;
break;
100: CreateItemInBackpack( mobile, 0x19eb, 10 );
SendSysMessage( mobile, "You find a piece of Exlusive ZULU ORE!" );
found := 1;
break;
102: CreateItemInBackpack( mobile, 0x19e8, 8 );
SendSysMessage( mobile, "You find a strange looking Blue Gem!" );
found := 1;
break;
104: CreateItemInBackpack( mobile, 0x19e9, 6 );
SendSysMessage( mobile, "You find a strange looking Red Gem!" );
found := 1;
break;
106: CreateItemInBackpack( mobile, 0x19ea, 4 );
SendSysMessage( mobile, "You find a strange looking White Gem!" );
found := 1;
break;
108: CreateItemInBackpack( mobile, 0x19ec, 2 );
SendSysMessage( mobile, "You find a glowing bright SPECIAL ORE!" );
found := 1;
break;
endcase
if( !found )
SendSysMessage( mobile, "You fail to find any usable ore." );
return 0;
endif
return 1;
endfunction
function Play_mining_effects( mobile, targ )
TurnObjectToward( mobile, targ.x, targ.y );
PerformAction( mobile, 0x0b );
SleepMS(500);
PlaySoundEffect( mobile, 0x0043 );
SleepMS( 1000 );
return 1;
endfunction
Excuse me, but I can not write in English. I use the google translator. I am Brazilian, only the Portuguese domino :/
Thank you for your attention.