fix: Stages faction code for serialization conversion (#1835)
This commit is contained in:
parent
20596e52fa
commit
221312be4c
43 changed files with 6234 additions and 6364 deletions
|
|
@ -1,137 +1,136 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Factions
|
||||
namespace Server.Factions;
|
||||
|
||||
public abstract class BaseMonolith : BaseSystemController
|
||||
{
|
||||
public abstract class BaseMonolith : BaseSystemController
|
||||
private Faction m_Faction;
|
||||
private Sigil m_Sigil;
|
||||
private Town m_Town;
|
||||
|
||||
public BaseMonolith(Town town = null, Faction faction = null) : base(0x1183)
|
||||
{
|
||||
private Faction m_Faction;
|
||||
private Sigil m_Sigil;
|
||||
private Town m_Town;
|
||||
Movable = false;
|
||||
Town = town;
|
||||
Faction = faction;
|
||||
Monoliths.Add(this);
|
||||
}
|
||||
|
||||
public BaseMonolith(Town town = null, Faction faction = null) : base(0x1183)
|
||||
public BaseMonolith(Serial serial) : base(serial)
|
||||
{
|
||||
Monoliths.Add(this);
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
|
||||
public Sigil Sigil
|
||||
{
|
||||
get => m_Sigil;
|
||||
set
|
||||
{
|
||||
Movable = false;
|
||||
Town = town;
|
||||
Faction = faction;
|
||||
Monoliths.Add(this);
|
||||
}
|
||||
|
||||
public BaseMonolith(Serial serial) : base(serial)
|
||||
{
|
||||
Monoliths.Add(this);
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
|
||||
public Sigil Sigil
|
||||
{
|
||||
get => m_Sigil;
|
||||
set
|
||||
{
|
||||
if (m_Sigil == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_Sigil = value;
|
||||
|
||||
if (m_Sigil?.LastMonolith != null && m_Sigil.LastMonolith != this && m_Sigil.LastMonolith.Sigil == m_Sigil)
|
||||
{
|
||||
m_Sigil.LastMonolith.Sigil = null;
|
||||
}
|
||||
|
||||
if (m_Sigil != null)
|
||||
{
|
||||
m_Sigil.LastMonolith = this;
|
||||
}
|
||||
|
||||
UpdateSigil();
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
|
||||
public Town Town
|
||||
{
|
||||
get => m_Town;
|
||||
set
|
||||
{
|
||||
m_Town = value;
|
||||
OnTownChanged();
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
|
||||
public Faction Faction
|
||||
{
|
||||
get => m_Faction;
|
||||
set
|
||||
{
|
||||
m_Faction = value;
|
||||
Hue = m_Faction?.Definition.HuePrimary ?? 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static List<BaseMonolith> Monoliths { get; set; } = new();
|
||||
|
||||
public override void OnLocationChange(Point3D oldLocation)
|
||||
{
|
||||
base.OnLocationChange(oldLocation);
|
||||
UpdateSigil();
|
||||
}
|
||||
|
||||
public override void OnMapChange()
|
||||
{
|
||||
base.OnMapChange();
|
||||
UpdateSigil();
|
||||
}
|
||||
|
||||
public virtual void UpdateSigil()
|
||||
{
|
||||
if (m_Sigil?.Deleted != false)
|
||||
if (m_Sigil == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_Sigil.MoveToWorld(new Point3D(X, Y, Z + 18), Map);
|
||||
}
|
||||
m_Sigil = value;
|
||||
|
||||
public virtual void OnTownChanged()
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
base.OnAfterDelete();
|
||||
Monoliths.Remove(this);
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
|
||||
Town.WriteReference(writer, m_Town);
|
||||
Faction.WriteReference(writer, m_Faction);
|
||||
|
||||
writer.Write(m_Sigil);
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadInt();
|
||||
|
||||
switch (version)
|
||||
if (m_Sigil?.LastMonolith != null && m_Sigil.LastMonolith != this && m_Sigil.LastMonolith.Sigil == m_Sigil)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
Town = Town.ReadReference(reader);
|
||||
Faction = Faction.ReadReference(reader);
|
||||
m_Sigil = reader.ReadEntity<Sigil>();
|
||||
break;
|
||||
}
|
||||
m_Sigil.LastMonolith.Sigil = null;
|
||||
}
|
||||
|
||||
if (m_Sigil != null)
|
||||
{
|
||||
m_Sigil.LastMonolith = this;
|
||||
}
|
||||
|
||||
UpdateSigil();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
|
||||
public Town Town
|
||||
{
|
||||
get => m_Town;
|
||||
set
|
||||
{
|
||||
m_Town = value;
|
||||
OnTownChanged();
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
|
||||
public Faction Faction
|
||||
{
|
||||
get => m_Faction;
|
||||
set
|
||||
{
|
||||
m_Faction = value;
|
||||
Hue = m_Faction?.Definition.HuePrimary ?? 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static List<BaseMonolith> Monoliths { get; set; } = new();
|
||||
|
||||
public override void OnLocationChange(Point3D oldLocation)
|
||||
{
|
||||
base.OnLocationChange(oldLocation);
|
||||
UpdateSigil();
|
||||
}
|
||||
|
||||
public override void OnMapChange()
|
||||
{
|
||||
base.OnMapChange();
|
||||
UpdateSigil();
|
||||
}
|
||||
|
||||
public virtual void UpdateSigil()
|
||||
{
|
||||
if (m_Sigil?.Deleted != false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_Sigil.MoveToWorld(new Point3D(X, Y, Z + 18), Map);
|
||||
}
|
||||
|
||||
public virtual void OnTownChanged()
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
base.OnAfterDelete();
|
||||
Monoliths.Remove(this);
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
|
||||
Town.WriteReference(writer, m_Town);
|
||||
Faction.WriteReference(writer, m_Faction);
|
||||
|
||||
writer.Write(m_Sigil);
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadInt();
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
Town = Town.ReadReference(reader);
|
||||
Faction = Faction.ReadReference(reader);
|
||||
m_Sigil = reader.ReadEntity<Sigil>();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,66 +1,44 @@
|
|||
namespace Server.Factions
|
||||
using ModernUO.Serialization;
|
||||
|
||||
namespace Server.Factions;
|
||||
|
||||
[SerializationGenerator(1, false)]
|
||||
public abstract partial class BaseSystemController : Item
|
||||
{
|
||||
public abstract class BaseSystemController : Item
|
||||
private int _labelNumber;
|
||||
|
||||
public BaseSystemController(int itemID) : base(itemID)
|
||||
{
|
||||
private int m_LabelNumber;
|
||||
}
|
||||
|
||||
public BaseSystemController(int itemID) : base(itemID)
|
||||
public virtual int DefaultLabelNumber => 0;
|
||||
|
||||
[SerializableProperty(0, useField: nameof(_labelNumber))]
|
||||
public override int LabelNumber => _labelNumber > 0 ? _labelNumber : DefaultLabelNumber;
|
||||
|
||||
public virtual void AssignName(TextDefinition name)
|
||||
{
|
||||
if (name?.Number > 0)
|
||||
{
|
||||
_labelNumber = name.Number;
|
||||
Name = null;
|
||||
}
|
||||
else if (name?.String != null)
|
||||
{
|
||||
_labelNumber = 0;
|
||||
Name = name.String;
|
||||
}
|
||||
else
|
||||
{
|
||||
_labelNumber = 0;
|
||||
Name = null;
|
||||
}
|
||||
|
||||
public BaseSystemController(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
InvalidateProperties();
|
||||
}
|
||||
|
||||
public virtual int DefaultLabelNumber => base.LabelNumber;
|
||||
public new virtual string DefaultName => null;
|
||||
|
||||
public override int LabelNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_LabelNumber > 0)
|
||||
{
|
||||
return m_LabelNumber;
|
||||
}
|
||||
|
||||
return DefaultLabelNumber;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void AssignName(TextDefinition name)
|
||||
{
|
||||
if (name?.Number > 0)
|
||||
{
|
||||
m_LabelNumber = name.Number;
|
||||
Name = null;
|
||||
}
|
||||
else if (name?.String != null)
|
||||
{
|
||||
m_LabelNumber = 0;
|
||||
Name = name.String;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_LabelNumber = 0;
|
||||
Name = DefaultName;
|
||||
}
|
||||
|
||||
InvalidateProperties();
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadInt();
|
||||
}
|
||||
private void Deserialize(IGenericReader reader, int version)
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,104 +1,103 @@
|
|||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Factions
|
||||
namespace Server.Factions;
|
||||
|
||||
public class FactionStone : BaseSystemController
|
||||
{
|
||||
public class FactionStone : BaseSystemController
|
||||
private Faction m_Faction;
|
||||
|
||||
[Constructible]
|
||||
public FactionStone(Faction faction = null) : base(0xEDC)
|
||||
{
|
||||
private Faction m_Faction;
|
||||
Movable = false;
|
||||
Faction = faction;
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public FactionStone(Faction faction = null) : base(0xEDC)
|
||||
public FactionStone(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
|
||||
public Faction Faction
|
||||
{
|
||||
get => m_Faction;
|
||||
set
|
||||
{
|
||||
Movable = false;
|
||||
Faction = faction;
|
||||
m_Faction = value;
|
||||
|
||||
AssignName(m_Faction?.Definition.FactionStoneName);
|
||||
}
|
||||
}
|
||||
|
||||
public override string DefaultName => "faction stone";
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (m_Faction == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
public FactionStone(Serial serial) : base(serial)
|
||||
if (!from.InRange(GetWorldLocation(), 2))
|
||||
{
|
||||
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that.
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
|
||||
public Faction Faction
|
||||
else if (FactionGump.Exists(from))
|
||||
{
|
||||
get => m_Faction;
|
||||
set
|
||||
{
|
||||
m_Faction = value;
|
||||
|
||||
AssignName(m_Faction?.Definition.FactionStoneName);
|
||||
}
|
||||
from.SendLocalizedMessage(1042160); // You already have a faction menu open.
|
||||
}
|
||||
|
||||
public override string DefaultName => "faction stone";
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
else if (from is PlayerMobile mobile)
|
||||
{
|
||||
if (m_Faction == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var existingFaction = Faction.Find(mobile);
|
||||
|
||||
if (!from.InRange(GetWorldLocation(), 2))
|
||||
if (existingFaction == m_Faction || mobile.AccessLevel >= AccessLevel.GameMaster)
|
||||
{
|
||||
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that.
|
||||
}
|
||||
else if (FactionGump.Exists(from))
|
||||
{
|
||||
from.SendLocalizedMessage(1042160); // You already have a faction menu open.
|
||||
}
|
||||
else if (from is PlayerMobile mobile)
|
||||
{
|
||||
var existingFaction = Faction.Find(mobile);
|
||||
var pl = PlayerState.Find(mobile);
|
||||
|
||||
if (existingFaction == m_Faction || mobile.AccessLevel >= AccessLevel.GameMaster)
|
||||
if (pl?.IsLeaving == true)
|
||||
{
|
||||
var pl = PlayerState.Find(mobile);
|
||||
|
||||
if (pl?.IsLeaving == true)
|
||||
{
|
||||
// You cannot use the faction stone until you have finished quitting your current faction
|
||||
mobile.SendLocalizedMessage(1005051);
|
||||
}
|
||||
else
|
||||
{
|
||||
mobile.SendGump(new FactionStoneGump(mobile, m_Faction));
|
||||
}
|
||||
}
|
||||
else if (existingFaction != null)
|
||||
{
|
||||
// TODO: Validate
|
||||
mobile.SendLocalizedMessage(1005053); // This is not your faction stone!
|
||||
// You cannot use the faction stone until you have finished quitting your current faction
|
||||
mobile.SendLocalizedMessage(1005051);
|
||||
}
|
||||
else
|
||||
{
|
||||
mobile.SendGump(new JoinStoneGump(mobile, m_Faction));
|
||||
mobile.SendGump(new FactionStoneGump(mobile, m_Faction));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
|
||||
Faction.WriteReference(writer, m_Faction);
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadInt();
|
||||
|
||||
switch (version)
|
||||
else if (existingFaction != null)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
Faction = Faction.ReadReference(reader);
|
||||
break;
|
||||
}
|
||||
// TODO: Validate
|
||||
mobile.SendLocalizedMessage(1005053); // This is not your faction stone!
|
||||
}
|
||||
else
|
||||
{
|
||||
mobile.SendGump(new JoinStoneGump(mobile, m_Faction));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
|
||||
Faction.WriteReference(writer, m_Faction);
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadInt();
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
Faction = Faction.ReadReference(reader);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,81 +1,80 @@
|
|||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Factions
|
||||
namespace Server.Factions;
|
||||
|
||||
public class JoinStone : BaseSystemController
|
||||
{
|
||||
public class JoinStone : BaseSystemController
|
||||
private Faction m_Faction;
|
||||
|
||||
[Constructible]
|
||||
public JoinStone(Faction faction = null) : base(0xEDC)
|
||||
{
|
||||
private Faction m_Faction;
|
||||
Movable = false;
|
||||
Faction = faction;
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public JoinStone(Faction faction = null) : base(0xEDC)
|
||||
public JoinStone(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
|
||||
public Faction Faction
|
||||
{
|
||||
get => m_Faction;
|
||||
set
|
||||
{
|
||||
Movable = false;
|
||||
Faction = faction;
|
||||
}
|
||||
m_Faction = value;
|
||||
|
||||
public JoinStone(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
|
||||
public Faction Faction
|
||||
{
|
||||
get => m_Faction;
|
||||
set
|
||||
{
|
||||
m_Faction = value;
|
||||
|
||||
Hue = m_Faction?.Definition.HueJoin ?? 0;
|
||||
AssignName(m_Faction?.Definition.SignupName);
|
||||
}
|
||||
}
|
||||
|
||||
public override string DefaultName => "faction signup stone";
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (m_Faction == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!from.InRange(GetWorldLocation(), 2))
|
||||
{
|
||||
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that.
|
||||
}
|
||||
else if (FactionGump.Exists(from))
|
||||
{
|
||||
from.SendLocalizedMessage(1042160); // You already have a faction menu open.
|
||||
}
|
||||
else if (Faction.Find(from) == null && from is PlayerMobile mobile)
|
||||
{
|
||||
mobile.SendGump(new JoinStoneGump(mobile, m_Faction));
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
|
||||
Faction.WriteReference(writer, m_Faction);
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadInt();
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
Faction = Faction.ReadReference(reader);
|
||||
break;
|
||||
}
|
||||
}
|
||||
Hue = m_Faction?.Definition.HueJoin ?? 0;
|
||||
AssignName(m_Faction?.Definition.SignupName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override string DefaultName => "faction signup stone";
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (m_Faction == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!from.InRange(GetWorldLocation(), 2))
|
||||
{
|
||||
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that.
|
||||
}
|
||||
else if (FactionGump.Exists(from))
|
||||
{
|
||||
from.SendLocalizedMessage(1042160); // You already have a faction menu open.
|
||||
}
|
||||
else if (Faction.Find(from) == null && from is PlayerMobile mobile)
|
||||
{
|
||||
mobile.SendGump(new JoinStoneGump(mobile, m_Faction));
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
|
||||
Faction.WriteReference(writer, m_Faction);
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadInt();
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
Faction = Faction.ReadReference(reader);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,474 +4,473 @@ using Server.Mobiles;
|
|||
using Server.Network;
|
||||
using Server.Targeting;
|
||||
|
||||
namespace Server.Factions
|
||||
namespace Server.Factions;
|
||||
|
||||
public class Sigil : BaseSystemController
|
||||
{
|
||||
public class Sigil : BaseSystemController
|
||||
public const int OwnershipHue = 0xB;
|
||||
|
||||
// ?? time corrupting faction has to return the sigil before corruption time resets ?
|
||||
public static readonly TimeSpan CorruptionGrace = TimeSpan.FromMinutes(Core.SE ? 30.0 : 15.0);
|
||||
|
||||
// Sigil must be held at a stronghold for this amount of time in order to become corrupted
|
||||
public static readonly TimeSpan CorruptionPeriod = Core.SE ? TimeSpan.FromHours(10.0) : TimeSpan.FromHours(24.0);
|
||||
|
||||
// After a sigil has been corrupted it must be returned to the town within this period of time
|
||||
public static readonly TimeSpan ReturnPeriod = TimeSpan.FromHours(1.0);
|
||||
|
||||
// Once it's been returned the corrupting faction owns the town for this period of time
|
||||
public static readonly TimeSpan PurificationPeriod = TimeSpan.FromDays(3.0);
|
||||
private Faction m_Corrupted;
|
||||
private Faction m_Corrupting;
|
||||
|
||||
private Town m_Town;
|
||||
|
||||
public Sigil(Town town) : base(0x1869)
|
||||
{
|
||||
public const int OwnershipHue = 0xB;
|
||||
Movable = false;
|
||||
Town = town;
|
||||
|
||||
// ?? time corrupting faction has to return the sigil before corruption time resets ?
|
||||
public static readonly TimeSpan CorruptionGrace = TimeSpan.FromMinutes(Core.SE ? 30.0 : 15.0);
|
||||
Sigils.Add(this);
|
||||
}
|
||||
|
||||
// Sigil must be held at a stronghold for this amount of time in order to become corrupted
|
||||
public static readonly TimeSpan CorruptionPeriod = Core.SE ? TimeSpan.FromHours(10.0) : TimeSpan.FromHours(24.0);
|
||||
public Sigil(Serial serial) : base(serial)
|
||||
{
|
||||
Sigils.Add(this);
|
||||
}
|
||||
|
||||
// After a sigil has been corrupted it must be returned to the town within this period of time
|
||||
public static readonly TimeSpan ReturnPeriod = TimeSpan.FromHours(1.0);
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
|
||||
public DateTime LastStolen { get; set; }
|
||||
|
||||
// Once it's been returned the corrupting faction owns the town for this period of time
|
||||
public static readonly TimeSpan PurificationPeriod = TimeSpan.FromDays(3.0);
|
||||
private Faction m_Corrupted;
|
||||
private Faction m_Corrupting;
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
|
||||
public DateTime GraceStart { get; set; }
|
||||
|
||||
private Town m_Town;
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
|
||||
public DateTime CorruptionStart { get; set; }
|
||||
|
||||
public Sigil(Town town) : base(0x1869)
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
|
||||
public DateTime PurificationStart { get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
|
||||
public Town Town
|
||||
{
|
||||
get => m_Town;
|
||||
set
|
||||
{
|
||||
Movable = false;
|
||||
Town = town;
|
||||
m_Town = value;
|
||||
Update();
|
||||
}
|
||||
}
|
||||
|
||||
Sigils.Add(this);
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
|
||||
public Faction Corrupted
|
||||
{
|
||||
get => m_Corrupted;
|
||||
set
|
||||
{
|
||||
m_Corrupted = value;
|
||||
Update();
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
|
||||
public Faction Corrupting
|
||||
{
|
||||
get => m_Corrupting;
|
||||
set
|
||||
{
|
||||
m_Corrupting = value;
|
||||
Update();
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
|
||||
public BaseMonolith LastMonolith { get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public bool IsBeingCorrupted => LastMonolith is StrongholdMonolith && LastMonolith.Faction == m_Corrupting &&
|
||||
m_Corrupting != null;
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public bool IsCorrupted => m_Corrupted != null;
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public bool IsPurifying => PurificationStart != DateTime.MinValue;
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public bool IsCorrupting => m_Corrupting != null && m_Corrupting != m_Corrupted;
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public TimeSpan TimeUntilCorruption =>
|
||||
!IsBeingCorrupted ?
|
||||
TimeSpan.Zero :
|
||||
Utility.Max(CorruptionStart + CorruptionPeriod - Core.Now, TimeSpan.Zero);
|
||||
|
||||
public static List<Sigil> Sigils { get; } = new();
|
||||
|
||||
public void Update()
|
||||
{
|
||||
ItemID = m_Town?.Definition.SigilID ?? 0x1869;
|
||||
|
||||
if (m_Town == null)
|
||||
{
|
||||
AssignName(null);
|
||||
}
|
||||
else if (IsCorrupted || IsPurifying)
|
||||
{
|
||||
AssignName(m_Town.Definition.CorruptedSigilName);
|
||||
}
|
||||
else
|
||||
{
|
||||
AssignName(m_Town.Definition.SigilName);
|
||||
}
|
||||
|
||||
public Sigil(Serial serial) : base(serial)
|
||||
InvalidateProperties();
|
||||
}
|
||||
|
||||
public override void GetProperties(IPropertyList list)
|
||||
{
|
||||
base.GetProperties(list);
|
||||
|
||||
if (IsCorrupted)
|
||||
{
|
||||
Sigils.Add(this);
|
||||
m_Corrupted.Definition.SigilControl.AddTo(list);
|
||||
}
|
||||
else
|
||||
{
|
||||
list.Add(1042256); // This sigil is not corrupted.
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
|
||||
public DateTime LastStolen { get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
|
||||
public DateTime GraceStart { get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
|
||||
public DateTime CorruptionStart { get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
|
||||
public DateTime PurificationStart { get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
|
||||
public Town Town
|
||||
if (IsCorrupting)
|
||||
{
|
||||
get => m_Town;
|
||||
set
|
||||
list.Add(1042257); // This sigil is in the process of being corrupted.
|
||||
}
|
||||
else if (IsPurifying)
|
||||
{
|
||||
list.Add(1042258); // This sigil has recently been corrupted, and is undergoing purification.
|
||||
}
|
||||
else
|
||||
{
|
||||
list.Add(1042259); // This sigil is not in the process of being corrupted.
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnSingleClick(Mobile from)
|
||||
{
|
||||
base.OnSingleClick(from);
|
||||
|
||||
if (IsCorrupted)
|
||||
{
|
||||
if (m_Corrupted.Definition.SigilControl.Number > 0)
|
||||
{
|
||||
m_Town = value;
|
||||
Update();
|
||||
LabelTo(from, m_Corrupted.Definition.SigilControl.Number);
|
||||
}
|
||||
else if (m_Corrupted.Definition.SigilControl.String != null)
|
||||
{
|
||||
LabelTo(from, m_Corrupted.Definition.SigilControl.String);
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
|
||||
public Faction Corrupted
|
||||
else
|
||||
{
|
||||
get => m_Corrupted;
|
||||
set
|
||||
{
|
||||
m_Corrupted = value;
|
||||
Update();
|
||||
}
|
||||
LabelTo(from, 1042256); // This sigil is not corrupted.
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
|
||||
public Faction Corrupting
|
||||
if (IsCorrupting)
|
||||
{
|
||||
get => m_Corrupting;
|
||||
set
|
||||
{
|
||||
m_Corrupting = value;
|
||||
Update();
|
||||
}
|
||||
LabelTo(from, 1042257); // This sigil is in the process of being corrupted.
|
||||
}
|
||||
else if (IsPurifying)
|
||||
{
|
||||
LabelTo(from, 1042258); // This sigil has been recently corrupted, and is undergoing purification.
|
||||
}
|
||||
else
|
||||
{
|
||||
LabelTo(from, 1042259); // This sigil is not in the process of being corrupted.
|
||||
}
|
||||
}
|
||||
|
||||
public override bool CheckLift(Mobile from, Item item, ref LRReason reject)
|
||||
{
|
||||
from.SendLocalizedMessage(1005225); // You must use the stealing skill to pick up the sigil
|
||||
return false;
|
||||
}
|
||||
|
||||
private Mobile FindOwner(IEntity parent)
|
||||
{
|
||||
if (parent is Item item)
|
||||
{
|
||||
return item.RootParent as Mobile;
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
|
||||
public BaseMonolith LastMonolith { get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public bool IsBeingCorrupted => LastMonolith is StrongholdMonolith && LastMonolith.Faction == m_Corrupting &&
|
||||
m_Corrupting != null;
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public bool IsCorrupted => m_Corrupted != null;
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public bool IsPurifying => PurificationStart != DateTime.MinValue;
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public bool IsCorrupting => m_Corrupting != null && m_Corrupting != m_Corrupted;
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public TimeSpan TimeUntilCorruption =>
|
||||
!IsBeingCorrupted ?
|
||||
TimeSpan.Zero :
|
||||
Utility.Max(CorruptionStart + CorruptionPeriod - Core.Now, TimeSpan.Zero);
|
||||
|
||||
public static List<Sigil> Sigils { get; } = new();
|
||||
|
||||
public void Update()
|
||||
if (parent is Mobile mobile)
|
||||
{
|
||||
ItemID = m_Town?.Definition.SigilID ?? 0x1869;
|
||||
|
||||
if (m_Town == null)
|
||||
{
|
||||
AssignName(null);
|
||||
}
|
||||
else if (IsCorrupted || IsPurifying)
|
||||
{
|
||||
AssignName(m_Town.Definition.CorruptedSigilName);
|
||||
}
|
||||
else
|
||||
{
|
||||
AssignName(m_Town.Definition.SigilName);
|
||||
}
|
||||
|
||||
InvalidateProperties();
|
||||
return mobile;
|
||||
}
|
||||
|
||||
public override void GetProperties(IPropertyList list)
|
||||
return null;
|
||||
}
|
||||
|
||||
public override void OnAdded(IEntity parent)
|
||||
{
|
||||
base.OnAdded(parent);
|
||||
|
||||
var mob = FindOwner(parent);
|
||||
|
||||
if (mob != null)
|
||||
{
|
||||
base.GetProperties(list);
|
||||
mob.SolidHueOverride = OwnershipHue;
|
||||
}
|
||||
}
|
||||
|
||||
if (IsCorrupted)
|
||||
{
|
||||
m_Corrupted.Definition.SigilControl.AddTo(list);
|
||||
}
|
||||
else
|
||||
{
|
||||
list.Add(1042256); // This sigil is not corrupted.
|
||||
}
|
||||
public override void OnRemoved(IEntity parent)
|
||||
{
|
||||
base.OnRemoved(parent);
|
||||
|
||||
if (IsCorrupting)
|
||||
{
|
||||
list.Add(1042257); // This sigil is in the process of being corrupted.
|
||||
}
|
||||
else if (IsPurifying)
|
||||
{
|
||||
list.Add(1042258); // This sigil has recently been corrupted, and is undergoing purification.
|
||||
}
|
||||
else
|
||||
{
|
||||
list.Add(1042259); // This sigil is not in the process of being corrupted.
|
||||
}
|
||||
var mob = FindOwner(parent);
|
||||
|
||||
if (mob != null)
|
||||
{
|
||||
mob.SolidHueOverride = -1;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (IsChildOf(from.Backpack))
|
||||
{
|
||||
from.BeginTarget(1, false, TargetFlags.None, Sigil_OnTarget);
|
||||
from.SendLocalizedMessage(1042251); // Click on a sigil monolith or player
|
||||
}
|
||||
}
|
||||
|
||||
public static bool ExistsOn(Mobile mob) => mob.Backpack?.FindItemByType<Sigil>() != null;
|
||||
|
||||
private void BeginCorrupting(Faction faction)
|
||||
{
|
||||
m_Corrupting = faction;
|
||||
CorruptionStart = Core.Now;
|
||||
}
|
||||
|
||||
private void ClearCorrupting()
|
||||
{
|
||||
m_Corrupting = null;
|
||||
CorruptionStart = DateTime.MinValue;
|
||||
}
|
||||
|
||||
private void Sigil_OnTarget(Mobile from, object obj)
|
||||
{
|
||||
if (Deleted || !IsChildOf(from.Backpack))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
public override void OnSingleClick(Mobile from)
|
||||
if (obj is Mobile)
|
||||
{
|
||||
base.OnSingleClick(from);
|
||||
|
||||
if (IsCorrupted)
|
||||
if (obj is PlayerMobile targ)
|
||||
{
|
||||
if (m_Corrupted.Definition.SigilControl.Number > 0)
|
||||
var toFaction = Faction.Find(targ);
|
||||
var fromFaction = Faction.Find(from);
|
||||
|
||||
if (toFaction == null)
|
||||
{
|
||||
LabelTo(from, m_Corrupted.Definition.SigilControl.Number);
|
||||
from.SendLocalizedMessage(1005223); // You cannot give the sigil to someone not in a faction
|
||||
}
|
||||
else if (m_Corrupted.Definition.SigilControl.String != null)
|
||||
else if (fromFaction != toFaction)
|
||||
{
|
||||
LabelTo(from, m_Corrupted.Definition.SigilControl.String);
|
||||
from.SendLocalizedMessage(1005222); // You cannot give the sigil to someone not in your faction
|
||||
}
|
||||
else if (ExistsOn(targ))
|
||||
{
|
||||
from.SendLocalizedMessage(1005220); // You cannot give this sigil to someone who already has a sigil
|
||||
}
|
||||
else if (!targ.Alive)
|
||||
{
|
||||
from.SendLocalizedMessage(1042248); // You cannot give a sigil to a dead person.
|
||||
}
|
||||
else if (from.NetState != null && targ.NetState != null)
|
||||
{
|
||||
var pack = targ.Backpack;
|
||||
|
||||
pack?.DropItem(this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LabelTo(from, 1042256); // This sigil is not corrupted.
|
||||
}
|
||||
|
||||
if (IsCorrupting)
|
||||
{
|
||||
LabelTo(from, 1042257); // This sigil is in the process of being corrupted.
|
||||
}
|
||||
else if (IsPurifying)
|
||||
{
|
||||
LabelTo(from, 1042258); // This sigil has been recently corrupted, and is undergoing purification.
|
||||
}
|
||||
else
|
||||
{
|
||||
LabelTo(from, 1042259); // This sigil is not in the process of being corrupted.
|
||||
from.SendLocalizedMessage(1005221); // You cannot give the sigil to them
|
||||
}
|
||||
}
|
||||
|
||||
public override bool CheckLift(Mobile from, Item item, ref LRReason reject)
|
||||
else if (obj is BaseMonolith)
|
||||
{
|
||||
from.SendLocalizedMessage(1005225); // You must use the stealing skill to pick up the sigil
|
||||
return false;
|
||||
}
|
||||
|
||||
private Mobile FindOwner(IEntity parent)
|
||||
{
|
||||
if (parent is Item item)
|
||||
if (obj is StrongholdMonolith sm)
|
||||
{
|
||||
return item.RootParent as Mobile;
|
||||
}
|
||||
|
||||
if (parent is Mobile mobile)
|
||||
{
|
||||
return mobile;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public override void OnAdded(IEntity parent)
|
||||
{
|
||||
base.OnAdded(parent);
|
||||
|
||||
var mob = FindOwner(parent);
|
||||
|
||||
if (mob != null)
|
||||
{
|
||||
mob.SolidHueOverride = OwnershipHue;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnRemoved(IEntity parent)
|
||||
{
|
||||
base.OnRemoved(parent);
|
||||
|
||||
var mob = FindOwner(parent);
|
||||
|
||||
if (mob != null)
|
||||
{
|
||||
mob.SolidHueOverride = -1;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (IsChildOf(from.Backpack))
|
||||
{
|
||||
from.BeginTarget(1, false, TargetFlags.None, Sigil_OnTarget);
|
||||
from.SendLocalizedMessage(1042251); // Click on a sigil monolith or player
|
||||
}
|
||||
}
|
||||
|
||||
public static bool ExistsOn(Mobile mob) => mob.Backpack?.FindItemByType<Sigil>() != null;
|
||||
|
||||
private void BeginCorrupting(Faction faction)
|
||||
{
|
||||
m_Corrupting = faction;
|
||||
CorruptionStart = Core.Now;
|
||||
}
|
||||
|
||||
private void ClearCorrupting()
|
||||
{
|
||||
m_Corrupting = null;
|
||||
CorruptionStart = DateTime.MinValue;
|
||||
}
|
||||
|
||||
private void Sigil_OnTarget(Mobile from, object obj)
|
||||
{
|
||||
if (Deleted || !IsChildOf(from.Backpack))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj is Mobile)
|
||||
{
|
||||
if (obj is PlayerMobile targ)
|
||||
if (sm.Faction == null || sm.Faction != Faction.Find(from))
|
||||
{
|
||||
var toFaction = Faction.Find(targ);
|
||||
var fromFaction = Faction.Find(from);
|
||||
|
||||
if (toFaction == null)
|
||||
{
|
||||
from.SendLocalizedMessage(1005223); // You cannot give the sigil to someone not in a faction
|
||||
}
|
||||
else if (fromFaction != toFaction)
|
||||
{
|
||||
from.SendLocalizedMessage(1005222); // You cannot give the sigil to someone not in your faction
|
||||
}
|
||||
else if (ExistsOn(targ))
|
||||
{
|
||||
from.SendLocalizedMessage(1005220); // You cannot give this sigil to someone who already has a sigil
|
||||
}
|
||||
else if (!targ.Alive)
|
||||
{
|
||||
from.SendLocalizedMessage(1042248); // You cannot give a sigil to a dead person.
|
||||
}
|
||||
else if (from.NetState != null && targ.NetState != null)
|
||||
{
|
||||
var pack = targ.Backpack;
|
||||
|
||||
pack?.DropItem(this);
|
||||
}
|
||||
from.SendLocalizedMessage(1042246); // You can't place that on an enemy monolith
|
||||
}
|
||||
else if (sm.Town == null || sm.Town != m_Town)
|
||||
{
|
||||
from.SendLocalizedMessage(1042247); // That is not the correct faction monolith
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(1005221); // You cannot give the sigil to them
|
||||
sm.Sigil = this;
|
||||
|
||||
var newController = sm.Faction;
|
||||
var oldController = m_Corrupting;
|
||||
|
||||
if (oldController == null)
|
||||
{
|
||||
if (m_Corrupted != newController)
|
||||
{
|
||||
BeginCorrupting(newController);
|
||||
}
|
||||
}
|
||||
else if (GraceStart > DateTime.MinValue && GraceStart + CorruptionGrace < Core.Now)
|
||||
{
|
||||
if (m_Corrupted != newController)
|
||||
{
|
||||
BeginCorrupting(newController); // grace time over, reset period
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearCorrupting();
|
||||
}
|
||||
|
||||
GraceStart = DateTime.MinValue;
|
||||
}
|
||||
else if (newController == oldController)
|
||||
{
|
||||
GraceStart = DateTime.MinValue; // returned within grace period
|
||||
}
|
||||
else if (GraceStart == DateTime.MinValue)
|
||||
{
|
||||
GraceStart = Core.Now;
|
||||
}
|
||||
|
||||
PurificationStart = DateTime.MinValue;
|
||||
}
|
||||
}
|
||||
else if (obj is BaseMonolith)
|
||||
else if (obj is TownMonolith tm)
|
||||
{
|
||||
if (obj is StrongholdMonolith sm)
|
||||
if (tm.Town == null || tm.Town != m_Town)
|
||||
{
|
||||
if (sm.Faction == null || sm.Faction != Faction.Find(from))
|
||||
{
|
||||
from.SendLocalizedMessage(1042246); // You can't place that on an enemy monolith
|
||||
}
|
||||
else if (sm.Town == null || sm.Town != m_Town)
|
||||
{
|
||||
from.SendLocalizedMessage(1042247); // That is not the correct faction monolith
|
||||
}
|
||||
else
|
||||
{
|
||||
sm.Sigil = this;
|
||||
|
||||
var newController = sm.Faction;
|
||||
var oldController = m_Corrupting;
|
||||
|
||||
if (oldController == null)
|
||||
{
|
||||
if (m_Corrupted != newController)
|
||||
{
|
||||
BeginCorrupting(newController);
|
||||
}
|
||||
}
|
||||
else if (GraceStart > DateTime.MinValue && GraceStart + CorruptionGrace < Core.Now)
|
||||
{
|
||||
if (m_Corrupted != newController)
|
||||
{
|
||||
BeginCorrupting(newController); // grace time over, reset period
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearCorrupting();
|
||||
}
|
||||
|
||||
GraceStart = DateTime.MinValue;
|
||||
}
|
||||
else if (newController == oldController)
|
||||
{
|
||||
GraceStart = DateTime.MinValue; // returned within grace period
|
||||
}
|
||||
else if (GraceStart == DateTime.MinValue)
|
||||
{
|
||||
GraceStart = Core.Now;
|
||||
}
|
||||
|
||||
PurificationStart = DateTime.MinValue;
|
||||
}
|
||||
from.SendLocalizedMessage(1042245); // This is not the correct town sigil monolith
|
||||
}
|
||||
else if (obj is TownMonolith tm)
|
||||
else if (m_Corrupted == null || m_Corrupted != Faction.Find(from))
|
||||
{
|
||||
if (tm.Town == null || tm.Town != m_Town)
|
||||
{
|
||||
from.SendLocalizedMessage(1042245); // This is not the correct town sigil monolith
|
||||
}
|
||||
else if (m_Corrupted == null || m_Corrupted != Faction.Find(from))
|
||||
{
|
||||
// Your faction did not corrupt this sigil. Take it to your stronghold.
|
||||
from.SendLocalizedMessage(1042244);
|
||||
}
|
||||
else
|
||||
{
|
||||
tm.Sigil = this;
|
||||
// Your faction did not corrupt this sigil. Take it to your stronghold.
|
||||
from.SendLocalizedMessage(1042244);
|
||||
}
|
||||
else
|
||||
{
|
||||
tm.Sigil = this;
|
||||
|
||||
m_Corrupting = null;
|
||||
PurificationStart = Core.Now;
|
||||
CorruptionStart = DateTime.MinValue;
|
||||
m_Corrupting = null;
|
||||
PurificationStart = Core.Now;
|
||||
CorruptionStart = DateTime.MinValue;
|
||||
|
||||
m_Town.Capture(m_Corrupted);
|
||||
m_Corrupted = null;
|
||||
}
|
||||
m_Town.Capture(m_Corrupted);
|
||||
m_Corrupted = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(1005224); // You can't use the sigil on that
|
||||
}
|
||||
|
||||
Update();
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(1005224); // You can't use the sigil on that
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
Update();
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
|
||||
Town.WriteReference(writer, m_Town);
|
||||
Faction.WriteReference(writer, m_Corrupted);
|
||||
Faction.WriteReference(writer, m_Corrupting);
|
||||
|
||||
writer.Write(LastMonolith);
|
||||
|
||||
writer.Write(LastStolen);
|
||||
writer.Write(GraceStart);
|
||||
writer.Write(CorruptionStart);
|
||||
writer.Write(PurificationStart);
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadInt();
|
||||
|
||||
switch (version)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
case 0:
|
||||
{
|
||||
m_Town = Town.ReadReference(reader);
|
||||
m_Corrupted = Faction.ReadReference(reader);
|
||||
m_Corrupting = Faction.ReadReference(reader);
|
||||
|
||||
writer.Write(0); // version
|
||||
LastMonolith = reader.ReadEntity<BaseMonolith>();
|
||||
|
||||
Town.WriteReference(writer, m_Town);
|
||||
Faction.WriteReference(writer, m_Corrupted);
|
||||
Faction.WriteReference(writer, m_Corrupting);
|
||||
LastStolen = reader.ReadDateTime();
|
||||
GraceStart = reader.ReadDateTime();
|
||||
CorruptionStart = reader.ReadDateTime();
|
||||
PurificationStart = reader.ReadDateTime();
|
||||
|
||||
writer.Write(LastMonolith);
|
||||
Update();
|
||||
|
||||
writer.Write(LastStolen);
|
||||
writer.Write(GraceStart);
|
||||
writer.Write(CorruptionStart);
|
||||
writer.Write(PurificationStart);
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadInt();
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case 0:
|
||||
if (RootParent is Mobile mob)
|
||||
{
|
||||
m_Town = Town.ReadReference(reader);
|
||||
m_Corrupted = Faction.ReadReference(reader);
|
||||
m_Corrupting = Faction.ReadReference(reader);
|
||||
|
||||
LastMonolith = reader.ReadEntity<BaseMonolith>();
|
||||
|
||||
LastStolen = reader.ReadDateTime();
|
||||
GraceStart = reader.ReadDateTime();
|
||||
CorruptionStart = reader.ReadDateTime();
|
||||
PurificationStart = reader.ReadDateTime();
|
||||
|
||||
Update();
|
||||
|
||||
if (RootParent is Mobile mob)
|
||||
{
|
||||
mob.SolidHueOverride = OwnershipHue;
|
||||
}
|
||||
|
||||
break;
|
||||
mob.SolidHueOverride = OwnershipHue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool ReturnHome()
|
||||
{
|
||||
var monolith = LastMonolith;
|
||||
|
||||
if (monolith == null && m_Town != null)
|
||||
{
|
||||
monolith = m_Town.Monolith;
|
||||
}
|
||||
|
||||
if (monolith?.Deleted == false)
|
||||
{
|
||||
monolith.Sigil = this;
|
||||
}
|
||||
|
||||
return monolith?.Deleted == false;
|
||||
}
|
||||
|
||||
public override void OnParentDeleted(IEntity parent)
|
||||
{
|
||||
base.OnParentDeleted(parent);
|
||||
|
||||
ReturnHome();
|
||||
}
|
||||
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
base.OnAfterDelete();
|
||||
|
||||
Sigils.Remove(this);
|
||||
}
|
||||
|
||||
public override void Delete()
|
||||
{
|
||||
if (ReturnHome())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
base.Delete();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool ReturnHome()
|
||||
{
|
||||
var monolith = LastMonolith;
|
||||
|
||||
if (monolith == null && m_Town != null)
|
||||
{
|
||||
monolith = m_Town.Monolith;
|
||||
}
|
||||
|
||||
if (monolith?.Deleted == false)
|
||||
{
|
||||
monolith.Sigil = this;
|
||||
}
|
||||
|
||||
return monolith?.Deleted == false;
|
||||
}
|
||||
|
||||
public override void OnParentDeleted(IEntity parent)
|
||||
{
|
||||
base.OnParentDeleted(parent);
|
||||
|
||||
ReturnHome();
|
||||
}
|
||||
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
base.OnAfterDelete();
|
||||
|
||||
Sigils.Remove(this);
|
||||
}
|
||||
|
||||
public override void Delete()
|
||||
{
|
||||
if (ReturnHome())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
base.Delete();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,34 +1,33 @@
|
|||
namespace Server.Factions
|
||||
namespace Server.Factions;
|
||||
|
||||
public class StrongholdMonolith : BaseMonolith
|
||||
{
|
||||
public class StrongholdMonolith : BaseMonolith
|
||||
public StrongholdMonolith(Town town = null, Faction faction = null) : base(town, faction)
|
||||
{
|
||||
public StrongholdMonolith(Town town = null, Faction faction = null) : base(town, faction)
|
||||
{
|
||||
}
|
||||
|
||||
public StrongholdMonolith(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override int DefaultLabelNumber => 1041042; // A Faction Sigil Monolith
|
||||
|
||||
public override void OnTownChanged()
|
||||
{
|
||||
AssignName(Town?.Definition.StrongholdMonolithName);
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public StrongholdMonolith(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override int DefaultLabelNumber => 1041042; // A Faction Sigil Monolith
|
||||
|
||||
public override void OnTownChanged()
|
||||
{
|
||||
AssignName(Town?.Definition.StrongholdMonolithName);
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,34 +1,33 @@
|
|||
namespace Server.Factions
|
||||
namespace Server.Factions;
|
||||
|
||||
public class TownMonolith : BaseMonolith
|
||||
{
|
||||
public class TownMonolith : BaseMonolith
|
||||
public TownMonolith(Town town = null) : base(town)
|
||||
{
|
||||
public TownMonolith(Town town = null) : base(town)
|
||||
{
|
||||
}
|
||||
|
||||
public TownMonolith(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override int DefaultLabelNumber => 1041403; // A Faction Town Sigil Monolith
|
||||
|
||||
public override void OnTownChanged()
|
||||
{
|
||||
AssignName(Town?.Definition.TownMonolithName);
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public TownMonolith(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override int DefaultLabelNumber => 1041403; // A Faction Town Sigil Monolith
|
||||
|
||||
public override void OnTownChanged()
|
||||
{
|
||||
AssignName(Town?.Definition.TownMonolithName);
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,91 +1,90 @@
|
|||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Factions
|
||||
namespace Server.Factions;
|
||||
|
||||
public class TownStone : BaseSystemController
|
||||
{
|
||||
public class TownStone : BaseSystemController
|
||||
private Town m_Town;
|
||||
|
||||
[Constructible]
|
||||
public TownStone(Town town = null) : base(0xEDE)
|
||||
{
|
||||
private Town m_Town;
|
||||
Movable = false;
|
||||
Town = town;
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public TownStone(Town town = null) : base(0xEDE)
|
||||
public TownStone(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
|
||||
public Town Town
|
||||
{
|
||||
get => m_Town;
|
||||
set
|
||||
{
|
||||
Movable = false;
|
||||
Town = town;
|
||||
}
|
||||
m_Town = value;
|
||||
|
||||
public TownStone(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
|
||||
public Town Town
|
||||
{
|
||||
get => m_Town;
|
||||
set
|
||||
{
|
||||
m_Town = value;
|
||||
|
||||
AssignName(m_Town?.Definition.TownStoneName);
|
||||
}
|
||||
}
|
||||
|
||||
public override string DefaultName => "faction town stone";
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (m_Town == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var faction = Faction.Find(from);
|
||||
|
||||
if (faction == null && from.AccessLevel < AccessLevel.GameMaster)
|
||||
{
|
||||
return; // TODO: Message?
|
||||
}
|
||||
|
||||
if (m_Town.Owner == null || from.AccessLevel < AccessLevel.GameMaster && faction != m_Town.Owner)
|
||||
{
|
||||
from.SendLocalizedMessage(1010332); // Your faction does not control this town
|
||||
}
|
||||
else if (!m_Town.Owner.IsCommander(from))
|
||||
{
|
||||
from.SendLocalizedMessage(1005242); // Only faction Leaders can use townstones
|
||||
}
|
||||
else if (FactionGump.Exists(from))
|
||||
{
|
||||
from.SendLocalizedMessage(1042160); // You already have a faction menu open.
|
||||
}
|
||||
else if (from is PlayerMobile mobile)
|
||||
{
|
||||
mobile.SendGump(new TownStoneGump(mobile, m_Town.Owner, m_Town));
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
|
||||
Town.WriteReference(writer, m_Town);
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadInt();
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
Town = Town.ReadReference(reader);
|
||||
break;
|
||||
}
|
||||
}
|
||||
AssignName(m_Town?.Definition.TownStoneName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override string DefaultName => "faction town stone";
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (m_Town == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var faction = Faction.Find(from);
|
||||
|
||||
if (faction == null && from.AccessLevel < AccessLevel.GameMaster)
|
||||
{
|
||||
return; // TODO: Message?
|
||||
}
|
||||
|
||||
if (m_Town.Owner == null || from.AccessLevel < AccessLevel.GameMaster && faction != m_Town.Owner)
|
||||
{
|
||||
from.SendLocalizedMessage(1010332); // Your faction does not control this town
|
||||
}
|
||||
else if (!m_Town.Owner.IsCommander(from))
|
||||
{
|
||||
from.SendLocalizedMessage(1005242); // Only faction Leaders can use townstones
|
||||
}
|
||||
else if (FactionGump.Exists(from))
|
||||
{
|
||||
from.SendLocalizedMessage(1042160); // You already have a faction menu open.
|
||||
}
|
||||
else if (from is PlayerMobile mobile)
|
||||
{
|
||||
mobile.SendGump(new TownStoneGump(mobile, m_Town.Owner, m_Town));
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
|
||||
Town.WriteReference(writer, m_Town);
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadInt();
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
Town = Town.ReadReference(reader);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,289 +2,288 @@ using System;
|
|||
using Server.Items;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public enum AllowedPlacing
|
||||
{
|
||||
Everywhere,
|
||||
namespace Server.Factions;
|
||||
|
||||
AnyFactionTown,
|
||||
ControlledFactionTown,
|
||||
FactionStronghold
|
||||
public enum AllowedPlacing
|
||||
{
|
||||
Everywhere,
|
||||
|
||||
AnyFactionTown,
|
||||
ControlledFactionTown,
|
||||
FactionStronghold
|
||||
}
|
||||
|
||||
public abstract class BaseFactionTrap : BaseTrap
|
||||
{
|
||||
private TimerExecutionToken _concealingTimerToken;
|
||||
|
||||
public BaseFactionTrap(Faction f, Mobile m, int itemID) : base(itemID)
|
||||
{
|
||||
Visible = false;
|
||||
|
||||
Faction = f;
|
||||
TimeOfPlacement = Core.Now;
|
||||
Placer = m;
|
||||
}
|
||||
|
||||
public abstract class BaseFactionTrap : BaseTrap
|
||||
public BaseFactionTrap(Serial serial) : base(serial)
|
||||
{
|
||||
private TimerExecutionToken _concealingTimerToken;
|
||||
}
|
||||
|
||||
public BaseFactionTrap(Faction f, Mobile m, int itemID) : base(itemID)
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Faction Faction { get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Mobile Placer { get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public DateTime TimeOfPlacement { get; set; }
|
||||
|
||||
public virtual int EffectSound => 0;
|
||||
|
||||
public virtual int SilverFromDisarm => 100;
|
||||
|
||||
public virtual int MessageHue => 0;
|
||||
|
||||
public virtual int AttackMessage => 0;
|
||||
public virtual int DisarmMessage => 0;
|
||||
|
||||
public virtual AllowedPlacing AllowedPlacing => AllowedPlacing.Everywhere;
|
||||
|
||||
public virtual TimeSpan ConcealPeriod => TimeSpan.FromMinutes(1.0);
|
||||
|
||||
public virtual TimeSpan DecayPeriod => Core.AOS ? TimeSpan.FromDays(1.0) : TimeSpan.MaxValue;
|
||||
|
||||
public override void OnTrigger(Mobile from)
|
||||
{
|
||||
if (!IsEnemy(from))
|
||||
{
|
||||
Visible = false;
|
||||
|
||||
Faction = f;
|
||||
TimeOfPlacement = Core.Now;
|
||||
Placer = m;
|
||||
return;
|
||||
}
|
||||
|
||||
public BaseFactionTrap(Serial serial) : base(serial)
|
||||
Conceal();
|
||||
|
||||
DoVisibleEffect();
|
||||
Effects.PlaySound(Location, Map, EffectSound);
|
||||
DoAttackEffect(from);
|
||||
|
||||
var silverToAward = from.Alive ? 20 : 40;
|
||||
|
||||
if (Placer != null && Faction != null)
|
||||
{
|
||||
}
|
||||
var victimState = PlayerState.Find(from);
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Faction Faction { get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Mobile Placer { get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public DateTime TimeOfPlacement { get; set; }
|
||||
|
||||
public virtual int EffectSound => 0;
|
||||
|
||||
public virtual int SilverFromDisarm => 100;
|
||||
|
||||
public virtual int MessageHue => 0;
|
||||
|
||||
public virtual int AttackMessage => 0;
|
||||
public virtual int DisarmMessage => 0;
|
||||
|
||||
public virtual AllowedPlacing AllowedPlacing => AllowedPlacing.Everywhere;
|
||||
|
||||
public virtual TimeSpan ConcealPeriod => TimeSpan.FromMinutes(1.0);
|
||||
|
||||
public virtual TimeSpan DecayPeriod => Core.AOS ? TimeSpan.FromDays(1.0) : TimeSpan.MaxValue;
|
||||
|
||||
public override void OnTrigger(Mobile from)
|
||||
{
|
||||
if (!IsEnemy(from))
|
||||
if (victimState?.CanGiveSilverTo(Placer) == true && victimState.KillPoints > 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var silverGiven = Faction.AwardSilver(Placer, silverToAward);
|
||||
|
||||
Conceal();
|
||||
|
||||
DoVisibleEffect();
|
||||
Effects.PlaySound(Location, Map, EffectSound);
|
||||
DoAttackEffect(from);
|
||||
|
||||
var silverToAward = from.Alive ? 20 : 40;
|
||||
|
||||
if (Placer != null && Faction != null)
|
||||
{
|
||||
var victimState = PlayerState.Find(from);
|
||||
|
||||
if (victimState?.CanGiveSilverTo(Placer) == true && victimState.KillPoints > 0)
|
||||
if (silverGiven > 0)
|
||||
{
|
||||
var silverGiven = Faction.AwardSilver(Placer, silverToAward);
|
||||
|
||||
if (silverGiven > 0)
|
||||
// TODO: Get real message
|
||||
if (from.Alive)
|
||||
{
|
||||
// TODO: Get real message
|
||||
if (from.Alive)
|
||||
{
|
||||
Placer.SendMessage(
|
||||
$"You have earned {silverGiven} silver pieces because {from.Name} fell for your trap."
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
// You have earned ~1_SILVER_AMOUNT~ pieces for vanquishing ~2_PLAYER_NAME~!
|
||||
Placer.SendLocalizedMessage(1042736, $"{silverGiven} silver\t{from.Name}");
|
||||
}
|
||||
Placer.SendMessage(
|
||||
$"You have earned {silverGiven} silver pieces because {from.Name} fell for your trap."
|
||||
);
|
||||
}
|
||||
|
||||
victimState.OnGivenSilverTo(Placer);
|
||||
}
|
||||
}
|
||||
|
||||
from.LocalOverheadMessage(MessageType.Regular, MessageHue, AttackMessage);
|
||||
}
|
||||
|
||||
public abstract void DoVisibleEffect();
|
||||
public abstract void DoAttackEffect(Mobile m);
|
||||
|
||||
public virtual int IsValidLocation() => IsValidLocation(GetWorldLocation(), Map);
|
||||
|
||||
public virtual int IsValidLocation(Point3D p, Map m)
|
||||
{
|
||||
if (m == null)
|
||||
{
|
||||
return 502956; // You cannot place a trap on that.
|
||||
}
|
||||
|
||||
if (Core.ML)
|
||||
{
|
||||
foreach (var item in m.GetItemsAt(p))
|
||||
{
|
||||
if (item is BaseFactionTrap trap && trap.Faction == Faction)
|
||||
else
|
||||
{
|
||||
return 1075263; // There is already a trap belonging to your faction at this location.;
|
||||
// You have earned ~1_SILVER_AMOUNT~ pieces for vanquishing ~2_PLAYER_NAME~!
|
||||
Placer.SendLocalizedMessage(1042736, $"{silverGiven} silver\t{from.Name}");
|
||||
}
|
||||
}
|
||||
|
||||
victimState.OnGivenSilverTo(Placer);
|
||||
}
|
||||
|
||||
switch (AllowedPlacing)
|
||||
{
|
||||
case AllowedPlacing.FactionStronghold:
|
||||
{
|
||||
var region = Region.Find(p, m).GetRegion<StrongholdRegion>();
|
||||
|
||||
if (region != null && region.Faction == Faction)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1010355; // This trap can only be placed in your stronghold
|
||||
}
|
||||
case AllowedPlacing.AnyFactionTown:
|
||||
{
|
||||
var 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:
|
||||
{
|
||||
var town = Town.FromRegion(Region.Find(p, m));
|
||||
|
||||
if (town != null && town.Owner == Faction)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1010357; // This trap can only be placed in a town your faction controls
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public override void OnMovement(Mobile m, Point3D oldLocation)
|
||||
{
|
||||
base.OnMovement(m, oldLocation);
|
||||
from.LocalOverheadMessage(MessageType.Regular, MessageHue, AttackMessage);
|
||||
}
|
||||
|
||||
if (!CheckDecay() && CheckRange(m.Location, oldLocation, 6))
|
||||
public abstract void DoVisibleEffect();
|
||||
public abstract void DoAttackEffect(Mobile m);
|
||||
|
||||
public virtual int IsValidLocation() => IsValidLocation(GetWorldLocation(), Map);
|
||||
|
||||
public virtual int IsValidLocation(Point3D p, Map m)
|
||||
{
|
||||
if (m == null)
|
||||
{
|
||||
return 502956; // You cannot place a trap on that.
|
||||
}
|
||||
|
||||
if (Core.ML)
|
||||
{
|
||||
foreach (var item in m.GetItemsAt(p))
|
||||
{
|
||||
if (Faction.Find(m) != null &&
|
||||
(m.Skills.DetectHidden.Value - 80.0) / 20.0 > Utility.RandomDouble())
|
||||
if (item is BaseFactionTrap trap && trap.Faction == Faction)
|
||||
{
|
||||
PrivateOverheadLocalizedMessage(m, 1010154, MessageHue, "", ""); // [Faction Trap]
|
||||
return 1075263; // There is already a trap belonging to your faction at this location.;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void PrivateOverheadLocalizedMessage(Mobile to, int number, int hue, string name, string args)
|
||||
switch (AllowedPlacing)
|
||||
{
|
||||
to?.NetState.SendMessageLocalized(Serial, ItemID, MessageType.Regular, hue, 3, number, name, args);
|
||||
case AllowedPlacing.FactionStronghold:
|
||||
{
|
||||
var region = Region.Find(p, m).GetRegion<StrongholdRegion>();
|
||||
|
||||
if (region != null && region.Faction == Faction)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1010355; // This trap can only be placed in your stronghold
|
||||
}
|
||||
case AllowedPlacing.AnyFactionTown:
|
||||
{
|
||||
var 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:
|
||||
{
|
||||
var town = Town.FromRegion(Region.Find(p, m));
|
||||
|
||||
if (town != null && town.Owner == Faction)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1010357; // This trap can only be placed in a town your faction controls
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool CheckDecay()
|
||||
return 0;
|
||||
}
|
||||
|
||||
public override void OnMovement(Mobile m, Point3D oldLocation)
|
||||
{
|
||||
base.OnMovement(m, oldLocation);
|
||||
|
||||
if (!CheckDecay() && CheckRange(m.Location, oldLocation, 6))
|
||||
{
|
||||
var decayPeriod = DecayPeriod;
|
||||
|
||||
if (decayPeriod == TimeSpan.MaxValue)
|
||||
if (Faction.Find(m) != null &&
|
||||
(m.Skills.DetectHidden.Value - 80.0) / 20.0 > Utility.RandomDouble())
|
||||
{
|
||||
return false;
|
||||
PrivateOverheadLocalizedMessage(m, 1010154, MessageHue, "", ""); // [Faction Trap]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (TimeOfPlacement + decayPeriod < Core.Now)
|
||||
{
|
||||
Timer.StartTimer(Delete);
|
||||
return true;
|
||||
}
|
||||
public void PrivateOverheadLocalizedMessage(Mobile to, int number, int hue, string name, string args)
|
||||
{
|
||||
to?.NetState.SendMessageLocalized(Serial, ItemID, MessageType.Regular, hue, 3, number, name, args);
|
||||
}
|
||||
|
||||
public virtual bool CheckDecay()
|
||||
{
|
||||
var decayPeriod = DecayPeriod;
|
||||
|
||||
if (decayPeriod == TimeSpan.MaxValue)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual void BeginConceal()
|
||||
if (TimeOfPlacement + decayPeriod < Core.Now)
|
||||
{
|
||||
_concealingTimerToken.Cancel();
|
||||
Timer.StartTimer(ConcealPeriod, Conceal, out _concealingTimerToken);
|
||||
Timer.StartTimer(Delete);
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual void Conceal()
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual void BeginConceal()
|
||||
{
|
||||
_concealingTimerToken.Cancel();
|
||||
Timer.StartTimer(ConcealPeriod, Conceal, out _concealingTimerToken);
|
||||
}
|
||||
|
||||
public virtual void Conceal()
|
||||
{
|
||||
_concealingTimerToken.Cancel();
|
||||
|
||||
if (!Deleted)
|
||||
{
|
||||
_concealingTimerToken.Cancel();
|
||||
|
||||
if (!Deleted)
|
||||
{
|
||||
Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
|
||||
Faction.WriteReference(writer, Faction);
|
||||
writer.Write(Placer);
|
||||
writer.Write(TimeOfPlacement);
|
||||
|
||||
if (Visible)
|
||||
{
|
||||
BeginConceal();
|
||||
}
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadInt();
|
||||
|
||||
Faction = Faction.ReadReference(reader);
|
||||
Placer = reader.ReadEntity<Mobile>();
|
||||
TimeOfPlacement = reader.ReadDateTime();
|
||||
|
||||
if (Visible)
|
||||
{
|
||||
BeginConceal();
|
||||
}
|
||||
|
||||
CheckDecay();
|
||||
}
|
||||
|
||||
public override void OnDelete()
|
||||
{
|
||||
if (Faction?.Traps.Contains(this) == true)
|
||||
{
|
||||
Faction.Traps.Remove(this);
|
||||
}
|
||||
|
||||
base.OnDelete();
|
||||
}
|
||||
|
||||
public virtual bool IsEnemy(Mobile mob)
|
||||
{
|
||||
if (mob.Hidden && mob.AccessLevel > AccessLevel.Player)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!mob.Alive || mob.IsDeadBondedPet)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var faction = Faction.Find(mob, true);
|
||||
|
||||
if (faction == null && mob is BaseFactionGuard guard)
|
||||
{
|
||||
faction = guard.Faction;
|
||||
}
|
||||
|
||||
if (faction == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return faction != Faction;
|
||||
Visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
|
||||
Faction.WriteReference(writer, Faction);
|
||||
writer.Write(Placer);
|
||||
writer.Write(TimeOfPlacement);
|
||||
|
||||
if (Visible)
|
||||
{
|
||||
BeginConceal();
|
||||
}
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadInt();
|
||||
|
||||
Faction = Faction.ReadReference(reader);
|
||||
Placer = reader.ReadEntity<Mobile>();
|
||||
TimeOfPlacement = reader.ReadDateTime();
|
||||
|
||||
if (Visible)
|
||||
{
|
||||
BeginConceal();
|
||||
}
|
||||
|
||||
CheckDecay();
|
||||
}
|
||||
|
||||
public override void OnDelete()
|
||||
{
|
||||
if (Faction?.Traps.Contains(this) == true)
|
||||
{
|
||||
Faction.Traps.Remove(this);
|
||||
}
|
||||
|
||||
base.OnDelete();
|
||||
}
|
||||
|
||||
public virtual bool IsEnemy(Mobile mob)
|
||||
{
|
||||
if (mob.Hidden && mob.AccessLevel > AccessLevel.Player)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!mob.Alive || mob.IsDeadBondedPet)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var faction = Faction.Find(mob, true);
|
||||
|
||||
if (faction == null && mob is BaseFactionGuard guard)
|
||||
{
|
||||
faction = guard.Faction;
|
||||
}
|
||||
|
||||
if (faction == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return faction != Faction;
|
||||
}
|
||||
}
|
||||
|
|
@ -2,120 +2,119 @@ using System;
|
|||
using Server.Engines.Craft;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Factions
|
||||
namespace Server.Factions;
|
||||
|
||||
public abstract class BaseFactionTrapDeed : Item, ICraftable
|
||||
{
|
||||
public abstract class BaseFactionTrapDeed : Item, ICraftable
|
||||
private Faction m_Faction;
|
||||
|
||||
public BaseFactionTrapDeed(int itemID = 0x14F0) : base(itemID)
|
||||
{
|
||||
private Faction m_Faction;
|
||||
Weight = 1.0;
|
||||
LootType = LootType.Blessed;
|
||||
}
|
||||
|
||||
public BaseFactionTrapDeed(int itemID = 0x14F0) : base(itemID)
|
||||
public BaseFactionTrapDeed(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public abstract Type TrapType { get; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Faction Faction
|
||||
{
|
||||
get => m_Faction;
|
||||
set
|
||||
{
|
||||
Weight = 1.0;
|
||||
LootType = LootType.Blessed;
|
||||
}
|
||||
m_Faction = value;
|
||||
|
||||
public BaseFactionTrapDeed(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public abstract Type TrapType { get; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Faction Faction
|
||||
{
|
||||
get => m_Faction;
|
||||
set
|
||||
if (m_Faction != null)
|
||||
{
|
||||
m_Faction = value;
|
||||
|
||||
if (m_Faction != null)
|
||||
{
|
||||
Hue = m_Faction.Definition.HuePrimary;
|
||||
}
|
||||
Hue = m_Faction.Definition.HuePrimary;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int OnCraft(
|
||||
int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool,
|
||||
CraftItem craftItem, int resHue
|
||||
)
|
||||
public int OnCraft(
|
||||
int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool,
|
||||
CraftItem craftItem, int resHue
|
||||
)
|
||||
{
|
||||
ItemID = 0x14F0;
|
||||
Faction = Faction.Find(from);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
public virtual BaseFactionTrap Construct(Mobile from)
|
||||
{
|
||||
try
|
||||
{
|
||||
ItemID = 0x14F0;
|
||||
Faction = Faction.Find(from);
|
||||
|
||||
return 1;
|
||||
return TrapType.CreateInstance<BaseFactionTrap>(m_Faction, from);
|
||||
}
|
||||
|
||||
public virtual BaseFactionTrap Construct(Mobile from)
|
||||
catch
|
||||
{
|
||||
try
|
||||
{
|
||||
return TrapType.CreateInstance<BaseFactionTrap>(m_Faction, from);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
var faction = Faction.Find(from);
|
||||
|
||||
if (faction == null)
|
||||
{
|
||||
var faction = Faction.Find(from);
|
||||
from.SendLocalizedMessage(1010353, "", 0x23); // Only faction members may place faction traps
|
||||
}
|
||||
else if (faction != m_Faction)
|
||||
{
|
||||
from.SendLocalizedMessage(1010354, "", 0x23); // You may only place faction traps created by your faction
|
||||
}
|
||||
else if (faction.Traps.Count >= faction.MaximumTraps)
|
||||
{
|
||||
from.SendLocalizedMessage(1010358, "", 0x23); // Your faction already has the maximum number of traps placed
|
||||
}
|
||||
else
|
||||
{
|
||||
var trap = Construct(from);
|
||||
|
||||
if (faction == null)
|
||||
if (trap == null)
|
||||
{
|
||||
from.SendLocalizedMessage(1010353, "", 0x23); // Only faction members may place faction traps
|
||||
return;
|
||||
}
|
||||
else if (faction != m_Faction)
|
||||
|
||||
var message = trap.IsValidLocation(from.Location, from.Map);
|
||||
|
||||
if (message > 0)
|
||||
{
|
||||
from.SendLocalizedMessage(1010354, "", 0x23); // You may only place faction traps created by your faction
|
||||
}
|
||||
else if (faction.Traps.Count >= faction.MaximumTraps)
|
||||
{
|
||||
from.SendLocalizedMessage(1010358, "", 0x23); // Your faction already has the maximum number of traps placed
|
||||
from.SendLocalizedMessage(message, "", 0x23);
|
||||
trap.Delete();
|
||||
}
|
||||
else
|
||||
{
|
||||
var trap = Construct(from);
|
||||
|
||||
if (trap == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var message = trap.IsValidLocation(from.Location, from.Map);
|
||||
|
||||
if (message > 0)
|
||||
{
|
||||
from.SendLocalizedMessage(message, "", 0x23);
|
||||
trap.Delete();
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(1010360); // You arm the trap and carefully hide it from view
|
||||
trap.MoveToWorld(from.Location, from.Map);
|
||||
faction.Traps.Add(trap);
|
||||
Delete();
|
||||
}
|
||||
from.SendLocalizedMessage(1010360); // You arm the trap and carefully hide it from view
|
||||
trap.MoveToWorld(from.Location, from.Map);
|
||||
faction.Traps.Add(trap);
|
||||
Delete();
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
|
||||
Faction.WriteReference(writer, m_Faction);
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadInt();
|
||||
|
||||
m_Faction = Faction.ReadReference(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
|
||||
Faction.WriteReference(writer, m_Faction);
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadInt();
|
||||
|
||||
m_Faction = Faction.ReadReference(reader);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue