Fixes casting, default parameters and null propogation in more files.
This commit is contained in:
parent
067dca8393
commit
403e2a8b9d
21 changed files with 328 additions and 523 deletions
|
|
@ -8,11 +8,7 @@ namespace Server.Guilds
|
|||
{
|
||||
public class CreateGuildGump : Gump
|
||||
{
|
||||
public CreateGuildGump( PlayerMobile pm ) : this( pm, "Guild Name", "" )
|
||||
{
|
||||
}
|
||||
|
||||
public CreateGuildGump( PlayerMobile pm, string guildName, string guildAbbrev ) : base( 10, 10 )
|
||||
public CreateGuildGump( PlayerMobile pm, string guildName = "Guild Name", string guildAbbrev = "") : base ( 10, 10 )
|
||||
{
|
||||
pm.CloseGump( typeof( CreateGuildGump ) );
|
||||
pm.CloseGump( typeof( BaseGuildGump ) );
|
||||
|
|
|
|||
|
|
@ -216,9 +216,7 @@ namespace Server.Misc
|
|||
|
||||
op.Write( "+ {0}:", state );
|
||||
|
||||
Account a = state.Account as Account;
|
||||
|
||||
if ( a != null )
|
||||
if ( state.Account is Account a )
|
||||
op.Write( " (account = {0})", a.Username );
|
||||
|
||||
Mobile m = state.Mobile;
|
||||
|
|
|
|||
|
|
@ -62,9 +62,9 @@ namespace Server.Items
|
|||
{
|
||||
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;
|
||||
}
|
||||
else
|
||||
|
|
@ -241,9 +241,7 @@ namespace Server.Items
|
|||
|
||||
public void Placement_OnTarget( Mobile from, object targeted, object state )
|
||||
{
|
||||
IPoint3D p = targeted as IPoint3D;
|
||||
|
||||
if ( p == null )
|
||||
if ( !(targeted is IPoint3D p) )
|
||||
return;
|
||||
|
||||
Point3D loc = new Point3D( p );
|
||||
|
|
|
|||
|
|
@ -107,9 +107,8 @@ namespace Server.Items
|
|||
{
|
||||
from.SendLocalizedMessage( 1005576 ); // You can't throw this at yourself.
|
||||
}
|
||||
else if ( target is Mobile )
|
||||
else if ( target is Mobile targ )
|
||||
{
|
||||
Mobile targ = (Mobile) target;
|
||||
Container pack = targ.Backpack;
|
||||
|
||||
if ( from.Region.IsPartOf( typeof( Engines.ConPVP.SafeZone ) ) || targ.Region.IsPartOf( typeof( Engines.ConPVP.SafeZone ) ) )
|
||||
|
|
|
|||
|
|
@ -93,16 +93,15 @@ namespace Server.Items
|
|||
{
|
||||
from.SendLocalizedMessage( 1005576 ); // You can't throw this at yourself.
|
||||
}
|
||||
else if ( target is Mobile )
|
||||
else if ( target is Mobile targ )
|
||||
{
|
||||
Mobile targ = (Mobile) target;
|
||||
Container pack = targ.Backpack;
|
||||
|
||||
if ( from.Region.IsPartOf( typeof( Engines.ConPVP.SafeZone ) ) || targ.Region.IsPartOf( typeof( Engines.ConPVP.SafeZone ) ) )
|
||||
{
|
||||
from.SendMessage( "You may not throw snow here." );
|
||||
}
|
||||
else if ( pack != null && pack.FindItemByType( new Type[]{ typeof( SnowPile ), typeof( PileOfGlacialSnow ) } ) != null )
|
||||
else if ( pack?.FindItemByType( new Type[]{ typeof( SnowPile ), typeof( PileOfGlacialSnow ) } ) != null )
|
||||
{
|
||||
if ( from.BeginAction( typeof( SnowPile ) ) )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -598,27 +598,15 @@ namespace Server.Guilds
|
|||
}
|
||||
else
|
||||
{
|
||||
Guild g = null;
|
||||
|
||||
int id;
|
||||
|
||||
if ( int.TryParse( arg, out id ) )
|
||||
g = Guild.Find( id ) as Guild;
|
||||
|
||||
if ( g == null )
|
||||
{
|
||||
g = Guild.FindByAbbrev( arg ) as Guild;
|
||||
|
||||
if ( g == null )
|
||||
g = Guild.FindByName( arg ) as Guild;
|
||||
}
|
||||
Guild g = int.TryParse( arg, out int id ) ? Find( id ) as Guild :
|
||||
FindByAbbrev( arg ) as Guild ?? FindByName( arg ) as Guild;
|
||||
|
||||
if ( g != null )
|
||||
{
|
||||
from.SendGump( new PropertiesGump( from, g ) );
|
||||
|
||||
if ( NewGuildSystem && from.AccessLevel >= AccessLevel.GameMaster && from is PlayerMobile )
|
||||
from.SendGump( new GuildInfoGump( (PlayerMobile)from, g ) );
|
||||
if ( NewGuildSystem && from.AccessLevel >= AccessLevel.GameMaster && from is PlayerMobile mobile )
|
||||
mobile.SendGump( new GuildInfoGump( mobile, g ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -640,33 +628,31 @@ namespace Server.Guilds
|
|||
|
||||
Guild g = null;
|
||||
|
||||
if ( o is Guildstone )
|
||||
if ( o is Guildstone stone )
|
||||
{
|
||||
Guildstone stone = o as Guildstone;
|
||||
if ( stone.Guild == null || stone.Guild.Disbanded )
|
||||
{
|
||||
from.SendMessage( "The guild associated with that Guildstone no longer exists" );
|
||||
return;
|
||||
}
|
||||
else
|
||||
g = stone.Guild;
|
||||
|
||||
g = stone.Guild;
|
||||
}
|
||||
else if ( o is Mobile )
|
||||
else if ( o is Mobile mobile )
|
||||
{
|
||||
g = ((Mobile)o).Guild as Guild;
|
||||
g = mobile.Guild as Guild;
|
||||
}
|
||||
|
||||
if ( g != null )
|
||||
if (g == null)
|
||||
{
|
||||
from.SendGump( new PropertiesGump( from, g ) );
|
||||
from.SendMessage("That is not in a guild!");
|
||||
return;
|
||||
}
|
||||
|
||||
if ( NewGuildSystem && from.AccessLevel >= AccessLevel.GameMaster && from is PlayerMobile )
|
||||
from.SendGump( new GuildInfoGump( (PlayerMobile)from, g ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendMessage( "That is not in a guild!" );
|
||||
}
|
||||
from.SendGump( new PropertiesGump( from, g ) );
|
||||
|
||||
if ( NewGuildSystem && from.AccessLevel >= AccessLevel.GameMaster && @from is PlayerMobile pm )
|
||||
pm.SendGump( new GuildInfoGump( pm, g ) );
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
|
@ -674,8 +660,7 @@ namespace Server.Guilds
|
|||
#region EventSinks
|
||||
public static void EventSink_GuildGumpRequest( GuildGumpRequestArgs args )
|
||||
{
|
||||
PlayerMobile pm = args.Mobile as PlayerMobile;
|
||||
if ( !NewGuildSystem || pm == null )
|
||||
if ( !NewGuildSystem || !(args.Mobile is PlayerMobile pm) )
|
||||
return;
|
||||
|
||||
if ( pm.Guild == null )
|
||||
|
|
@ -707,10 +692,8 @@ namespace Server.Guilds
|
|||
get{
|
||||
if ( m_AllianceInfo != null )
|
||||
return m_AllianceInfo;
|
||||
else if ( m_AllianceLeader != null )
|
||||
return m_AllianceLeader.m_AllianceInfo;
|
||||
else
|
||||
return null;
|
||||
|
||||
return m_AllianceLeader?.m_AllianceInfo;
|
||||
}
|
||||
set
|
||||
{
|
||||
|
|
@ -719,10 +702,7 @@ namespace Server.Guilds
|
|||
if ( value == current )
|
||||
return;
|
||||
|
||||
if ( current != null )
|
||||
{
|
||||
current.RemoveGuild( this );
|
||||
}
|
||||
current?.RemoveGuild( this );
|
||||
|
||||
if ( value != null )
|
||||
{
|
||||
|
|
@ -747,11 +727,7 @@ namespace Server.Guilds
|
|||
{
|
||||
get
|
||||
{
|
||||
AllianceInfo al = this.Alliance;
|
||||
if ( al != null )
|
||||
return al.Name;
|
||||
|
||||
return null;
|
||||
return Alliance?.Name;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -760,12 +736,7 @@ namespace Server.Guilds
|
|||
{
|
||||
get
|
||||
{
|
||||
AllianceInfo al = this.Alliance;
|
||||
|
||||
if ( al != null )
|
||||
return al.Leader;
|
||||
|
||||
return null;
|
||||
return Alliance?.Leader;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -774,12 +745,7 @@ namespace Server.Guilds
|
|||
{
|
||||
get
|
||||
{
|
||||
AllianceInfo al = this.Alliance;
|
||||
|
||||
if ( al != null )
|
||||
return al.IsMember( this );
|
||||
|
||||
return false;
|
||||
return Alliance?.IsMember( this ) == true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -788,12 +754,7 @@ namespace Server.Guilds
|
|||
{
|
||||
get
|
||||
{
|
||||
AllianceInfo al = this.Alliance;
|
||||
|
||||
if ( al != null )
|
||||
return al.IsPendingMember( this );
|
||||
|
||||
return false;
|
||||
return Alliance?.IsPendingMember( this ) == true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -801,7 +762,7 @@ namespace Server.Guilds
|
|||
{
|
||||
AllianceInfo alliance = g.Alliance;
|
||||
|
||||
if ( alliance != null && alliance.Leader != null && alliance.IsMember( g ) )
|
||||
if ( alliance?.Leader != null && alliance.IsMember( g ) )
|
||||
return alliance.Leader;
|
||||
|
||||
return g;
|
||||
|
|
@ -859,9 +820,9 @@ namespace Server.Guilds
|
|||
if ( status != WarStatus.InProgress )
|
||||
{
|
||||
AllianceInfo myAlliance = this.Alliance;
|
||||
bool inAlliance = ( myAlliance != null && myAlliance.IsMember( this ) );
|
||||
bool inAlliance = myAlliance?.IsMember( this ) == true;
|
||||
|
||||
AllianceInfo otherAlliance = ((g != null) ? g.Alliance : null);
|
||||
AllianceInfo otherAlliance = g?.Alliance;
|
||||
bool otherInAlliance = ( otherAlliance != null && otherAlliance.IsMember( this ) );
|
||||
|
||||
if ( inAlliance )
|
||||
|
|
@ -908,10 +869,7 @@ namespace Server.Guilds
|
|||
//All sanity in here
|
||||
this.PendingWars.Remove( w );
|
||||
|
||||
if ( g != null )
|
||||
{
|
||||
g.PendingWars.Remove( g.FindPendingWar( this ) );
|
||||
}
|
||||
g?.PendingWars.Remove( g.FindPendingWar( this ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1006,8 +964,8 @@ namespace Server.Guilds
|
|||
|
||||
AddMember( m_Leader );
|
||||
|
||||
if ( m_Leader is PlayerMobile )
|
||||
((PlayerMobile)m_Leader).GuildRank = RankDefinition.Leader;
|
||||
if ( m_Leader is PlayerMobile mobile )
|
||||
mobile.GuildRank = RankDefinition.Leader;
|
||||
|
||||
m_AcceptedWars = new List<WarDeclaration>();
|
||||
m_PendingWars = new List<WarDeclaration>();
|
||||
|
|
@ -1018,12 +976,7 @@ namespace Server.Guilds
|
|||
{
|
||||
}
|
||||
|
||||
public void InvalidateMemberProperties()
|
||||
{
|
||||
InvalidateMemberProperties( false );
|
||||
}
|
||||
|
||||
public void InvalidateMemberProperties( bool onlyOPL )
|
||||
public void InvalidateMemberProperties( bool onlyOPL = false)
|
||||
{
|
||||
if ( m_Members != null )
|
||||
{
|
||||
|
|
@ -1042,7 +995,7 @@ namespace Server.Guilds
|
|||
{
|
||||
if ( m_Members != null )
|
||||
{
|
||||
for (int i=0;i<m_Members.Count;i++)
|
||||
for (int i=0; i < m_Members.Count; i++)
|
||||
m_Members[i].Delta( MobileDelta.Noto );
|
||||
}
|
||||
}
|
||||
|
|
@ -1085,13 +1038,13 @@ namespace Server.Guilds
|
|||
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;
|
||||
if ( m_Leader is PlayerMobile leader && leader?.Guild == this )
|
||||
leader.GuildRank = RankDefinition.Member;
|
||||
|
||||
m_Leader = value;
|
||||
|
||||
if ( m_Leader is PlayerMobile )
|
||||
((PlayerMobile)m_Leader).GuildRank = RankDefinition.Leader;
|
||||
if ( m_Leader is PlayerMobile mobile )
|
||||
mobile.GuildRank = RankDefinition.Leader;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1120,8 +1073,8 @@ namespace Server.Guilds
|
|||
{
|
||||
m.SendLocalizedMessage( 502131 ); // Your guild has disbanded.
|
||||
|
||||
if ( m is PlayerMobile )
|
||||
((PlayerMobile)m).GuildRank = RankDefinition.Lowest;
|
||||
if ( m is PlayerMobile mobile )
|
||||
mobile.GuildRank = RankDefinition.Lowest;
|
||||
|
||||
m.Guild = null;
|
||||
}
|
||||
|
|
@ -1136,8 +1089,8 @@ namespace Server.Guilds
|
|||
if ( i < m_Enemies.Count )
|
||||
RemoveEnemy( m_Enemies[i] );
|
||||
|
||||
if ( !NewGuildSystem && m_Guildstone != null )
|
||||
m_Guildstone.Delete();
|
||||
if ( !NewGuildSystem )
|
||||
m_Guildstone?.Delete();
|
||||
|
||||
m_Guildstone = null;
|
||||
|
||||
|
|
@ -1198,8 +1151,7 @@ namespace Server.Guilds
|
|||
|
||||
CheckExpiredWars();
|
||||
|
||||
if ( Alliance != null )
|
||||
Alliance.CheckLeader();
|
||||
Alliance?.CheckLeader();
|
||||
|
||||
writer.Write( (int) 5 );//version
|
||||
|
||||
|
|
@ -1324,8 +1276,8 @@ namespace Server.Guilds
|
|||
{
|
||||
m_Leader = reader.ReadMobile();
|
||||
|
||||
if ( m_Leader is PlayerMobile )
|
||||
((PlayerMobile)m_Leader).GuildRank = RankDefinition.Leader;
|
||||
if ( m_Leader is PlayerMobile mobile )
|
||||
mobile.GuildRank = RankDefinition.Leader;
|
||||
|
||||
m_Name = reader.ReadString();
|
||||
m_Abbreviation = reader.ReadString();
|
||||
|
|
@ -1380,8 +1332,7 @@ namespace Server.Guilds
|
|||
|
||||
AllianceInfo alliance = this.Alliance;
|
||||
|
||||
if ( alliance != null )
|
||||
alliance.CheckLeader();
|
||||
alliance?.CheckLeader();
|
||||
|
||||
alliance = this.Alliance; //CheckLeader could possibly change the value of this.Alliance
|
||||
|
||||
|
|
@ -1408,13 +1359,10 @@ namespace Server.Guilds
|
|||
else
|
||||
m.GuildFealty = null;
|
||||
|
||||
if ( m is PlayerMobile )
|
||||
((PlayerMobile)m).GuildRank = RankDefinition.Lowest;
|
||||
if ( m is PlayerMobile mobile )
|
||||
mobile.GuildRank = RankDefinition.Lowest;
|
||||
|
||||
Guild guild = m.Guild as Guild;
|
||||
|
||||
if ( guild != null )
|
||||
guild.InvalidateWarNotoriety();
|
||||
((Guild)m.Guild).InvalidateWarNotoriety();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1432,8 +1380,8 @@ namespace Server.Guilds
|
|||
|
||||
m.Guild = null;
|
||||
|
||||
if ( m is PlayerMobile )
|
||||
((PlayerMobile)m).GuildRank = RankDefinition.Lowest;
|
||||
if ( m is PlayerMobile mobile )
|
||||
mobile.GuildRank = RankDefinition.Lowest;
|
||||
|
||||
if ( message > 0 )
|
||||
m.SendLocalizedMessage( message );
|
||||
|
|
@ -1449,8 +1397,7 @@ namespace Server.Guilds
|
|||
if ( m_Members.Count == 0 )
|
||||
Disband();
|
||||
|
||||
if ( guild != null )
|
||||
guild.InvalidateWarNotoriety();
|
||||
guild?.InvalidateWarNotoriety();
|
||||
|
||||
m.Delta( MobileDelta.Noto );
|
||||
}
|
||||
|
|
@ -1508,24 +1455,14 @@ namespace Server.Guilds
|
|||
for ( int i = 0; i < m_Members.Count; ++i )
|
||||
m_Members[i].SendLocalizedMessage( number );
|
||||
}
|
||||
public void GuildMessage( int number, string args )
|
||||
{
|
||||
GuildMessage( number, args, 0x3B2 );
|
||||
}
|
||||
public void GuildMessage( int number, string args, int hue )
|
||||
|
||||
public void GuildMessage( int number, string args, int hue = 0x3B2)
|
||||
{
|
||||
for ( int i = 0; i < m_Members.Count; ++i )
|
||||
m_Members[i].SendLocalizedMessage( number, args, hue );
|
||||
}
|
||||
public void GuildMessage( int number, bool append, string affix )
|
||||
{
|
||||
GuildMessage( number, append, affix, "", 0x3B2 );
|
||||
}
|
||||
public void GuildMessage( int number, bool append, string affix, string args )
|
||||
{
|
||||
GuildMessage( number, append, affix, args, 0x3B2 );
|
||||
}
|
||||
public void GuildMessage( int number, bool append, string affix, string args, int hue )
|
||||
|
||||
public void GuildMessage( int number, bool append, string affix, string args = "", int hue = 0x3B2)
|
||||
{
|
||||
for ( int i = 0; i < m_Members.Count; ++i )
|
||||
m_Members[i].SendLocalizedMessage( number, append, affix, args, hue );
|
||||
|
|
@ -1552,7 +1489,7 @@ namespace Server.Guilds
|
|||
public void GuildChat( Mobile from, int hue, string text )
|
||||
{
|
||||
Packet p = null;
|
||||
for( int i = 0; i < m_Members.Count; i++ )
|
||||
for ( int i = 0; i < m_Members.Count; i++ )
|
||||
{
|
||||
Mobile m = m_Members[i];
|
||||
|
||||
|
|
@ -1574,7 +1511,7 @@ namespace Server.Guilds
|
|||
{
|
||||
PlayerMobile pm = from as PlayerMobile;
|
||||
|
||||
GuildChat( from, (pm == null) ? 0x3B2 : pm.GuildMessageHue, text );
|
||||
GuildChat( from, pm?.GuildMessageHue ?? 0x3B2, text );
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
|
@ -1583,8 +1520,7 @@ namespace Server.Guilds
|
|||
{
|
||||
if ( NewGuildSystem )
|
||||
{
|
||||
PlayerMobile pm = m as PlayerMobile;
|
||||
if ( pm == null || !pm.GuildRank.GetFlag( RankFlags.CanVote ) )
|
||||
if ( !(m is PlayerMobile pm) || !pm.GuildRank.GetFlag( RankFlags.CanVote ) )
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -1594,8 +1530,7 @@ namespace Server.Guilds
|
|||
{
|
||||
if ( NewGuildSystem )
|
||||
{
|
||||
PlayerMobile pm = m as PlayerMobile;
|
||||
if ( pm == null || pm.LastOnline + InactiveTime < DateTime.UtcNow )
|
||||
if ( !(m is PlayerMobile pm) || pm.LastOnline + InactiveTime < DateTime.UtcNow )
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -1641,8 +1576,8 @@ namespace Server.Guilds
|
|||
|
||||
foreach ( KeyValuePair<Mobile, int> kvp in votes )
|
||||
{
|
||||
Mobile m = (Mobile)kvp.Key;
|
||||
int val = (int)kvp.Value;
|
||||
Mobile m = kvp.Key;
|
||||
int val = kvp.Value;
|
||||
|
||||
if ( winner == null || val > highVotes )
|
||||
{
|
||||
|
|
@ -1703,8 +1638,7 @@ namespace Server.Guilds
|
|||
|
||||
InvalidateMemberProperties( true );
|
||||
|
||||
if ( m_Guildstone != null )
|
||||
m_Guildstone.InvalidateProperties();
|
||||
m_Guildstone?.InvalidateProperties();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1734,8 +1668,7 @@ namespace Server.Guilds
|
|||
|
||||
InvalidateMemberProperties( true );
|
||||
|
||||
if ( m_Guildstone != null )
|
||||
m_Guildstone.InvalidateProperties();
|
||||
m_Guildstone?.InvalidateProperties();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1864,7 +1797,6 @@ namespace Server.Guilds
|
|||
return m_Members;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,12 +117,9 @@ namespace Server
|
|||
|
||||
public static void HWInfo_OnTarget( Mobile from, object obj )
|
||||
{
|
||||
if ( obj is Mobile && ((Mobile)obj).Player )
|
||||
if ( obj is Mobile m && m.Player )
|
||||
{
|
||||
Mobile m = (Mobile)obj;
|
||||
Account acct = m.Account as Account;
|
||||
|
||||
if ( acct != null )
|
||||
if ( m.Account is Account acct )
|
||||
{
|
||||
HardwareInfo hwInfo = acct.HardwareInfo;
|
||||
|
||||
|
|
@ -180,9 +177,7 @@ namespace Server
|
|||
|
||||
info.m_TimeReceived = DateTime.UtcNow;
|
||||
|
||||
Account acct = state.Account as Account;
|
||||
|
||||
if ( acct != null )
|
||||
if ( state.Account is Account acct )
|
||||
acct.HardwareInfo = info;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,8 +26,7 @@ namespace Server.Misc
|
|||
{
|
||||
case 0x002A: // *i resign from my guild*
|
||||
{
|
||||
if ( from.Guild != null )
|
||||
((Guild)from.Guild).RemoveMember( from );
|
||||
((Guild)@from.Guild)?.RemoveMember( @from );
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
@ -46,9 +45,9 @@ namespace Server.Misc
|
|||
}
|
||||
case 0x0035: // i renounce my young player status*
|
||||
{
|
||||
if ( from is PlayerMobile && ((PlayerMobile)from).Young && !from.HasGump( typeof( RenounceYoungGump ) ) )
|
||||
if ( @from is PlayerMobile mobile && mobile.Young && !mobile.HasGump( typeof( RenounceYoungGump ) ) )
|
||||
{
|
||||
from.SendGump( new RenounceYoungGump() );
|
||||
mobile.SendGump( new RenounceYoungGump() );
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -16,8 +16,7 @@ namespace Server
|
|||
|
||||
int luck = killer.Luck;
|
||||
|
||||
PlayerMobile pmKiller = killer as PlayerMobile;
|
||||
if ( pmKiller != null && pmKiller.SentHonorContext != null && pmKiller.SentHonorContext.Target == victim )
|
||||
if ( killer is PlayerMobile pmKiller && pmKiller.SentHonorContext != null && pmKiller.SentHonorContext.Target == victim )
|
||||
luck += pmKiller.SentHonorContext.PerfectionLuckBonus;
|
||||
|
||||
if ( luck < 0 )
|
||||
|
|
@ -661,21 +660,19 @@ namespace Server
|
|||
if ( props > m_MaxProps )
|
||||
props = m_MaxProps;
|
||||
|
||||
if ( item is BaseWeapon )
|
||||
BaseRunicTool.ApplyAttributesTo( (BaseWeapon)item, false, luckChance, props, m_MinIntensity, m_MaxIntensity );
|
||||
else if ( item is BaseArmor )
|
||||
BaseRunicTool.ApplyAttributesTo( (BaseArmor)item, false, luckChance, props, m_MinIntensity, m_MaxIntensity );
|
||||
else if ( item is BaseJewel )
|
||||
BaseRunicTool.ApplyAttributesTo( (BaseJewel)item, false, luckChance, props, m_MinIntensity, m_MaxIntensity );
|
||||
else if ( item is BaseHat )
|
||||
if ( item is BaseWeapon weapon )
|
||||
BaseRunicTool.ApplyAttributesTo( weapon, false, luckChance, props, m_MinIntensity, m_MaxIntensity );
|
||||
else if ( item is BaseArmor armor )
|
||||
BaseRunicTool.ApplyAttributesTo( armor, false, luckChance, props, m_MinIntensity, m_MaxIntensity );
|
||||
else if ( item is BaseJewel jewel )
|
||||
BaseRunicTool.ApplyAttributesTo( jewel, false, luckChance, props, m_MinIntensity, m_MaxIntensity );
|
||||
else
|
||||
BaseRunicTool.ApplyAttributesTo( (BaseHat)item, false, luckChance, props, m_MinIntensity, m_MaxIntensity );
|
||||
}
|
||||
else // not aos
|
||||
{
|
||||
if ( item is BaseWeapon )
|
||||
if ( item is BaseWeapon weapon )
|
||||
{
|
||||
BaseWeapon weapon = (BaseWeapon)item;
|
||||
|
||||
if ( 80 > Utility.Random( 100 ) )
|
||||
weapon.AccuracyLevel = (WeaponAccuracyLevel)GetRandomOldBonus();
|
||||
|
||||
|
|
@ -691,10 +688,8 @@ namespace Server
|
|||
if ( from != null && weapon.AccuracyLevel == 0 && weapon.DamageLevel == 0 && weapon.DurabilityLevel == 0 && weapon.Slayer == SlayerName.None && 5 > Utility.Random( 100 ) )
|
||||
weapon.Slayer = SlayerGroup.GetLootSlayerType( from.GetType() );
|
||||
}
|
||||
else if ( item is BaseArmor )
|
||||
else if ( item is BaseArmor armor )
|
||||
{
|
||||
BaseArmor armor = (BaseArmor)item;
|
||||
|
||||
if ( 80 > Utility.Random( 100 ) )
|
||||
armor.ProtectionLevel = (ArmorProtectionLevel)GetRandomOldBonus();
|
||||
|
||||
|
|
@ -703,7 +698,7 @@ namespace Server
|
|||
}
|
||||
}
|
||||
}
|
||||
else if ( item is BaseInstrument )
|
||||
else if ( item is BaseInstrument instr )
|
||||
{
|
||||
SlayerName slayer = SlayerName.None;
|
||||
|
||||
|
|
@ -714,12 +709,10 @@ namespace Server
|
|||
|
||||
if ( slayer == SlayerName.None )
|
||||
{
|
||||
item.Delete();
|
||||
instr.Delete();
|
||||
return null;
|
||||
}
|
||||
|
||||
BaseInstrument instr = (BaseInstrument)item;
|
||||
|
||||
instr.Quality = InstrumentQuality.Regular;
|
||||
instr.Slayer = slayer;
|
||||
}
|
||||
|
|
@ -777,28 +770,23 @@ namespace Server
|
|||
|
||||
if ( rnd < p5 )
|
||||
return 5;
|
||||
else
|
||||
rnd -= p5;
|
||||
|
||||
rnd -= p5;
|
||||
|
||||
if ( rnd < p4 )
|
||||
return 4;
|
||||
else
|
||||
rnd -= p4;
|
||||
|
||||
rnd -= p4;
|
||||
|
||||
if ( rnd < p3 )
|
||||
return 3;
|
||||
else
|
||||
rnd -= p3;
|
||||
|
||||
rnd -= p3;
|
||||
|
||||
if ( rnd < p2 )
|
||||
return 2;
|
||||
else
|
||||
rnd -= p2;
|
||||
|
||||
if ( rnd < p1 )
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
return rnd - p2 < p1 ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -861,13 +849,11 @@ namespace Server
|
|||
|
||||
if ( index == 0 && rnd < m_BlankTypes.Length )
|
||||
return Loot.Construct( m_BlankTypes );
|
||||
else if ( index == 0 )
|
||||
if ( index == 0 )
|
||||
rnd -= m_BlankTypes.Length;
|
||||
|
||||
if ( Core.AOS && rnd < m_NecroTypes.Length )
|
||||
return Loot.Construct( m_NecroTypes[index] );
|
||||
else if ( Core.AOS )
|
||||
rnd -= m_NecroTypes[index].Length;
|
||||
|
||||
return Loot.RandomScroll( minCircle * 8, (maxCircle * 8) + 7, SpellbookType.Regular );
|
||||
}
|
||||
|
|
@ -959,12 +945,12 @@ namespace Server
|
|||
|
||||
m_Count = Utility.ToInt32( str.Substring( start, index-start ) );
|
||||
|
||||
bool negative;
|
||||
|
||||
start = index + 1;
|
||||
index = str.IndexOf( '+', start );
|
||||
|
||||
if ( negative = (index < start) )
|
||||
bool negative = index < start;
|
||||
|
||||
if ( negative )
|
||||
index = str.IndexOf( '-', start );
|
||||
|
||||
if ( index < start )
|
||||
|
|
|
|||
|
|
@ -42,9 +42,8 @@ namespace Server.Misc
|
|||
private static void OnGuildTrack( NetState state, PacketReader pvSrc )
|
||||
{
|
||||
Mobile from = state.Mobile;
|
||||
Guild guild = from.Guild as Guild;
|
||||
|
||||
if ( guild != null )
|
||||
if ( @from.Guild is Guild guild )
|
||||
{
|
||||
bool locations = pvSrc.ReadByte() != 0;
|
||||
|
||||
|
|
@ -78,7 +77,7 @@ namespace Server.Misc
|
|||
m_Stream.Write( (int) mob.Serial );
|
||||
m_Stream.Write( (short) mob.X );
|
||||
m_Stream.Write( (short) mob.Y );
|
||||
m_Stream.Write( (byte) ( mob.Map == null ? 0 : mob.Map.MapID ) );
|
||||
m_Stream.Write( (byte) (mob.Map?.MapID ?? 0) );
|
||||
}
|
||||
|
||||
m_Stream.Write( (int) 0 );
|
||||
|
|
@ -113,7 +112,7 @@ namespace Server.Misc
|
|||
{
|
||||
m_Stream.Write( (short) mob.X );
|
||||
m_Stream.Write( (short) mob.Y );
|
||||
m_Stream.Write( (byte) ( mob.Map == null ? 0 : mob.Map.MapID ) );
|
||||
m_Stream.Write( (byte) (mob.Map?.MapID ?? 0) );
|
||||
|
||||
if ( Settings.GuildHitsPercent && mob.Alive )
|
||||
m_Stream.Write( (byte) ( mob.Hits / Math.Max( mob.HitsMax, 1.0 ) * 100 ) );
|
||||
|
|
@ -127,4 +126,4 @@ namespace Server.Misc
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,9 +29,7 @@ namespace Server
|
|||
|
||||
public static void GiveArtifactTo( Mobile m )
|
||||
{
|
||||
Item item = Activator.CreateInstance( m_Artifacts[Utility.Random( m_Artifacts.Length )] ) as Item;
|
||||
|
||||
if ( item == null )
|
||||
if ( !(Activator.CreateInstance( m_Artifacts[Utility.Random( m_Artifacts.Length )] ) is Item item) )
|
||||
return;
|
||||
|
||||
if ( m.AddToBackpack( item ) )
|
||||
|
|
@ -51,14 +49,9 @@ namespace Server
|
|||
}
|
||||
}
|
||||
|
||||
public static bool CheckML( Mobile from )
|
||||
public static bool CheckML( Mobile from, bool message = true)
|
||||
{
|
||||
return CheckML( from, true );
|
||||
}
|
||||
|
||||
public static bool CheckML( Mobile from, bool message )
|
||||
{
|
||||
if ( from == null || from.NetState == null )
|
||||
if ( @from?.NetState == null )
|
||||
return false;
|
||||
|
||||
if ( from.NetState.SupportsExpansion( Expansion.ML ) )
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ using System;
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Server;
|
||||
using Server.Engines.ConPVP;
|
||||
using Server.Items;
|
||||
using Server.Guilds;
|
||||
using Server.Multis;
|
||||
|
|
@ -69,18 +70,14 @@ namespace Server.Misc
|
|||
PlayerMobile pmFrom = from as PlayerMobile;
|
||||
PlayerMobile pmTarg = target as PlayerMobile;
|
||||
|
||||
if ( pmFrom == null && from is BaseCreature )
|
||||
if ( pmFrom == null && @from is BaseCreature bcFrom )
|
||||
{
|
||||
BaseCreature bcFrom = (BaseCreature)from;
|
||||
|
||||
if ( bcFrom.Summoned )
|
||||
pmFrom = bcFrom.SummonMaster as PlayerMobile;
|
||||
}
|
||||
|
||||
if ( pmTarg == null && target is BaseCreature )
|
||||
if ( pmTarg == null && target is BaseCreature bcTarg )
|
||||
{
|
||||
BaseCreature bcTarg = (BaseCreature)target;
|
||||
|
||||
if ( bcTarg.Summoned )
|
||||
pmTarg = bcTarg.SummonMaster as PlayerMobile;
|
||||
}
|
||||
|
|
@ -103,12 +100,10 @@ namespace Server.Misc
|
|||
return true;
|
||||
}
|
||||
|
||||
if ( (pmFrom != null && pmFrom.DuelContext != null && pmFrom.DuelContext.Started) || (pmTarg != null && pmTarg.DuelContext != null && pmTarg.DuelContext.Started) )
|
||||
if ( (pmFrom?.DuelContext != null && pmFrom.DuelContext.Started) || (pmTarg?.DuelContext != null && pmTarg.DuelContext.Started) )
|
||||
return false;
|
||||
|
||||
Engines.ConPVP.SafeZone sz = from.Region.GetRegion( typeof( Engines.ConPVP.SafeZone ) ) as Engines.ConPVP.SafeZone;
|
||||
|
||||
if ( sz != null /*&& sz.IsDisabled()*/ )
|
||||
if ( @from.Region.GetRegion( typeof( Engines.ConPVP.SafeZone ) ) is SafeZone sz /*&& sz.IsDisabled()*/ )
|
||||
return false;
|
||||
|
||||
sz = target.Region.GetRegion( typeof( Engines.ConPVP.SafeZone ) ) as Engines.ConPVP.SafeZone;
|
||||
|
|
@ -136,16 +131,13 @@ namespace Server.Misc
|
|||
if ( !from.Player )
|
||||
return true; // NPCs have no restrictions
|
||||
|
||||
if ( target is BaseCreature && !((BaseCreature)target).Controlled )
|
||||
if ( target is BaseCreature creature && !creature.Controlled )
|
||||
return false; // Players cannot heal uncontrolled mobiles
|
||||
|
||||
if ( from is PlayerMobile && ((PlayerMobile)from).Young && (!(target is PlayerMobile) || !((PlayerMobile)target).Young) )
|
||||
if ( pmFrom?.Young == true || pmTarg?.Young == true )
|
||||
return false; // Young players cannot perform beneficial actions towards older players
|
||||
|
||||
Guild fromGuild = from.Guild as Guild;
|
||||
Guild targetGuild = target.Guild as Guild;
|
||||
|
||||
if ( fromGuild != null && targetGuild != null && (targetGuild == fromGuild || fromGuild.IsAlly( targetGuild )) )
|
||||
if ( @from.Guild is Guild fromGuild && target.Guild is Guild targetGuild && (targetGuild == fromGuild || fromGuild.IsAlly( targetGuild )) )
|
||||
return true; // Guild members can be beneficial
|
||||
|
||||
return CheckBeneficialStatus( GetGuildStatus( from ), GetGuildStatus( target ) );
|
||||
|
|
@ -159,22 +151,13 @@ namespace Server.Misc
|
|||
#region Dueling
|
||||
PlayerMobile pmFrom = from as PlayerMobile;
|
||||
PlayerMobile pmTarg = target as PlayerMobile;
|
||||
BaseCreature bcTarg = target as BaseCreature;
|
||||
|
||||
if ( pmFrom == null && from is BaseCreature )
|
||||
{
|
||||
BaseCreature bcFrom = (BaseCreature)from;
|
||||
if ( pmFrom == null && @from is BaseCreature bcFrom && bcFrom.Summoned )
|
||||
pmFrom = bcFrom.SummonMaster as PlayerMobile;
|
||||
|
||||
if ( bcFrom.Summoned )
|
||||
pmFrom = bcFrom.SummonMaster as PlayerMobile;
|
||||
}
|
||||
|
||||
if ( pmTarg == null && target is BaseCreature )
|
||||
{
|
||||
BaseCreature bcTarg = (BaseCreature)target;
|
||||
|
||||
if ( bcTarg.Summoned )
|
||||
pmTarg = bcTarg.SummonMaster as PlayerMobile;
|
||||
}
|
||||
if ( pmTarg == null && bcTarg?.Summoned == true )
|
||||
pmTarg = bcTarg.SummonMaster as PlayerMobile;
|
||||
|
||||
if ( pmFrom != null && pmTarg != null )
|
||||
{
|
||||
|
|
@ -191,12 +174,10 @@ namespace Server.Misc
|
|||
return true;
|
||||
}
|
||||
|
||||
if ( (pmFrom != null && pmFrom.DuelContext != null && pmFrom.DuelContext.Started) || (pmTarg != null && pmTarg.DuelContext != null && pmTarg.DuelContext.Started) )
|
||||
if ( (pmFrom?.DuelContext != null && pmFrom.DuelContext.Started) || (pmTarg?.DuelContext != null && pmTarg.DuelContext.Started) )
|
||||
return false;
|
||||
|
||||
Engines.ConPVP.SafeZone sz = from.Region.GetRegion( typeof( Engines.ConPVP.SafeZone ) ) as Engines.ConPVP.SafeZone;
|
||||
|
||||
if ( sz != null /*&& sz.IsDisabled()*/ )
|
||||
if ( @from.Region.GetRegion( typeof( Engines.ConPVP.SafeZone ) ) is SafeZone sz /*&& sz.IsDisabled()*/ )
|
||||
return false;
|
||||
|
||||
sz = target.Region.GetRegion( typeof( Engines.ConPVP.SafeZone ) ) as Engines.ConPVP.SafeZone;
|
||||
|
|
@ -210,11 +191,9 @@ namespace Server.Misc
|
|||
if ( map != null && (map.Rules & MapRules.HarmfulRestrictions) == 0 )
|
||||
return true; // In felucca, anything goes
|
||||
|
||||
BaseCreature bc = from as BaseCreature;
|
||||
|
||||
if ( !from.Player && !(bc != null && bc.GetMaster() != null && bc.GetMaster().AccessLevel == AccessLevel.Player ) )
|
||||
if ( !from.Player && !(@from is BaseCreature bc && bc.GetMaster() != null && bc.GetMaster().AccessLevel == AccessLevel.Player ) )
|
||||
{
|
||||
if ( !CheckAggressor( from.Aggressors, target ) && !CheckAggressed( from.Aggressed, target ) && target is PlayerMobile && ((PlayerMobile)target).CheckYoungProtection( from ) )
|
||||
if ( !CheckAggressor( from.Aggressors, target ) && !CheckAggressed( from.Aggressed, target ) && pmTarg?.CheckYoungProtection( from ) == true )
|
||||
return false;
|
||||
|
||||
return true; // Uncontrolled NPCs are only restricted by the young system
|
||||
|
|
@ -226,13 +205,13 @@ namespace Server.Misc
|
|||
if ( fromGuild != null && targetGuild != null && (fromGuild == targetGuild || fromGuild.IsAlly( targetGuild ) || fromGuild.IsEnemy( targetGuild )) )
|
||||
return true; // Guild allies or enemies can be harmful
|
||||
|
||||
if ( target is BaseCreature && (((BaseCreature)target).Controlled || (((BaseCreature)target).Summoned && from != ((BaseCreature)target).SummonMaster)) )
|
||||
if ( bcTarg?.Controlled == true || bcTarg?.Summoned == true && bcTarg?.SummonMaster != from )
|
||||
return false; // Cannot harm other controlled mobiles
|
||||
|
||||
if ( target.Player )
|
||||
return false; // Cannot harm other players
|
||||
|
||||
if ( !(target is BaseCreature && ((BaseCreature)target).InitialInnocent) )
|
||||
if ( bcTarg?.InitialInnocent != true )
|
||||
{
|
||||
if ( Notoriety.Compute( from, target ) == Notoriety.Innocent )
|
||||
return false; // Cannot harm innocent mobiles
|
||||
|
|
@ -245,9 +224,7 @@ namespace Server.Misc
|
|||
{
|
||||
Guild g = def;
|
||||
|
||||
BaseCreature c = m as BaseCreature;
|
||||
|
||||
if ( c != null && c.Controlled && c.ControlMaster != null )
|
||||
if ( m is BaseCreature c && c.Controlled && c.ControlMaster != null )
|
||||
{
|
||||
c.DisplayGuildTitle = false;
|
||||
|
||||
|
|
@ -265,119 +242,94 @@ namespace Server.Misc
|
|||
if ( target.AccessLevel > AccessLevel.Player )
|
||||
return Notoriety.CanBeAttacked;
|
||||
|
||||
Body body = (Body)target.Amount;
|
||||
Body body = target.Amount;
|
||||
|
||||
BaseCreature cretOwner = target.Owner as BaseCreature;
|
||||
Guild sourceGuild = GetGuildFor( source.Guild as Guild, source );
|
||||
Guild targetGuild = GetGuildFor( target.Guild, target.Owner );
|
||||
|
||||
if ( cretOwner != null )
|
||||
Faction srcFaction = Faction.Find( source, true, true );
|
||||
Faction trgFaction = Faction.Find( target.Owner, true, true );
|
||||
List<Mobile> list = target.Aggressors;
|
||||
|
||||
if ( sourceGuild != null && targetGuild != null )
|
||||
{
|
||||
Guild sourceGuild = GetGuildFor( source.Guild as Guild, source );
|
||||
Guild targetGuild = GetGuildFor( target.Guild as Guild, target.Owner );
|
||||
|
||||
if ( sourceGuild != null && targetGuild != null )
|
||||
{
|
||||
if ( sourceGuild == targetGuild || sourceGuild.IsAlly( targetGuild ) )
|
||||
return Notoriety.Ally;
|
||||
else if ( sourceGuild.IsEnemy( targetGuild ) )
|
||||
return Notoriety.Enemy;
|
||||
}
|
||||
|
||||
Faction srcFaction = Faction.Find( source, true, true );
|
||||
Faction trgFaction = Faction.Find( target.Owner, true, true );
|
||||
if ( sourceGuild == targetGuild || sourceGuild.IsAlly( targetGuild ) )
|
||||
return Notoriety.Ally;
|
||||
if ( sourceGuild.IsEnemy( targetGuild ) )
|
||||
return Notoriety.Enemy;
|
||||
}
|
||||
|
||||
if ( target.Owner is BaseCreature creature )
|
||||
{
|
||||
if ( srcFaction != null && trgFaction != null && srcFaction != trgFaction && source.Map == Faction.Facet )
|
||||
return Notoriety.Enemy;
|
||||
|
||||
if ( CheckHouseFlag( source, target.Owner, target.Location, target.Map ) )
|
||||
if ( CheckHouseFlag( source, creature, target.Location, target.Map ) )
|
||||
return Notoriety.CanBeAttacked;
|
||||
|
||||
int actual = Notoriety.CanBeAttacked;
|
||||
|
||||
if ( target.Kills >= 5 || (body.IsMonster && IsSummoned( target.Owner as BaseCreature )) || (target.Owner is BaseCreature && (((BaseCreature)target.Owner).AlwaysMurderer || ((BaseCreature)target.Owner).IsAnimatedDead)) )
|
||||
if ( target.Kills >= 5 || body.IsMonster && IsSummoned( creature ) || creature.AlwaysMurderer || creature.IsAnimatedDead )
|
||||
actual = Notoriety.Murderer;
|
||||
|
||||
if ( DateTime.UtcNow >= (target.TimeOfDeath + Corpse.MonsterLootRightSacrifice) )
|
||||
if ( DateTime.UtcNow >= target.TimeOfDeath + Corpse.MonsterLootRightSacrifice )
|
||||
return actual;
|
||||
|
||||
Party sourceParty = Party.Get( source );
|
||||
|
||||
List<Mobile> list = target.Aggressors;
|
||||
|
||||
for( int i = 0; i < list.Count; ++i )
|
||||
{
|
||||
if ( list[i] == source || (sourceParty != null && Party.Get( list[i] ) == sourceParty) )
|
||||
if ( list[i] == source || sourceParty != null && Party.Get( list[i] ) == sourceParty )
|
||||
return actual;
|
||||
}
|
||||
|
||||
return Notoriety.Innocent;
|
||||
}
|
||||
else
|
||||
|
||||
if ( target.Kills >= 5 || body.IsMonster )
|
||||
return Notoriety.Murderer;
|
||||
|
||||
if (target.Criminal && target.Map != null && (target.Map.Rules & MapRules.HarmfulRestrictions) == 0)
|
||||
return Notoriety.Criminal;
|
||||
|
||||
if ( srcFaction != null && trgFaction != null && srcFaction != trgFaction && source.Map == Faction.Facet )
|
||||
{
|
||||
if ( target.Kills >= 5 || (body.IsMonster && IsSummoned( target.Owner as BaseCreature )) || (target.Owner is BaseCreature && (((BaseCreature)target.Owner).AlwaysMurderer || ((BaseCreature)target.Owner).IsAnimatedDead)) )
|
||||
return Notoriety.Murderer;
|
||||
|
||||
if (target.Criminal && target.Map != null && ((target.Map.Rules & MapRules.HarmfulRestrictions) == 0))
|
||||
return Notoriety.Criminal;
|
||||
|
||||
Guild sourceGuild = GetGuildFor( source.Guild as Guild, source );
|
||||
Guild targetGuild = GetGuildFor( target.Guild as Guild, target.Owner );
|
||||
|
||||
if ( sourceGuild != null && targetGuild != null )
|
||||
for ( int i = 0; i < list.Count; ++i )
|
||||
{
|
||||
if ( sourceGuild == targetGuild || sourceGuild.IsAlly( targetGuild ) )
|
||||
return Notoriety.Ally;
|
||||
else if ( sourceGuild.IsEnemy( targetGuild ) )
|
||||
if ( list[i] == source || list[i] is BaseFactionGuard )
|
||||
return Notoriety.Enemy;
|
||||
}
|
||||
|
||||
Faction srcFaction = Faction.Find( source, true, true );
|
||||
Faction trgFaction = Faction.Find( target.Owner, true, true );
|
||||
|
||||
if ( srcFaction != null && trgFaction != null && srcFaction != trgFaction && source.Map == Faction.Facet )
|
||||
{
|
||||
List<Mobile> secondList = target.Aggressors;
|
||||
|
||||
for( int i = 0; i < secondList.Count; ++i )
|
||||
{
|
||||
if ( secondList[i] == source || secondList[i] is BaseFactionGuard )
|
||||
return Notoriety.Enemy;
|
||||
}
|
||||
}
|
||||
|
||||
if ( target.Owner != null && target.Owner is BaseCreature && ((BaseCreature)target.Owner).AlwaysAttackable )
|
||||
return Notoriety.CanBeAttacked;
|
||||
|
||||
if ( CheckHouseFlag( source, target.Owner, target.Location, target.Map ) )
|
||||
return Notoriety.CanBeAttacked;
|
||||
|
||||
if ( !(target.Owner is PlayerMobile) && !IsPet( target.Owner as BaseCreature ) )
|
||||
return Notoriety.CanBeAttacked;
|
||||
|
||||
List<Mobile> list = target.Aggressors;
|
||||
|
||||
for( int i = 0; i < list.Count; ++i )
|
||||
{
|
||||
if ( list[i] == source )
|
||||
return Notoriety.CanBeAttacked;
|
||||
}
|
||||
|
||||
return Notoriety.Innocent;
|
||||
}
|
||||
|
||||
if ( CheckHouseFlag( source, target.Owner, target.Location, target.Map ) )
|
||||
return Notoriety.CanBeAttacked;
|
||||
|
||||
if ( !(target.Owner is PlayerMobile) )
|
||||
return Notoriety.CanBeAttacked;
|
||||
|
||||
for ( int i = 0; i < list.Count; ++i )
|
||||
{
|
||||
if ( list[i] == source )
|
||||
return Notoriety.CanBeAttacked;
|
||||
}
|
||||
|
||||
return Notoriety.Innocent;
|
||||
}
|
||||
|
||||
/* Must be thread-safe */
|
||||
|
||||
public static int MobileNotoriety( Mobile source, Mobile target )
|
||||
{
|
||||
if ( Core.AOS && ( target.Blessed || ( target is BaseCreature && ( (BaseCreature)target ).IsInvulnerable ) || target is PlayerVendor || target is TownCrier ) )
|
||||
BaseCreature bcTarg = target as BaseCreature;
|
||||
|
||||
if ( Core.AOS && ( target.Blessed || bcTarg?.IsInvulnerable == true || target is PlayerVendor || target is TownCrier ) )
|
||||
return Notoriety.Invulnerable;
|
||||
|
||||
#region Dueling
|
||||
if ( source is PlayerMobile && target is PlayerMobile )
|
||||
{
|
||||
PlayerMobile pmFrom = (PlayerMobile)source;
|
||||
PlayerMobile pmTarg = (PlayerMobile)target;
|
||||
PlayerMobile pmFrom = source as PlayerMobile;
|
||||
PlayerMobile pmTarg = target as PlayerMobile;
|
||||
|
||||
#region Dueling
|
||||
if ( pmFrom != null && pmTarg != null )
|
||||
{
|
||||
if ( pmFrom.DuelContext != null && pmFrom.DuelContext.StartedBeginCountdown && !pmFrom.DuelContext.Finished && pmFrom.DuelContext == pmTarg.DuelContext )
|
||||
return pmFrom.DuelContext.IsAlly( pmFrom, pmTarg ) ? Notoriety.Ally : Notoriety.Enemy;
|
||||
}
|
||||
|
|
@ -386,30 +338,28 @@ namespace Server.Misc
|
|||
if ( target.AccessLevel > AccessLevel.Player )
|
||||
return Notoriety.CanBeAttacked;
|
||||
|
||||
if ( source.Player && !target.Player && source is PlayerMobile && target is BaseCreature )
|
||||
if ( source.Player && !target.Player && pmFrom != null && bcTarg != null )
|
||||
{
|
||||
BaseCreature bc = (BaseCreature)target;
|
||||
|
||||
Mobile master = bc.GetMaster();
|
||||
Mobile master = bcTarg.GetMaster();
|
||||
|
||||
if ( master != null && master.AccessLevel > AccessLevel.Player )
|
||||
return Notoriety.CanBeAttacked;
|
||||
|
||||
master = bc.ControlMaster;
|
||||
master = bcTarg.ControlMaster;
|
||||
|
||||
if ( Core.ML && master != null )
|
||||
{
|
||||
if ( ( source == master && CheckAggressor( target.Aggressors, source ) ) || ( CheckAggressor( source.Aggressors, bc ) ) )
|
||||
if ( ( source == master && CheckAggressor( bcTarg.Aggressors, source ) ) || ( CheckAggressor( source.Aggressors, bcTarg ) ) )
|
||||
return Notoriety.CanBeAttacked;
|
||||
else
|
||||
return MobileNotoriety( source, master );
|
||||
|
||||
return MobileNotoriety( source, master );
|
||||
}
|
||||
|
||||
if ( !bc.Summoned && !bc.Controlled && ((PlayerMobile)source).EnemyOfOneType == target.GetType() )
|
||||
if ( !bcTarg.Summoned && !bcTarg.Controlled && pmFrom.EnemyOfOneType == bcTarg.GetType() )
|
||||
return Notoriety.Enemy;
|
||||
}
|
||||
|
||||
if ( target.Kills >= 5 || ( target.Body.IsMonster && IsSummoned( target as BaseCreature ) && !( target is BaseFamiliar ) && !( target is ArcaneFey ) && !( target is Golem ) ) || ( target is BaseCreature && ( ( (BaseCreature)target ).AlwaysMurderer || ( (BaseCreature)target ).IsAnimatedDead ) ) )
|
||||
if ( target.Kills >= 5 || target.Body.IsMonster && IsSummoned( bcTarg ) && !( target is BaseFamiliar ) && !( target is ArcaneFey ) && !( target is Golem ) || bcTarg?.AlwaysMurderer == true || bcTarg?.IsAnimatedDead == true )
|
||||
return Notoriety.Murderer;
|
||||
|
||||
if ( target.Criminal )
|
||||
|
|
@ -422,7 +372,7 @@ namespace Server.Misc
|
|||
{
|
||||
if ( sourceGuild == targetGuild || sourceGuild.IsAlly( targetGuild ) )
|
||||
return Notoriety.Ally;
|
||||
else if ( sourceGuild.IsEnemy( targetGuild ) )
|
||||
if ( sourceGuild.IsEnemy( targetGuild ) )
|
||||
return Notoriety.Enemy;
|
||||
}
|
||||
|
||||
|
|
@ -432,18 +382,18 @@ namespace Server.Misc
|
|||
if ( srcFaction != null && trgFaction != null && srcFaction != trgFaction && source.Map == Faction.Facet )
|
||||
return Notoriety.Enemy;
|
||||
|
||||
if ( SkillHandlers.Stealing.ClassicMode && target is PlayerMobile && ((PlayerMobile)target).PermaFlags.Contains( source ) )
|
||||
if ( SkillHandlers.Stealing.ClassicMode && pmTarg?.PermaFlags.Contains( source ) == true )
|
||||
return Notoriety.CanBeAttacked;
|
||||
|
||||
if ( target is BaseCreature && ((BaseCreature)target).AlwaysAttackable )
|
||||
if ( bcTarg?.AlwaysAttackable == true )
|
||||
return Notoriety.CanBeAttacked;
|
||||
|
||||
if ( CheckHouseFlag( source, target, target.Location, target.Map ) )
|
||||
return Notoriety.CanBeAttacked;
|
||||
|
||||
if ( !(target is BaseCreature && ((BaseCreature)target).InitialInnocent) ) //If Target is NOT A baseCreature, OR it's a BC and the BC is initial innocent...
|
||||
if ( bcTarg?.InitialInnocent != true )
|
||||
{
|
||||
if ( !target.Body.IsHuman && !target.Body.IsGhost && !IsPet( target as BaseCreature ) && !(target is PlayerMobile) || !Core.ML && !target.CanBeginAction( typeof( Server.Spells.Seventh.PolymorphSpell ) ) )
|
||||
if ( !target.Body.IsHuman && !target.Body.IsGhost && !IsPet( bcTarg ) && pmTarg == null || !Core.ML && !target.CanBeginAction( typeof( Server.Spells.Seventh.PolymorphSpell ) ) )
|
||||
return Notoriety.CanBeAttacked;
|
||||
}
|
||||
|
||||
|
|
@ -453,22 +403,15 @@ namespace Server.Misc
|
|||
if ( CheckAggressed( source.Aggressed, target ) )
|
||||
return Notoriety.CanBeAttacked;
|
||||
|
||||
if ( target is BaseCreature )
|
||||
{
|
||||
BaseCreature bc = (BaseCreature)target;
|
||||
if ( bcTarg != null && bcTarg.Controlled && bcTarg.ControlOrder == OrderType.Guard && bcTarg.ControlTarget == source )
|
||||
return Notoriety.CanBeAttacked;
|
||||
|
||||
if ( bc.Controlled && bc.ControlOrder == OrderType.Guard && bc.ControlTarget == source )
|
||||
return Notoriety.CanBeAttacked;
|
||||
}
|
||||
|
||||
if ( source is BaseCreature )
|
||||
if ( source is BaseCreature bc )
|
||||
{
|
||||
BaseCreature bc = (BaseCreature)source;
|
||||
Mobile master = bc.GetMaster();
|
||||
|
||||
if ( master != null )
|
||||
if ( CheckAggressor( master.Aggressors, target ) || MobileNotoriety( master, target ) == Notoriety.CanBeAttacked || target is BaseCreature )
|
||||
return Notoriety.CanBeAttacked;
|
||||
if ( master != null && CheckAggressor( master.Aggressors, target ) || MobileNotoriety( master, target ) == Notoriety.CanBeAttacked || bcTarg != null )
|
||||
return Notoriety.CanBeAttacked;
|
||||
}
|
||||
|
||||
return Notoriety.Innocent;
|
||||
|
|
@ -484,9 +427,7 @@ namespace Server.Misc
|
|||
if ( m != null && house.IsFriend( m ) )
|
||||
return false;
|
||||
|
||||
BaseCreature c = m as BaseCreature;
|
||||
|
||||
if ( c != null && !c.Deleted && c.Controlled && c.ControlMaster != null )
|
||||
if ( m is BaseCreature c && !c.Deleted && c.Controlled && c.ControlMaster != null )
|
||||
return !house.IsFriend( c.ControlMaster );
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ namespace Server
|
|||
{
|
||||
Poison newPoison = ( oldPoison == null ? null : GetPoison( oldPoison.Level + 1 ) );
|
||||
|
||||
return ( newPoison == null ? oldPoison : newPoison );
|
||||
return newPoison ?? oldPoison;
|
||||
}
|
||||
|
||||
// Info
|
||||
|
|
@ -131,12 +131,10 @@ namespace Server
|
|||
m_LastDamage = damage;
|
||||
}
|
||||
|
||||
if ( m_From != null )
|
||||
m_From.DoHarmful( m_Mobile, true );
|
||||
m_From?.DoHarmful( m_Mobile, true );
|
||||
|
||||
IHonorTarget honorTarget = m_Mobile as IHonorTarget;
|
||||
if ( honorTarget != null && honorTarget.ReceivedHonorContext != null )
|
||||
honorTarget.ReceivedHonorContext.OnTargetPoisoned();
|
||||
if ( m_Mobile is IHonorTarget honorTarget )
|
||||
honorTarget.ReceivedHonorContext?.OnTargetPoisoned();
|
||||
|
||||
AOS.Damage( m_Mobile, m_From, damage, 0, 0, 0, 100, 0 );
|
||||
|
||||
|
|
|
|||
|
|
@ -59,9 +59,7 @@ namespace Server.Misc
|
|||
|
||||
private static string GetAccountDuration( Mobile m )
|
||||
{
|
||||
Account a = m.Account as Account;
|
||||
|
||||
if ( a == null )
|
||||
if ( !(m.Account is Account a) )
|
||||
return "";
|
||||
|
||||
TimeSpan ts = DateTime.UtcNow - a.Created;
|
||||
|
|
|
|||
|
|
@ -54,10 +54,12 @@ namespace Server.Misc
|
|||
{
|
||||
int points = AosAttributes.GetValue( from, AosAttribute.RegenHits );
|
||||
|
||||
if ( from is BaseCreature && !((BaseCreature)from).IsAnimatedDead )
|
||||
BaseCreature bc = from as BaseCreature;
|
||||
|
||||
if ( bc != null && !bc.IsAnimatedDead )
|
||||
points += 4;
|
||||
|
||||
if ( (from is BaseCreature && ((BaseCreature)from).IsParagon) || from is Leviathan )
|
||||
if ( bc?.IsParagon == true || from is Leviathan )
|
||||
points += 40;
|
||||
|
||||
if ( Core.ML && from.Race == Race.Human ) //Is this affected by the cap?
|
||||
|
|
@ -87,7 +89,7 @@ namespace Server.Misc
|
|||
|
||||
int points =(int)(from.Skills[SkillName.Focus].Value * 0.1);
|
||||
|
||||
if ( (from is BaseCreature && ((BaseCreature)from).IsParagon) || from is Leviathan )
|
||||
if ( (@from is BaseCreature creature && creature.IsParagon) || from is Leviathan )
|
||||
points += 40;
|
||||
|
||||
int cappedPoints = AosAttributes.GetValue( from, AosAttribute.RegenStam );
|
||||
|
|
@ -135,7 +137,7 @@ namespace Server.Misc
|
|||
|
||||
double totalPoints = focusPoints + medPoints + (from.Meditating ? (medPoints > 13.0 ? 13.0 : medPoints) : 0.0);
|
||||
|
||||
if ( (from is BaseCreature && ((BaseCreature)from).IsParagon) || from is Leviathan )
|
||||
if ( (@from is BaseCreature creature && creature.IsParagon) || from is Leviathan )
|
||||
totalPoints += 40;
|
||||
|
||||
int cappedPoints = AosAttributes.GetValue( from, AosAttribute.RegenMana );
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ namespace Server.Misc
|
|||
if ( gc < 0.01 )
|
||||
gc = 0.01;
|
||||
|
||||
if ( from is BaseCreature && ((BaseCreature)from).Controlled )
|
||||
if ( @from is BaseCreature creature && creature.Controlled )
|
||||
gc *= 2;
|
||||
|
||||
if ( from.Alive && ( ( gc >= Utility.RandomDouble() && AllowGain( from, skill, amObj ) ) || skill.Base < 10.0 ) )
|
||||
|
|
@ -155,7 +155,7 @@ namespace Server.Misc
|
|||
|
||||
if ( value < minSkill )
|
||||
return false; // Too difficult
|
||||
else if ( value >= maxSkill )
|
||||
if ( value >= maxSkill )
|
||||
return true; // No challenge
|
||||
|
||||
double chance = (value - minSkill) / (maxSkill - minSkill);
|
||||
|
|
@ -172,7 +172,7 @@ namespace Server.Misc
|
|||
|
||||
if ( chance < 0.0 )
|
||||
return false; // Too difficult
|
||||
else if ( chance >= 1.0 )
|
||||
if ( chance >= 1.0 )
|
||||
return true; // No challenge
|
||||
|
||||
return CheckSkill( from, skill, target, chance );
|
||||
|
|
@ -183,10 +183,10 @@ namespace Server.Misc
|
|||
if ( Core.AOS && Faction.InSkillLoss( from ) ) //Changed some time between the introduction of AoS and SE.
|
||||
return false;
|
||||
|
||||
if ( AntiMacroCode && from is PlayerMobile && UseAntiMacro[skill.Info.SkillID] )
|
||||
return ((PlayerMobile)from).AntiMacroCheck( skill, obj );
|
||||
else
|
||||
return true;
|
||||
if ( AntiMacroCode && @from is PlayerMobile mobile && UseAntiMacro[skill.Info.SkillID] )
|
||||
return mobile.AntiMacroCheck( skill, obj );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public enum Stat { Str, Dex, Int }
|
||||
|
|
@ -196,7 +196,7 @@ namespace Server.Misc
|
|||
if ( from.Region.IsPartOf( typeof( Regions.Jail ) ) )
|
||||
return;
|
||||
|
||||
if ( from is BaseCreature && ((BaseCreature)from).IsDeadPet )
|
||||
if ( @from is BaseCreature creature && creature.IsDeadPet )
|
||||
return;
|
||||
|
||||
if ( skill.SkillName == SkillName.Focus && from is BaseCreature )
|
||||
|
|
@ -226,9 +226,8 @@ namespace Server.Misc
|
|||
}
|
||||
|
||||
#region Scroll of Alacrity
|
||||
PlayerMobile pm = from as PlayerMobile;
|
||||
|
||||
if ( pm != null && skill.SkillName == pm.AcceleratedSkill && pm.AcceleratedStart > DateTime.UtcNow )
|
||||
if ( @from is PlayerMobile pm && skill.SkillName == pm.AcceleratedSkill && pm.AcceleratedStart > DateTime.UtcNow )
|
||||
toGain *= Utility.RandomMinMax(2, 5);
|
||||
#endregion
|
||||
|
||||
|
|
@ -265,7 +264,7 @@ namespace Server.Misc
|
|||
|
||||
public static bool CanRaise( Mobile from, Stat stat )
|
||||
{
|
||||
if ( !(from is BaseCreature && ((BaseCreature)from).Controlled) )
|
||||
if ( !(@from is BaseCreature creature && creature.Controlled) )
|
||||
{
|
||||
if ( from.RawStatTotal >= from.StatCap )
|
||||
return false;
|
||||
|
|
@ -344,8 +343,8 @@ namespace Server.Misc
|
|||
{
|
||||
case Stat.Str:
|
||||
{
|
||||
if ( from is BaseCreature && ((BaseCreature)from).Controlled ) {
|
||||
if ( (from.LastStrGain + m_PetStatGainDelay) >= DateTime.UtcNow )
|
||||
if ( @from is BaseCreature creature && creature.Controlled ) {
|
||||
if ( (creature.LastStrGain + m_PetStatGainDelay) >= DateTime.UtcNow )
|
||||
return;
|
||||
}
|
||||
else if ( (from.LastStrGain + m_StatGainDelay) >= DateTime.UtcNow )
|
||||
|
|
@ -356,8 +355,8 @@ namespace Server.Misc
|
|||
}
|
||||
case Stat.Dex:
|
||||
{
|
||||
if ( from is BaseCreature && ((BaseCreature)from).Controlled ) {
|
||||
if ( (from.LastDexGain + m_PetStatGainDelay) >= DateTime.UtcNow )
|
||||
if ( @from is BaseCreature creature && creature.Controlled ) {
|
||||
if ( (creature.LastDexGain + m_PetStatGainDelay) >= DateTime.UtcNow )
|
||||
return;
|
||||
}
|
||||
else if ( (from.LastDexGain + m_StatGainDelay) >= DateTime.UtcNow )
|
||||
|
|
@ -368,8 +367,8 @@ namespace Server.Misc
|
|||
}
|
||||
case Stat.Int:
|
||||
{
|
||||
if ( from is BaseCreature && ((BaseCreature)from).Controlled ) {
|
||||
if ( (from.LastIntGain + m_PetStatGainDelay) >= DateTime.UtcNow )
|
||||
if ( @from is BaseCreature creature && creature.Controlled ) {
|
||||
if ( (creature.LastIntGain + m_PetStatGainDelay) >= DateTime.UtcNow )
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -67,9 +67,11 @@ namespace Server.Misc
|
|||
|
||||
public static void AwardKarma( Mobile m, int offset, bool message )
|
||||
{
|
||||
PlayerMobile pm = m as PlayerMobile;
|
||||
|
||||
if ( offset > 0 )
|
||||
{
|
||||
if ( m is PlayerMobile && ((PlayerMobile)m).KarmaLocked )
|
||||
if ( pm?.KarmaLocked == true )
|
||||
return;
|
||||
|
||||
if ( m.Karma >= MaxKarma )
|
||||
|
|
@ -120,9 +122,9 @@ namespace Server.Misc
|
|||
m.SendLocalizedMessage( 1019063 ); // You have lost a little karma.
|
||||
}
|
||||
|
||||
if ( !Core.AOS && wasPositiveKarma && m.Karma < 0 && m is PlayerMobile && !((PlayerMobile)m).KarmaLocked )
|
||||
if ( !Core.AOS && wasPositiveKarma && m.Karma < 0 && pm != null && !pm.KarmaLocked )
|
||||
{
|
||||
((PlayerMobile)m).KarmaLocked = true;
|
||||
pm.KarmaLocked = true;
|
||||
m.SendLocalizedMessage( 1042511, "", 0x22 ); // Karma is locked. A mantra spoken at a shrine will unlock it again.
|
||||
}
|
||||
}
|
||||
|
|
@ -172,9 +174,9 @@ namespace Server.Misc
|
|||
title.Append( beheld.Name );
|
||||
}
|
||||
|
||||
if ( beheld is PlayerMobile && ((PlayerMobile)beheld).DisplayChampionTitle )
|
||||
if ( beheld is PlayerMobile mobile && mobile.DisplayChampionTitle )
|
||||
{
|
||||
PlayerMobile.ChampionTitleInfo info = ((PlayerMobile)beheld).ChampionTitles;
|
||||
PlayerMobile.ChampionTitleInfo info = mobile.ChampionTitles;
|
||||
|
||||
if ( info.Harrower > 0 )
|
||||
title.AppendFormat( ": {0} of Evil", HarrowerTitles[Math.Min( HarrowerTitles.Length, info.Harrower )-1] );
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ namespace Server.Items
|
|||
|
||||
public override void Execute( CommandEventArgs e, object obj )
|
||||
{
|
||||
if ( obj is ToggleItem )
|
||||
if ( obj is ToggleItem item )
|
||||
{
|
||||
((ToggleItem)obj).Toggle();
|
||||
item.Toggle();
|
||||
AddResponse( "The item has been toggled." );
|
||||
}
|
||||
else
|
||||
|
|
@ -64,13 +64,7 @@ namespace Server.Items
|
|||
}
|
||||
|
||||
[Constructible]
|
||||
public ToggleItem( int inactiveItemID, int activeItemID )
|
||||
: this( inactiveItemID, activeItemID, false )
|
||||
{
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public ToggleItem( int inactiveItemID, int activeItemID, bool playersCanToggle )
|
||||
public ToggleItem( int inactiveItemID, int activeItemID, bool playersCanToggle = false)
|
||||
: base( inactiveItemID )
|
||||
{
|
||||
Movable = false;
|
||||
|
|
|
|||
|
|
@ -96,13 +96,12 @@ namespace Server.Misc
|
|||
return;
|
||||
}
|
||||
|
||||
if ( from is PlayerMobile )
|
||||
if ( @from is PlayerMobile pm )
|
||||
{
|
||||
int amt = ( from.Mounted ? 48 : 16 );
|
||||
PlayerMobile pm = (PlayerMobile)from;
|
||||
int amt = ( pm.Mounted ? 48 : 16 );
|
||||
|
||||
if ( (++pm.StepsTaken % amt) == 0 )
|
||||
--from.Stam;
|
||||
--pm.Stam;
|
||||
}
|
||||
|
||||
Spells.Ninjitsu.DeathStrike.AddStep( from );
|
||||
|
|
@ -129,4 +128,4 @@ namespace Server.Misc
|
|||
return ( (Mobile.BodyWeight + m.TotalWeight) > (GetMaxWeight( m ) + OverloadAllowance) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,11 +33,11 @@ namespace Server.Targets
|
|||
|
||||
protected override void OnTarget( Mobile from, object o )
|
||||
{
|
||||
if ( o is Mobile ) {
|
||||
Mobile m = (Mobile)o;
|
||||
if ( o is Mobile m )
|
||||
{
|
||||
for ( int i = 0; i < m_List.Count; ++i )
|
||||
m_List[i].EndPickTarget( from, m, m_Order );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -225,10 +225,8 @@ namespace Server.Mobiles
|
|||
|
||||
from.Target = new AIControlMobileTarget(this, order);
|
||||
}
|
||||
else if (from.Target is AIControlMobileTarget)
|
||||
else if (@from.Target is AIControlMobileTarget t)
|
||||
{
|
||||
AIControlMobileTarget t = (AIControlMobileTarget)from.Target;
|
||||
|
||||
if (t.Order == order)
|
||||
t.AddAI(this);
|
||||
}
|
||||
|
|
@ -384,10 +382,7 @@ namespace Server.Mobiles
|
|||
}
|
||||
else
|
||||
{
|
||||
int generalNumber;
|
||||
string exactTime;
|
||||
|
||||
Clock.GetTime(m_Mobile, out generalNumber, out exactTime);
|
||||
Clock.GetTime(m_Mobile, out int generalNumber, out _);
|
||||
|
||||
m_Mobile.PublicOverheadMessage(MessageType.Regular, 0x3B2, generalNumber);
|
||||
}
|
||||
|
|
@ -1232,9 +1227,7 @@ namespace Server.Mobiles
|
|||
{
|
||||
if (distance < 1 && target.X == 1076 && target.Y == 450 && (m_Mobile is HordeMinionFamiliar))
|
||||
{
|
||||
PlayerMobile pm = m_Mobile.ControlMaster as PlayerMobile;
|
||||
|
||||
if (pm != null)
|
||||
if (m_Mobile.ControlMaster is PlayerMobile pm)
|
||||
{
|
||||
QuestSystem qs = pm.Quest;
|
||||
|
||||
|
|
@ -1328,8 +1321,8 @@ namespace Server.Mobiles
|
|||
}
|
||||
else
|
||||
{
|
||||
bool youngFrom = from is PlayerMobile ? ((PlayerMobile)from).Young : false;
|
||||
bool youngTo = to is PlayerMobile ? ((PlayerMobile)to).Young : false;
|
||||
bool youngFrom = @from is PlayerMobile mobile && mobile.Young;
|
||||
bool youngTo = to is PlayerMobile playerMobile && playerMobile.Young;
|
||||
|
||||
if (youngFrom && !youngTo)
|
||||
{
|
||||
|
|
@ -1560,8 +1553,7 @@ namespace Server.Mobiles
|
|||
m_Mobile.OwnerAbandonTime = DateTime.MinValue;
|
||||
m_Mobile.IsBonded = false;
|
||||
|
||||
SpawnEntry se = m_Mobile.Spawner as SpawnEntry;
|
||||
if (se != null && se.HomeLocation != Point3D.Zero)
|
||||
if (m_Mobile.Spawner is SpawnEntry se && se.HomeLocation != Point3D.Zero)
|
||||
{
|
||||
m_Mobile.Home = se.HomeLocation;
|
||||
m_Mobile.RangeHome = se.HomeRange;
|
||||
|
|
@ -1683,8 +1675,8 @@ namespace Server.Mobiles
|
|||
if (from.Map != m_Creature.Map || !from.InRange(m_Creature, 14))
|
||||
return false;
|
||||
|
||||
bool youngFrom = from is PlayerMobile ? ((PlayerMobile)from).Young : false;
|
||||
bool youngTo = to is PlayerMobile ? ((PlayerMobile)to).Young : false;
|
||||
bool youngFrom = @from is PlayerMobile mobile && mobile.Young;
|
||||
bool youngTo = to is PlayerMobile playerMobile && playerMobile.Young;
|
||||
|
||||
if (accepted && youngFrom && !youngTo)
|
||||
{
|
||||
|
|
@ -1777,8 +1769,8 @@ namespace Server.Mobiles
|
|||
{
|
||||
m_Mobile.DebugSay("Begin transfer with {0}", to.Name);
|
||||
|
||||
bool youngFrom = from is PlayerMobile ? ((PlayerMobile)from).Young : false;
|
||||
bool youngTo = to is PlayerMobile ? ((PlayerMobile)to).Young : false;
|
||||
bool youngFrom = @from is PlayerMobile mobile && mobile.Young;
|
||||
bool youngTo = to is PlayerMobile playerMobile && playerMobile.Young;
|
||||
|
||||
if (youngFrom && !youngTo)
|
||||
{
|
||||
|
|
@ -2032,7 +2024,7 @@ namespace Server.Mobiles
|
|||
{
|
||||
if (m_Mobile.Deleted || m_Mobile.Frozen || m_Mobile.Paralyzed || (m_Mobile.Spell != null && m_Mobile.Spell.IsCasting) || m_Mobile.DisallowAllMoves)
|
||||
return MoveResult.BadState;
|
||||
else if (!CheckMove())
|
||||
if (!CheckMove())
|
||||
return MoveResult.BadState;
|
||||
|
||||
// This makes them always move one step, never any direction changes
|
||||
|
|
@ -2056,7 +2048,7 @@ namespace Server.Mobiles
|
|||
MoveImpl.IgnoreMovableImpassables = false;
|
||||
return (v ? MoveResult.Success : MoveResult.Blocked);
|
||||
}
|
||||
else if (!m_Mobile.Move(d))
|
||||
if (!m_Mobile.Move(d))
|
||||
{
|
||||
bool wasPushing = m_Mobile.Pushing;
|
||||
|
||||
|
|
@ -2082,13 +2074,11 @@ namespace Server.Mobiles
|
|||
|
||||
foreach (Item item in eable)
|
||||
{
|
||||
if (canOpenDoors && item is BaseDoor && (item.Z + item.ItemData.Height) > m_Mobile.Z && (m_Mobile.Z + 16) > item.Z)
|
||||
if (canOpenDoors && item is BaseDoor door && (door.Z + door.ItemData.Height) > m_Mobile.Z && (m_Mobile.Z + 16) > door.Z)
|
||||
{
|
||||
if (item.X != x || item.Y != y)
|
||||
if (door.X != x || door.Y != y)
|
||||
continue;
|
||||
|
||||
BaseDoor door = (BaseDoor)item;
|
||||
|
||||
if (!door.Locked || !door.UseLocks())
|
||||
m_Obstacles.Enqueue(door);
|
||||
|
||||
|
|
@ -2117,26 +2107,24 @@ namespace Server.Mobiles
|
|||
{
|
||||
Item item = m_Obstacles.Dequeue();
|
||||
|
||||
if (item is BaseDoor)
|
||||
if (item is BaseDoor door)
|
||||
{
|
||||
m_Mobile.DebugSay("Little do they expect, I've learned how to open doors. Didn't they read the script??");
|
||||
m_Mobile.DebugSay("*twist*");
|
||||
|
||||
((BaseDoor)item).Use(m_Mobile);
|
||||
door.Use(m_Mobile);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Mobile.DebugSay("Ugabooga. I'm so big and tough I can destroy it: {0}", item.GetType().Name);
|
||||
|
||||
if (item is Container)
|
||||
if (item is Container cont)
|
||||
{
|
||||
Container cont = (Container)item;
|
||||
|
||||
for (int i = 0; i < cont.Items.Count; ++i)
|
||||
{
|
||||
Item check = cont.Items[i];
|
||||
|
||||
if (check.Movable && check.ItemData.Impassable && (item.Z + check.ItemData.Height) > m_Mobile.Z)
|
||||
if (check.Movable && check.ItemData.Impassable && (cont.Z + check.ItemData.Height) > m_Mobile.Z)
|
||||
m_Obstacles.Enqueue(check);
|
||||
}
|
||||
|
||||
|
|
@ -2172,11 +2160,9 @@ namespace Server.Mobiles
|
|||
MoveImpl.IgnoreMovableImpassables = false;
|
||||
return (wasPushing ? MoveResult.BadState : MoveResult.Blocked);
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveImpl.IgnoreMovableImpassables = false;
|
||||
return MoveResult.Success;
|
||||
}
|
||||
|
||||
MoveImpl.IgnoreMovableImpassables = false;
|
||||
return MoveResult.Success;
|
||||
}
|
||||
|
||||
MoveImpl.IgnoreMovableImpassables = false;
|
||||
|
|
@ -2190,9 +2176,9 @@ namespace Server.Mobiles
|
|||
|
||||
if (m_Mobile.Home == Point3D.Zero)
|
||||
{
|
||||
if (m_Mobile.Spawner is SpawnEntry)
|
||||
if (m_Mobile.Spawner is SpawnEntry entry)
|
||||
{
|
||||
Region region = ((SpawnEntry)m_Mobile.Spawner).Region;
|
||||
Region region = entry.Region;
|
||||
|
||||
if (m_Mobile.Region.AcceptsSpawnsFrom(region))
|
||||
{
|
||||
|
|
@ -2334,89 +2320,87 @@ namespace Server.Mobiles
|
|||
|
||||
/*
|
||||
* Walk at range distance from mobile
|
||||
*
|
||||
*
|
||||
* iSteps : Number of steps
|
||||
* bRun : Do we run
|
||||
* iWantDistMin : The minimum distance we want to be
|
||||
* iWantDistMax : The maximum distance we want to be
|
||||
*
|
||||
*
|
||||
*/
|
||||
public virtual bool WalkMobileRange(Mobile m, int iSteps, bool bRun, int iWantDistMin, int iWantDistMax)
|
||||
{
|
||||
if (m_Mobile.Deleted || m_Mobile.DisallowAllMoves)
|
||||
return false;
|
||||
|
||||
if (m != null)
|
||||
if (m == null)
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < iSteps; i++)
|
||||
{
|
||||
for (int i = 0; i < iSteps; i++)
|
||||
// Get the current distance
|
||||
int iCurrDist = (int)m_Mobile.GetDistanceToSqrt(m);
|
||||
|
||||
if (iCurrDist < iWantDistMin || iCurrDist > iWantDistMax)
|
||||
{
|
||||
// Get the current distance
|
||||
int iCurrDist = (int)m_Mobile.GetDistanceToSqrt(m);
|
||||
bool needCloser = (iCurrDist > iWantDistMax);
|
||||
bool needFurther = !needCloser;
|
||||
|
||||
if (iCurrDist < iWantDistMin || iCurrDist > iWantDistMax)
|
||||
if (needCloser && m_Path != null && m_Path.Goal == m)
|
||||
{
|
||||
bool needCloser = (iCurrDist > iWantDistMax);
|
||||
bool needFurther = !needCloser;
|
||||
if (m_Path.Follow(bRun, 1))
|
||||
m_Path = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
Direction dirTo;
|
||||
|
||||
if (needCloser && m_Path != null && m_Path.Goal == m)
|
||||
if (iCurrDist > iWantDistMax)
|
||||
dirTo = m_Mobile.GetDirectionTo(m);
|
||||
else
|
||||
dirTo = m.GetDirectionTo(m_Mobile);
|
||||
|
||||
// Add the run flag
|
||||
if (bRun)
|
||||
dirTo = dirTo | Direction.Running;
|
||||
|
||||
if (!DoMove(dirTo, true) && needCloser)
|
||||
{
|
||||
m_Path = new PathFollower(m_Mobile, m);
|
||||
m_Path.Mover = new MoveMethod(DoMoveImpl);
|
||||
|
||||
if (m_Path.Follow(bRun, 1))
|
||||
m_Path = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
Direction dirTo;
|
||||
|
||||
if (iCurrDist > iWantDistMax)
|
||||
dirTo = m_Mobile.GetDirectionTo(m);
|
||||
else
|
||||
dirTo = m.GetDirectionTo(m_Mobile);
|
||||
|
||||
// Add the run flag
|
||||
if (bRun)
|
||||
dirTo = dirTo | Direction.Running;
|
||||
|
||||
if (!DoMove(dirTo, true) && needCloser)
|
||||
{
|
||||
m_Path = new PathFollower(m_Mobile, m);
|
||||
m_Path.Mover = new MoveMethod(DoMoveImpl);
|
||||
|
||||
if (m_Path.Follow(bRun, 1))
|
||||
m_Path = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Path = null;
|
||||
}
|
||||
m_Path = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the current distance
|
||||
int iNewDist = (int)m_Mobile.GetDistanceToSqrt(m);
|
||||
|
||||
if (iNewDist >= iWantDistMin && iNewDist <= iWantDistMax)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the current distance
|
||||
int iNewDist = (int)m_Mobile.GetDistanceToSqrt(m);
|
||||
|
||||
if (iNewDist >= iWantDistMin && iNewDist <= iWantDistMax)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Here we check to acquire a target from our surrounding
|
||||
*
|
||||
*
|
||||
* iRange : The range
|
||||
* acqType : A type of acquire we want (closest, strongest, etc)
|
||||
* bPlayerOnly : Don't bother with other creatures or NPCs, want a player
|
||||
* bFacFriend : Check people in my faction
|
||||
* bFacFoe : Check people in other factions
|
||||
*
|
||||
*
|
||||
*/
|
||||
public virtual bool AcquireFocusMob(int iRange, FightMode acqType, bool bPlayerOnly, bool bFacFriend, bool bFacFoe)
|
||||
{
|
||||
|
|
@ -2430,11 +2414,9 @@ namespace Server.Mobiles
|
|||
m_Mobile.FocusMob = null;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Mobile.FocusMob = m_Mobile.BardTarget;
|
||||
return (m_Mobile.FocusMob != null);
|
||||
}
|
||||
|
||||
m_Mobile.FocusMob = m_Mobile.BardTarget;
|
||||
return (m_Mobile.FocusMob != null);
|
||||
}
|
||||
else if (m_Mobile.Controlled)
|
||||
{
|
||||
|
|
@ -2446,11 +2428,9 @@ namespace Server.Mobiles
|
|||
m_Mobile.FocusMob = null;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Mobile.FocusMob = m_Mobile.ControlTarget;
|
||||
return (m_Mobile.FocusMob != null);
|
||||
}
|
||||
|
||||
m_Mobile.FocusMob = m_Mobile.ControlTarget;
|
||||
return (m_Mobile.FocusMob != null);
|
||||
}
|
||||
|
||||
if (m_Mobile.ConstantFocus != null)
|
||||
|
|
@ -2488,7 +2468,6 @@ namespace Server.Mobiles
|
|||
{
|
||||
Mobile newFocusMob = null;
|
||||
double val = double.MinValue;
|
||||
double theirVal;
|
||||
|
||||
IPooledEnumerable<Mobile> eable = map.GetMobilesInRange(m_Mobile.Location, iRange);
|
||||
|
||||
|
|
@ -2517,7 +2496,10 @@ namespace Server.Mobiles
|
|||
if (!m_Mobile.CanSee(m))
|
||||
continue;
|
||||
|
||||
if (Core.AOS && m is BaseCreature && (m as BaseCreature).Summoned && !(m as BaseCreature).Controlled)
|
||||
BaseCreature bc = m as BaseCreature;
|
||||
PlayerMobile pm = m as PlayerMobile;
|
||||
|
||||
if (Core.AOS && bc?.Summoned == true && bc?.Controlled != true)
|
||||
continue;
|
||||
|
||||
if (m_Mobile.Summoned && m_Mobile.SummonMaster != null)
|
||||
|
|
@ -2531,7 +2513,7 @@ namespace Server.Mobiles
|
|||
continue;
|
||||
|
||||
// Animated creatures cannot attack players directly.
|
||||
if (m is PlayerMobile && m_Mobile.IsAnimatedDead)
|
||||
if (pm != null && m_Mobile.IsAnimatedDead)
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -2544,7 +2526,7 @@ namespace Server.Mobiles
|
|||
continue;
|
||||
|
||||
// Ignore players with activated honor
|
||||
if (m is PlayerMobile && ((PlayerMobile)m).HonorActive && !(m_Mobile.Combatant == m))
|
||||
if (pm?.HonorActive == true && m_Mobile.Combatant != m)
|
||||
continue;
|
||||
|
||||
if (acqType == FightMode.Aggressor || acqType == FightMode.Evil)
|
||||
|
|
@ -2556,8 +2538,8 @@ namespace Server.Mobiles
|
|||
|
||||
if (acqType == FightMode.Evil && !bValid)
|
||||
{
|
||||
if (m is BaseCreature && ((BaseCreature)m).Controlled && ((BaseCreature)m).ControlMaster != null)
|
||||
bValid = (((BaseCreature)m).ControlMaster.Karma < 0);
|
||||
if (bc?.Controlled == true && bc?.ControlMaster != null)
|
||||
bValid = bc.ControlMaster.Karma < 0;
|
||||
else
|
||||
bValid = (m.Karma < 0);
|
||||
}
|
||||
|
|
@ -2576,7 +2558,7 @@ namespace Server.Mobiles
|
|||
continue;
|
||||
}
|
||||
|
||||
theirVal = m_Mobile.GetFightModeRanking(m, acqType, bPlayerOnly);
|
||||
var theirVal = m_Mobile.GetFightModeRanking(m, acqType, bPlayerOnly);
|
||||
|
||||
if (theirVal > val && m_Mobile.InLOS(m))
|
||||
{
|
||||
|
|
@ -2667,9 +2649,7 @@ namespace Server.Mobiles
|
|||
{
|
||||
m_Timer.Stop();
|
||||
|
||||
SpawnEntry se = m_Mobile.Spawner as SpawnEntry;
|
||||
|
||||
if (se != null && se.ReturnOnDeactivate && !m_Mobile.Controlled)
|
||||
if (m_Mobile.Spawner is SpawnEntry se && se.ReturnOnDeactivate && !m_Mobile.Controlled)
|
||||
{
|
||||
if (se.HomeLocation == Point3D.Zero)
|
||||
{
|
||||
|
|
@ -2688,9 +2668,7 @@ namespace Server.Mobiles
|
|||
|
||||
private void ReturnToHome()
|
||||
{
|
||||
SpawnEntry se = m_Mobile.Spawner as SpawnEntry;
|
||||
|
||||
if (se != null)
|
||||
if (m_Mobile.Spawner is SpawnEntry se)
|
||||
{
|
||||
Point3D loc = se.RandomSpawnLocation(16, !m_Mobile.CantWalk, m_Mobile.CanSwim);
|
||||
|
||||
|
|
@ -2750,12 +2728,12 @@ namespace Server.Mobiles
|
|||
Stop();
|
||||
return;
|
||||
}
|
||||
else if (m_Owner.m_Mobile.Map == null || m_Owner.m_Mobile.Map == Map.Internal)
|
||||
if (m_Owner.m_Mobile.Map == null || m_Owner.m_Mobile.Map == Map.Internal)
|
||||
{
|
||||
m_Owner.Deactivate();
|
||||
return;
|
||||
}
|
||||
else if (m_Owner.m_Mobile.PlayerRangeSensitive)//have to check this in the timer....
|
||||
if (m_Owner.m_Mobile.PlayerRangeSensitive)//have to check this in the timer....
|
||||
{
|
||||
Sector sect = m_Owner.m_Mobile.Map.GetSector(m_Owner.m_Mobile);
|
||||
if (!sect.Active)
|
||||
|
|
@ -2772,7 +2750,7 @@ namespace Server.Mobiles
|
|||
Stop();
|
||||
return;
|
||||
}
|
||||
else if (m_Owner.m_Mobile.Map == null || m_Owner.m_Mobile.Map == Map.Internal)
|
||||
if (m_Owner.m_Mobile.Map == null || m_Owner.m_Mobile.Map == Map.Internal)
|
||||
{
|
||||
m_Owner.Deactivate();
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue