From 3f4a2c4dc897de7324e45c0cf4ad2b7d6314aeba Mon Sep 17 00:00:00 2001 From: eos Date: Sun, 29 Jul 2012 02:41:00 +0000 Subject: [PATCH] - Ore bought from faction ore vendors is no longer randomly sized. - Ore is no longer a deedable commodity. - Added StaffOnly condition to ConditionTeleporter. - Account/IAccount now compares greater than null. - General BaseOre cleanup. - Fixed BaseOre smelting bug where any ore over 30k would be discarded. - Added a 2 tile range check to FishingPole OnDoubleClick. - Removed redundant checks from BaseAxe OnDoubleClick. - General SkillCheck cleanup. - Fixed a typo in SkillMod. - Added CommandProperty to Mobile NetState. - Implemented IComparable for NetState. --- Scripts/Accounting/Account.cs | 4 +- .../Mobiles/Vendors/FactionOreVendor.cs | 4 +- Scripts/Items/Deeds/CommodityDeed.cs | 47 +++-- Scripts/Items/Misc/Teleporter.cs | 16 +- Scripts/Items/Resources/Blacksmithing/Ore.cs | 160 ++++++++---------- .../Items/Skill Items/Fishing/FishingPole.cs | 8 +- Scripts/Items/Weapons/Axes/BaseAxe.cs | 15 +- Scripts/Misc/SkillCheck.cs | 5 +- Server/Mobile.cs | 3 +- Server/Network/NetState.cs | 9 +- 10 files changed, 148 insertions(+), 123 deletions(-) diff --git a/Scripts/Accounting/Account.cs b/Scripts/Accounting/Account.cs index 57d5c6055..90a905879 100644 --- a/Scripts/Accounting/Account.cs +++ b/Scripts/Accounting/Account.cs @@ -1186,7 +1186,7 @@ namespace Server.Accounting public int CompareTo( Account other ) { if ( other == null ) - return -1; + return 1; return m_Username.CompareTo( other.m_Username ); } @@ -1194,7 +1194,7 @@ namespace Server.Accounting public int CompareTo( IAccount other ) { if ( other == null ) - return -1; + return 1; return m_Username.CompareTo( other.Username ); } diff --git a/Scripts/Engines/Factions/Mobiles/Vendors/FactionOreVendor.cs b/Scripts/Engines/Factions/Mobiles/Vendors/FactionOreVendor.cs index e76b93742..a9d67fa3e 100644 --- a/Scripts/Engines/Factions/Mobiles/Vendors/FactionOreVendor.cs +++ b/Scripts/Engines/Factions/Mobiles/Vendors/FactionOreVendor.cs @@ -48,6 +48,8 @@ namespace Server.Factions public class SBFactionOre : SBInfo { + private static readonly object[] m_FixedSizeArgs = { true }; + private List m_BuyInfo = new InternalBuyInfo(); private IShopSellInfo m_SellInfo = new InternalSellInfo(); @@ -63,7 +65,7 @@ namespace Server.Factions public InternalBuyInfo() { for ( int i = 0; i < 5; ++i ) - Add( new GenericBuyInfo( typeof( IronOre ), 16, 20, 0x19B8, 0 ) ); + Add( new GenericBuyInfo( typeof( IronOre ), 16, 20, 0x19B8, 0, m_FixedSizeArgs ) ); } } diff --git a/Scripts/Items/Deeds/CommodityDeed.cs b/Scripts/Items/Deeds/CommodityDeed.cs index e574b1bd1..6a4f019cd 100644 --- a/Scripts/Items/Deeds/CommodityDeed.cs +++ b/Scripts/Items/Deeds/CommodityDeed.cs @@ -69,11 +69,6 @@ namespace Server.Items break; } } - - if ( m_Commodity != null && !( m_Commodity is ICommodity ) ) //Apparently, there may be items out there with this. Funky. - { - Timer.DelayCall( TimeSpan.Zero, this.Delete ); - } } public CommodityDeed( Item commodity ) : base( 0x14F0 ) @@ -109,32 +104,56 @@ namespace Server.Items { base.GetProperties( list ); - if (m_Commodity != null && m_Commodity is ICommodity) + if ( m_Commodity != null ) { - list.Add(1060658, "#{0}\t{1}", ((ICommodity)m_Commodity).DescriptionNumber, m_Commodity.Amount); // ~1_val~: ~2_val~ + string args; + + if ( m_Commodity.Name == null ) + args = String.Format( "#{0}\t{1}", ( m_Commodity is ICommodity ) ? ((ICommodity)m_Commodity).DescriptionNumber : m_Commodity.LabelNumber, m_Commodity.Amount ); + else + args = String.Format( "{0}\t{1}", m_Commodity.Name, m_Commodity.Amount ); + + list.Add( 1060658, args ); // ~1_val~: ~2_val~ } else - list.Add(1060748); // unfilled + { + list.Add( 1060748 ); // unfilled + } } public override void OnSingleClick( Mobile from ) { base.OnSingleClick( from ); - if ( m_Commodity != null && m_Commodity is ICommodity ) + if ( m_Commodity != null ) + { + int label; + string labelString; - from.Send(new MessageLocalizedAffix( + if ( m_Commodity.Name == null ) + { + label = ( m_Commodity is ICommodity ) ? ((ICommodity)m_Commodity).DescriptionNumber : m_Commodity.LabelNumber; + labelString = null; + } + else + { + label = 0; + labelString = m_Commodity.Name; + } + + from.Send( new MessageLocalizedAffix( Serial, ItemID, MessageType.Label, 0x3B2, 3, - (m_Commodity.Name == null) ? ((ICommodity)m_Commodity).DescriptionNumber : 0, - (m_Commodity.Name != null) ? m_Commodity.Name : null, + label, + labelString, AffixType.Append, - String.Format(": {0}", m_Commodity.Amount), - null) + String.Format( ": {0}", m_Commodity.Amount ), + null ) ); + } } public override void OnDoubleClick( Mobile from ) diff --git a/Scripts/Items/Misc/Teleporter.cs b/Scripts/Items/Misc/Teleporter.cs index 8d14519ae..530621d33 100644 --- a/Scripts/Items/Misc/Teleporter.cs +++ b/Scripts/Items/Misc/Teleporter.cs @@ -909,7 +909,8 @@ namespace Server.Items DenyPackContents = 0x04, DenyHolding = 0x08, DenyEquipment = 0x10, - DenyTransformed = 0x20 + DenyTransformed = 0x20, + StaffOnly = 0x40 } private ConditionFlag m_Flags; @@ -956,11 +957,21 @@ namespace Server.Items set{ SetFlag( ConditionFlag.DenyTransformed, value ); InvalidateProperties(); } } + [CommandProperty( AccessLevel.GameMaster )] + public bool StaffOnly + { + get{ return GetFlag( ConditionFlag.StaffOnly ); } + set{ SetFlag( ConditionFlag.StaffOnly, value ); InvalidateProperties(); } + } + public override bool CanTeleport( Mobile m ) { if ( !base.CanTeleport( m ) ) return false; + if ( GetFlag( ConditionFlag.StaffOnly ) && m.AccessLevel < AccessLevel.Counselor ) + return false; + if ( GetFlag( ConditionFlag.DenyMounted ) && m.Mounted ) { m.SendLocalizedMessage( 1077252 ); // You must dismount before proceeding. @@ -1048,6 +1059,9 @@ namespace Server.Items if ( GetFlag( ConditionFlag.DenyTransformed ) ) props.Append( "
Deny Transformed" ); + if ( GetFlag( ConditionFlag.StaffOnly ) ) + props.Append( "
Staff Only" ); + if ( props.Length != 0 ) { props.Remove( 0, 4 ); diff --git a/Scripts/Items/Resources/Blacksmithing/Ore.cs b/Scripts/Items/Resources/Blacksmithing/Ore.cs index e7d9c197e..fda62e630 100644 --- a/Scripts/Items/Resources/Blacksmithing/Ore.cs +++ b/Scripts/Items/Resources/Blacksmithing/Ore.cs @@ -7,7 +7,7 @@ using Server.Mobiles; namespace Server.Items { - public abstract class BaseOre : Item, ICommodity + public abstract class BaseOre : Item { private CraftResource m_Resource; @@ -18,9 +18,6 @@ namespace Server.Items set{ m_Resource = value; InvalidateProperties(); } } - int ICommodity.DescriptionNumber { get { return LabelNumber; } } - bool ICommodity.IsDeedable { get { return true; } } - public abstract BaseIngot GetIngot(); public override void Serialize( GenericWriter writer ) @@ -69,24 +66,26 @@ namespace Server.Items } } + private static int RandomSize() + { + 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 ) { } - public BaseOre( CraftResource resource, int amount ) : base( Utility.Random( 4 ) ) + public BaseOre( CraftResource resource, int amount ) : base( RandomSize() ) { - { - double random = Utility.RandomDouble(); - if ( 0.12 >= random ) - ItemID = 0x19B7; - else if ( 0.18 >= random ) - ItemID = 0x19B8; - else if ( 0.25 >= random ) - ItemID = 0x19BA; - else - ItemID = 0x19B9; - } - Stackable = true; Amount = amount; Hue = CraftResources.GetHue( resource ); @@ -136,11 +135,10 @@ namespace Server.Items { if ( !Movable ) return; - + if ( RootParent is BaseCreature ) { from.SendLocalizedMessage( 500447 ); // That is not accessible - return; } else if ( from.InRange( this.GetWorldLocation(), 2 ) ) { @@ -190,13 +188,16 @@ namespace Server.Items from.SendLocalizedMessage( 501976 ); // The ore is too far away. return; } - + #region Combine Ore if ( targeted is BaseOre ) { 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. @@ -210,23 +211,28 @@ namespace Server.Items } int worth = ore.Amount; + if ( ore.ItemID == 0x19B9 ) worth *= 8; else if ( ore.ItemID == 0x19B7 ) worth *= 2; - else + 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 ) @@ -244,33 +250,27 @@ namespace Server.Items } } - if ( (ore.ItemID == 0x19B9 && worth > 120000) || (( ore.ItemID == 0x19B8 || ore.ItemID == 0x19BA ) && worth > 60000) || (ore.ItemID == 0x19B7 && worth > 30000)) + 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 ) - { + 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; - m_Ore.Delete(); - } else if ( ore.ItemID == 0x19B7 ) - { ore.Amount = worth / 2; - m_Ore.Delete(); - } else - { ore.Amount = worth / 4; - m_Ore.Delete(); - } + + m_Ore.Delete(); return; } #endregion @@ -294,14 +294,14 @@ namespace Server.Items 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.Amount <= 1 && m_Ore.ItemID == 0x19B7 ) + + 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; @@ -309,66 +309,60 @@ namespace Server.Items if ( from.CheckTargetSkill( SkillName.Mining, targeted, minSkill, maxSkill ) ) { - if ( m_Ore.Amount <= 0 ) + 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 { - int amount = m_Ore.Amount; - if ( m_Ore.Amount > 30000 ) - amount = 30000; + if ( toConsume > 30000 ) + toConsume = 30000; + + int ingotAmount; - BaseIngot ingot = m_Ore.GetIngot(); - if ( m_Ore.ItemID == 0x19B7 ) { - if ( m_Ore.Amount % 2 == 0 ) - { - amount /= 2; - m_Ore.Delete(); - } - else - { - amount /= 2; - m_Ore.Amount = 1; - } + ingotAmount = toConsume / 2; + + if ( toConsume % 2 != 0 ) + --toConsume; } - else if ( m_Ore.ItemID == 0x19B9 ) { - amount *= 2; - m_Ore.Delete(); + ingotAmount = toConsume * 2; } - else { - amount /= 1; - m_Ore.Delete(); + ingotAmount = toConsume; } - ingot.Amount = amount; + 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 && m_Ore.ItemID == 0x19B9 ) - { - from.SendLocalizedMessage( 501990 ); // You burn away the impurities but are left with less useable metal. - m_Ore.ItemID = 0x19B8; - } - else if ( m_Ore.Amount < 2 && m_Ore.ItemID == 0x19B8 || m_Ore.ItemID == 0x19BA ) - { - from.SendLocalizedMessage( 501990 ); // You burn away the impurities but are left with less useable metal. - m_Ore.ItemID = 0x19B7; - } 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.Amount /= 2; } } } @@ -387,6 +381,12 @@ namespace Server.Items { } + public IronOre( bool fixedSize ) : this( 1 ) + { + if ( fixedSize ) + ItemID = 0x19B8; + } + public IronOre( Serial serial ) : base( serial ) { } @@ -405,8 +405,6 @@ namespace Server.Items int version = reader.ReadInt(); } - - public override BaseIngot GetIngot() { return new IronIngot(); @@ -443,8 +441,6 @@ namespace Server.Items int version = reader.ReadInt(); } - - public override BaseIngot GetIngot() { return new DullCopperIngot(); @@ -481,8 +477,6 @@ namespace Server.Items int version = reader.ReadInt(); } - - public override BaseIngot GetIngot() { return new ShadowIronIngot(); @@ -519,8 +513,6 @@ namespace Server.Items int version = reader.ReadInt(); } - - public override BaseIngot GetIngot() { return new CopperIngot(); @@ -557,8 +549,6 @@ namespace Server.Items int version = reader.ReadInt(); } - - public override BaseIngot GetIngot() { return new BronzeIngot(); @@ -595,8 +585,6 @@ namespace Server.Items int version = reader.ReadInt(); } - - public override BaseIngot GetIngot() { return new GoldIngot(); @@ -633,8 +621,6 @@ namespace Server.Items int version = reader.ReadInt(); } - - public override BaseIngot GetIngot() { return new AgapiteIngot(); @@ -671,8 +657,6 @@ namespace Server.Items int version = reader.ReadInt(); } - - public override BaseIngot GetIngot() { return new VeriteIngot(); @@ -709,8 +693,6 @@ namespace Server.Items int version = reader.ReadInt(); } - - public override BaseIngot GetIngot() { return new ValoriteIngot(); diff --git a/Scripts/Items/Skill Items/Fishing/FishingPole.cs b/Scripts/Items/Skill Items/Fishing/FishingPole.cs index 779312206..ad4eabb30 100644 --- a/Scripts/Items/Skill Items/Fishing/FishingPole.cs +++ b/Scripts/Items/Skill Items/Fishing/FishingPole.cs @@ -5,6 +5,7 @@ using Server.Items; using Server.Engines.Harvest; using System.Collections.Generic; using Server.ContextMenus; +using Server.Network; namespace Server.Items { @@ -19,7 +20,12 @@ namespace Server.Items public override void OnDoubleClick( Mobile from ) { - Fishing.System.BeginHarvesting( from, this ); + Point3D loc = GetWorldLocation(); + + if ( !from.InLOS( loc ) || !from.InRange( loc, 2 ) ) + from.LocalOverheadMessage( MessageType.Regular, 0x3E9, 1019045 ); // I can't reach that + else + Fishing.System.BeginHarvesting( from, this ); } public override void GetContextMenuEntries( Mobile from, List list ) diff --git a/Scripts/Items/Weapons/Axes/BaseAxe.cs b/Scripts/Items/Weapons/Axes/BaseAxe.cs index ed42495da..fd546cc4e 100644 --- a/Scripts/Items/Weapons/Axes/BaseAxe.cs +++ b/Scripts/Items/Weapons/Axes/BaseAxe.cs @@ -80,25 +80,20 @@ namespace Server.Items public override void OnDoubleClick( Mobile from ) { - if ( HarvestSystem == null || Deleted ) + if ( HarvestSystem == null ) return; - Point3D loc = this.GetWorldLocation(); + Point3D loc = GetWorldLocation(); if ( !from.InLOS( loc ) || !from.InRange( loc, 2 ) ) { from.LocalOverheadMessage( Server.Network.MessageType.Regular, 0x3E9, 1019045 ); // I can't reach that return; } - else if ( !this.IsAccessibleTo( from ) ) - { - this.PublicOverheadMessage( Server.Network.MessageType.Regular, 0x3E9, 1061637 ); // You are not allowed to access this. - return; - } - - if ( !(this.HarvestSystem is Mining) ) + + if ( !( HarvestSystem is Mining ) ) from.SendLocalizedMessage( 1010018 ); // What do you want to use this item on? - + HarvestSystem.BeginHarvesting( from, this ); } diff --git a/Scripts/Misc/SkillCheck.cs b/Scripts/Misc/SkillCheck.cs index cf10ed556..f9f5733b1 100644 --- a/Scripts/Misc/SkillCheck.cs +++ b/Scripts/Misc/SkillCheck.cs @@ -228,10 +228,9 @@ namespace Server.Misc #region Scroll of Alacrity PlayerMobile pm = from as PlayerMobile; - if ( from is PlayerMobile ) - if (pm != null && skill.SkillName == pm.AcceleratedSkill && pm.AcceleratedStart > DateTime.Now) + if ( pm != null && skill.SkillName == pm.AcceleratedSkill && pm.AcceleratedStart > DateTime.Now ) toGain *= Utility.RandomMinMax(2, 5); - #endregion + #endregion if ( !from.Player || (skills.Total + toGain) <= skills.Cap ) { diff --git a/Server/Mobile.cs b/Server/Mobile.cs index 9ac65a5a2..55be2af46 100644 --- a/Server/Mobile.cs +++ b/Server/Mobile.cs @@ -170,7 +170,7 @@ namespace Server { if( m_Skill != value ) { - Skill oldUpdate = (m_Owner == null ? m_Owner.Skills[m_Skill] : null); + Skill oldUpdate = (m_Owner != null ? m_Owner.Skills[m_Skill] : null); m_Skill = value; @@ -8009,6 +8009,7 @@ namespace Server { } + [CommandProperty( AccessLevel.GameMaster, AccessLevel.Owner )] public NetState NetState { get diff --git a/Server/Network/NetState.cs b/Server/Network/NetState.cs index 6b48b15e2..1679c0a0b 100644 --- a/Server/Network/NetState.cs +++ b/Server/Network/NetState.cs @@ -42,7 +42,7 @@ namespace Server.Network { public delegate void NetStateCreatedCallback( NetState ns ); - public class NetState { + public class NetState : IComparable { private Socket m_Socket; private IPAddress m_Address; private ByteQueue m_Buffer; @@ -1223,5 +1223,12 @@ namespace Server.Network { public bool SupportsExpansion( ExpansionInfo info ) { return SupportsExpansion( info, true ); } + + public int CompareTo( NetState other ) { + if ( other == null ) + return 1; + + return m_ToString.CompareTo( other.m_ToString ); + } } } \ No newline at end of file