From 71e80d59494cec3a4e6e32a899640b74156ae4e9 Mon Sep 17 00:00:00 2001 From: asayre Date: Wed, 30 Aug 2006 03:24:57 +0000 Subject: [PATCH] --- Scripts/Engines/AI/AI/BaseAI.cs | 17 +++--- Scripts/Engines/AI/Creature/BaseCreature.cs | 14 +++-- Scripts/Engines/Craft/Core/Enhance.cs | 4 +- Scripts/Items/Misc/FlipableAttribute.cs | 36 ++++++------ Scripts/Items/Resources/MiscMLResources.cs | 7 ++- .../Items/Skill Items/Fishing/FishingPole.cs | 5 ++ .../Musical Instruments/BaseInstrument.cs | 2 +- Scripts/Items/Weapons/BaseWeapon.cs | 58 +------------------ Scripts/Misc/Guild.cs | 3 +- Scripts/Mobiles/Animals/Mounts/LesserHiryu.cs | 8 ++- Scripts/Mobiles/Animals/Mounts/Ridgeback.cs | 2 +- .../Mobiles/Animals/Mounts/SavageRidgeback.cs | 2 +- .../Animals/Mounts/ScaledSwampDragon.cs | 2 +- Scripts/Mobiles/Animals/Mounts/SwampDragon.cs | 2 +- Scripts/Mobiles/Monsters/SE/FireBeetle.cs | 2 +- Scripts/Spells/Ninjitsu/MirrorImage.cs | 2 + 16 files changed, 63 insertions(+), 103 deletions(-) diff --git a/Scripts/Engines/AI/AI/BaseAI.cs b/Scripts/Engines/AI/AI/BaseAI.cs index 1af317c5a..fa15a25c4 100644 --- a/Scripts/Engines/AI/AI/BaseAI.cs +++ b/Scripts/Engines/AI/AI/BaseAI.cs @@ -2642,22 +2642,23 @@ namespace Server.Mobiles m_Timer.Start(); } + private DateTime m_NextDetectHidden; + + public virtual bool CanDetectHidden { get { return m_Mobile.Skills[SkillName.DetectHidden].Value > 0; } } + /* * The Timer object */ private class AITimer : Timer { private BaseAI m_Owner; - private DateTime m_NextDetectHidden; - private bool m_bDetectHidden; public AITimer( BaseAI owner ) : base( TimeSpan.FromSeconds( Utility.RandomDouble() ), TimeSpan.FromSeconds( Math.Max( 0.0, owner.m_Mobile.CurrentSpeed ) ) ) { m_Owner = owner; - m_bDetectHidden = false; - m_NextDetectHidden = DateTime.Now; + m_Owner.m_NextDetectHidden = DateTime.Now; Priority = TimerPriority.FiftyMS; } @@ -2723,7 +2724,7 @@ namespace Server.Mobiles } } - if( m_bDetectHidden && DateTime.Now > m_NextDetectHidden ) + if( m_Owner.CanDetectHidden && DateTime.Now > m_Owner.m_NextDetectHidden ) { m_Owner.DetectHidden(); @@ -2736,11 +2737,7 @@ namespace Server.Mobiles int min = delay * (9 / 10); // 13s at 1000 int, 33s at 400 int, 54s at <250 int int max = delay * (10 / 9); // 16s at 1000 int, 41s at 400 int, 66s at <250 int - m_NextDetectHidden = DateTime.Now + TimeSpan.FromSeconds( Utility.RandomMinMax( min, max ) ); - } - else - { - m_bDetectHidden = m_Owner.m_Mobile.Skills[SkillName.DetectHidden].Value > 0; + m_Owner.m_NextDetectHidden = DateTime.Now + TimeSpan.FromSeconds( Utility.RandomMinMax( min, max ) ); } } } diff --git a/Scripts/Engines/AI/Creature/BaseCreature.cs b/Scripts/Engines/AI/Creature/BaseCreature.cs index eeabb27f2..ea7f6b6ab 100644 --- a/Scripts/Engines/AI/Creature/BaseCreature.cs +++ b/Scripts/Engines/AI/Creature/BaseCreature.cs @@ -800,7 +800,12 @@ namespace Server.Mobiles return ( GetControlChance( m ) > 0.0 ); } - public virtual double GetControlChance( Mobile m ) + public double GetControlChance( Mobile m ) + { + return GetControlChance( m, false ); + } + + public virtual double GetControlChance( Mobile m, bool useBaseSkill ) { if ( m_dMinTameSkill <= 29.1 || m_bSummoned || m.AccessLevel >= AccessLevel.GameMaster ) return 1.0; @@ -810,8 +815,9 @@ namespace Server.Mobiles if ( dMinTameSkill > -24.9 && Server.SkillHandlers.AnimalTaming.CheckMastery( m, this ) ) dMinTameSkill = -24.9; - int taming = (int)(m.Skills[SkillName.AnimalTaming].Value * 10); - int lore = (int)(m.Skills[SkillName.AnimalLore].Value * 10); + int taming = (int)((useBaseSkill ? m.Skills[SkillName.AnimalTaming].Base : m.Skills[SkillName.AnimalTaming].Value ) * 10); + int lore = (int)((useBaseSkill ? m.Skills[SkillName.AnimalLore].Base : m.Skills[SkillName.AnimalLore].Value )* 10); + int difficulty = (int)(dMinTameSkill * 10); int weighted = ((taming * 4) + lore) / 5; int bonus = weighted - difficulty; @@ -1876,7 +1882,7 @@ namespace Server.Mobiles if ( master != null && master == from ) //So friends can't start the bonding process { - if ( m_dMinTameSkill <= 29.1 || master.Skills[SkillName.AnimalTaming].Value >= m_dMinTameSkill || GetControlChance( master ) >= 1.0 ) + if ( m_dMinTameSkill <= 29.1 || master.Skills[SkillName.AnimalTaming].Base >= m_dMinTameSkill || GetControlChance( master, true ) >= 1.0 ) { if ( BondingBegin == DateTime.MinValue ) { diff --git a/Scripts/Engines/Craft/Core/Enhance.cs b/Scripts/Engines/Craft/Core/Enhance.cs index f3a895488..555ab44bc 100644 --- a/Scripts/Engines/Craft/Core/Enhance.cs +++ b/Scripts/Engines/Craft/Core/Enhance.cs @@ -39,10 +39,8 @@ namespace Server.Engines.Craft if ( craftItem == null || craftItem.Ressources.Count == 0 ) return EnhanceResult.BadItem; - int quality = 0; bool allRequiredSkills = false; - - if ( !craftItem.CheckSkills( from, resType, craftSystem, ref quality, ref allRequiredSkills, false ) ) + if( craftItem.GetSuccessChance( from, resType, craftSystem, false, ref allRequiredSkills ) <= 0.0 ) return EnhanceResult.NoSkill; CraftResourceInfo info = CraftResources.GetInfo( resource ); diff --git a/Scripts/Items/Misc/FlipableAttribute.cs b/Scripts/Items/Misc/FlipableAttribute.cs index 1200d8d5e..adac01da5 100644 --- a/Scripts/Items/Misc/FlipableAttribute.cs +++ b/Scripts/Items/Misc/FlipableAttribute.cs @@ -22,31 +22,32 @@ namespace Server.Items private class FlipTarget : Target { - public FlipTarget() : base( -1, false, TargetFlags.None ) + public FlipTarget() + : base( -1, false, TargetFlags.None ) { } protected override void OnTarget( Mobile from, object targeted ) { - if ( targeted is Item ) + if( targeted is Item ) { Item item = (Item)targeted; - if ( item.Movable == false && from.AccessLevel == AccessLevel.Player ) + if( item.Movable == false && from.AccessLevel == AccessLevel.Player ) return; - Type type = targeted.GetType(); + Type type = targeted.GetType(); + + FlipableAttribute[] AttributeArray = (FlipableAttribute[])type.GetCustomAttributes( typeof( FlipableAttribute ), false ); - FlipableAttribute [] AttributeArray = (FlipableAttribute []) type.GetCustomAttributes(typeof(FlipableAttribute), false); - if( AttributeArray.Length == 0 ) { - return ; + return; } FlipableAttribute fa = AttributeArray[0]; - fa.Flip( (Item)targeted); + fa.Flip( (Item)targeted ); } } } @@ -67,13 +68,14 @@ namespace Server.Items public int[] ItemIDs { - get{ return m_ItemIDs; } + get { return m_ItemIDs; } } - public FlipableAttribute() : this ( null ) + public FlipableAttribute() + : this( null ) { } - + public FlipableAttribute( params int[] itemIDs ) { m_ItemIDs = itemIDs; @@ -81,12 +83,12 @@ namespace Server.Items public virtual void Flip( Item item ) { - if ( m_ItemIDs == null ) + if( m_ItemIDs == null ) { try { MethodInfo flipMethod = item.GetType().GetMethod( "Flip", Type.EmptyTypes ); - if ( flipMethod != null ) + if( flipMethod != null ) flipMethod.Invoke( item, new object[0] ); } catch @@ -97,18 +99,18 @@ namespace Server.Items else { int index = 0; - for ( int i = 0; i < m_ItemIDs.Length; i++ ) + for( int i = 0; i < m_ItemIDs.Length; i++ ) { - if ( item.ItemID == m_ItemIDs[i] ) + if( item.ItemID == m_ItemIDs[i] ) { index = i + 1; break; } } - if ( index > m_ItemIDs.Length - 1) + if( index > m_ItemIDs.Length - 1 ) index = 0; - + item.ItemID = m_ItemIDs[index]; } } diff --git a/Scripts/Items/Resources/MiscMLResources.cs b/Scripts/Items/Resources/MiscMLResources.cs index de498f604..8db6e7d5e 100644 --- a/Scripts/Items/Resources/MiscMLResources.cs +++ b/Scripts/Items/Resources/MiscMLResources.cs @@ -429,7 +429,7 @@ namespace Server.Items [Constructable] public GrizzledBones( int amount ) - : base( 0x318F ) + : base( 0x318C ) { Stackable = true; Amount = amount; @@ -444,7 +444,7 @@ namespace Server.Items { base.Serialize( writer ); - writer.Write( (int)0 ); // version + writer.Write( (int)1 ); // version } public override void Deserialize( GenericReader reader ) @@ -452,6 +452,9 @@ namespace Server.Items base.Deserialize( reader ); int version = reader.ReadInt(); + + if( version <= 0 && ItemID == 0x318F ) + ItemID = 0x318C; } } diff --git a/Scripts/Items/Skill Items/Fishing/FishingPole.cs b/Scripts/Items/Skill Items/Fishing/FishingPole.cs index 779312206..6b5550348 100644 --- a/Scripts/Items/Skill Items/Fishing/FishingPole.cs +++ b/Scripts/Items/Skill Items/Fishing/FishingPole.cs @@ -20,6 +20,11 @@ namespace Server.Items public override void OnDoubleClick( Mobile from ) { Fishing.System.BeginHarvesting( from, this ); + + Item item = from.FindItemOnLayer( Layer.OneHanded ); + + if( item != null ) + from.RemoveItem( item ); } public override void GetContextMenuEntries( Mobile from, List list ) diff --git a/Scripts/Items/Skill Items/Musical Instruments/BaseInstrument.cs b/Scripts/Items/Skill Items/Musical Instruments/BaseInstrument.cs index dd0e5762b..d6c777303 100644 --- a/Scripts/Items/Skill Items/Musical Instruments/BaseInstrument.cs +++ b/Scripts/Items/Skill Items/Musical Instruments/BaseInstrument.cs @@ -262,7 +262,7 @@ namespace Server.Items val += targ.SkillsTotal / 10; if ( val > 700 ) - val = 700 + ((val - 700) * (3 / 11)); + val = 700 + (int)((val - 700) * (3.0 / 11)); BaseCreature bc = targ as BaseCreature; diff --git a/Scripts/Items/Weapons/BaseWeapon.cs b/Scripts/Items/Weapons/BaseWeapon.cs index e1f3b8aca..1215b8b6a 100644 --- a/Scripts/Items/Weapons/BaseWeapon.cs +++ b/Scripts/Items/Weapons/BaseWeapon.cs @@ -1278,7 +1278,7 @@ namespace Server.Items set{ m_InDoubleStrike = value; } } - public virtual void OnHit( Mobile attacker, Mobile defender ) + public void OnHit( Mobile attacker, Mobile defender ) { OnHit( attacker, defender, 1.0 ); } @@ -1871,62 +1871,6 @@ namespace Server.Items defender.Z ), defender.Map ); } } - - /* if ( damage <= 2 ) - return; - - Direction d = defender.GetDirectionTo( attacker ); - - int maxCount = damage / 15; - - if ( maxCount < 1 ) - maxCount = 1; - else if ( maxCount > 4 ) - maxCount = 4; - - for( int i = 0; i < Utility.Random( 1, maxCount ); ++i ) - { - int x = defender.X; - int y = defender.Y; - - switch( d ) - { - case Direction.North: - x += Utility.Random( -1, 3 ); - y += Utility.Random( 2 ); - break; - case Direction.East: - y += Utility.Random( -1, 3 ); - x += Utility.Random( -1, 2 ); - break; - case Direction.West: - y += Utility.Random( -1, 3 ); - x += Utility.Random( 2 ); - break; - case Direction.South: - x += Utility.Random( -1, 3 ); - y += Utility.Random( -1, 2 ); - break; - case Direction.Up: - x += Utility.Random( 2 ); - y += Utility.Random( 2 ); - break; - case Direction.Down: - x += Utility.Random( -1, 2 ); - y += Utility.Random( -1, 2 ); - break; - case Direction.Left: - x += Utility.Random( 2 ); - y += Utility.Random( -1, 2 ); - break; - case Direction.Right: - x += Utility.Random( -1, 2 ); - y += Utility.Random( 2 ); - break; - } - - new Blood().MoveToWorld( new Point3D( x, y, defender.Z ), defender.Map ); - }*/ } public virtual void GetDamageTypes( Mobile wielder, out int phys, out int fire, out int cold, out int pois, out int nrgy ) diff --git a/Scripts/Misc/Guild.cs b/Scripts/Misc/Guild.cs index ae90acb0f..6e4923243 100644 --- a/Scripts/Misc/Guild.cs +++ b/Scripts/Misc/Guild.cs @@ -961,7 +961,8 @@ namespace Server.Guilds } set { - this.AddMember( value ); //Also removes from old guild. + if( value != null ) + this.AddMember( value ); //Also removes from old guild. if( m_Leader is PlayerMobile && m_Leader.Guild == this ) ((PlayerMobile)m_Leader).GuildRank = RankDefinition.Member; diff --git a/Scripts/Mobiles/Animals/Mounts/LesserHiryu.cs b/Scripts/Mobiles/Animals/Mounts/LesserHiryu.cs index 529c6eefe..c725e7fc3 100644 --- a/Scripts/Mobiles/Animals/Mounts/LesserHiryu.cs +++ b/Scripts/Mobiles/Animals/Mounts/LesserHiryu.cs @@ -86,12 +86,14 @@ namespace Server.Mobiles AddLoot( LootPack.Gems, 4 ); } - public override double GetControlChance( Mobile m ) + public override double GetControlChance( Mobile m, bool useBaseSkill ) { - if ( m.Skills.Bushido.Value >= 90.0 ) + double skill = (useBaseSkill? m.Skills.Bushido.Base : m.Skills.Bushido.Value); + + if ( skill >= 90.0 ) return 1.0; - return base.GetControlChance( m ); + return base.GetControlChance( m, useBaseSkill ); } public override int TreasureMapLevel{ get{ return 3; } } diff --git a/Scripts/Mobiles/Animals/Mounts/Ridgeback.cs b/Scripts/Mobiles/Animals/Mounts/Ridgeback.cs index 46dc8d221..2a3f22330 100644 --- a/Scripts/Mobiles/Animals/Mounts/Ridgeback.cs +++ b/Scripts/Mobiles/Animals/Mounts/Ridgeback.cs @@ -45,7 +45,7 @@ namespace Server.Mobiles MinTameSkill = 83.1; } - public override double GetControlChance( Mobile m ) + public override double GetControlChance( Mobile m, bool useBaseSkill ) { return 1.0; } diff --git a/Scripts/Mobiles/Animals/Mounts/SavageRidgeback.cs b/Scripts/Mobiles/Animals/Mounts/SavageRidgeback.cs index e342be44d..88a98affb 100644 --- a/Scripts/Mobiles/Animals/Mounts/SavageRidgeback.cs +++ b/Scripts/Mobiles/Animals/Mounts/SavageRidgeback.cs @@ -45,7 +45,7 @@ namespace Server.Mobiles MinTameSkill = 83.1; } - public override double GetControlChance( Mobile m ) + public override double GetControlChance( Mobile m, bool useBaseSkill ) { return 1.0; } diff --git a/Scripts/Mobiles/Animals/Mounts/ScaledSwampDragon.cs b/Scripts/Mobiles/Animals/Mounts/ScaledSwampDragon.cs index 5b8cb590e..2127cb7e0 100644 --- a/Scripts/Mobiles/Animals/Mounts/ScaledSwampDragon.cs +++ b/Scripts/Mobiles/Animals/Mounts/ScaledSwampDragon.cs @@ -44,7 +44,7 @@ namespace Server.Mobiles MinTameSkill = 93.9; } - public override double GetControlChance( Mobile m ) + public override double GetControlChance( Mobile m, bool useBaseSkill ) { return 1.0; } diff --git a/Scripts/Mobiles/Animals/Mounts/SwampDragon.cs b/Scripts/Mobiles/Animals/Mounts/SwampDragon.cs index a5db3236b..1e8ca1839 100644 --- a/Scripts/Mobiles/Animals/Mounts/SwampDragon.cs +++ b/Scripts/Mobiles/Animals/Mounts/SwampDragon.cs @@ -142,7 +142,7 @@ namespace Server.Mobiles return 0x2C8; } - public override double GetControlChance( Mobile m ) + public override double GetControlChance( Mobile m, bool useBaseSkill ) { return 1.0; } diff --git a/Scripts/Mobiles/Monsters/SE/FireBeetle.cs b/Scripts/Mobiles/Monsters/SE/FireBeetle.cs index 92947da0e..1a55f6304 100644 --- a/Scripts/Mobiles/Monsters/SE/FireBeetle.cs +++ b/Scripts/Mobiles/Monsters/SE/FireBeetle.cs @@ -77,7 +77,7 @@ namespace Server.Mobiles public override int Meat{ get{ return 16; } } public override FoodType FavoriteFood{ get{ return FoodType.Meat; } } - public override double GetControlChance( Mobile m ) + public override double GetControlChance( Mobile m, bool useBaseSkill ) { return 1.0; } diff --git a/Scripts/Spells/Ninjitsu/MirrorImage.cs b/Scripts/Spells/Ninjitsu/MirrorImage.cs index 6007e0344..472871acd 100644 --- a/Scripts/Spells/Ninjitsu/MirrorImage.cs +++ b/Scripts/Spells/Ninjitsu/MirrorImage.cs @@ -262,5 +262,7 @@ namespace Server.Mobiles return true; } + + public override bool CanDetectHidden { get { return false; } } } }