Fixes chaos damage bug with the spell system. Fixes various small other bugs. Fixes more merge cast type checks and uses default values.
This commit is contained in:
parent
9542c79ea4
commit
c155c82325
115 changed files with 644 additions and 1041 deletions
|
|
@ -77,8 +77,7 @@ namespace Server.SkillHandlers
|
|||
|
||||
protected override void OnTarget(Mobile from, object targeted)
|
||||
{
|
||||
BaseBook book = targeted as BaseBook;
|
||||
if (book == null)
|
||||
if (!(targeted is BaseBook book))
|
||||
{
|
||||
from.SendLocalizedMessage(1046296); // That is not a book
|
||||
}
|
||||
|
|
@ -122,9 +121,7 @@ namespace Server.SkillHandlers
|
|||
if (m_BookSrc.Deleted)
|
||||
return;
|
||||
|
||||
BaseBook bookDst = targeted as BaseBook;
|
||||
|
||||
if (bookDst == null)
|
||||
if (!(targeted is BaseBook bookDst))
|
||||
{
|
||||
from.SendLocalizedMessage(1046296); // That is not a book
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,10 +42,8 @@ namespace Server.SkillHandlers
|
|||
{
|
||||
from.RevealingAction();
|
||||
|
||||
if (targeted is BaseCreature && from.CanBeHarmful((Mobile)targeted, true))
|
||||
if (targeted is BaseCreature creature && from.CanBeHarmful(creature, true))
|
||||
{
|
||||
BaseCreature creature = (BaseCreature)targeted;
|
||||
|
||||
if (!m_Instrument.IsChildOf(from.Backpack))
|
||||
{
|
||||
from.SendLocalizedMessage(
|
||||
|
|
@ -91,10 +89,8 @@ namespace Server.SkillHandlers
|
|||
{
|
||||
from.RevealingAction();
|
||||
|
||||
if (targeted is BaseCreature)
|
||||
if (targeted is BaseCreature creature)
|
||||
{
|
||||
BaseCreature creature = (BaseCreature)targeted;
|
||||
|
||||
if (!m_Instrument.IsChildOf(from.Backpack))
|
||||
{
|
||||
from.SendLocalizedMessage(
|
||||
|
|
|
|||
|
|
@ -45,10 +45,8 @@ namespace Server.SkillHandlers
|
|||
{
|
||||
from.SendLocalizedMessage(502816); // You feel that such an action would be inappropriate
|
||||
}
|
||||
else if (targeted is TrappableContainer)
|
||||
else if (targeted is TrappableContainer targ)
|
||||
{
|
||||
TrappableContainer targ = (TrappableContainer)targeted;
|
||||
|
||||
from.Direction = from.GetDirectionTo(targ);
|
||||
|
||||
if (targ.TrapType == TrapType.None)
|
||||
|
|
|
|||
|
|
@ -28,9 +28,7 @@ namespace Server.SkillHandlers
|
|||
if (reg == null || reg.IsDisabled())
|
||||
return true; // not in town? we can snoop any npc
|
||||
|
||||
BaseCreature cret = to as BaseCreature;
|
||||
|
||||
if (to.Body.IsHuman && (cret == null || !cret.AlwaysAttackable && !cret.AlwaysMurderer))
|
||||
if (to.Body.IsHuman && (!(to is BaseCreature cret) || !cret.AlwaysAttackable && !cret.AlwaysMurderer))
|
||||
return false; // in town we cannot snoop blue human npcs
|
||||
|
||||
return true;
|
||||
|
|
@ -81,7 +79,7 @@ namespace Server.SkillHandlers
|
|||
|
||||
if (from.AccessLevel > AccessLevel.Player || from.CheckTargetSkill(SkillName.Snooping, cont, 0.0, 100.0))
|
||||
{
|
||||
if (cont is TrappableContainer && ((TrappableContainer)cont).ExecuteTrap(from))
|
||||
if (cont is TrappableContainer container && container.ExecuteTrap(from))
|
||||
return;
|
||||
|
||||
cont.DisplayTo(from);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using Server.Items;
|
||||
using Server.Network;
|
||||
using Server.Spells;
|
||||
|
|
@ -134,14 +135,9 @@ namespace Server.SkillHandlers
|
|||
|
||||
public override void OnCast()
|
||||
{
|
||||
Corpse toChannel = null;
|
||||
|
||||
foreach (Item item in Caster.GetItemsInRange(3))
|
||||
if (item is Corpse && !((Corpse)item).Channeled)
|
||||
{
|
||||
toChannel = (Corpse)item;
|
||||
break;
|
||||
}
|
||||
IPooledEnumerable<Corpse> eable = Caster.GetItemsInRange<Corpse>(3);
|
||||
Corpse toChannel = eable.ToList().Find(item => item is Corpse corpse && !corpse.Channeled);
|
||||
eable.Free();
|
||||
|
||||
int max, min, mana, number;
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ namespace Server.SkillHandlers
|
|||
|
||||
public static bool IsInGuild(Mobile m)
|
||||
{
|
||||
return m is PlayerMobile && ((PlayerMobile)m).NpcGuild == NpcGuild.ThievesGuild;
|
||||
return m is PlayerMobile mobile && mobile.NpcGuild == NpcGuild.ThievesGuild;
|
||||
}
|
||||
|
||||
public static bool IsInnocentTo(Mobile from, Mobile to)
|
||||
|
|
@ -72,7 +72,6 @@ namespace Server.SkillHandlers
|
|||
public StealingTarget(Mobile thief) : base(1, false, TargetFlags.None)
|
||||
{
|
||||
m_Thief = thief;
|
||||
|
||||
AllowNonlocal = true;
|
||||
}
|
||||
|
||||
|
|
@ -81,6 +80,7 @@ namespace Server.SkillHandlers
|
|||
Item stolen = null;
|
||||
|
||||
object root = toSteal.RootParent;
|
||||
Mobile mobRoot = root as Mobile;
|
||||
|
||||
StealableArtifactsSpawner.StealableInstance si = null;
|
||||
if (toSteal.Parent == null || !toSteal.Movable)
|
||||
|
|
@ -94,16 +94,16 @@ namespace Server.SkillHandlers
|
|||
{
|
||||
m_Thief.SendMessage("You may not steal in this area.");
|
||||
}
|
||||
else if (root is Mobile && ((Mobile)root).Player && !IsInGuild(m_Thief))
|
||||
else if (mobRoot?.Player == true && !IsInGuild(m_Thief))
|
||||
{
|
||||
m_Thief.SendLocalizedMessage(1005596); // You must be in the thieves guild to steal from other players.
|
||||
}
|
||||
else if (SuspendOnMurder && root is Mobile && ((Mobile)root).Player && IsInGuild(m_Thief) &&
|
||||
else if (SuspendOnMurder && mobRoot?.Player == true && IsInGuild(m_Thief) &&
|
||||
m_Thief.Kills > 0)
|
||||
{
|
||||
m_Thief.SendLocalizedMessage(502706); // You are currently suspended from the thieves guild.
|
||||
}
|
||||
else if (root is BaseVendor && ((BaseVendor)root).IsInvulnerable)
|
||||
else if (root is BaseVendor vendor && vendor.IsInvulnerable)
|
||||
{
|
||||
m_Thief.SendLocalizedMessage(1005598); // You can't steal from shopkeepers.
|
||||
}
|
||||
|
|
@ -122,14 +122,12 @@ namespace Server.SkillHandlers
|
|||
|
||||
#region Sigils
|
||||
|
||||
else if (toSteal is Sigil)
|
||||
else if (toSteal is Sigil sig)
|
||||
{
|
||||
PlayerState pl = PlayerState.Find(m_Thief);
|
||||
Faction faction = pl?.Faction;
|
||||
|
||||
Sigil sig = (Sigil)toSteal;
|
||||
|
||||
if (!m_Thief.InRange(toSteal.GetWorldLocation(), 1))
|
||||
if (!m_Thief.InRange(sig.GetWorldLocation(), 1))
|
||||
{
|
||||
m_Thief.SendLocalizedMessage(502703); // You must be standing next to an item to steal it.
|
||||
}
|
||||
|
|
@ -242,11 +240,11 @@ namespace Server.SkillHandlers
|
|||
{
|
||||
m_Thief.SendLocalizedMessage(502704); // You catch yourself red-handed.
|
||||
}
|
||||
else if (root is Mobile && ((Mobile)root).AccessLevel > AccessLevel.Player)
|
||||
else if (mobRoot?.AccessLevel > AccessLevel.Player)
|
||||
{
|
||||
m_Thief.SendLocalizedMessage(502710); // You can't steal that!
|
||||
}
|
||||
else if (root is Mobile && !m_Thief.CanBeHarmful((Mobile)root))
|
||||
else if (mobRoot != null && !m_Thief.CanBeHarmful((Mobile)root))
|
||||
{
|
||||
}
|
||||
else if (root is Corpse)
|
||||
|
|
@ -337,20 +335,20 @@ namespace Server.SkillHandlers
|
|||
object root = null;
|
||||
bool caught = false;
|
||||
|
||||
if (target is Item)
|
||||
if (target is Item item)
|
||||
{
|
||||
root = ((Item)target).RootParent;
|
||||
stolen = TryStealItem((Item)target, ref caught);
|
||||
root = item.RootParent;
|
||||
stolen = TryStealItem(item, ref caught);
|
||||
}
|
||||
else if (target is Mobile)
|
||||
else if (target is Mobile mobile)
|
||||
{
|
||||
Container pack = ((Mobile)target).Backpack;
|
||||
Container pack = mobile.Backpack;
|
||||
|
||||
if (pack != null && pack.Items.Count > 0)
|
||||
{
|
||||
int randomIndex = Utility.Random(pack.Items.Count);
|
||||
|
||||
root = target;
|
||||
root = mobile;
|
||||
stolen = TryStealItem(pack.Items[randomIndex], ref caught);
|
||||
}
|
||||
}
|
||||
|
|
@ -358,28 +356,27 @@ namespace Server.SkillHandlers
|
|||
{
|
||||
m_Thief.SendLocalizedMessage(502710); // You can't steal that!
|
||||
}
|
||||
|
||||
Mobile mobRoot = root as Mobile;
|
||||
|
||||
if (stolen != null)
|
||||
{
|
||||
from.AddToBackpack(stolen);
|
||||
|
||||
if (!(stolen is Container || stolen.Stackable)) StolenItem.Add(stolen, m_Thief, root as Mobile);
|
||||
if (!(stolen is Container || stolen.Stackable))
|
||||
StolenItem.Add(stolen, m_Thief, mobRoot);
|
||||
}
|
||||
|
||||
Corpse corpse = root as Corpse;
|
||||
|
||||
if (caught)
|
||||
{
|
||||
if (root == null)
|
||||
if (root == null || corpse?.IsCriminalAction(m_Thief) == true)
|
||||
{
|
||||
m_Thief.CriminalAction(false);
|
||||
}
|
||||
else if (root is Corpse && ((Corpse)root).IsCriminalAction(m_Thief))
|
||||
else if (mobRoot != null)
|
||||
{
|
||||
m_Thief.CriminalAction(false);
|
||||
}
|
||||
else if (root is Mobile)
|
||||
{
|
||||
Mobile mobRoot = (Mobile)root;
|
||||
|
||||
if (!IsInGuild(mobRoot) && IsInnocentTo(m_Thief, mobRoot))
|
||||
m_Thief.CriminalAction(false);
|
||||
|
||||
|
|
@ -390,16 +387,14 @@ namespace Server.SkillHandlers
|
|||
ns.Mobile.SendMessage(message);
|
||||
}
|
||||
}
|
||||
else if (root is Corpse && ((Corpse)root).IsCriminalAction(m_Thief))
|
||||
else if (corpse?.IsCriminalAction(m_Thief) == true)
|
||||
{
|
||||
m_Thief.CriminalAction(false);
|
||||
}
|
||||
|
||||
if (root is Mobile && ((Mobile)root).Player && m_Thief is PlayerMobile &&
|
||||
IsInnocentTo(m_Thief, (Mobile)root) && !IsInGuild((Mobile)root))
|
||||
if (mobRoot?.Player == true && m_Thief is PlayerMobile pm &&
|
||||
IsInnocentTo(pm, mobRoot) && !IsInGuild(mobRoot))
|
||||
{
|
||||
PlayerMobile pm = (PlayerMobile)m_Thief;
|
||||
|
||||
pm.PermaFlags.Add((Mobile)root);
|
||||
pm.Delta(MobileDelta.Noto);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,9 +38,7 @@ namespace Server.SkillHandlers
|
|||
|
||||
for (int i = 0; i < m.Items.Count; i++)
|
||||
{
|
||||
BaseArmor armor = m.Items[i] as BaseArmor;
|
||||
|
||||
if (armor == null)
|
||||
if (!(m.Items[i] is BaseArmor armor))
|
||||
continue;
|
||||
|
||||
int materialType = (int)armor.MaterialType;
|
||||
|
|
@ -91,9 +89,7 @@ namespace Server.SkillHandlers
|
|||
|
||||
m.AllowedStealthSteps = steps;
|
||||
|
||||
PlayerMobile pm = m as PlayerMobile; // IsStealthing should be moved to Server.Mobiles
|
||||
|
||||
if (pm != null)
|
||||
if (m is PlayerMobile pm)
|
||||
pm.IsStealthing = true;
|
||||
|
||||
m.SendLocalizedMessage(502730); // You begin to move quietly.
|
||||
|
|
|
|||
|
|
@ -35,10 +35,8 @@ namespace Server.SkillHandlers
|
|||
{
|
||||
from.SendLocalizedMessage(502816); // You feel that such an action would be inappropriate.
|
||||
}
|
||||
else if (targeted is Food)
|
||||
else if (targeted is Food food)
|
||||
{
|
||||
Food food = (Food)targeted;
|
||||
|
||||
if (from.CheckTargetSkill(SkillName.TasteID, food, 0, 100))
|
||||
{
|
||||
if (food.Poison != null)
|
||||
|
|
@ -52,17 +50,13 @@ namespace Server.SkillHandlers
|
|||
food.SendLocalizedMessageTo(from, 502823); // You cannot discern anything about this substance.
|
||||
}
|
||||
}
|
||||
else if (targeted is BasePotion)
|
||||
else if (targeted is BasePotion potion)
|
||||
{
|
||||
BasePotion potion = (BasePotion)targeted;
|
||||
|
||||
potion.SendLocalizedMessageTo(from, 502813); // You already know what kind of potion that is.
|
||||
potion.SendLocalizedMessageTo(from, potion.LabelNumber);
|
||||
}
|
||||
else if (targeted is PotionKeg)
|
||||
else if (targeted is PotionKeg keg)
|
||||
{
|
||||
PotionKeg keg = (PotionKeg)targeted;
|
||||
|
||||
if (keg.Held <= 0)
|
||||
{
|
||||
keg.SendLocalizedMessageTo(from, 502228); // There is nothing in the keg to taste!
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue