More cast conversion fixes

This commit is contained in:
Kamron Batman 2018-09-06 18:07:42 -07:00
parent 3f45bd57b9
commit aba9452161
46 changed files with 359 additions and 506 deletions

View file

@ -9,7 +9,7 @@ namespace Server.ContextMenus
private Mobile m_From; private Mobile m_From;
private Mobile m_Target; private Mobile m_Target;
private BaseHouse m_TargetHouse; private BaseHouse m_TargetHouse;
public EjectPlayerEntry( Mobile from, Mobile target ) : base( 6206, 12 ) public EjectPlayerEntry( Mobile from, Mobile target ) : base( 6206, 12 )
{ {
m_From = from; m_From = from;
@ -18,14 +18,12 @@ namespace Server.ContextMenus
} }
public override void OnClick() public override void OnClick()
{ {
if ( !m_From.Alive || m_TargetHouse.Deleted || !m_TargetHouse.IsFriend( m_From ) ) if ( !m_From.Alive || m_TargetHouse.Deleted || !m_TargetHouse.IsFriend( m_From ) )
return; return;
if ( m_Target is Mobile ) if ( m_Target is Mobile mobile )
{ m_TargetHouse.Kick( m_From, mobile );
m_TargetHouse.Kick( m_From, (Mobile)m_Target );
}
} }
} }
} }

View file

@ -169,17 +169,17 @@ namespace Server.Items
public override void OnRemoved(IEntity parent) public override void OnRemoved(IEntity parent)
{ {
if ( Core.AOS && parent is Mobile @from ) if ( Core.AOS && parent is Mobile from )
{ {
m_AosSkillBonuses.Remove(); m_AosSkillBonuses.Remove();
string modName = this.Serial.ToString(); string modName = this.Serial.ToString();
@from.RemoveStatMod( modName + "Str" ); from.RemoveStatMod( modName + "Str" );
@from.RemoveStatMod( modName + "Dex" ); from.RemoveStatMod( modName + "Dex" );
@from.RemoveStatMod( modName + "Int" ); from.RemoveStatMod( modName + "Int" );
@from.CheckStatTimers(); from.CheckStatTimers();
} }
} }

View file

@ -617,7 +617,7 @@ namespace Server.Items
if ( from.AccessLevel >= AccessLevel.GameMaster ) if ( from.AccessLevel >= AccessLevel.GameMaster )
return true; return true;
if ( @from is PlayerMobile mobile && mobile.Young ) if ( from is PlayerMobile mobile && mobile.Young )
return true; return true;
if ( from == this.Decoder ) if ( from == this.Decoder )

View file

@ -233,7 +233,7 @@ namespace Server.Items
// Gold was deposited in your account: // Gold was deposited in your account:
from.SendLocalizedMessage(1042672, true, deposited.ToString("#,0")); from.SendLocalizedMessage(1042672, true, deposited.ToString("#,0"));
if (@from is PlayerMobile pm) if (from is PlayerMobile pm)
{ {
var qs = pm.Quest; var qs = pm.Quest;

View file

@ -1021,7 +1021,7 @@ namespace Server.Items
#region Self Looting #region Self Looting
if ( checkSelfLoot && from == m_Owner && !GetFlag( CorpseFlag.SelfLooted ) && this.Items.Count != 0 ) if ( checkSelfLoot && from == m_Owner && !GetFlag( CorpseFlag.SelfLooted ) && this.Items.Count != 0 )
{ {
if ( @from.FindItemOnLayer( Layer.OuterTorso ) is DeathRobe robe ) if ( from.FindItemOnLayer( Layer.OuterTorso ) is DeathRobe robe )
{ {
Map map = from.Map; Map map = from.Map;
@ -1104,7 +1104,7 @@ namespace Server.Items
#region Quests #region Quests
if ( @from is PlayerMobile player ) if ( from is PlayerMobile player )
{ {
QuestSystem qs = player.Quest; QuestSystem qs = player.Quest;

View file

@ -75,7 +75,7 @@ namespace Server.Items
{ {
from.SendLocalizedMessage( 1005401 ); // You cannot bury the stone here. from.SendLocalizedMessage( 1005401 ); // You cannot bury the stone here.
} }
else if ( @from is PlayerMobile mobile && mobile.Young ) else if ( from is PlayerMobile mobile && mobile.Young )
{ {
mobile.SendLocalizedMessage( 1049543 ); // You decide against traveling to Felucca while you are still young. mobile.SendLocalizedMessage( 1049543 ); // You decide against traveling to Felucca while you are still young.
} }

View file

@ -122,7 +122,7 @@ namespace Server.Items
public override Item CreateItemFor( Mobile from ) public override Item CreateItemFor( Mobile from )
{ {
if ( @from?.Account != null ) if ( from?.Account != null )
return new SoulstoneFragment( from.Account.ToString() ); return new SoulstoneFragment( from.Account.ToString() );
return null; return null;

View file

@ -54,7 +54,7 @@ namespace Server.Items
from.BodyMod = ( from.Female ? 184 : 183 ); from.BodyMod = ( from.Female ? 184 : 183 );
from.HueMod = 0; from.HueMod = 0;
if ( @from is PlayerMobile mobile ) if ( from is PlayerMobile mobile )
mobile.SavagePaintExpiration = TimeSpan.FromDays( 7.0 ); mobile.SavagePaintExpiration = TimeSpan.FromDays( 7.0 );
from.SendLocalizedMessage( 1042537 ); // You now bear the markings of the savage tribe. Your body paint will last about a week or you can remove it with an oil cloth. from.SendLocalizedMessage( 1042537 ); // You now bear the markings of the savage tribe. Your body paint will last about a week or you can remove it with an oil cloth.

View file

@ -166,7 +166,7 @@ namespace Server.Items
private bool IsForge( object obj ) private bool IsForge( object obj )
{ {
if ( Core.ML && obj is Mobile && ((Mobile)obj).IsDeadBondedPet ) if ( Core.ML && obj is Mobile mobile && mobile.IsDeadBondedPet )
return false; return false;
if ( obj.GetType().IsDefined( typeof( ForgeAttribute ), false ) ) if ( obj.GetType().IsDefined( typeof( ForgeAttribute ), false ) )
@ -174,10 +174,10 @@ namespace Server.Items
int itemID = 0; int itemID = 0;
if ( obj is Item ) if ( obj is Item item )
itemID = ((Item)obj).ItemID; itemID = item.ItemID;
else if ( obj is StaticTarget ) else if ( obj is StaticTarget target )
itemID = ((StaticTarget)obj).ItemID; itemID = target.ItemID;
return ( itemID == 4017 || (itemID >= 6522 && itemID <= 6569) ); return ( itemID == 4017 || (itemID >= 6522 && itemID <= 6569) );
} }
@ -194,21 +194,19 @@ namespace Server.Items
} }
#region Combine Ore #region Combine Ore
if ( targeted is BaseOre ) if ( targeted is BaseOre ore )
{ {
BaseOre ore = (BaseOre)targeted;
if ( !ore.Movable ) if ( !ore.Movable )
{ {
return; return;
} }
else if ( m_Ore == ore ) if ( m_Ore == ore )
{ {
from.SendLocalizedMessage( 501972 ); // Select another pile or ore with which to combine this. from.SendLocalizedMessage( 501972 ); // Select another pile or ore with which to combine this.
from.Target = new InternalTarget( ore ); from.Target = new InternalTarget( ore );
return; return;
} }
else if ( ore.Resource != m_Ore.Resource ) if ( ore.Resource != m_Ore.Resource )
{ {
from.SendLocalizedMessage( 501979 ); // You cannot combine ores of different metals. from.SendLocalizedMessage( 501979 ); // You cannot combine ores of different metals.
return; return;
@ -259,7 +257,7 @@ namespace Server.Items
from.SendLocalizedMessage( 1062844 ); // There is too much ore to combine. from.SendLocalizedMessage( 1062844 ); // There is too much ore to combine.
return; return;
} }
else if ( ore.RootParent is Mobile && ( plusWeight + ((Mobile)ore.RootParent).Backpack.TotalWeight ) > ((Mobile)ore.RootParent).Backpack.MaxWeight ) if ( ore.RootParent is Mobile mobile && ( plusWeight + mobile.Backpack.TotalWeight ) > mobile.Backpack.MaxWeight )
{ {
from.SendLocalizedMessage( 501978 ); // The weight is too great to combine in a container. from.SendLocalizedMessage( 501978 ); // The weight is too great to combine in a container.
return; return;

View file

@ -59,7 +59,7 @@ namespace Server.Items
} }
} }
public static void OnSpun( ISpinningWheel wheel, Mobile from, int hue ) public virtual void OnSpun( ISpinningWheel wheel, Mobile from, int hue )
{ {
Item item = new SpoolOfThread( 6 ); Item item = new SpoolOfThread( 6 );
item.Hue = hue; item.Hue = hue;
@ -84,13 +84,11 @@ namespace Server.Items
ISpinningWheel wheel = targeted as ISpinningWheel; ISpinningWheel wheel = targeted as ISpinningWheel;
if ( wheel == null && targeted is AddonComponent ) if ( wheel == null && targeted is AddonComponent component )
wheel = ((AddonComponent)targeted).Addon as ISpinningWheel; wheel = component.Addon as ISpinningWheel;
if ( wheel is Item ) if ( wheel is Item )
{ {
Item item = (Item)wheel;
if ( !m_Cotton.IsChildOf( from.Backpack ) ) if ( !m_Cotton.IsChildOf( from.Backpack ) )
{ {
from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it. from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
@ -102,7 +100,7 @@ namespace Server.Items
else else
{ {
m_Cotton.Consume(); m_Cotton.Consume();
wheel.BeginSpin( new SpinCallback( Cotton.OnSpun ), from, m_Cotton.Hue ); wheel.BeginSpin( m_Cotton.OnSpun, from, m_Cotton.Hue );
} }
} }
else else
@ -112,4 +110,4 @@ namespace Server.Items
} }
} }
} }
} }

View file

@ -49,7 +49,7 @@ namespace Server.Items
} }
} }
public static void OnSpun( ISpinningWheel wheel, Mobile from, int hue ) public virtual void OnSpun( ISpinningWheel wheel, Mobile from, int hue )
{ {
Item item = new SpoolOfThread( 6 ); Item item = new SpoolOfThread( 6 );
item.Hue = hue; item.Hue = hue;
@ -74,13 +74,11 @@ namespace Server.Items
ISpinningWheel wheel = targeted as ISpinningWheel; ISpinningWheel wheel = targeted as ISpinningWheel;
if ( wheel == null && targeted is AddonComponent ) if ( wheel == null && targeted is AddonComponent component )
wheel = ((AddonComponent)targeted).Addon as ISpinningWheel; wheel = component.Addon as ISpinningWheel;
if ( wheel is Item ) if ( wheel is Item )
{ {
Item item = (Item)wheel;
if ( !m_Flax.IsChildOf( from.Backpack ) ) if ( !m_Flax.IsChildOf( from.Backpack ) )
{ {
from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it. from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
@ -92,7 +90,7 @@ namespace Server.Items
else else
{ {
m_Flax.Consume(); m_Flax.Consume();
wheel.BeginSpin( new SpinCallback( Flax.OnSpun ), from, m_Flax.Hue ); wheel.BeginSpin( m_Flax.OnSpun, from, m_Flax.Hue );
} }
} }
else else
@ -102,4 +100,4 @@ namespace Server.Items
} }
} }
} }
} }

View file

@ -59,7 +59,7 @@ namespace Server.Items
} }
} }
public static void OnSpun( ISpinningWheel wheel, Mobile from, int hue ) public virtual void OnSpun( ISpinningWheel wheel, Mobile from, int hue )
{ {
Item item = new DarkYarn( 3 ); Item item = new DarkYarn( 3 );
item.Hue = hue; item.Hue = hue;
@ -84,13 +84,11 @@ namespace Server.Items
ISpinningWheel wheel = targeted as ISpinningWheel; ISpinningWheel wheel = targeted as ISpinningWheel;
if ( wheel == null && targeted is AddonComponent ) if ( wheel == null && targeted is AddonComponent component )
wheel = ((AddonComponent)targeted).Addon as ISpinningWheel; wheel = component.Addon as ISpinningWheel;
if ( wheel is Item ) if ( wheel is Item )
{ {
Item item = (Item)wheel;
if ( !m_Wool.IsChildOf( from.Backpack ) ) if ( !m_Wool.IsChildOf( from.Backpack ) )
{ {
from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it. from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
@ -102,8 +100,7 @@ namespace Server.Items
else else
{ {
m_Wool.Consume(); m_Wool.Consume();
if ( m_Wool is TaintedWool ) wheel.BeginSpin( new SpinCallback( TaintedWool.OnSpun ), from, m_Wool.Hue ); wheel.BeginSpin( m_Wool.OnSpun, from, m_Wool.Hue );
else wheel.BeginSpin( new SpinCallback( Wool.OnSpun ), from, m_Wool.Hue );
} }
} }
else else
@ -119,7 +116,7 @@ namespace Server.Items
public TaintedWool() : this( 1 ) public TaintedWool() : this( 1 )
{ {
} }
[Constructible] [Constructible]
public TaintedWool( int amount ) : base( 0x101F ) public TaintedWool( int amount ) : base( 0x101F )
{ {
@ -145,8 +142,8 @@ namespace Server.Items
int version = reader.ReadInt(); int version = reader.ReadInt();
} }
new public static void OnSpun( ISpinningWheel wheel, Mobile from, int hue ) public override void OnSpun( ISpinningWheel wheel, Mobile from, int hue )
{ {
Item item = new DarkYarn( 1 ); Item item = new DarkYarn( 1 );
item.Hue = hue; item.Hue = hue;
@ -155,4 +152,4 @@ namespace Server.Items
from.SendLocalizedMessage( 1010574 ); // You put a ball of yarn in your backpack. from.SendLocalizedMessage( 1010574 ); // You put a ball of yarn in your backpack.
} }
} }
} }

View file

@ -74,8 +74,8 @@ namespace Server.Items
ILoom loom = targeted as ILoom; ILoom loom = targeted as ILoom;
if ( loom == null && targeted is AddonComponent ) if ( loom == null && targeted is AddonComponent component )
loom = ((AddonComponent)targeted).Addon as ILoom; loom = component.Addon as ILoom;
if ( loom != null ) if ( loom != null )
{ {
@ -87,8 +87,8 @@ namespace Server.Items
{ {
m_Material.Consume(); m_Material.Consume();
if ( targeted is Item ) if ( targeted is Item item )
((Item)targeted).SendLocalizedMessageTo( from, 1010001 + loom.Phase++ ); item.SendLocalizedMessageTo( from, 1010001 + loom.Phase++ );
} }
else else
{ {
@ -232,4 +232,4 @@ namespace Server.Items
int version = reader.ReadInt(); int version = reader.ReadInt();
} }
} }
} }

View file

@ -100,8 +100,8 @@ namespace Server.Items
{ {
MaxHitPoints -= wear; MaxHitPoints -= wear;
if ( Parent is Mobile ) if ( Parent is Mobile mobile )
((Mobile)Parent).LocalOverheadMessage( MessageType.Regular, 0x3B2, 1061121 ); // Your equipment is severely damaged. mobile.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1061121 ); // Your equipment is severely damaged.
} }
else else
{ {
@ -113,73 +113,69 @@ namespace Server.Items
return 0; return 0;
} }
else
if ( !(Parent is Mobile owner) )
return damage;
double ar = this.ArmorRating;
double chance = (owner.Skills[SkillName.Parry].Value - (ar * 2.0)) / 100.0;
if ( chance < 0.01 )
chance = 0.01;
/*
FORMULA: Displayed AR = ((Parrying Skill * Base AR of Shield) <EFBFBD> 200) + 1
FORMULA: % Chance of Blocking = parry skill - (shieldAR * 2)
FORMULA: Melee Damage Absorbed = (AR of Shield) / 2 | Archery Damage Absorbed = AR of Shield
*/
if ( owner.CheckSkill( SkillName.Parry, chance ) )
{ {
Mobile owner = this.Parent as Mobile; if ( weapon.Skill == SkillName.Archery )
if ( owner == null ) damage -= (int)ar;
return damage; else
damage -= (int)(ar / 2.0);
double ar = this.ArmorRating; if ( damage < 0 )
double chance = (owner.Skills[SkillName.Parry].Value - (ar * 2.0)) / 100.0; damage = 0;
if ( chance < 0.01 ) owner.FixedEffect( 0x37B9, 10, 16 );
chance = 0.01;
/*
FORMULA: Displayed AR = ((Parrying Skill * Base AR of Shield) <EFBFBD> 200) + 1
FORMULA: % Chance of Blocking = parry skill - (shieldAR * 2) if ( 25 > Utility.Random( 100 ) ) // 25% chance to lower durability
FORMULA: Melee Damage Absorbed = (AR of Shield) / 2 | Archery Damage Absorbed = AR of Shield
*/
if ( owner.CheckSkill( SkillName.Parry, chance ) )
{ {
if ( weapon.Skill == SkillName.Archery ) int wear = Utility.Random( 2 );
damage -= (int)ar;
else
damage -= (int)(ar / 2.0);
if ( damage < 0 ) if ( wear > 0 && MaxHitPoints > 0 )
damage = 0;
owner.FixedEffect( 0x37B9, 10, 16 );
if ( 25 > Utility.Random( 100 ) ) // 25% chance to lower durability
{ {
int wear = Utility.Random( 2 ); if ( HitPoints >= wear )
if ( wear > 0 && MaxHitPoints > 0 )
{ {
if ( HitPoints >= wear ) HitPoints -= wear;
wear = 0;
}
else
{
wear -= HitPoints;
HitPoints = 0;
}
if ( wear > 0 )
{
if ( MaxHitPoints > wear )
{ {
HitPoints -= wear; MaxHitPoints -= wear;
wear = 0;
((Mobile)Parent).LocalOverheadMessage( MessageType.Regular, 0x3B2, 1061121 ); // Your equipment is severely damaged.
} }
else else
{ {
wear -= HitPoints; Delete();
HitPoints = 0;
}
if ( wear > 0 )
{
if ( MaxHitPoints > wear )
{
MaxHitPoints -= wear;
if ( Parent is Mobile )
((Mobile)Parent).LocalOverheadMessage( MessageType.Regular, 0x3B2, 1061121 ); // Your equipment is severely damaged.
}
else
{
Delete();
}
} }
} }
} }
} }
return damage;
} }
return damage;
} }
} }
} }

View file

@ -62,9 +62,7 @@ namespace Server.Items
if ( m == null || !m.Player || m.AccessLevel != AccessLevel.Player || Core.AOS ) if ( m == null || !m.Player || m.AccessLevel != AccessLevel.Player || Core.AOS )
return true; return true;
Guild g = m.Guild as Guild; if ( !(m.Guild is Guild g) || g.Type != GuildType.Chaos )
if ( g == null || g.Type != GuildType.Chaos )
{ {
m.FixedEffect( 0x3728, 10, 13 ); m.FixedEffect( 0x3728, 10, 13 );
Delete(); Delete();

View file

@ -65,9 +65,7 @@ namespace Server.Items
if ( Core.AOS || m == null || !m.Player || m.AccessLevel != AccessLevel.Player ) if ( Core.AOS || m == null || !m.Player || m.AccessLevel != AccessLevel.Player )
return true; return true;
Guild g = m.Guild as Guild; if ( !(m.Guild is Guild g) || g.Type != GuildType.Order )
if ( g == null || g.Type != GuildType.Order )
{ {
m.FixedEffect( 0x3728, 10, 13 ); m.FixedEffect( 0x3728, 10, 13 );
Delete(); Delete();

View file

@ -132,9 +132,7 @@ namespace Server.Items
foreach ( NetState state in eable ) foreach ( NetState state in eable )
{ {
PlayerMobile pm = state.Mobile as PlayerMobile; if ( state.Mobile is PlayerMobile pm && GetEntry( pm ) == null )
if ( pm != null && GetEntry( pm ) == null )
{ {
CampfireEntry entry = new CampfireEntry( pm, this ); CampfireEntry entry = new CampfireEntry( pm, this );

View file

@ -103,7 +103,7 @@ namespace Server.Items
{ {
from.SendLocalizedMessage( 1042600 ); // That is not a corpse! from.SendLocalizedMessage( 1042600 ); // That is not a corpse!
} }
else if ( targeted is Corpse && ((Corpse)targeted).VisitedByTaxidermist ) else if ( targeted is Corpse corpse && corpse.VisitedByTaxidermist )
{ {
from.SendLocalizedMessage( 1042596 ); // That corpse seems to have been visited by a taxidermist already. from.SendLocalizedMessage( 1042596 ); // That corpse seems to have been visited by a taxidermist already.
} }
@ -138,11 +138,9 @@ namespace Server.Items
Mobile hunter = null; Mobile hunter = null;
int weight = 0; int weight = 0;
if ( targeted is BigFish ) if ( targeted is BigFish fish )
{ {
BigFish fish = targeted as BigFish; hunter = fish.Fisher;
hunter = fish.Fisher;
weight = (int)fish.Weight; weight = (int)fish.Weight;
fish.Consume(); fish.Consume();
@ -151,17 +149,15 @@ namespace Server.Items
from.AddToBackpack( new TrophyDeed( m_Table[i], hunter, weight ) ); from.AddToBackpack( new TrophyDeed( m_Table[i], hunter, weight ) );
if ( targeted is Corpse ) if ( targeted is Corpse corpse1 )
((Corpse)targeted).VisitedByTaxidermist = true; corpse1.VisitedByTaxidermist = true;
m_Kit.Delete(); m_Kit.Delete();
return; return;
} }
else
{ from.SendLocalizedMessage( 1042598 ); // You do not have enough boards.
from.SendLocalizedMessage( 1042598 ); // You do not have enough boards. return;
return;
}
} }
} }
} }
@ -303,9 +299,9 @@ namespace Server.Items
{ {
Item deed = this.Deed; Item deed = this.Deed;
if ( this.Parent is Item ) if ( this.Parent is Item item )
{ {
((Item)this.Parent).AddItem( deed ); item.AddItem( deed );
deed.Location = this.Location; deed.Location = this.Location;
} }
else else

View file

@ -114,16 +114,14 @@ namespace Server.Items
} }
} }
public virtual bool RequireDeepWater{ get{ return true; } } public virtual bool RequireDeepWater => true;
public void OnTarget( Mobile from, object obj ) public void OnTarget( Mobile from, object obj )
{ {
if ( Deleted || m_InUse ) if ( Deleted || m_InUse )
return; return;
IPoint3D p3D = obj as IPoint3D; if ( !(obj is IPoint3D p3D) )
if ( p3D == null )
return; return;
Map map = from.Map; Map map = from.Map;

View file

@ -123,9 +123,7 @@ namespace Server.Items
if ( !item.IsChildOf( from.Backpack ) && item.Parent != from ) if ( !item.IsChildOf( from.Backpack ) && item.Parent != from )
return; return;
PlayerMobile pm = from as PlayerMobile; if ( !(from is PlayerMobile pm) )
if ( pm == null )
return; return;
ContextMenuEntry miningEntry = new ContextMenuEntry( pm.ToggleMiningStone ? 6179 : 6178 ); ContextMenuEntry miningEntry = new ContextMenuEntry( pm.ToggleMiningStone ? 6179 : 6178 );
@ -239,4 +237,4 @@ namespace Server.Items
#endregion #endregion
} }
} }

View file

@ -123,9 +123,9 @@ namespace Server.Items
{ {
m.SendLocalizedMessage( 1061632 ); // You can't do that while carrying the sigil. m.SendLocalizedMessage( 1061632 ); // You can't do that while carrying the sigil.
} }
else if ( m_TargetMap == Map.Felucca && m is PlayerMobile && ((PlayerMobile)m).Young ) else if ( m_TargetMap == Map.Felucca && m is PlayerMobile mobile && mobile.Young )
{ {
m.SendLocalizedMessage( 1049543 ); // You decide against traveling to Felucca while you are still young. mobile.SendLocalizedMessage( 1049543 ); // You decide against traveling to Felucca while you are still young.
} }
else if ( (m.Kills >= 5 && m_TargetMap != Map.Felucca) || ( m_TargetMap == Map.Tokuno && (flags & ClientFlags.Tokuno) == 0 ) || ( m_TargetMap == Map.Malas && (flags & ClientFlags.Malas) == 0 ) || ( m_TargetMap == Map.Ilshenar && (flags & ClientFlags.Ilshenar) == 0 ) ) else if ( (m.Kills >= 5 && m_TargetMap != Map.Felucca) || ( m_TargetMap == Map.Tokuno && (flags & ClientFlags.Tokuno) == 0 ) || ( m_TargetMap == Map.Malas && (flags & ClientFlags.Malas) == 0 ) || ( m_TargetMap == Map.Ilshenar && (flags & ClientFlags.Ilshenar) == 0 ) )
{ {
@ -160,7 +160,7 @@ namespace Server.Items
writer.Write( m_Target ); writer.Write( m_Target );
writer.Write( m_TargetMap ); writer.Write( m_TargetMap );
// Version 1 // Version 1
writer.Write( m_bDispellable ); writer.Write( m_bDispellable );
} }
@ -461,4 +461,4 @@ namespace Server.Items
m_Gate.EndConfirmation( m_From ); m_Gate.EndConfirmation( m_From );
} }
} }
} }

View file

@ -217,82 +217,75 @@ namespace Server.Items
public override bool OnDragDrop( Mobile from, Item item ) public override bool OnDragDrop( Mobile from, Item item )
{ {
if ( item is BasePotion ) if (!(item is BasePotion pot))
{
BasePotion pot = (BasePotion)item;
int toHold = Math.Min( 100 - m_Held, pot.Amount );
if ( toHold <= 0 )
{
from.SendLocalizedMessage( 502233 ); // The keg will not hold any more!
return false;
}
else if ( m_Held == 0 )
{
#region Mondain's Legacy
if ( (int) pot.PotionEffect >= (int) PotionEffect.Invisibility )
{
from.SendLocalizedMessage( 502232 ); // The keg is not designed to hold that type of object.
return false;
}
#endregion
if ( GiveBottle( from, toHold ) )
{
m_Type = pot.PotionEffect;
Held = toHold;
from.PlaySound( 0x240 );
from.SendLocalizedMessage( 502237 ); // You place the empty bottle in your backpack.
item.Consume( toHold );
if ( !item.Deleted )
item.Bounce( from );
return true;
}
else
{
from.SendLocalizedMessage( 502238 ); // You don't have room for the empty bottle in your backpack.
return false;
}
}
else if ( pot.PotionEffect != m_Type )
{
from.SendLocalizedMessage( 502236 ); // You decide that it would be a bad idea to mix different types of potions.
return false;
}
else
{
if ( GiveBottle( from, toHold ) )
{
Held += toHold;
from.PlaySound( 0x240 );
from.SendLocalizedMessage( 502237 ); // You place the empty bottle in your backpack.
item.Consume( toHold );
if ( !item.Deleted )
item.Bounce( from );
return true;
}
else
{
from.SendLocalizedMessage( 502238 ); // You don't have room for the empty bottle in your backpack.
return false;
}
}
}
else
{ {
from.SendLocalizedMessage( 502232 ); // The keg is not designed to hold that type of object. from.SendLocalizedMessage( 502232 ); // The keg is not designed to hold that type of object.
return false; return false;
} }
int toHold = Math.Min( 100 - m_Held, pot.Amount );
if ( toHold <= 0 )
{
from.SendLocalizedMessage( 502233 ); // The keg will not hold any more!
return false;
}
if ( m_Held == 0 )
{
#region Mondain's Legacy
if ( (int) pot.PotionEffect >= (int) PotionEffect.Invisibility )
{
from.SendLocalizedMessage( 502232 ); // The keg is not designed to hold that type of object.
return false;
}
#endregion
if ( GiveBottle( from, toHold ) )
{
m_Type = pot.PotionEffect;
Held = toHold;
from.PlaySound( 0x240 );
from.SendLocalizedMessage( 502237 ); // You place the empty bottle in your backpack.
pot.Consume( toHold );
if ( !pot.Deleted )
pot.Bounce( from );
return true;
}
from.SendLocalizedMessage( 502238 ); // You don't have room for the empty bottle in your backpack.
return false;
}
if ( pot.PotionEffect != m_Type )
{
from.SendLocalizedMessage( 502236 ); // You decide that it would be a bad idea to mix different types of potions.
return false;
}
if ( GiveBottle( from, toHold ) )
{
Held += toHold;
from.PlaySound( 0x240 );
from.SendLocalizedMessage( 502237 ); // You place the empty bottle in your backpack.
pot.Consume( toHold );
if ( !pot.Deleted )
pot.Bounce( from );
return true;
}
from.SendLocalizedMessage( 502238 ); // You don't have room for the empty bottle in your backpack.
return false;
} }
public bool GiveBottle( Mobile m, int amount ) public bool GiveBottle( Mobile m, int amount )

View file

@ -81,13 +81,9 @@ namespace Server.Items
if ( handTwo is BaseWeapon ) if ( handTwo is BaseWeapon )
handOne = handTwo; handOne = handTwo;
if ( handTwo is BaseRanged )
{
BaseRanged ranged = (BaseRanged) handTwo;
if ( ranged.Balanced ) if ( handTwo is BaseRanged ranged && ranged.Balanced )
return true; return true;
}
return ( handOne == null || handTwo == null ); return ( handOne == null || handTwo == null );
} }
@ -223,10 +219,8 @@ namespace Server.Items
public override bool StackWith( Mobile from, Item dropped, bool playSound ) public override bool StackWith( Mobile from, Item dropped, bool playSound )
{ {
if ( dropped is BasePotion && ((BasePotion)dropped).m_PotionEffect == m_PotionEffect ) return dropped is BasePotion potion && potion.m_PotionEffect == m_PotionEffect &&
return base.StackWith( from, dropped, playSound ); base.StackWith(from, potion, playSound);
return false;
} }
#region ICraftable Members #region ICraftable Members

View file

@ -40,9 +40,7 @@ namespace Server.Items
return; return;
} }
ThrowTarget targ = from.Target as ThrowTarget; if ( from.Target is ThrowTarget targ && targ.Potion == this )
if ( targ != null && targ.Potion == this )
return; return;
from.RevealingAction(); from.RevealingAction();
@ -86,9 +84,7 @@ namespace Server.Items
// Check if any other players are using this potion // Check if any other players are using this potion
for ( int i = 0; i < m_Users.Count; i ++ ) for ( int i = 0; i < m_Users.Count; i ++ )
{ {
ThrowTarget targ = m_Users[ i ].Target as ThrowTarget; if ( m_Users[ i ].Target is ThrowTarget targ && targ.Potion == this )
if ( targ != null && targ.Potion == this )
Target.Cancel( from ); Target.Cancel( from );
} }
@ -112,9 +108,7 @@ namespace Server.Items
public static void AddDelay( Mobile m ) public static void AddDelay( Mobile m )
{ {
Timer timer = m_Delay[ m ] as Timer; if ( m_Delay[ m ] is Timer timer )
if ( timer != null )
timer.Stop(); timer.Stop();
m_Delay[ m ] = Timer.DelayCall( TimeSpan.FromSeconds( 30 ), new TimerStateCallback( EndDelay_Callback ), m ); m_Delay[ m ] = Timer.DelayCall( TimeSpan.FromSeconds( 30 ), new TimerStateCallback( EndDelay_Callback ), m );
@ -122,9 +116,7 @@ namespace Server.Items
public static int GetDelay( Mobile m ) public static int GetDelay( Mobile m )
{ {
Timer timer = m_Delay[ m ] as Timer; if ( m_Delay[ m ] is Timer timer && timer.Next > DateTime.UtcNow )
if ( timer != null && timer.Next > DateTime.UtcNow )
return (int) (timer.Next - DateTime.UtcNow).TotalSeconds; return (int) (timer.Next - DateTime.UtcNow).TotalSeconds;
return 0; return 0;
@ -132,15 +124,13 @@ namespace Server.Items
private static void EndDelay_Callback( object obj ) private static void EndDelay_Callback( object obj )
{ {
if ( obj is Mobile ) if ( obj is Mobile mobile )
EndDelay( (Mobile) obj ); EndDelay( mobile );
} }
public static void EndDelay( Mobile m ) public static void EndDelay( Mobile m )
{ {
Timer timer = m_Delay[ m ] as Timer; if ( m_Delay[ m ] is Timer timer )
if ( timer != null )
{ {
timer.Stop(); timer.Stop();
m_Delay.Remove( m ); m_Delay.Remove( m );
@ -167,13 +157,11 @@ namespace Server.Items
if ( m_Potion.Deleted || m_Potion.Map == Map.Internal ) if ( m_Potion.Deleted || m_Potion.Map == Map.Internal )
return; return;
IPoint3D p = targeted as IPoint3D; if ( !(targeted is IPoint3D p) || from.Map == null )
if ( p == null || from.Map == null )
return; return;
// Add delay // Add delay
BaseConflagrationPotion.AddDelay( from ); AddDelay( from );
SpellHelper.GetSurfaceTop( ref p ); SpellHelper.GetSurfaceTop( ref p );
@ -181,8 +169,8 @@ namespace Server.Items
IEntity to; IEntity to;
if ( p is Mobile ) if ( p is Mobile mobile )
to = (Mobile)p; to = mobile;
else else
to = new Entity( Serial.Zero, new Point3D( p ), from.Map ); to = new Entity( Serial.Zero, new Point3D( p ), from.Map );

View file

@ -41,9 +41,7 @@ namespace Server.Items
return; return;
} }
ThrowTarget targ = from.Target as ThrowTarget; if ( from.Target is ThrowTarget targ && targ.Potion == this )
if ( targ != null && targ.Potion == this )
return; return;
from.RevealingAction(); from.RevealingAction();
@ -87,9 +85,7 @@ namespace Server.Items
// Check if any other players are using this potion // Check if any other players are using this potion
for ( int i = 0; i < m_Users.Count; i ++ ) for ( int i = 0; i < m_Users.Count; i ++ )
{ {
ThrowTarget targ = m_Users[ i ].Target as ThrowTarget; if ( m_Users[ i ].Target is ThrowTarget targ && targ.Potion == this )
if ( targ != null && targ.Potion == this )
Target.Cancel( from ); Target.Cancel( from );
} }
@ -102,10 +98,8 @@ namespace Server.Items
foreach ( Mobile mobile in map.GetMobilesInRange( loc, Radius ) ) foreach ( Mobile mobile in map.GetMobilesInRange( loc, Radius ) )
{ {
if ( mobile is BaseCreature ) if ( mobile is BaseCreature mon )
{ {
BaseCreature mon = (BaseCreature) mobile;
if ( mon.Controlled || mon.Summoned ) if ( mon.Controlled || mon.Summoned )
continue; continue;
@ -134,9 +128,7 @@ namespace Server.Items
public static void AddDelay( Mobile m ) public static void AddDelay( Mobile m )
{ {
Timer timer = m_Delay[ m ] as Timer; if ( m_Delay[ m ] is Timer timer )
if ( timer != null )
timer.Stop(); timer.Stop();
m_Delay[ m ] = Timer.DelayCall( TimeSpan.FromSeconds( 60 ), new TimerStateCallback( EndDelay_Callback ), m ); m_Delay[ m ] = Timer.DelayCall( TimeSpan.FromSeconds( 60 ), new TimerStateCallback( EndDelay_Callback ), m );
@ -144,9 +136,7 @@ namespace Server.Items
public static int GetDelay( Mobile m ) public static int GetDelay( Mobile m )
{ {
Timer timer = m_Delay[ m ] as Timer; if ( m_Delay[ m ] is Timer timer && timer.Next > DateTime.UtcNow )
if ( timer != null && timer.Next > DateTime.UtcNow )
return (int) (timer.Next - DateTime.UtcNow).TotalSeconds; return (int) (timer.Next - DateTime.UtcNow).TotalSeconds;
return 0; return 0;
@ -154,15 +144,13 @@ namespace Server.Items
private static void EndDelay_Callback( object obj ) private static void EndDelay_Callback( object obj )
{ {
if ( obj is Mobile ) if ( obj is Mobile mobile )
EndDelay( (Mobile) obj ); EndDelay( mobile );
} }
public static void EndDelay( Mobile m ) public static void EndDelay( Mobile m )
{ {
Timer timer = m_Delay[ m ] as Timer; if ( m_Delay[ m ] is Timer timer )
if ( timer != null )
{ {
timer.Stop(); timer.Stop();
m_Delay.Remove( m ); m_Delay.Remove( m );
@ -189,13 +177,11 @@ namespace Server.Items
if ( m_Potion.Deleted || m_Potion.Map == Map.Internal ) if ( m_Potion.Deleted || m_Potion.Map == Map.Internal )
return; return;
IPoint3D p = targeted as IPoint3D; if ( !(targeted is IPoint3D p) || from.Map == null )
if ( p == null || from.Map == null )
return; return;
// Add delay // Add delay
BaseConfusionBlastPotion.AddDelay( from ); AddDelay( from );
SpellHelper.GetSurfaceTop( ref p ); SpellHelper.GetSurfaceTop( ref p );
@ -203,8 +189,8 @@ namespace Server.Items
IEntity to; IEntity to;
if ( p is Mobile ) if ( p is Mobile mobile )
to = (Mobile)p; to = mobile;
else else
to = new Entity( Serial.Zero, new Point3D( p ), from.Map ); to = new Entity( Serial.Zero, new Point3D( p ), from.Map );

View file

@ -117,17 +117,13 @@ namespace Server.Items
Point3D loc; Point3D loc;
Map map; Map map;
if ( parent is Item ) if ( parent is Item item )
{ {
Item item = (Item)parent;
loc = item.GetWorldLocation(); loc = item.GetWorldLocation();
map = item.Map; map = item.Map;
} }
else if ( parent is Mobile ) else if ( parent is Mobile m )
{ {
Mobile m = (Mobile)parent;
loc = m.Location; loc = m.Location;
map = m.Map; map = m.Map;
} }
@ -141,10 +137,10 @@ namespace Server.Items
} }
else else
{ {
if ( parent is Item ) if ( parent is Item item )
((Item)parent).PublicOverheadMessage( MessageType.Regular, 0x22, false, timer.ToString() ); item.PublicOverheadMessage( MessageType.Regular, 0x22, false, timer.ToString() );
else if ( parent is Mobile ) else if ( parent is Mobile mobile )
((Mobile)parent).PublicOverheadMessage( MessageType.Regular, 0x22, false, timer.ToString() ); mobile.PublicOverheadMessage( MessageType.Regular, 0x22, false, timer.ToString() );
states[1] = timer - 1; states[1] = timer - 1;
} }
@ -187,9 +183,7 @@ namespace Server.Items
if ( m_Potion.Deleted || m_Potion.Map == Map.Internal ) if ( m_Potion.Deleted || m_Potion.Map == Map.Internal )
return; return;
IPoint3D p = targeted as IPoint3D; if ( !(targeted is IPoint3D p) )
if ( p == null )
return; return;
Map map = from.Map; Map map = from.Map;
@ -201,16 +195,14 @@ namespace Server.Items
from.RevealingAction(); from.RevealingAction();
IEntity to; IEntity to = new Entity( Serial.Zero, new Point3D( p ), map );
to = new Entity( Serial.Zero, new Point3D( p ), map ); if ( p is Mobile m )
if ( p is Mobile )
{ {
if ( !RelativeLocation ) // explosion location = current mob location. if ( !RelativeLocation ) // explosion location = current mob location.
p = ((Mobile)p).Location; p = m.Location;
else else
to = (Mobile)p; to = m;
} }
Effects.SendMovingEffect( from, to, m_Potion.ItemID, 7, 0, false, false, m_Potion.Hue, 0 ); Effects.SendMovingEffect( from, to, m_Potion.ItemID, 7, 0, false, false, m_Potion.Hue, 0 );
@ -235,9 +227,8 @@ namespace Server.Items
for ( int i = 0; m_Users != null && i < m_Users.Count; ++i ) for ( int i = 0; m_Users != null && i < m_Users.Count; ++i )
{ {
Mobile m = m_Users[i]; Mobile m = m_Users[i];
ThrowTarget targ = m.Target as ThrowTarget;
if ( targ != null && targ.Potion == this ) if ( m.Target is ThrowTarget targ && targ.Potion == this )
Target.Cancel( m ); Target.Cancel( m );
} }
@ -259,9 +250,9 @@ namespace Server.Items
foreach ( IEntity o in eable ) foreach ( IEntity o in eable )
{ {
if ( o is Mobile && (from == null || (SpellHelper.ValidIndirectTarget( from, (Mobile)o ) && from.CanBeHarmful( (Mobile)o, false )))) if ( o is Mobile mobile && (from == null || (SpellHelper.ValidIndirectTarget( from, mobile ) && from.CanBeHarmful( mobile, false ))))
{ {
toExplode.Add( o ); toExplode.Add( mobile );
++toDamage; ++toDamage;
} }
else if ( o is BaseExplosionPotion && o != this ) else if ( o is BaseExplosionPotion && o != this )
@ -279,12 +270,9 @@ namespace Server.Items
{ {
object o = toExplode[i]; object o = toExplode[i];
if ( o is Mobile ) if ( o is Mobile m )
{ {
Mobile m = (Mobile)o; from?.DoHarmful( m );
if ( from != null )
from.DoHarmful( m );
int damage = Utility.RandomMinMax( min, max ); int damage = Utility.RandomMinMax( min, max );
@ -297,10 +285,8 @@ namespace Server.Items
AOS.Damage( m, from, damage, 0, 100, 0, 0, 0 ); AOS.Damage( m, from, damage, 0, 100, 0, 0, 0 );
} }
else if ( o is BaseExplosionPotion ) else if ( o is BaseExplosionPotion pot )
{ {
BaseExplosionPotion pot = (BaseExplosionPotion)o;
pot.Explode( from, false, pot.GetWorldLocation(), pot.Map ); pot.Explode( from, false, pot.GetWorldLocation(), pot.Map );
} }
} }

View file

@ -39,8 +39,8 @@ namespace Server.Items
private static void Hide_Callback( object obj ) private static void Hide_Callback( object obj )
{ {
if ( obj is Mobile ) if ( obj is Mobile mobile )
Hide( (Mobile) obj ); Hide( mobile );
} }
public static void Hide( Mobile m ) public static void Hide( Mobile m )
@ -60,8 +60,8 @@ namespace Server.Items
private static void EndHide_Callback( object obj ) private static void EndHide_Callback( object obj )
{ {
if ( obj is Mobile ) if ( obj is Mobile mobile )
EndHide( (Mobile) obj ); EndHide( mobile );
} }
public static void EndHide( Mobile m ) public static void EndHide( Mobile m )

View file

@ -270,13 +270,14 @@ namespace Server.Items
{ {
NetState ns = toCheck.NetState; NetState ns = toCheck.NetState;
if ( ns != null ) { if (ns == null)
foreach ( Gump gump in ns.Gumps ) { return false;
RunebookGump bookGump = gump as RunebookGump;
if ( bookGump != null && bookGump.Book == this ) { foreach ( Gump gump in ns.Gumps )
return true; {
} if ( gump is RunebookGump bookGump && bookGump.Book == this )
{
return true;
} }
} }
@ -295,7 +296,7 @@ namespace Server.Items
if ( m_Crafter != null ) if ( m_Crafter != null )
list.Add( 1050043, m_Crafter.Name ); // crafted by ~1_NAME~ list.Add( 1050043, m_Crafter.Name ); // crafted by ~1_NAME~
if ( m_Description != null && m_Description.Length > 0 ) if ( !string.IsNullOrEmpty(m_Description) )
list.Add( m_Description ); list.Add( m_Description );
} }
@ -358,9 +359,7 @@ namespace Server.Items
public override void OnAfterDuped( Item newItem ) public override void OnAfterDuped( Item newItem )
{ {
Runebook book = newItem as Runebook; if ( !(newItem is Runebook book) )
if ( book == null )
return; return;
book.m_Entries = new List<RunebookEntry>(); book.m_Entries = new List<RunebookEntry>();
@ -388,7 +387,7 @@ namespace Server.Items
public override bool OnDragDrop( Mobile from, Item dropped ) public override bool OnDragDrop( Mobile from, Item dropped )
{ {
if ( dropped is RecallRune ) if ( dropped is RecallRune rune )
{ {
if ( IsLockedDown && from.AccessLevel < AccessLevel.GameMaster ) if ( IsLockedDown && from.AccessLevel < AccessLevel.GameMaster )
{ {
@ -400,13 +399,11 @@ namespace Server.Items
} }
else if ( m_Entries.Count < 16 ) else if ( m_Entries.Count < 16 )
{ {
RecallRune rune = (RecallRune)dropped;
if ( rune.Marked && rune.TargetMap != null ) if ( rune.Marked && rune.TargetMap != null )
{ {
m_Entries.Add( new RunebookEntry( rune.Target, rune.TargetMap, rune.Description, rune.House ) ); m_Entries.Add( new RunebookEntry( rune.Target, rune.TargetMap, rune.Description, rune.House ) );
dropped.Delete(); rune.Delete();
from.Send( new PlaySound( 0x42, GetWorldLocation() ) ); from.Send( new PlaySound( 0x42, GetWorldLocation() ) );
@ -419,10 +416,8 @@ namespace Server.Items
return true; return true;
} }
else
{ from.SendLocalizedMessage( 502409 ); // This rune does not have a marked location.
from.SendLocalizedMessage( 502409 ); // This rune does not have a marked location.
}
} }
else else
{ {

View file

@ -64,10 +64,8 @@ namespace Server.Items
private static void AllSpells_OnTarget( Mobile from, object obj ) private static void AllSpells_OnTarget( Mobile from, object obj )
{ {
if ( obj is Spellbook ) if ( obj is Spellbook book )
{ {
Spellbook book = (Spellbook)obj;
if ( book.BookCount == 64 ) if ( book.BookCount == 64 )
book.Content = ulong.MaxValue; book.Content = ulong.MaxValue;
else else
@ -268,8 +266,8 @@ namespace Server.Items
Item item = from.FindItemOnLayer( Layer.OneHanded ); Item item = from.FindItemOnLayer( Layer.OneHanded );
if ( item is Spellbook ) if ( item is Spellbook spellbook )
list.Add( (Spellbook)item ); list.Add( spellbook );
Container pack = from.Backpack; Container pack = from.Backpack;
@ -280,8 +278,8 @@ namespace Server.Items
{ {
item = pack.Items[i]; item = pack.Items[i];
if ( item is Spellbook ) if ( item is Spellbook spellbook1 )
list.Add( (Spellbook)item ); list.Add( spellbook1 );
} }
return list; return list;
@ -352,45 +350,38 @@ namespace Server.Items
public override bool OnDragDrop( Mobile from, Item dropped ) public override bool OnDragDrop( Mobile from, Item dropped )
{ {
if ( dropped is SpellScroll && dropped.Amount == 1 ) if ( dropped is SpellScroll scroll && scroll.Amount == 1 )
{ {
SpellScroll scroll = (SpellScroll)dropped;
SpellbookType type = GetTypeForSpell( scroll.SpellID ); SpellbookType type = GetTypeForSpell( scroll.SpellID );
if ( type != this.SpellbookType ) if ( type != this.SpellbookType )
{ {
return false; return false;
} }
else if ( HasSpell( scroll.SpellID ) )
if ( HasSpell( scroll.SpellID ) )
{ {
from.SendLocalizedMessage( 500179 ); // That spell is already present in that spellbook. from.SendLocalizedMessage( 500179 ); // That spell is already present in that spellbook.
return false; return false;
} }
else
int val = scroll.SpellID - BookOffset;
if ( val >= 0 && val < BookCount )
{ {
int val = scroll.SpellID - BookOffset; m_Content |= (ulong)1 << val;
++m_Count;
if ( val >= 0 && val < BookCount ) InvalidateProperties();
{
m_Content |= (ulong)1 << val;
++m_Count;
InvalidateProperties(); scroll.Delete();
scroll.Delete(); from.Send( new PlaySound( 0x249, GetWorldLocation() ) );
return true;
from.Send( new PlaySound( 0x249, GetWorldLocation() ) );
return true;
}
return false;
} }
} }
else
{ return false;
return false;
}
} }
[CommandProperty( AccessLevel.GameMaster )] [CommandProperty( AccessLevel.GameMaster )]
@ -452,9 +443,7 @@ namespace Server.Items
public override void OnAfterDuped( Item newItem ) public override void OnAfterDuped( Item newItem )
{ {
Spellbook book = newItem as Spellbook; if ( !(newItem is Spellbook book) )
if ( book == null )
return; return;
book.m_AosAttributes = new AosAttributes( newItem, m_AosAttributes ); book.m_AosAttributes = new AosAttributes( newItem, m_AosAttributes );
@ -463,10 +452,8 @@ namespace Server.Items
public override void OnAdded(IEntity parent) public override void OnAdded(IEntity parent)
{ {
if ( Core.AOS && parent is Mobile ) if ( Core.AOS && parent is Mobile from )
{ {
Mobile from = (Mobile)parent;
m_AosSkillBonuses.AddTo( from ); m_AosSkillBonuses.AddTo( from );
int strBonus = m_AosAttributes.BonusStr; int strBonus = m_AosAttributes.BonusStr;
@ -493,10 +480,8 @@ namespace Server.Items
public override void OnRemoved(IEntity parent) public override void OnRemoved(IEntity parent)
{ {
if ( Core.AOS && parent is Mobile ) if ( Core.AOS && parent is Mobile from )
{ {
Mobile from = (Mobile)parent;
m_AosSkillBonuses.Remove(); m_AosSkillBonuses.Remove();
string modName = this.Serial.ToString(); string modName = this.Serial.ToString();
@ -802,31 +787,31 @@ namespace Server.Items
if ( m_AosSkillBonuses == null ) if ( m_AosSkillBonuses == null )
m_AosSkillBonuses = new AosSkillBonuses( this ); m_AosSkillBonuses = new AosSkillBonuses( this );
if ( Core.AOS && Parent is Mobile ) if ( Core.AOS && Parent is Mobile mobile )
m_AosSkillBonuses.AddTo( (Mobile) Parent ); m_AosSkillBonuses.AddTo( mobile );
int strBonus = m_AosAttributes.BonusStr; int strBonus = m_AosAttributes.BonusStr;
int dexBonus = m_AosAttributes.BonusDex; int dexBonus = m_AosAttributes.BonusDex;
int intBonus = m_AosAttributes.BonusInt; int intBonus = m_AosAttributes.BonusInt;
if ( Parent is Mobile && (strBonus != 0 || dexBonus != 0 || intBonus != 0) ) if ( Parent is Mobile m )
{ {
Mobile m = (Mobile)Parent; if (strBonus != 0 || dexBonus != 0 || intBonus != 0)
{
string modName = Serial.ToString();
string modName = Serial.ToString(); if ( strBonus != 0 )
m.AddStatMod( new StatMod( StatType.Str, modName + "Str", strBonus, TimeSpan.Zero ) );
if ( strBonus != 0 ) if ( dexBonus != 0 )
m.AddStatMod( new StatMod( StatType.Str, modName + "Str", strBonus, TimeSpan.Zero ) ); m.AddStatMod( new StatMod( StatType.Dex, modName + "Dex", dexBonus, TimeSpan.Zero ) );
if ( dexBonus != 0 ) if ( intBonus != 0 )
m.AddStatMod( new StatMod( StatType.Dex, modName + "Dex", dexBonus, TimeSpan.Zero ) ); m.AddStatMod( new StatMod( StatType.Int, modName + "Int", intBonus, TimeSpan.Zero ) );
}
if ( intBonus != 0 ) m.CheckStatTimers();
m.AddStatMod( new StatMod( StatType.Int, modName + "Int", intBonus, TimeSpan.Zero ) );
} }
if ( Parent is Mobile )
((Mobile)Parent).CheckStatTimers();
} }
private static int[] m_LegendPropertyCounts = new int[] private static int[] m_LegendPropertyCounts = new int[]

View file

@ -81,9 +81,7 @@ namespace Server.Items
private static void EventSink_BandageTargetRequest(BandageTargetRequestEventArgs e) private static void EventSink_BandageTargetRequest(BandageTargetRequestEventArgs e)
{ {
Bandage b = e.Bandage as Bandage; if (!(e.Bandage is Bandage b) || b.Deleted)
if (b == null || b.Deleted)
return; return;
Mobile from = e.Mobile; Mobile from = e.Mobile;
@ -124,11 +122,11 @@ namespace Server.Items
if ( m_Bandage.Deleted ) if ( m_Bandage.Deleted )
return; return;
if ( targeted is Mobile ) if ( targeted is Mobile mobile )
{ {
if ( from.InRange( m_Bandage.GetWorldLocation(), Bandage.Range ) ) if ( from.InRange( m_Bandage.GetWorldLocation(), Bandage.Range ) )
{ {
if ( BandageContext.BeginHeal( from, (Mobile)targeted ) != null ) if ( BandageContext.BeginHeal( from, mobile ) != null )
{ {
if ( !Engines.ConPVP.DuelContext.IsFreeConsume( from ) ) if ( !Engines.ConPVP.DuelContext.IsFreeConsume( from ) )
m_Bandage.Consume(); m_Bandage.Consume();
@ -139,9 +137,9 @@ namespace Server.Items
from.SendLocalizedMessage( 500295 ); // You are too far away to do that. from.SendLocalizedMessage( 500295 ); // You are too far away to do that.
} }
} }
else if ( targeted is PlagueBeastInnard ) else if ( targeted is PlagueBeastInnard innard )
{ {
if ( ((PlagueBeastInnard) targeted).OnBandage( from ) ) if ( innard.OnBandage( from ) )
m_Bandage.Consume(); m_Bandage.Consume();
} }
else else
@ -152,9 +150,9 @@ namespace Server.Items
protected override void OnNonlocalTarget( Mobile from, object targeted ) protected override void OnNonlocalTarget( Mobile from, object targeted )
{ {
if ( targeted is PlagueBeastInnard ) if ( targeted is PlagueBeastInnard innard )
{ {
if ( ((PlagueBeastInnard) targeted).OnBandage( from ) ) if ( innard.OnBandage( from ) )
m_Bandage.Consume(); m_Bandage.Consume();
} }
else else
@ -469,17 +467,17 @@ namespace Server.Items
public static BandageContext BeginHeal( Mobile healer, Mobile patient ) public static BandageContext BeginHeal( Mobile healer, Mobile patient )
{ {
bool isDeadPet = ( patient is BaseCreature && ((BaseCreature)patient).IsDeadPet ); BaseCreature creature = patient as BaseCreature;
if ( patient is Golem ) if ( patient is Golem )
{ {
healer.SendLocalizedMessage( 500970 ); // Bandages cannot be used on that. healer.SendLocalizedMessage( 500970 ); // Bandages cannot be used on that.
} }
else if ( patient is BaseCreature && ((BaseCreature)patient).IsAnimatedDead ) else if ( creature?.IsAnimatedDead == true )
{ {
healer.SendLocalizedMessage( 500951 ); // You cannot heal that. healer.SendLocalizedMessage( 500951 ); // You cannot heal that.
} }
else if ( !patient.Poisoned && patient.Hits == patient.HitsMax && !BleedAttack.IsBleeding( patient ) && !isDeadPet ) else if ( !patient.Poisoned && patient.Hits == patient.HitsMax && !BleedAttack.IsBleeding( patient ) && creature?.IsDeadPet != true )
{ {
healer.SendLocalizedMessage( 500955 ); // That being is not damaged! healer.SendLocalizedMessage( 500955 ); // That being is not damaged!
} }
@ -534,8 +532,7 @@ namespace Server.Items
BandageContext context = GetContext( healer ); BandageContext context = GetContext( healer );
if ( context != null ) context?.StopHeal();
context.StopHeal();
seconds *= 1000; seconds *= 1000;
context = new BandageContext( healer, patient, TimeSpan.FromMilliseconds( seconds ) ); context = new BandageContext( healer, patient, TimeSpan.FromMilliseconds( seconds ) );

View file

@ -199,8 +199,8 @@ namespace Server.Items
return; return;
IPoint3D loc; IPoint3D loc;
if ( targeted is Item ) if ( targeted is Item item )
loc = ((Item)targeted).GetWorldLocation(); loc = item.GetWorldLocation();
else else
loc = targeted as IPoint3D; loc = targeted as IPoint3D;

View file

@ -67,14 +67,12 @@ namespace Server.Items
Recipe r = this.Recipe; Recipe r = this.Recipe;
if ( r != null && from is PlayerMobile ) if ( r != null && @from is PlayerMobile pm )
{ {
PlayerMobile pm = from as PlayerMobile;
if ( !pm.HasRecipe( r ) ) if ( !pm.HasRecipe( r ) )
{ {
bool allRequiredSkills = true; bool allRequiredSkills = true;
double chance = r.CraftItem.GetSuccessChance( from, null, r.CraftSystem, false, ref allRequiredSkills ); double chance = r.CraftItem.GetSuccessChance( pm, null, r.CraftSystem, false, ref allRequiredSkills );
if ( allRequiredSkills && chance >= 0.0 ) if ( allRequiredSkills && chance >= 0.0 )
{ {

View file

@ -165,9 +165,7 @@ namespace Server.Items
public static BaseInstrument GetInstrument( Mobile from ) public static BaseInstrument GetInstrument( Mobile from )
{ {
BaseInstrument item = m_Instruments[from] as BaseInstrument; if ( !(m_Instruments[@from] is BaseInstrument item) )
if ( item == null )
return null; return null;
if ( !item.IsChildOf( from.Backpack ) ) if ( !item.IsChildOf( from.Backpack ) )
@ -202,9 +200,7 @@ namespace Server.Items
public static void OnPickedInstrument( Mobile from, object targeted, object state ) public static void OnPickedInstrument( Mobile from, object targeted, object state )
{ {
BaseInstrument instrument = targeted as BaseInstrument; if ( !(targeted is BaseInstrument instrument) )
if ( instrument == null )
{ {
from.SendLocalizedMessage( 500619 ); // That is not a musical instrument. from.SendLocalizedMessage( 500619 ); // That is not a musical instrument.
} }
@ -214,8 +210,7 @@ namespace Server.Items
InstrumentPickedCallback callback = state as InstrumentPickedCallback; InstrumentPickedCallback callback = state as InstrumentPickedCallback;
if ( callback != null ) callback?.Invoke( @from, instrument );
callback( from, instrument );
} }
} }

View file

@ -316,9 +316,9 @@ namespace Server.Items
if (WeaponIsValid(weapon, from)) if (WeaponIsValid(weapon, from))
{ {
if (targeted is Mobile) if (targeted is Mobile mobile)
{ {
Shoot(player, (Mobile)targeted, weapon); Shoot(player, mobile, weapon);
} }
else if (targeted.GetType() == weapon.AmmoType) else if (targeted.GetType() == weapon.AmmoType)
{ {
@ -382,4 +382,4 @@ namespace Server.Items
} }
} }
} }
} }

View file

@ -173,21 +173,19 @@ namespace Server.Items
protected override void OnTarget( Mobile from, object targeted ) protected override void OnTarget( Mobile from, object targeted )
{ {
if ( targeted is Item ) if ( targeted is Item item )
{ {
Item item = (Item)targeted;
if ( item.QuestItem ) if ( item.QuestItem )
{ {
from.SendLocalizedMessage( 1151836 ); // You may not dye toggled quest items. from.SendLocalizedMessage( 1151836 ); // You may not dye toggled quest items.
} }
else if ( item is IDyable && m_Tub.AllowDyables ) else if ( item is IDyable dyable && m_Tub.AllowDyables )
{ {
if ( !from.InRange( m_Tub.GetWorldLocation(), 1 ) || !from.InRange( item.GetWorldLocation(), 1 ) ) if ( !from.InRange( m_Tub.GetWorldLocation(), 1 ) || !from.InRange( item.GetWorldLocation(), 1 ) )
from.SendLocalizedMessage( 500446 ); // That is too far away. from.SendLocalizedMessage( 500446 ); // That is too far away.
else if ( item.Parent is Mobile ) else if ( item.Parent is Mobile )
from.SendLocalizedMessage( 500861 ); // Can't Dye clothing that is being worn. from.SendLocalizedMessage( 500861 ); // Can't Dye clothing that is being worn.
else if ( ((IDyable)item).Dye( from, m_Tub ) ) else if ( dyable.Dye( from, m_Tub ) )
from.PlaySound( 0x23E ); from.PlaySound( 0x23E );
} }
else if ( (FurnitureAttribute.Check( item ) || (item is PotionKeg)) && m_Tub.AllowFurniture ) else if ( (FurnitureAttribute.Check( item ) || (item is PotionKeg)) && m_Tub.AllowFurniture )
@ -258,7 +256,7 @@ namespace Server.Items
from.PlaySound( 0x23E ); from.PlaySound( 0x23E );
} }
} }
else if ( (item is BaseArmor && (((BaseArmor)item).MaterialType == ArmorMaterialType.Leather || ((BaseArmor)item).MaterialType == ArmorMaterialType.Studded) || item is ElvenBoots || item is WoodlandBelt) && m_Tub.AllowLeather ) else if ( (item is BaseArmor armor && (armor.MaterialType == ArmorMaterialType.Leather || armor.MaterialType == ArmorMaterialType.Studded) || item is ElvenBoots || item is WoodlandBelt) && m_Tub.AllowLeather )
{ {
if ( !from.InRange( m_Tub.GetWorldLocation(), 1 ) || !from.InRange( item.GetWorldLocation(), 1 ) ) if ( !from.InRange( m_Tub.GetWorldLocation(), 1 ) || !from.InRange( item.GetWorldLocation(), 1 ) )
{ {

View file

@ -77,10 +77,8 @@ namespace Server.Items
public virtual void SetTubHue( Mobile from, object state, int hue ) public virtual void SetTubHue( Mobile from, object state, int hue )
{ {
if ( state is DyeTub ) if ( state is DyeTub tub )
{ {
DyeTub tub = state as DyeTub;
tub.DyedHue = hue; tub.DyedHue = hue;
/* dyes.m_UsesRemaining--; let this change ride till the overhaul */ /* dyes.m_UsesRemaining--; let this change ride till the overhaul */
@ -89,10 +87,8 @@ namespace Server.Items
protected override void OnTarget( Mobile from, object targeted ) protected override void OnTarget( Mobile from, object targeted )
{ {
if ( targeted is DyeTub ) if ( targeted is DyeTub tub )
{ {
DyeTub tub = (DyeTub) targeted;
if ( tub.Redyable ) if ( tub.Redyable )
{ {
if ( tub.MetallicHues ) /* OSI has three metallic tubs now */ if ( tub.MetallicHues ) /* OSI has three metallic tubs now */

View file

@ -71,20 +71,16 @@ namespace Server.Items
{ {
from.SendLocalizedMessage( 1063305 ); // Didn't your parents ever tell you not to run with scissors in your hand?! from.SendLocalizedMessage( 1063305 ); // Didn't your parents ever tell you not to run with scissors in your hand?!
} }
else if ( targeted is Item && !((Item)targeted).Movable ) else if ( targeted is Item item && !item.Movable )
{ {
if ( targeted is IScissorable && ( targeted is PlagueBeastInnard || targeted is PlagueBeastMutationCore ) ) if ( item is IScissorable obj && ( obj is PlagueBeastInnard || obj is PlagueBeastMutationCore ) )
{ {
IScissorable obj = (IScissorable) targeted;
if ( CanScissor( from, obj ) && obj.Scissor( from, m_Item ) ) if ( CanScissor( from, obj ) && obj.Scissor( from, m_Item ) )
from.PlaySound( 0x248 ); from.PlaySound( 0x248 );
} }
} }
else if ( targeted is IScissorable ) else if ( targeted is IScissorable obj )
{ {
IScissorable obj = (IScissorable)targeted;
if ( CanScissor( from, obj ) && obj.Scissor( from, m_Item ) ) if ( CanScissor( from, obj ) && obj.Scissor( from, m_Item ) )
from.PlaySound( 0x248 ); from.PlaySound( 0x248 );
} }
@ -96,10 +92,8 @@ namespace Server.Items
protected override void OnNonlocalTarget( Mobile from, object targeted ) protected override void OnNonlocalTarget( Mobile from, object targeted )
{ {
if ( targeted is IScissorable && ( targeted is PlagueBeastInnard || targeted is PlagueBeastMutationCore ) ) if ( targeted is IScissorable obj && ( obj is PlagueBeastInnard || obj is PlagueBeastMutationCore ) )
{ {
IScissorable obj = (IScissorable) targeted;
if ( CanScissor( from, obj ) && obj.Scissor( from, m_Item ) ) if ( CanScissor( from, obj ) && obj.Scissor( from, m_Item ) )
from.PlaySound( 0x248 ); from.PlaySound( 0x248 );
} }
@ -110,7 +104,7 @@ namespace Server.Items
public static bool CanScissor( Mobile from, IScissorable obj ) public static bool CanScissor( Mobile from, IScissorable obj )
{ {
if ( obj is Item && ( (Item)obj ).Nontransferable ) if ( obj is Item item && item.Nontransferable )
{ {
from.SendLocalizedMessage( 502440 ); // Scissors can not be used on that to produce anything. from.SendLocalizedMessage( 502440 ); // Scissors can not be used on that to produce anything.
return false; return false;

View file

@ -212,10 +212,8 @@ namespace Server.Items
m_From.NameMod = NameList.RandomName( m_From.Female ? "female" : "male" ); m_From.NameMod = NameList.RandomName( m_From.Female ? "female" : "male" );
if ( m_From is PlayerMobile ) if ( m_From is PlayerMobile pm )
{ {
PlayerMobile pm = (PlayerMobile)m_From;
if ( hair ) if ( hair )
pm.SetHairMods( entry.m_ItemID, -2 ); pm.SetHairMods( entry.m_ItemID, -2 );
else else
@ -297,10 +295,10 @@ namespace Server.Items
{ {
m_Player.NameMod = null; m_Player.NameMod = null;
if ( m_Player is PlayerMobile ) if ( m_Player is PlayerMobile mobile )
((PlayerMobile)m_Player).SetHairMods( -1, -1 ); mobile.SetHairMods( -1, -1 );
DisguiseTimers.RemoveTimer( m_Player ); RemoveTimer( m_Player );
} }
} }

View file

@ -73,16 +73,16 @@ namespace Server.Items
if ( m_Item.Deleted ) if ( m_Item.Deleted )
return; return;
if ( targeted is ILockpickable ) if ( targeted is ILockpickable lockpickable )
{ {
Item item = (Item)targeted; Item item = lockpickable as Item;
from.Direction = from.GetDirectionTo( item ); from.Direction = from.GetDirectionTo( item );
if ( ((ILockpickable)targeted).Locked ) if ( lockpickable.Locked )
{ {
from.PlaySound( 0x241 ); from.PlaySound( 0x241 );
new InternalTimer( from, (ILockpickable)targeted, m_Item ).Start(); new InternalTimer( from, lockpickable, m_Item ).Start();
} }
else else
{ {
@ -101,7 +101,7 @@ namespace Server.Items
private Mobile m_From; private Mobile m_From;
private ILockpickable m_Item; private ILockpickable m_Item;
private Lockpick m_Lockpick; private Lockpick m_Lockpick;
public InternalTimer( Mobile from, ILockpickable item, Lockpick lockpick ) : base( TimeSpan.FromSeconds( 3.0 ) ) public InternalTimer( Mobile from, ILockpickable item, Lockpick lockpick ) : base( TimeSpan.FromSeconds( 3.0 ) )
{ {
m_From = from; m_From = from;
@ -124,7 +124,7 @@ namespace Server.Items
m_Lockpick.Consume(); m_Lockpick.Consume();
} }
} }
protected override void OnTick() protected override void OnTick()
{ {
Item item = (Item)m_Item; Item item = (Item)m_Item;
@ -168,4 +168,4 @@ namespace Server.Items
} }
} }
} }
} }

View file

@ -26,20 +26,15 @@ namespace Server.Items
from.Send( new MessageLocalizedAffix( from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 1008146 + (int)Clock.GetMoonPhase( Map.Trammel, from.X, from.Y ), "", AffixType.Prepend, "Trammel : ", "" ) ); from.Send( new MessageLocalizedAffix( from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 1008146 + (int)Clock.GetMoonPhase( Map.Trammel, from.X, from.Y ), "", AffixType.Prepend, "Trammel : ", "" ) );
from.Send( new MessageLocalizedAffix( from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 1008146 + (int)Clock.GetMoonPhase( Map.Felucca, from.X, from.Y ), "", AffixType.Prepend, "Felucca : ", "" ) ); from.Send( new MessageLocalizedAffix( from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 1008146 + (int)Clock.GetMoonPhase( Map.Felucca, from.X, from.Y ), "", AffixType.Prepend, "Felucca : ", "" ) );
PlayerMobile player = from as PlayerMobile; if ( @from is PlayerMobile player )
if ( player != null )
{ {
QuestSystem qs = player.Quest; QuestSystem qs = player.Quest;
if ( qs is WitchApprenticeQuest ) if ( qs is WitchApprenticeQuest )
{ {
FindIngredientObjective obj = qs.FindObjective( typeof( FindIngredientObjective ) ) as FindIngredientObjective; if ( qs.FindObjective( typeof( FindIngredientObjective ) ) is FindIngredientObjective obj && !obj.Completed && obj.Ingredient == Ingredient.StarChart )
if ( obj != null && !obj.Completed && obj.Ingredient == Ingredient.StarChart )
{ {
int hours, minutes; Clock.GetTime( from.Map, from.X, from.Y, out int hours, out int _ );
Clock.GetTime( from.Map, from.X, from.Y, out hours, out minutes );
if ( hours < 5 || hours > 17 ) if ( hours < 5 || hours > 17 )
{ {
@ -74,4 +69,4 @@ namespace Server.Items
int version = reader.ReadInt(); int version = reader.ReadInt();
} }
} }
} }

View file

@ -60,9 +60,7 @@ namespace Server.Items
public override void OnAfterDuped( Item newItem ) public override void OnAfterDuped( Item newItem )
{ {
DawnsMusicBox box = newItem as DawnsMusicBox; if ( !(newItem is DawnsMusicBox box) )
if ( box == null )
return; return;
box.m_Tracks = new List<MusicName>(); box.m_Tracks = new List<MusicName>();

View file

@ -76,7 +76,7 @@ namespace Server.Items
base.Serialize( writer ); base.Serialize( writer );
writer.WriteEncodedInt( (int) 1 ); // version writer.WriteEncodedInt( (int) 1 ); // version
writer.Write( (int) m_Music ); writer.Write( (int) m_Music );
} }
@ -85,7 +85,7 @@ namespace Server.Items
base.Deserialize( reader ); base.Deserialize( reader );
int version = reader.ReadEncodedInt(); int version = reader.ReadEncodedInt();
switch ( version ) switch ( version )
{ {
case 1: case 1:
@ -94,19 +94,19 @@ namespace Server.Items
break; break;
} }
} }
if ( version == 0 ) // Music wasn't serialized in version 0, pick a new track of random rarity if ( version == 0 ) // Music wasn't serialized in version 0, pick a new track of random rarity
{ {
DawnsMusicRarity rarity; DawnsMusicRarity rarity;
double rand = Utility.RandomDouble(); double rand = Utility.RandomDouble();
if ( rand < 0.025 ) if ( rand < 0.025 )
rarity = DawnsMusicRarity.Rare; rarity = DawnsMusicRarity.Rare;
else if ( rand < 0.225 ) else if ( rand < 0.225 )
rarity = DawnsMusicRarity.Uncommon; rarity = DawnsMusicRarity.Uncommon;
else else
rarity = DawnsMusicRarity.Common; rarity = DawnsMusicRarity.Common;
m_Music = DawnsMusicBox.RandomTrack( rarity ); m_Music = DawnsMusicBox.RandomTrack( rarity );
} }
} }
@ -125,9 +125,7 @@ namespace Server.Items
if ( m_Gear == null || m_Gear.Deleted ) if ( m_Gear == null || m_Gear.Deleted )
return; return;
DawnsMusicBox box = targeted as DawnsMusicBox; if ( targeted is DawnsMusicBox box )
if ( box != null )
{ {
if ( !box.Tracks.Contains( m_Gear.Music ) ) if ( !box.Tracks.Contains( m_Gear.Music ) )
{ {

View file

@ -198,9 +198,7 @@ namespace Server.Items
if ( Items[i] is EnhancedBandage ) if ( Items[i] is EnhancedBandage )
continue; continue;
Bandage bandage = Items[i] as Bandage; if ( Items[i] is Bandage bandage )
if ( bandage != null )
{ {
Item enhanced; Item enhanced;

View file

@ -50,10 +50,8 @@ namespace Server.Items
{ {
base.OnRemoved( parent ); base.OnRemoved( parent );
if ( parent is Mobile ) if ( parent is Mobile m )
{ {
Mobile m = (Mobile) parent;
AnimalForm.RemoveContext( m, true ); AnimalForm.RemoveContext( m, true );
} }
} }
@ -62,11 +60,11 @@ namespace Server.Items
{ {
if ( type == typeof( Squirrel ) ) if ( type == typeof( Squirrel ) )
return m.Talisman is SquirrelFormTalisman; return m.Talisman is SquirrelFormTalisman;
else if ( type == typeof( Ferret ) ) if ( type == typeof( Ferret ) )
return m.Talisman is FerretFormTalisman; return m.Talisman is FerretFormTalisman;
else if ( type == typeof( CuSidhe ) ) if ( type == typeof( CuSidhe ) )
return m.Talisman is CuSidheFormTalisman; return m.Talisman is CuSidheFormTalisman;
else if ( type == typeof( Reptalon ) ) if ( type == typeof( Reptalon ) )
return m.Talisman is ReptalonFormTalisman; return m.Talisman is ReptalonFormTalisman;
return true; return true;

View file

@ -24,15 +24,14 @@ namespace Server.Items
if ( m_Bonus == 0 ) if ( m_Bonus == 0 )
{ {
if ( m_SkillMod != null ) m_SkillMod?.Remove();
m_SkillMod.Remove();
m_SkillMod = null; m_SkillMod = null;
} }
else if ( m_SkillMod == null && Parent is Mobile ) else if ( m_SkillMod == null && Parent is Mobile mobile )
{ {
m_SkillMod = new DefaultSkillMod( SkillName.Blacksmith, true, m_Bonus ); m_SkillMod = new DefaultSkillMod( SkillName.Blacksmith, true, m_Bonus );
((Mobile)Parent).AddSkillMod( m_SkillMod ); mobile.AddSkillMod( m_SkillMod );
} }
else if ( m_SkillMod != null ) else if ( m_SkillMod != null )
{ {
@ -45,13 +44,12 @@ namespace Server.Items
{ {
base.OnAdded( parent ); base.OnAdded( parent );
if ( m_Bonus != 0 && parent is Mobile ) if ( m_Bonus != 0 && parent is Mobile mobile )
{ {
if ( m_SkillMod != null ) m_SkillMod?.Remove();
m_SkillMod.Remove();
m_SkillMod = new DefaultSkillMod( SkillName.Blacksmith, true, m_Bonus ); m_SkillMod = new DefaultSkillMod( SkillName.Blacksmith, true, m_Bonus );
((Mobile)parent).AddSkillMod( m_SkillMod ); mobile.AddSkillMod( m_SkillMod );
} }
} }
@ -59,8 +57,7 @@ namespace Server.Items
{ {
base.OnRemoved( parent ); base.OnRemoved( parent );
if ( m_SkillMod != null ) m_SkillMod?.Remove();
m_SkillMod.Remove();
m_SkillMod = null; m_SkillMod = null;
} }
@ -118,13 +115,12 @@ namespace Server.Items
} }
} }
if ( m_Bonus != 0 && Parent is Mobile ) if ( m_Bonus != 0 && Parent is Mobile mobile )
{ {
if ( m_SkillMod != null ) m_SkillMod?.Remove();
m_SkillMod.Remove();
m_SkillMod = new DefaultSkillMod( SkillName.Blacksmith, true, m_Bonus ); m_SkillMod = new DefaultSkillMod( SkillName.Blacksmith, true, m_Bonus );
((Mobile)Parent).AddSkillMod( m_SkillMod ); mobile.AddSkillMod( m_SkillMod );
} }
if ( Hue == 0 ) if ( Hue == 0 )

View file

@ -159,15 +159,14 @@ namespace Server.Items
if ( m_Bonus == 0 ) if ( m_Bonus == 0 )
{ {
if ( m_SkillMod != null ) m_SkillMod?.Remove();
m_SkillMod.Remove();
m_SkillMod = null; m_SkillMod = null;
} }
else if ( m_SkillMod == null && Parent is Mobile ) else if ( m_SkillMod == null && Parent is Mobile mobile )
{ {
m_SkillMod = new DefaultSkillMod( SkillName.Mining, true, m_Bonus ); m_SkillMod = new DefaultSkillMod( SkillName.Mining, true, m_Bonus );
((Mobile)Parent).AddSkillMod( m_SkillMod ); mobile.AddSkillMod( m_SkillMod );
} }
else if ( m_SkillMod != null ) else if ( m_SkillMod != null )
{ {
@ -180,13 +179,12 @@ namespace Server.Items
{ {
base.OnAdded( parent ); base.OnAdded( parent );
if ( m_Bonus != 0 && parent is Mobile ) if ( m_Bonus != 0 && parent is Mobile mobile )
{ {
if ( m_SkillMod != null ) m_SkillMod?.Remove();
m_SkillMod.Remove();
m_SkillMod = new DefaultSkillMod( SkillName.Mining, true, m_Bonus ); m_SkillMod = new DefaultSkillMod( SkillName.Mining, true, m_Bonus );
((Mobile)parent).AddSkillMod( m_SkillMod ); mobile.AddSkillMod( m_SkillMod );
} }
} }
@ -194,8 +192,7 @@ namespace Server.Items
{ {
base.OnRemoved( parent ); base.OnRemoved( parent );
if ( m_SkillMod != null ) m_SkillMod?.Remove();
m_SkillMod.Remove();
m_SkillMod = null; m_SkillMod = null;
} }
@ -243,13 +240,12 @@ namespace Server.Items
} }
} }
if ( m_Bonus != 0 && Parent is Mobile ) if ( m_Bonus != 0 && Parent is Mobile mobile )
{ {
if ( m_SkillMod != null ) m_SkillMod?.Remove();
m_SkillMod.Remove();
m_SkillMod = new DefaultSkillMod( SkillName.Mining, true, m_Bonus ); m_SkillMod = new DefaultSkillMod( SkillName.Mining, true, m_Bonus );
((Mobile)Parent).AddSkillMod( m_SkillMod ); mobile.AddSkillMod( m_SkillMod );
} }
} }
} }