Revert "Updates Packets & Randomizer (#43)" (#61)

This reverts commit 179cb50557.
This commit is contained in:
Kamron Batman 2019-11-11 08:46:11 -08:00 • committed by GitHub
parent 179cb50557
commit c2ecc76457
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
588 changed files with 16260 additions and 10926 deletions

View file

@ -8,6 +8,7 @@ using Server.Ethics;
using Server.Guilds;
using Server.Items;
using Server.Mobiles;
using Server.Prompts;
using Server.Targeting;
namespace Server.Factions
@ -132,12 +133,21 @@ namespace Server.Factions
public static void HandleAtrophy()
{
if (Factions.Any(f => !f.State.IsAtrophyReady))
return;
foreach (Faction f in Factions)
if (!f.State.IsAtrophyReady)
return;
List<PlayerState> activePlayers = (from f in Factions from ps in f.Members where ps.KillPoints > 0 && ps.IsActive select ps).ToList();
List<PlayerState> activePlayers = new List<PlayerState>();
int distrib = Factions.Sum(f => f.State.CheckAtrophy());
foreach (Faction f in Factions)
foreach (PlayerState ps in f.Members)
if (ps.KillPoints > 0 && ps.IsActive)
activePlayers.Add(ps);
int distrib = 0;
foreach (Faction f in Factions)
distrib += f.State.CheckAtrophy();
if (activePlayers.Count == 0)
return;
@ -148,7 +158,12 @@ namespace Server.Factions
public static void DistributePoints(int distrib)
{
List<PlayerState> activePlayers = (from f in Factions from ps in f.Members where ps.KillPoints > 0 && ps.IsActive select ps).ToList();
List<PlayerState> activePlayers = new List<PlayerState>();
foreach (Faction f in Factions)
foreach (PlayerState ps in f.Members)
if (ps.KillPoints > 0 && ps.IsActive)
activePlayers.Add(ps);
if (activePlayers.Count > 0)
for (int i = 0; i < distrib; ++i)
@ -172,9 +187,13 @@ namespace Server.Factions
return;
if (recvState == null || recvState.Faction != giveState.Faction)
{
from.SendLocalizedMessage(1042497); // Only faction mates can be honored this way.
}
else if (giveState.KillPoints < 5)
{
from.SendLocalizedMessage(1042499); // You must have at least five kill points to honor them.
}
else
{
recvState.LastHonorTime = DateTime.UtcNow;
@ -186,7 +205,9 @@ namespace Server.Factions
}
}
else
{
from.SendLocalizedMessage(1042496); // You may only honor another player.
}
}
public virtual void AddMember(Mobile mob)
@ -628,7 +649,11 @@ namespace Server.Factions
public static void FactionItemReset_OnCommand(CommandEventArgs e)
{
List<Item> items = World.Items.Values.Where(item => item is IFactionItem && !(item is HoodedShroudOfShadows)).ToList();
List<Item> items = new List<Item>();
foreach (Item item in World.Items.Values)
if (item is IFactionItem && !(item is HoodedShroudOfShadows))
items.Add(item);
int[] hues = new int[Factions.Count * 2];
@ -648,7 +673,16 @@ namespace Server.Factions
if (fci.FactionItemState != null || item.LootType != LootType.Blessed)
continue;
if (hues.Any(t => item.Hue == t))
bool isHued = false;
for (int j = 0; j < hues.Length; ++j)
if (item.Hue == hues[j])
{
isHued = true;
break;
}
if (isHued)
{
fci.FactionItemState = null;
++count;
@ -807,7 +841,7 @@ namespace Server.Factions
Silver += tithed;
silver -= tithed;
silver = silver - tithed;
if (silver > 0)
mob.AddToBackpack(new Silver(silver));
@ -853,12 +887,19 @@ namespace Server.Factions
Faction smallest = FindSmallestFaction();
return smallest == null || (Members.Count + influx) * 100 / StabilityFactor <= smallest.Members.Count;
if (smallest == null)
return true; // sanity
if ((Members.Count + influx) * 100 / StabilityFactor > smallest.Members.Count)
return false;
return true;
}
public static void HandleDeath(Mobile victim, Mobile killer)
{
killer ??= victim.FindMostRecentDamager(true);
if (killer == null)
killer = victim.FindMostRecentDamager(true);
PlayerState killerState = PlayerState.Find(killer);
Container killerPack = killer?.Backpack;
@ -900,7 +941,7 @@ namespace Server.Factions
int silver = killerState.Faction.AwardSilver(killer, bc.FactionSilverWorth);
if (silver > 0)
killer?.SendLocalizedMessage(1042748,
killer.SendLocalizedMessage(1042748,
silver.ToString("N0")); // Thou hast earned ~1_AMOUNT~ silver for vanquishing the vile creature.
}
@ -941,7 +982,7 @@ namespace Server.Factions
{
if (victimState.KillPoints <= -6)
{
killer?.SendLocalizedMessage(501693); // This victim is not worth enough to get kill points from.
killer.SendLocalizedMessage(501693); // This victim is not worth enough to get kill points from.
#region Ethics
@ -983,12 +1024,13 @@ namespace Server.Factions
{
victimState.IsActive = true;
killerState.IsActive |= 1 > Utility.Random(3);
if (1 > Utility.Random(3))
killerState.IsActive = true;
int silver = killerState.Faction.AwardSilver(killer, award * 40);
if (silver > 0)
killer?.SendLocalizedMessage(1042736,
killer.SendLocalizedMessage(1042736,
$"{silver:N0} silver\t{victim.Name}"); // You have earned ~1_SILVER_AMOUNT~ pieces for vanquishing ~2_PLAYER_NAME~!
}
@ -997,9 +1039,9 @@ namespace Server.Factions
int offset = award != 1 ? 0 : 2; // for pluralization
string args = $"{award}\t{victim.Name}\t{killer?.Name ?? ""}";
string args = $"{award}\t{victim.Name}\t{killer.Name}";
killer?.SendLocalizedMessage(1042737 + offset,
killer.SendLocalizedMessage(1042737 + offset,
args); // Thou hast been honored with ~1_KILL_POINTS~ kill point(s) for vanquishing ~2_DEAD_PLAYER~!
victim.SendLocalizedMessage(1042738 + offset,
args); // Thou has lost ~1_KILL_POINTS~ kill point(s) to ~3_ATTACKER_NAME~ for being vanquished!
@ -1031,7 +1073,7 @@ namespace Server.Factions
}
else
{
killer?.SendLocalizedMessage(
killer.SendLocalizedMessage(
1042231); // You have recently defeated this enemy and thus their death brings you no honor.
}
}
@ -1242,7 +1284,9 @@ namespace Server.Factions
AddResponse("They have been kicked from their faction.");
}
else
{
LogFailure("They are not in a faction.");
}
break;
}
@ -1256,7 +1300,9 @@ namespace Server.Factions
AddResponse("The account has been banned from joining factions.");
}
else
{
AddResponse("The account is already banned from joining factions.");
}
for (int i = 0; i < acct.Length; ++i)
{
@ -1276,7 +1322,9 @@ namespace Server.Factions
}
}
else
{
LogFailure("They have no assigned account.");
}
break;
}
@ -1285,7 +1333,9 @@ namespace Server.Factions
if (mob.Account is Account acct)
{
if (acct.GetTag("FactionBanned") == null)
{
AddResponse("The account is not already banned from joining factions.");
}
else
{
acct.RemoveTag("FactionBanned");
@ -1293,7 +1343,9 @@ namespace Server.Factions
}
}
else
{
LogFailure("They have no assigned account.");
}
break;
}

View file

@ -260,7 +260,9 @@ namespace Server.Factions
public void OnGivenSilverTo(Mobile mob)
{
SilverGiven ??= new List<SilverGivenEntry>();
if (SilverGiven == null)
SilverGiven = new List<SilverGivenEntry>();
SilverGiven.Add(new SilverGivenEntry(mob));
}

View file

@ -1,6 +1,5 @@
using System;
using System.IO;
using System.Linq;
using Server.Factions;
using Server.Mobiles;
using Server.Network;
@ -42,7 +41,9 @@ namespace Server
if (chance > Utility.Random(100))
{
int weight = _items.Sum(item => item.Weight);
int weight = 0;
foreach (WeightedItem item in _items) weight += item.Weight;
weight = Utility.Random(weight);
@ -176,4 +177,4 @@ namespace Server
public Item Construct() => Activator.CreateInstance(Type) as Item;
}
}
}
}

View file

@ -25,9 +25,7 @@ namespace Server
bool used = false;
IPooledEnumerable eable = from.GetMobilesInRange(8);
foreach (Mobile mob in eable)
foreach (Mobile mob in from.GetMobilesInRange(8))
if (mob.Player && !mob.Alive && from.InLOS(mob))
{
if (Faction.Find(mob) != ourFaction) continue;
@ -43,8 +41,6 @@ namespace Server
}
}
eable.Free();
if (used)
{
from.LocalOverheadMessage(MessageType.Regular, 2219, false, "The urn shatters as you invoke its power.");

View file

@ -113,15 +113,10 @@ namespace Server.Factions
return 502956; // You cannot place a trap on that.
if (Core.ML)
{
IPooledEnumerable eable = m.GetItemsInRange(p, 0);
foreach (Item item in eable)
foreach (Item item in m.GetItemsInRange(p, 0))
if (item is BaseFactionTrap trap && trap.Faction == Faction)
return 1075263; // There is already a trap belonging to your faction at this location.;
eable.Free();
}
switch (AllowedPlacing)
{
case AllowedPlacing.FactionStronghold:
@ -134,12 +129,22 @@ namespace Server.Factions
return 1010355; // This trap can only be placed in your stronghold
}
case AllowedPlacing.AnyFactionTown:
return Town.FromRegion(Region.Find(p, m)) != null ? 0 : 1010356;
{
Town town = Town.FromRegion(Region.Find(p, m));
if (town != null)
return 0;
return 1010356; // This trap can only be placed in a faction town
}
case AllowedPlacing.ControlledFactionTown:
{
Town town = Town.FromRegion(Region.Find(p, m));
return town != null && town.Owner == Faction ? 0 : 1010357;
if (town != null && town.Owner == Faction)
return 0;
return 1010357; // This trap can only be placed in a town your faction controls
}
}
@ -150,16 +155,17 @@ namespace Server.Factions
{
base.OnMovement(m, oldLocation);
if (!CheckDecay() && CheckRange(m.Location, oldLocation, 6) &&
Faction.Find(m) != null && (m.Skills.DetectHidden.Value - 80.0) / 20.0 > Utility.RandomDouble())
PrivateOverheadLocalizedMessage(m, 1010154, MessageHue, "", ""); // [Faction Trap]
if (!CheckDecay() && CheckRange(m.Location, oldLocation, 6))
if (Faction.Find(m) != null &&
(m.Skills.DetectHidden.Value - 80.0) / 20.0 > Utility.RandomDouble())
PrivateOverheadLocalizedMessage(m, 1010154, MessageHue, "", ""); // [Faction Trap]
}
public void PrivateOverheadLocalizedMessage(Mobile to, int number, int hue, string name, string args)
{
NetState ns = to?.NetState;
Packets.SendMessageLocalized(ns, Serial, ItemID, MessageType.Regular, hue, 3, number, name, args);
ns?.Send(new MessageLocalized(Serial, ItemID, MessageType.Regular, hue, 3, number, name, args));
}
public virtual bool CheckDecay()
@ -246,7 +252,10 @@ namespace Server.Factions
if (faction == null && mob is BaseFactionGuard guard)
faction = guard.Faction;
return faction != null && faction != Faction;
if (faction == null)
return false;
return faction != Faction;
}
}
}

View file

@ -23,7 +23,7 @@ namespace Server.Factions
public override void DoVisibleEffect()
{
Effects.SendLocationEffect(GetWorldLocation(), Map, 0x36BD, 15);
Effects.SendLocationEffect(GetWorldLocation(), Map, 0x36BD, 15, 10);
}
public override void DoAttackEffect(Mobile m)

View file

@ -8,10 +8,6 @@ namespace Server.Factions
{
}
public FactionSawTrap(Serial serial) : base(serial)
{
}
public override int LabelNumber => 1041047; // faction saw trap
public override int AttackMessage => 1010544; // The blade cuts deep into your skin!
@ -23,7 +19,7 @@ namespace Server.Factions
public override void DoVisibleEffect()
{
Effects.SendLocationEffect(Location, Map, 0x11AD, 25);
Effects.SendLocationEffect(Location, Map, 0x11AD, 25, 10);
}
public override void DoAttackEffect(Mobile m)

View file

@ -313,9 +313,7 @@ namespace Server.Factions
actPrio = inactPrio = m_Mobile.GetDistanceToSqrt(comb);
}
IPooledEnumerable eable = m_Mobile.GetMobilesInRange(12);
foreach (Mobile m in eable)
foreach (Mobile m in m_Mobile.GetMobilesInRange(12))
if (m != m_Mobile && CanDispel(m))
{
double prio = m_Mobile.GetDistanceToSqrt(m);
@ -333,8 +331,6 @@ namespace Server.Factions
}
}
eable.Free();
return active ?? inactive;
}