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

@ -58,7 +58,7 @@ namespace Server.Items
set {
if ( base.Locked != value ) {
base.Locked = value;
if ( !value )
StartResetTimer();
}
@ -119,7 +119,7 @@ namespace Server.Items
m_MinSpawnTime = reader.ReadShort();
m_MaxSpawnTime = reader.ReadShort();
if( !Locked )
if ( !Locked )
StartResetTimer();
}
@ -155,7 +155,7 @@ namespace Server.Items
private void StartResetTimer()
{
if( m_ResetTimer == null )
if ( m_ResetTimer == null )
m_ResetTimer = new TreasureResetTimer( this );
else
m_ResetTimer.Delay = TimeSpan.FromMinutes( Utility.Random( m_MinSpawnTime, m_MaxSpawnTime ));
@ -215,9 +215,9 @@ namespace Server.Items
public void Reset()
{
if( m_ResetTimer != null )
if ( m_ResetTimer != null )
{
if( m_ResetTimer.Running )
if ( m_ResetTimer.Running )
m_ResetTimer.Stop();
}
@ -228,13 +228,13 @@ namespace Server.Items
public enum TreasureLevel
{
Level1,
Level2,
Level3,
Level4,
Level1,
Level2,
Level3,
Level4,
Level5,
Level6,
};
};
private class TreasureResetTimer : Timer
{
@ -252,4 +252,4 @@ namespace Server.Items
}
}
}
}
}

View file

@ -35,14 +35,14 @@ namespace Server.Items
get { return m_Content; }
set
{
if( m_Content == value )
if ( m_Content == value )
return;
m_Content = value;
for( int i = Items.Count - 1; i >= 0; --i )
{
if( i < Items.Count )
if ( i < Items.Count )
Items[ i ].Delete();
}
@ -70,12 +70,12 @@ namespace Server.Items
public virtual void AcquireContent()
{
if( m_Content != null )
if ( m_Content != null )
return;
m_Content = FillableContent.Acquire( this.GetWorldLocation(), this.Map );
if( m_Content != null )
if ( m_Content != null )
Respawn();
}
@ -88,7 +88,7 @@ namespace Server.Items
{
base.OnAfterDelete();
if( m_RespawnTimer != null )
if ( m_RespawnTimer != null )
{
m_RespawnTimer.Stop();
m_RespawnTimer = null;
@ -111,9 +111,9 @@ namespace Server.Items
{
bool canSpawn = ( m_Content != null && !Deleted && GetItemsCount() <= SpawnThreshold && !Movable && Parent == null && !IsLockedDown && !IsSecure );
if( canSpawn )
if ( canSpawn )
{
if( m_RespawnTimer == null )
if ( m_RespawnTimer == null )
{
int mins = Utility.RandomMinMax( this.MinRespawnMinutes, this.MaxRespawnMinutes );
TimeSpan delay = TimeSpan.FromMinutes( mins );
@ -122,7 +122,7 @@ namespace Server.Items
m_RespawnTimer = Timer.DelayCall( delay, new TimerCallback( Respawn ) );
}
}
else if( m_RespawnTimer != null )
else if ( m_RespawnTimer != null )
{
m_RespawnTimer.Stop();
m_RespawnTimer = null;
@ -131,18 +131,18 @@ namespace Server.Items
public void Respawn()
{
if( m_RespawnTimer != null )
if ( m_RespawnTimer != null )
{
m_RespawnTimer.Stop();
m_RespawnTimer = null;
}
if( m_Content == null || Deleted )
if ( m_Content == null || Deleted )
return;
GenerateContent();
if( IsLockable )
if ( IsLockable )
{
Locked = true;
@ -153,9 +153,9 @@ namespace Server.Items
RequiredSkill = difficulty;
}
if( IsTrappable && ( m_Content.Level > 1 || 4 > Utility.Random( 5 ) ) )
if ( IsTrappable && ( m_Content.Level > 1 || 4 > Utility.Random( 5 ) ) )
{
if( m_Content.Level > Utility.Random( 5 ) )
if ( m_Content.Level > Utility.Random( 5 ) )
TrapType = TrapType.PoisonTrap;
else
TrapType = TrapType.ExplosionTrap;
@ -177,7 +177,7 @@ namespace Server.Items
{
int itemsCount = GetItemsCount();
if( itemsCount > SpawnThreshold )
if ( itemsCount > SpawnThreshold )
return 0;
int maxSpawnCount = ( 1 + SpawnThreshold - itemsCount ) * 2;
@ -187,7 +187,7 @@ namespace Server.Items
public virtual void GenerateContent()
{
if( m_Content == null || Deleted )
if ( m_Content == null || Deleted )
return;
int toSpawn = GetSpawnCount();
@ -196,7 +196,7 @@ namespace Server.Items
{
Item item = m_Content.Construct();
if( item != null )
if ( item != null )
{
List<Item> list = this.Items;
@ -204,11 +204,11 @@ namespace Server.Items
{
Item subItem = list[ j ];
if( !( subItem is Container ) && subItem.StackWith( null, item, false ) )
if ( !( subItem is Container ) && subItem.StackWith( null, item, false ) )
break;
}
if( item != null && !item.Deleted )
if ( item != null && !item.Deleted )
DropItem( item );
}
}
@ -227,7 +227,7 @@ namespace Server.Items
writer.Write( (int)ContentType );
if( m_RespawnTimer != null )
if ( m_RespawnTimer != null )
{
writer.Write( true );
writer.WriteDeltaTime( (DateTime)m_NextRespawnTime );
@ -253,7 +253,7 @@ namespace Server.Items
}
case 0:
{
if( reader.ReadBool() )
if ( reader.ReadBool() )
{
m_NextRespawnTime = reader.ReadDeltaTime();
@ -284,12 +284,12 @@ namespace Server.Items
public override void AcquireContent()
{
if( m_Content != null )
if ( m_Content != null )
return;
m_Content = FillableContent.Library;
if( m_Content != null )
if ( m_Content != null )
Respawn();
}
@ -318,7 +318,7 @@ namespace Server.Items
int version = reader.ReadEncodedInt();
if( version == 0 && m_Content == null )
if ( version == 0 && m_Content == null )
Timer.DelayCall( TimeSpan.Zero, new TimerCallback( AcquireContent ) );
}
}
@ -440,7 +440,7 @@ namespace Server.Items
int version = reader.ReadEncodedInt();
if( version == 0 && Weight == 3 )
if ( version == 0 && Weight == 3 )
Weight = -1;
}
}
@ -473,7 +473,7 @@ namespace Server.Items
int version = reader.ReadEncodedInt();
if( version == 0 && Weight == 25 )
if ( version == 0 && Weight == 25 )
Weight = -1;
}
}
@ -505,7 +505,7 @@ namespace Server.Items
int version = reader.ReadInt();
if( version == 0 && Weight == 25 )
if ( version == 0 && Weight == 25 )
Weight = -1;
}
}
@ -537,7 +537,7 @@ namespace Server.Items
int version = reader.ReadInt();
if( version == 0 && Weight == 25 )
if ( version == 0 && Weight == 25 )
Weight = -1;
}
}
@ -569,7 +569,7 @@ namespace Server.Items
int version = reader.ReadInt();
if( version == 0 && Weight == 2 )
if ( version == 0 && Weight == 2 )
Weight = -1;
}
}
@ -616,11 +616,11 @@ namespace Server.Items
{
Item item = Loot.Construct( m_Types );
if( item is Key )
if ( item is Key )
( (Key)item ).ItemID = Utility.RandomList( (int)KeyType.Copper, (int)KeyType.Gold, (int)KeyType.Iron, (int)KeyType.Rusty );
else if( item is Arrow || item is Bolt )
else if ( item is Arrow || item is Bolt )
item.Amount = Utility.RandomMinMax( 2, 6 );
else if( item is Bandage || item is Lockpick )
else if ( item is Bandage || item is Lockpick )
item.Amount = Utility.RandomMinMax( 1, 3 );
return item;
@ -650,11 +650,11 @@ namespace Server.Items
int index = Utility.Random( m_Types.Length );
if( m_Types[ index ] == typeof( BeverageBottle ) )
if ( m_Types[ index ] == typeof( BeverageBottle ) )
{
item = new BeverageBottle( m_Content );
}
else if( m_Types[ index ] == typeof( Jug ) )
else if ( m_Types[ index ] == typeof( Jug ) )
{
item = new Jug( m_Content );
}
@ -662,7 +662,7 @@ namespace Server.Items
{
item = base.Construct();
if( item is BaseBeverage )
if ( item is BaseBeverage )
{
BaseBeverage bev = (BaseBeverage)item;
@ -723,7 +723,7 @@ namespace Server.Items
{
FillableEntry entry = m_Entries[ i ];
if( index < entry.Weight )
if ( index < entry.Weight )
return entry.Construct();
index -= entry.Weight;
@ -1456,7 +1456,7 @@ namespace Server.Items
{
int v = (int)type;
if( v >= 0 && v < m_ContentTypes.Length )
if ( v >= 0 && v < m_ContentTypes.Length )
return m_ContentTypes[ v ];
return null;
@ -1464,7 +1464,7 @@ namespace Server.Items
public static FillableContentType Lookup( FillableContent content )
{
if( content == null )
if ( content == null )
return FillableContentType.None;
return (FillableContentType)Array.IndexOf( m_ContentTypes, content );
@ -1490,10 +1490,10 @@ namespace Server.Items
public static FillableContent Acquire( Point3D loc, Map map )
{
if( map == null || map == Map.Internal )
if ( map == null || map == Map.Internal )
return null;
if( m_AcquireTable == null )
if ( m_AcquireTable == null )
{
m_AcquireTable = new Hashtable();
@ -1511,12 +1511,12 @@ namespace Server.Items
foreach( Mobile mob in map.GetMobilesInRange( loc, 20 ) )
{
if( nearest != null && mob.GetDistanceToSqrt( loc ) > nearest.GetDistanceToSqrt( loc ) && !( nearest is Cobbler && mob is Provisioner ) )
if ( nearest != null && mob.GetDistanceToSqrt( loc ) > nearest.GetDistanceToSqrt( loc ) && !( nearest is Cobbler && mob is Provisioner ) )
continue;
FillableContent check = m_AcquireTable[ mob.GetType() ] as FillableContent;
if( check != null )
if ( check != null )
{
nearest = mob;
content = check;

View file

@ -19,7 +19,7 @@ namespace Server.Items
private static int[] m_Hues = new int[]
{
0x0, 0x455, 0x47E, 0x89F, 0x8A5, 0x8AB,
0x0, 0x455, 0x47E, 0x89F, 0x8A5, 0x8AB,
0x966, 0x96D, 0x972, 0x973, 0x979
};
@ -76,14 +76,14 @@ namespace Server.Items
min = 10; max = 20;
}
}
public void Flip()
{
switch ( ItemID )
{
case 0x9AB : ItemID = 0xE7C; break;
case 0xE7C : ItemID = 0x9AB; break;
case 0xE40 : ItemID = 0xE41; break;
case 0xE41 : ItemID = 0xE40; break;
}
@ -165,11 +165,11 @@ namespace Server.Items
DropItem( item );
}
else if( item is BaseHat )
else if ( item is BaseHat )
{
BaseHat hat = (BaseHat)item;
if( Core.AOS )
if ( Core.AOS )
{
int attributeCount;
int min, max;
@ -181,7 +181,7 @@ namespace Server.Items
DropItem( item );
}
else if( item is BaseJewel )
else if ( item is BaseJewel )
{
int attributeCount;
int min, max;

View file

@ -32,7 +32,7 @@ namespace Server.Items
{
base.GetContextMenuEntries( from, list );
if( from.Alive )
if ( from.Alive )
{
list.Add( new SalvageIngotsEntry( this, IsChildOf( from.Backpack ) && Resmeltables() ) );
list.Add( new SalvageClothEntry( this, IsChildOf( from.Backpack ) && Scissorables() ) );
@ -45,19 +45,19 @@ namespace Server.Items
{
foreach( Item i in Items )
{
if( i != null && !i.Deleted )
if ( i != null && !i.Deleted )
{
if( i is BaseWeapon )
if ( i is BaseWeapon )
{
if( CraftResources.GetType( ( (BaseWeapon)i ).Resource ) == CraftResourceType.Metal )
if ( CraftResources.GetType( ( (BaseWeapon)i ).Resource ) == CraftResourceType.Metal )
return true;
}
if( i is BaseArmor )
if ( i is BaseArmor )
{
if( CraftResources.GetType( ( (BaseArmor)i ).Resource ) == CraftResourceType.Metal )
if ( CraftResources.GetType( ( (BaseArmor)i ).Resource ) == CraftResourceType.Metal )
return true;
}
if( i is DragonBardingDeed )
if ( i is DragonBardingDeed )
return true;
}
}
@ -68,18 +68,18 @@ namespace Server.Items
{
foreach( Item i in Items )
{
if( i != null && !i.Deleted )
if ( i != null && !i.Deleted )
{
if( i is IScissorable )
if ( i is IScissorable )
{
if( i is BaseClothing )
if ( i is BaseClothing )
return true;
if( i is BaseArmor )
if ( i is BaseArmor )
{
if( CraftResources.GetType( ( (BaseArmor)i ).Resource ) == CraftResourceType.Leather )
if ( CraftResources.GetType( ( (BaseArmor)i ).Resource ) == CraftResourceType.Leather )
return true;
}
if( ( i is Cloth ) || ( i is BoltOfCloth ) || ( i is Hides ) || ( i is BonePile ) )
if ( ( i is Cloth ) || ( i is BoltOfCloth ) || ( i is Hides ) || ( i is BonePile ) )
return true;
}
}
@ -93,22 +93,22 @@ namespace Server.Items
{
try
{
if( CraftResources.GetType( resource ) != CraftResourceType.Metal )
if ( CraftResources.GetType( resource ) != CraftResourceType.Metal )
return false;
CraftResourceInfo info = CraftResources.GetInfo( resource );
if( info == null || info.ResourceTypes.Length == 0 )
if ( info == null || info.ResourceTypes.Length == 0 )
return false;
CraftItem craftItem = DefBlacksmithy.CraftSystem.CraftItems.SearchFor( item.GetType() );
if( craftItem == null || craftItem.Resources.Count == 0 )
if ( craftItem == null || craftItem.Resources.Count == 0 )
return false;
CraftRes craftResource = craftItem.Resources.GetAt( 0 );
if( craftResource.Amount < 2 )
if ( craftResource.Amount < 2 )
return false; // Not enough metal to resmelt
double difficulty = 0.0;
@ -128,13 +128,13 @@ namespace Server.Items
Type resourceType = info.ResourceTypes[ 0 ];
Item ingot = (Item)Activator.CreateInstance( resourceType );
if( item is DragonBardingDeed || ( item is BaseArmor && ( (BaseArmor)item ).PlayerConstructed ) || ( item is BaseWeapon && ( (BaseWeapon)item ).PlayerConstructed ) || ( item is BaseClothing && ( (BaseClothing)item ).PlayerConstructed ) )
if ( item is DragonBardingDeed || ( item is BaseArmor && ( (BaseArmor)item ).PlayerConstructed ) || ( item is BaseWeapon && ( (BaseWeapon)item ).PlayerConstructed ) || ( item is BaseClothing && ( (BaseClothing)item ).PlayerConstructed ) )
{
double mining = from.Skills[ SkillName.Mining ].Value;
if( mining > 100.0 )
if ( mining > 100.0 )
mining = 100.0;
double amount = ( ( ( 4 + mining ) * craftResource.Amount - 4 ) * 0.0068 );
if( amount < 2 )
if ( amount < 2 )
ingot.Amount = 2;
else
ingot.Amount = (int)amount;
@ -176,11 +176,11 @@ namespace Server.Items
bool ToolFound = false;
foreach( Item tool in tools )
{
if( tool is BaseTool && ( (BaseTool)tool ).CraftSystem == DefBlacksmithy.CraftSystem )
if ( tool is BaseTool && ( (BaseTool)tool ).CraftSystem == DefBlacksmithy.CraftSystem )
ToolFound = true;
}
if( !ToolFound )
if ( !ToolFound )
{
from.SendLocalizedMessage( 1079822 ); // You need a blacksmithing tool in order to salvage ingots.
return;
@ -189,7 +189,7 @@ namespace Server.Items
bool anvil, forge;
DefBlacksmithy.CheckAnvilAndForge( from, 2, out anvil, out forge );
if( !forge )
if ( !forge )
{
from.SendLocalizedMessage( 1044265 ); // You must be near a forge.
return;
@ -206,30 +206,30 @@ namespace Server.Items
{
Item item = Smeltables[ i ];
if( item is BaseArmor )
if ( item is BaseArmor )
{
if( Resmelt( from, item, ( (BaseArmor)item ).Resource ) )
if ( Resmelt( from, item, ( (BaseArmor)item ).Resource ) )
salvaged++;
else
notSalvaged++;
}
else if( item is BaseWeapon )
else if ( item is BaseWeapon )
{
if( Resmelt( from, item, ( (BaseWeapon)item ).Resource ) )
if ( Resmelt( from, item, ( (BaseWeapon)item ).Resource ) )
salvaged++;
else
notSalvaged++;
}
else if( item is DragonBardingDeed )
else if ( item is DragonBardingDeed )
{
if( Resmelt( from, item, ( (DragonBardingDeed)item ).Resource ) )
if ( Resmelt( from, item, ( (DragonBardingDeed)item ).Resource ) )
salvaged++;
else
notSalvaged++;
}
}
if( m_Failure )
if ( m_Failure )
{
from.SendLocalizedMessage( 1079975 ); // You failed to smelt some metal for lack of skill.
m_Failure = false;
@ -241,7 +241,7 @@ namespace Server.Items
private void SalvageCloth( Mobile from )
{
Scissors scissors = from.Backpack.FindItemByType( typeof( Scissors ) ) as Scissors;
if( scissors == null )
if ( scissors == null )
{
from.SendLocalizedMessage( 1079823 ); // You need scissors in order to salvage cloth.
return;
@ -275,7 +275,7 @@ namespace Server.Items
foreach (Item i in ((Container)this).FindItemsByType(typeof(Item), true))
{
if( ( i is Leather ) || ( i is Cloth ) || ( i is SpinedLeather ) || ( i is HornedLeather ) || ( i is BarbedLeather ) || ( i is Bandage ) || ( i is Bone ) )
if ( ( i is Leather ) || ( i is Cloth ) || ( i is SpinedLeather ) || ( i is HornedLeather ) || ( i is BarbedLeather ) || ( i is Bandage ) || ( i is Bone ) )
{
from.AddToBackpack( i );
}
@ -300,18 +300,18 @@ namespace Server.Items
{
m_Bag = bag;
if( !enabled )
if ( !enabled )
Flags |= CMEFlags.Disabled;
}
public override void OnClick()
{
if( m_Bag.Deleted )
if ( m_Bag.Deleted )
return;
Mobile from = Owner.From;
if( from.CheckAlive() )
if ( from.CheckAlive() )
m_Bag.SalvageAll( from );
}
}
@ -325,18 +325,18 @@ namespace Server.Items
{
m_Bag = bag;
if( !enabled )
if ( !enabled )
Flags |= CMEFlags.Disabled;
}
public override void OnClick()
{
if( m_Bag.Deleted )
if ( m_Bag.Deleted )
return;
Mobile from = Owner.From;
if( from.CheckAlive() )
if ( from.CheckAlive() )
m_Bag.SalvageIngots( from );
}
}
@ -350,18 +350,18 @@ namespace Server.Items
{
m_Bag = bag;
if( !enabled )
if ( !enabled )
Flags |= CMEFlags.Disabled;
}
public override void OnClick()
{
if( m_Bag.Deleted )
if ( m_Bag.Deleted )
return;
Mobile from = Owner.From;
if( from.CheckAlive() )
if ( from.CheckAlive() )
m_Bag.SalvageCloth( from );
}
}

View file

@ -207,7 +207,7 @@ namespace Server.Items
Effects.SendLocationParticles( EffectItem.Create( Location, Map, EffectItem.DefaultDuration ), 0x376A, 9, 32, 5022 );
Effects.PlaySound( Location, Map, 0x1F5 );
if( this.TrapOnOpen )
if ( this.TrapOnOpen )
{
ExecuteTrap( from );
}
@ -257,4 +257,4 @@ namespace Server.Items
}
}
}
}
}

View file

@ -241,11 +241,11 @@ namespace Server.Items
cont.DropItem( item );
}
else if( item is BaseHat )
else if ( item is BaseHat )
{
BaseHat hat = (BaseHat)item;
if( Core.AOS )
if ( Core.AOS )
{
int attributeCount;
int min, max;
@ -257,7 +257,7 @@ namespace Server.Items
cont.DropItem( item );
}
else if( item is BaseJewel )
else if ( item is BaseJewel )
{
int attributeCount;
int min, max;