Fixes casting checks
This commit is contained in:
parent
7ea00fbf4f
commit
03dd5f1926
431 changed files with 5616 additions and 6250 deletions
|
|
@ -63,10 +63,10 @@ namespace Server.Engines.Harvest
|
|||
|
||||
public void SendMessageTo( Mobile from, object message )
|
||||
{
|
||||
if ( message is int )
|
||||
from.SendLocalizedMessage( (int)message );
|
||||
else if ( message is string )
|
||||
from.SendMessage( (string)message );
|
||||
if ( message is int messageInt )
|
||||
from.SendLocalizedMessage( messageInt );
|
||||
else
|
||||
from.SendMessage( message.ToString() );
|
||||
}
|
||||
|
||||
public HarvestBank GetBank( Map map, int x, int y )
|
||||
|
|
|
|||
|
|
@ -16,10 +16,10 @@ namespace Server.Engines.Harvest
|
|||
|
||||
public void SendSuccessTo( Mobile m )
|
||||
{
|
||||
if ( m_SuccessMessage is int )
|
||||
m.SendLocalizedMessage( (int)m_SuccessMessage );
|
||||
else if ( m_SuccessMessage is string )
|
||||
m.SendMessage( (string)m_SuccessMessage );
|
||||
if ( m_SuccessMessage is int messageInt )
|
||||
m.SendLocalizedMessage( messageInt );
|
||||
else
|
||||
m.SendMessage( m_SuccessMessage.ToString() );
|
||||
}
|
||||
|
||||
public HarvestResource( double reqSkill, double minSkill, double maxSkill, object message, params Type[] types )
|
||||
|
|
@ -31,4 +31,4 @@ namespace Server.Engines.Harvest
|
|||
m_SuccessMessage = message;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ namespace Server.Engines.Harvest
|
|||
|
||||
public virtual bool CheckTool( Mobile from, Item tool )
|
||||
{
|
||||
bool wornOut = ( tool == null || tool.Deleted || (tool is IUsesRemaining && ((IUsesRemaining)tool).UsesRemaining <= 0) );
|
||||
bool wornOut = ( tool == null || tool.Deleted || (tool is IUsesRemaining remaining && remaining.UsesRemaining <= 0) );
|
||||
|
||||
if ( wornOut )
|
||||
from.SendLocalizedMessage( 1044038 ); // You have worn out your tool!
|
||||
|
|
@ -176,11 +176,11 @@ namespace Server.Engines.Harvest
|
|||
bool eligableForRacialBonus = ( def.RaceBonus && from.Race == Race.Human );
|
||||
bool inFelucca = (map == Map.Felucca);
|
||||
|
||||
if( eligableForRacialBonus && inFelucca && bank.Current >= feluccaRacialAmount && 0.1 > Utility.RandomDouble() )
|
||||
if ( eligableForRacialBonus && inFelucca && bank.Current >= feluccaRacialAmount && 0.1 > Utility.RandomDouble() )
|
||||
item.Amount = feluccaRacialAmount;
|
||||
else if( inFelucca && bank.Current >= feluccaAmount )
|
||||
else if ( inFelucca && bank.Current >= feluccaAmount )
|
||||
item.Amount = feluccaAmount;
|
||||
else if( eligableForRacialBonus && bank.Current >= racialAmount && 0.1 > Utility.RandomDouble() )
|
||||
else if ( eligableForRacialBonus && bank.Current >= racialAmount && 0.1 > Utility.RandomDouble() )
|
||||
item.Amount = racialAmount;
|
||||
else
|
||||
item.Amount = amount;
|
||||
|
|
@ -214,10 +214,8 @@ namespace Server.Engines.Harvest
|
|||
}
|
||||
}
|
||||
|
||||
if ( tool is IUsesRemaining )
|
||||
if ( tool is IUsesRemaining toolWithUses )
|
||||
{
|
||||
IUsesRemaining toolWithUses = (IUsesRemaining)tool;
|
||||
|
||||
toolWithUses.ShowUsesRemaining = true;
|
||||
|
||||
if ( toolWithUses.UsesRemaining > 0 )
|
||||
|
|
@ -316,7 +314,7 @@ namespace Server.Engines.Harvest
|
|||
{
|
||||
bool racialBonus = (def.RaceBonus && from.Race == Race.Elf );
|
||||
|
||||
if( vein.ChanceToFallback > (Utility.RandomDouble() + (racialBonus ? .20 : 0)) )
|
||||
if ( vein.ChanceToFallback > (Utility.RandomDouble() + (racialBonus ? .20 : 0)) )
|
||||
return fallback;
|
||||
|
||||
double skillValue = from.Skills[def.Skill].Value;
|
||||
|
|
@ -447,29 +445,23 @@ namespace Server.Engines.Harvest
|
|||
|
||||
public virtual bool GetHarvestDetails( Mobile from, Item tool, object toHarvest, out int tileID, out Map map, out Point3D loc )
|
||||
{
|
||||
if ( toHarvest is Static && !((Static)toHarvest).Movable )
|
||||
if ( toHarvest is Static staticObj && !staticObj.Movable )
|
||||
{
|
||||
Static obj = (Static)toHarvest;
|
||||
|
||||
tileID = (obj.ItemID & 0x3FFF) | 0x4000;
|
||||
map = obj.Map;
|
||||
loc = obj.GetWorldLocation();
|
||||
tileID = (staticObj.ItemID & 0x3FFF) | 0x4000;
|
||||
map = staticObj.Map;
|
||||
loc = staticObj.GetWorldLocation();
|
||||
}
|
||||
else if ( toHarvest is StaticTarget )
|
||||
else if ( toHarvest is StaticTarget staticTarget )
|
||||
{
|
||||
StaticTarget obj = (StaticTarget)toHarvest;
|
||||
|
||||
tileID = (obj.ItemID & 0x3FFF) | 0x4000;
|
||||
tileID = (staticTarget.ItemID & 0x3FFF) | 0x4000;
|
||||
map = from.Map;
|
||||
loc = obj.Location;
|
||||
loc = staticTarget.Location;
|
||||
}
|
||||
else if ( toHarvest is LandTarget )
|
||||
else if ( toHarvest is LandTarget landTarget )
|
||||
{
|
||||
LandTarget obj = (LandTarget)toHarvest;
|
||||
|
||||
tileID = obj.TileID;
|
||||
tileID = landTarget.TileID;
|
||||
map = from.Map;
|
||||
loc = obj.Location;
|
||||
loc = landTarget.Location;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -24,53 +24,45 @@ namespace Server.Engines.Harvest
|
|||
|
||||
protected override void OnTarget( Mobile from, object targeted )
|
||||
{
|
||||
if ( m_System is Mining && targeted is StaticTarget )
|
||||
if ( m_System is Mining && targeted is StaticTarget target )
|
||||
{
|
||||
int itemID = ((StaticTarget)targeted).ItemID;
|
||||
int itemID = target.ItemID;
|
||||
|
||||
// grave
|
||||
if ( itemID == 0xED3 || itemID == 0xEDF || itemID == 0xEE0 || itemID == 0xEE1 || itemID == 0xEE2 || itemID == 0xEE8 )
|
||||
{
|
||||
PlayerMobile player = from as PlayerMobile;
|
||||
|
||||
if ( player != null )
|
||||
if ( from is PlayerMobile player )
|
||||
{
|
||||
QuestSystem qs = player.Quest;
|
||||
|
||||
if ( qs is WitchApprenticeQuest )
|
||||
if ( qs is WitchApprenticeQuest && qs.FindObjective( typeof( FindIngredientObjective ) ) is FindIngredientObjective obj && !obj.Completed && obj.Ingredient == Ingredient.Bones )
|
||||
{
|
||||
FindIngredientObjective obj = qs.FindObjective( typeof( FindIngredientObjective ) ) as FindIngredientObjective;
|
||||
player.SendLocalizedMessage( 1055037 ); // You finish your grim work, finding some of the specific bones listed in the Hag's recipe.
|
||||
obj.Complete();
|
||||
|
||||
if ( obj != null && !obj.Completed && obj.Ingredient == Ingredient.Bones )
|
||||
{
|
||||
player.SendLocalizedMessage( 1055037 ); // You finish your grim work, finding some of the specific bones listed in the Hag's recipe.
|
||||
obj.Complete();
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( m_System is Lumberjacking && targeted is IChopable )
|
||||
((IChopable)targeted).OnChop( from );
|
||||
else if ( m_System is Lumberjacking && targeted is IAxe && m_Tool is BaseAxe )
|
||||
if ( m_System is Lumberjacking && targeted is IChopable chopable )
|
||||
chopable.OnChop( from );
|
||||
else if ( m_System is Lumberjacking && targeted is IAxe obj && m_Tool is BaseAxe axe )
|
||||
{
|
||||
IAxe obj = (IAxe)targeted;
|
||||
Item item = (Item)targeted;
|
||||
|
||||
Item item = (Item)obj;
|
||||
|
||||
if ( !item.IsChildOf( from.Backpack ) )
|
||||
from.SendLocalizedMessage( 1062334 ); // This item must be in your backpack to be used.
|
||||
else if ( obj.Axe( from, (BaseAxe)m_Tool ) )
|
||||
else if ( obj.Axe( from, axe ) )
|
||||
from.PlaySound( 0x13E );
|
||||
}
|
||||
else if ( m_System is Lumberjacking && targeted is ICarvable )
|
||||
((ICarvable)targeted).Carve( from, (Item)m_Tool );
|
||||
else if ( m_System is Lumberjacking && targeted is ICarvable carvable )
|
||||
carvable.Carve( from, m_Tool );
|
||||
else if ( m_System is Lumberjacking && FurnitureAttribute.Check( targeted as Item ) )
|
||||
DestroyFurniture( from, (Item)targeted );
|
||||
else if ( m_System is Mining && targeted is TreasureMap )
|
||||
((TreasureMap)targeted).OnBeginDig( from );
|
||||
else if ( m_System is Mining && targeted is TreasureMap map )
|
||||
map.OnBeginDig( from );
|
||||
else
|
||||
m_System.StartHarvesting( from, m_Tool, targeted );
|
||||
}
|
||||
|
|
@ -82,7 +74,7 @@ namespace Server.Engines.Harvest
|
|||
from.SendLocalizedMessage( 500446 ); // That is too far away.
|
||||
return;
|
||||
}
|
||||
else if ( !item.IsChildOf( from.Backpack ) && !item.Movable )
|
||||
if ( !item.IsChildOf( from.Backpack ) && !item.Movable )
|
||||
{
|
||||
from.SendLocalizedMessage( 500462 ); // You can't destroy that while it is here.
|
||||
return;
|
||||
|
|
@ -91,12 +83,12 @@ namespace Server.Engines.Harvest
|
|||
from.SendLocalizedMessage( 500461 ); // You destroy the item.
|
||||
Effects.PlaySound( item.GetWorldLocation(), item.Map, 0x3B3 );
|
||||
|
||||
if ( item is Container )
|
||||
if ( item is Container container )
|
||||
{
|
||||
if ( item is TrappableContainer )
|
||||
(item as TrappableContainer).ExecuteTrap( from );
|
||||
if ( container is TrappableContainer trappableContainer )
|
||||
trappableContainer.ExecuteTrap( from );
|
||||
|
||||
((Container)item).Destroy();
|
||||
container.Destroy();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -104,4 +96,4 @@ namespace Server.Engines.Harvest
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -140,9 +140,7 @@ namespace Server.Engines.Harvest
|
|||
|
||||
public override bool SpecialHarvest( Mobile from, Item tool, HarvestDefinition def, Map map, Point3D loc )
|
||||
{
|
||||
PlayerMobile player = from as PlayerMobile;
|
||||
|
||||
if ( player != null )
|
||||
if ( from is PlayerMobile player )
|
||||
{
|
||||
QuestSystem qs = player.Quest;
|
||||
|
||||
|
|
@ -230,14 +228,14 @@ namespace Server.Engines.Harvest
|
|||
if ( type == typeof( TreasureMap ) )
|
||||
{
|
||||
int level;
|
||||
if ( from is PlayerMobile && ((PlayerMobile)from).Young && from.Map == Map.Trammel && TreasureMap.IsInHavenIsland( from ) )
|
||||
if ( @from is PlayerMobile mobile && mobile.Young && mobile.Map == Map.Trammel && TreasureMap.IsInHavenIsland( from ) )
|
||||
level = 0;
|
||||
else
|
||||
level = 1;
|
||||
|
||||
return new TreasureMap( level, from.Map == Map.Felucca ? Map.Felucca : Map.Trammel );
|
||||
}
|
||||
else if ( type == typeof( MessageInABottle ) )
|
||||
if ( type == typeof( MessageInABottle ) )
|
||||
{
|
||||
return new MessageInABottle( from.Map == Map.Felucca ? Map.Felucca : Map.Trammel );
|
||||
}
|
||||
|
|
@ -329,14 +327,14 @@ namespace Server.Engines.Harvest
|
|||
|
||||
if ( preLoot != null )
|
||||
{
|
||||
if ( preLoot is IShipwreckedItem )
|
||||
( (IShipwreckedItem)preLoot ).IsShipwreckedItem = true;
|
||||
if ( preLoot is IShipwreckedItem shipwreckedItem )
|
||||
shipwreckedItem.IsShipwreckedItem = true;
|
||||
|
||||
return preLoot;
|
||||
}
|
||||
|
||||
LockableContainer chest;
|
||||
|
||||
|
||||
if ( Utility.RandomBool() )
|
||||
chest = new MetalGoldenChest();
|
||||
else
|
||||
|
|
@ -418,11 +416,10 @@ namespace Server.Engines.Harvest
|
|||
|
||||
public override void SendSuccessTo( Mobile from, Item item, HarvestResource resource )
|
||||
{
|
||||
if ( item is BigFish )
|
||||
if ( item is BigFish fish )
|
||||
{
|
||||
from.SendLocalizedMessage( 1042635 ); // Your fishing pole bends as you pull a big fish from the depths!
|
||||
|
||||
((BigFish)item).Fisher = from;
|
||||
fish.Fisher = from;
|
||||
}
|
||||
else if ( item is WoodenChest || item is MetalGoldenChest )
|
||||
{
|
||||
|
|
@ -496,10 +493,10 @@ namespace Server.Engines.Harvest
|
|||
Point3D loc;
|
||||
|
||||
if ( GetHarvestDetails( from, tool, toHarvest, out tileID, out map, out loc ) )
|
||||
Timer.DelayCall( TimeSpan.FromSeconds( 1.5 ),
|
||||
Timer.DelayCall( TimeSpan.FromSeconds( 1.5 ),
|
||||
delegate
|
||||
{
|
||||
if( Core.ML )
|
||||
if ( Core.ML )
|
||||
from.RevealingAction();
|
||||
|
||||
Effects.SendLocationEffect( loc, map, 0x352D, 16, 4 );
|
||||
|
|
@ -567,4 +564,4 @@ namespace Server.Engines.Harvest
|
|||
0x74B5, 0x75D5
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -175,8 +175,8 @@ namespace Server.Engines.Harvest
|
|||
public override void OnHarvestStarted( Mobile from, Item tool, HarvestDefinition def, object toHarvest )
|
||||
{
|
||||
base.OnHarvestStarted( from, tool, def, toHarvest );
|
||||
|
||||
if( Core.ML )
|
||||
|
||||
if ( Core.ML )
|
||||
from.RevealingAction();
|
||||
}
|
||||
|
||||
|
|
@ -212,4 +212,4 @@ namespace Server.Engines.Harvest
|
|||
};
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue