Overwrite

Complete Overwrite of the Folder with the free shard. ServUO 57.3 has been added.
This commit is contained in:
Unstable Kitsune
2023-11-28 23:20:26 -05:00
parent 3cd54811de
commit b918192e4e
11608 changed files with 2644205 additions and 47 deletions

View File

@@ -0,0 +1,249 @@
using System;
using Server.Mobiles;
namespace Server.Ethics
{
public abstract class Ethic
{
public static readonly bool Enabled = false;
public static readonly Ethic Hero = new Hero.HeroEthic();
public static readonly Ethic Evil = new Evil.EvilEthic();
public static readonly Ethic[] Ethics = new Ethic[]
{
Hero,
Evil
};
protected EthicDefinition m_Definition;
protected PlayerCollection m_Players;
public Ethic()
{
this.m_Players = new PlayerCollection();
}
public EthicDefinition Definition
{
get
{
return this.m_Definition;
}
}
public PlayerCollection Players
{
get
{
return this.m_Players;
}
}
public static Ethic Find(Item item)
{
if ((item.SavedFlags & 0x100) != 0)
{
if (item.Hue == Hero.Definition.PrimaryHue)
return Hero;
item.SavedFlags &= ~0x100;
}
if ((item.SavedFlags & 0x200) != 0)
{
if (item.Hue == Evil.Definition.PrimaryHue)
return Evil;
item.SavedFlags &= ~0x200;
}
return null;
}
public static bool CheckTrade(Mobile from, Mobile to, Mobile newOwner, Item item)
{
Ethic itemEthic = Find(item);
if (itemEthic == null || Find(newOwner) == itemEthic)
return true;
if (itemEthic == Hero)
(from == newOwner ? to : from).SendMessage("Only heros may receive this item.");
else if (itemEthic == Evil)
(from == newOwner ? to : from).SendMessage("Only the evil may receive this item.");
return false;
}
public static bool CheckEquip(Mobile from, Item item)
{
Ethic itemEthic = Find(item);
if (itemEthic == null || Find(from) == itemEthic)
return true;
if (itemEthic == Hero)
from.SendMessage("Only heros may wear this item.");
else if (itemEthic == Evil)
from.SendMessage("Only the evil may wear this item.");
return false;
}
public static bool IsImbued(Item item)
{
return IsImbued(item, false);
}
public static bool IsImbued(Item item, bool recurse)
{
if (Find(item) != null)
return true;
if (recurse)
{
foreach (Item child in item.Items)
{
if (IsImbued(child, true))
return true;
}
}
return false;
}
public static void Initialize()
{
if (Enabled)
EventSink.Speech += new SpeechEventHandler(EventSink_Speech);
}
public static void EventSink_Speech(SpeechEventArgs e)
{
if (e.Blocked || e.Handled)
return;
Player pl = Player.Find(e.Mobile);
if (pl == null)
{
for (int i = 0; i < Ethics.Length; ++i)
{
Ethic ethic = Ethics[i];
if (!ethic.IsEligible(e.Mobile))
continue;
if (!Insensitive.Equals(ethic.Definition.JoinPhrase.String, e.Speech))
continue;
bool isNearAnkh = false;
foreach (Item item in e.Mobile.GetItemsInRange(2))
{
if (item is Items.AnkhNorth || item is Items.AnkhWest)
{
isNearAnkh = true;
break;
}
}
if (!isNearAnkh)
continue;
pl = new Player(ethic, e.Mobile);
pl.Attach();
e.Mobile.FixedEffect(0x373A, 10, 30);
e.Mobile.PlaySound(0x209);
e.Handled = true;
break;
}
}
else
{
Ethic ethic = pl.Ethic;
for (int i = 0; i < ethic.Definition.Powers.Length; ++i)
{
Power power = ethic.Definition.Powers[i];
if (!Insensitive.Equals(power.Definition.Phrase.String, e.Speech))
continue;
if (!power.CheckInvoke(pl))
continue;
power.BeginInvoke(pl);
e.Handled = true;
break;
}
}
}
public static Ethic Find(Mobile mob)
{
return Find(mob, false, false);
}
public static Ethic Find(Mobile mob, bool inherit)
{
return Find(mob, inherit, false);
}
public static Ethic Find(Mobile mob, bool inherit, bool allegiance)
{
Player pl = Player.Find(mob);
if (pl != null)
return pl.Ethic;
if (inherit && mob is BaseCreature)
{
BaseCreature bc = (BaseCreature)mob;
if (bc.Controlled)
return Find(bc.ControlMaster, false);
else if (bc.Summoned)
return Find(bc.SummonMaster, false);
else if (allegiance)
return bc.EthicAllegiance;
}
return null;
}
public abstract bool IsEligible(Mobile mob);
public virtual void Deserialize(GenericReader reader)
{
int version = reader.ReadEncodedInt();
switch ( version )
{
case 0:
{
int playerCount = reader.ReadEncodedInt();
for (int i = 0; i < playerCount; ++i)
{
Player pl = new Player(this, reader);
if (pl.Mobile != null)
Timer.DelayCall(TimeSpan.Zero, new TimerCallback(pl.CheckAttach));
}
break;
}
}
}
public virtual void Serialize(GenericWriter writer)
{
writer.WriteEncodedInt(0); // version
writer.WriteEncodedInt(this.m_Players.Count);
for (int i = 0; i < this.m_Players.Count; ++i)
this.m_Players[i].Serialize(writer);
}
}
}

View File

