Modernization Fixes & Updates to Default Values (#3)

This commit is contained in:
Kamron Batman 2018-10-28 00:33:16 -07:00 committed by GitHub
parent 445eddff68
commit dcf64091b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
768 changed files with 10507 additions and 14196 deletions

View file

@ -34,21 +34,19 @@ namespace Server.SkillHandlers
from.LocalOverheadMessage(MessageType.Regular, 0x3B2,
500324); // You know yourself quite well enough already.
}
else if (targeted is TownCrier)
else if (targeted is TownCrier crier)
{
((TownCrier)targeted).PrivateOverheadMessage(MessageType.Regular, 0x3B2, 500322,
crier.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 500322,
from.NetState); // This person looks fine to me, though he may have some news...
}
else if (targeted is BaseVendor && ((BaseVendor)targeted).IsInvulnerable)
else if (targeted is BaseVendor vendor && vendor.IsInvulnerable)
{
((BaseVendor)targeted).PrivateOverheadMessage(MessageType.Regular, 0x3B2, 500326,
vendor.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 500326,
from.NetState); // That can not be inspected.
}
else if (targeted is Mobile)
else if (targeted is Mobile targ)
{
Mobile targ = (Mobile)targeted;
int marginOfError = Math.Max(0, 25 - (int)(from.Skills[SkillName.Anatomy].Value / 4));
int marginOfError = Math.Max(0, 25 - (int)(from.Skills.Anatomy.Value / 4));
int str = targ.Str + Utility.RandomMinMax(-marginOfError, +marginOfError);
int dex = targ.Dex + Utility.RandomMinMax(-marginOfError, +marginOfError);
@ -73,7 +71,7 @@ namespace Server.SkillHandlers
targ.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1038045 + strMod * 11 + dexMod,
from.NetState); // That looks [strong] and [dexterous].
if (from.Skills[SkillName.Anatomy].Base >= 65.0)
if (from.Skills.Anatomy.Base >= 65.0)
targ.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1038303 + stmMod,
from.NetState); // That being is at [10,20,...] percent endurance.
}

View file

