Clean up: Bugs, LINQ, constructors, default values, and null checks (#18)

This commit is contained in:
Kamron Batman 2019-03-11 14:29:59 -07:00 committed by GitHub
parent e748af4430
commit 513e54f70e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1094 changed files with 15913 additions and 21892 deletions

View file

@ -54,7 +54,7 @@ namespace Server
public static int Damage(Mobile m, Mobile from, int damage, bool ignoreArmor, int phys, int fire, int cold, int pois,
int nrgy, int chaos = 0, int direct = 0, bool keepAlive = false, bool archer = false, bool deathStrike = false)
{
if (m == null || m.Deleted || !m.Alive || damage <= 0)
if (m?.Deleted != false || !m.Alive || damage <= 0)
return 0;
if (phys == 0 && fire == 100 && cold == 0 && pois == 0 && nrgy == 0)
@ -149,7 +149,7 @@ namespace Server
#region Dragon Barding
if ((from == null || !from.Player) && m.Player && m.Mount is SwampDragon pet)
if ((from?.Player != true) && m.Player && m.Mount is SwampDragon pet)
if (pet.HasBarding)
{
int percent = pet.BardingExceptional ? 20 : 10;
@ -172,14 +172,14 @@ namespace Server
if (keepAlive && totalDamage > m.Hits)
totalDamage = m.Hits;
if (from != null && !from.Deleted && from.Alive)
if (from?.Deleted == false && from.Alive)
{
int reflectPhys = AosAttributes.GetValue(m, AosAttribute.ReflectPhysical);
if (reflectPhys != 0)
{
if (from is ExodusMinion minion && minion.FieldActive ||
from is ExodusOverseer overseer && overseer.FieldActive)
if ((from as ExodusMinion)?.FieldActive == true ||
(from as ExodusOverseer)?.FieldActive == true)
{
from.FixedParticles(0x376A, 20, 10, 0x2530, EffectLayer.Waist);
from.PlaySound(0x2F4);
@ -1019,13 +1019,10 @@ namespace Server
public void GetProperties(ObjectPropertyList list)
{
SkillName skill;
for (int i = 0; i < 5; ++i)
{
if (!GetValues(i, out skill, out double bonus))
continue;
list.Add(1060451 + i, "#{0}\t{1}", GetLabel(skill), bonus);
if (GetValues(i, out SkillName skill, out double bonus))
list.Add(1060451 + i, "#{0}\t{1}", GetLabel(skill), bonus);
}
}
@ -1495,4 +1492,4 @@ namespace Server
return index;
}
}
}
}

View file

@ -126,6 +126,7 @@ namespace Server.Misc
}
catch
{
// ignored
}
}
else
@ -136,6 +137,7 @@ namespace Server.Misc
}
catch
{
// ignored
}
}
}

View file

@ -16,6 +16,7 @@ namespace Server.Misc
}
catch
{
// ignored
}
}
@ -27,6 +28,7 @@ namespace Server.Misc
}
catch
{
// ignored
}
}
}

View file

@ -222,7 +222,7 @@ namespace Server.Misc
PlaceItemIn(cont, 45, 105, new Spellbook(ulong.MaxValue));
PlaceItemIn(cont, 65, 105, new NecromancerSpellbook((ulong)0xFFFF));
PlaceItemIn(cont, 85, 105, new BookOfChivalry((ulong)0x3FF));
PlaceItemIn(cont, 85, 105, new BookOfChivalry());
PlaceItemIn(cont, 105, 105, new BookOfBushido()); //Default ctor = full
PlaceItemIn(cont, 125, 105, new BookOfNinjitsu()); //Default ctor = full
@ -462,7 +462,7 @@ namespace Server.Misc
bank.DropItem(new TreasureMap(5, Map.Trammel));
// Bag containing 50 of each reagent
bank.DropItem(new BagOfReagents(50));
bank.DropItem(new BagOfReagents());
// Craft tools
bank.DropItem(MakeNewbie(new Scissors()));
@ -1004,7 +1004,7 @@ namespace Server.Misc
}
case 4: // Necromancer
{
Container regs = new BagOfNecroReagents(50);
Container regs = new BagOfNecroReagents();
if (!Core.AOS)
foreach (Item item in regs.Items)
@ -1076,7 +1076,7 @@ namespace Server.Misc
EquipItem(new BodySash(0xCF));
}
Spellbook book = new BookOfChivalry((ulong)0x3FF);
Spellbook book = new BookOfChivalry();
PackItem(book);
@ -1161,7 +1161,7 @@ namespace Server.Misc
if (!Core.AOS)
item.LootType = LootType.Newbied;
if (m_Mobile != null && m_Mobile.EquipItem(item))
if (m_Mobile?.EquipItem(item) == true)
return;
Container pack = m_Mobile.Backpack;
@ -1472,7 +1472,7 @@ namespace Server.Misc
case SkillName.Chivalry:
{
if (Core.ML)
PackItem(new BookOfChivalry((ulong)0x3FF));
PackItem(new BookOfChivalry());
break;
}
@ -1620,7 +1620,7 @@ namespace Server.Misc
{
if (Core.ML)
{
Container regs = new BagOfNecroReagents(50);
Container regs = new BagOfNecroReagents();
PackItem(regs);
@ -1748,4 +1748,4 @@ namespace Server.Misc
}
}
}
}
}

View file

@ -119,6 +119,7 @@ namespace Server.Misc
}
catch
{
// ignored
}
}
@ -197,6 +198,7 @@ namespace Server.Misc
}
catch
{
// ignored
}
try
@ -205,6 +207,7 @@ namespace Server.Misc
}
catch
{
// ignored
}
op.WriteLine("Exception:");

View file

@ -503,9 +503,9 @@ namespace Server
* Bleh.
*/
Type[] ifaces = active.FindInterfaces((type, obj) => (type.IsGenericType)
&& (type.GetGenericTypeDefinition() == typeof(IComparable<>))
&& (type.GetGenericArguments()[0].IsAssignableFrom(active)), null );
Type[] ifaces = active.FindInterfaces((type, obj) => type.IsGenericType
&& type.GetGenericTypeDefinition() == typeof(IComparable<>)
&& type.GetGenericArguments()[0].IsAssignableFrom(active), null );
if ( ifaces.Length > 0 )
{
@ -513,10 +513,7 @@ namespace Server
}
else
{
ifaces = active.FindInterfaces( delegate( Type type, object obj )
{
return ( type == typeof( IComparable ) );
}, null );
ifaces = active.FindInterfaces((type, obj) => type == typeof(IComparable), null );
if ( ifaces.Length > 0 )
compareTo = ifaces[0].GetMethod( "CompareTo", new[] { active } );
@ -668,7 +665,7 @@ namespace Server
if ( ( call.type.IsValueType || call.type.IsByRef ) && call.method.DeclaringType != call.type )
Generator.Emit( OpCodes.Constrained, call.type );
if ( call.method.DeclaringType.IsValueType || call.method.IsStatic )
if ( call.method.DeclaringType?.IsValueType == true || call.method.IsStatic )
Generator.Emit( OpCodes.Call, call.method );
else
Generator.Emit( OpCodes.Callvirt, call.method );

View file

@ -31,14 +31,14 @@ namespace Server.Misc
public static void HungerDecay(Mobile m)
{
if (m != null && m.Hunger >= 1)
if (m?.Hunger >= 1)
m.Hunger -= 1;
}
public static void ThirstDecay(Mobile m)
{
if (m != null && m.Thirst >= 1)
if (m?.Thirst >= 1)
m.Thirst -= 1;
}
}
}
}

