Btw: vyskakujou ještě monstra při kopání nebo se to už zrušilo? :p
Kód: Vybrat vše
using System;
using System.Collections.Generic;
using System.Linq;
using Phoenix.WorldData;
namespace Phoenix.Scripts {
public class Mining {
private const ushort PickaxeGraphic = 0x0E85;
private const int MiningRadius = 2;
public Mining() {
ores = new List<OreInfo>() {
new OreInfo( "Iron", 0x0000, true, true ),
new OreInfo( "Copper", 0x0289, true, true ),
new OreInfo( "Bronze", 0x01BF, true, false ),
new OreInfo( "Silver", 0x0482, true, false ),
new OreInfo( "Shadow", 0x0322, true, false ),
new OreInfo( "Rose", 0x0665, true, true ),
new OreInfo( "Golden", 0x0160, true, false ),
new OreInfo( "Verite", 0x01CB, false, false ),
new OreInfo( "Valorite", 0x0253, false, false ),
new OreInfo( "Blood Rock", 0x04C2, false, false ),
new OreInfo( "Black Rock", 0x0455, false, false ),
new OreInfo( "Mytheril", 0x052D, false, false ),
new OreInfo( "Star Sapphire", 0x0006, false, false ),
new OreInfo( "Emerald", 0x0041, false, false ),
new OreInfo( "Citrine", 0x002C, false, false ),
new OreInfo( "Amethyst",0x0015, false, false ),
new OreInfo( "Ruby", 0x0027, false, false ),
new OreInfo( "Diamond", 0x03E9, false, false ),
};
}
private List<OreInfo> ores;
private bool DropOres() {
bool dropped = false;
foreach ( OreInfo ore in ores )
dropped |= ore.DropIfRequired();
return dropped;
}
[Executable( "mining" ), BlockMultipleExecutions( "mining" )]
public void Start() {
Start( true );
}
[Executable( "mining" ), BlockMultipleExecutions( "mining" )]
public void Start( bool hide ) {
int lastUse = 0;
for ( int x = -MiningRadius; x < MiningRadius; x++ ) {
for ( int y = -MiningRadius; y < MiningRadius; y++ ) {
UO.PrintInformation( "Mining at {0}, {1}", x, y );
do {
while ( !World.Player.Hidden && hide ) {
UO.PrintInformation( "Trying to hide" );
Journal.Clear();
UO.UseSkill( StandardSkill.Hiding );
Journal.WaitForText( "You can't seem to hide here.", "You have hidden yourself well" );
UO.Wait( 500 );
}
UOItem pickaxe = World.Player.Layers[ Layer.RightHand ];
if ( !pickaxe.Exist || pickaxe.Graphic != PickaxeGraphic ) {
pickaxe = World.Player.Backpack.AllItems.FindType( PickaxeGraphic );
if ( !pickaxe.Exist )
throw new ScriptErrorException( "No pickaxe found" );
}
Journal.Clear();
UO.WaitTargetTileRel( x, y, 0, 0 );
UO.Wait( Math.Max( 0, 3500 - ( Environment.TickCount - lastUse ) ) );
lastUse = Environment.TickCount;
pickaxe.Use();
Journal.WaitForText( "ore in your pack.", "ores in your pack.", "There is no ore here to mine.", "You loosen some rocks but fail to find any useable ore.", "Jeste nemuzes pouzit krumpac", "*You destroy pickaxe*" );
UO.Wait( 500 );
if ( DropOres() )
break;
if ( Journal.Contains( "Jeste nemuzes pouzit krumpac" ) )
UIManager.Reset();
} while ( !Journal.Contains( "There is no ore here to mine." ) );
}
}
UO.PrintInformation( "Mining finished" );
}
#region Nested type: OreInfo
private class OreInfo {
private const ushort OreMinGraphic = 0x19B7;
private const ushort OreMaxGraphic = 0x19BA;
public OreInfo( string name, UOColor color, bool drop, bool skip ) {
Name = name;
Color = color;
Drop = drop;
Skip = skip;
}
public IEnumerable<UOItem> Find( ItemsCollection list ) {
return from i in list
where i.Graphic >= OreMinGraphic && i.Graphic <= OreMaxGraphic && i.Color == Color
select i;
}
public bool DropIfRequired() {
if ( !Drop )
return false;
var items = Find( World.Player.Backpack.AllItems );
if ( items.Count() <= 0 )
return false;
foreach ( UOItem item in items ) {
UOItem pile = Find( World.Ground ).Where( i => i.Distance <= 1 ).FirstOrDefault();
if ( pile != null )
item.Move( item.Amount, pile );
else
item.DropHere();
}
return Skip;
}
#region Public properties
public string Name {
get;
private set;
}
public UOColor Color {
get;
private set;
}
public bool Drop {
get;
private set;
}
public bool Skip {
get;
private set;
}
#endregion
}
#endregion
}
}