@@ -0,0 +1,73 @@
using System;
namespace Server.Ethics
{
[TypeAlias("Server.Factions.EthicsPersistance")]
public class EthicsPersistence : Item
{
private static EthicsPersistence m_Instance;
[Constructable]
public EthicsPersistence()
: base(1)
{
this.Movable = false;
if (m_Instance == null || m_Instance.Deleted)
m_Instance = this;
else
base.Delete();
}
public EthicsPersistence(Serial serial)
: base(serial)
{
m_Instance = this;
}
public static EthicsPersistence Instance
{
get
{
return m_Instance;
}
}
public override string DefaultName
{
get
{
return "Ethics Persistence - Internal";
}
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0); // version
for (int i = 0; i < Ethics.Ethic.Ethics.Length; ++i)
Ethics.Ethic.Ethics[i].Serialize(writer);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
switch ( version )
{
case 0:
{
for (int i = 0; i < Ethics.Ethic.Ethics.Length; ++i)
Ethics.Ethic.Ethics[i].Deserialize(reader);
break;
}
}
}
public override void Delete()
{
}
}
}

View File

@@ -0,0 +1,211 @@
using System;
using Server.Mobiles;
namespace Server.Ethics
{
public class PlayerCollection : System.Collections.ObjectModel.Collection<Player>
{
}
[PropertyObject]
public class Player
{
private readonly Ethic m_Ethic;
private readonly Mobile m_Mobile;
private int m_Power;
private int m_History;
private Mobile m_Steed;
private Mobile m_Familiar;
private DateTime m_Shield;
public Player(Ethic ethic, Mobile mobile)
{
this.m_Ethic = ethic;
this.m_Mobile = mobile;
this.m_Power = 5;
this.m_History = 5;
}
public Player(Ethic ethic, GenericReader reader)
{
this.m_Ethic = ethic;
int version = reader.ReadEncodedInt();
switch ( version )
{
case 0:
{
this.m_Mobile = reader.ReadMobile();
this.m_Power = reader.ReadEncodedInt();
this.m_History = reader.ReadEncodedInt();
this.m_Steed = reader.ReadMobile();
this.m_Familiar = reader.ReadMobile();
this.m_Shield = reader.ReadDeltaTime();
break;
}
}
}
public Ethic Ethic
{
get
{
return this.m_Ethic;
}
}
public Mobile Mobile
{
get
{
return this.m_Mobile;
}
}
[CommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)]
public int Power
{
get
{
return this.m_Power;
}
set
{
this.m_Power = value;
}
}
[CommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)]
public int History
{
get
{
return this.m_History;
}
set
{
this.m_History = value;
}
}
[CommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)]
public Mobile Steed
{
get
{
return this.m_Steed;
}
set
{
this.m_Steed = value;
}
}
[CommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)]
public Mobile Familiar
{
get
{
return this.m_Familiar;
}
set
{
this.m_Familiar = value;
}
}
[CommandProperty(AccessLevel.GameMaster)]
public bool IsShielded
{
get
{
if (this.m_Shield == DateTime.MinValue)
return false;
if (DateTime.UtcNow < (this.m_Shield + TimeSpan.FromHours(1.0)))
return true;
this.FinishShield();
return false;
}
}
public static Player Find(Mobile mob)
{
return Find(mob, false);
}
public static Player Find(Mobile mob, bool inherit)
{
PlayerMobile pm = mob as PlayerMobile;
if (pm == null)
{
if (inherit && mob is BaseCreature)
{
BaseCreature bc = mob as BaseCreature;
if (bc != null && bc.Controlled)
pm = bc.ControlMaster as PlayerMobile;
else if (bc != null && bc.Summoned)
pm = bc.SummonMaster as PlayerMobile;
}
if (pm == null)
return null;
}
Player pl = pm.EthicPlayer;
if (pl != null && !pl.Ethic.IsEligible(pl.Mobile))
pm.EthicPlayer = pl = null;
return pl;
}
public void BeginShield()
{
this.m_Shield = DateTime.UtcNow;
}
public void FinishShield()
{
this.m_Shield = DateTime.MinValue;
}
public void CheckAttach()
{
if (this.m_Ethic.IsEligible(this.m_Mobile))
this.Attach();
}
public void Attach()
{
if (this.m_Mobile is PlayerMobile)
(this.m_Mobile as PlayerMobile).EthicPlayer = this;
this.m_Ethic.Players.Add(this);
}
public void Detach()
{
if (this.m_Mobile is PlayerMobile)
(this.m_Mobile as PlayerMobile).EthicPlayer = null;
this.m_Ethic.Players.Remove(this);
}
public void Serialize(GenericWriter writer)
{
writer.WriteEncodedInt(0); // version
writer.Write(this.m_Mobile);
writer.WriteEncodedInt(this.m_Power);
writer.WriteEncodedInt(this.m_History);
writer.Write(this.m_Steed);
writer.Write(this.m_Familiar);
writer.WriteDeltaTime(this.m_Shield);
}
}
}

View File

@@ -0,0 +1,36 @@
using System;
namespace Server.Ethics
{
public abstract class Power
{
protected PowerDefinition m_Definition;
public PowerDefinition Definition
{
get
{
return this.m_Definition;
}
}
public virtual bool CheckInvoke(Player from)
{
if (!from.Mobile.CheckAlive())
return false;
if (from.Power < this.m_Definition.Power)
{
from.Mobile.LocalOverheadMessage(Server.Network.MessageType.Regular, 0x3B2, false, "You lack the power to invoke this ability.");
return false;
}
return true;
}
public abstract void BeginInvoke(Player from);
public virtual void FinishInvoke(Player from)
{
from.Power -= this.m_Definition.Power;
}
}
}