View file

@ -24,14 +24,9 @@ namespace Server.Items
};
[Constructible]
public LightOfTheWinterSolstice() : this(m_StaffNames[Utility.Random(m_StaffNames.Length)])
public LightOfTheWinterSolstice(string dipper = null) : base(0x236E)
{
}
[Constructible]
public LightOfTheWinterSolstice(string dipper) : base(0x236E)
{
Dipper = dipper;
Dipper = dipper ?? m_StaffNames[Utility.Random(m_StaffNames.Length)];
Weight = 1.0;
LootType = LootType.Blessed;
@ -95,4 +90,4 @@ namespace Server.Items
Dipper = string.Intern(Dipper);
}
}
}
}

View file

@ -43,7 +43,7 @@ namespace Server.Items
BaseHouse house = BaseHouse.FindHouseAt(this);
if (house != null && house.IsCoOwner(from))
if (house?.IsCoOwner(from) == true)
{
if (from.InRange(GetWorldLocation(), 1))
{
@ -101,7 +101,7 @@ namespace Server.Items
{
BaseHouse house = BaseHouse.FindHouseAt(this);
if (house != null && house.IsCoOwner(from))
if (house?.IsCoOwner(from) == true)
{
if (from.InRange(GetWorldLocation(), 3))
{
@ -129,29 +129,26 @@ namespace Server.Items
AddBackground(0, 0, 220, 170, 0x13BE);
AddBackground(10, 10, 200, 150, 0xBB8);
AddHtmlLocalized(20, 30, 180, 60, 1062839, false, false); // Do you wish to re-deed this decoration?
AddHtmlLocalized(55, 100, 160, 25, 1011011, false, false); // CONTINUE
AddButton(20, 100, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0);
AddHtmlLocalized(55, 125, 160, 25, 1011012, false, false); // CANCEL
AddButton(20, 125, 0xFA5, 0xFA7, 0, GumpButtonType.Reply, 0);
AddHtmlLocalized(20, 30, 180, 60, 1062839); // Do you wish to re-deed this decoration?
AddHtmlLocalized(55, 100, 160, 25, 1011011); // CONTINUE
AddButton(20, 100, 0xFA5, 0xFA7, 1);
AddHtmlLocalized(55, 125, 160, 25, 1011012); // CANCEL
AddButton(20, 125, 0xFA5, 0xFA7, 0);
}
public override void OnResponse(NetState sender, RelayInfo info)
{
if (m_Addon.Deleted)
if (m_Addon.Deleted || info.ButtonID != 1)
return;
if (info.ButtonID == 1)
if (m_From.InRange(m_Addon.GetWorldLocation(), 3))
{
if (m_From.InRange(m_Addon.GetWorldLocation(), 3))
{
m_From.AddToBackpack(m_Addon.Deed);
m_Addon.Delete();
}
else
{
m_From.SendLocalizedMessage(500295); // You are too far away to do that.
}
m_From.AddToBackpack(m_Addon.Deed);
m_Addon.Delete();
}
else
{
m_From.SendLocalizedMessage(500295); // You are too far away to do that.
}
}
}
@ -161,12 +158,7 @@ namespace Server.Items
public class MistletoeDeed : Item
{
[Constructible]
public MistletoeDeed() : this(0)
{
}
[Constructible]
public MistletoeDeed(int hue) : base(0x14F0)
public MistletoeDeed(int hue = 0) : base(0x14F0)
{
Hue = hue;
Weight = 1.0;
@ -213,7 +205,7 @@ namespace Server.Items
{
BaseHouse house = BaseHouse.FindHouseAt(from);
if (house != null && house.IsCoOwner(from))
if (house?.IsCoOwner(from) == true)
{
from.SendLocalizedMessage(1062838); // Where would you like to place this decoration?
from.BeginTarget(-1, true, TargetFlags.None, Placement_OnTarget);
@ -238,7 +230,7 @@ namespace Server.Items
BaseHouse house = BaseHouse.FindHouseAt(loc, from.Map, 16);
if (house != null && house.IsCoOwner(from))
if (house?.IsCoOwner(from) == true)
{
bool northWall = BaseAddon.IsWall(loc.X, loc.Y - 1, loc.Z, from.Map);
bool westWall = BaseAddon.IsWall(loc.X - 1, loc.Y, loc.Z, from.Map);
@ -306,8 +298,8 @@ namespace Server.Items
AddItem(90, 30, 0x2375);
AddItem(180, 30, 0x2374);
AddButton(50, 35, 0x868, 0x869, 1, GumpButtonType.Reply, 0);
AddButton(145, 35, 0x868, 0x869, 2, GumpButtonType.Reply, 0);
AddButton(50, 35, 0x868, 0x869, 1);
AddButton(145, 35, 0x868, 0x869, 2);
}
public override void OnResponse(NetState sender, RelayInfo info)
@ -327,4 +319,4 @@ namespace Server.Items
}
}
}
}
}

View file

@ -443,10 +443,10 @@ namespace Server.Guilds
{
get
{
if (Opponent == null || Opponent.Disbanded)
if (Opponent?.Disbanded != false)
return WarStatus.Win;
if (Guild == null || Guild.Disbanded)
if (Guild?.Disbanded != false)
return WarStatus.Lose;
WarDeclaration w = Opponent.FindActiveWar(Guild);
@ -572,7 +572,7 @@ namespace Server.Guilds
{
get
{
if (m_Leader == null || m_Leader.Deleted || m_Leader.Guild != this)
if (Disbanded || m_Leader.Guild != this)
CalculateGuildmaster();
return m_Leader;
@ -582,7 +582,7 @@ namespace Server.Guilds
if (value != null)
AddMember(value); //Also removes from old guild.
if (m_Leader is PlayerMobile leader && leader?.Guild == this)
if (m_Leader is PlayerMobile leader && leader.Guild == this)
leader.GuildRank = RankDefinition.Member;
m_Leader = value;
@ -593,7 +593,7 @@ namespace Server.Guilds
}
public override bool Disbanded => m_Leader == null || m_Leader.Deleted;
public override bool Disbanded => m_Leader?.Deleted != false;
public static void Configure()
{
@ -605,22 +605,20 @@ namespace Server.Guilds
public void InvalidateMemberProperties(bool onlyOPL = false)
{
if (Members != null)
for (int i = 0; i < Members.Count; i++)
{
Mobile m = Members[i];
m.InvalidateProperties();
for (int i = 0; i < Members?.Count; i++)
{
Mobile m = Members[i];
m.InvalidateProperties();
if (!onlyOPL)
m.Delta(MobileDelta.Noto);
}
if (!onlyOPL)
m.Delta(MobileDelta.Noto);
}
}
public void InvalidateMemberNotoriety()
{
if (Members != null)
for (int i = 0; i < Members.Count; i++)
Members[i].Delta(MobileDelta.Noto);
for (int i = 0; i < Members?.Count; i++)
Members[i].Delta(MobileDelta.Noto);
}
public void InvalidateWarNotoriety()
@ -735,7 +733,7 @@ namespace Server.Guilds
if (o is Guildstone stone)
{
if (stone.Guild == null || stone.Guild.Disbanded)
if (stone?.Guild.Disbanded != false)
{
from.SendMessage("The guild associated with that Guildstone no longer exists");
return;
@ -893,7 +891,7 @@ namespace Server.Guilds
bool inAlliance = myAlliance?.IsMember(this) == true;
AllianceInfo otherAlliance = g?.Alliance;
bool otherInAlliance = otherAlliance != null && otherAlliance.IsMember(this);
bool otherInAlliance = otherAlliance?.IsMember(this) == true;
if (inAlliance)
{
@ -910,24 +908,24 @@ namespace Server.Guilds
AcceptedWars.Remove(w);
if (g != null)
if (g == null)
continue;
if (status != WarStatus.Draw)
status = (WarStatus)((int)status + 1 % 2);
if (otherInAlliance)
{
if (status != WarStatus.Draw)
status = (WarStatus)((int)status + 1 % 2);
if (otherInAlliance)
{
otherAlliance.AllianceMessage(1070739 + (int)status, inAlliance ? Alliance.Name : Name);
otherAlliance.InvalidateMemberProperties();
}
else
{
g.GuildMessage(1070739 + (int)status, inAlliance ? Alliance.Name : Name);
g.InvalidateMemberProperties();
}
g.AcceptedWars.Remove(g.FindActiveWar(this));
otherAlliance.AllianceMessage(1070739 + (int)status, inAlliance ? Alliance.Name : Name);
otherAlliance.InvalidateMemberProperties();
}
else
{
g.GuildMessage(1070739 + (int)status, inAlliance ? Alliance.Name : Name);
g.InvalidateMemberProperties();
}
g.AcceptedWars.Remove(g.FindActiveWar(this));
}
}
@ -998,17 +996,12 @@ namespace Server.Guilds
public bool IsAlly(Guild g)
{
if (NewGuildSystem) return Alliance != null && Alliance.IsMember(this) && Alliance.IsMember(g);
return Allies.Contains(g);
return NewGuildSystem ? Alliance?.IsMember(this) == true && Alliance.IsMember(g) : Allies.Contains(g);
}
public bool IsEnemy(Guild g)
{
if (Type != GuildType.Regular && g.Type != GuildType.Regular && Type != g.Type)
return true;
return IsWar(g);
return Type != GuildType.Regular && g.Type != GuildType.Regular && Type != g.Type || IsWar(g);
}
public bool IsWar(Guild g)
@ -1016,18 +1009,14 @@ namespace Server.Guilds
if (g == null)
return false;
if (NewGuildSystem)
{
Guild guild = GetAllianceLeader(this);
Guild otherGuild = GetAllianceLeader(g);
if (!NewGuildSystem)
return Enemies.Contains(g);
if (guild.FindActiveWar(otherGuild) != null)
return true;
Guild guild = GetAllianceLeader(this);
Guild otherGuild = GetAllianceLeader(g);
return false;
}
return guild.FindActiveWar(otherGuild) != null;
return Enemies.Contains(g);
}
#endregion
@ -1216,7 +1205,7 @@ namespace Server.Guilds
alliance = Alliance; //CheckLeader could possibly change the value of this.Alliance
if (alliance != null && !alliance.IsMember(this) && !alliance.IsPendingMember(this)
if (alliance?.IsMember(this) == false && !alliance.IsPendingMember(this)
) //This block is there to fix a bug in the code in an older version.
Alliance = null; //Will call Alliance.RemoveGuild which will set it null & perform all the pertient checks as far as alliacne disbanding
}
@ -1309,7 +1298,7 @@ namespace Server.Guilds
public void RemoveEnemy(Guild g)
{
if (Enemies != null && Enemies.Contains(g))
if (Enemies.Contains(g))
{
Enemies.Remove(g);
@ -1389,9 +1378,7 @@ namespace Server.Guilds
public void GuildChat(Mobile from, string text)
{
PlayerMobile pm = from as PlayerMobile;
GuildChat(from, pm?.GuildMessageHue ?? 0x3B2, text);
GuildChat(from, (from as PlayerMobile)?.GuildMessageHue ?? 0x3B2, text);
}
#endregion
@ -1400,20 +1387,13 @@ namespace Server.Guilds
public bool CanVote(Mobile m)
{
if (NewGuildSystem)
if (!(m is PlayerMobile pm) || !pm.GuildRank.GetFlag(RankFlags.CanVote))
return false;
return m != null && !m.Deleted && m.Guild == this;
return (!NewGuildSystem || m is PlayerMobile pm && pm.GuildRank.GetFlag(RankFlags.CanVote)) &&
m?.Deleted == false && m.Guild == this;
}
public bool CanBeVotedFor(Mobile m)
{
if (NewGuildSystem)
if (!(m is PlayerMobile pm) || pm.LastOnline + InactiveTime < DateTime.UtcNow)
return false;
return m != null && !m.Deleted && m.Guild == this;
return (!NewGuildSystem || m is PlayerMobile pm && pm.LastOnline + InactiveTime >= DateTime.UtcNow) && m?.Deleted == false && m.Guild == this;
}
public void CalculateGuildmaster()
@ -1433,7 +1413,7 @@ namespace Server.Guilds
if (!CanBeVotedFor(m))
{
if (m_Leader != null && !m_Leader.Deleted && m_Leader.Guild == this)
if (!Disbanded && m_Leader.Guild == this)
m = m_Leader;
else
m = memb;
@ -1461,8 +1441,8 @@ namespace Server.Guilds
}
}
if (NewGuildSystem && highVotes * 100 / Math.Max(votingMembers, 1) < MajorityPercentage && m_Leader != null &&
winner != m_Leader && !m_Leader.Deleted && m_Leader.Guild == this)
if (NewGuildSystem && highVotes * 100 / Math.Max(votingMembers, 1) < MajorityPercentage && !Disbanded &&
winner != m_Leader && m_Leader.Guild == this)
winner = m_Leader;
if (m_Leader != winner && winner != null)

View file

@ -534,12 +534,12 @@ namespace Server
private bool m_AtSpawnTime;
public LootPackEntry(bool atSpawnTime, LootPackItem[] items, double chance, string quantity) : this(atSpawnTime,
items, chance, new LootPackDice(quantity), 0, 0, 0)
items, chance, new LootPackDice(quantity))
{
}
public LootPackEntry(bool atSpawnTime, LootPackItem[] items, double chance, int quantity) : this(atSpawnTime, items,
chance, new LootPackDice(0, 0, quantity), 0, 0, 0)
chance, new LootPackDice(0, 0, quantity))
{
}
@ -555,8 +555,8 @@ namespace Server
{
}
public LootPackEntry(bool atSpawnTime, LootPackItem[] items, double chance, LootPackDice quantity, int maxProps,
int minIntensity, int maxIntensity)
public LootPackEntry(bool atSpawnTime, LootPackItem[] items, double chance, LootPackDice quantity, int maxProps = 0,
int minIntensity = 0, int maxIntensity = 0)
{
m_AtSpawnTime = atSpawnTime;
Items = items;
@ -901,6 +901,7 @@ namespace Server
}
catch
{
// ignored
}
return null;

View file

@ -90,10 +90,11 @@ namespace Server
m_Table[type] = list;
}
catch
{
}
}
catch
{
// ignored
}
}
}
}
}

View file

@ -67,19 +67,16 @@ namespace Server.Misc
PlayerMobile pmFrom = from as PlayerMobile;
PlayerMobile pmTarg = target as PlayerMobile;
if (pmFrom == null && from is BaseCreature bcFrom)
if (bcFrom.Summoned)
pmFrom = bcFrom.SummonMaster as PlayerMobile;
if (pmFrom == null && from is BaseCreature bcFrom && bcFrom.Summoned)
pmFrom = bcFrom.SummonMaster as PlayerMobile;
if (pmTarg == null && target is BaseCreature bcTarg)
if (bcTarg.Summoned)
pmTarg = bcTarg.SummonMaster as PlayerMobile;
if (pmTarg == null && target is BaseCreature bcTarg && bcTarg.Summoned)
pmTarg = bcTarg.SummonMaster as PlayerMobile;
if (pmFrom != null && pmTarg != null)
{
if (pmFrom.DuelContext != pmTarg.DuelContext &&
(pmFrom.DuelContext != null && pmFrom.DuelContext.Started ||
pmTarg.DuelContext != null && pmTarg.DuelContext.Started))
(pmFrom.DuelContext?.Started == true || pmTarg.DuelContext?.Started == true))
return false;
if (pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext &&
@ -87,27 +84,25 @@ namespace Server.Misc
pmFrom.DuelPlayer.Eliminated || pmTarg.DuelPlayer.Eliminated))
return false;
if (pmFrom.DuelPlayer != null && !pmFrom.DuelPlayer.Eliminated && pmFrom.DuelContext != null &&
pmFrom.DuelContext.IsSuddenDeath)
if (pmFrom.DuelPlayer?.Eliminated == false && pmFrom.DuelContext?.IsSuddenDeath == true)
return false;
if (pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext &&
pmFrom.DuelContext.m_Tournament != null && pmFrom.DuelContext.m_Tournament.IsNotoRestricted &&
pmFrom.DuelContext.m_Tournament?.IsNotoRestricted == true &&
pmFrom.DuelPlayer != null && pmTarg.DuelPlayer != null &&
pmFrom.DuelPlayer.Participant != pmTarg.DuelPlayer.Participant)
return false;
if (pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext && pmFrom.DuelContext.Started)
if (pmFrom.DuelContext?.Started == true && pmFrom.DuelContext == pmTarg.DuelContext)
return true;
}
if (pmFrom?.DuelContext != null && pmFrom.DuelContext.Started ||
pmTarg?.DuelContext != null && pmTarg.DuelContext.Started)
if (pmFrom?.DuelContext?.Started == true || pmTarg?.DuelContext?.Started == true)
return false;
if (from.Region.IsPartOf<SafeZone>() || target.Region.IsPartOf<SafeZone>())
return false;
#endregion
Map map = from.Map;
@ -123,7 +118,7 @@ namespace Server.Misc
#endregion
if (map != null && (map.Rules & MapRules.BeneficialRestrictions) == 0)
if ((map?.Rules & MapRules.BeneficialRestrictions) == 0)
return true; // In felucca, anything goes
if (!from.Player)
@ -163,8 +158,7 @@ namespace Server.Misc
if (pmFrom != null && pmTarg != null)
{
if (pmFrom.DuelContext != pmTarg.DuelContext &&
(pmFrom.DuelContext != null && pmFrom.DuelContext.Started ||
pmTarg.DuelContext != null && pmTarg.DuelContext.Started))
(pmFrom.DuelContext?.Started == true || pmTarg.DuelContext?.Started == true))
return false;
if (pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext &&
@ -173,17 +167,16 @@ namespace Server.Misc
return false;
if (pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext &&
pmFrom.DuelContext.m_Tournament != null && pmFrom.DuelContext.m_Tournament.IsNotoRestricted &&
pmFrom.DuelContext.m_Tournament?.IsNotoRestricted == true &&
pmFrom.DuelPlayer != null && pmTarg.DuelPlayer != null &&
pmFrom.DuelPlayer.Participant == pmTarg.DuelPlayer.Participant)
return false;
if (pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext && pmFrom.DuelContext.Started)
if ( pmFrom.DuelContext?.Started == true && pmFrom.DuelContext == pmTarg.DuelContext)
return true;
}
if (pmFrom?.DuelContext != null && pmFrom.DuelContext.Started ||
pmTarg?.DuelContext != null && pmTarg.DuelContext.Started)
if (pmFrom?.DuelContext?.Started == true || pmTarg?.DuelContext?.Started == true)
return false;
if (from.Region.IsPartOf<SafeZone>() || target.Region.IsPartOf<SafeZone>())
@ -193,7 +186,7 @@ namespace Server.Misc
Map map = from.Map;
if (map != null && (map.Rules & MapRules.HarmfulRestrictions) == 0)
if ((map?.Rules & MapRules.HarmfulRestrictions) == 0)
return true; // In felucca, anything goes
if (!from.Player && !(from is BaseCreature bc && bc.GetMaster() != null &&
@ -219,11 +212,7 @@ namespace Server.Misc
if (target.Player)
return false; // Cannot harm other players
if (bcTarg?.InitialInnocent != true)
if (Notoriety.Compute(from, target) == Notoriety.Innocent)
return false; // Cannot harm innocent mobiles
return true;
return bcTarg?.InitialInnocent == true || Notoriety.Compute(from, target) != Notoriety.Innocent;
}
public static Guild GetGuildFor(Guild def, Mobile m)
@ -344,7 +333,7 @@ namespace Server.Misc
{
Mobile master = bcTarg.GetMaster();
if (master != null && master.AccessLevel > AccessLevel.Player)
if (master?.AccessLevel > AccessLevel.Player)
return Notoriety.CanBeAttacked;
master = bcTarg.ControlMaster;
@ -407,7 +396,7 @@ namespace Server.Misc
if (CheckAggressed(source.Aggressed, target))
return Notoriety.CanBeAttacked;
if (bcTarg != null && bcTarg.Controlled && bcTarg.ControlOrder == OrderType.Guard &&
if (bcTarg?.Controlled == true && bcTarg.ControlOrder == OrderType.Guard &&
bcTarg.ControlTarget == source)
return Notoriety.CanBeAttacked;
@ -427,26 +416,24 @@ namespace Server.Misc
{
BaseHouse house = BaseHouse.FindHouseAt(p, map, 16);
if (house == null || house.Public || !house.IsFriend(from))
if (house?.Public != false || !house.IsFriend(from))
return false;
if (m != null && house.IsFriend(m))
return false;
if (m is BaseCreature c && !c.Deleted && c.Controlled && c.ControlMaster != null)
return !house.IsFriend(c.ControlMaster);
return true;
return !(m is BaseCreature c) || c.Deleted || !c.Controlled || c.ControlMaster == null ||
!house.IsFriend(c.ControlMaster);
}
public static bool IsPet(BaseCreature c)
{
return c != null && c.Controlled;
return c?.Controlled == true;
}
public static bool IsSummoned(BaseCreature c)
{
return c != null && /*c.Controlled &&*/ c.Summoned;
return c?.Summoned == true;
}
public static bool CheckAggressor(List<AggressorInfo> list, Mobile target)
@ -478,4 +465,4 @@ namespace Server.Misc
Waring
}
}
}
}

View file

@ -63,9 +63,7 @@ namespace Server.Misc
TimeSpan ts = DateTime.UtcNow - a.Created;
string v;
if (Format(ts.TotalDays, "This account is {0} day{1} old.", out v))
if (Format(ts.TotalDays, "This account is {0} day{1} old.", out string v))
return v;
if (Format(ts.TotalHours, "This account is {0} hour{1} old.", out v))

View file

@ -55,7 +55,7 @@ namespace Server.Misc
BaseCreature bc = from as BaseCreature;
if (bc != null && !bc.IsAnimatedDead)
if (bc?.IsAnimatedDead == false)
points += 4;
if (bc?.IsParagon == true || from is Leviathan)
@ -217,4 +217,4 @@ namespace Server.Misc
}
}
}
}
}

View file

@ -423,7 +423,7 @@ namespace Server.Items
new CraftResourceInfo( 0x8A5, 1053104, "Gold", CraftAttributeInfo.Golden, CraftResource.Gold, typeof( GoldIngot ), typeof( GoldOre ), typeof( GoldGranite ) ),
new CraftResourceInfo( 0x979, 1053103, "Agapite", CraftAttributeInfo.Agapite, CraftResource.Agapite, typeof( AgapiteIngot ), typeof( AgapiteOre ), typeof( AgapiteGranite ) ),
new CraftResourceInfo( 0x89F, 1053102, "Verite", CraftAttributeInfo.Verite, CraftResource.Verite, typeof( VeriteIngot ), typeof( VeriteOre ), typeof( VeriteGranite ) ),
new CraftResourceInfo( 0x8AB, 1053101, "Valorite", CraftAttributeInfo.Valorite, CraftResource.Valorite, typeof( ValoriteIngot ), typeof( ValoriteOre ), typeof( ValoriteGranite ) ),
new CraftResourceInfo( 0x8AB, 1053101, "Valorite", CraftAttributeInfo.Valorite, CraftResource.Valorite, typeof( ValoriteIngot ), typeof( ValoriteOre ), typeof( ValoriteGranite ) )
};
private static CraftResourceInfo[] m_ScaleInfo = {
@ -446,7 +446,7 @@ namespace Server.Items
new CraftResourceInfo( 0x000, 1049353, "Normal", CraftAttributeInfo.Blank, CraftResource.RegularLeather, typeof( Leather ), typeof( Hides ) ),
new CraftResourceInfo( 0x8AC, 1049354, "Spined", CraftAttributeInfo.Spined, CraftResource.SpinedLeather, typeof( SpinedLeather ), typeof( SpinedHides ) ),
new CraftResourceInfo( 0x845, 1049355, "Horned", CraftAttributeInfo.Horned, CraftResource.HornedLeather, typeof( HornedLeather ), typeof( HornedHides ) ),
new CraftResourceInfo( 0x851, 1049356, "Barbed", CraftAttributeInfo.Barbed, CraftResource.BarbedLeather, typeof( BarbedLeather ), typeof( BarbedHides ) ),
new CraftResourceInfo( 0x851, 1049356, "Barbed", CraftAttributeInfo.Barbed, CraftResource.BarbedLeather, typeof( BarbedLeather ), typeof( BarbedHides ) )
};
private static CraftResourceInfo[] m_WoodInfo = {
@ -563,7 +563,7 @@ namespace Server.Items
if ( start == CraftResource.None )
return 0;
return (int)(resource - start);
return resource - start;
}
/// <summary>

View file

@ -114,6 +114,7 @@ namespace Server.Misc
}
catch
{
// ignored
}
}

View file

@ -153,7 +153,7 @@ namespace Server.Misc
private static void EventSink_Login_Callback(Mobile from)
{
NetState ns = from.NetState;
if (ns == null)
return;
@ -409,15 +409,15 @@ namespace Server.Misc
else
title = "Shard Poll";
AddHtml(22, 22, 294, 20, Color(Center(title), LabelColor32), false, false);
AddHtml(22, 22, 294, 20, Color(Center(title), LabelColor32));
if (editing)
{
AddHtml(22, 22, 294, 20, Color($"{totalVotes} total", LabelColor32), false, false);
AddButton(287, 23, 0x2622, 0x2623, 2, GumpButtonType.Reply, 0);
AddHtml(22, 22, 294, 20, Color($"{totalVotes} total", LabelColor32));
AddButton(287, 23, 0x2622, 0x2623, 2);
}
AddHtml(22, 50, 294, 40, Color(poller.Title, 0x99CC66), false, false);
AddHtml(22, 50, 294, 40, Color(poller.Title, 0x99CC66));
AddImageTiled(32, 88, 264, 1, 9107);
AddImageTiled(42, 90, 264, 1, 9157);
@ -433,7 +433,7 @@ namespace Server.Misc
{
double perc = option.Votes / (double)totalVotes;
text = string.Format("[{1}: {2}%] {0}", text, option.Votes, (int)(perc * 100));
text = $"[{option.Votes}: {(int)(perc * 100)}%] {text}";
}
int optHeight = option.ComputeHeight();
@ -445,7 +445,7 @@ namespace Server.Misc
else
AddRadio(24, y - 15, 0x25F9, 0x25FC, false, 1 + i);
AddHtml(60, y - 9 * option.LineBreaks, 250, 18 * option.LineBreaks, Color(text, LabelColor32), false, false);
AddHtml(60, y - 9 * option.LineBreaks, 250, 18 * option.LineBreaks, Color(text, LabelColor32));
y += optHeight / 2;
y += 5;
@ -454,11 +454,11 @@ namespace Server.Misc
if (editing && !isViewingResults)
{
AddRadio(24, y + 15 - 15, 0x25F9, 0x25FC, false, 1 + poller.Options.Length);
AddHtml(60, y + 15 - 9, 250, 18, Color("Create new option.", 0x99CC66), false, false);
AddHtml(60, y + 15 - 9, 250, 18, Color("Create new option.", 0x99CC66));
}
AddButton(314, height - 73, 247, 248, 1, GumpButtonType.Reply, 0);
AddButton(314, height - 47, 242, 241, 0, GumpButtonType.Reply, 0);
AddButton(314, height - 73, 247, 248, 1);
AddButton(314, height - 47, 242, 241, 0);
}
public bool Editing{ get; }
@ -568,7 +568,7 @@ namespace Server.Misc
}
else if (m.Groups[2].Success)
{
return string.Format("<a href=\"{0}\">{0}</a>", m.Groups[2].Value);
return $"<a href=\"{m.Groups[2].Value}\">{m.Groups[2].Value}</a>";
}
return m.Value;
@ -606,4 +606,4 @@ namespace Server.Misc
from.SendGump(new ShardPollGump(from, m_Poller, true, null));
}
}
}
}

