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

@ -62,8 +62,8 @@ namespace Server.Factions
Faction ourFaction = m_Faction;
Faction theirFaction = Faction.Find( m );
if ( theirFaction == null && m is BaseFactionGuard )
theirFaction = ((BaseFactionGuard)m).Faction;
if ( theirFaction == null && m is BaseFactionGuard guard )
theirFaction = guard.Faction;
if ( ourFaction != null && theirFaction != null && ourFaction != theirFaction )
{
@ -72,22 +72,14 @@ namespace Server.Factions
if ( reactionType == ReactionType.Attack )
return true;
if ( theirFaction != null )
List<AggressorInfo> list = m.Aggressed;
for ( int i = 0; i < list.Count; ++i )
{
List<AggressorInfo> list = m.Aggressed;
AggressorInfo ai = list[i];
for ( int i = 0; i < list.Count; ++i )
{
AggressorInfo ai = list[i];
if ( ai.Defender is BaseFactionGuard )
{
BaseFactionGuard bf = (BaseFactionGuard)ai.Defender;
if ( bf.Faction == ourFaction )
return true;
}
}
if ( ai.Defender is BaseFactionGuard bf && bf.Faction == ourFaction )
return true;
}
}

View file

@ -165,9 +165,7 @@ namespace Server.Factions
if ( pack == null )
return false;
Item weapon = m_Guard.Weapon as Item;
if ( weapon != null && weapon.Parent == m_Guard && !(weapon is Fists) )
if ( m_Guard.Weapon is Item weapon && weapon.Parent == m_Guard && !(weapon is Fists) )
{
pack.DropItem( weapon );
return true;
@ -180,10 +178,7 @@ namespace Server.Factions
{
Container pack = m_Guard.Backpack;
if ( pack == null )
return false;
Item weapon = pack.FindItemByType( typeof( BaseWeapon ) );
Item weapon = pack?.FindItemByType( typeof( BaseWeapon ) );
if ( weapon == null )
return false;
@ -197,10 +192,7 @@ namespace Server.Factions
Container pack = m_Guard.Backpack;
if ( pack == null )
return false;
Item bandage = pack.FindItemByType( typeof( Bandage ) );
Item bandage = pack?.FindItemByType( typeof( Bandage ) );
if ( bandage == null )
return false;
@ -214,10 +206,7 @@ namespace Server.Factions
{
Container pack = m_Guard.Backpack;
if ( pack == null )
return false;
Item item = pack.FindItemByType( type );
Item item = pack?.FindItemByType( type );
if ( item == null )
return false;
@ -375,7 +364,7 @@ namespace Server.Factions
public bool CanDispel( Mobile m )
{
return ( m is BaseCreature && ((BaseCreature)m).Summoned && m_Mobile.CanBeHarmful( m, false ) && !((BaseCreature)m).IsAnimatedDead );
return ( m is BaseCreature creature && creature.Summoned && m_Mobile.CanBeHarmful( creature, false ) && !creature.IsAnimatedDead );
}
public void RunTo( Mobile m )
@ -606,7 +595,7 @@ namespace Server.Factions
}
else if ( IsDamaged && (m_Guard.HitsMax - m_Guard.Hits) > Utility.Random( 200 ) )
{
if( IsAllowed( GuardAI.Magic ) && ((m_Guard.Hits * 100) / Math.Max( m_Guard.HitsMax, 1 )) < 10 && m_Guard.Home != Point3D.Zero && !Utility.InRange( m_Guard.Location, m_Guard.Home, 15 ) && m_Guard.Mana >= 11 )
if ( IsAllowed( GuardAI.Magic ) && ((m_Guard.Hits * 100) / Math.Max( m_Guard.HitsMax, 1 )) < 10 && m_Guard.Home != Point3D.Zero && !Utility.InRange( m_Guard.Location, m_Guard.Home, 15 ) && m_Guard.Mana >= 11 )
{
spell = new RecallSpell( m_Guard, null, new RunebookEntry( m_Guard.Home, m_Guard.Map, "Guard's Home", null ), null );
}
@ -768,7 +757,7 @@ namespace Server.Factions
if ( spell == null || !spell.Cast() )
EquipWeapon();
}
else if ( m_Mobile.Spell is Spell && ((Spell)m_Mobile.Spell).State == SpellState.Sequencing )
else if ( m_Mobile.Spell is Spell spell && spell.State == SpellState.Sequencing )
{
EquipWeapon();
}
@ -776,4 +765,4 @@ namespace Server.Factions
return true;
}
}
}
}

View file

@ -40,7 +40,7 @@ namespace Server.Factions
AddItem( Immovable( Rehued( new ChainChest(), 2125 ) ) );
AddItem( Immovable( Rehued( new ChainLegs(), 2125 ) ) );
AddItem( Immovable( Rehued( new ChainCoif(), 2125 ) ) );
AddItem( Immovable( Rehued( new ChainCoif (), 2125 ) ) );
AddItem( Immovable( Rehued( new PlateArms(), 2125 ) ) );
AddItem( Immovable( Rehued( new PlateGloves(), 2125 ) ) );

View file

@ -36,7 +36,7 @@ namespace Server.Factions
AddItem( new ChainLegs() );
AddItem( new RingmailArms() );
AddItem( new RingmailGloves() );
AddItem( new ChainCoif() );
AddItem( new ChainCoif () );
AddItem( new Boots() );
AddItem( Newbied( new ShortSpear() ) );

View file

@ -14,7 +14,7 @@ namespace Server.Factions
{
SetSkill( SkillName.AnimalLore, 64.0, 100.0 );
SetSkill( SkillName.AnimalTaming, 90.0, 100.0 );
SetSkill( SkillName.Veterinary, 65.0, 88.0 );
SetSkill( SkillName.Veterinary, 65.0, 88.0 );
}
public override void InitSBInfo()
@ -48,8 +48,8 @@ namespace Server.Factions
PrivateOverheadMessage( MessageType.Regular, 0x3B2, 1042201, from.NetState ); // You are not in my faction, I cannot sell you a horse!
else if ( FactionGump.Exists( from ) )
from.SendLocalizedMessage( 1042160 ); // You already have a faction menu open.
else if ( from is PlayerMobile )
from.SendGump( new HorseBreederGump( (PlayerMobile) from, this.Faction ) );
else if ( @from is PlayerMobile mobile )
mobile.SendGump( new HorseBreederGump( mobile, this.Faction ) );
}
public override void VendorSell( Mobile from )
@ -80,4 +80,4 @@ namespace Server.Factions
int version = reader.ReadInt();
}
}
}
}