#W# Some ore/smelting changes.
This commit is contained in:
parent
eb57f49200
commit
2240e623c7
1 changed files with 131 additions and 201 deletions
|
|
@ -20,19 +20,18 @@ namespace Server.Items
|
|||
|
||||
public abstract BaseIngot GetIngot();
|
||||
|
||||
public virtual int IngotsPerOre { get{ return 2; } }
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.Write( (int) 1 ); // version
|
||||
|
||||
writer.Write( (int) 1 );
|
||||
writer.Write( (int) m_Resource );
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch ( version )
|
||||
|
|
@ -45,7 +44,6 @@ namespace Server.Items
|
|||
case 0:
|
||||
{
|
||||
OreInfo info;
|
||||
|
||||
switch ( reader.ReadInt() )
|
||||
{
|
||||
case 0: info = OreInfo.Iron; break;
|
||||
|
|
@ -59,7 +57,6 @@ namespace Server.Items
|
|||
case 8: info = OreInfo.Valorite; break;
|
||||
default: info = null; break;
|
||||
}
|
||||
|
||||
m_Resource = CraftResources.GetFromOreInfo( info );
|
||||
break;
|
||||
}
|
||||
|
|
@ -69,16 +66,6 @@ namespace Server.Items
|
|||
private static int RandomSize()
|
||||
{
|
||||
return 0x19B9;
|
||||
/*double rand = Utility.RandomDouble();
|
||||
|
||||
if ( rand < 0.12 )
|
||||
return 0x19B7;
|
||||
else if ( rand < 0.18 )
|
||||
return 0x19B8;
|
||||
else if ( rand < 0.25 )
|
||||
return 0x19BA;
|
||||
else
|
||||
return 0x19B9;*/
|
||||
}
|
||||
|
||||
public BaseOre( CraftResource resource ) : this( resource, 1 )
|
||||
|
|
@ -101,9 +88,9 @@ namespace Server.Items
|
|||
public override void AddNameProperty( ObjectPropertyList list )
|
||||
{
|
||||
if ( Amount > 1 )
|
||||
list.Add( 1050039, "{0}\t#{1}", Amount, 1026583 ); // ~1_NUMBER~ ~2_ITEMNAME~
|
||||
list.Add( 1050039, "{0}\t#{1}", Amount, 1026583 );
|
||||
else
|
||||
list.Add( 1026583 ); // ore
|
||||
list.Add( 1026583 );
|
||||
}
|
||||
|
||||
public override void GetProperties( ObjectPropertyList list )
|
||||
|
|
@ -128,7 +115,7 @@ namespace Server.Items
|
|||
if ( m_Resource >= CraftResource.DullCopper && m_Resource <= CraftResource.Valorite )
|
||||
return 1042845 + (int)(m_Resource - CraftResource.DullCopper);
|
||||
|
||||
return 1042853; // iron ore;
|
||||
return 1042853;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -139,26 +126,110 @@ namespace Server.Items
|
|||
|
||||
if ( RootParent is BaseCreature )
|
||||
{
|
||||
from.SendLocalizedMessage( 500447 ); // That is not accessible
|
||||
from.SendLocalizedMessage( 500447 );
|
||||
}
|
||||
else if ( from.InRange( this.GetWorldLocation(), 2 ) )
|
||||
{
|
||||
from.SendLocalizedMessage( 501971 ); // Select the forge on which to smelt the ore, or another pile of ore with which to combine it.
|
||||
from.Target = new InternalTarget( this );
|
||||
from.SendLocalizedMessage( 501971 );
|
||||
|
||||
if ( Utility.RandomDouble() < 0.1 ) from.SendMessage("Target yourself to automatically choose a nearby target");
|
||||
|
||||
from.Target = new InternalTarget( this, from );
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage( 501976 ); // The ore is too far away.
|
||||
from.SendLocalizedMessage( 501976 );
|
||||
}
|
||||
}
|
||||
|
||||
public bool SmeltAll(Mobile from, object targeted)
|
||||
{
|
||||
if ( Deleted )
|
||||
return false;
|
||||
|
||||
double difficulty;
|
||||
switch ( m_Resource )
|
||||
{
|
||||
default: difficulty = 50.0; break;
|
||||
case CraftResource.DullCopper: difficulty = 65.0; break;
|
||||
case CraftResource.ShadowIron: difficulty = 70.0; break;
|
||||
case CraftResource.Copper: difficulty = 75.0; break;
|
||||
case CraftResource.Bronze: difficulty = 80.0; break;
|
||||
case CraftResource.Gold: difficulty = 85.0; break;
|
||||
case CraftResource.Agapite: difficulty = 90.0; break;
|
||||
case CraftResource.Verite: difficulty = 95.0; break;
|
||||
case CraftResource.Valorite: difficulty = 99.0; break;
|
||||
}
|
||||
|
||||
double minSkill = difficulty - 25.0;
|
||||
double maxSkill = difficulty + 25.0;
|
||||
|
||||
if (Resource == CraftResource.Iron)
|
||||
{
|
||||
minSkill = 0.0;
|
||||
maxSkill = 75.0;
|
||||
}
|
||||
|
||||
if (Resource == CraftResource.Iron)
|
||||
maxSkill = 65.0 + 10.0;
|
||||
|
||||
if ( difficulty > 50.0 && difficulty > from.Skills[SkillName.Mining].Value || from.Skills[SkillName.Mining].Value < minSkill)
|
||||
{
|
||||
from.SendLocalizedMessage( 501986 );
|
||||
return false;
|
||||
}
|
||||
|
||||
int lost = 0;
|
||||
int remaining = Amount;
|
||||
|
||||
while(0 < remaining)
|
||||
{
|
||||
if (maxSkill < from.Skills[SkillName.Mining].Value) break;
|
||||
|
||||
if (!from.CheckTargetSkill(SkillName.Mining, targeted, minSkill, maxSkill))
|
||||
lost++;
|
||||
|
||||
remaining--;
|
||||
}
|
||||
|
||||
from.PlaySound( 0x2B );
|
||||
|
||||
int ingots = Amount - lost;
|
||||
|
||||
if (0 < lost)
|
||||
{
|
||||
from.SendLocalizedMessage( 501990 ); // You burn away the impurities but are left with less useable metal.
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage( 501988 ); // You smelt the ore removing the impurities and put the metal in your backpack.
|
||||
}
|
||||
|
||||
if (0 < ingots)
|
||||
{
|
||||
BaseIngot ingot = GetIngot();
|
||||
Delete();
|
||||
|
||||
ingot.Amount = ingots * IngotsPerOre;
|
||||
from.AddToBackpack(ingot);
|
||||
}
|
||||
else
|
||||
{
|
||||
Delete();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private class InternalTarget : Target
|
||||
{
|
||||
private BaseOre m_Ore;
|
||||
private readonly BaseOre m_Ore;
|
||||
private readonly Mobile m_From;
|
||||
|
||||
public InternalTarget( BaseOre ore ) : base ( 2, false, TargetFlags.None )
|
||||
public InternalTarget( BaseOre ore, Mobile from ) : base ( 2, false, TargetFlags.None )
|
||||
{
|
||||
m_Ore = ore;
|
||||
m_From = from;
|
||||
}
|
||||
|
||||
private bool IsForge( object obj )
|
||||
|
|
@ -179,193 +250,52 @@ namespace Server.Items
|
|||
return ( itemID == 4017 || (itemID >= 6522 && itemID <= 6569) );
|
||||
}
|
||||
|
||||
private bool UseNearbyForge(Mobile from, int range)
|
||||
{
|
||||
if (from.Map == null) return false;
|
||||
|
||||
IPooledEnumerable eable = from.Map.GetItemsInRange(from.Location, range);
|
||||
foreach (Item item in eable)
|
||||
{
|
||||
if (IsForge(item))
|
||||
{
|
||||
eable.Free();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
eable.Free();
|
||||
|
||||
for (int x = -range; x <= range; ++x)
|
||||
{
|
||||
for (int y = -range; y <= range; ++y)
|
||||
{
|
||||
Server.StaticTile[] tiles = from.Map.Tiles.GetStaticTiles(from.X + x, from.Y + y, true);
|
||||
for (int i = 0; i < tiles.Length; ++i)
|
||||
{
|
||||
int id = tiles[i].ID & 0x3FFF;
|
||||
if (id == 4017 || (id >= 6522 && id <= 6569))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override void OnTarget( Mobile from, object targeted )
|
||||
{
|
||||
if ( m_Ore.Deleted )
|
||||
return;
|
||||
|
||||
if ( !from.InRange( m_Ore.GetWorldLocation(), 2 ) )
|
||||
{
|
||||
from.SendLocalizedMessage( 501976 ); // The ore is too far away.
|
||||
return;
|
||||
}
|
||||
|
||||
#region Combine Ore
|
||||
if ( targeted is BaseOre )
|
||||
|
||||
if ( !IsForge( targeted ) && false == ( targeted == m_From && UseNearbyForge( from, Range ) ) )
|
||||
{
|
||||
BaseOre ore = (BaseOre)targeted;
|
||||
|
||||
if ( !ore.Movable )
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if ( m_Ore == ore )
|
||||
{
|
||||
from.SendLocalizedMessage( 501972 ); // Select another pile or ore with which to combine this.
|
||||
from.Target = new InternalTarget( ore );
|
||||
return;
|
||||
}
|
||||
else if ( ore.Resource != m_Ore.Resource )
|
||||
{
|
||||
from.SendLocalizedMessage( 501979 ); // You cannot combine ores of different metals.
|
||||
return;
|
||||
}
|
||||
|
||||
int worth = ore.Amount;
|
||||
|
||||
if ( ore.ItemID == 0x19B9 )
|
||||
worth *= 8;
|
||||
else if ( ore.ItemID == 0x19B7 )
|
||||
worth *= 2;
|
||||
else
|
||||
worth *= 4;
|
||||
|
||||
int sourceWorth = m_Ore.Amount;
|
||||
|
||||
if ( m_Ore.ItemID == 0x19B9 )
|
||||
sourceWorth *= 8;
|
||||
else if ( m_Ore.ItemID == 0x19B7 )
|
||||
sourceWorth *= 2;
|
||||
else
|
||||
sourceWorth *= 4;
|
||||
|
||||
worth += sourceWorth;
|
||||
|
||||
int plusWeight = 0;
|
||||
int newID = ore.ItemID;
|
||||
|
||||
if ( ore.DefaultWeight != m_Ore.DefaultWeight )
|
||||
{
|
||||
if ( ore.ItemID == 0x19B7 || m_Ore.ItemID == 0x19B7 )
|
||||
{
|
||||
newID = 0x19B7;
|
||||
}
|
||||
else if ( ore.ItemID == 0x19B9 )
|
||||
{
|
||||
newID = m_Ore.ItemID;
|
||||
plusWeight = ore.Amount * 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
plusWeight = m_Ore.Amount * 2;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ( ore.ItemID == 0x19B9 && worth > 120000 ) || ( ( ore.ItemID == 0x19B8 || ore.ItemID == 0x19BA ) && worth > 60000 ) || ( ore.ItemID == 0x19B7 && worth > 30000 ) )
|
||||
{
|
||||
from.SendLocalizedMessage( 1062844 ); // There is too much ore to combine.
|
||||
return;
|
||||
}
|
||||
else if ( ore.RootParent is Mobile && ( plusWeight + ((Mobile)ore.RootParent).Backpack.TotalWeight ) > ((Mobile)ore.RootParent).Backpack.MaxWeight )
|
||||
{
|
||||
from.SendLocalizedMessage( 501978 ); // The weight is too great to combine in a container.
|
||||
return;
|
||||
}
|
||||
|
||||
ore.ItemID = newID;
|
||||
|
||||
if ( ore.ItemID == 0x19B9 )
|
||||
ore.Amount = worth / 8;
|
||||
else if ( ore.ItemID == 0x19B7 )
|
||||
ore.Amount = worth / 2;
|
||||
else
|
||||
ore.Amount = worth / 4;
|
||||
|
||||
m_Ore.Delete();
|
||||
from.SendMessage("That is not a forge.");
|
||||
return;
|
||||
}
|
||||
#endregion
|
||||
|
||||
if ( IsForge( targeted ) )
|
||||
{
|
||||
double difficulty;
|
||||
|
||||
switch ( m_Ore.Resource )
|
||||
{
|
||||
default: difficulty = 50.0; break;
|
||||
case CraftResource.DullCopper: difficulty = 65.0; break;
|
||||
case CraftResource.ShadowIron: difficulty = 70.0; break;
|
||||
case CraftResource.Copper: difficulty = 75.0; break;
|
||||
case CraftResource.Bronze: difficulty = 80.0; break;
|
||||
case CraftResource.Gold: difficulty = 85.0; break;
|
||||
case CraftResource.Agapite: difficulty = 90.0; break;
|
||||
case CraftResource.Verite: difficulty = 95.0; break;
|
||||
case CraftResource.Valorite: difficulty = 99.0; break;
|
||||
}
|
||||
|
||||
double minSkill = difficulty - 25.0;
|
||||
double maxSkill = difficulty + 25.0;
|
||||
|
||||
if ( difficulty > 50.0 && difficulty > from.Skills[SkillName.Mining].Value )
|
||||
{
|
||||
from.SendLocalizedMessage( 501986 ); // You have no idea how to smelt this strange ore!
|
||||
return;
|
||||
}
|
||||
|
||||
if ( m_Ore.ItemID == 0x19B7 && m_Ore.Amount < 2 )
|
||||
{
|
||||
from.SendLocalizedMessage( 501987 ); // There is not enough metal-bearing ore in this pile to make an ingot.
|
||||
return;
|
||||
}
|
||||
|
||||
if ( from.CheckTargetSkill( SkillName.Mining, targeted, minSkill, maxSkill ) )
|
||||
{
|
||||
int toConsume = m_Ore.Amount;
|
||||
|
||||
if ( toConsume <= 0 )
|
||||
{
|
||||
from.SendLocalizedMessage( 501987 ); // There is not enough metal-bearing ore in this pile to make an ingot.
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( toConsume > 30000 )
|
||||
toConsume = 30000;
|
||||
|
||||
int ingotAmount;
|
||||
|
||||
if ( m_Ore.ItemID == 0x19B7 )
|
||||
{
|
||||
ingotAmount = toConsume / 2;
|
||||
|
||||
if ( toConsume % 2 != 0 )
|
||||
--toConsume;
|
||||
}
|
||||
else if ( m_Ore.ItemID == 0x19B9 )
|
||||
{
|
||||
ingotAmount = toConsume * 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
ingotAmount = toConsume;
|
||||
}
|
||||
|
||||
BaseIngot ingot = m_Ore.GetIngot();
|
||||
ingot.Amount = ingotAmount;
|
||||
|
||||
m_Ore.Consume( toConsume );
|
||||
from.AddToBackpack( ingot );
|
||||
//from.PlaySound( 0x57 );
|
||||
|
||||
from.SendLocalizedMessage( 501988 ); // You smelt the ore removing the impurities and put the metal in your backpack.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( m_Ore.Amount < 2 )
|
||||
{
|
||||
if ( m_Ore.ItemID == 0x19B9 )
|
||||
m_Ore.ItemID = 0x19B8;
|
||||
else
|
||||
m_Ore.ItemID = 0x19B7;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Ore.Amount /= 2;
|
||||
}
|
||||
|
||||
from.SendLocalizedMessage( 501990 ); // You burn away the impurities but are left with less useable metal.
|
||||
}
|
||||
}
|
||||
m_Ore.SmeltAll(from, targeted);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue