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

@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Server.Accounting;
using Server.Commands;
@ -677,11 +676,11 @@ namespace Server.Factions
public static void FactionItemReset_OnCommand(CommandEventArgs e)
{
ArrayList pots = new ArrayList();
List<Item> items = new List<Item>();
foreach (Item item in World.Items.Values)
if (item is IFactionItem && !(item is HoodedShroudOfShadows))
pots.Add(item);
items.Add(item);
int[] hues = new int[Factions.Count * 2];
@ -693,9 +692,9 @@ namespace Server.Factions
int count = 0;
for (int i = 0; i < pots.Count; ++i)
for (int i = 0; i < items.Count; ++i)
{
Item item = (Item)pots[i];
Item item = items[i];
IFactionItem fci = (IFactionItem)item;
if (fci.FactionItemState != null || item.LootType != LootType.Blessed)
@ -918,7 +917,7 @@ namespace Server.Factions
if (smallest == null)
return true; // sanity
if (StabilityFactor > 0 && (Members.Count + influx) * 100 / StabilityFactor > smallest.Members.Count)
if ((Members.Count + influx) * 100 / StabilityFactor > smallest.Members.Count)
return false;
return true;
@ -939,7 +938,7 @@ namespace Server.Factions
return;
}
if (killer.GetDistanceToSqrt(victim) > 64)
if (killer?.GetDistanceToSqrt(victim) > 64)
{
sigil.ReturnHome();
killer.SendLocalizedMessage(1042230); // The sigil has gone back to its home location.
@ -947,13 +946,13 @@ namespace Server.Factions
else if (Sigil.ExistsOn(killer))
{
sigil.ReturnHome();
killer.SendLocalizedMessage(
killer?.SendLocalizedMessage(
1010258); // The sigil has gone back to its home location because you already have a sigil.
}
else if (!killerPack.TryDropItem(killer, sigil, false))
{
sigil.ReturnHome();
killer.SendLocalizedMessage(1010259); // The sigil has gone home because your backpack is full.
killer?.SendLocalizedMessage(1010259); // The sigil has gone home because your backpack is full.
}
});
@ -998,7 +997,7 @@ namespace Server.Factions
#region Dueling
if (victim.Region.IsPartOf(typeof(SafeZone)))
if (victim.Region.IsPartOf<SafeZone>())
return;
#endregion
@ -1231,12 +1230,7 @@ namespace Server.Factions
}
}
context.m_Timer = Timer.DelayCall(SkillLossPeriod, new TimerStateCallback(ClearSkillLoss_Callback), mob);
}
private static void ClearSkillLoss_Callback(object state)
{
ClearSkillLoss((Mobile)state);
context.m_Timer = Timer.DelayCall(SkillLossPeriod, () => ClearSkillLoss(mob));
}
public static bool ClearSkillLoss(Mobile mob)

View file

@ -11,10 +11,8 @@ namespace Server.Factions
EventSink.Speech += EventSink_Speech;
}
private static void ShowScore_Sandbox(object state)
private static void ShowScore_Sandbox(PlayerState pl)
{
PlayerState pl = (PlayerState)state;
pl?.Mobile.PublicOverheadMessage(MessageType.Regular, pl.Mobile.SpeechHue, true,
pl.KillPoints.ToString("N0")); // NOTE: Added 'N0'
}
@ -141,16 +139,13 @@ namespace Server.Factions
PlayerState pl = PlayerState.Find(from);
if (pl != null)
Timer.DelayCall(TimeSpan.Zero, new TimerStateCallback(ShowScore_Sandbox), pl);
Timer.DelayCall(TimeSpan.Zero, ShowScore_Sandbox, pl);
break;
}
case 0x0178: // i honor your leadership
{
Faction faction = Faction.Find(from);
faction?.BeginHonorLeadership(from);
Faction.Find(from)?.BeginHonorLeadership(from);
break;
}
}

View file

@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Server.Commands;
using Server.Targeting;
@ -7,7 +6,7 @@ using Server.Targeting;
namespace Server.Factions
{
[CustomEnum(new[] { "Britain", "Magincia", "Minoc", "Moonglow", "Skara Brae", "Trinsic", "Vesper", "Yew" })]
public abstract class Town : IComparable
public abstract class Town : IComparable, IComparable<Town>
{
public const int SilverCaptureBonus = 10000;
@ -133,6 +132,11 @@ namespace Server.Factions
public static List<Town> Towns => Reflector.Towns;
public int CompareTo(Town other)
{
return Definition.Sort - other.Definition.Sort;
}
public int CompareTo(object obj)
{
return Definition.Sort - ((Town)obj).Definition.Sort;
@ -225,12 +229,12 @@ namespace Server.Factions
if (Silver + flow < 0)
{
ArrayList toDelete = BuildFinanceList();
List<Mobile> toDelete = BuildFinanceList();
while (Silver + flow < 0 && toDelete.Count > 0)
{
int index = Utility.Random(toDelete.Count);
Mobile mob = (Mobile)toDelete[index];
Mobile mob = toDelete[index];
mob.Delete();
@ -242,19 +246,15 @@ namespace Server.Factions
Silver += flow;
}
public ArrayList BuildFinanceList()
public List<Mobile> BuildFinanceList()
{
ArrayList list = new ArrayList();
List<Mobile> list = new List<Mobile>();
List<VendorList> vendorLists = VendorLists;
for (int i = 0; i < VendorLists.Count; ++i)
list.AddRange(VendorLists[i].Vendors);
for (int i = 0; i < vendorLists.Count; ++i)
list.AddRange(vendorLists[i].Vendors);
List<GuardList> guardLists = GuardLists;
for (int i = 0; i < guardLists.Count; ++i)
list.AddRange(guardLists[i].Guards);
for (int i = 0; i < GuardLists.Count; ++i)
list.AddRange(GuardLists[i].Guards);
return list;
}

View file

@ -32,7 +32,7 @@ namespace Server.Factions
public static bool Exists(Mobile mob)
{
return mob.FindGump(typeof(FactionGump)) != null;
return mob.HasGump<FactionGump>();
}
public void AddHtmlText(int x, int y, int width, int height, TextDefinition text, bool back, bool scroll)

View file

@ -14,7 +14,6 @@ namespace Server.Factions
private Item m_Item;
private Mobile m_Mobile;
private object m_Notice;
private int m_Quality;
private BaseTool m_Tool;
public FactionImbueGump(int quality, Item item, Mobile from, CraftSystem craftSystem, BaseTool tool, object notice,
@ -26,7 +25,6 @@ namespace Server.Factions
m_CraftSystem = craftSystem;
m_Tool = tool;
m_Notice = notice;
m_Quality = quality;
m_Definition = def;
AddPage(0);
@ -38,7 +36,7 @@ namespace Server.Factions
AddHtmlLocalized(20, 60, 170, 25, 1018302, false, false); // Item quality:
AddHtmlLocalized(175, 60, 100, 25, 1018305 - m_Quality, false, false); // Exceptional, Average, Low
AddHtmlLocalized(175, 60, 100, 25, 1018305 - quality, false, false); // Exceptional, Average, Low
AddHtmlLocalized(20, 80, 170, 25, 1011572, false, false); // Item Cost :
AddLabel(175, 80, 0x34, def.SilverCost.ToString("N0")); // NOTE: Added 'N0'

View file

@ -267,9 +267,7 @@ namespace Server.Factions
public override void OnResponse(NetState sender, RelayInfo info)
{
int type, index;
if (!FromButtonID(info.ButtonID, out type, out index))
if (!FromButtonID(info.ButtonID, out int type, out int index))
return;
switch (type)

View file

@ -190,9 +190,7 @@ namespace Server.Factions
return;
}
int type, index;
if (!FromButtonID(info.ButtonID, out type, out index))
if (!FromButtonID(info.ButtonID, out int type, out int index))
return;
switch (type)
@ -259,8 +257,6 @@ namespace Server.Factions
{
VendorList vendorList = vendorLists[index];
Town town = Town.FromRegion(m_From.Region);
if (Town.FromRegion(m_From.Region) != m_Town)
{
m_From.SendLocalizedMessage(1010305); // You must be in your controlled city to buy Items

View file

@ -153,7 +153,6 @@ namespace Server.Factions
if (index >= 0 && index < m_Town.GuardLists.Count)
{
GuardList guardList = m_Town.GuardLists[index];
Town town = Town.FromRegion(m_From.Region);
if (Town.FromRegion(m_From.Region) != m_Town)
{

View file

@ -19,7 +19,7 @@ namespace Server
public override bool Use(Mobile from)
{
if (from.BeginAction(typeof(ClarityPotion)))
if (from.BeginAction<ClarityPotion>())
{
int amount = Utility.Dice(3, 3, 3);
int time = Utility.RandomMinMax(5, 30);
@ -42,7 +42,7 @@ namespace Server
from.PlaySound(0x1EE);
from.AddStatMod(new StatMod(StatType.Int, "clarity-potion", amount, TimeSpan.FromMinutes(time)));
Timer.DelayCall(TimeSpan.FromMinutes(time), delegate { from.EndAction(typeof(ClarityPotion)); });
Timer.DelayCall(TimeSpan.FromMinutes(time), delegate { from.EndAction<ClarityPotion>(); });
return true;
}

View file

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

View file

@ -34,13 +34,13 @@ namespace Server
Point3D origin = new Point3D(pt);
Map facet = from.Map;
if (facet != null && facet.CanFit(pt.X, pt.Y, pt.Z, 16, false, false, true))
if (facet != null && facet.CanFit(pt.X, pt.Y, pt.Z, 16, false, false))
{
Movable = false;
Effects.SendMovingEffect(
from, new Entity(Serial.Zero, origin, facet),
ItemID & 0x3FFF, 7, 0, false, false, Hue - 1, 0
ItemID & 0x3FFF, 7, 0, false, false, Hue - 1
);
Timer.DelayCall(TimeSpan.FromSeconds(0.5), delegate
@ -80,11 +80,11 @@ namespace Server
from.DoHarmful(mob);
SpellHelper.Damage(TimeSpan.FromSeconds(0.50), mob, from, damage / 3, 0, 0, 0, 0,
SpellHelper.Damage(TimeSpan.FromSeconds(0.50), mob, from, damage / 3.0, 0, 0, 0, 0,
100);
SpellHelper.Damage(TimeSpan.FromSeconds(0.70), mob, from, damage / 3, 0, 0, 0, 0,
SpellHelper.Damage(TimeSpan.FromSeconds(0.70), mob, from, damage / 3.0, 0, 0, 0, 0,
100);
SpellHelper.Damage(TimeSpan.FromSeconds(1.00), mob, from, damage / 3, 0, 0, 0, 0,
SpellHelper.Damage(TimeSpan.FromSeconds(1.00), mob, from, damage / 3.0, 0, 0, 0, 0,
100);
Timer.DelayCall(TimeSpan.FromSeconds(0.50), delegate { mob.PlaySound(0x1FB); });

View file

@ -124,7 +124,7 @@ namespace Server.Factions
{
case AllowedPlacing.FactionStronghold:
{
StrongholdRegion region = (StrongholdRegion)Region.Find(p, m).GetRegion(typeof(StrongholdRegion));
StrongholdRegion region = Region.Find(p, m).GetRegion<StrongholdRegion>();
if (region != null && region.Faction == Faction)
return 0;
@ -160,7 +160,7 @@ namespace Server.Factions
if (!CheckDecay() && CheckRange(m.Location, oldLocation, 6))
if (Faction.Find(m) != null &&
(m.Skills[SkillName.DetectHidden].Value - 80.0) / 20.0 > Utility.RandomDouble())
(m.Skills.DetectHidden.Value - 80.0) / 20.0 > Utility.RandomDouble())
PrivateOverheadLocalizedMessage(m, 1010154, MessageHue, "", ""); // [Faction Trap]
}

View file

@ -418,7 +418,7 @@ namespace Server.Factions
public virtual void GenerateBody(bool isFemale, bool randomHair)
{
Hue = Utility.RandomSkinHue();
Hue = Race.Human.RandomSkinHue();
if (isFemale)
{
@ -472,7 +472,7 @@ namespace Server.Factions
m_Item = item;
}
public Mobile Rider
Mobile IMount.Rider
{
get => m_Item.Rider;
set { }

View file

@ -15,6 +15,7 @@ using Server.Targeting;
namespace Server.Factions
{
[Flags]
public enum GuardAI
{
Bless = 0x01, // heal, cure, +stats
@ -588,7 +589,7 @@ namespace Server.Factions
m_Guard.Mana >= 11)
{
spell = new RecallSpell(m_Guard, null,
new RunebookEntry(m_Guard.Home, m_Guard.Map, "Guard's Home", null), null);
new RunebookEntry(m_Guard.Home, m_Guard.Map, "Guard's Home", null));
}
else if (IsAllowed(GuardAI.Bless))
{
@ -598,7 +599,7 @@ namespace Server.Factions
(m_Guard.Mana < 11 || m_Guard.NextCombatTime - Core.TickCount > 2000))
spell = new HealSpell(m_Guard, null);
}
else if (m_Guard.CanBeginAction(typeof(BaseHealPotion)))
else if (m_Guard.CanBeginAction<BaseHealPotion>())
{
UseItemByType(typeof(BaseHealPotion));
}