Fixes casting checks

This commit is contained in:
Kamron Batman 2018-08-19 01:38:55 +08:00
parent 7ea00fbf4f
commit 03dd5f1926
431 changed files with 5616 additions and 6250 deletions

View file

@ -48,27 +48,27 @@ namespace Server.Factions
{
from.SendLocalizedMessage( 1042160 ); // You already have a faction menu open.
}
else if ( from is PlayerMobile )
else if ( from is PlayerMobile mobile )
{
Faction existingFaction = Faction.Find( from );
Faction existingFaction = Faction.Find( mobile );
if ( existingFaction == m_Faction || from.AccessLevel >= AccessLevel.GameMaster )
if ( existingFaction == m_Faction || mobile.AccessLevel >= AccessLevel.GameMaster )
{
PlayerState pl = PlayerState.Find( from );
PlayerState pl = PlayerState.Find( mobile );
if ( pl != null && pl.IsLeaving )
from.SendLocalizedMessage( 1005051 ); // You cannot use the faction stone until you have finished quitting your current faction
mobile.SendLocalizedMessage( 1005051 ); // You cannot use the faction stone until you have finished quitting your current faction
else
from.SendGump( new FactionStoneGump( (PlayerMobile) from, m_Faction ) );
mobile.SendGump( new FactionStoneGump( mobile, m_Faction ) );
}
else if ( existingFaction != null )
{
// TODO: Validate
from.SendLocalizedMessage( 1005053 ); // This is not your faction stone!
mobile.SendLocalizedMessage( 1005053 ); // This is not your faction stone!
}
else
{
from.SendGump( new JoinStoneGump( (PlayerMobile) from, m_Faction ) );
mobile.SendGump( new JoinStoneGump( mobile, m_Faction ) );
}
}
}

View file

@ -45,8 +45,8 @@ namespace Server.Factions
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that.
else if ( FactionGump.Exists( from ) )
from.SendLocalizedMessage( 1042160 ); // You already have a faction menu open.
else if ( Faction.Find( from ) == null && from is PlayerMobile )
from.SendGump( new JoinStoneGump( (PlayerMobile) from, m_Faction ) );
else if ( Faction.Find( from ) == null && from is PlayerMobile mobile )
mobile.SendGump( new JoinStoneGump( mobile, m_Faction ) );
}
public JoinStone( Serial serial ) : base( serial )

View file

@ -49,7 +49,7 @@ namespace Server {
from.PlaySound( 0x1EE );
from.AddStatMod( new StatMod( StatType.Int, "clarity-potion", amount, TimeSpan.FromMinutes( time ) ) );
Timer.DelayCall( TimeSpan.FromMinutes( time ), delegate() {
Timer.DelayCall( TimeSpan.FromMinutes( time ), delegate {
from.EndAction( typeof( ClarityPotion ) );
} );
@ -71,4 +71,4 @@ namespace Server {
int version = reader.ReadEncodedInt();
}
}
}
}

View file