View file

@ -77,6 +77,7 @@ namespace Server
}
catch
{
// ignored
}
}
}

View file

@ -7,19 +7,11 @@ namespace Server
[Parsable]
public class TextDefinition
{
public TextDefinition() : this(0, null)
{
}
public TextDefinition(int number) : this(number, null)
{
}
public TextDefinition(string text) : this(0, text)
{
}
public TextDefinition(int number, string text)
public TextDefinition(int number = 0, string text = null)
{
Number = number;
String = text;
@ -31,34 +23,17 @@ namespace Server
public bool IsEmpty => Number <= 0 && String == null;
public override string ToString()
{
if (Number > 0)
return string.Concat("#", Number.ToString());
if (String != null)
return String;
return "";
}
public override string ToString() => Number > 0 ? $"#{Number}" : String ?? "";
public string Format(bool propsGump)
{
if (Number > 0)
return string.Format("{0} (0x{0:X})", Number);
if (String != null)
return $"\"{String}\"";
return propsGump ? "-empty-" : "empty";
return Number > 0 ? $"{Number} (0x{Number:X})" :
String != null ? $"\"{String}\"" : propsGump ? "-empty-" : "empty";
}
public string GetValue()
{
if (Number > 0)
return Number.ToString();
if (String != null)
return String;
return "";
return Number > 0 ? Number.ToString() : String ?? "";
}
public static void Serialize(GenericWriter writer, TextDefinition def)
@ -120,10 +95,7 @@ namespace Server
public static implicit operator int(TextDefinition m)
{
if (m == null)
return 0;
return m.Number;
return m?.Number ?? 0;
}
public static implicit operator string(TextDefinition m)
@ -201,14 +173,11 @@ namespace Server
int i;
bool isInteger;
if (value.StartsWith("0x"))
isInteger = int.TryParse(value.Substring(2), NumberStyles.HexNumber, null, out i);
else
isInteger = int.TryParse(value, out i);
isInteger = value.StartsWith("0x") ?
int.TryParse(value.Substring(2), NumberStyles.HexNumber, null, out i) :
int.TryParse(value, out i);
if (isInteger)
return new TextDefinition(i);
return new TextDefinition(value);
return isInteger ? new TextDefinition(i) : new TextDefinition(value);
}
public static bool IsNullOrEmpty(TextDefinition def)
@ -216,4 +185,4 @@ namespace Server
return def == null || def.IsEmpty;
}
}
}
}

View file

@ -320,7 +320,7 @@ namespace Server.Misc
{
Skill highest = GetHighestSkill(mob); // beheld.Skills.Highest;
if (highest != null && highest.BaseFixedPoint >= 300)
if (highest?.BaseFixedPoint >= 300)
{
string skillLevel = GetSkillLevel(highest);
string skillTitle = highest.Info.Title;
@ -403,4 +403,4 @@ namespace Server.Misc
m_Title = title;
}
}
}
}

View file

@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Server.Commands;
@ -261,22 +260,8 @@ namespace Server
private static bool IsClothes(int itemID)
{
if (itemID >= 0x1515 && itemID <= 0x1518)
return true;
if (itemID >= 0x152E && itemID <= 0x1531)
return true;
if (itemID >= 0x1537 && itemID <= 0x154C)
return true;
if (itemID >= 0x1EFD && itemID <= 0x1F04)
return true;
if (itemID >= 0x170B && itemID <= 0x171C)
return true;
return false;
return itemID >= 0x1515 && itemID <= 0x1518 || itemID >= 0x152E && itemID <= 0x1531 || itemID >= 0x1537
&& itemID <= 0x154C || itemID >= 0x1EFD && itemID <= 0x1F04 || itemID >= 0x170B && itemID <= 0x171C;
}
private static bool IsArmor(int itemID)

View file

@ -344,7 +344,7 @@ namespace Server.Misc
{
base.Serialize( writer );
writer.Write( (int) 0 );
writer.Write( 0 );
}
public override void Deserialize( GenericReader reader )

View file

@ -75,6 +75,7 @@ namespace Server.Misc
}
catch
{
// ignored
}
Listen();

View file

@ -12,11 +12,11 @@ namespace Server
{
//configuration
private const int
NPCCount = 2; //2 npcs per type (so a mage spawner will spawn 2 npcs, a alchemist and herbalist spawner will spawn 4 npcs total)
NPCCount = 2; // 2 npcs per type (so a mage spawner will spawn 2 npcs, a alchemist and herbalist spawner will spawn 4 npcs total)
private const int HomeRange = 5; //How far should they wander?
private const bool TotalRespawn = true; //Should we spawn them up right away?
private const int Team = 0; //"team" the npcs are on
private const int HomeRange = 5; // How far should they wander?
private const bool TotalRespawn = true; // Should we spawn them up right away?
private const int Team = 0; // "team" the npcs are on
private static int m_Count;
private static TimeSpan MinTime = TimeSpan.FromMinutes(2.5); //min spawn time
private static TimeSpan MaxTime = TimeSpan.FromMinutes(10.0); //max spawn time
@ -38,209 +38,208 @@ namespace Server
string vendor_path = Path.Combine(Core.BaseDirectory, "Data/Common.map");
m_Count = 0;
if (File.Exists(vendor_path))
{
from.SendMessage("Generating Vendors...");
using (StreamReader ip = new StreamReader(vendor_path))
{
string line;
while ((line = ip.ReadLine()) != null)
{
int indexOf = line.IndexOf(':');
if (indexOf == -1)
continue;
string type = line.Substring(0, ++indexOf).Trim();
string sub = line.Substring(indexOf).Trim();
string[] split = sub.Split(' ');
if (split.Length < 3)
continue;
split = new[] { type, split[0], split[1], split[2] };
switch (split[0].ToLower())
{
case "-healer:":
PlaceNPC(split[1], split[2], split[3], "Healer", "HealerGuildmaster");
break;
case "-baker:":
PlaceNPC(split[1], split[2], split[3], "Baker");
break;
case "-vet:":
PlaceNPC(split[1], split[2], split[3], "Veterinarian");
break;
case "-gypsymaiden:":
PlaceNPC(split[1], split[2], split[3], "GypsyMaiden");
break;
case "-gypsybank:":
PlaceNPC(split[1], split[2], split[3], "GypsyBanker");
break;
case "-bank:":
PlaceNPC(split[1], split[2], split[3], "Banker", "Minter");
break;
case "-inn:":
PlaceNPC(split[1], split[2], split[3], "Innkeeper");
break;
case "-provisioner:":
PlaceNPC(split[1], split[2], split[3], "Provisioner", "Cobbler");
break;
case "-tailor:":
PlaceNPC(split[1], split[2], split[3], "Tailor", "Weaver", "TailorGuildmaster");
break;
case "-tavern:":
PlaceNPC(split[1], split[2], split[3], "Tavernkeeper", "Waiter", "Cook", "Barkeeper");
break;
case "-reagents:":
PlaceNPC(split[1], split[2], split[3], "Herbalist", "Alchemist", "CustomHairstylist");
break;
case "-fortuneteller:":
PlaceNPC(split[1], split[2], split[3], "FortuneTeller");
break;
case "-holymage:":
PlaceNPC(split[1], split[2], split[3], "HolyMage");
break;
case "-chivalrykeeper:":
PlaceNPC(split[1], split[2], split[3], "KeeperOfChivalry");
break;
case "-mage:":
PlaceNPC(split[1], split[2], split[3], "Mage", "Alchemist", "MageGuildmaster");
break;
case "-arms:":
PlaceNPC(split[1], split[2], split[3], "Armorer", "Weaponsmith");
break;
case "-tinker:":
PlaceNPC(split[1], split[2], split[3], "Tinker", "TinkerGuildmaster");
break;
case "-gypsystable:":
PlaceNPC(split[1], split[2], split[3], "GypsyAnimalTrainer");
break;
case "-stable:":
PlaceNPC(split[1], split[2], split[3], "AnimalTrainer");
break;
case "-blacksmith:":
PlaceNPC(split[1], split[2], split[3], "Blacksmith", "BlacksmithGuildmaster");
break;
case "-bowyer:":
case "-fletcher:":
PlaceNPC(split[1], split[2], split[3], "Bowyer");
break;
case "-carpenter:":
PlaceNPC(split[1], split[2], split[3], "Carpenter", "Architect", "RealEstateBroker");
break;
case "-butcher:":
PlaceNPC(split[1], split[2], split[3], "Butcher");
break;
case "-jeweler:":
PlaceNPC(split[1], split[2], split[3], "Jeweler");
break;
case "-tanner:":
PlaceNPC(split[1], split[2], split[3], "Tanner", "Furtrader");
break;
case "-bard:":
PlaceNPC(split[1], split[2], split[3], "Bard", "BardGuildmaster");
break;
case "-market:":
PlaceNPC(split[1], split[2], split[3], "Butcher", "Farmer");
break;
case "-library:":
PlaceNPC(split[1], split[2], split[3], "Scribe");
break;
case "-shipwright:":
PlaceNPC(split[1], split[2], split[3], "Shipwright", "Mapmaker");
break;
case "-docks:":
PlaceNPC(split[1], split[2], split[3], "Fisherman");
break;
case "-beekeeper:":
PlaceNPC(split[1], split[2], split[3], "Beekeeper");
break;
// Guilds & Misc
case "-tinkers guild:":
PlaceNPC(split[1], split[2], split[3], "TinkerGuildmaster");
break;
case "-blacksmiths guild:":
PlaceNPC(split[1], split[2], split[3], "BlacksmithGuildmaster");
break;
case "-sorcerors guild:":
PlaceNPC(split[1], split[2], split[3], "MageGuildmaster");
break;
case "-customs:": break;
case "-painter:": break;
case "-theater:": break;
case "-warriors guild:":
PlaceNPC(split[1], split[2], split[3], "WarriorGuildmaster");
break;
case "-archers guild:":
PlaceNPC(split[1], split[2], split[3], "RangerGuildmaster");
break;
case "-thieves guild:":
PlaceNPC(split[1], split[2], split[3], "ThiefGuildmaster");
break;
case "-miners guild:":
PlaceNPC(split[1], split[2], split[3], "MinerGuildmaster");
break;
case "-fishermans guild:":
PlaceNPC(split[1], split[2], split[3], "FisherGuildmaster");
break;
case "-merchants guild:":
PlaceNPC(split[1], split[2], split[3], "MerchantGuildmaster");
break;
case "-illusionists guild:": break;
case "-armourers guild:": break;
case "-sorcerers guild:": break;
case "-mages guild:":
PlaceNPC(split[1], split[2], split[3], "MageGuildmaster");
break;
case "-weapons guild:": break;
case "-bardic guild:":
PlaceNPC(split[1], split[2], split[3], "BardGuildmaster");
break;
case "-rogues guild:":
break;
// Skip
case "+landmark:":
case "-point of interest:":
case "+shrine:":
case "+moongate:":
case "+dungeon:":
case "+scenic:":
case "-gate:":
case "+Body of Water:":
case "+ruins:":
case "+teleporter:":
case "+Terrain:":
case "-exit:":
case "-bridge:":
case "-other:":
case "+champion:":
case "-stairs:":
case "-guild:":
case "+graveyard:":
case "+Island:":
case "+town:":
break;
/*default:
Console.WriteLine(split[0]);
break;*/
}
}
}
from.SendMessage("Done, added {0} spawners", m_Count);
}
else
if (!File.Exists(vendor_path))
{
from.SendMessage("{0} not found!", vendor_path);
return;
}
from.SendMessage("Generating Vendors...");
using (StreamReader ip = new StreamReader(vendor_path))
{
string line;
while ((line = ip.ReadLine()) != null)
{
int indexOf = line.IndexOf(':');
if (indexOf == -1)
continue;
string type = line.Substring(0, ++indexOf).Trim();
string sub = line.Substring(indexOf).Trim();
string[] split = sub.Split(' ');
if (split.Length < 3)
continue;
split = new[] { type, split[0], split[1], split[2] };
switch (split[0].ToLower())
{
case "-healer:":
PlaceNPC(split[1], split[2], split[3], "Healer", "HealerGuildmaster");
break;
case "-baker:":
PlaceNPC(split[1], split[2], split[3], "Baker");
break;
case "-vet:":
PlaceNPC(split[1], split[2], split[3], "Veterinarian");
break;
case "-gypsymaiden:":
PlaceNPC(split[1], split[2], split[3], "GypsyMaiden");
break;
case "-gypsybank:":
PlaceNPC(split[1], split[2], split[3], "GypsyBanker");
break;
case "-bank:":
PlaceNPC(split[1], split[2], split[3], "Banker", "Minter");
break;
case "-inn:":
PlaceNPC(split[1], split[2], split[3], "Innkeeper");
break;
case "-provisioner:":
PlaceNPC(split[1], split[2], split[3], "Provisioner", "Cobbler");
break;
case "-tailor:":
PlaceNPC(split[1], split[2], split[3], "Tailor", "Weaver", "TailorGuildmaster");
break;
case "-tavern:":
PlaceNPC(split[1], split[2], split[3], "Tavernkeeper", "Waiter", "Cook", "Barkeeper");
break;
case "-reagents:":
PlaceNPC(split[1], split[2], split[3], "Herbalist", "Alchemist", "CustomHairstylist");
break;
case "-fortuneteller:":
PlaceNPC(split[1], split[2], split[3], "FortuneTeller");
break;
case "-holymage:":
PlaceNPC(split[1], split[2], split[3], "HolyMage");
break;
case "-chivalrykeeper:":
PlaceNPC(split[1], split[2], split[3], "KeeperOfChivalry");
break;
case "-mage:":
PlaceNPC(split[1], split[2], split[3], "Mage", "Alchemist", "MageGuildmaster");
break;
case "-arms:":
PlaceNPC(split[1], split[2], split[3], "Armorer", "Weaponsmith");
break;
case "-tinker:":
PlaceNPC(split[1], split[2], split[3], "Tinker", "TinkerGuildmaster");
break;
case "-gypsystable:":
PlaceNPC(split[1], split[2], split[3], "GypsyAnimalTrainer");
break;
case "-stable:":
PlaceNPC(split[1], split[2], split[3], "AnimalTrainer");
break;
case "-blacksmith:":
PlaceNPC(split[1], split[2], split[3], "Blacksmith", "BlacksmithGuildmaster");
break;
case "-bowyer:":
case "-fletcher:":
PlaceNPC(split[1], split[2], split[3], "Bowyer");
break;
case "-carpenter:":
PlaceNPC(split[1], split[2], split[3], "Carpenter", "Architect", "RealEstateBroker");
break;
case "-butcher:":
PlaceNPC(split[1], split[2], split[3], "Butcher");
break;
case "-jeweler:":
PlaceNPC(split[1], split[2], split[3], "Jeweler");
break;
case "-tanner:":
PlaceNPC(split[1], split[2], split[3], "Tanner", "Furtrader");
break;
case "-bard:":
PlaceNPC(split[1], split[2], split[3], "Bard", "BardGuildmaster");
break;
case "-market:":
PlaceNPC(split[1], split[2], split[3], "Butcher", "Farmer");
break;
case "-library:":
PlaceNPC(split[1], split[2], split[3], "Scribe");
break;
case "-shipwright:":
PlaceNPC(split[1], split[2], split[3], "Shipwright", "Mapmaker");
break;
case "-docks:":
PlaceNPC(split[1], split[2], split[3], "Fisherman");
break;
case "-beekeeper:":
PlaceNPC(split[1], split[2], split[3], "Beekeeper");
break;
// Guilds & Misc
case "-tinkers guild:":
PlaceNPC(split[1], split[2], split[3], "TinkerGuildmaster");
break;
case "-blacksmiths guild:":
PlaceNPC(split[1], split[2], split[3], "BlacksmithGuildmaster");
break;
case "-sorcerors guild:":
PlaceNPC(split[1], split[2], split[3], "MageGuildmaster");
break;
case "-customs:": break;
case "-painter:": break;
case "-theater:": break;
case "-warriors guild:":
PlaceNPC(split[1], split[2], split[3], "WarriorGuildmaster");
break;
case "-archers guild:":
PlaceNPC(split[1], split[2], split[3], "RangerGuildmaster");
break;
case "-thieves guild:":
PlaceNPC(split[1], split[2], split[3], "ThiefGuildmaster");
break;
case "-miners guild:":
PlaceNPC(split[1], split[2], split[3], "MinerGuildmaster");
break;
case "-fishermans guild:":
PlaceNPC(split[1], split[2], split[3], "FisherGuildmaster");
break;
case "-merchants guild:":
PlaceNPC(split[1], split[2], split[3], "MerchantGuildmaster");
break;
case "-illusionists guild:": break;
case "-armourers guild:": break;
case "-sorcerers guild:": break;
case "-mages guild:":
PlaceNPC(split[1], split[2], split[3], "MageGuildmaster");
break;
case "-weapons guild:": break;
case "-bardic guild:":
PlaceNPC(split[1], split[2], split[3], "BardGuildmaster");
break;
case "-rogues guild:":
break;
// Skip
case "+landmark:":
case "-point of interest:":
case "+shrine:":
case "+moongate:":
case "+dungeon:":
case "+scenic:":
case "-gate:":
case "+Body of Water:":
case "+ruins:":
case "+teleporter:":
case "+Terrain:":
case "-exit:":
case "-bridge:":
case "-other:":
case "+champion:":
case "-stairs:":
case "-guild:":
case "+graveyard:":
case "+Island:":
case "+town:":
break;
/*default:
Console.WriteLine(split[0]);
break;*/
}
}
}
from.SendMessage("Done, added {0} spawners", m_Count);
}
public static void PlaceNPC(string sx, string sy, string sm, params string[] types)
@ -283,7 +282,7 @@ namespace Server
if (map.CanFit(x, y, z, 16, false, false))
return z;
for (int i = 1; i <= 20; ++i)
for (int i = 1; i <= 5; ++i)
{
if (map.CanFit(x, y, z + i, 16, false, false))
return z + i;
@ -319,32 +318,36 @@ namespace Server
ClearSpawners(x, y, z, map);
Spawner sp = new Spawner
{
MinDelay = MinTime,
MaxDelay = MaxTime,
Team = Team,
HomeRange = HomeRange
};
int count = 0;
for (int i = 0; i < types.Length; ++i)
{
bool isGuildmaster = types[i].EndsWith("Guildmaster");
bool isGuildMaster = types[i].EndsWith("Guildmaster");
count += isGuildMaster ? 1 : NPCCount;
if (isGuildMaster)
count++;
Spawner sp = new Spawner(types[i]);
if (isGuildmaster)
sp.Count = 1;
else
sp.Count = NPCCount;
sp.MinDelay = MinTime;
sp.MaxDelay = MaxTime;
sp.Team = Team;
sp.HomeRange = HomeRange;
sp.MoveToWorld(new Point3D(x, y, z), map);
if (TotalRespawn)
{
sp.Respawn();
sp.BringToHome();
}
++m_Count;
sp.AddEntry(types[i], 100, isGuildMaster ? 1 : NPCCount);
}
sp.Count = count;
sp.MoveToWorld(new Point3D(x, y, z), map);
if (TotalRespawn)
{
sp.Respawn();
sp.BringToHome();
}
m_Count += types.Length;
}
}
}
}