@ -34,20 +34,18 @@ namespace Server.SkillHandlers
{
from.SendLocalizedMessage(500331); // The spirits of the dead are not the province of animal lore.
}
else if (targeted is BaseCreature)
else if (targeted is BaseCreature c)
{
BaseCreature c = (BaseCreature)targeted;
if (!c.IsDeadPet)
{
if (c.Body.IsAnimal || c.Body.IsMonster || c.Body.IsSea)
{
if (!c.Controlled && from.Skills[SkillName.AnimalLore].Value < 100.0)
if (!c.Controlled && from.Skills.AnimalLore.Value < 100.0)
{
from.SendLocalizedMessage(
1049674); // At your skill level, you can only lore tamed creatures.
}
else if (!c.Controlled && !c.Tamable && from.Skills[SkillName.AnimalLore].Value < 110.0)
else if (!c.Controlled && !c.Tamable && from.Skills.AnimalLore.Value < 110.0)
{
from.SendLocalizedMessage(
1049675); // At your skill level, you can only lore tamed or tameable creatures.
@ -58,7 +56,7 @@ namespace Server.SkillHandlers
}
else
{
from.CloseGump(typeof(AnimalLoreGump));
from.CloseGump<AnimalLoreGump>();
from.SendGump(new AnimalLoreGump(c));
}
}

View file

@ -36,9 +36,7 @@ namespace Server.SkillHandlers
public static bool CheckMastery(Mobile tamer, BaseCreature creature)
{
BaseCreature familiar = (BaseCreature)SummonFamiliarSpell.Table[tamer];
if (familiar != null && !familiar.Deleted && familiar is DarkWolfFamiliar)
if (SummonFamiliarSpell.Table[tamer] is DarkWolfFamiliar familiar && !familiar.Deleted)
if (creature is DireWolf || creature is GreyWolf || creature is TimberWolf || creature is WhiteWolf ||
creature is BakeKitsune)
return true;
@ -107,133 +105,133 @@ namespace Server.SkillHandlers
from.NextSkillTime = Core.TickCount;
}
public virtual void ResetPacify(object obj)
{
if (obj is BaseCreature) ((BaseCreature)obj).BardPacified = true;
}
protected override void OnTarget(Mobile from, object targeted)
{
from.RevealingAction();
if (targeted is Mobile)
if (!(targeted is Mobile mobile))
{
if (targeted is BaseCreature)
from.SendLocalizedMessage(502801); // You can't tame that!
return;
}
if (!(mobile is BaseCreature creature))
{
mobile.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502469,
from.NetState); // That being cannot be tamed.
return;
}
if (!creature.Tamable)
{
creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1049655,
from.NetState); // That creature cannot be tamed.
return;
}
if (creature.Controlled)
{
creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502804,
from.NetState); // That animal looks tame already.
return;
}
if (from.Female && !creature.AllowFemaleTamer)
{
creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1049653,
from.NetState); // That creature can only be tamed by males.
return;
}
if (!from.Female && !creature.AllowMaleTamer)
{
creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1049652,
from.NetState); // That creature can only be tamed by females.
return;
}
if (creature is CuSidhe && from.Race != Race.Elf)
{
creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502801,
from.NetState); // You can't tame that!
return;
}
if (from.Followers + creature.ControlSlots > from.FollowersMax)
{
from.SendLocalizedMessage(1049611); // You have too many followers to tame that creature.
return;
}
if (creature.Owners.Count >= BaseCreature.MaxOwners && !creature.Owners.Contains(from))
{
creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1005615,
from.NetState); // This animal has had too many owners and is too upset for you to tame.
return;
}
if (MustBeSubdued(creature))
{
creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1054025,
from.NetState); // You must subdue this creature before you can tame it!
return;
}
if (!(CheckMastery(from, creature) || from.Skills.AnimalTaming.Value >= creature.MinTameSkill))
{
creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502806,
from.NetState); // You have no chance of taming this creature.
return;
}
if (creature is FactionWarHorse warHorse)
{
Faction faction = Faction.Find(from);
if (faction == null || faction != warHorse.Faction)
{
BaseCreature creature = (BaseCreature)targeted;
if (!creature.Tamable)
{
creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1049655,
from.NetState); // That creature cannot be tamed.
}
else if (creature.Controlled)
{
creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502804,
from.NetState); // That animal looks tame already.
}
else if (from.Female && !creature.AllowFemaleTamer)
{
creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1049653,
from.NetState); // That creature can only be tamed by males.
}
else if (!from.Female && !creature.AllowMaleTamer)
{
creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1049652,
from.NetState); // That creature can only be tamed by females.
}
else if (creature is CuSidhe && from.Race != Race.Elf)
{
creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502801,
from.NetState); // You can't tame that!
}
else if (from.Followers + creature.ControlSlots > from.FollowersMax)
{
from.SendLocalizedMessage(1049611); // You have too many followers to tame that creature.
}
else if (creature.Owners.Count >= BaseCreature.MaxOwners && !creature.Owners.Contains(from))
{
creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1005615,
from.NetState); // This animal has had too many owners and is too upset for you to tame.
}
else if (MustBeSubdued(creature))
{
creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1054025,
from.NetState); // You must subdue this creature before you can tame it!
}
else if (CheckMastery(from, creature) ||
from.Skills[SkillName.AnimalTaming].Value >= creature.MinTameSkill)
{
FactionWarHorse warHorse = creature as FactionWarHorse;
if (warHorse != null)
{
Faction faction = Faction.Find(from);
if (faction == null || faction != warHorse.Faction)
{
creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1042590,
from.NetState); // You cannot tame this creature.
return;
}
}
if (m_BeingTamed.ContainsKey(creature))
{
creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502802,
from.NetState); // Someone else is already taming this.
}
else if (creature.CanAngerOnTame && 0.95 >= Utility.RandomDouble())
{
creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502805,
from.NetState); // You seem to anger the beast!
creature.PlaySound(creature.GetAngerSound());
creature.Direction = creature.GetDirectionTo(from);
if (creature.BardPacified && Utility.RandomDouble() > .24)
Timer.DelayCall(TimeSpan.FromSeconds(2.0), new TimerStateCallback(ResetPacify),
creature);
else
creature.BardEndTime = DateTime.UtcNow;
creature.BardPacified = false;
creature.AIObject?.DoMove(creature.Direction);
if (from is PlayerMobile &&
!(((PlayerMobile)from).HonorActive ||
TransformationSpellHelper.UnderTransformation(from, typeof(EtherealVoyageSpell))))
creature.Combatant = from;
}
else
{
m_BeingTamed[creature] = from;
from.LocalOverheadMessage(MessageType.Emote, 0x59,
1010597); // You start to tame the creature.
from.NonlocalOverheadMessage(MessageType.Emote, 0x59,
1010598); // *begins taming a creature.*
new InternalTimer(from, creature, Utility.Random(3, 2)).Start();
m_SetSkillTime = false;
}
}
else
{
creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502806,
from.NetState); // You have no chance of taming this creature.
}
creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1042590,
from.NetState); // You cannot tame this creature.
return;
}
}
if (m_BeingTamed.ContainsKey(creature))
{
creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502802,
from.NetState); // Someone else is already taming this.
}
else if (creature.CanAngerOnTame && 0.95 >= Utility.RandomDouble())
{
creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502805,
from.NetState); // You seem to anger the beast!
creature.PlaySound(creature.GetAngerSound());
creature.Direction = creature.GetDirectionTo(from);
if (creature.BardPacified && Utility.RandomDouble() > .24)
Timer.DelayCall(TimeSpan.FromSeconds(2.0), () => creature.BardPacified = true);
else
{
((Mobile)targeted).PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502469,
from.NetState); // That being cannot be tamed.
}
creature.BardEndTime = DateTime.UtcNow;
creature.BardPacified = false;
creature.AIObject?.DoMove(creature.Direction);
if (from is PlayerMobile pm &&
!(pm.HonorActive ||
TransformationSpellHelper.UnderTransformation(pm, typeof(EtherealVoyageSpell))))
creature.Combatant = pm;
}
else
{
from.SendLocalizedMessage(502801); // You can't tame that!
m_BeingTamed[creature] = from;
from.LocalOverheadMessage(MessageType.Emote, 0x59,
1010597); // You start to tame the creature.
from.NonlocalOverheadMessage(MessageType.Emote, 0x59,
1010598); // *begins taming a creature.*
new InternalTimer(from, creature, Utility.Random(3, 2)).Start();
m_SetSkillTime = false;
}
}
@ -378,8 +376,8 @@ namespace Server.SkillHandlers
if (m_Creature is GreaterDragon)
{
ScaleSkills(m_Creature, 0.72, 0.90); // 72% of original skills trainable to 90%
m_Creature.Skills[SkillName.Magery].Base =
m_Creature.Skills[SkillName.Magery]
m_Creature.Skills.Magery.Base =
m_Creature.Skills.Magery
.Cap; // Greater dragons have a 90% cap reduction and 90% skill reduction on magery
}
else if (m_Paralyzed)
@ -434,4 +432,4 @@ namespace Server.SkillHandlers
}
}
}
}
}

View file

@ -32,12 +32,10 @@ namespace Server.SkillHandlers
protected override void OnTarget(Mobile from, object targeted)
{
if (targeted is BaseWeapon)
if (targeted is BaseWeapon weap)
{
if (from.CheckTargetSkill(SkillName.ArmsLore, targeted, 0, 100))
if (from.CheckTargetSkill(SkillName.ArmsLore, weap, 0, 100))
{
BaseWeapon weap = (BaseWeapon)targeted;
if (weap.MaxHitPoints != 0)
{
int hp = (int)(weap.HitPoints / (double)weap.MaxHitPoints * 10);
@ -93,12 +91,10 @@ namespace Server.SkillHandlers
from.SendLocalizedMessage(500353); // You are not certain...
}
}
else if (targeted is BaseArmor)
else if (targeted is BaseArmor arm)
{
if (from.CheckTargetSkill(SkillName.ArmsLore, targeted, 0, 100))
if (from.CheckTargetSkill(SkillName.ArmsLore, arm, 0, 100))
{
BaseArmor arm = (BaseArmor)targeted;
if (arm.MaxHitPoints != 0)
{
int hp = (int)(arm.HitPoints / (double)arm.MaxHitPoints * 10);
@ -137,11 +133,9 @@ namespace Server.SkillHandlers
from.SendLocalizedMessage(500353); // You are not certain...
}
}
else if (targeted is SwampDragon && ((SwampDragon)targeted).HasBarding)
else if (targeted is SwampDragon pet && pet.HasBarding)
{
SwampDragon pet = (SwampDragon)targeted;
if (from.CheckTargetSkill(SkillName.ArmsLore, targeted, 0, 100))
if (from.CheckTargetSkill(SkillName.ArmsLore, pet, 0, 100))
{
int perc = 4 * pet.BardingHP / pet.BardingMaxHP;

View file

@ -45,10 +45,8 @@ namespace Server.SkillHandlers
int number = -1;
if (targeted is Mobile)
if (targeted is Mobile targ)
{
Mobile targ = (Mobile)targeted;
if (targ.Player) // We can't beg from players
{
number = 500398; // Perhaps just asking would work better.
@ -71,7 +69,7 @@ namespace Server.SkillHandlers
}
else
{
// Face eachother
// Face each other
from.Direction = from.GetDirectionTo(targ);
targ.Direction = targ.GetDirectionTo(from);

View file

@ -32,16 +32,16 @@ namespace Server.SkillHandlers
bool foundAnyone = false;
Point3D p;
if (targ is Mobile)
p = ((Mobile)targ).Location;
else if (targ is Item)
p = ((Item)targ).Location;
else if (targ is IPoint3D)
p = new Point3D((IPoint3D)targ);
if (targ is Mobile mobile)
p = mobile.Location;
else if (targ is Item item)
p = item.Location;
else if (targ is IPoint3D d)
p = new Point3D(d);
else
p = src.Location;
double srcSkill = src.Skills[SkillName.DetectHidden].Value;
double srcSkill = src.Skills.DetectHidden.Value;
int range = (int)(srcSkill / 10.0);
if (!src.CheckSkill(SkillName.DetectHidden, 0.0, 100.0))
@ -62,7 +62,7 @@ namespace Server.SkillHandlers
if (trg.Hidden && src != trg)
{
double ss = srcSkill + Utility.Random(21) - 10;
double ts = trg.Skills[SkillName.Hiding].Value + Utility.Random(21) - 10;
double ts = trg.Skills.Hiding.Value + Utility.Random(21) - 10;
if (src.AccessLevel >= trg.AccessLevel && (ss >= ts || inHouse && house.IsInside(trg)))
{

View file

@ -1,5 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Server.Items;
using Server.Mobiles;
using Server.Targeting;
@ -8,7 +9,7 @@ namespace Server.SkillHandlers
{
public class Discordance
{
private static Hashtable m_Table = new Hashtable();
private static Dictionary<Mobile, DiscordanceInfo> m_Table = new Dictionary<Mobile, DiscordanceInfo>();
public static void Initialize()
{
@ -34,7 +35,7 @@ namespace Server.SkillHandlers
public static bool GetEffect(Mobile targ, ref int effect)
{
DiscordanceInfo info = m_Table[targ] as DiscordanceInfo;
DiscordanceInfo info = m_Table[targ];
if (info == null)
return false;
@ -49,7 +50,7 @@ namespace Server.SkillHandlers
Mobile targ = info.m_Creature;
bool ends = false;
// According to uoherald bard must remain alive, visible, and
// According to uoherald bard must remain alive, visible, and
// within range of the target or the effect ends in 15 seconds.
if (!targ.Alive || targ.Deleted || !from.Alive || from.Hidden)
{
@ -95,10 +96,10 @@ namespace Server.SkillHandlers
public bool m_Ending;
public DateTime m_EndTime;
public Mobile m_From;
public ArrayList m_Mods;
public List<object> m_Mods;
public Timer m_Timer;
public DiscordanceInfo(Mobile from, Mobile creature, int effect, ArrayList mods)
public DiscordanceInfo(Mobile from, Mobile creature, int effect, List<object> mods)
{
m_From = from;
m_Creature = creature;
@ -116,12 +117,12 @@ namespace Server.SkillHandlers
{
object mod = m_Mods[i];
if (mod is ResistanceMod)
m_Creature.AddResistanceMod((ResistanceMod)mod);
else if (mod is StatMod)
m_Creature.AddStatMod((StatMod)mod);
else if (mod is SkillMod)
m_Creature.AddSkillMod((SkillMod)mod);
if (mod is ResistanceMod resistanceMod)
m_Creature.AddResistanceMod(resistanceMod);
else if (mod is StatMod statMod)
m_Creature.AddStatMod(statMod);
else if (mod is SkillMod skillMod)
m_Creature.AddSkillMod(skillMod);
}
}
@ -131,12 +132,12 @@ namespace Server.SkillHandlers
{
object mod = m_Mods[i];
if (mod is ResistanceMod)
m_Creature.RemoveResistanceMod((ResistanceMod)mod);
else if (mod is StatMod)
m_Creature.RemoveStatMod(((StatMod)mod).Name);
else if (mod is SkillMod)
m_Creature.RemoveSkillMod((SkillMod)mod);
if (mod is ResistanceMod resistanceMod)
m_Creature.RemoveResistanceMod(resistanceMod);
else if (mod is StatMod statMod)
m_Creature.RemoveStatMod(statMod.Name);
else if (mod is SkillMod skillMod)
m_Creature.RemoveSkillMod(skillMod);
}
}
}
@ -161,24 +162,22 @@ namespace Server.SkillHandlers
from.SendLocalizedMessage(
1062488); // The instrument you are trying to play is no longer in your backpack!
}
else if (target is Mobile)
else if (target is Mobile targ)
{
Mobile targ = (Mobile)target;
if (targ == from || targ is BaseCreature &&
(((BaseCreature)targ).BardImmune || !from.CanBeHarmful(targ, false)) &&
((BaseCreature)targ).ControlMaster != from)
if (targ == from || targ is BaseCreature bc &&
(bc.BardImmune || !from.CanBeHarmful(bc, false)) &&
bc.ControlMaster != from)
{
from.SendLocalizedMessage(1049535); // A song of discord would have no effect on that.
}
else if (m_Table.Contains(targ)) //Already discorded
else if (m_Table.ContainsKey(targ)) //Already discorded
{
from.SendLocalizedMessage(1049537); // Your target is already in discord.
}
else if (!targ.Player)
{
double diff = m_Instrument.GetDifficultyFor(targ) - 10.0;
double music = from.Skills[SkillName.Musicianship].Value;
double music = from.Skills.Musicianship.Value;
if (music > 100.0)
diff -= (music - 100.0) * 0.5;
@ -189,19 +188,19 @@ namespace Server.SkillHandlers
m_Instrument.PlayInstrumentBadly(from);
m_Instrument.ConsumeUse(from);
}
else if (from.CheckTargetSkill(SkillName.Discordance, target, diff - 25.0, diff + 25.0))
else if (from.CheckTargetSkill(SkillName.Discordance, targ, diff - 25.0, diff + 25.0))
{
from.SendLocalizedMessage(1049539); // You play the song surpressing your targets strength
m_Instrument.PlayInstrumentWell(from);
m_Instrument.ConsumeUse(from);
ArrayList mods = new ArrayList();
List<object> mods = new List<object>();
int effect;
double scalar;
if (Core.AOS)
{
double discord = from.Skills[SkillName.Discordance].Value;
double discord = from.Skills.Discordance.Value;
if (discord > 100.0)
effect = -20 + (int)((discord - 100.0) / -2.5);
@ -225,7 +224,7 @@ namespace Server.SkillHandlers
}
else
{
effect = (int)(from.Skills[SkillName.Discordance].Value / -5.0);
effect = (int)(from.Skills.Discordance.Value / -5.0);
scalar = effect * 0.01;
mods.Add(new StatMod(StatType.Str, "DiscordanceStr", (int)(targ.RawStr * scalar),
@ -267,4 +266,4 @@ namespace Server.SkillHandlers
}
}
}
}
}

View file

@ -33,21 +33,19 @@ namespace Server.SkillHandlers
{
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 500910); // Hmm, that person looks really silly.
}
else if (targeted is TownCrier)
else if (targeted is TownCrier crier)
{
((TownCrier)targeted).PrivateOverheadMessage(MessageType.Regular, 0x3B2, 500907,
crier.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 500907,
from.NetState); // He looks smart enough to remember the news. Ask him about it.
}
else if (targeted is BaseVendor && ((BaseVendor)targeted).IsInvulnerable)
else if (targeted is BaseVendor vendor && vendor.IsInvulnerable)
{
((BaseVendor)targeted).PrivateOverheadMessage(MessageType.Regular, 0x3B2, 500909,
vendor.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 500909,
from.NetState); // That person could probably calculate the cost of what you buy from them.
}
else if (targeted is Mobile)
else if (targeted is Mobile targ)
{
Mobile targ = (Mobile)targeted;
int marginOfError = Math.Max(0, 20 - (int)(from.Skills[SkillName.EvalInt].Value / 5));
int marginOfError = Math.Max(0, 20 - (int)(from.Skills.EvalInt.Value / 5));
int intel = targ.Int + Utility.RandomMinMax(-marginOfError, +marginOfError);
int mana = targ.Mana * 100 / Math.Max(targ.ManaMax, 1) +
@ -74,7 +72,7 @@ namespace Server.SkillHandlers
targ.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1038169 + intMod + body,
from.NetState); // He/She/It looks [slighly less intelligent than a rock.] [Of Average intellect] [etc...]
if (from.Skills[SkillName.EvalInt].Base >= 76.0)
if (from.Skills.EvalInt.Base >= 76.0)
targ.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1038202 + mnMod,
from.NetState); // That being is at [10,20,...] percent mental strength.
}

View file

@ -35,7 +35,7 @@ namespace Server.SkillHandlers
{
if (from.CheckTargetSkill(SkillName.Forensics, target, 40.0, 100.0))
{
if (target is PlayerMobile && ((PlayerMobile)target).NpcGuild == NpcGuild.ThievesGuild)
if (target is PlayerMobile pm && pm.NpcGuild == NpcGuild.ThievesGuild)
from.SendLocalizedMessage(501004); //That individual is a thief!
else
from.SendLocalizedMessage(501003); //You notice nothing unusual.
@ -45,12 +45,10 @@ namespace Server.SkillHandlers
from.SendLocalizedMessage(501001); //You cannot determain anything useful.
}
}
else if (target is Corpse)
else if (target is Corpse c)
{
if (from.CheckTargetSkill(SkillName.Forensics, target, 0.0, 100.0))
if (from.CheckTargetSkill(SkillName.Forensics, c, 0.0, 100.0))
{
Corpse c = (Corpse)target;
if (c.m_Forensicist != null)
from.SendLocalizedMessage(1042750,
c.m_Forensicist); // The forensicist ~1_NAME~ has already discovered that:
@ -84,9 +82,8 @@ namespace Server.SkillHandlers
from.SendLocalizedMessage(501001); //You cannot determain anything useful.
}
}
else if (target is ILockpickable)
else if (target is ILockpickable p)
{
ILockpickable p = (ILockpickable)target;
if (p.Picker != null)
from.SendLocalizedMessage(1042749, p.Picker.Name); //This lock was opened by ~1_PICKER_NAME~
else

View file

@ -50,8 +50,8 @@ namespace Server.SkillHandlers
bonus = 50.0;
}
//int range = 18 - (int)(m.Skills[SkillName.Hiding].Value / 10);
int range = Math.Min((int)((100 - m.Skills[SkillName.Hiding].Value) / 2) + 8,
//int range = 18 - (int)(m.Skills.Hiding.Value / 10);
int range = Math.Min((int)((100 - m.Skills.Hiding.Value) / 2) + 8,
18); //Cap of 18 not OSI-exact, intentional difference
bool badCombat = !CombatOverride && m.Combatant != null && m.InRange(m.Combatant.Location, range) &&

View file

@ -29,26 +29,26 @@ namespace Server.Items
protected override void OnTarget(Mobile from, object o)
{
if (o is Item)
if (o is Item item)
{
if (from.CheckTargetSkill(SkillName.ItemID, o, 0, 100))
if (from.CheckTargetSkill(SkillName.ItemID, item, 0, 100))
{
if (o is BaseWeapon)
((BaseWeapon)o).Identified = true;
else if (o is BaseArmor)
((BaseArmor)o).Identified = true;
if (item is BaseWeapon weapon)
weapon.Identified = true;
else if (item is BaseArmor armor)
armor.Identified = true;
if (!Core.AOS)
((Item)o).OnSingleClick(from);
item.OnSingleClick(from);
}
else
{
from.SendLocalizedMessage(500353); // You are not certain...
}
}
else if (o is Mobile)
else if (o is Mobile mobile)
{
((Mobile)o).OnSingleClick(from);
mobile.OnSingleClick(from);
}
else
{

View file

@ -19,10 +19,10 @@ namespace Server.SkillHandlers
if (item is Spellbook || item is Runebook)
return true;
if (Core.AOS && item is BaseWeapon && ((BaseWeapon)item).Attributes.SpellChanneling != 0)
if (Core.AOS && item is BaseWeapon weapon && weapon.Attributes.SpellChanneling != 0)
return true;
if (Core.AOS && item is BaseArmor && ((BaseArmor)item).Attributes.SpellChanneling != 0)
if (Core.AOS && item is BaseArmor armor && armor.Attributes.SpellChanneling != 0)
return true;
return false;
@ -78,7 +78,7 @@ namespace Server.SkillHandlers
return TimeSpan.FromSeconds(2.5);
}
double skillVal = m.Skills[SkillName.Meditation].Value;
double skillVal = m.Skills.Meditation.Value;
double chance = (50.0 + (skillVal - (m.ManaMax - m.Mana)) * 2) / 100;
if (chance > Utility.RandomDouble())

View file

@ -51,15 +51,15 @@ namespace Server.SkillHandlers
{
from.RevealingAction();
if (!(targeted is Mobile))
if (!(targeted is Mobile targ))
{
from.SendLocalizedMessage(1049528); // You cannot calm that!
}
else if (from.Region.IsPartOf(typeof(SafeZone)))
else if (from.Region.IsPartOf<SafeZone>())
{
from.SendMessage("You may not peacemake in this area.");
}
else if (((Mobile)targeted).Region.IsPartOf(typeof(SafeZone)))
else if (targ.Region.IsPartOf<SafeZone>())
{
from.SendMessage("You may not peacemake there.");
}
@ -105,8 +105,8 @@ namespace Server.SkillHandlers
foreach (Mobile m in from.GetMobilesInRange(range))
{
if (m is BaseCreature && ((BaseCreature)m).Uncalmable ||
m is BaseCreature && ((BaseCreature)m).AreaPeaceImmune || m == from ||
BaseCreature bc = m as BaseCreature;
if (bc?.Uncalmable == true || bc?.AreaPeaceImmune == true || m == from ||
!from.CanBeHarmful(m, false))
continue;
@ -117,8 +117,8 @@ namespace Server.SkillHandlers
m.Combatant = null;
m.Warmode = false;
if (m is BaseCreature && !((BaseCreature)m).BardPacified)
((BaseCreature)m).Pacify(from, DateTime.UtcNow + TimeSpan.FromSeconds(1.0));
if (bc?.BardPacified == false)
bc.Pacify(from, DateTime.UtcNow + TimeSpan.FromSeconds(1.0));
}
if (!calmed)
@ -132,20 +132,19 @@ namespace Server.SkillHandlers
else
{
// Target mode : pacify a single target for a longer duration
Mobile targ = (Mobile)targeted;
BaseCreature bc = targ as BaseCreature;
if (!from.CanBeHarmful(targ, false))
{
from.SendLocalizedMessage(1049528);
m_SetSkillTime = true;
}
else if (targ is BaseCreature && ((BaseCreature)targ).Uncalmable)
else if (bc?.Uncalmable == true)
{
from.SendLocalizedMessage(1049526); // You have no chance of calming that creature.
m_SetSkillTime = true;
}
else if (targ is BaseCreature && ((BaseCreature)targ).BardPacified)
else if (bc?.BardPacified == true)
{
from.SendLocalizedMessage(1049527); // That creature is already being calmed.
m_SetSkillTime = true;
@ -160,7 +159,7 @@ namespace Server.SkillHandlers
else
{
double diff = m_Instrument.GetDifficultyFor(targ) - 10.0;
double music = from.Skills[SkillName.Musicianship].Value;
double music = from.Skills.Musicianship.Value;
if (music > 100.0)
diff -= (music - 100.0) * 0.5;
@ -177,15 +176,13 @@ namespace Server.SkillHandlers
m_Instrument.ConsumeUse(from);
from.NextSkillTime = Core.TickCount + 5000;
if (targ is BaseCreature)
targ.Combatant = null;
targ.Warmode = false;
if (bc != null)
{
BaseCreature bc = (BaseCreature)targ;
from.SendLocalizedMessage(1049532); // You play hypnotic music, calming your target.
targ.Combatant = null;
targ.Warmode = false;
double seconds = 100 - diff / 1.5;
if (seconds > 120)
@ -201,8 +198,6 @@ namespace Server.SkillHandlers
targ.SendLocalizedMessage(
500616); // You hear lovely music, and forget to continue battling!
targ.Combatant = null;
targ.Warmode = false;
}
}
}

View file

@ -30,10 +30,10 @@ namespace Server.SkillHandlers
protected override void OnTarget(Mobile from, object targeted)
{
if (targeted is BasePoisonPotion)
if (targeted is BasePoisonPotion potion)
{
from.SendLocalizedMessage(502142); // To what do you wish to apply the poison?
from.Target = new InternalTarget((BasePoisonPotion)targeted);
from.Target = new InternalTarget(potion);
}
else // Not a Poison Potion
{
@ -61,10 +61,8 @@ namespace Server.SkillHandlers
{
startTimer = true;
}
else if (targeted is BaseWeapon)
else if (targeted is BaseWeapon weapon)
{
BaseWeapon weapon = (BaseWeapon)targeted;
if (Core.AOS)
startTimer = weapon.PrimaryAbility == WeaponAbility.InfectiousStrike ||
weapon.SecondaryAbility == WeaponAbility.InfectiousStrike;
@ -116,26 +114,26 @@ namespace Server.SkillHandlers
{
if (m_From.CheckTargetSkill(SkillName.Poisoning, m_Target, m_MinSkill, m_MaxSkill))
{
if (m_Target is Food)
if (m_Target is Food food)
{
((Food)m_Target).Poison = m_Poison;
food.Poison = m_Poison;
}
else if (m_Target is BaseWeapon)
else if (m_Target is BaseWeapon weapon)
{
((BaseWeapon)m_Target).Poison = m_Poison;
((BaseWeapon)m_Target).PoisonCharges = 18 - m_Poison.Level * 2;
weapon.Poison = m_Poison;
weapon.PoisonCharges = 18 - m_Poison.Level * 2;
}
else if (m_Target is FukiyaDarts)
else if (m_Target is FukiyaDarts darts)
{
((FukiyaDarts)m_Target).Poison = m_Poison;
((FukiyaDarts)m_Target).PoisonCharges = Math.Min(18 - m_Poison.Level * 2,
((FukiyaDarts)m_Target).UsesRemaining);
darts.Poison = m_Poison;
darts.PoisonCharges = Math.Min(18 - m_Poison.Level * 2,
darts.UsesRemaining);
}
else if (m_Target is Shuriken)
else if (m_Target is Shuriken shuriken)
{
((Shuriken)m_Target).Poison = m_Poison;
((Shuriken)m_Target).PoisonCharges = Math.Min(18 - m_Poison.Level * 2,
((Shuriken)m_Target).UsesRemaining);
shuriken.Poison = m_Poison;
shuriken.PoisonCharges = Math.Min(18 - m_Poison.Level * 2,
shuriken.UsesRemaining);
}
m_From.SendLocalizedMessage(1010517); // You apply the poison
@ -145,17 +143,15 @@ namespace Server.SkillHandlers
else // Failed
{
// 5% of chance of getting poisoned if failed
if (m_From.Skills[SkillName.Poisoning].Base < 80.0 && Utility.Random(20) == 0)
if (m_From.Skills.Poisoning.Base < 80.0 && Utility.Random(20) == 0)
{
m_From.SendLocalizedMessage(502148); // You make a grave mistake while applying the poison.
m_From.ApplyPoison(m_From, m_Poison);
}
else
{
if (m_Target is BaseWeapon)
if (m_Target is BaseWeapon weapon)
{
BaseWeapon weapon = (BaseWeapon)m_Target;
if (weapon.Type == WeaponType.Slashing)
m_From.SendLocalizedMessage(
1010516); // You fail to apply a sufficient dose of poison on the blade

View file

@ -116,7 +116,7 @@ namespace Server.SkillHandlers
double diff = (m_Instrument.GetDifficultyFor(m_Creature) + m_Instrument.GetDifficultyFor(creature)) *
0.5 - 5.0;
double music = from.Skills[SkillName.Musicianship].Value;
double music = from.Skills.Musicianship.Value;
if (music > 100.0)
diff -= (music - 100.0) * 0.5;

View file

@ -15,11 +15,11 @@ namespace Server.SkillHandlers
public static TimeSpan OnUse(Mobile m)
{
if (m.Skills[SkillName.Lockpicking].Value < 50)
if (m.Skills.Lockpicking.Value < 50)
{
m.SendLocalizedMessage(502366); // You do not know enough about locks. Become better at picking locks.
}
else if (m.Skills[SkillName.DetectHidden].Value < 50)
else if (m.Skills.DetectHidden.Value < 50)
{
m.SendLocalizedMessage(502367); // You are not perceptive enough. Become better at detect hidden.
}

View file

@ -23,7 +23,7 @@ namespace Server.SkillHandlers
if (map != null && (map.Rules & MapRules.HarmfulRestrictions) == 0)
return true; // felucca you can snoop anybody
GuardedRegion reg = (GuardedRegion)to.Region.GetRegion(typeof(GuardedRegion));
GuardedRegion reg = to.Region.GetRegion<GuardedRegion>();
if (reg == null || reg.IsDisabled())
return true; // not in town? we can snoop any npc
@ -56,7 +56,7 @@ namespace Server.SkillHandlers
}
if (root != null && from.AccessLevel == AccessLevel.Player &&
from.Skills[SkillName.Snooping].Value < Utility.Random(100))
from.Skills.Snooping.Value < Utility.Random(100))
{
Map map = from.Map;
@ -88,7 +88,7 @@ namespace Server.SkillHandlers
{
from.SendLocalizedMessage(500210); // You failed to peek into the container.
if (from.Skills[SkillName.Hiding].Value / 2 < Utility.Random(100))
if (from.Skills.Hiding.Value / 2 < Utility.Random(100))
from.RevealingAction();
}
}

View file

@ -34,7 +34,7 @@ namespace Server.SkillHandlers
if (!m.CanHearGhosts)
{
Timer t = new SpiritSpeakTimer(m);
double secs = m.Skills[SkillName.SpiritSpeak].Base / 50;
double secs = m.Skills.SpiritSpeak.Base / 50;
secs *= 90;
if (secs < 15)
secs = 15;
@ -143,14 +143,14 @@ namespace Server.SkillHandlers
if (toChannel != null)
{
min = 1 + (int)(Caster.Skills[SkillName.SpiritSpeak].Value * 0.25);
min = 1 + (int)(Caster.Skills.SpiritSpeak.Value * 0.25);
max = min + 4;
mana = 0;
number = 1061287; // You channel energy from a nearby corpse to heal your wounds.
}
else
{
min = 1 + (int)(Caster.Skills[SkillName.SpiritSpeak].Value * 0.25);
min = 1 + (int)(Caster.Skills.SpiritSpeak.Value * 0.25);
max = min + 4;
mana = 10;
number = 1061286; // You channel your own spiritual energy to heal your wounds.
@ -164,7 +164,7 @@ namespace Server.SkillHandlers
{
Caster.CheckSkill(SkillName.SpiritSpeak, 0.0, 120.0);
if (Utility.RandomDouble() > Caster.Skills[SkillName.SpiritSpeak].Value / 100.0)
if (Utility.RandomDouble() > Caster.Skills.SpiritSpeak.Value / 100.0)
{
Caster.SendLocalizedMessage(502443); // You fail your attempt at contacting the netherworld.
}

View file

@ -50,7 +50,7 @@ namespace Server.SkillHandlers
{
m.SendLocalizedMessage(1005584); // Both hands must be free to steal.
}
else if (m.Region.IsPartOf(typeof(SafeZone)))
else if (m.Region.IsPartOf<SafeZone>())
{
m.SendMessage("You may not steal in this area.");
}
@ -90,7 +90,7 @@ namespace Server.SkillHandlers
{
m_Thief.SendLocalizedMessage(1005584); // Both hands must be free to steal.
}
else if (m_Thief.Region.IsPartOf(typeof(SafeZone)))
else if (m_Thief.Region.IsPartOf<SafeZone>())
{
m_Thief.SendMessage("You may not steal in this area.");
}
@ -137,7 +137,7 @@ namespace Server.SkillHandlers
}
else if (faction != null)
{
if (!m_Thief.CanBeginAction(typeof(IncognitoSpell)))
if (!m_Thief.CanBeginAction<IncognitoSpell>())
{
m_Thief.SendLocalizedMessage(1010581); // You cannot steal the sigil when you are incognito
}
@ -145,7 +145,7 @@ namespace Server.SkillHandlers
{
m_Thief.SendLocalizedMessage(1010583); // You cannot steal the sigil while disguised
}
else if (!m_Thief.CanBeginAction(typeof(PolymorphSpell)))
else if (!m_Thief.CanBeginAction<PolymorphSpell>())
{
m_Thief.SendLocalizedMessage(1010582); // You cannot steal the sigil while polymorphed
}
@ -227,7 +227,7 @@ namespace Server.SkillHandlers
{
m_Thief.SendLocalizedMessage(502703); // You must be standing next to an item to steal it.
}
else if (si != null && m_Thief.Skills[SkillName.Stealing].Value < 100.0)
else if (si != null && m_Thief.Skills.Stealing.Value < 100.0)
{
m_Thief.SendLocalizedMessage(1060025, "",
0x66D); // You're not skilled enough to attempt the theft of this item.
@ -263,7 +263,7 @@ namespace Server.SkillHandlers
{
if (toSteal.Stackable && toSteal.Amount > 1)
{
int maxAmount = (int)(m_Thief.Skills[SkillName.Stealing].Value / 10.0 / toSteal.Weight);
int maxAmount = (int)(m_Thief.Skills.Stealing.Value / 10.0 / toSteal.Weight);
if (maxAmount < 1)
maxAmount = 1;
@ -320,7 +320,7 @@ namespace Server.SkillHandlers
m_Thief.SendLocalizedMessage(502723); // You fail to steal the item.
}
caught = m_Thief.Skills[SkillName.Stealing].Value < Utility.Random(150);
caught = m_Thief.Skills.Stealing.Value < Utility.Random(150);
}
}

View file

@ -60,12 +60,12 @@ namespace Server.SkillHandlers
{
m.SendLocalizedMessage(502725); // You must hide first
}
else if (m.Skills[SkillName.Hiding].Base < HidingRequirement)
else if (m.Skills.Hiding.Base < HidingRequirement)
{
m.SendLocalizedMessage(502726); // You are not hidden well enough. Become better at hiding.
m.RevealingAction();
}
else if (!m.CanBeginAction(typeof(Stealth)))
else if (!m.CanBeginAction<Stealth>())
{
m.SendLocalizedMessage(1063086); // You cannot use this skill right now.
m.RevealingAction();
@ -82,7 +82,7 @@ namespace Server.SkillHandlers
else if (m.CheckSkill(SkillName.Stealth, -20.0 + armorRating * 2,
(Core.AOS ? 60.0 : 80.0) + armorRating * 2))
{
int steps = (int)(m.Skills[SkillName.Stealth].Value / (Core.AOS ? 5.0 : 10.0));
int steps = (int)(m.Skills.Stealth.Value / (Core.AOS ? 5.0 : 10.0));
if (steps < 1)
steps = 1;

View file

@ -20,8 +20,8 @@ namespace Server.SkillHandlers
{
m.SendLocalizedMessage(1011350); // What do you wish to track?
m.CloseGump(typeof(TrackWhatGump));
m.CloseGump(typeof(TrackWhoGump));
m.CloseGump<TrackWhatGump>();
m.CloseGump<TrackWhoGump>();
m.SendGump(new TrackWhatGump(m));
return TimeSpan.FromSeconds(10.0); // 10 second delay before beign able to re-use a skill
@ -192,7 +192,7 @@ namespace Server.SkillHandlers
from.CheckSkill(SkillName.Tracking, 21.1, 100.0); // Passive gain
int range = 10 + (int)(from.Skills[SkillName.Tracking].Value / 10);
int range = 10 + (int)(from.Skills.Tracking.Value / 10);
List<Mobile> list = new List<Mobile>();
@ -228,14 +228,14 @@ namespace Server.SkillHandlers
return true;
int tracking = from.Skills[SkillName.Tracking].Fixed;
int detectHidden = from.Skills[SkillName.DetectHidden].Fixed;
int tracking = from.Skills.Tracking.Fixed;
int detectHidden = from.Skills.DetectHidden.Fixed;
if (Core.ML && m.Race == Race.Elf)
tracking /= 2; //The 'Guide' says that it requires twice as Much tracking SKILL to track an elf. Not the total difficulty to track.
int hiding = m.Skills[SkillName.Hiding].Fixed;
int stealth = m.Skills[SkillName.Stealth].Fixed;
int hiding = m.Skills.Hiding.Fixed;
int stealth = m.Skills.Stealth.Fixed;
int divisor = hiding + stealth;
// Necromancy forms affect tracking difficulty