@ -119,16 +119,16 @@ namespace Server {
public override void OnDoubleClick( Mobile from ) {
if ( !IsChildOf( from.Backpack ) ) {
from.SendLocalizedMessage( 1042038 ); // You must have the object in your backpack to use it.
} else if ( from is PlayerMobile && ((PlayerMobile)from).DuelContext != null ) {
from.SendMessage( "You can't use that." );
} else if ( from is PlayerMobile mobile && mobile.DuelContext != null ) {
mobile.SendMessage( "You can't use that." );
} else if ( Faction.Find( from ) == null ) {
from.LocalOverheadMessage( Server.Network.MessageType.Regular, 2119, false, "The object vanishes from your hands as you touch it." );
Timer.DelayCall( TimeSpan.FromSeconds( 1.0 ), delegate() {
Timer.DelayCall( TimeSpan.FromSeconds( 1.0 ), delegate {
from.LocalOverheadMessage( Server.Network.MessageType.Regular, 2118, false, "You feel a strange tingling sensation throughout your body." );
} );
Timer.DelayCall( TimeSpan.FromSeconds( 4.0 ), delegate() {
Timer.DelayCall( TimeSpan.FromSeconds( 4.0 ), delegate {
from.LocalOverheadMessage( Server.Network.MessageType.Regular, 2118, false, "Your skin begins to burn." );
} );
@ -162,4 +162,4 @@ namespace Server {
int version = reader.ReadEncodedInt();
}
}
}
}

View file

@ -30,9 +30,7 @@ namespace Server {
if ( this.Movable ) {
user.BeginTarget( 12, true, Server.Targeting.TargetFlags.None, delegate( Mobile from, object obj ) {
if ( this.Movable && !this.Deleted ) {
IPoint3D pt = obj as IPoint3D;
if ( pt != null ) {
if ( obj is IPoint3D pt ) {
SpellHelper.GetSurfaceTop( ref pt );
Point3D origin = new Point3D( pt );
@ -46,7 +44,7 @@ namespace Server {
this.ItemID & 0x3FFF, 7, 0, false, false, this.Hue - 1, 0
);
Timer.DelayCall( TimeSpan.FromSeconds( 0.5 ), delegate() {
Timer.DelayCall( TimeSpan.FromSeconds( 0.5 ), delegate {
this.Delete();
Effects.PlaySound( origin, facet, 530 );
@ -57,7 +55,7 @@ namespace Server {
14284, 96, 1, 0, 2
);
Timer.DelayCall( TimeSpan.FromSeconds( 1.0 ), delegate() {
Timer.DelayCall( TimeSpan.FromSeconds( 1.0 ), delegate {
List<Mobile> targets = new List<Mobile>();
foreach ( Mobile mob in facet.GetMobilesInRange( origin, 12 ) ) {
@ -88,7 +86,7 @@ namespace Server {
SpellHelper.Damage( TimeSpan.FromSeconds( 0.70 ), mob, from, damage / 3, 0, 0, 0, 0, 100 );
SpellHelper.Damage( TimeSpan.FromSeconds( 1.00 ), mob, from, damage / 3, 0, 0, 0, 0, 100 );
Timer.DelayCall( TimeSpan.FromSeconds( 0.50 ), delegate() {
Timer.DelayCall( TimeSpan.FromSeconds( 0.50 ), delegate {
mob.PlaySound( 0x1FB );
} );
}
@ -115,4 +113,4 @@ namespace Server {
int version = reader.ReadEncodedInt();
}
}
}
}

View file

@ -15,7 +15,7 @@ namespace Server.Factions
public static readonly TimeSpan CorruptionGrace = TimeSpan.FromMinutes( (Core.SE) ? 30.0 : 15.0 );
// Sigil must be held at a stronghold for this amount of time in order to become corrupted
public static readonly TimeSpan CorruptionPeriod = ( (Core.SE) ? TimeSpan.FromHours( 10.0 ) : TimeSpan.FromHours( 24.0 ) );
public static readonly TimeSpan CorruptionPeriod = ( (Core.SE) ? TimeSpan.FromHours( 10.0 ) : TimeSpan.FromHours( 24.0 ) );
// After a sigil has been corrupted it must be returned to the town within this period of time
public static readonly TimeSpan ReturnPeriod = TimeSpan.FromHours( 1.0 );
@ -177,11 +177,11 @@ namespace Server.Factions
private Mobile FindOwner( object parent )
{
if ( parent is Item )
return ((Item)parent).RootParent as Mobile;
if ( parent is Item item )
return item.RootParent as Mobile;
if ( parent is Mobile )
return (Mobile) parent;
if ( parent is Mobile mobile )
return mobile;
return null;
}
@ -227,7 +227,7 @@ namespace Server.Factions
{
Container pack = mob.Backpack;
return ( pack != null && pack.FindItemByType( typeof( Sigil ) ) != null );
return ( pack?.FindItemByType( typeof( Sigil ) ) != null );
}
private void BeginCorrupting( Faction faction )
@ -267,10 +267,8 @@ namespace Server.Factions
#region Give To Mobile
if ( obj is Mobile )
{
if ( obj is PlayerMobile )
if ( obj is PlayerMobile targ )
{
PlayerMobile targ = (PlayerMobile)obj;
Faction toFaction = Faction.Find( targ );
Faction fromFaction = Faction.Find( from );
@ -280,14 +278,13 @@ namespace Server.Factions
from.SendLocalizedMessage( 1005222 ); // You cannot give the sigil to someone not in your faction
else if ( Sigil.ExistsOn( targ ) )
from.SendLocalizedMessage( 1005220 ); // You cannot give this sigil to someone who already has a sigil
else if( !targ.Alive )
else if ( !targ.Alive )
from.SendLocalizedMessage( 1042248 ); // You cannot give a sigil to a dead person.
else if ( from.NetState != null && targ.NetState != null )
{
Container pack = targ.Backpack;
if ( pack != null )
pack.DropItem( this );
pack?.DropItem( this );
}
}
else
@ -299,19 +296,17 @@ namespace Server.Factions
else if ( obj is BaseMonolith )
{
#region Put in Stronghold
if ( obj is StrongholdMonolith )
if ( obj is StrongholdMonolith sm )
{
StrongholdMonolith m = (StrongholdMonolith)obj;
if ( m.Faction == null || m.Faction != Faction.Find( from ) )
if ( sm.Faction == null || sm.Faction != Faction.Find( from ) )
from.SendLocalizedMessage( 1042246 ); // You can't place that on an enemy monolith
else if ( m.Town == null || m.Town != m_Town )
else if ( sm.Town == null || sm.Town != m_Town )
from.SendLocalizedMessage( 1042247 ); // That is not the correct faction monolith
else
{
m.Sigil = this;
sm.Sigil = this;
Faction newController = m.Faction;
Faction newController = sm.Faction;
Faction oldController = m_Corrupting;
if ( oldController == null )
@ -343,17 +338,15 @@ namespace Server.Factions
#endregion
#region Put in Town
else if ( obj is TownMonolith )
else if ( obj is TownMonolith tm )
{
TownMonolith m = (TownMonolith)obj;
if ( m.Town == null || m.Town != m_Town )
if ( tm.Town == null || tm.Town != m_Town )
from.SendLocalizedMessage( 1042245 ); // This is not the correct town sigil monolith
else if ( m_Corrupted == null || m_Corrupted != Faction.Find( from ) )
from.SendLocalizedMessage( 1042244 ); // Your faction did not corrupt this sigil. Take it to your stronghold.
else
{
m.Sigil = this;
tm.Sigil = this;
m_Corrupting = null;
m_PurificationStart = DateTime.UtcNow;
@ -367,7 +360,7 @@ namespace Server.Factions
}
else
{
from.SendLocalizedMessage( 1005224 ); // You can't use the sigil on that
from.SendLocalizedMessage( 1005224 ); // You can't use the sigil on that
}
Update();
@ -419,9 +412,7 @@ namespace Server.Factions
Update();
Mobile mob = RootParent as Mobile;
if ( mob != null )
if ( RootParent is Mobile mob )
mob.SolidHueOverride = OwnershipHue;
break;
@ -468,4 +459,4 @@ namespace Server.Factions
public static List<Sigil> Sigils{ get{ return m_Sigils; } }
}
}
}

View file

@ -51,8 +51,8 @@ namespace Server.Factions
from.SendLocalizedMessage( 1005242 ); // Only faction Leaders can use townstones
else if ( FactionGump.Exists( from ) )
from.SendLocalizedMessage( 1042160 ); // You already have a faction menu open.
else if ( from is PlayerMobile )
from.SendGump( new TownStoneGump( (PlayerMobile)from, m_Town.Owner, m_Town ) );
else if ( @from is PlayerMobile mobile )
mobile.SendGump( new TownStoneGump( mobile, m_Town.Owner, m_Town ) );
}
public TownStone( Serial serial ) : base( serial )

View file

@ -110,7 +110,7 @@ namespace Server.Factions
public abstract void DoVisibleEffect();
public abstract void DoAttackEffect( Mobile m );
public virtual int IsValidLocation()
{
return IsValidLocation( GetWorldLocation(), Map );
@ -118,14 +118,14 @@ namespace Server.Factions
public virtual int IsValidLocation( Point3D p, Map m )
{
if( m == null )
if ( m == null )
return 502956; // You cannot place a trap on that.
if( Core.ML )
if ( Core.ML )
{
foreach( Item item in m.GetItemsInRange( p, 0 ) )
{
if( item is BaseFactionTrap && ((BaseFactionTrap)item).Faction == this.Faction )
if ( item is BaseFactionTrap trap && trap.Faction == this.Faction )
return 1075263; // There is already a trap belonging to your faction at this location.;
}
}
@ -282,8 +282,8 @@ namespace Server.Factions
Faction faction = Faction.Find( mob, true );
if ( faction == null && mob is BaseFactionGuard )
faction = ((BaseFactionGuard)mob).Faction;
if ( faction == null && mob is BaseFactionGuard guard )
faction = guard.Faction;
if ( faction == null )
return false;
@ -291,4 +291,4 @@ namespace Server.Factions
return ( faction != m_Faction );
}
}
}
}

View file

@ -54,9 +54,9 @@ namespace Server.Factions
from.SendLocalizedMessage( 1010353, "", 0x23 ); // Only faction members may place faction traps
else if ( faction != m_Faction )
from.SendLocalizedMessage( 1010354, "", 0x23 ); // You may only place faction traps created by your faction
else if( faction.Traps.Count >= faction.MaximumTraps )
else if ( faction.Traps.Count >= faction.MaximumTraps )
from.SendLocalizedMessage( 1010358, "", 0x23 ); // Your faction already has the maximum number of traps placed
else
else
{
BaseFactionTrap trap = Construct( from );
@ -109,4 +109,4 @@ namespace Server.Factions
#endregion
}
}
}