Overwrite
Complete Overwrite of the Folder with the free shard. ServUO 57.3 has been added.
This commit is contained in:
626
Scripts/Services/Factions/Core/Election.cs
Normal file
626
Scripts/Services/Factions/Core/Election.cs
Normal file
@@ -0,0 +1,626 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public enum ElectionState
|
||||
{
|
||||
Pending,
|
||||
Campaign,
|
||||
Election
|
||||
}
|
||||
|
||||
public class Election
|
||||
{
|
||||
public static readonly TimeSpan PendingPeriod = TimeSpan.FromDays(5.0);
|
||||
public static readonly TimeSpan CampaignPeriod = TimeSpan.FromDays(1.0);
|
||||
public static readonly TimeSpan VotingPeriod = TimeSpan.FromDays(3.0);
|
||||
|
||||
public const int MaxCandidates = 10;
|
||||
public const int CandidateRank = 5;
|
||||
private Faction m_Faction;
|
||||
private readonly List<Candidate> m_Candidates;
|
||||
private ElectionState m_State;
|
||||
private DateTime m_LastStateTime;
|
||||
private Timer m_Timer;
|
||||
|
||||
public Election(Faction faction)
|
||||
{
|
||||
m_Faction = faction;
|
||||
m_Candidates = new List<Candidate>();
|
||||
|
||||
StartTimer();
|
||||
}
|
||||
|
||||
public Election(GenericReader reader)
|
||||
{
|
||||
int version = reader.ReadEncodedInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
m_Faction = Faction.ReadReference(reader);
|
||||
|
||||
m_LastStateTime = reader.ReadDateTime();
|
||||
m_State = (ElectionState)reader.ReadEncodedInt();
|
||||
|
||||
m_Candidates = new List<Candidate>();
|
||||
|
||||
int count = reader.ReadEncodedInt();
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
Candidate cd = new Candidate(reader);
|
||||
|
||||
if (cd.Mobile != null)
|
||||
m_Candidates.Add(cd);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
StartTimer();
|
||||
}
|
||||
|
||||
public Faction Faction
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Faction;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_Faction = value;
|
||||
}
|
||||
}
|
||||
public List<Candidate> Candidates
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Candidates;
|
||||
}
|
||||
}
|
||||
public ElectionState State
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_State;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_State = value;
|
||||
m_LastStateTime = DateTime.UtcNow;
|
||||
}
|
||||
}
|
||||
public DateTime LastStateTime
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_LastStateTime;
|
||||
}
|
||||
}
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public ElectionState CurrentState
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_State;
|
||||
}
|
||||
}
|
||||
[CommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)]
|
||||
public TimeSpan NextStateTime
|
||||
{
|
||||
get
|
||||
{
|
||||
TimeSpan period;
|
||||
|
||||
switch ( m_State )
|
||||
{
|
||||
default:
|
||||
case ElectionState.Pending:
|
||||
period = PendingPeriod;
|
||||
break;
|
||||
case ElectionState.Election:
|
||||
period = VotingPeriod;
|
||||
break;
|
||||
case ElectionState.Campaign:
|
||||
period = CampaignPeriod;
|
||||
break;
|
||||
}
|
||||
|
||||
TimeSpan until = (m_LastStateTime + period) - DateTime.UtcNow;
|
||||
|
||||
if (until < TimeSpan.Zero)
|
||||
until = TimeSpan.Zero;
|
||||
|
||||
return until;
|
||||
}
|
||||
set
|
||||
{
|
||||
TimeSpan period;
|
||||
|
||||
switch ( m_State )
|
||||
{
|
||||
default:
|
||||
case ElectionState.Pending:
|
||||
period = PendingPeriod;
|
||||
break;
|
||||
case ElectionState.Election:
|
||||
period = VotingPeriod;
|
||||
break;
|
||||
case ElectionState.Campaign:
|
||||
period = CampaignPeriod;
|
||||
break;
|
||||
}
|
||||
|
||||
m_LastStateTime = DateTime.UtcNow - period + value;
|
||||
}
|
||||
}
|
||||
public void StartTimer()
|
||||
{
|
||||
m_Timer = Timer.DelayCall(TimeSpan.FromMinutes(1.0), TimeSpan.FromMinutes(1.0), new TimerCallback(Slice));
|
||||
}
|
||||
|
||||
public void Serialize(GenericWriter writer)
|
||||
{
|
||||
writer.WriteEncodedInt((int)0); // version
|
||||
|
||||
Faction.WriteReference(writer, m_Faction);
|
||||
|
||||
writer.Write((DateTime)m_LastStateTime);
|
||||
writer.WriteEncodedInt((int)m_State);
|
||||
|
||||
writer.WriteEncodedInt(m_Candidates.Count);
|
||||
|
||||
for (int i = 0; i < m_Candidates.Count; ++i)
|
||||
m_Candidates[i].Serialize(writer);
|
||||
}
|
||||
|
||||
public void AddCandidate(Mobile mob)
|
||||
{
|
||||
if (IsCandidate(mob))
|
||||
return;
|
||||
|
||||
m_Candidates.Add(new Candidate(mob));
|
||||
mob.SendLocalizedMessage(1010117); // You are now running for office.
|
||||
}
|
||||
|
||||
public void RemoveVoter(Mobile mob)
|
||||
{
|
||||
if (m_State == ElectionState.Election)
|
||||
{
|
||||
for (int i = 0; i < m_Candidates.Count; ++i)
|
||||
{
|
||||
List<Voter> voters = m_Candidates[i].Voters;
|
||||
|
||||
for (int j = 0; j < voters.Count; ++j)
|
||||
{
|
||||
Voter voter = voters[j];
|
||||
|
||||
if (voter.From == mob)
|
||||
voters.RemoveAt(j--);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveCandidate(Mobile mob)
|
||||
{
|
||||
Candidate cd = FindCandidate(mob);
|
||||
|
||||
if (cd == null)
|
||||
return;
|
||||
|
||||
m_Candidates.Remove(cd);
|
||||
mob.SendLocalizedMessage(1038031);
|
||||
|
||||
if (m_State == ElectionState.Election)
|
||||
{
|
||||
if (m_Candidates.Count == 1)
|
||||
{
|
||||
m_Faction.Broadcast(1038031); // There are no longer any valid candidates in the Faction Commander election.
|
||||
|
||||
Candidate winner = m_Candidates[0];
|
||||
|
||||
Mobile winMob = winner.Mobile;
|
||||
PlayerState pl = PlayerState.Find(winMob);
|
||||
|
||||
if (pl == null || pl.Faction != m_Faction || winMob == m_Faction.Commander)
|
||||
{
|
||||
m_Faction.Broadcast(1038026); // Faction leadership has not changed.
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Faction.Broadcast(1038028); // The faction has a new commander.
|
||||
m_Faction.Commander = winMob;
|
||||
}
|
||||
|
||||
m_Candidates.Clear();
|
||||
State = ElectionState.Pending;
|
||||
}
|
||||
else if (m_Candidates.Count == 0) // well, I guess this'll never happen
|
||||
{
|
||||
m_Faction.Broadcast(1038031); // There are no longer any valid candidates in the Faction Commander election.
|
||||
|
||||
m_Candidates.Clear();
|
||||
State = ElectionState.Pending;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsCandidate(Mobile mob)
|
||||
{
|
||||
return (FindCandidate(mob) != null);
|
||||
}
|
||||
|
||||
public bool CanVote(Mobile mob)
|
||||
{
|
||||
return (m_State == ElectionState.Election && !HasVoted(mob));
|
||||
}
|
||||
|
||||
public bool HasVoted(Mobile mob)
|
||||
{
|
||||
return (FindVoter(mob) != null);
|
||||
}
|
||||
|
||||
public Candidate FindCandidate(Mobile mob)
|
||||
{
|
||||
for (int i = 0; i < m_Candidates.Count; ++i)
|
||||
{
|
||||
if (m_Candidates[i].Mobile == mob)
|
||||
return m_Candidates[i];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public Candidate FindVoter(Mobile mob)
|
||||
{
|
||||
for (int i = 0; i < m_Candidates.Count; ++i)
|
||||
{
|
||||
List<Voter> voters = m_Candidates[i].Voters;
|
||||
|
||||
for (int j = 0; j < voters.Count; ++j)
|
||||
{
|
||||
Voter voter = voters[j];
|
||||
|
||||
if (voter.From == mob)
|
||||
return m_Candidates[i];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool CanBeCandidate(Mobile mob)
|
||||
{
|
||||
if (IsCandidate(mob))
|
||||
return false;
|
||||
|
||||
if (m_Candidates.Count >= MaxCandidates)
|
||||
return false;
|
||||
|
||||
if (m_State != ElectionState.Campaign)
|
||||
return false; // sanity..
|
||||
|
||||
PlayerState pl = PlayerState.Find(mob);
|
||||
|
||||
return (pl != null && pl.Faction == m_Faction && pl.Rank.Rank >= CandidateRank);
|
||||
}
|
||||
|
||||
public void Slice()
|
||||
{
|
||||
if (m_Faction == null || m_Faction.Election != this)
|
||||
{
|
||||
if (m_Timer != null)
|
||||
m_Timer.Stop();
|
||||
|
||||
m_Timer = null;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
switch ( m_State )
|
||||
{
|
||||
case ElectionState.Pending:
|
||||
{
|
||||
if ((m_LastStateTime + PendingPeriod) > DateTime.UtcNow)
|
||||
break;
|
||||
|
||||
m_Faction.Broadcast(1038023); // Campaigning for the Faction Commander election has begun.
|
||||
|
||||
m_Candidates.Clear();
|
||||
State = ElectionState.Campaign;
|
||||
|
||||
break;
|
||||
}
|
||||
case ElectionState.Campaign:
|
||||
{
|
||||
if ((m_LastStateTime + CampaignPeriod) > DateTime.UtcNow)
|
||||
break;
|
||||
|
||||
if (m_Candidates.Count == 0)
|
||||
{
|
||||
m_Faction.Broadcast(1038025); // Nobody ran for office.
|
||||
State = ElectionState.Pending;
|
||||
}
|
||||
else if (m_Candidates.Count == 1)
|
||||
{
|
||||
m_Faction.Broadcast(1038029); // Only one member ran for office.
|
||||
|
||||
Candidate winner = m_Candidates[0];
|
||||
|
||||
Mobile mob = winner.Mobile;
|
||||
PlayerState pl = PlayerState.Find(mob);
|
||||
|
||||
if (pl == null || pl.Faction != m_Faction || mob == m_Faction.Commander)
|
||||
{
|
||||
m_Faction.Broadcast(1038026); // Faction leadership has not changed.
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Faction.Broadcast(1038028); // The faction has a new commander.
|
||||
m_Faction.Commander = mob;
|
||||
}
|
||||
|
||||
m_Candidates.Clear();
|
||||
State = ElectionState.Pending;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Faction.Broadcast(1038030);
|
||||
State = ElectionState.Election;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case ElectionState.Election:
|
||||
{
|
||||
if ((m_LastStateTime + VotingPeriod) > DateTime.UtcNow)
|
||||
break;
|
||||
|
||||
m_Faction.Broadcast(1038024); // The results for the Faction Commander election are in
|
||||
|
||||
Candidate winner = null;
|
||||
|
||||
for (int i = 0; i < m_Candidates.Count; ++i)
|
||||
{
|
||||
Candidate cd = m_Candidates[i];
|
||||
|
||||
PlayerState pl = PlayerState.Find(cd.Mobile);
|
||||
|
||||
if (pl == null || pl.Faction != m_Faction)
|
||||
continue;
|
||||
|
||||
//cd.CleanMuleVotes();
|
||||
|
||||
if (winner == null || cd.Votes > winner.Votes)
|
||||
winner = cd;
|
||||
}
|
||||
|
||||
if (winner == null)
|
||||
{
|
||||
m_Faction.Broadcast(1038026); // Faction leadership has not changed.
|
||||
}
|
||||
else if (winner.Mobile == m_Faction.Commander)
|
||||
{
|
||||
m_Faction.Broadcast(1038027); // The incumbent won the election.
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Faction.Broadcast(1038028); // The faction has a new commander.
|
||||
m_Faction.Commander = winner.Mobile;
|
||||
}
|
||||
|
||||
m_Candidates.Clear();
|
||||
State = ElectionState.Pending;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Voter
|
||||
{
|
||||
private readonly Mobile m_From;
|
||||
private readonly Mobile m_Candidate;
|
||||
private readonly IPAddress m_Address;
|
||||
private readonly DateTime m_Time;
|
||||
public Voter(Mobile from, Mobile candidate)
|
||||
{
|
||||
m_From = from;
|
||||
m_Candidate = candidate;
|
||||
|
||||
if (m_From.NetState != null)
|
||||
m_Address = m_From.NetState.Address;
|
||||
else
|
||||
m_Address = IPAddress.None;
|
||||
|
||||
m_Time = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
public Voter(GenericReader reader, Mobile candidate)
|
||||
{
|
||||
m_Candidate = candidate;
|
||||
|
||||
int version = reader.ReadEncodedInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
m_From = reader.ReadMobile();
|
||||
m_Address = Utility.Intern(reader.ReadIPAddress());
|
||||
m_Time = reader.ReadDateTime();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Mobile From
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_From;
|
||||
}
|
||||
}
|
||||
public Mobile Candidate
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Candidate;
|
||||
}
|
||||
}
|
||||
public IPAddress Address
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Address;
|
||||
}
|
||||
}
|
||||
public DateTime Time
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Time;
|
||||
}
|
||||
}
|
||||
public object[] AcquireFields()
|
||||
{
|
||||
TimeSpan gameTime = TimeSpan.Zero;
|
||||
|
||||
if (m_From is PlayerMobile)
|
||||
gameTime = ((PlayerMobile)m_From).GameTime;
|
||||
|
||||
int kp = 0;
|
||||
|
||||
PlayerState pl = PlayerState.Find(m_From);
|
||||
|
||||
if (pl != null)
|
||||
kp = pl.KillPoints;
|
||||
|
||||
int sk = m_From.Skills.Total;
|
||||
|
||||
int factorSkills = 50 + ((sk * 100) / 10000);
|
||||
int factorKillPts = 100 + (kp * 2);
|
||||
int factorGameTime = 50 + (int)((gameTime.Ticks * 100) / TimeSpan.TicksPerDay);
|
||||
|
||||
int totalFactor = (factorSkills * factorKillPts * Math.Max(factorGameTime, 100)) / 10000;
|
||||
|
||||
if (totalFactor > 100)
|
||||
totalFactor = 100;
|
||||
else if (totalFactor < 0)
|
||||
totalFactor = 0;
|
||||
|
||||
return new object[] { m_From, m_Address, m_Time, totalFactor };
|
||||
}
|
||||
|
||||
public void Serialize(GenericWriter writer)
|
||||
{
|
||||
writer.WriteEncodedInt((int)0);
|
||||
|
||||
writer.Write((Mobile)m_From);
|
||||
writer.Write((IPAddress)m_Address);
|
||||
writer.Write((DateTime)m_Time);
|
||||
}
|
||||
}
|
||||
|
||||
public class Candidate
|
||||
{
|
||||
private readonly Mobile m_Mobile;
|
||||
private readonly List<Voter> m_Voters;
|
||||
public Candidate(Mobile mob)
|
||||
{
|
||||
m_Mobile = mob;
|
||||
m_Voters = new List<Voter>();
|
||||
}
|
||||
|
||||
public Candidate(GenericReader reader)
|
||||
{
|
||||
int version = reader.ReadEncodedInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
m_Mobile = reader.ReadMobile();
|
||||
|
||||
int count = reader.ReadEncodedInt();
|
||||
m_Voters = new List<Voter>(count);
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
Voter voter = new Voter(reader, m_Mobile);
|
||||
|
||||
if (voter.From != null)
|
||||
m_Voters.Add(voter);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
m_Mobile = reader.ReadMobile();
|
||||
|
||||
List<Mobile> mobs = reader.ReadStrongMobileList();
|
||||
m_Voters = new List<Voter>(mobs.Count);
|
||||
|
||||
for (int i = 0; i < mobs.Count; ++i)
|
||||
m_Voters.Add(new Voter(mobs[i], m_Mobile));
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Mobile Mobile
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Mobile;
|
||||
}
|
||||
}
|
||||
public List<Voter> Voters
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Voters;
|
||||
}
|
||||
}
|
||||
public int Votes
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Voters.Count;
|
||||
}
|
||||
}
|
||||
public void CleanMuleVotes()
|
||||
{
|
||||
for (int i = 0; i < m_Voters.Count; ++i)
|
||||
{
|
||||
Voter voter = (Voter)m_Voters[i];
|
||||
|
||||
if ((int)voter.AcquireFields()[3] < 90)
|
||||
m_Voters.RemoveAt(i--);
|
||||
}
|
||||
}
|
||||
|
||||
public void Serialize(GenericWriter writer)
|
||||
{
|
||||
writer.WriteEncodedInt((int)1); // version
|
||||
|
||||
writer.Write((Mobile)m_Mobile);
|
||||
|
||||
writer.WriteEncodedInt((int)m_Voters.Count);
|
||||
|
||||
for (int i = 0; i < m_Voters.Count; ++i)
|
||||
((Voter)m_Voters[i]).Serialize(writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
1595
Scripts/Services/Factions/Core/Faction.cs
Normal file
1595
Scripts/Services/Factions/Core/Faction.cs
Normal file
File diff suppressed because it is too large
Load Diff
179
Scripts/Services/Factions/Core/FactionItem.cs
Normal file
179
Scripts/Services/Factions/Core/FactionItem.cs
Normal file
@@ -0,0 +1,179 @@
|
||||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public interface IFactionItem
|
||||
{
|
||||
FactionItem FactionItemState { get; set; }
|
||||
}
|
||||
|
||||
public class FactionItem
|
||||
{
|
||||
public static readonly TimeSpan ExpirationPeriod = TimeSpan.FromDays(21.0);
|
||||
private readonly Item m_Item;
|
||||
private readonly Faction m_Faction;
|
||||
private DateTime m_Expiration;
|
||||
private int m_MinRank;
|
||||
|
||||
public FactionItem(Item item, Faction faction, int level)
|
||||
{
|
||||
m_Item = item;
|
||||
m_Faction = faction;
|
||||
m_MinRank = level;
|
||||
}
|
||||
|
||||
public FactionItem(GenericReader reader, Faction faction)
|
||||
{
|
||||
int version = reader.ReadEncodedInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
m_MinRank = reader.ReadInt();
|
||||
goto case 0;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
m_Item = reader.ReadItem();
|
||||
m_Expiration = reader.ReadDateTime();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_Faction = faction;
|
||||
}
|
||||
|
||||
public Item Item
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Item;
|
||||
}
|
||||
}
|
||||
public Faction Faction
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Faction;
|
||||
}
|
||||
}
|
||||
public DateTime Expiration
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Expiration;
|
||||
}
|
||||
}
|
||||
public int MinRank
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_MinRank;
|
||||
}
|
||||
}
|
||||
public bool HasExpired
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_Item == null || m_Item.Deleted)
|
||||
return true;
|
||||
|
||||
return (m_Expiration != DateTime.MinValue && DateTime.UtcNow >= m_Expiration);
|
||||
}
|
||||
}
|
||||
public static int GetMaxWearables(Mobile mob)
|
||||
{
|
||||
PlayerState pl = PlayerState.Find(mob);
|
||||
|
||||
if (pl == null)
|
||||
return 0;
|
||||
|
||||
if (pl.Faction.IsCommander(mob))
|
||||
return 9;
|
||||
|
||||
return pl.Rank.MaxWearables;
|
||||
}
|
||||
|
||||
public static FactionItem Find(Item item)
|
||||
{
|
||||
if (item is IFactionItem)
|
||||
{
|
||||
FactionItem state = ((IFactionItem)item).FactionItemState;
|
||||
|
||||
if (state != null && state.HasExpired)
|
||||
{
|
||||
state.Detach();
|
||||
state = null;
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Item Imbue(Item item, Faction faction, bool expire, int hue, int MinRank = 0)
|
||||
{
|
||||
if (!(item is IFactionItem))
|
||||
return item;
|
||||
|
||||
FactionItem state = Find(item);
|
||||
|
||||
if (state == null)
|
||||
{
|
||||
state = new FactionItem(item, faction, MinRank);
|
||||
state.Attach();
|
||||
}
|
||||
|
||||
if (expire)
|
||||
state.StartExpiration();
|
||||
|
||||
if (hue >= 0)
|
||||
item.Hue = hue;
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
public void StartExpiration()
|
||||
{
|
||||
m_Expiration = DateTime.UtcNow + ExpirationPeriod;
|
||||
}
|
||||
|
||||
public void CheckAttach()
|
||||
{
|
||||
if (!HasExpired)
|
||||
Attach();
|
||||
else
|
||||
Detach();
|
||||
}
|
||||
|
||||
public void Attach()
|
||||
{
|
||||
if (m_Item is IFactionItem)
|
||||
((IFactionItem)m_Item).FactionItemState = this;
|
||||
|
||||
if (m_Faction != null)
|
||||
m_Faction.State.FactionItems.Add(this);
|
||||
}
|
||||
|
||||
public void Detach()
|
||||
{
|
||||
if (m_Item is IFactionItem)
|
||||
((IFactionItem)m_Item).FactionItemState = null;
|
||||
|
||||
if (m_Faction != null && m_Faction.State.FactionItems.Contains(this))
|
||||
m_Faction.State.FactionItems.Remove(this);
|
||||
}
|
||||
|
||||
public void Serialize(GenericWriter writer)
|
||||
{
|
||||
writer.WriteEncodedInt((int)1);
|
||||
|
||||
writer.Write(m_MinRank);
|
||||
|
||||
writer.Write((Item)m_Item);
|
||||
writer.Write((DateTime)m_Expiration);
|
||||
}
|
||||
}
|
||||
}
|
||||
389
Scripts/Services/Factions/Core/FactionState.cs
Normal file
389
Scripts/Services/Factions/Core/FactionState.cs
Normal file
@@ -0,0 +1,389 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionState
|
||||
{
|
||||
private static readonly TimeSpan BroadcastPeriod = TimeSpan.FromHours(1.0);
|
||||
private const int BroadcastsPerPeriod = 2;
|
||||
private readonly Faction m_Faction;
|
||||
private readonly DateTime[] m_LastBroadcasts = new DateTime[BroadcastsPerPeriod];
|
||||
private Mobile m_Commander;
|
||||
private int m_Tithe;
|
||||
private int m_Silver;
|
||||
private List<PlayerState> m_Members;
|
||||
private Election m_Election;
|
||||
private List<FactionItem> m_FactionItems;
|
||||
private List<BaseFactionTrap> m_FactionTraps;
|
||||
private DateTime m_LastAtrophy;
|
||||
|
||||
public FactionState(Faction faction)
|
||||
{
|
||||
m_Faction = faction;
|
||||
m_Tithe = 50;
|
||||
m_Members = new List<PlayerState>();
|
||||
m_Election = new Election(faction);
|
||||
m_FactionItems = new List<FactionItem>();
|
||||
m_FactionTraps = new List<BaseFactionTrap>();
|
||||
}
|
||||
|
||||
public FactionState(GenericReader reader)
|
||||
{
|
||||
int version = reader.ReadEncodedInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 6:
|
||||
case 5:
|
||||
{
|
||||
m_LastAtrophy = reader.ReadDateTime();
|
||||
goto case 4;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
int count = reader.ReadEncodedInt();
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
DateTime time = reader.ReadDateTime();
|
||||
|
||||
if (i < m_LastBroadcasts.Length)
|
||||
m_LastBroadcasts[i] = time;
|
||||
}
|
||||
|
||||
goto case 3;
|
||||
}
|
||||
case 3:
|
||||
case 2:
|
||||
case 1:
|
||||
{
|
||||
Election ele = new Election(reader);
|
||||
|
||||
if (Settings.Enabled)
|
||||
m_Election = ele;
|
||||
else
|
||||
m_Election = new Election(m_Faction);
|
||||
|
||||
goto case 0;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
m_Faction = Faction.ReadReference(reader);
|
||||
|
||||
if (m_Election.Faction == null)
|
||||
{
|
||||
m_Election.Faction = m_Faction;
|
||||
}
|
||||
|
||||
m_Commander = reader.ReadMobile();
|
||||
|
||||
if (version < 5)
|
||||
m_LastAtrophy = DateTime.UtcNow;
|
||||
|
||||
if (version < 4)
|
||||
{
|
||||
DateTime time = reader.ReadDateTime();
|
||||
|
||||
if (m_LastBroadcasts.Length > 0)
|
||||
m_LastBroadcasts[0] = time;
|
||||
}
|
||||
|
||||
m_Tithe = reader.ReadEncodedInt();
|
||||
m_Silver = reader.ReadEncodedInt();
|
||||
|
||||
int memberCount = reader.ReadEncodedInt();
|
||||
|
||||
m_Members = new List<PlayerState>();
|
||||
|
||||
for (int i = 0; i < memberCount; ++i)
|
||||
{
|
||||
PlayerState pl = new PlayerState(reader, m_Faction, m_Members);
|
||||
|
||||
if (pl.Mobile != null)
|
||||
{
|
||||
if (Settings.Enabled)
|
||||
{
|
||||
m_Members.Add(pl);
|
||||
}
|
||||
else
|
||||
{
|
||||
Settings.AddDisabledNotice(pl.Mobile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_Faction.State = this;
|
||||
|
||||
m_Faction.ZeroRankOffset = m_Members.Count;
|
||||
m_Members.Sort();
|
||||
|
||||
for (int i = m_Members.Count - 1; i >= 0; i--)
|
||||
{
|
||||
PlayerState player = m_Members[i];
|
||||
|
||||
if (player.KillPoints <= 0)
|
||||
m_Faction.ZeroRankOffset = i;
|
||||
else
|
||||
player.RankIndex = i;
|
||||
}
|
||||
|
||||
m_FactionItems = new List<FactionItem>();
|
||||
|
||||
if (version >= 2)
|
||||
{
|
||||
int factionItemCount = reader.ReadEncodedInt();
|
||||
|
||||
for (int i = 0; i < factionItemCount; ++i)
|
||||
{
|
||||
FactionItem factionItem = new FactionItem(reader, m_Faction);
|
||||
|
||||
if(Settings.Enabled)
|
||||
Timer.DelayCall(TimeSpan.Zero, new TimerCallback(factionItem.CheckAttach)); // sandbox attachment
|
||||
}
|
||||
}
|
||||
|
||||
m_FactionTraps = new List<BaseFactionTrap>();
|
||||
|
||||
if (version >= 3)
|
||||
{
|
||||
int factionTrapCount = reader.ReadEncodedInt();
|
||||
|
||||
for (int i = 0; i < factionTrapCount; ++i)
|
||||
{
|
||||
BaseFactionTrap trap = reader.ReadItem() as BaseFactionTrap;
|
||||
|
||||
if (trap != null && !trap.CheckDecay())
|
||||
{
|
||||
if (Settings.Enabled)
|
||||
m_FactionTraps.Add(trap);
|
||||
else
|
||||
trap.Delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (version < 6 && Settings.Enabled && Core.ML)
|
||||
{
|
||||
FactionCollectionBox box = new FactionCollectionBox(m_Faction);
|
||||
WeakEntityCollection.Add("factions", box);
|
||||
box.MoveToWorld(m_Faction.Definition.Stronghold.CollectionBox, Faction.Facet);
|
||||
}
|
||||
|
||||
if (version < 1)
|
||||
m_Election = new Election(m_Faction);
|
||||
}
|
||||
|
||||
public DateTime LastAtrophy
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_LastAtrophy;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_LastAtrophy = value;
|
||||
}
|
||||
}
|
||||
public bool FactionMessageReady
|
||||
{
|
||||
get
|
||||
{
|
||||
for (int i = 0; i < m_LastBroadcasts.Length; ++i)
|
||||
{
|
||||
if (DateTime.UtcNow >= (m_LastBroadcasts[i] + BroadcastPeriod))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public bool IsAtrophyReady
|
||||
{
|
||||
get
|
||||
{
|
||||
return DateTime.UtcNow >= (m_LastAtrophy + TimeSpan.FromHours(47.0));
|
||||
}
|
||||
}
|
||||
public List<FactionItem> FactionItems
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_FactionItems;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_FactionItems = value;
|
||||
}
|
||||
}
|
||||
public List<BaseFactionTrap> Traps
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_FactionTraps;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_FactionTraps = value;
|
||||
}
|
||||
}
|
||||
public Election Election
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Election;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_Election = value;
|
||||
}
|
||||
}
|
||||
public Mobile Commander
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Commander;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (m_Commander != null)
|
||||
m_Commander.InvalidateProperties();
|
||||
|
||||
m_Commander = value;
|
||||
|
||||
if (m_Commander != null)
|
||||
{
|
||||
m_Commander.SendLocalizedMessage(1042227); // You have been elected Commander of your faction
|
||||
|
||||
m_Commander.InvalidateProperties();
|
||||
|
||||
PlayerState pl = PlayerState.Find(m_Commander);
|
||||
|
||||
if (pl != null && pl.Finance != null)
|
||||
pl.Finance.Finance = null;
|
||||
|
||||
if (pl != null && pl.Sheriff != null)
|
||||
pl.Sheriff.Sheriff = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
public int Tithe
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Tithe;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_Tithe = value;
|
||||
}
|
||||
}
|
||||
public int Silver
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Silver;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_Silver = value;
|
||||
}
|
||||
}
|
||||
public List<PlayerState> Members
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Members;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_Members = value;
|
||||
}
|
||||
}
|
||||
public int CheckAtrophy()
|
||||
{
|
||||
if (DateTime.UtcNow < (m_LastAtrophy + TimeSpan.FromHours(47.0)))
|
||||
return 0;
|
||||
|
||||
int distrib = 0;
|
||||
m_LastAtrophy = DateTime.UtcNow;
|
||||
|
||||
List<PlayerState> members = new List<PlayerState>(m_Members);
|
||||
|
||||
for (int i = 0; i < members.Count; ++i)
|
||||
{
|
||||
PlayerState ps = members[i];
|
||||
|
||||
if (ps.IsActive)
|
||||
{
|
||||
ps.IsActive = false;
|
||||
continue;
|
||||
}
|
||||
else if (ps.KillPoints > 0)
|
||||
{
|
||||
int atrophy = (ps.KillPoints + 9) / 10;
|
||||
ps.KillPoints -= atrophy;
|
||||
distrib += atrophy;
|
||||
}
|
||||
}
|
||||
|
||||
return distrib;
|
||||
}
|
||||
|
||||
public void RegisterBroadcast()
|
||||
{
|
||||
for (int i = 0; i < m_LastBroadcasts.Length; ++i)
|
||||
{
|
||||
if (DateTime.UtcNow >= (m_LastBroadcasts[i] + BroadcastPeriod))
|
||||
{
|
||||
m_LastBroadcasts[i] = DateTime.UtcNow;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Serialize(GenericWriter writer)
|
||||
{
|
||||
writer.WriteEncodedInt((int)6); // version
|
||||
|
||||
writer.Write(m_LastAtrophy);
|
||||
|
||||
writer.WriteEncodedInt((int)m_LastBroadcasts.Length);
|
||||
|
||||
for (int i = 0; i < m_LastBroadcasts.Length; ++i)
|
||||
writer.Write((DateTime)m_LastBroadcasts[i]);
|
||||
|
||||
m_Election.Serialize(writer);
|
||||
|
||||
Faction.WriteReference(writer, m_Faction);
|
||||
|
||||
writer.Write((Mobile)m_Commander);
|
||||
|
||||
writer.WriteEncodedInt((int)m_Tithe);
|
||||
writer.WriteEncodedInt((int)m_Silver);
|
||||
|
||||
writer.WriteEncodedInt((int)m_Members.Count);
|
||||
|
||||
for (int i = 0; i < m_Members.Count; ++i)
|
||||
{
|
||||
PlayerState pl = (PlayerState)m_Members[i];
|
||||
|
||||
pl.Serialize(writer);
|
||||
}
|
||||
|
||||
writer.WriteEncodedInt((int)m_FactionItems.Count);
|
||||
|
||||
for (int i = 0; i < m_FactionItems.Count; ++i)
|
||||
m_FactionItems[i].Serialize(writer);
|
||||
|
||||
writer.WriteEncodedInt((int)m_FactionTraps.Count);
|
||||
|
||||
for (int i = 0; i < m_FactionTraps.Count; ++i)
|
||||
writer.Write((Item)m_FactionTraps[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
137
Scripts/Services/Factions/Core/Generator.cs
Normal file
137
Scripts/Services/Factions/Core/Generator.cs
Normal file
@@ -0,0 +1,137 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Commands;
|
||||
using System.Linq;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class Generator
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
CommandSystem.Register("GenerateFactions", AccessLevel.Administrator, new CommandEventHandler(GenerateFactions_OnCommand));
|
||||
CommandSystem.Register("DeleteFactions", AccessLevel.Administrator, new CommandEventHandler(DeleteFactions_OnCommand));
|
||||
}
|
||||
|
||||
public static void RemoveFactions()
|
||||
{
|
||||
// Removes Items, ie monoliths, stones, etc
|
||||
WeakEntityCollection.Delete("factions");
|
||||
|
||||
List<Item> items = new List<Item>(World.Items.Values.Where(i => i is StrongholdRune ||
|
||||
i is ShrineGem || i is EnchantedBandage || i is PowderOfPerseverance || i is Sigil));
|
||||
|
||||
foreach (var item in items)
|
||||
{
|
||||
item.Delete();
|
||||
}
|
||||
|
||||
ColUtility.Free(items);
|
||||
}
|
||||
|
||||
public static void DeleteFactions_OnCommand(CommandEventArgs e)
|
||||
{
|
||||
RemoveFactions();
|
||||
}
|
||||
|
||||
public static void GenerateFactions_OnCommand(CommandEventArgs e)
|
||||
{
|
||||
if (Settings.Enabled)
|
||||
{
|
||||
new FactionPersistence();
|
||||
|
||||
List<Faction> factions = Faction.Factions;
|
||||
|
||||
foreach (Faction faction in factions)
|
||||
Generate(faction);
|
||||
|
||||
List<Town> towns = Town.Towns;
|
||||
|
||||
foreach (Town town in towns)
|
||||
Generate(town);
|
||||
|
||||
e.Mobile.SendMessage("Factions generated!");
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Mobile.SendMessage("You must enable factions first by disabling VvV before you can generate.");
|
||||
}
|
||||
}
|
||||
|
||||
public static void Generate(Town town)
|
||||
{
|
||||
Map facet = Faction.Facet;
|
||||
|
||||
TownDefinition def = town.Definition;
|
||||
|
||||
if (!CheckExistance(def.Monolith, facet, typeof(TownMonolith)))
|
||||
{
|
||||
TownMonolith mono = new TownMonolith(town);
|
||||
mono.MoveToWorld(def.Monolith, facet);
|
||||
mono.Sigil = new Sigil(town);
|
||||
WeakEntityCollection.Add("factions", mono);
|
||||
WeakEntityCollection.Add("factions", mono.Sigil);
|
||||
}
|
||||
|
||||
if (!CheckExistance(def.TownStone, facet, typeof(TownStone)))
|
||||
{
|
||||
TownStone stone = new TownStone(town);
|
||||
WeakEntityCollection.Add("factions", stone);
|
||||
stone.MoveToWorld(def.TownStone, facet);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Generate(Faction faction)
|
||||
{
|
||||
Map facet = Faction.Facet;
|
||||
|
||||
List<Town> towns = Town.Towns;
|
||||
|
||||
StrongholdDefinition stronghold = faction.Definition.Stronghold;
|
||||
|
||||
if (!CheckExistance(stronghold.JoinStone, facet, typeof(JoinStone)))
|
||||
{
|
||||
JoinStone join = new JoinStone(faction);
|
||||
WeakEntityCollection.Add("factions", join);
|
||||
join.MoveToWorld(stronghold.JoinStone, facet);
|
||||
}
|
||||
|
||||
if (!CheckExistance(stronghold.FactionStone, facet, typeof(FactionStone)))
|
||||
{
|
||||
FactionStone stone = new FactionStone(faction);
|
||||
WeakEntityCollection.Add("factions", stone);
|
||||
stone.MoveToWorld(stronghold.FactionStone, facet);
|
||||
}
|
||||
|
||||
for (int i = 0; i < stronghold.Monoliths.Length; ++i)
|
||||
{
|
||||
Point3D monolith = stronghold.Monoliths[i];
|
||||
|
||||
if (!CheckExistance(monolith, facet, typeof(StrongholdMonolith)))
|
||||
{
|
||||
StrongholdMonolith mono = new StrongholdMonolith(towns[i], faction);
|
||||
WeakEntityCollection.Add("factions", mono);
|
||||
mono.MoveToWorld(monolith, facet);
|
||||
}
|
||||
}
|
||||
|
||||
if (Core.ML && !CheckExistance(stronghold.FactionStone, facet, typeof(FactionCollectionBox)))
|
||||
{
|
||||
FactionCollectionBox box = new FactionCollectionBox(faction);
|
||||
WeakEntityCollection.Add("factions", box);
|
||||
box.MoveToWorld(stronghold.CollectionBox, facet);
|
||||
}
|
||||
}
|
||||
|
||||
private static bool CheckExistance(Point3D loc, Map facet, Type type)
|
||||
{
|
||||
foreach (Item item in facet.GetItemsInRange(loc, 0))
|
||||
{
|
||||
if (type.IsAssignableFrom(item.GetType()))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
42
Scripts/Services/Factions/Core/GuardList.cs
Normal file
42
Scripts/Services/Factions/Core/GuardList.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class GuardList
|
||||
{
|
||||
private readonly GuardDefinition m_Definition;
|
||||
private readonly List<BaseFactionGuard> m_Guards;
|
||||
public GuardList(GuardDefinition definition)
|
||||
{
|
||||
this.m_Definition = definition;
|
||||
this.m_Guards = new List<BaseFactionGuard>();
|
||||
}
|
||||
|
||||
public GuardDefinition Definition
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Definition;
|
||||
}
|
||||
}
|
||||
public List<BaseFactionGuard> Guards
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Guards;
|
||||
}
|
||||
}
|
||||
public BaseFactionGuard Construct()
|
||||
{
|
||||
try
|
||||
{
|
||||
return Activator.CreateInstance(this.m_Definition.Type) as BaseFactionGuard;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
156
Scripts/Services/Factions/Core/Keywords.cs
Normal file
156
Scripts/Services/Factions/Core/Keywords.cs
Normal file
@@ -0,0 +1,156 @@
|
||||
using System;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class Keywords
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
EventSink.Speech += new SpeechEventHandler(EventSink_Speech);
|
||||
}
|
||||
|
||||
private static void ShowScore_Sandbox(object state)
|
||||
{
|
||||
PlayerState pl = (PlayerState)state;
|
||||
|
||||
if (pl != null)
|
||||
pl.Mobile.PublicOverheadMessage(MessageType.Regular, pl.Mobile.SpeechHue, true, pl.KillPoints.ToString("N0")); // NOTE: Added 'N0'
|
||||
}
|
||||
|
||||
private static void EventSink_Speech(SpeechEventArgs e)
|
||||
{
|
||||
Mobile from = e.Mobile;
|
||||
int[] keywords = e.Keywords;
|
||||
|
||||
for (int i = 0; i < keywords.Length; ++i)
|
||||
{
|
||||
switch ( keywords[i] )
|
||||
{
|
||||
case 0x00E4: // *i wish to access the city treasury*
|
||||
{
|
||||
Town town = Town.FromRegion(from.Region);
|
||||
|
||||
if (town == null || !town.IsFinance(from) || !from.Alive)
|
||||
break;
|
||||
|
||||
if (FactionGump.Exists(from))
|
||||
from.SendLocalizedMessage(1042160); // You already have a faction menu open.
|
||||
else if (town.Owner != null && from is PlayerMobile)
|
||||
from.SendGump(new FinanceGump((PlayerMobile)from, town.Owner, town));
|
||||
|
||||
break;
|
||||
}
|
||||
case 0x0ED: // *i am sheriff*
|
||||
{
|
||||
Town town = Town.FromRegion(from.Region);
|
||||
|
||||
if (town == null || !town.IsSheriff(from) || !from.Alive)
|
||||
break;
|
||||
|
||||
if (FactionGump.Exists(from))
|
||||
from.SendLocalizedMessage(1042160); // You already have a faction menu open.
|
||||
else if (town.Owner != null)
|
||||
from.SendGump(new SheriffGump((PlayerMobile)from, town.Owner, town));
|
||||
|
||||
break;
|
||||
}
|
||||
case 0x00EF: // *you are fired*
|
||||
{
|
||||
Town town = Town.FromRegion(from.Region);
|
||||
|
||||
if (town == null)
|
||||
break;
|
||||
|
||||
if (town.IsFinance(from) || town.IsSheriff(from))
|
||||
town.BeginOrderFiring(from);
|
||||
|
||||
break;
|
||||
}
|
||||
case 0x00E5: // *i wish to resign as finance minister*
|
||||
{
|
||||
PlayerState pl = PlayerState.Find(from);
|
||||
|
||||
if (pl != null && pl.Finance != null)
|
||||
{
|
||||
pl.Finance.Finance = null;
|
||||
from.SendLocalizedMessage(1005081); // You have been fired as Finance Minister
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 0x00EE: // *i wish to resign as sheriff*
|
||||
{
|
||||
PlayerState pl = PlayerState.Find(from);
|
||||
|
||||
if (pl != null && pl.Sheriff != null)
|
||||
{
|
||||
pl.Sheriff.Sheriff = null;
|
||||
from.SendLocalizedMessage(1010270); // You have been fired as Sheriff
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 0x00E9: // *what is my faction term status*
|
||||
{
|
||||
PlayerState pl = PlayerState.Find(from);
|
||||
|
||||
if (pl != null && pl.IsLeaving)
|
||||
{
|
||||
if (Faction.CheckLeaveTimer(from))
|
||||
break;
|
||||
|
||||
TimeSpan remaining = (pl.Leaving + Faction.LeavePeriod) - DateTime.UtcNow;
|
||||
|
||||
if (remaining.TotalDays >= 1)
|
||||
from.SendLocalizedMessage(1042743, remaining.TotalDays.ToString("N0")) ;// Your term of service will come to an end in ~1_DAYS~ days.
|
||||
else if (remaining.TotalHours >= 1)
|
||||
from.SendLocalizedMessage(1042741, remaining.TotalHours.ToString("N0")); // Your term of service will come to an end in ~1_HOURS~ hours.
|
||||
else
|
||||
from.SendLocalizedMessage(1042742); // Your term of service will come to an end in less than one hour.
|
||||
}
|
||||
else if (pl != null)
|
||||
{
|
||||
from.SendLocalizedMessage(1042233); // You are not in the process of quitting the faction.
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 0x00EA: // *message faction*
|
||||
{
|
||||
Faction faction = Faction.Find(from);
|
||||
|
||||
if (faction == null || !faction.IsCommander(from))
|
||||
break;
|
||||
|
||||
if (from.IsPlayer() && !faction.FactionMessageReady)
|
||||
from.SendLocalizedMessage(1010264); // The required time has not yet passed since the last message was sent
|
||||
else
|
||||
faction.BeginBroadcast(from);
|
||||
|
||||
break;
|
||||
}
|
||||
case 0x00EC: // *showscore*
|
||||
{
|
||||
PlayerState pl = PlayerState.Find(from);
|
||||
|
||||
if (pl != null)
|
||||
Timer.DelayCall(TimeSpan.Zero, new TimerStateCallback(ShowScore_Sandbox), pl);
|
||||
|
||||
break;
|
||||
}
|
||||
case 0x0178: // i honor your leadership
|
||||
{
|
||||
Faction faction = Faction.Find(from);
|
||||
|
||||
if (faction != null)
|
||||
faction.BeginHonorLeadership(from);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
120
Scripts/Services/Factions/Core/MerchantTitles.cs
Normal file
120
Scripts/Services/Factions/Core/MerchantTitles.cs
Normal file
@@ -0,0 +1,120 @@
|
||||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public enum MerchantTitle
|
||||
{
|
||||
None,
|
||||
Scribe,
|
||||
Carpenter,
|
||||
Blacksmith,
|
||||
Bowyer,
|
||||
Tialor
|
||||
}
|
||||
|
||||
public class MerchantTitleInfo
|
||||
{
|
||||
private readonly SkillName m_Skill;
|
||||
private readonly double m_Requirement;
|
||||
private readonly TextDefinition m_Title;
|
||||
private readonly TextDefinition m_Label;
|
||||
private readonly TextDefinition m_Assigned;
|
||||
public MerchantTitleInfo(SkillName skill, double requirement, TextDefinition title, TextDefinition label, TextDefinition assigned)
|
||||
{
|
||||
this.m_Skill = skill;
|
||||
this.m_Requirement = requirement;
|
||||
this.m_Title = title;
|
||||
this.m_Label = label;
|
||||
this.m_Assigned = assigned;
|
||||
}
|
||||
|
||||
public SkillName Skill
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Skill;
|
||||
}
|
||||
}
|
||||
public double Requirement
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Requirement;
|
||||
}
|
||||
}
|
||||
public TextDefinition Title
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Title;
|
||||
}
|
||||
}
|
||||
public TextDefinition Label
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Label;
|
||||
}
|
||||
}
|
||||
public TextDefinition Assigned
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Assigned;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class MerchantTitles
|
||||
{
|
||||
private static readonly MerchantTitleInfo[] m_Info = new MerchantTitleInfo[]
|
||||
{
|
||||
new MerchantTitleInfo(SkillName.Inscribe, 90.0, new TextDefinition(1060773, "Scribe"), new TextDefinition(1011468, "SCRIBE"), new TextDefinition(1010121, "You now have the faction title of scribe")),
|
||||
new MerchantTitleInfo(SkillName.Carpentry, 90.0, new TextDefinition(1060774, "Carpenter"), new TextDefinition(1011469, "CARPENTER"), new TextDefinition(1010122, "You now have the faction title of carpenter")),
|
||||
new MerchantTitleInfo(SkillName.Tinkering, 90.0, new TextDefinition(1022984, "Tinker"), new TextDefinition(1011470, "TINKER"), new TextDefinition(1010123, "You now have the faction title of tinker")),
|
||||
new MerchantTitleInfo(SkillName.Blacksmith, 90.0, new TextDefinition(1023016, "Blacksmith"), new TextDefinition(1011471, "BLACKSMITH"), new TextDefinition(1010124, "You now have the faction title of blacksmith")),
|
||||
new MerchantTitleInfo(SkillName.Fletching, 90.0, new TextDefinition(1023022, "Bowyer"), new TextDefinition(1011472, "BOWYER"), new TextDefinition(1010125, "You now have the faction title of Bowyer")),
|
||||
new MerchantTitleInfo(SkillName.Tailoring, 90.0, new TextDefinition(1022982, "Tailor"), new TextDefinition(1018300, "TAILOR"), new TextDefinition(1042162, "You now have the faction title of Tailor")),
|
||||
};
|
||||
public static MerchantTitleInfo[] Info
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Info;
|
||||
}
|
||||
}
|
||||
public static MerchantTitleInfo GetInfo(MerchantTitle title)
|
||||
{
|
||||
int idx = (int)title - 1;
|
||||
|
||||
if (idx >= 0 && idx < m_Info.Length)
|
||||
return m_Info[idx];
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static bool HasMerchantQualifications(Mobile mob)
|
||||
{
|
||||
for (int i = 0; i < m_Info.Length; ++i)
|
||||
{
|
||||
if (IsQualified(mob, m_Info[i]))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool IsQualified(Mobile mob, MerchantTitle title)
|
||||
{
|
||||
return IsQualified(mob, GetInfo(title));
|
||||
}
|
||||
|
||||
public static bool IsQualified(Mobile mob, MerchantTitleInfo info)
|
||||
{
|
||||
if (mob == null || info == null)
|
||||
return false;
|
||||
|
||||
return (mob.Skills[info.Skill].Value >= info.Requirement);
|
||||
}
|
||||
}
|
||||
}
|
||||
112
Scripts/Services/Factions/Core/Persistence.cs
Normal file
112
Scripts/Services/Factions/Core/Persistence.cs
Normal file
@@ -0,0 +1,112 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
[TypeAlias("Server.Factions.FactionPersistance")]
|
||||
public class FactionPersistence : Item
|
||||
{
|
||||
private static FactionPersistence m_Instance;
|
||||
|
||||
public FactionPersistence()
|
||||
: base(1)
|
||||
{
|
||||
this.Movable = false;
|
||||
|
||||
if (m_Instance == null || m_Instance.Deleted)
|
||||
m_Instance = this;
|
||||
else
|
||||
base.Delete();
|
||||
}
|
||||
|
||||
public FactionPersistence(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
m_Instance = this;
|
||||
}
|
||||
|
||||
private enum PersistedType
|
||||
{
|
||||
Terminator,
|
||||
Faction,
|
||||
Town
|
||||
}
|
||||
public static FactionPersistence Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Instance;
|
||||
}
|
||||
}
|
||||
public override string DefaultName
|
||||
{
|
||||
get
|
||||
{
|
||||
return "Faction Persistance - Internal";
|
||||
}
|
||||
}
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
// Version 0 removes faction items, ie monoliths, stones, etc
|
||||
writer.Write((int)1); // version
|
||||
|
||||
List<Faction> factions = Faction.Factions;
|
||||
|
||||
for (int i = 0; i < factions.Count; ++i)
|
||||
{
|
||||
writer.WriteEncodedInt((int)PersistedType.Faction);
|
||||
factions[i].State.Serialize(writer);
|
||||
}
|
||||
|
||||
List<Town> towns = Town.Towns;
|
||||
|
||||
for (int i = 0; i < towns.Count; ++i)
|
||||
{
|
||||
writer.WriteEncodedInt((int)PersistedType.Town);
|
||||
towns[i].State.Serialize(writer);
|
||||
}
|
||||
|
||||
writer.WriteEncodedInt((int)PersistedType.Terminator);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 1:
|
||||
case 0:
|
||||
{
|
||||
PersistedType type;
|
||||
|
||||
while ((type = (PersistedType)reader.ReadEncodedInt()) != PersistedType.Terminator)
|
||||
{
|
||||
switch ( type )
|
||||
{
|
||||
case PersistedType.Faction:
|
||||
new FactionState(reader);
|
||||
break;
|
||||
case PersistedType.Town:
|
||||
new TownState(reader);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!Settings.Enabled && version == 0)
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(10), () => Generator.RemoveFactions());
|
||||
}
|
||||
|
||||
public override void Delete()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
374
Scripts/Services/Factions/Core/PlayerState.cs
Normal file
374
Scripts/Services/Factions/Core/PlayerState.cs
Normal file
@@ -0,0 +1,374 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class PlayerState : IComparable
|
||||
{
|
||||
private readonly Mobile m_Mobile;
|
||||
private readonly Faction m_Faction;
|
||||
private readonly List<PlayerState> m_Owner;
|
||||
private int m_KillPoints;
|
||||
private DateTime m_Leaving;
|
||||
private MerchantTitle m_MerchantTitle;
|
||||
private RankDefinition m_Rank;
|
||||
private List<SilverGivenEntry> m_SilverGiven;
|
||||
private bool m_IsActive;
|
||||
private Town m_Sheriff;
|
||||
private Town m_Finance;
|
||||
private DateTime m_LastHonorTime;
|
||||
private bool m_InvalidateRank = true;
|
||||
private int m_RankIndex = -1;
|
||||
|
||||
public PlayerState(Mobile mob, Faction faction, List<PlayerState> owner)
|
||||
{
|
||||
m_Mobile = mob;
|
||||
m_Faction = faction;
|
||||
m_Owner = owner;
|
||||
|
||||
Attach();
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
public PlayerState(GenericReader reader, Faction faction, List<PlayerState> owner)
|
||||
{
|
||||
m_Faction = faction;
|
||||
m_Owner = owner;
|
||||
|
||||
int version = reader.ReadEncodedInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
m_IsActive = reader.ReadBool();
|
||||
m_LastHonorTime = reader.ReadDateTime();
|
||||
goto case 0;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
m_Mobile = reader.ReadMobile();
|
||||
|
||||
m_KillPoints = reader.ReadEncodedInt();
|
||||
m_MerchantTitle = (MerchantTitle)reader.ReadEncodedInt();
|
||||
|
||||
m_Leaving = reader.ReadDateTime();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Attach();
|
||||
}
|
||||
|
||||
public Mobile Mobile
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Mobile;
|
||||
}
|
||||
}
|
||||
public Faction Faction
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Faction;
|
||||
}
|
||||
}
|
||||
public List<PlayerState> Owner
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Owner;
|
||||
}
|
||||
}
|
||||
public MerchantTitle MerchantTitle
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_MerchantTitle;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_MerchantTitle = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
public Town Sheriff
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Sheriff;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_Sheriff = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
public Town Finance
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Finance;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_Finance = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
public List<SilverGivenEntry> SilverGiven
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_SilverGiven;
|
||||
}
|
||||
}
|
||||
public int KillPoints
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_KillPoints;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (m_KillPoints != value)
|
||||
{
|
||||
if (value > m_KillPoints)
|
||||
{
|
||||
if (m_KillPoints <= 0)
|
||||
{
|
||||
if (value <= 0)
|
||||
{
|
||||
m_KillPoints = value;
|
||||
Invalidate();
|
||||
return;
|
||||
}
|
||||
|
||||
m_Owner.Remove(this);
|
||||
m_Owner.Insert(m_Faction.ZeroRankOffset, this);
|
||||
|
||||
m_RankIndex = m_Faction.ZeroRankOffset;
|
||||
m_Faction.ZeroRankOffset++;
|
||||
}
|
||||
while ((m_RankIndex - 1) >= 0)
|
||||
{
|
||||
PlayerState p = m_Owner[m_RankIndex - 1] as PlayerState;
|
||||
if (value > p.KillPoints)
|
||||
{
|
||||
m_Owner[m_RankIndex] = p;
|
||||
m_Owner[m_RankIndex - 1] = this;
|
||||
RankIndex--;
|
||||
p.RankIndex++;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (value <= 0)
|
||||
{
|
||||
if (m_KillPoints <= 0)
|
||||
{
|
||||
m_KillPoints = value;
|
||||
Invalidate();
|
||||
return;
|
||||
}
|
||||
|
||||
while ((m_RankIndex + 1) < m_Faction.ZeroRankOffset)
|
||||
{
|
||||
PlayerState p = m_Owner[m_RankIndex + 1] as PlayerState;
|
||||
m_Owner[m_RankIndex + 1] = this;
|
||||
m_Owner[m_RankIndex] = p;
|
||||
RankIndex++;
|
||||
p.RankIndex--;
|
||||
}
|
||||
|
||||
m_RankIndex = -1;
|
||||
m_Faction.ZeroRankOffset--;
|
||||
}
|
||||
else
|
||||
{
|
||||
while ((m_RankIndex + 1) < m_Faction.ZeroRankOffset)
|
||||
{
|
||||
PlayerState p = m_Owner[m_RankIndex + 1] as PlayerState;
|
||||
if (value < p.KillPoints)
|
||||
{
|
||||
m_Owner[m_RankIndex + 1] = this;
|
||||
m_Owner[m_RankIndex] = p;
|
||||
RankIndex++;
|
||||
p.RankIndex--;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_KillPoints = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
public int RankIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_RankIndex;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (m_RankIndex != value)
|
||||
{
|
||||
m_RankIndex = value;
|
||||
m_InvalidateRank = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
public RankDefinition Rank
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_InvalidateRank)
|
||||
{
|
||||
RankDefinition[] ranks = m_Faction.Definition.Ranks;
|
||||
int percent;
|
||||
|
||||
if (m_Owner.Count == 1)
|
||||
percent = 1000;
|
||||
else if (m_RankIndex == -1)
|
||||
percent = 0;
|
||||
else
|
||||
percent = ((m_Faction.ZeroRankOffset - m_RankIndex) * 1000) / m_Faction.ZeroRankOffset;
|
||||
|
||||
for (int i = 0; i < ranks.Length; i++)
|
||||
{
|
||||
RankDefinition check = ranks[i];
|
||||
|
||||
if (percent >= check.Required)
|
||||
{
|
||||
m_Rank = check;
|
||||
m_InvalidateRank = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
return m_Rank;
|
||||
}
|
||||
}
|
||||
public DateTime LastHonorTime
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_LastHonorTime;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_LastHonorTime = value;
|
||||
}
|
||||
}
|
||||
public DateTime Leaving
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Leaving;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_Leaving = value;
|
||||
}
|
||||
}
|
||||
public bool IsLeaving
|
||||
{
|
||||
get
|
||||
{
|
||||
return (m_Leaving > DateTime.MinValue);
|
||||
}
|
||||
}
|
||||
public bool IsActive
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_IsActive;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_IsActive = value;
|
||||
}
|
||||
}
|
||||
public static PlayerState Find(Mobile mob)
|
||||
{
|
||||
if (mob is PlayerMobile)
|
||||
return ((PlayerMobile)mob).FactionPlayerState;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool CanGiveSilverTo(Mobile mob)
|
||||
{
|
||||
if (m_SilverGiven == null)
|
||||
return true;
|
||||
|
||||
for (int i = 0; i < m_SilverGiven.Count; ++i)
|
||||
{
|
||||
SilverGivenEntry sge = m_SilverGiven[i];
|
||||
|
||||
if (sge.IsExpired)
|
||||
m_SilverGiven.RemoveAt(i--);
|
||||
else if (sge.GivenTo == mob)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void OnGivenSilverTo(Mobile mob)
|
||||
{
|
||||
if (m_SilverGiven == null)
|
||||
m_SilverGiven = new List<SilverGivenEntry>();
|
||||
|
||||
m_SilverGiven.Add(new SilverGivenEntry(mob));
|
||||
}
|
||||
|
||||
public void Invalidate()
|
||||
{
|
||||
if (m_Mobile is PlayerMobile)
|
||||
{
|
||||
PlayerMobile pm = (PlayerMobile)m_Mobile;
|
||||
pm.InvalidateProperties();
|
||||
}
|
||||
}
|
||||
|
||||
public void Attach()
|
||||
{
|
||||
if (Settings.Enabled && m_Mobile is PlayerMobile)
|
||||
((PlayerMobile)m_Mobile).FactionPlayerState = this;
|
||||
}
|
||||
|
||||
public void Serialize(GenericWriter writer)
|
||||
{
|
||||
writer.WriteEncodedInt((int)1); // version
|
||||
|
||||
writer.Write(m_IsActive);
|
||||
writer.Write(m_LastHonorTime);
|
||||
|
||||
writer.Write((Mobile)m_Mobile);
|
||||
|
||||
writer.WriteEncodedInt((int)m_KillPoints);
|
||||
writer.WriteEncodedInt((int)m_MerchantTitle);
|
||||
|
||||
writer.Write((DateTime)m_Leaving);
|
||||
}
|
||||
|
||||
public int CompareTo(object obj)
|
||||
{
|
||||
return ((PlayerState)obj).m_KillPoints - m_KillPoints;
|
||||
}
|
||||
}
|
||||
}
|
||||
78
Scripts/Services/Factions/Core/Reflector.cs
Normal file
78
Scripts/Services/Factions/Core/Reflector.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class Reflector
|
||||
{
|
||||
private static List<Town> m_Towns;
|
||||
private static List<Faction> m_Factions;
|
||||
public static List<Town> Towns
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_Towns == null)
|
||||
ProcessTypes();
|
||||
|
||||
return m_Towns;
|
||||
}
|
||||
}
|
||||
public static List<Faction> Factions
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_Factions == null)
|
||||
Reflector.ProcessTypes();
|
||||
|
||||
return m_Factions;
|
||||
}
|
||||
}
|
||||
private static object Construct(Type type)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Activator.CreateInstance(type);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static void ProcessTypes()
|
||||
{
|
||||
m_Factions = new List<Faction>();
|
||||
m_Towns = new List<Town>();
|
||||
|
||||
Assembly[] asms = ScriptCompiler.Assemblies;
|
||||
|
||||
for (int i = 0; i < asms.Length; ++i)
|
||||
{
|
||||
Assembly asm = asms[i];
|
||||
TypeCache tc = ScriptCompiler.GetTypeCache(asm);
|
||||
Type[] types = tc.Types;
|
||||
|
||||
for (int j = 0; j < types.Length; ++j)
|
||||
{
|
||||
Type type = types[j];
|
||||
|
||||
if (type.IsSubclassOf(typeof(Faction)))
|
||||
{
|
||||
Faction faction = Construct(type) as Faction;
|
||||
|
||||
if (faction != null)
|
||||
Faction.Factions.Add(faction);
|
||||
}
|
||||
else if (type.IsSubclassOf(typeof(Town)))
|
||||
{
|
||||
Town town = Construct(type) as Town;
|
||||
|
||||
if (town != null)
|
||||
Town.Towns.Add(town);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
38
Scripts/Services/Factions/Core/SilverGivenEntry.cs
Normal file
38
Scripts/Services/Factions/Core/SilverGivenEntry.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class SilverGivenEntry
|
||||
{
|
||||
public static readonly TimeSpan ExpirePeriod = TimeSpan.FromHours(3.0);
|
||||
private readonly Mobile m_GivenTo;
|
||||
private readonly DateTime m_TimeOfGift;
|
||||
public SilverGivenEntry(Mobile givenTo)
|
||||
{
|
||||
this.m_GivenTo = givenTo;
|
||||
this.m_TimeOfGift = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
public Mobile GivenTo
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_GivenTo;
|
||||
}
|
||||
}
|
||||
public DateTime TimeOfGift
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_TimeOfGift;
|
||||
}
|
||||
}
|
||||
public bool IsExpired
|
||||
{
|
||||
get
|
||||
{
|
||||
return (this.m_TimeOfGift + ExpirePeriod) < DateTime.UtcNow;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
45
Scripts/Services/Factions/Core/StrongholdRegion.cs
Normal file
45
Scripts/Services/Factions/Core/StrongholdRegion.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using Server.Mobiles;
|
||||
using Server.Regions;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class StrongholdRegion : BaseRegion
|
||||
{
|
||||
private Faction m_Faction;
|
||||
public StrongholdRegion(Faction faction)
|
||||
: base(faction.Definition.FriendlyName, Faction.Facet, Region.DefaultPriority, faction.Definition.Stronghold.Area)
|
||||
{
|
||||
this.m_Faction = faction;
|
||||
|
||||
this.Register();
|
||||
}
|
||||
|
||||
public Faction Faction
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Faction;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_Faction = value;
|
||||
}
|
||||
}
|
||||
public override bool OnMoveInto(Mobile m, Direction d, Point3D newLocation, Point3D oldLocation)
|
||||
{
|
||||
if (!base.OnMoveInto(m, d, newLocation, oldLocation))
|
||||
return false;
|
||||
|
||||
if (m.IsStaff() || this.Contains(oldLocation))
|
||||
return true;
|
||||
|
||||
return (Faction.Find(m, true, true) != null);
|
||||
}
|
||||
|
||||
public override bool AllowHousing(Mobile from, Point3D p)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
611
Scripts/Services/Factions/Core/Town.cs
Normal file
611
Scripts/Services/Factions/Core/Town.cs
Normal file
@@ -0,0 +1,611 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Server.Commands;
|
||||
using Server.Targeting;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
[CustomEnum(new string[] { "Britain", "Magincia", "Minoc", "Moonglow", "Skara Brae", "Trinsic", "Vesper", "Yew" })]
|
||||
public abstract class Town : IComparable
|
||||
{
|
||||
public static readonly TimeSpan TaxChangePeriod = TimeSpan.FromHours(12.0);
|
||||
public static readonly TimeSpan IncomePeriod = TimeSpan.FromDays(1.0);
|
||||
public const int SilverCaptureBonus = 10000;
|
||||
private TownDefinition m_Definition;
|
||||
private TownState m_State;
|
||||
private Timer m_IncomeTimer;
|
||||
private List<VendorList> m_VendorLists;
|
||||
private List<GuardList> m_GuardLists;
|
||||
public Town()
|
||||
{
|
||||
this.m_State = new TownState(this);
|
||||
this.ConstructVendorLists();
|
||||
this.ConstructGuardLists();
|
||||
this.StartIncomeTimer();
|
||||
}
|
||||
|
||||
public static List<Town> Towns
|
||||
{
|
||||
get
|
||||
{
|
||||
return Reflector.Towns;
|
||||
}
|
||||
}
|
||||
public TownDefinition Definition
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Definition;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_Definition = value;
|
||||
}
|
||||
}
|
||||
public TownState State
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_State;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_State = value;
|
||||
this.ConstructGuardLists();
|
||||
}
|
||||
}
|
||||
public int Silver
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_State.Silver;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_State.Silver = value;
|
||||
}
|
||||
}
|
||||
public Faction Owner
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_State.Owner;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.Capture(value);
|
||||
}
|
||||
}
|
||||
public Mobile Sheriff
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_State.Sheriff;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_State.Sheriff = value;
|
||||
}
|
||||
}
|
||||
public Mobile Finance
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_State.Finance;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_State.Finance = value;
|
||||
}
|
||||
}
|
||||
public int Tax
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_State.Tax;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_State.Tax = value;
|
||||
}
|
||||
}
|
||||
public DateTime LastTaxChange
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_State.LastTaxChange;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_State.LastTaxChange = value;
|
||||
}
|
||||
}
|
||||
public bool TaxChangeReady
|
||||
{
|
||||
get
|
||||
{
|
||||
return (this.m_State.LastTaxChange + TaxChangePeriod) < DateTime.UtcNow;
|
||||
}
|
||||
}
|
||||
public int FinanceUpkeep
|
||||
{
|
||||
get
|
||||
{
|
||||
List<VendorList> vendorLists = this.VendorLists;
|
||||
int upkeep = 0;
|
||||
|
||||
for (int i = 0; i < vendorLists.Count; ++i)
|
||||
upkeep += vendorLists[i].Vendors.Count * vendorLists[i].Definition.Upkeep;
|
||||
|
||||
return upkeep;
|
||||
}
|
||||
}
|
||||
public int SheriffUpkeep
|
||||
{
|
||||
get
|
||||
{
|
||||
List<GuardList> guardLists = this.GuardLists;
|
||||
int upkeep = 0;
|
||||
|
||||
for (int i = 0; i < guardLists.Count; ++i)
|
||||
upkeep += guardLists[i].Guards.Count * guardLists[i].Definition.Upkeep;
|
||||
|
||||
return upkeep;
|
||||
}
|
||||
}
|
||||
public int DailyIncome
|
||||
{
|
||||
get
|
||||
{
|
||||
return (10000 * (100 + this.m_State.Tax)) / 100;
|
||||
}
|
||||
}
|
||||
public int NetCashFlow
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.DailyIncome - this.FinanceUpkeep - this.SheriffUpkeep;
|
||||
}
|
||||
}
|
||||
public TownMonolith Monolith
|
||||
{
|
||||
get
|
||||
{
|
||||
List<BaseMonolith> monoliths = BaseMonolith.Monoliths;
|
||||
|
||||
foreach (BaseMonolith monolith in monoliths)
|
||||
{
|
||||
if (monolith is TownMonolith)
|
||||
{
|
||||
TownMonolith townMonolith = (TownMonolith)monolith;
|
||||
|
||||
if (townMonolith.Town == this)
|
||||
return townMonolith;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public DateTime LastIncome
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_State.LastIncome;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_State.LastIncome = value;
|
||||
}
|
||||
}
|
||||
public List<VendorList> VendorLists
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_VendorLists;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_VendorLists = value;
|
||||
}
|
||||
}
|
||||
public List<GuardList> GuardLists
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_GuardLists;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_GuardLists = value;
|
||||
}
|
||||
}
|
||||
public static Town FromRegion(Region reg)
|
||||
{
|
||||
if (reg.Map != Faction.Facet)
|
||||
return null;
|
||||
|
||||
List<Town> towns = Towns;
|
||||
|
||||
for (int i = 0; i < towns.Count; ++i)
|
||||
{
|
||||
Town town = towns[i];
|
||||
|
||||
if (reg.IsPartOf(town.Definition.Region))
|
||||
return town;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
List<Town> towns = Towns;
|
||||
|
||||
for (int i = 0; i < towns.Count; ++i)
|
||||
{
|
||||
towns[i].Sheriff = towns[i].Sheriff;
|
||||
towns[i].Finance = towns[i].Finance;
|
||||
}
|
||||
|
||||
CommandSystem.Register("GrantTownSilver", AccessLevel.Administrator, new CommandEventHandler(GrantTownSilver_OnCommand));
|
||||
}
|
||||
|
||||
public static void WriteReference(GenericWriter writer, Town town)
|
||||
{
|
||||
int idx = Towns.IndexOf(town);
|
||||
|
||||
writer.WriteEncodedInt((int)(idx + 1));
|
||||
}
|
||||
|
||||
public static Town ReadReference(GenericReader reader)
|
||||
{
|
||||
int idx = reader.ReadEncodedInt() - 1;
|
||||
|
||||
if (idx >= 0 && idx < Towns.Count)
|
||||
return Towns[idx];
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Town Parse(string name)
|
||||
{
|
||||
List<Town> towns = Towns;
|
||||
|
||||
for (int i = 0; i < towns.Count; ++i)
|
||||
{
|
||||
Town town = towns[i];
|
||||
|
||||
if (Insensitive.Equals(town.Definition.FriendlyName, name))
|
||||
return town;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void GrantTownSilver_OnCommand(CommandEventArgs e)
|
||||
{
|
||||
Town town = FromRegion(e.Mobile.Region);
|
||||
|
||||
if (town == null)
|
||||
e.Mobile.SendMessage("You are not in a faction town.");
|
||||
else if (e.Length == 0)
|
||||
e.Mobile.SendMessage("Format: GrantTownSilver <amount>");
|
||||
else
|
||||
{
|
||||
town.Silver += e.GetInt32(0);
|
||||
e.Mobile.SendMessage("You have granted {0:N0} silver to the town. It now has {1:N0} silver.", e.GetInt32(0), town.Silver);
|
||||
}
|
||||
}
|
||||
|
||||
public void BeginOrderFiring(Mobile from)
|
||||
{
|
||||
bool isFinance = this.IsFinance(from);
|
||||
bool isSheriff = this.IsSheriff(from);
|
||||
string type = null;
|
||||
|
||||
// NOTE: Messages not OSI-accurate, intentional
|
||||
if (isFinance && isSheriff) // GM only
|
||||
type = "vendor or guard";
|
||||
else if (isFinance)
|
||||
type = "vendor";
|
||||
else if (isSheriff)
|
||||
type = "guard";
|
||||
|
||||
from.SendMessage("Target the {0} you wish to dismiss.", type);
|
||||
from.BeginTarget(12, false, TargetFlags.None, new TargetCallback(EndOrderFiring));
|
||||
}
|
||||
|
||||
public void EndOrderFiring(Mobile from, object obj)
|
||||
{
|
||||
bool isFinance = this.IsFinance(from);
|
||||
bool isSheriff = this.IsSheriff(from);
|
||||
string type = null;
|
||||
|
||||
if (isFinance && isSheriff) // GM only
|
||||
type = "vendor or guard";
|
||||
else if (isFinance)
|
||||
type = "vendor";
|
||||
else if (isSheriff)
|
||||
type = "guard";
|
||||
|
||||
if (obj is BaseFactionVendor)
|
||||
{
|
||||
BaseFactionVendor vendor = (BaseFactionVendor)obj;
|
||||
|
||||
if (vendor.Town == this && isFinance)
|
||||
vendor.Delete();
|
||||
}
|
||||
else if (obj is BaseFactionGuard)
|
||||
{
|
||||
BaseFactionGuard guard = (BaseFactionGuard)obj;
|
||||
|
||||
if (guard.Town == this && isSheriff)
|
||||
guard.Delete();
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendMessage("That is not a {0}!", type);
|
||||
}
|
||||
}
|
||||
|
||||
public void StartIncomeTimer()
|
||||
{
|
||||
if (this.m_IncomeTimer != null)
|
||||
this.m_IncomeTimer.Stop();
|
||||
|
||||
this.m_IncomeTimer = Timer.DelayCall(TimeSpan.FromMinutes(1.0), TimeSpan.FromMinutes(1.0), new TimerCallback(CheckIncome));
|
||||
}
|
||||
|
||||
public void StopIncomeTimer()
|
||||
{
|
||||
if (this.m_IncomeTimer != null)
|
||||
this.m_IncomeTimer.Stop();
|
||||
|
||||
this.m_IncomeTimer = null;
|
||||
}
|
||||
|
||||
public void CheckIncome()
|
||||
{
|
||||
if ((this.LastIncome + IncomePeriod) > DateTime.UtcNow || this.Owner == null)
|
||||
return;
|
||||
|
||||
this.ProcessIncome();
|
||||
}
|
||||
|
||||
public void ProcessIncome()
|
||||
{
|
||||
this.LastIncome = DateTime.UtcNow;
|
||||
|
||||
int flow = this.NetCashFlow;
|
||||
|
||||
if ((this.Silver + flow) < 0)
|
||||
{
|
||||
ArrayList toDelete = this.BuildFinanceList();
|
||||
|
||||
while ((this.Silver + flow) < 0 && toDelete.Count > 0)
|
||||
{
|
||||
int index = Utility.Random(toDelete.Count);
|
||||
Mobile mob = (Mobile)toDelete[index];
|
||||
|
||||
mob.Delete();
|
||||
|
||||
toDelete.RemoveAt(index);
|
||||
flow = this.NetCashFlow;
|
||||
}
|
||||
}
|
||||
|
||||
this.Silver += flow;
|
||||
}
|
||||
|
||||
public ArrayList BuildFinanceList()
|
||||
{
|
||||
ArrayList list = new ArrayList();
|
||||
|
||||
List<VendorList> vendorLists = this.VendorLists;
|
||||
|
||||
for (int i = 0; i < vendorLists.Count; ++i)
|
||||
list.AddRange(vendorLists[i].Vendors);
|
||||
|
||||
List<GuardList> guardLists = this.GuardLists;
|
||||
|
||||
for (int i = 0; i < guardLists.Count; ++i)
|
||||
list.AddRange(guardLists[i].Guards);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public void ConstructGuardLists()
|
||||
{
|
||||
GuardDefinition[] defs = (this.Owner == null ? new GuardDefinition[0] : this.Owner.Definition.Guards);
|
||||
|
||||
this.m_GuardLists = new List<GuardList>();
|
||||
|
||||
for (int i = 0; i < defs.Length; ++i)
|
||||
this.m_GuardLists.Add(new GuardList(defs[i]));
|
||||
}
|
||||
|
||||
public GuardList FindGuardList(Type type)
|
||||
{
|
||||
List<GuardList> guardLists = this.GuardLists;
|
||||
|
||||
for (int i = 0; i < guardLists.Count; ++i)
|
||||
{
|
||||
GuardList guardList = guardLists[i];
|
||||
|
||||
if (guardList.Definition.Type == type)
|
||||
return guardList;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void ConstructVendorLists()
|
||||
{
|
||||
VendorDefinition[] defs = VendorDefinition.Definitions;
|
||||
|
||||
this.m_VendorLists = new List<VendorList>();
|
||||
|
||||
for (int i = 0; i < defs.Length; ++i)
|
||||
this.m_VendorLists.Add(new VendorList(defs[i]));
|
||||
}
|
||||
|
||||
public VendorList FindVendorList(Type type)
|
||||
{
|
||||
List<VendorList> vendorLists = this.VendorLists;
|
||||
|
||||
for (int i = 0; i < vendorLists.Count; ++i)
|
||||
{
|
||||
VendorList vendorList = vendorLists[i];
|
||||
|
||||
if (vendorList.Definition.Type == type)
|
||||
return vendorList;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool RegisterGuard(BaseFactionGuard guard)
|
||||
{
|
||||
if (guard == null)
|
||||
return false;
|
||||
|
||||
GuardList guardList = this.FindGuardList(guard.GetType());
|
||||
|
||||
if (guardList == null)
|
||||
return false;
|
||||
|
||||
guardList.Guards.Add(guard);
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool UnregisterGuard(BaseFactionGuard guard)
|
||||
{
|
||||
if (guard == null)
|
||||
return false;
|
||||
|
||||
GuardList guardList = this.FindGuardList(guard.GetType());
|
||||
|
||||
if (guardList == null)
|
||||
return false;
|
||||
|
||||
if (!guardList.Guards.Contains(guard))
|
||||
return false;
|
||||
|
||||
guardList.Guards.Remove(guard);
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool RegisterVendor(BaseFactionVendor vendor)
|
||||
{
|
||||
if (vendor == null)
|
||||
return false;
|
||||
|
||||
VendorList vendorList = this.FindVendorList(vendor.GetType());
|
||||
|
||||
if (vendorList == null)
|
||||
return false;
|
||||
|
||||
vendorList.Vendors.Add(vendor);
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool UnregisterVendor(BaseFactionVendor vendor)
|
||||
{
|
||||
if (vendor == null)
|
||||
return false;
|
||||
|
||||
VendorList vendorList = this.FindVendorList(vendor.GetType());
|
||||
|
||||
if (vendorList == null)
|
||||
return false;
|
||||
|
||||
if (!vendorList.Vendors.Contains(vendor))
|
||||
return false;
|
||||
|
||||
vendorList.Vendors.Remove(vendor);
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool IsSheriff(Mobile mob)
|
||||
{
|
||||
if (mob == null || mob.Deleted)
|
||||
return false;
|
||||
|
||||
return (mob.AccessLevel >= AccessLevel.GameMaster || mob == this.Sheriff);
|
||||
}
|
||||
|
||||
public bool IsFinance(Mobile mob)
|
||||
{
|
||||
if (mob == null || mob.Deleted)
|
||||
return false;
|
||||
|
||||
return (mob.AccessLevel >= AccessLevel.GameMaster || mob == this.Finance);
|
||||
}
|
||||
|
||||
public void Capture(Faction f)
|
||||
{
|
||||
if (this.m_State.Owner == f)
|
||||
return;
|
||||
|
||||
if (this.m_State.Owner == null) // going from unowned to owned
|
||||
{
|
||||
this.LastIncome = DateTime.UtcNow;
|
||||
f.Silver += SilverCaptureBonus;
|
||||
}
|
||||
else if (f == null) // going from owned to unowned
|
||||
{
|
||||
this.LastIncome = DateTime.MinValue;
|
||||
}
|
||||
else // otherwise changing hands, income timer doesn't change
|
||||
{
|
||||
f.Silver += SilverCaptureBonus;
|
||||
}
|
||||
|
||||
this.m_State.Owner = f;
|
||||
|
||||
this.Sheriff = null;
|
||||
this.Finance = null;
|
||||
|
||||
TownMonolith monolith = this.Monolith;
|
||||
|
||||
if (monolith != null)
|
||||
monolith.Faction = f;
|
||||
|
||||
List<VendorList> vendorLists = this.VendorLists;
|
||||
|
||||
for (int i = 0; i < vendorLists.Count; ++i)
|
||||
{
|
||||
VendorList vendorList = vendorLists[i];
|
||||
List<BaseFactionVendor> vendors = vendorList.Vendors;
|
||||
|
||||
for (int j = vendors.Count - 1; j >= 0; --j)
|
||||
vendors[j].Delete();
|
||||
}
|
||||
|
||||
List<GuardList> guardLists = this.GuardLists;
|
||||
|
||||
for (int i = 0; i < guardLists.Count; ++i)
|
||||
{
|
||||
GuardList guardList = guardLists[i];
|
||||
List<BaseFactionGuard> guards = guardList.Guards;
|
||||
|
||||
for (int j = guards.Count - 1; j >= 0; --j)
|
||||
guards[j].Delete();
|
||||
}
|
||||
|
||||
this.ConstructGuardLists();
|
||||
}
|
||||
|
||||
public int CompareTo(object obj)
|
||||
{
|
||||
return this.m_Definition.Sort - ((Town)obj).m_Definition.Sort;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return this.m_Definition.FriendlyName;
|
||||
}
|
||||
}
|
||||
}
|
||||
198
Scripts/Services/Factions/Core/TownState.cs
Normal file
198
Scripts/Services/Factions/Core/TownState.cs
Normal file
@@ -0,0 +1,198 @@
|
||||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class TownState
|
||||
{
|
||||
private Town m_Town;
|
||||
private Faction m_Owner;
|
||||
private Mobile m_Sheriff;
|
||||
private Mobile m_Finance;
|
||||
private int m_Silver;
|
||||
private int m_Tax;
|
||||
private DateTime m_LastTaxChange;
|
||||
private DateTime m_LastIncome;
|
||||
public TownState(Town town)
|
||||
{
|
||||
this.m_Town = town;
|
||||
}
|
||||
|
||||
public TownState(GenericReader reader)
|
||||
{
|
||||
int version = reader.ReadEncodedInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 3:
|
||||
{
|
||||
this.m_LastIncome = reader.ReadDateTime();
|
||||
|
||||
goto case 2;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
this.m_Tax = reader.ReadEncodedInt();
|
||||
this.m_LastTaxChange = reader.ReadDateTime();
|
||||
|
||||
goto case 1;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
this.m_Silver = reader.ReadEncodedInt();
|
||||
|
||||
goto case 0;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
this.m_Town = Town.ReadReference(reader);
|
||||
this.m_Owner = Faction.ReadReference(reader);
|
||||
|
||||
this.m_Sheriff = reader.ReadMobile();
|
||||
this.m_Finance = reader.ReadMobile();
|
||||
|
||||
this.m_Town.State = this;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Town Town
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Town;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_Town = value;
|
||||
}
|
||||
}
|
||||
public Faction Owner
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Owner;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_Owner = value;
|
||||
}
|
||||
}
|
||||
public Mobile Sheriff
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Sheriff;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (this.m_Sheriff != null)
|
||||
{
|
||||
PlayerState pl = PlayerState.Find(this.m_Sheriff);
|
||||
|
||||
if (pl != null)
|
||||
pl.Sheriff = null;
|
||||
}
|
||||
|
||||
this.m_Sheriff = value;
|
||||
|
||||
if (this.m_Sheriff != null)
|
||||
{
|
||||
PlayerState pl = PlayerState.Find(this.m_Sheriff);
|
||||
|
||||
if (pl != null)
|
||||
pl.Sheriff = this.m_Town;
|
||||
}
|
||||
}
|
||||
}
|
||||
public Mobile Finance
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Finance;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (this.m_Finance != null)
|
||||
{
|
||||
PlayerState pl = PlayerState.Find(this.m_Finance);
|
||||
|
||||
if (pl != null)
|
||||
pl.Finance = null;
|
||||
}
|
||||
|
||||
this.m_Finance = value;
|
||||
|
||||
if (this.m_Finance != null)
|
||||
{
|
||||
PlayerState pl = PlayerState.Find(this.m_Finance);
|
||||
|
||||
if (pl != null)
|
||||
pl.Finance = this.m_Town;
|
||||
}
|
||||
}
|
||||
}
|
||||
public int Silver
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Silver;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_Silver = value;
|
||||
}
|
||||
}
|
||||
public int Tax
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Tax;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_Tax = value;
|
||||
}
|
||||
}
|
||||
public DateTime LastTaxChange
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_LastTaxChange;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_LastTaxChange = value;
|
||||
}
|
||||
}
|
||||
public DateTime LastIncome
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_LastIncome;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_LastIncome = value;
|
||||
}
|
||||
}
|
||||
public void Serialize(GenericWriter writer)
|
||||
{
|
||||
writer.WriteEncodedInt((int)3); // version
|
||||
|
||||
writer.Write((DateTime)this.m_LastIncome);
|
||||
|
||||
writer.WriteEncodedInt((int)this.m_Tax);
|
||||
writer.Write((DateTime)this.m_LastTaxChange);
|
||||
|
||||
writer.WriteEncodedInt((int)this.m_Silver);
|
||||
|
||||
Town.WriteReference(writer, this.m_Town);
|
||||
Faction.WriteReference(writer, this.m_Owner);
|
||||
|
||||
writer.Write((Mobile)this.m_Sheriff);
|
||||
writer.Write((Mobile)this.m_Finance);
|
||||
}
|
||||
}
|
||||
}
|
||||
42
Scripts/Services/Factions/Core/VendorList.cs
Normal file
42
Scripts/Services/Factions/Core/VendorList.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class VendorList
|
||||
{
|
||||
private readonly VendorDefinition m_Definition;
|
||||
private readonly List<BaseFactionVendor> m_Vendors;
|
||||
public VendorList(VendorDefinition definition)
|
||||
{
|
||||
this.m_Definition = definition;
|
||||
this.m_Vendors = new List<BaseFactionVendor>();
|
||||
}
|
||||
|
||||
public VendorDefinition Definition
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Definition;
|
||||
}
|
||||
}
|
||||
public List<BaseFactionVendor> Vendors
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Vendors;
|
||||
}
|
||||
}
|
||||
public BaseFactionVendor Construct(Town town, Faction faction)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Activator.CreateInstance(this.m_Definition.Type, new object[] { town, faction }) as BaseFactionVendor;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
238
Scripts/Services/Factions/Definitions/FactionDefinition.cs
Normal file
238
Scripts/Services/Factions/Definitions/FactionDefinition.cs
Normal file
@@ -0,0 +1,238 @@
|
||||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionDefinition
|
||||
{
|
||||
private readonly int m_Sort;
|
||||
private readonly int m_HuePrimary;
|
||||
private readonly int m_HueSecondary;
|
||||
private readonly int m_HueJoin;
|
||||
private readonly int m_HueBroadcast;
|
||||
private readonly int m_WarHorseBody;
|
||||
private readonly int m_WarHorseItem;
|
||||
private readonly string m_FriendlyName;
|
||||
private readonly string m_Keyword;
|
||||
private readonly string m_Abbreviation;
|
||||
private readonly TextDefinition m_Name;
|
||||
private readonly TextDefinition m_PropName;
|
||||
private readonly TextDefinition m_Header;
|
||||
private readonly TextDefinition m_About;
|
||||
private readonly TextDefinition m_CityControl;
|
||||
private readonly TextDefinition m_SigilControl;
|
||||
private readonly TextDefinition m_SignupName;
|
||||
private readonly TextDefinition m_FactionStoneName;
|
||||
private readonly TextDefinition m_OwnerLabel;
|
||||
private readonly TextDefinition m_GuardIgnore;
|
||||
private readonly TextDefinition m_GuardWarn;
|
||||
private readonly TextDefinition m_GuardAttack;
|
||||
private readonly StrongholdDefinition m_Stronghold;
|
||||
private readonly RankDefinition[] m_Ranks;
|
||||
private readonly GuardDefinition[] m_Guards;
|
||||
|
||||
public FactionDefinition(int sort, int huePrimary, int hueSecondary, int hueJoin, int hueBroadcast, int warHorseBody, int warHorseItem, string friendlyName, string keyword, string abbreviation, TextDefinition name, TextDefinition propName, TextDefinition header, TextDefinition about, TextDefinition cityControl, TextDefinition sigilControl, TextDefinition signupName, TextDefinition factionStoneName, TextDefinition ownerLabel, TextDefinition guardIgnore, TextDefinition guardWarn, TextDefinition guardAttack, StrongholdDefinition stronghold, RankDefinition[] ranks, GuardDefinition[] guards)
|
||||
{
|
||||
m_Sort = sort;
|
||||
m_HuePrimary = huePrimary;
|
||||
m_HueSecondary = hueSecondary;
|
||||
m_HueJoin = hueJoin;
|
||||
m_HueBroadcast = hueBroadcast;
|
||||
m_WarHorseBody = warHorseBody;
|
||||
m_WarHorseItem = warHorseItem;
|
||||
m_FriendlyName = friendlyName;
|
||||
m_Keyword = keyword;
|
||||
m_Abbreviation = abbreviation;
|
||||
m_Name = name;
|
||||
m_PropName = propName;
|
||||
m_Header = header;
|
||||
m_About = about;
|
||||
m_CityControl = cityControl;
|
||||
m_SigilControl = sigilControl;
|
||||
m_SignupName = signupName;
|
||||
m_FactionStoneName = factionStoneName;
|
||||
m_OwnerLabel = ownerLabel;
|
||||
m_GuardIgnore = guardIgnore;
|
||||
m_GuardWarn = guardWarn;
|
||||
m_GuardAttack = guardAttack;
|
||||
m_Stronghold = stronghold;
|
||||
m_Ranks = ranks;
|
||||
m_Guards = guards;
|
||||
}
|
||||
|
||||
public int Sort
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Sort;
|
||||
}
|
||||
}
|
||||
public int HuePrimary
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_HuePrimary;
|
||||
}
|
||||
}
|
||||
public int HueSecondary
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_HueSecondary;
|
||||
}
|
||||
}
|
||||
public int HueJoin
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_HueJoin;
|
||||
}
|
||||
}
|
||||
public int HueBroadcast
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_HueBroadcast;
|
||||
}
|
||||
}
|
||||
public int WarHorseBody
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_WarHorseBody;
|
||||
}
|
||||
}
|
||||
public int WarHorseItem
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_WarHorseItem;
|
||||
}
|
||||
}
|
||||
public string FriendlyName
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_FriendlyName;
|
||||
}
|
||||
}
|
||||
public string Keyword
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Keyword;
|
||||
}
|
||||
}
|
||||
public string Abbreviation
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Abbreviation;
|
||||
}
|
||||
}
|
||||
public TextDefinition Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Name;
|
||||
}
|
||||
}
|
||||
public TextDefinition PropName
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_PropName;
|
||||
}
|
||||
}
|
||||
public TextDefinition Header
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Header;
|
||||
}
|
||||
}
|
||||
public TextDefinition About
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_About;
|
||||
}
|
||||
}
|
||||
public TextDefinition CityControl
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_CityControl;
|
||||
}
|
||||
}
|
||||
public TextDefinition SigilControl
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_SigilControl;
|
||||
}
|
||||
}
|
||||
public TextDefinition SignupName
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_SignupName;
|
||||
}
|
||||
}
|
||||
public TextDefinition FactionStoneName
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_FactionStoneName;
|
||||
}
|
||||
}
|
||||
public TextDefinition OwnerLabel
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_OwnerLabel;
|
||||
}
|
||||
}
|
||||
public TextDefinition GuardIgnore
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_GuardIgnore;
|
||||
}
|
||||
}
|
||||
public TextDefinition GuardWarn
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_GuardWarn;
|
||||
}
|
||||
}
|
||||
public TextDefinition GuardAttack
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_GuardAttack;
|
||||
}
|
||||
}
|
||||
public StrongholdDefinition Stronghold
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Stronghold;
|
||||
}
|
||||
}
|
||||
public RankDefinition[] Ranks
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Ranks;
|
||||
}
|
||||
}
|
||||
public GuardDefinition[] Guards
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Guards;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionItemDefinition
|
||||
{
|
||||
private static readonly FactionItemDefinition m_MetalArmor = new FactionItemDefinition(1000, typeof(Blacksmith));
|
||||
private static readonly FactionItemDefinition m_Weapon = new FactionItemDefinition(1000, typeof(Blacksmith));
|
||||
private static readonly FactionItemDefinition m_RangedWeapon = new FactionItemDefinition(1000, typeof(Bowyer));
|
||||
private static readonly FactionItemDefinition m_LeatherArmor = new FactionItemDefinition(750, typeof(Tailor));
|
||||
private static readonly FactionItemDefinition m_Clothing = new FactionItemDefinition(200, typeof(Tailor));
|
||||
private static readonly FactionItemDefinition m_Scroll = new FactionItemDefinition(500, typeof(Mage));
|
||||
private readonly int m_SilverCost;
|
||||
private readonly Type m_VendorType;
|
||||
public FactionItemDefinition(int silverCost, Type vendorType)
|
||||
{
|
||||
this.m_SilverCost = silverCost;
|
||||
this.m_VendorType = vendorType;
|
||||
}
|
||||
|
||||
public int SilverCost
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_SilverCost;
|
||||
}
|
||||
}
|
||||
public Type VendorType
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_VendorType;
|
||||
}
|
||||
}
|
||||
public static FactionItemDefinition Identify(Item item)
|
||||
{
|
||||
if (item is BaseArmor)
|
||||
{
|
||||
if (CraftResources.GetType(((BaseArmor)item).Resource) == CraftResourceType.Leather)
|
||||
return m_LeatherArmor;
|
||||
|
||||
return m_MetalArmor;
|
||||
}
|
||||
|
||||
if (item is BaseRanged)
|
||||
return m_RangedWeapon;
|
||||
else if (item is BaseWeapon)
|
||||
return m_Weapon;
|
||||
else if (item is BaseClothing)
|
||||
return m_Clothing;
|
||||
else if (item is SpellScroll)
|
||||
return m_Scroll;
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
77
Scripts/Services/Factions/Definitions/GuardDefinition.cs
Normal file
77
Scripts/Services/Factions/Definitions/GuardDefinition.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class GuardDefinition
|
||||
{
|
||||
private readonly Type m_Type;
|
||||
private readonly int m_Price;
|
||||
private readonly int m_Upkeep;
|
||||
private readonly int m_Maximum;
|
||||
private readonly int m_ItemID;
|
||||
private readonly TextDefinition m_Header;
|
||||
private readonly TextDefinition m_Label;
|
||||
public GuardDefinition(Type type, int itemID, int price, int upkeep, int maximum, TextDefinition header, TextDefinition label)
|
||||
{
|
||||
this.m_Type = type;
|
||||
|
||||
this.m_Price = price;
|
||||
this.m_Upkeep = upkeep;
|
||||
this.m_Maximum = maximum;
|
||||
this.m_ItemID = itemID;
|
||||
|
||||
this.m_Header = header;
|
||||
this.m_Label = label;
|
||||
}
|
||||
|
||||
public Type Type
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Type;
|
||||
}
|
||||
}
|
||||
public int Price
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Price;
|
||||
}
|
||||
}
|
||||
public int Upkeep
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Upkeep;
|
||||
}
|
||||
}
|
||||
public int Maximum
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Maximum;
|
||||
}
|
||||
}
|
||||
public int ItemID
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_ItemID;
|
||||
}
|
||||
}
|
||||
public TextDefinition Header
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Header;
|
||||
}
|
||||
}
|
||||
public TextDefinition Label
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Label;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
49
Scripts/Services/Factions/Definitions/RankDefinition.cs
Normal file
49
Scripts/Services/Factions/Definitions/RankDefinition.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class RankDefinition
|
||||
{
|
||||
private readonly int m_Rank;
|
||||
private readonly int m_Required;
|
||||
private readonly int m_MaxWearables;
|
||||
private readonly TextDefinition m_Title;
|
||||
|
||||
public RankDefinition(int rank, int required, int maxWearables, TextDefinition title)
|
||||
{
|
||||
m_Rank = rank;
|
||||
m_Required = required;
|
||||
m_Title = title;
|
||||
m_MaxWearables = maxWearables;
|
||||
}
|
||||
|
||||
public int Rank
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Rank;
|
||||
}
|
||||
}
|
||||
public int Required
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Required;
|
||||
}
|
||||
}
|
||||
public int MaxWearables
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_MaxWearables;
|
||||
}
|
||||
}
|
||||
public TextDefinition Title
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Title;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
59
Scripts/Services/Factions/Definitions/StrongholdDefintion.cs
Normal file
59
Scripts/Services/Factions/Definitions/StrongholdDefintion.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class StrongholdDefinition
|
||||
{
|
||||
private readonly Rectangle2D[] m_Area;
|
||||
private readonly Point3D m_JoinStone;
|
||||
private readonly Point3D m_FactionStone;
|
||||
private readonly Point3D[] m_Monoliths;
|
||||
private readonly Point3D m_CollectionBox;
|
||||
|
||||
public StrongholdDefinition(Rectangle2D[] area, Point3D joinStone, Point3D factionStone, Point3D[] monoliths, Point3D collectionBox)
|
||||
{
|
||||
m_Area = area;
|
||||
m_JoinStone = joinStone;
|
||||
m_FactionStone = factionStone;
|
||||
m_Monoliths = monoliths;
|
||||
m_CollectionBox = collectionBox;
|
||||
}
|
||||
|
||||
public Rectangle2D[] Area
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Area;
|
||||
}
|
||||
}
|
||||
public Point3D JoinStone
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_JoinStone;
|
||||
}
|
||||
}
|
||||
public Point3D FactionStone
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_FactionStone;
|
||||
}
|
||||
}
|
||||
public Point3D[] Monoliths
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Monoliths;
|
||||
}
|
||||
}
|
||||
|
||||
public Point3D CollectionBox
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_CollectionBox;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
129
Scripts/Services/Factions/Definitions/TownDefinition.cs
Normal file
129
Scripts/Services/Factions/Definitions/TownDefinition.cs
Normal file
@@ -0,0 +1,129 @@
|
||||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class TownDefinition
|
||||
{
|
||||
private readonly int m_Sort;
|
||||
private readonly int m_SigilID;
|
||||
private readonly string m_Region;
|
||||
private readonly string m_FriendlyName;
|
||||
private readonly TextDefinition m_TownName;
|
||||
private readonly TextDefinition m_TownStoneHeader;
|
||||
private readonly TextDefinition m_StrongholdMonolithName;
|
||||
private readonly TextDefinition m_TownMonolithName;
|
||||
private readonly TextDefinition m_TownStoneName;
|
||||
private readonly TextDefinition m_SigilName;
|
||||
private readonly TextDefinition m_CorruptedSigilName;
|
||||
private readonly Point3D m_Monolith;
|
||||
private readonly Point3D m_TownStone;
|
||||
public TownDefinition(int sort, int sigilID, string region, string friendlyName, TextDefinition townName, TextDefinition townStoneHeader, TextDefinition strongholdMonolithName, TextDefinition townMonolithName, TextDefinition townStoneName, TextDefinition sigilName, TextDefinition corruptedSigilName, Point3D monolith, Point3D townStone)
|
||||
{
|
||||
this.m_Sort = sort;
|
||||
this.m_SigilID = sigilID;
|
||||
this.m_Region = region;
|
||||
this.m_FriendlyName = friendlyName;
|
||||
this.m_TownName = townName;
|
||||
this.m_TownStoneHeader = townStoneHeader;
|
||||
this.m_StrongholdMonolithName = strongholdMonolithName;
|
||||
this.m_TownMonolithName = townMonolithName;
|
||||
this.m_TownStoneName = townStoneName;
|
||||
this.m_SigilName = sigilName;
|
||||
this.m_CorruptedSigilName = corruptedSigilName;
|
||||
this.m_Monolith = monolith;
|
||||
this.m_TownStone = townStone;
|
||||
}
|
||||
|
||||
public int Sort
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Sort;
|
||||
}
|
||||
}
|
||||
public int SigilID
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_SigilID;
|
||||
}
|
||||
}
|
||||
public string Region
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Region;
|
||||
}
|
||||
}
|
||||
public string FriendlyName
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_FriendlyName;
|
||||
}
|
||||
}
|
||||
public TextDefinition TownName
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_TownName;
|
||||
}
|
||||
}
|
||||
public TextDefinition TownStoneHeader
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_TownStoneHeader;
|
||||
}
|
||||
}
|
||||
public TextDefinition StrongholdMonolithName
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_StrongholdMonolithName;
|
||||
}
|
||||
}
|
||||
public TextDefinition TownMonolithName
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_TownMonolithName;
|
||||
}
|
||||
}
|
||||
public TextDefinition TownStoneName
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_TownStoneName;
|
||||
}
|
||||
}
|
||||
public TextDefinition SigilName
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_SigilName;
|
||||
}
|
||||
}
|
||||
public TextDefinition CorruptedSigilName
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_CorruptedSigilName;
|
||||
}
|
||||
}
|
||||
public Point3D Monolith
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Monolith;
|
||||
}
|
||||
}
|
||||
public Point3D TownStone
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_TownStone;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
117
Scripts/Services/Factions/Definitions/VendorDefinition.cs
Normal file
117
Scripts/Services/Factions/Definitions/VendorDefinition.cs
Normal file
@@ -0,0 +1,117 @@
|
||||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class VendorDefinition
|
||||
{
|
||||
private static readonly VendorDefinition[] m_Definitions = new VendorDefinition[]
|
||||
{
|
||||
new VendorDefinition(typeof(FactionBottleVendor), 0xF0E,
|
||||
5000,
|
||||
1000,
|
||||
10,
|
||||
new TextDefinition(1011549, "POTION BOTTLE VENDOR"),
|
||||
new TextDefinition(1011544, "Buy Potion Bottle Vendor")),
|
||||
new VendorDefinition(typeof(FactionBoardVendor), 0x1BD7,
|
||||
3000,
|
||||
500,
|
||||
10,
|
||||
new TextDefinition(1011552, "WOOD VENDOR"),
|
||||
new TextDefinition(1011545, "Buy Wooden Board Vendor")),
|
||||
new VendorDefinition(typeof(FactionOreVendor), 0x19B8,
|
||||
3000,
|
||||
500,
|
||||
10,
|
||||
new TextDefinition(1011553, "IRON ORE VENDOR"),
|
||||
new TextDefinition(1011546, "Buy Iron Ore Vendor")),
|
||||
new VendorDefinition(typeof(FactionReagentVendor), 0xF86,
|
||||
5000,
|
||||
1000,
|
||||
10,
|
||||
new TextDefinition(1011554, "REAGENT VENDOR"),
|
||||
new TextDefinition(1011547, "Buy Reagent Vendor")),
|
||||
new VendorDefinition(typeof(FactionHorseVendor), 0x20DD,
|
||||
5000,
|
||||
1000,
|
||||
1,
|
||||
new TextDefinition(1011556, "HORSE BREEDER"),
|
||||
new TextDefinition(1011555, "Buy Horse Breeder"))
|
||||
};
|
||||
private readonly Type m_Type;
|
||||
private readonly int m_Price;
|
||||
private readonly int m_Upkeep;
|
||||
private readonly int m_Maximum;
|
||||
private readonly int m_ItemID;
|
||||
private readonly TextDefinition m_Header;
|
||||
private readonly TextDefinition m_Label;
|
||||
public VendorDefinition(Type type, int itemID, int price, int upkeep, int maximum, TextDefinition header, TextDefinition label)
|
||||
{
|
||||
this.m_Type = type;
|
||||
|
||||
this.m_Price = price;
|
||||
this.m_Upkeep = upkeep;
|
||||
this.m_Maximum = maximum;
|
||||
this.m_ItemID = itemID;
|
||||
|
||||
this.m_Header = header;
|
||||
this.m_Label = label;
|
||||
}
|
||||
|
||||
public static VendorDefinition[] Definitions
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Definitions;
|
||||
}
|
||||
}
|
||||
public Type Type
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Type;
|
||||
}
|
||||
}
|
||||
public int Price
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Price;
|
||||
}
|
||||
}
|
||||
public int Upkeep
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Upkeep;
|
||||
}
|
||||
}
|
||||
public int Maximum
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Maximum;
|
||||
}
|
||||
}
|
||||
public int ItemID
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_ItemID;
|
||||
}
|
||||
}
|
||||
public TextDefinition Header
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Header;
|
||||
}
|
||||
}
|
||||
public TextDefinition Label
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Label;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
128
Scripts/Services/Factions/Gumps/ElectionGump.cs
Normal file
128
Scripts/Services/Factions/Gumps/ElectionGump.cs
Normal file
@@ -0,0 +1,128 @@
|
||||
using System;
|
||||
using Server.Gumps;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class ElectionGump : FactionGump
|
||||
{
|
||||
private readonly PlayerMobile m_From;
|
||||
private readonly Election m_Election;
|
||||
|
||||
public ElectionGump(PlayerMobile from, Election election)
|
||||
: base(50, 50)
|
||||
{
|
||||
m_From = from;
|
||||
m_Election = election;
|
||||
|
||||
AddPage(0);
|
||||
|
||||
AddBackground(0, 0, 420, 180, 5054);
|
||||
AddBackground(10, 10, 400, 160, 3000);
|
||||
|
||||
AddHtmlText(20, 20, 380, 20, election.Faction.Definition.Header, false, false);
|
||||
|
||||
// NOTE: Gump not entirely OSI-accurate, intentionally so
|
||||
|
||||
switch ( election.State )
|
||||
{
|
||||
case ElectionState.Pending:
|
||||
{
|
||||
TimeSpan toGo = (election.LastStateTime + Election.PendingPeriod) - DateTime.UtcNow;
|
||||
int days = (int)(toGo.TotalDays + 0.5);
|
||||
|
||||
AddHtmlLocalized(20, 40, 380, 20, 1038034, false, false); // A new election campaign is pending
|
||||
|
||||
if (days > 0)
|
||||
{
|
||||
AddHtmlLocalized(20, 60, 280, 20, 1018062, false, false); // Days until next election :
|
||||
AddLabel(300, 60, 0, days.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
AddHtmlLocalized(20, 60, 280, 20, 1018059, false, false); // Election campaigning begins tonight.
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case ElectionState.Campaign:
|
||||
{
|
||||
TimeSpan toGo = (election.LastStateTime + Election.CampaignPeriod) - DateTime.UtcNow;
|
||||
int days = (int)(toGo.TotalDays + 0.5);
|
||||
|
||||
AddHtmlLocalized(20, 40, 380, 20, 1018058, false, false); // There is an election campaign in progress.
|
||||
|
||||
if (days > 0)
|
||||
{
|
||||
AddHtmlLocalized(20, 60, 280, 20, 1038033, false, false); // Days to go:
|
||||
AddLabel(300, 60, 0, days.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
AddHtmlLocalized(20, 60, 280, 20, 1018061, false, false); // Campaign in progress. Voting begins tonight.
|
||||
}
|
||||
|
||||
if (m_Election.CanBeCandidate(m_From))
|
||||
{
|
||||
AddButton(20, 110, 4005, 4007, 2, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(55, 110, 350, 20, 1011427, false, false); // CAMPAIGN FOR LEADERSHIP
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerState pl = PlayerState.Find(m_From);
|
||||
|
||||
if (pl == null || pl.Rank.Rank < Election.CandidateRank)
|
||||
AddHtmlLocalized(20, 100, 380, 20, 1010118, false, false); // You must have a higher rank to run for office
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case ElectionState.Election:
|
||||
{
|
||||
TimeSpan toGo = (election.LastStateTime + Election.VotingPeriod) - DateTime.UtcNow;
|
||||
int days = (int)Math.Ceiling(toGo.TotalDays);
|
||||
|
||||
AddHtmlLocalized(20, 40, 380, 20, 1018060, false, false); // There is an election vote in progress.
|
||||
|
||||
AddHtmlLocalized(20, 60, 280, 20, 1038033, false, false);
|
||||
AddLabel(300, 60, 0, days.ToString());
|
||||
|
||||
AddHtmlLocalized(55, 100, 380, 20, 1011428, false, false); // VOTE FOR LEADERSHIP
|
||||
AddButton(20, 100, 4005, 4007, 1, GumpButtonType.Reply, 0);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
AddButton(20, 140, 4005, 4007, 0, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(55, 140, 350, 20, 1011012, false, false); // CANCEL
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
switch ( info.ButtonID )
|
||||
{
|
||||
case 0: // back
|
||||
{
|
||||
m_From.SendGump(new FactionStoneGump(m_From, m_Election.Faction));
|
||||
break;
|
||||
}
|
||||
case 1: // vote
|
||||
{
|
||||
if (m_Election.State == ElectionState.Election)
|
||||
m_From.SendGump(new VoteGump(m_From, m_Election));
|
||||
|
||||
break;
|
||||
}
|
||||
case 2: // campaign
|
||||
{
|
||||
if (m_Election.CanBeCandidate(m_From))
|
||||
m_Election.AddCandidate(m_From);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
215
Scripts/Services/Factions/Gumps/ElectionManagementGump.cs
Normal file
215
Scripts/Services/Factions/Gumps/ElectionManagementGump.cs
Normal file
@@ -0,0 +1,215 @@
|
||||
using System;
|
||||
using Server.Gumps;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class ElectionManagementGump : Gump
|
||||
{
|
||||
public const int LabelColor = 0xFFFFFF;
|
||||
private readonly Election m_Election;
|
||||
private readonly Candidate m_Candidate;
|
||||
private readonly int m_Page;
|
||||
public ElectionManagementGump(Election election)
|
||||
: this(election, null, 0)
|
||||
{
|
||||
}
|
||||
|
||||
public ElectionManagementGump(Election election, Candidate candidate, int page)
|
||||
: base(40, 40)
|
||||
{
|
||||
this.m_Election = election;
|
||||
this.m_Candidate = candidate;
|
||||
this.m_Page = page;
|
||||
|
||||
this.AddPage(0);
|
||||
|
||||
if (candidate != null)
|
||||
{
|
||||
this.AddBackground(0, 0, 448, 354, 9270);
|
||||
this.AddAlphaRegion(10, 10, 428, 334);
|
||||
|
||||
this.AddHtml(10, 10, 428, 20, this.Color(this.Center("Candidate Management"), LabelColor), false, false);
|
||||
|
||||
this.AddHtml(45, 35, 100, 20, this.Color("Player Name:", LabelColor), false, false);
|
||||
this.AddHtml(145, 35, 100, 20, this.Color(candidate.Mobile == null ? "null" : candidate.Mobile.Name, LabelColor), false, false);
|
||||
|
||||
this.AddHtml(45, 55, 100, 20, this.Color("Vote Count:", LabelColor), false, false);
|
||||
this.AddHtml(145, 55, 100, 20, this.Color(candidate.Votes.ToString(), LabelColor), false, false);
|
||||
|
||||
this.AddButton(12, 73, 4005, 4007, 1, GumpButtonType.Reply, 0);
|
||||
this.AddHtml(45, 75, 100, 20, this.Color("Drop Candidate", LabelColor), false, false);
|
||||
|
||||
this.AddImageTiled(13, 99, 422, 242, 9264);
|
||||
this.AddImageTiled(14, 100, 420, 240, 9274);
|
||||
this.AddAlphaRegion(14, 100, 420, 240);
|
||||
|
||||
this.AddHtml(14, 100, 420, 20, this.Color(this.Center("Voters"), LabelColor), false, false);
|
||||
|
||||
if (page > 0)
|
||||
this.AddButton(397, 104, 0x15E3, 0x15E7, 2, GumpButtonType.Reply, 0);
|
||||
else
|
||||
this.AddImage(397, 104, 0x25EA);
|
||||
|
||||
if ((page + 1) * 10 < candidate.Voters.Count)
|
||||
this.AddButton(414, 104, 0x15E1, 0x15E5, 3, GumpButtonType.Reply, 0);
|
||||
else
|
||||
this.AddImage(414, 104, 0x25E6);
|
||||
|
||||
this.AddHtml(14, 120, 30, 20, this.Color(this.Center("DEL"), LabelColor), false, false);
|
||||
this.AddHtml(47, 120, 150, 20, this.Color("Name", LabelColor), false, false);
|
||||
this.AddHtml(195, 120, 100, 20, this.Color(this.Center("Address"), LabelColor), false, false);
|
||||
this.AddHtml(295, 120, 80, 20, this.Color(this.Center("Time"), LabelColor), false, false);
|
||||
this.AddHtml(355, 120, 60, 20, this.Color(this.Center("Legit"), LabelColor), false, false);
|
||||
|
||||
int idx = 0;
|
||||
|
||||
for (int i = page * 10; i >= 0 && i < candidate.Voters.Count && i < (page + 1) * 10; ++i, ++idx)
|
||||
{
|
||||
Voter voter = (Voter)candidate.Voters[i];
|
||||
|
||||
this.AddButton(13, 138 + (idx * 20), 4002, 4004, 4 + i, GumpButtonType.Reply, 0);
|
||||
|
||||
object[] fields = voter.AcquireFields();
|
||||
|
||||
int x = 45;
|
||||
|
||||
for (int j = 0; j < fields.Length; ++j)
|
||||
{
|
||||
object obj = fields[j];
|
||||
|
||||
if (obj is Mobile)
|
||||
{
|
||||
this.AddHtml(x + 2, 140 + (idx * 20), 150, 20, this.Color(((Mobile)obj).Name, LabelColor), false, false);
|
||||
x += 150;
|
||||
}
|
||||
else if (obj is System.Net.IPAddress)
|
||||
{
|
||||
this.AddHtml(x, 140 + (idx * 20), 100, 20, this.Color(this.Center(obj.ToString()), LabelColor), false, false);
|
||||
x += 100;
|
||||
}
|
||||
else if (obj is DateTime)
|
||||
{
|
||||
this.AddHtml(x, 140 + (idx * 20), 80, 20, this.Color(this.Center(FormatTimeSpan(((DateTime)obj) - election.LastStateTime)), LabelColor), false, false);
|
||||
x += 80;
|
||||
}
|
||||
else if (obj is int)
|
||||
{
|
||||
this.AddHtml(x, 140 + (idx * 20), 60, 20, this.Color(this.Center((int)obj + "%"), LabelColor), false, false);
|
||||
x += 60;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.AddBackground(0, 0, 288, 334, 9270);
|
||||
this.AddAlphaRegion(10, 10, 268, 314);
|
||||
|
||||
this.AddHtml(10, 10, 268, 20, this.Color(this.Center("Election Management"), LabelColor), false, false);
|
||||
|
||||
this.AddHtml(45, 35, 100, 20, this.Color("Current State:", LabelColor), false, false);
|
||||
this.AddHtml(145, 35, 100, 20, this.Color(election.State.ToString(), LabelColor), false, false);
|
||||
|
||||
this.AddButton(12, 53, 4005, 4007, 1, GumpButtonType.Reply, 0);
|
||||
this.AddHtml(45, 55, 100, 20, this.Color("Transition Time:", LabelColor), false, false);
|
||||
this.AddHtml(145, 55, 100, 20, this.Color(FormatTimeSpan(election.NextStateTime), LabelColor), false, false);
|
||||
|
||||
this.AddImageTiled(13, 79, 262, 242, 9264);
|
||||
this.AddImageTiled(14, 80, 260, 240, 9274);
|
||||
this.AddAlphaRegion(14, 80, 260, 240);
|
||||
|
||||
this.AddHtml(14, 80, 260, 20, this.Color(this.Center("Candidates"), LabelColor), false, false);
|
||||
this.AddHtml(14, 100, 30, 20, this.Color(this.Center("-->"), LabelColor), false, false);
|
||||
this.AddHtml(47, 100, 150, 20, this.Color("Name", LabelColor), false, false);
|
||||
this.AddHtml(195, 100, 80, 20, this.Color(this.Center("Votes"), LabelColor), false, false);
|
||||
|
||||
for (int i = 0; i < election.Candidates.Count; ++i)
|
||||
{
|
||||
Candidate cd = election.Candidates[i];
|
||||
Mobile mob = cd.Mobile;
|
||||
|
||||
if (mob == null)
|
||||
continue;
|
||||
|
||||
this.AddButton(13, 118 + (i * 20), 4005, 4007, 2 + i, GumpButtonType.Reply, 0);
|
||||
this.AddHtml(47, 120 + (i * 20), 150, 20, this.Color(mob.Name, LabelColor), false, false);
|
||||
this.AddHtml(195, 120 + (i * 20), 80, 20, this.Color(this.Center(cd.Votes.ToString()), LabelColor), false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static string FormatTimeSpan(TimeSpan ts)
|
||||
{
|
||||
return String.Format("{0:D2}:{1:D2}:{2:D2}:{3:D2}", ts.Days, ts.Hours % 24, ts.Minutes % 60, ts.Seconds % 60);
|
||||
}
|
||||
|
||||
public string Right(string text)
|
||||
{
|
||||
return String.Format("<DIV ALIGN=RIGHT>{0}</DIV>", text);
|
||||
}
|
||||
|
||||
public string Center(string text)
|
||||
{
|
||||
return String.Format("<CENTER>{0}</CENTER>", text);
|
||||
}
|
||||
|
||||
public string Color(string text, int color)
|
||||
{
|
||||
return String.Format("<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", color, text);
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
Mobile from = sender.Mobile;
|
||||
int bid = info.ButtonID;
|
||||
|
||||
if (this.m_Candidate == null)
|
||||
{
|
||||
if (bid == 0)
|
||||
{
|
||||
}
|
||||
else if (bid == 1)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
bid -= 2;
|
||||
|
||||
if (bid >= 0 && bid < this.m_Election.Candidates.Count)
|
||||
from.SendGump(new ElectionManagementGump(this.m_Election, this.m_Election.Candidates[bid], 0));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bid == 0)
|
||||
{
|
||||
from.SendGump(new ElectionManagementGump(this.m_Election));
|
||||
}
|
||||
else if (bid == 1)
|
||||
{
|
||||
this.m_Election.RemoveCandidate(this.m_Candidate.Mobile);
|
||||
from.SendGump(new ElectionManagementGump(this.m_Election));
|
||||
}
|
||||
else if (bid == 2 && this.m_Page > 0)
|
||||
{
|
||||
from.SendGump(new ElectionManagementGump(this.m_Election, this.m_Candidate, this.m_Page - 1));
|
||||
}
|
||||
else if (bid == 3 && (this.m_Page + 1) * 10 < this.m_Candidate.Voters.Count)
|
||||
{
|
||||
from.SendGump(new ElectionManagementGump(this.m_Election, this.m_Candidate, this.m_Page + 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
bid -= 4;
|
||||
|
||||
if (bid >= 0 && bid < this.m_Candidate.Voters.Count)
|
||||
{
|
||||
this.m_Candidate.Voters.RemoveAt(bid);
|
||||
from.SendGump(new ElectionManagementGump(this.m_Election, this.m_Candidate, this.m_Page));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
55
Scripts/Services/Factions/Gumps/FactionGump.cs
Normal file
55
Scripts/Services/Factions/Gumps/FactionGump.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using Server.Gumps;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public abstract class FactionGump : Gump
|
||||
{
|
||||
public FactionGump(int x, int y)
|
||||
: base(x, y)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual int ButtonTypes
|
||||
{
|
||||
get
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
}
|
||||
public static bool Exists(Mobile mob)
|
||||
{
|
||||
return (mob.FindGump(typeof(FactionGump)) != null);
|
||||
}
|
||||
|
||||
public int ToButtonID(int type, int index)
|
||||
{
|
||||
return 1 + (index * this.ButtonTypes) + type;
|
||||
}
|
||||
|
||||
public bool FromButtonID(int buttonID, out int type, out int index)
|
||||
{
|
||||
int offset = buttonID - 1;
|
||||
|
||||
if (offset >= 0)
|
||||
{
|
||||
type = offset % this.ButtonTypes;
|
||||
index = offset / this.ButtonTypes;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
type = index = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void AddHtmlText(int x, int y, int width, int height, TextDefinition text, bool back, bool scroll)
|
||||
{
|
||||
if (text != null && text.Number > 0)
|
||||
this.AddHtmlLocalized(x, y, width, height, text.Number, back, scroll);
|
||||
else if (text != null && text.String != null)
|
||||
this.AddHtml(x, y, width, height, text.String, back, scroll);
|
||||
}
|
||||
}
|
||||
}
|
||||
98
Scripts/Services/Factions/Gumps/FactionImbueGump.cs
Normal file
98
Scripts/Services/Factions/Gumps/FactionImbueGump.cs
Normal file
@@ -0,0 +1,98 @@
|
||||
using System;
|
||||
using Server.Engines.Craft;
|
||||
using Server.Gumps;
|
||||
using Server.Items;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionImbueGump : FactionGump
|
||||
{
|
||||
private readonly Item m_Item;
|
||||
private readonly Mobile m_Mobile;
|
||||
private readonly Faction m_Faction;
|
||||
private readonly CraftSystem m_CraftSystem;
|
||||
private readonly ITool m_Tool;
|
||||
private readonly object m_Notice;
|
||||
private readonly int m_Quality;
|
||||
private readonly FactionItemDefinition m_Definition;
|
||||
public FactionImbueGump(int quality, Item item, Mobile from, CraftSystem craftSystem, ITool tool, object notice, int availableSilver, Faction faction, FactionItemDefinition def)
|
||||
: base(100, 200)
|
||||
{
|
||||
this.m_Item = item;
|
||||
this.m_Mobile = from;
|
||||
this.m_Faction = faction;
|
||||
this.m_CraftSystem = craftSystem;
|
||||
this.m_Tool = tool;
|
||||
this.m_Notice = notice;
|
||||
this.m_Quality = quality;
|
||||
this.m_Definition = def;
|
||||
|
||||
this.AddPage(0);
|
||||
|
||||
this.AddBackground(0, 0, 320, 270, 5054);
|
||||
this.AddBackground(10, 10, 300, 250, 3000);
|
||||
|
||||
this.AddHtmlLocalized(20, 20, 210, 25, 1011569, false, false); // Imbue with Faction properties?
|
||||
|
||||
this.AddHtmlLocalized(20, 60, 170, 25, 1018302, false, false); // Item quality:
|
||||
this.AddHtmlLocalized(175, 60, 100, 25, 1018305 - this.m_Quality, false, false); // Exceptional, Average, Low
|
||||
|
||||
this.AddHtmlLocalized(20, 80, 170, 25, 1011572, false, false); // Item Cost :
|
||||
this.AddLabel(175, 80, 0x34, def.SilverCost.ToString("N0")); // NOTE: Added 'N0'
|
||||
|
||||
this.AddHtmlLocalized(20, 100, 170, 25, 1011573, false, false); // Your Silver :
|
||||
this.AddLabel(175, 100, 0x34, availableSilver.ToString("N0")); // NOTE: Added 'N0'
|
||||
|
||||
this.AddRadio(20, 140, 210, 211, true, 1);
|
||||
this.AddLabel(55, 140, this.m_Faction.Definition.HuePrimary - 1, "*****");
|
||||
this.AddHtmlLocalized(150, 140, 150, 25, 1011570, false, false); // Primary Color
|
||||
|
||||
this.AddRadio(20, 160, 210, 211, false, 2);
|
||||
this.AddLabel(55, 160, this.m_Faction.Definition.HueSecondary - 1, "*****");
|
||||
this.AddHtmlLocalized(150, 160, 150, 25, 1011571, false, false); // Secondary Color
|
||||
|
||||
this.AddHtmlLocalized(55, 200, 200, 25, 1011011, false, false); // CONTINUE
|
||||
this.AddButton(20, 200, 4005, 4007, 1, GumpButtonType.Reply, 0);
|
||||
|
||||
this.AddHtmlLocalized(55, 230, 200, 25, 1011012, false, false); // CANCEL
|
||||
this.AddButton(20, 230, 4005, 4007, 0, GumpButtonType.Reply, 0);
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
if (info.ButtonID == 1)
|
||||
{
|
||||
Container pack = this.m_Mobile.Backpack;
|
||||
|
||||
if (pack != null && this.m_Item.IsChildOf(pack))
|
||||
{
|
||||
if (pack.ConsumeTotal(typeof(Silver), this.m_Definition.SilverCost))
|
||||
{
|
||||
int hue;
|
||||
|
||||
if (this.m_Item is SpellScroll)
|
||||
hue = 0;
|
||||
else if (info.IsSwitched(1))
|
||||
hue = this.m_Faction.Definition.HuePrimary;
|
||||
else
|
||||
hue = this.m_Faction.Definition.HueSecondary;
|
||||
|
||||
FactionItem.Imbue(this.m_Item, this.m_Faction, true, hue);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.m_Mobile.SendLocalizedMessage(1042204); // You do not have enough silver.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.m_Tool != null && !this.m_Tool.Deleted && this.m_Tool.UsesRemaining > 0)
|
||||
this.m_Mobile.SendGump(new CraftGump(this.m_Mobile, this.m_CraftSystem, this.m_Tool, this.m_Notice));
|
||||
else if (this.m_Notice is string)
|
||||
this.m_Mobile.SendMessage((string)this.m_Notice);
|
||||
else if (this.m_Notice is int && ((int)this.m_Notice) > 0)
|
||||
this.m_Mobile.SendLocalizedMessage((int)this.m_Notice);
|
||||
}
|
||||
}
|
||||
}
|
||||
359
Scripts/Services/Factions/Gumps/FactionStoneGump.cs
Normal file
359
Scripts/Services/Factions/Gumps/FactionStoneGump.cs
Normal file
@@ -0,0 +1,359 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Gumps;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionStoneGump : FactionGump
|
||||
{
|
||||
private readonly PlayerMobile m_From;
|
||||
private readonly Faction m_Faction;
|
||||
|
||||
public override int ButtonTypes
|
||||
{
|
||||
get
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
||||
public FactionStoneGump(PlayerMobile from, Faction faction)
|
||||
: base(20, 30)
|
||||
{
|
||||
m_From = from;
|
||||
m_Faction = faction;
|
||||
|
||||
AddPage(0);
|
||||
|
||||
AddBackground(0, 0, 550, 440, 5054);
|
||||
AddBackground(10, 10, 530, 420, 3000);
|
||||
|
||||
#region General
|
||||
AddPage(1);
|
||||
|
||||
AddHtmlText(20, 30, 510, 20, faction.Definition.Header, false, false);
|
||||
|
||||
AddHtmlLocalized(20, 60, 100, 20, 1011429, false, false); // Led By :
|
||||
AddHtml(125, 60, 200, 20, faction.Commander != null ? faction.Commander.Name : "Nobody", false, false);
|
||||
|
||||
AddHtmlLocalized(20, 80, 100, 20, 1011457, false, false); // Tithe rate :
|
||||
if (faction.Tithe >= 0 && faction.Tithe <= 100 && (faction.Tithe % 10) == 0)
|
||||
AddHtmlLocalized(125, 80, 350, 20, 1011480 + (faction.Tithe / 10), false, false);
|
||||
else
|
||||
AddHtml(125, 80, 350, 20, faction.Tithe + "%", false, false);
|
||||
|
||||
AddHtmlLocalized(20, 100, 100, 20, 1011458, false, false); // Traps placed :
|
||||
AddHtml(125, 100, 50, 20, faction.Traps.Count.ToString(), false, false);
|
||||
|
||||
AddHtmlLocalized(55, 225, 200, 20, 1011428, false, false); // VOTE FOR LEADERSHIP
|
||||
|
||||
if (m_Faction.Election != null)
|
||||
{
|
||||
AddButton(20, 225, 4005, 4007, ToButtonID(0, 0), GumpButtonType.Reply, 0);
|
||||
}
|
||||
|
||||
AddHtmlLocalized(55, 150, 100, 20, 1011430, false, false); // CITY STATUS
|
||||
AddButton(20, 150, 4005, 4007, 0, GumpButtonType.Page, 2);
|
||||
|
||||
AddHtmlLocalized(55, 175, 100, 20, 1011444, false, false); // STATISTICS
|
||||
AddButton(20, 175, 4005, 4007, 0, GumpButtonType.Page, 4);
|
||||
|
||||
bool isMerchantQualified = MerchantTitles.HasMerchantQualifications(from);
|
||||
|
||||
PlayerState pl = PlayerState.Find(from);
|
||||
|
||||
if (pl != null && pl.MerchantTitle != MerchantTitle.None)
|
||||
{
|
||||
AddHtmlLocalized(55, 200, 250, 20, 1011460, false, false); // UNDECLARE FACTION MERCHANT
|
||||
AddButton(20, 200, 4005, 4007, ToButtonID(1, 0), GumpButtonType.Reply, 0);
|
||||
}
|
||||
else if (isMerchantQualified)
|
||||
{
|
||||
AddHtmlLocalized(55, 200, 250, 20, 1011459, false, false); // DECLARE FACTION MERCHANT
|
||||
AddButton(20, 200, 4005, 4007, 0, GumpButtonType.Page, 5);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddHtmlLocalized(55, 200, 250, 20, 1011467, false, false); // MERCHANT OPTIONS
|
||||
AddImage(20, 200, 4020);
|
||||
}
|
||||
|
||||
AddHtmlLocalized(55, 250, 300, 20, 1011461, false, false); // COMMANDER OPTIONS
|
||||
if (faction.IsCommander(from))
|
||||
AddButton(20, 250, 4005, 4007, 0, GumpButtonType.Page, 6);
|
||||
else
|
||||
AddImage(20, 250, 4020);
|
||||
|
||||
AddHtmlLocalized(55, 275, 300, 20, 1011426, false, false); // LEAVE THIS FACTION
|
||||
AddButton(20, 275, 4005, 4007, ToButtonID(0, 1), GumpButtonType.Reply, 0);
|
||||
|
||||
AddHtmlLocalized(55, 300, 200, 20, 1011441, false, false); // EXIT
|
||||
AddButton(20, 300, 4005, 4007, 0, GumpButtonType.Reply, 0);
|
||||
#endregion
|
||||
|
||||
#region City Status
|
||||
AddPage(2);
|
||||
|
||||
AddHtmlLocalized(20, 30, 250, 20, 1011430, false, false); // CITY STATUS
|
||||
|
||||
List<Town> towns = Town.Towns;
|
||||
|
||||
for (int i = 0; i < towns.Count; ++i)
|
||||
{
|
||||
Town town = towns[i];
|
||||
|
||||
AddHtmlText(40, 55 + (i * 30), 150, 20, town.Definition.TownName, false, false);
|
||||
|
||||
if (town.Owner == null)
|
||||
{
|
||||
AddHtmlLocalized(200, 55 + (i * 30), 150, 20, 1011462, false, false); // : Neutral
|
||||
}
|
||||
else
|
||||
{
|
||||
AddHtmlLocalized(200, 55 + (i * 30), 150, 20, town.Owner.Definition.OwnerLabel, false, false);
|
||||
|
||||
BaseMonolith monolith = town.Monolith;
|
||||
|
||||
AddImage(20, 60 + (i * 30), (monolith != null && monolith.Sigil != null && monolith.Sigil.IsPurifying) ? 0x938 : 0x939);
|
||||
}
|
||||
}
|
||||
|
||||
AddImage(20, 300, 2361);
|
||||
AddHtmlLocalized(45, 295, 300, 20, 1011491, false, false); // sigil may be recaptured
|
||||
|
||||
AddImage(20, 320, 2360);
|
||||
AddHtmlLocalized(45, 315, 300, 20, 1011492, false, false); // sigil may not be recaptured
|
||||
|
||||
AddHtmlLocalized(55, 350, 100, 20, 1011447, false, false); // BACK
|
||||
AddButton(20, 350, 4005, 4007, 0, GumpButtonType.Page, 1);
|
||||
#endregion
|
||||
|
||||
#region Statistics
|
||||
AddPage(4);
|
||||
|
||||
AddHtmlLocalized(20, 30, 150, 20, 1011444, false, false); // STATISTICS
|
||||
|
||||
AddHtmlLocalized(20, 100, 100, 20, 1011445, false, false); // Name :
|
||||
AddHtml(120, 100, 150, 20, from.Name, false, false);
|
||||
|
||||
AddHtmlLocalized(20, 130, 100, 20, 1018064, false, false); // score :
|
||||
AddHtml(120, 130, 100, 20, (pl != null ? pl.KillPoints : 0).ToString(), false, false);
|
||||
|
||||
AddHtmlLocalized(20, 160, 100, 20, 1011446, false, false); // Rank :
|
||||
AddHtml(120, 160, 100, 20, (pl != null ? pl.Rank.Rank : 0).ToString(), false, false);
|
||||
|
||||
AddHtmlLocalized(55, 250, 100, 20, 1011447, false, false); // BACK
|
||||
AddButton(20, 250, 4005, 4007, 0, GumpButtonType.Page, 1);
|
||||
#endregion
|
||||
|
||||
#region Merchant Options
|
||||
if ((pl == null || pl.MerchantTitle == MerchantTitle.None) && isMerchantQualified)
|
||||
{
|
||||
AddPage(5);
|
||||
|
||||
AddHtmlLocalized(20, 30, 250, 20, 1011467, false, false); // MERCHANT OPTIONS
|
||||
|
||||
AddHtmlLocalized(20, 80, 300, 20, 1011473, false, false); // Select the title you wish to display
|
||||
|
||||
MerchantTitleInfo[] infos = MerchantTitles.Info;
|
||||
|
||||
for (int i = 0; i < infos.Length; ++i)
|
||||
{
|
||||
MerchantTitleInfo info = infos[i];
|
||||
|
||||
if (MerchantTitles.IsQualified(from, info))
|
||||
AddButton(20, 100 + (i * 30), 4005, 4007, ToButtonID(1, i + 1), GumpButtonType.Reply, 0);
|
||||
else
|
||||
AddImage(20, 100 + (i * 30), 4020);
|
||||
|
||||
AddHtmlText(55, 100 + (i * 30), 200, 20, info.Label, false, false);
|
||||
}
|
||||
|
||||
AddHtmlLocalized(55, 340, 100, 20, 1011447, false, false); // BACK
|
||||
AddButton(20, 340, 4005, 4007, 0, GumpButtonType.Page, 1);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Commander Options
|
||||
if (faction.IsCommander(from))
|
||||
{
|
||||
#region General
|
||||
AddPage(6);
|
||||
|
||||
AddHtmlLocalized(20, 30, 200, 20, 1011461, false, false); // COMMANDER OPTIONS
|
||||
|
||||
AddHtmlLocalized(20, 70, 120, 20, 1011457, false, false); // Tithe rate :
|
||||
if (faction.Tithe >= 0 && faction.Tithe <= 100 && (faction.Tithe % 10) == 0)
|
||||
AddHtmlLocalized(140, 70, 250, 20, 1011480 + (faction.Tithe / 10), false, false);
|
||||
else
|
||||
AddHtml(140, 70, 250, 20, faction.Tithe + "%", false, false);
|
||||
|
||||
AddHtmlLocalized(20, 100, 120, 20, 1011474, false, false); // Silver available :
|
||||
AddHtml(140, 100, 50, 20, faction.Silver.ToString("N0"), false, false); // NOTE: Added 'N0' formatting
|
||||
|
||||
AddHtmlLocalized(55, 130, 200, 20, 1011478, false, false); // CHANGE TITHE RATE
|
||||
AddButton(20, 130, 4005, 4007, 0, GumpButtonType.Page, 8);
|
||||
|
||||
AddHtmlLocalized(55, 160, 200, 20, 1018301, false, false); // TRANSFER SILVER
|
||||
if (faction.Silver >= 10000)
|
||||
AddButton(20, 160, 4005, 4007, 0, GumpButtonType.Page, 7);
|
||||
else
|
||||
AddImage(20, 160, 4020);
|
||||
|
||||
AddHtmlLocalized(55, 310, 100, 20, 1011447, false, false); // BACK
|
||||
AddButton(20, 310, 4005, 4007, 0, GumpButtonType.Page, 1);
|
||||
#endregion
|
||||
|
||||
#region Town Finance
|
||||
if (faction.Silver >= 10000)
|
||||
{
|
||||
AddPage(7);
|
||||
|
||||
AddHtmlLocalized(20, 30, 250, 20, 1011476, false, false); // TOWN FINANCE
|
||||
|
||||
AddHtmlLocalized(20, 50, 400, 20, 1011477, false, false); // Select a town to transfer 10000 silver to
|
||||
|
||||
for (int i = 0; i < towns.Count; ++i)
|
||||
{
|
||||
Town town = towns[i];
|
||||
|
||||
AddHtmlText(55, 75 + (i * 30), 200, 20, town.Definition.TownName, false, false);
|
||||
|
||||
if (town.Owner == faction)
|
||||
AddButton(20, 75 + (i * 30), 4005, 4007, ToButtonID(2, i), GumpButtonType.Reply, 0);
|
||||
else
|
||||
AddImage(20, 75 + (i * 30), 4020);
|
||||
}
|
||||
|
||||
AddHtmlLocalized(55, 310, 100, 20, 1011447, false, false); // BACK
|
||||
AddButton(20, 310, 4005, 4007, 0, GumpButtonType.Page, 1);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Change Tithe Rate
|
||||
AddPage(8);
|
||||
|
||||
AddHtmlLocalized(20, 30, 400, 20, 1011479, false, false); // Select the % for the new tithe rate
|
||||
|
||||
int y = 55;
|
||||
|
||||
for (int i = 0; i <= 10; ++i)
|
||||
{
|
||||
if (i == 5)
|
||||
y += 5;
|
||||
|
||||
AddHtmlLocalized(55, y, 300, 20, 1011480 + i, false, false);
|
||||
AddButton(20, y, 4005, 4007, ToButtonID(3, i), GumpButtonType.Reply, 0);
|
||||
|
||||
y += 20;
|
||||
|
||||
if (i == 5)
|
||||
y += 5;
|
||||
}
|
||||
|
||||
AddHtmlLocalized(55, 310, 300, 20, 1011447, false, false); // BACK
|
||||
AddButton(20, 310, 4005, 4007, 0, GumpButtonType.Page, 1);
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
int type, index;
|
||||
|
||||
if (!FromButtonID(info.ButtonID, out type, out index))
|
||||
return;
|
||||
|
||||
switch ( type )
|
||||
{
|
||||
case 0: // general
|
||||
{
|
||||
switch ( index )
|
||||
{
|
||||
case 0: // vote
|
||||
{
|
||||
if (m_Faction.Election != null)
|
||||
{
|
||||
m_From.SendGump(new ElectionGump(m_From, m_Faction.Election));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 1: // leave
|
||||
{
|
||||
m_From.SendGump(new LeaveFactionGump(m_From, m_Faction));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 1: // merchant title
|
||||
{
|
||||
if (index >= 0 && index <= MerchantTitles.Info.Length)
|
||||
{
|
||||
PlayerState pl = PlayerState.Find(m_From);
|
||||
|
||||
MerchantTitle newTitle = (MerchantTitle)index;
|
||||
MerchantTitleInfo mti = MerchantTitles.GetInfo(newTitle);
|
||||
|
||||
if (mti == null)
|
||||
{
|
||||
m_From.SendLocalizedMessage(1010120); // Your merchant title has been removed
|
||||
|
||||
if (pl != null)
|
||||
pl.MerchantTitle = newTitle;
|
||||
}
|
||||
else if (MerchantTitles.IsQualified(m_From, mti))
|
||||
{
|
||||
m_From.SendLocalizedMessage(mti.Assigned);
|
||||
|
||||
if (pl != null)
|
||||
pl.MerchantTitle = newTitle;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 2: // transfer silver
|
||||
{
|
||||
if (!m_Faction.IsCommander(m_From))
|
||||
return;
|
||||
|
||||
List<Town> towns = Town.Towns;
|
||||
|
||||
if (index >= 0 && index < towns.Count)
|
||||
{
|
||||
Town town = towns[index];
|
||||
|
||||
if (town.Owner == m_Faction)
|
||||
{
|
||||
if (m_Faction.Silver >= 10000)
|
||||
{
|
||||
m_Faction.Silver -= 10000;
|
||||
town.Silver += 10000;
|
||||
|
||||
// 10k in silver has been received by:
|
||||
m_From.SendLocalizedMessage(1042726, true, " " + town.Definition.FriendlyName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 3: // change tithe
|
||||
{
|
||||
if (!m_Faction.IsCommander(m_From))
|
||||
return;
|
||||
|
||||
if (index >= 0 && index <= 10)
|
||||
m_Faction.Tithe = index * 10;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
284
Scripts/Services/Factions/Gumps/FinanceGump.cs
Normal file
284
Scripts/Services/Factions/Gumps/FinanceGump.cs
Normal file
@@ -0,0 +1,284 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Gumps;
|
||||
using Server.Mobiles;
|
||||
using Server.Multis;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FinanceGump : FactionGump
|
||||
{
|
||||
private readonly PlayerMobile m_From;
|
||||
private readonly Faction m_Faction;
|
||||
private readonly Town m_Town;
|
||||
|
||||
private static readonly int[] m_PriceOffsets = new int[]
|
||||
{
|
||||
-30, -25, -20, -15, -10, -5,
|
||||
+50, +100, +150, +200, +250, +300
|
||||
};
|
||||
|
||||
public override int ButtonTypes
|
||||
{
|
||||
get
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
public FinanceGump(PlayerMobile from, Faction faction, Town town)
|
||||
: base(50, 50)
|
||||
{
|
||||
this.m_From = from;
|
||||
this.m_Faction = faction;
|
||||
this.m_Town = town;
|
||||
|
||||
this.AddPage(0);
|
||||
|
||||
this.AddBackground(0, 0, 320, 410, 5054);
|
||||
this.AddBackground(10, 10, 300, 390, 3000);
|
||||
|
||||
#region General
|
||||
this.AddPage(1);
|
||||
|
||||
this.AddHtmlLocalized(20, 30, 260, 25, 1011541, false, false); // FINANCE MINISTER
|
||||
|
||||
this.AddHtmlLocalized(55, 90, 200, 25, 1011539, false, false); // CHANGE PRICES
|
||||
this.AddButton(20, 90, 4005, 4007, 0, GumpButtonType.Page, 2);
|
||||
|
||||
this.AddHtmlLocalized(55, 120, 200, 25, 1011540, false, false); // BUY SHOPKEEPERS
|
||||
this.AddButton(20, 120, 4005, 4007, 0, GumpButtonType.Page, 3);
|
||||
|
||||
this.AddHtmlLocalized(55, 150, 200, 25, 1011495, false, false); // VIEW FINANCES
|
||||
this.AddButton(20, 150, 4005, 4007, 0, GumpButtonType.Page, 4);
|
||||
|
||||
this.AddHtmlLocalized(55, 360, 200, 25, 1011441, false, false); // EXIT
|
||||
this.AddButton(20, 360, 4005, 4007, 0, GumpButtonType.Reply, 0);
|
||||
#endregion
|
||||
|
||||
#region Change Prices
|
||||
this.AddPage(2);
|
||||
|
||||
this.AddHtmlLocalized(20, 30, 200, 25, 1011539, false, false); // CHANGE PRICES
|
||||
|
||||
for (int i = 0; i < m_PriceOffsets.Length; ++i)
|
||||
{
|
||||
int ofs = m_PriceOffsets[i];
|
||||
|
||||
int x = 20 + ((i / 6) * 150);
|
||||
int y = 90 + ((i % 6) * 30);
|
||||
|
||||
this.AddRadio(x, y, 208, 209, (town.Tax == ofs), i + 1);
|
||||
|
||||
if (ofs < 0)
|
||||
this.AddLabel(x + 35, y, 0x26, String.Concat("- ", -ofs, "%"));
|
||||
else
|
||||
this.AddLabel(x + 35, y, 0x12A, String.Concat("+ ", ofs, "%"));
|
||||
}
|
||||
|
||||
this.AddRadio(20, 270, 208, 209, (town.Tax == 0), 0);
|
||||
this.AddHtmlLocalized(55, 270, 90, 25, 1011542, false, false); // normal
|
||||
|
||||
this.AddHtmlLocalized(55, 330, 200, 25, 1011509, false, false); // Set Prices
|
||||
this.AddButton(20, 330, 4005, 4007, this.ToButtonID(0, 0), GumpButtonType.Reply, 0);
|
||||
|
||||
this.AddHtmlLocalized(55, 360, 200, 25, 1011067, false, false); // Previous page
|
||||
this.AddButton(20, 360, 4005, 4007, 0, GumpButtonType.Page, 1);
|
||||
#endregion
|
||||
|
||||
#region Buy Shopkeepers
|
||||
this.AddPage(3);
|
||||
|
||||
this.AddHtmlLocalized(20, 30, 200, 25, 1011540, false, false); // BUY SHOPKEEPERS
|
||||
|
||||
List<VendorList> vendorLists = town.VendorLists;
|
||||
|
||||
for (int i = 0; i < vendorLists.Count; ++i)
|
||||
{
|
||||
VendorList list = vendorLists[i];
|
||||
|
||||
this.AddButton(20, 90 + (i * 40), 4005, 4007, 0, GumpButtonType.Page, 5 + i);
|
||||
this.AddItem(55, 90 + (i * 40), list.Definition.ItemID);
|
||||
this.AddHtmlText(100, 90 + (i * 40), 200, 25, list.Definition.Label, false, false);
|
||||
}
|
||||
|
||||
this.AddHtmlLocalized(55, 360, 200, 25, 1011067, false, false); // Previous page
|
||||
this.AddButton(20, 360, 4005, 4007, 0, GumpButtonType.Page, 1);
|
||||
#endregion
|
||||
|
||||
#region View Finances
|
||||
this.AddPage(4);
|
||||
|
||||
int financeUpkeep = town.FinanceUpkeep;
|
||||
int sheriffUpkeep = town.SheriffUpkeep;
|
||||
int dailyIncome = town.DailyIncome;
|
||||
int netCashFlow = town.NetCashFlow;
|
||||
|
||||
this.AddHtmlLocalized(20, 30, 300, 25, 1011524, false, false); // FINANCE STATEMENT
|
||||
|
||||
this.AddHtmlLocalized(20, 80, 300, 25, 1011538, false, false); // Current total money for town :
|
||||
this.AddLabel(20, 100, 0x44, town.Silver.ToString());
|
||||
|
||||
this.AddHtmlLocalized(20, 130, 300, 25, 1011520, false, false); // Finance Minister Upkeep :
|
||||
this.AddLabel(20, 150, 0x44, financeUpkeep.ToString("N0")); // NOTE: Added 'N0'
|
||||
|
||||
this.AddHtmlLocalized(20, 180, 300, 25, 1011521, false, false); // Sheriff Upkeep :
|
||||
this.AddLabel(20, 200, 0x44, sheriffUpkeep.ToString("N0")); // NOTE: Added 'N0'
|
||||
|
||||
this.AddHtmlLocalized(20, 230, 300, 25, 1011522, false, false); // Town Income :
|
||||
this.AddLabel(20, 250, 0x44, dailyIncome.ToString("N0")); // NOTE: Added 'N0'
|
||||
|
||||
this.AddHtmlLocalized(20, 280, 300, 25, 1011523, false, false); // Net Cash flow per day :
|
||||
this.AddLabel(20, 300, 0x44, netCashFlow.ToString("N0")); // NOTE: Added 'N0'
|
||||
|
||||
this.AddHtmlLocalized(55, 360, 200, 25, 1011067, false, false); // Previous page
|
||||
this.AddButton(20, 360, 4005, 4007, 0, GumpButtonType.Page, 1);
|
||||
#endregion
|
||||
|
||||
#region Shopkeeper Pages
|
||||
for (int i = 0; i < vendorLists.Count; ++i)
|
||||
{
|
||||
VendorList vendorList = vendorLists[i];
|
||||
|
||||
this.AddPage(5 + i);
|
||||
|
||||
this.AddHtmlText(60, 30, 300, 25, vendorList.Definition.Header, false, false);
|
||||
this.AddItem(20, 30, vendorList.Definition.ItemID);
|
||||
|
||||
this.AddHtmlLocalized(20, 90, 200, 25, 1011514, false, false); // You have :
|
||||
this.AddLabel(230, 90, 0x26, vendorList.Vendors.Count.ToString());
|
||||
|
||||
this.AddHtmlLocalized(20, 120, 200, 25, 1011515, false, false); // Maximum :
|
||||
this.AddLabel(230, 120, 0x256, vendorList.Definition.Maximum.ToString());
|
||||
|
||||
this.AddHtmlLocalized(20, 150, 200, 25, 1011516, false, false); // Cost :
|
||||
this.AddLabel(230, 150, 0x44, vendorList.Definition.Price.ToString("N0")); // NOTE: Added 'N0'
|
||||
|
||||
this.AddHtmlLocalized(20, 180, 200, 25, 1011517, false, false); // Daily Pay :
|
||||
this.AddLabel(230, 180, 0x37, vendorList.Definition.Upkeep.ToString("N0")); // NOTE: Added 'N0'
|
||||
|
||||
this.AddHtmlLocalized(20, 210, 200, 25, 1011518, false, false); // Current Silver :
|
||||
this.AddLabel(230, 210, 0x44, town.Silver.ToString("N0")); // NOTE: Added 'N0'
|
||||
|
||||
this.AddHtmlLocalized(20, 240, 200, 25, 1011519, false, false); // Current Payroll :
|
||||
this.AddLabel(230, 240, 0x44, financeUpkeep.ToString("N0")); // NOTE: Added 'N0'
|
||||
|
||||
this.AddHtmlText(55, 300, 200, 25, vendorList.Definition.Label, false, false);
|
||||
if (town.Silver >= vendorList.Definition.Price)
|
||||
this.AddButton(20, 300, 4005, 4007, this.ToButtonID(1, i), GumpButtonType.Reply, 0);
|
||||
else
|
||||
this.AddImage(20, 300, 4020);
|
||||
|
||||
this.AddHtmlLocalized(55, 360, 200, 25, 1011067, false, false); // Previous page
|
||||
this.AddButton(20, 360, 4005, 4007, 0, GumpButtonType.Page, 3);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
if (!this.m_Town.IsFinance(this.m_From) || this.m_Town.Owner != this.m_Faction)
|
||||
{
|
||||
this.m_From.SendLocalizedMessage(1010339); // You no longer control this city
|
||||
return;
|
||||
}
|
||||
|
||||
int type, index;
|
||||
|
||||
if (!this.FromButtonID(info.ButtonID, out type, out index))
|
||||
return;
|
||||
|
||||
switch ( type )
|
||||
{
|
||||
case 0: // general
|
||||
{
|
||||
switch ( index )
|
||||
{
|
||||
case 0: // set price
|
||||
{
|
||||
int[] switches = info.Switches;
|
||||
|
||||
if (switches.Length == 0)
|
||||
break;
|
||||
|
||||
int opt = switches[0];
|
||||
int newTax = 0;
|
||||
|
||||
if (opt >= 1 && opt <= m_PriceOffsets.Length)
|
||||
newTax = m_PriceOffsets[opt - 1];
|
||||
|
||||
if (this.m_Town.Tax == newTax)
|
||||
break;
|
||||
|
||||
if (this.m_From.IsPlayer() && !this.m_Town.TaxChangeReady)
|
||||
{
|
||||
TimeSpan remaining = DateTime.UtcNow - (this.m_Town.LastTaxChange + Town.TaxChangePeriod);
|
||||
|
||||
if (remaining.TotalMinutes < 4)
|
||||
this.m_From.SendLocalizedMessage(1042165); // You must wait a short while before changing prices again.
|
||||
else if (remaining.TotalMinutes < 10)
|
||||
this.m_From.SendLocalizedMessage(1042166); // You must wait several minutes before changing prices again.
|
||||
else if (remaining.TotalHours < 1)
|
||||
this.m_From.SendLocalizedMessage(1042167); // You must wait up to an hour before changing prices again.
|
||||
else if (remaining.TotalHours < 4)
|
||||
this.m_From.SendLocalizedMessage(1042168); // You must wait a few hours before changing prices again.
|
||||
else
|
||||
this.m_From.SendLocalizedMessage(1042169); // You must wait several hours before changing prices again.
|
||||
}
|
||||
else
|
||||
{
|
||||
this.m_Town.Tax = newTax;
|
||||
|
||||
if (this.m_From.IsPlayer())
|
||||
this.m_Town.LastTaxChange = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 1: // make vendor
|
||||
{
|
||||
List<VendorList> vendorLists = this.m_Town.VendorLists;
|
||||
|
||||
if (index >= 0 && index < vendorLists.Count)
|
||||
{
|
||||
VendorList vendorList = vendorLists[index];
|
||||
|
||||
Town town = Town.FromRegion(this.m_From.Region);
|
||||
|
||||
if (Town.FromRegion(this.m_From.Region) != this.m_Town)
|
||||
{
|
||||
this.m_From.SendLocalizedMessage(1010305); // You must be in your controlled city to buy Items
|
||||
}
|
||||
else if (vendorList.Vendors.Count >= vendorList.Definition.Maximum)
|
||||
{
|
||||
this.m_From.SendLocalizedMessage(1010306); // You currently have too many of this enhancement type to place another
|
||||
}
|
||||
else if (BaseBoat.FindBoatAt(this.m_From.Location, this.m_From.Map) != null)
|
||||
{
|
||||
this.m_From.SendMessage("You cannot place a vendor here");
|
||||
}
|
||||
else if (this.m_Town.Silver >= vendorList.Definition.Price)
|
||||
{
|
||||
BaseFactionVendor vendor = vendorList.Construct(this.m_Town, this.m_Faction);
|
||||
|
||||
if (vendor != null)
|
||||
{
|
||||
this.m_Town.Silver -= vendorList.Definition.Price;
|
||||
|
||||
vendor.MoveToWorld(this.m_From.Location, this.m_From.Map);
|
||||
vendor.Home = vendor.Location;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
91
Scripts/Services/Factions/Gumps/HorseBreederGump.cs
Normal file
91
Scripts/Services/Factions/Gumps/HorseBreederGump.cs
Normal file
@@ -0,0 +1,91 @@
|
||||
using System;
|
||||
using Server.Gumps;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class HorseBreederGump : FactionGump
|
||||
{
|
||||
private readonly PlayerMobile m_From;
|
||||
private readonly Faction m_Faction;
|
||||
public HorseBreederGump(PlayerMobile from, Faction faction)
|
||||
: base(20, 30)
|
||||
{
|
||||
this.m_From = from;
|
||||
this.m_Faction = faction;
|
||||
|
||||
this.AddPage(0);
|
||||
|
||||
this.AddBackground(0, 0, 320, 280, 5054);
|
||||
this.AddBackground(10, 10, 300, 260, 3000);
|
||||
|
||||
this.AddHtmlText(20, 30, 300, 25, faction.Definition.Header, false, false);
|
||||
|
||||
this.AddHtmlLocalized(20, 60, 300, 25, 1018306, false, false); // Purchase a Faction War Horse
|
||||
this.AddItem(70, 120, 0x3FFE);
|
||||
|
||||
this.AddItem(150, 120, 0xEF2);
|
||||
this.AddLabel(190, 122, 0x3E3, FactionWarHorse.SilverPrice.ToString("N0")); // NOTE: Added 'N0'
|
||||
|
||||
this.AddItem(150, 150, 0xEEF);
|
||||
this.AddLabel(190, 152, 0x3E3, FactionWarHorse.GoldPrice.ToString("N0")); // NOTE: Added 'N0'
|
||||
|
||||
this.AddHtmlLocalized(55, 210, 200, 25, 1011011, false, false); // CONTINUE
|
||||
this.AddButton(20, 210, 4005, 4007, 1, GumpButtonType.Reply, 0);
|
||||
|
||||
this.AddHtmlLocalized(55, 240, 200, 25, 1011012, false, false); // CANCEL
|
||||
this.AddButton(20, 240, 4005, 4007, 0, GumpButtonType.Reply, 0);
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
if (info.ButtonID != 1)
|
||||
return;
|
||||
|
||||
if (Faction.Find(this.m_From) != this.m_Faction)
|
||||
return;
|
||||
|
||||
Container pack = this.m_From.Backpack;
|
||||
|
||||
if (pack == null)
|
||||
return;
|
||||
|
||||
FactionWarHorse horse = new FactionWarHorse(this.m_Faction);
|
||||
|
||||
if ((this.m_From.Followers + horse.ControlSlots) > this.m_From.FollowersMax)
|
||||
{
|
||||
// TODO: Message?
|
||||
horse.Delete();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pack.GetAmount(typeof(Silver)) < FactionWarHorse.SilverPrice)
|
||||
{
|
||||
sender.Mobile.SendLocalizedMessage(1042204); // You do not have enough silver.
|
||||
horse.Delete();
|
||||
}
|
||||
else if (pack.GetAmount(typeof(Gold)) < FactionWarHorse.GoldPrice)
|
||||
{
|
||||
sender.Mobile.SendLocalizedMessage(1042205); // You do not have enough gold.
|
||||
horse.Delete();
|
||||
}
|
||||
else if (pack.ConsumeTotal(typeof(Silver), FactionWarHorse.SilverPrice) && pack.ConsumeTotal(typeof(Gold), FactionWarHorse.GoldPrice))
|
||||
{
|
||||
horse.Controlled = true;
|
||||
horse.ControlMaster = this.m_From;
|
||||
|
||||
horse.ControlOrder = OrderType.Follow;
|
||||
horse.ControlTarget = this.m_From;
|
||||
|
||||
horse.MoveToWorld(this.m_From.Location, this.m_From.Map);
|
||||
}
|
||||
else
|
||||
{
|
||||
horse.Delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
48
Scripts/Services/Factions/Gumps/JoinStoneGump.cs
Normal file
48
Scripts/Services/Factions/Gumps/JoinStoneGump.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using Server.Gumps;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class JoinStoneGump : FactionGump
|
||||
{
|
||||
private readonly PlayerMobile m_From;
|
||||
private readonly Faction m_Faction;
|
||||
public JoinStoneGump(PlayerMobile from, Faction faction)
|
||||
: base(20, 30)
|
||||
{
|
||||
this.m_From = from;
|
||||
this.m_Faction = faction;
|
||||
|
||||
this.AddPage(0);
|
||||
|
||||
this.AddBackground(0, 0, 550, 440, 5054);
|
||||
this.AddBackground(10, 10, 530, 420, 3000);
|
||||
|
||||
this.AddHtmlText(20, 30, 510, 20, faction.Definition.Header, false, false);
|
||||
this.AddHtmlText(20, 130, 510, 100, faction.Definition.About, true, true);
|
||||
|
||||
this.AddHtmlLocalized(20, 60, 100, 20, 1011429, false, false); // Led By :
|
||||
this.AddHtml(125, 60, 200, 20, faction.Commander != null ? faction.Commander.Name : "Nobody", false, false);
|
||||
|
||||
this.AddHtmlLocalized(20, 80, 100, 20, 1011457, false, false); // Tithe rate :
|
||||
if (faction.Tithe >= 0 && faction.Tithe <= 100 && (faction.Tithe % 10) == 0)
|
||||
this.AddHtmlLocalized(125, 80, 350, 20, 1011480 + (faction.Tithe / 10), false, false);
|
||||
else
|
||||
this.AddHtml(125, 80, 350, 20, faction.Tithe + "%", false, false);
|
||||
|
||||
this.AddButton(20, 400, 4005, 4007, 1, GumpButtonType.Reply, 0);
|
||||
this.AddHtmlLocalized(55, 400, 200, 20, 1011425, false, false); // JOIN THIS FACTION
|
||||
|
||||
this.AddButton(300, 400, 4005, 4007, 0, GumpButtonType.Reply, 0);
|
||||
this.AddHtmlLocalized(335, 400, 200, 20, 1011012, false, false); // CANCEL
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
if (info.ButtonID == 1)
|
||||
this.m_Faction.OnJoinAccepted(this.m_From);
|
||||
}
|
||||
}
|
||||
}
|
||||
91
Scripts/Services/Factions/Gumps/LeaveFactionGump.cs
Normal file
91
Scripts/Services/Factions/Gumps/LeaveFactionGump.cs
Normal file
@@ -0,0 +1,91 @@
|
||||
using System;
|
||||
using Server.Guilds;
|
||||
using Server.Gumps;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class LeaveFactionGump : FactionGump
|
||||
{
|
||||
private readonly PlayerMobile m_From;
|
||||
private readonly Faction m_Faction;
|
||||
public LeaveFactionGump(PlayerMobile from, Faction faction)
|
||||
: base(20, 30)
|
||||
{
|
||||
this.m_From = from;
|
||||
this.m_Faction = faction;
|
||||
|
||||
this.AddBackground(0, 0, 270, 120, 5054);
|
||||
this.AddBackground(10, 10, 250, 100, 3000);
|
||||
|
||||
if (from.Guild is Guild && ((Guild)from.Guild).Leader == from)
|
||||
this.AddHtmlLocalized(20, 15, 230, 60, 1018057, true, true); // Are you sure you want your entire guild to leave this faction?
|
||||
else
|
||||
this.AddHtmlLocalized(20, 15, 230, 60, 1018063, true, true); // Are you sure you want to leave this faction?
|
||||
|
||||
this.AddHtmlLocalized(55, 80, 75, 20, 1011011, false, false); // CONTINUE
|
||||
this.AddButton(20, 80, 4005, 4007, 1, GumpButtonType.Reply, 0);
|
||||
|
||||
this.AddHtmlLocalized(170, 80, 75, 20, 1011012, false, false); // CANCEL
|
||||
this.AddButton(135, 80, 4005, 4007, 2, GumpButtonType.Reply, 0);
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
switch ( info.ButtonID )
|
||||
{
|
||||
case 1: // continue
|
||||
{
|
||||
Guild guild = this.m_From.Guild as Guild;
|
||||
|
||||
if (guild == null)
|
||||
{
|
||||
PlayerState pl = PlayerState.Find(this.m_From);
|
||||
|
||||
if (pl != null)
|
||||
{
|
||||
pl.Leaving = DateTime.UtcNow;
|
||||
|
||||
if (Faction.LeavePeriod == TimeSpan.FromDays(3.0))
|
||||
this.m_From.SendLocalizedMessage(1005065); // You will be removed from the faction in 3 days
|
||||
else
|
||||
this.m_From.SendMessage("You will be removed from the faction in {0} days.", Faction.LeavePeriod.TotalDays);
|
||||
}
|
||||
}
|
||||
else if (guild.Leader != this.m_From)
|
||||
{
|
||||
this.m_From.SendLocalizedMessage(1005061); // You cannot quit the faction because you are not the guild master
|
||||
}
|
||||
else
|
||||
{
|
||||
this.m_From.SendLocalizedMessage(1042285); // Your guild is now quitting the faction.
|
||||
|
||||
for (int i = 0; i < guild.Members.Count; ++i)
|
||||
{
|
||||
Mobile mob = (Mobile)guild.Members[i];
|
||||
PlayerState pl = PlayerState.Find(mob);
|
||||
|
||||
if (pl != null)
|
||||
{
|
||||
pl.Leaving = DateTime.UtcNow;
|
||||
|
||||
if (Faction.LeavePeriod == TimeSpan.FromDays(3.0))
|
||||
mob.SendLocalizedMessage(1005060); // Your guild will quit the faction in 3 days
|
||||
else
|
||||
mob.SendMessage("Your guild will quit the faction in {0} days.", Faction.LeavePeriod.TotalDays);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 2: // cancel
|
||||
{
|
||||
this.m_From.SendLocalizedMessage(500737); // Canceled resignation.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
181
Scripts/Services/Factions/Gumps/SheriffGump.cs
Normal file
181
Scripts/Services/Factions/Gumps/SheriffGump.cs
Normal file
@@ -0,0 +1,181 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Gumps;
|
||||
using Server.Mobiles;
|
||||
using Server.Multis;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class SheriffGump : FactionGump
|
||||
{
|
||||
private readonly PlayerMobile m_From;
|
||||
private readonly Faction m_Faction;
|
||||
private readonly Town m_Town;
|
||||
|
||||
private void CenterItem(int itemID, int x, int y, int w, int h)
|
||||
{
|
||||
Rectangle2D rc = ItemBounds.Table[itemID];
|
||||
this.AddItem(x + ((w - rc.Width) / 2) - rc.X, y + ((h - rc.Height) / 2) - rc.Y, itemID);
|
||||
}
|
||||
|
||||
public SheriffGump(PlayerMobile from, Faction faction, Town town)
|
||||
: base(50, 50)
|
||||
{
|
||||
this.m_From = from;
|
||||
this.m_Faction = faction;
|
||||
this.m_Town = town;
|
||||
|
||||
this.AddPage(0);
|
||||
|
||||
this.AddBackground(0, 0, 320, 410, 5054);
|
||||
this.AddBackground(10, 10, 300, 390, 3000);
|
||||
|
||||
#region General
|
||||
this.AddPage(1);
|
||||
|
||||
this.AddHtmlLocalized(20, 30, 260, 25, 1011431, false, false); // Sheriff
|
||||
|
||||
this.AddHtmlLocalized(55, 90, 200, 25, 1011494, false, false); // HIRE GUARDS
|
||||
this.AddButton(20, 90, 4005, 4007, 0, GumpButtonType.Page, 3);
|
||||
|
||||
this.AddHtmlLocalized(55, 120, 200, 25, 1011495, false, false); // VIEW FINANCES
|
||||
this.AddButton(20, 120, 4005, 4007, 0, GumpButtonType.Page, 2);
|
||||
|
||||
this.AddHtmlLocalized(55, 360, 200, 25, 1011441, false, false); // Exit
|
||||
this.AddButton(20, 360, 4005, 4007, 0, GumpButtonType.Reply, 0);
|
||||
#endregion
|
||||
|
||||
#region Finances
|
||||
this.AddPage(2);
|
||||
|
||||
int financeUpkeep = town.FinanceUpkeep;
|
||||
int sheriffUpkeep = town.SheriffUpkeep;
|
||||
int dailyIncome = town.DailyIncome;
|
||||
int netCashFlow = town.NetCashFlow;
|
||||
|
||||
this.AddHtmlLocalized(20, 30, 300, 25, 1011524, false, false); // FINANCE STATEMENT
|
||||
|
||||
this.AddHtmlLocalized(20, 80, 300, 25, 1011538, false, false); // Current total money for town :
|
||||
this.AddLabel(20, 100, 0x44, town.Silver.ToString("N0")); // NOTE: Added 'N0'
|
||||
|
||||
this.AddHtmlLocalized(20, 130, 300, 25, 1011520, false, false); // Finance Minister Upkeep :
|
||||
this.AddLabel(20, 150, 0x44, financeUpkeep.ToString("N0")); // NOTE: Added 'N0'
|
||||
|
||||
this.AddHtmlLocalized(20, 180, 300, 25, 1011521, false, false); // Sheriff Upkeep :
|
||||
this.AddLabel(20, 200, 0x44, sheriffUpkeep.ToString("N0")); // NOTE: Added 'N0'
|
||||
|
||||
this.AddHtmlLocalized(20, 230, 300, 25, 1011522, false, false); // Town Income :
|
||||
this.AddLabel(20, 250, 0x44, dailyIncome.ToString("N0")); // NOTE: Added 'N0'
|
||||
|
||||
this.AddHtmlLocalized(20, 280, 300, 25, 1011523, false, false); // Net Cash flow per day :
|
||||
this.AddLabel(20, 300, 0x44, netCashFlow.ToString("N0")); // NOTE: Added 'N0'
|
||||
|
||||
this.AddHtmlLocalized(55, 360, 200, 25, 1011067, false, false); // Previous page
|
||||
this.AddButton(20, 360, 4005, 4007, 0, GumpButtonType.Page, 1);
|
||||
#endregion
|
||||
|
||||
#region Hire Guards
|
||||
this.AddPage(3);
|
||||
|
||||
this.AddHtmlLocalized(20, 30, 300, 25, 1011494, false, false); // HIRE GUARDS
|
||||
|
||||
List<GuardList> guardLists = town.GuardLists;
|
||||
|
||||
for (int i = 0; i < guardLists.Count; ++i)
|
||||
{
|
||||
GuardList guardList = guardLists[i];
|
||||
int y = 90 + (i * 60);
|
||||
|
||||
this.AddButton(20, y, 4005, 4007, 0, GumpButtonType.Page, 4 + i);
|
||||
this.CenterItem(guardList.Definition.ItemID, 50, y - 20, 70, 60);
|
||||
this.AddHtmlText(120, y, 200, 25, guardList.Definition.Header, false, false);
|
||||
}
|
||||
|
||||
this.AddHtmlLocalized(55, 360, 200, 25, 1011067, false, false); // Previous page
|
||||
this.AddButton(20, 360, 4005, 4007, 0, GumpButtonType.Page, 1);
|
||||
#endregion
|
||||
|
||||
#region Guard Pages
|
||||
for (int i = 0; i < guardLists.Count; ++i)
|
||||
{
|
||||
GuardList guardList = guardLists[i];
|
||||
|
||||
this.AddPage(4 + i);
|
||||
|
||||
this.AddHtmlText(90, 30, 300, 25, guardList.Definition.Header, false, false);
|
||||
this.CenterItem(guardList.Definition.ItemID, 10, 10, 80, 80);
|
||||
|
||||
this.AddHtmlLocalized(20, 90, 200, 25, 1011514, false, false); // You have :
|
||||
this.AddLabel(230, 90, 0x26, guardList.Guards.Count.ToString());
|
||||
|
||||
this.AddHtmlLocalized(20, 120, 200, 25, 1011515, false, false); // Maximum :
|
||||
this.AddLabel(230, 120, 0x12A, guardList.Definition.Maximum.ToString());
|
||||
|
||||
this.AddHtmlLocalized(20, 150, 200, 25, 1011516, false, false); // Cost :
|
||||
this.AddLabel(230, 150, 0x44, guardList.Definition.Price.ToString("N0")); // NOTE: Added 'N0'
|
||||
|
||||
this.AddHtmlLocalized(20, 180, 200, 25, 1011517, false, false); // Daily Pay :
|
||||
this.AddLabel(230, 180, 0x37, guardList.Definition.Upkeep.ToString("N0")); // NOTE: Added 'N0'
|
||||
|
||||
this.AddHtmlLocalized(20, 210, 200, 25, 1011518, false, false); // Current Silver :
|
||||
this.AddLabel(230, 210, 0x44, town.Silver.ToString("N0")); // NOTE: Added 'N0'
|
||||
|
||||
this.AddHtmlLocalized(20, 240, 200, 25, 1011519, false, false); // Current Payroll :
|
||||
this.AddLabel(230, 240, 0x44, sheriffUpkeep.ToString("N0")); // NOTE: Added 'N0'
|
||||
|
||||
this.AddHtmlText(55, 300, 200, 25, guardList.Definition.Label, false, false);
|
||||
this.AddButton(20, 300, 4005, 4007, 1 + i, GumpButtonType.Reply, 0);
|
||||
|
||||
this.AddHtmlLocalized(55, 360, 200, 25, 1011067, false, false); // Previous page
|
||||
this.AddButton(20, 360, 4005, 4007, 0, GumpButtonType.Page, 3);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
if (!this.m_Town.IsSheriff(this.m_From) || this.m_Town.Owner != this.m_Faction)
|
||||
{
|
||||
this.m_From.SendLocalizedMessage(1010339); // You no longer control this city
|
||||
return;
|
||||
}
|
||||
|
||||
int index = info.ButtonID - 1;
|
||||
|
||||
if (index >= 0 && index < this.m_Town.GuardLists.Count)
|
||||
{
|
||||
GuardList guardList = this.m_Town.GuardLists[index];
|
||||
Town town = Town.FromRegion(this.m_From.Region);
|
||||
|
||||
if (Town.FromRegion(this.m_From.Region) != this.m_Town)
|
||||
{
|
||||
this.m_From.SendLocalizedMessage(1010305); // You must be in your controlled city to buy Items
|
||||
}
|
||||
else if (guardList.Guards.Count >= guardList.Definition.Maximum)
|
||||
{
|
||||
this.m_From.SendLocalizedMessage(1010306); // You currently have too many of this enhancement type to place another
|
||||
}
|
||||
else if (BaseBoat.FindBoatAt(this.m_From.Location, this.m_From.Map) != null)
|
||||
{
|
||||
this.m_From.SendMessage("You cannot place a guard here");
|
||||
}
|
||||
else if (this.m_Town.Silver >= guardList.Definition.Price)
|
||||
{
|
||||
BaseFactionGuard guard = guardList.Construct();
|
||||
|
||||
if (guard != null)
|
||||
{
|
||||
guard.Faction = this.m_Faction;
|
||||
guard.Town = this.m_Town;
|
||||
|
||||
this.m_Town.Silver -= guardList.Definition.Price;
|
||||
|
||||
guard.MoveToWorld(this.m_From.Location, this.m_From.Map);
|
||||
guard.Home = guard.Location;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
205
Scripts/Services/Factions/Gumps/TownStoneGump.cs
Normal file
205
Scripts/Services/Factions/Gumps/TownStoneGump.cs
Normal file
@@ -0,0 +1,205 @@
|
||||
using System;
|
||||
using Server.Gumps;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
using Server.Targeting;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class TownStoneGump : FactionGump
|
||||
{
|
||||
private readonly PlayerMobile m_From;
|
||||
private readonly Faction m_Faction;
|
||||
private readonly Town m_Town;
|
||||
public TownStoneGump(PlayerMobile from, Faction faction, Town town)
|
||||
: base(50, 50)
|
||||
{
|
||||
this.m_From = from;
|
||||
this.m_Faction = faction;
|
||||
this.m_Town = town;
|
||||
|
||||
this.AddPage(0);
|
||||
|
||||
this.AddBackground(0, 0, 320, 250, 5054);
|
||||
this.AddBackground(10, 10, 300, 230, 3000);
|
||||
|
||||
this.AddHtmlText(25, 30, 250, 25, town.Definition.TownStoneHeader, false, false);
|
||||
|
||||
this.AddHtmlLocalized(55, 60, 150, 25, 1011557, false, false); // Hire Sheriff
|
||||
this.AddButton(20, 60, 4005, 4007, 1, GumpButtonType.Reply, 0);
|
||||
|
||||
this.AddHtmlLocalized(55, 90, 150, 25, 1011559, false, false); // Hire Finance Minister
|
||||
this.AddButton(20, 90, 4005, 4007, 2, GumpButtonType.Reply, 0);
|
||||
|
||||
this.AddHtmlLocalized(55, 120, 150, 25, 1011558, false, false); // Fire Sheriff
|
||||
this.AddButton(20, 120, 4005, 4007, 3, GumpButtonType.Reply, 0);
|
||||
|
||||
this.AddHtmlLocalized(55, 150, 150, 25, 1011560, false, false); // Fire Finance Minister
|
||||
this.AddButton(20, 150, 4005, 4007, 4, GumpButtonType.Reply, 0);
|
||||
|
||||
this.AddHtmlLocalized(55, 210, 150, 25, 1011441, false, false); // EXIT
|
||||
this.AddButton(20, 210, 4005, 4007, 0, GumpButtonType.Reply, 0);
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
if (this.m_Town.Owner != this.m_Faction || !this.m_Faction.IsCommander(this.m_From))
|
||||
{
|
||||
this.m_From.SendLocalizedMessage(1010339); // You no longer control this city
|
||||
return;
|
||||
}
|
||||
|
||||
switch ( info.ButtonID )
|
||||
{
|
||||
case 1: // hire sheriff
|
||||
{
|
||||
if (this.m_Town.Sheriff != null)
|
||||
{
|
||||
this.m_From.SendLocalizedMessage(1010342); // You must fire your Sheriff before you can elect a new one
|
||||
}
|
||||
else
|
||||
{
|
||||
this.m_From.SendLocalizedMessage(1010347); // Who shall be your new sheriff
|
||||
this.m_From.BeginTarget(12, false, TargetFlags.None, new TargetCallback(HireSheriff_OnTarget));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 2: // hire finance minister
|
||||
{
|
||||
if (this.m_Town.Finance != null)
|
||||
{
|
||||
this.m_From.SendLocalizedMessage(1010345); // You must fire your finance minister before you can elect a new one
|
||||
}
|
||||
else
|
||||
{
|
||||
this.m_From.SendLocalizedMessage(1010348); // Who shall be your new Minister of Finances?
|
||||
this.m_From.BeginTarget(12, false, TargetFlags.None, new TargetCallback(HireFinanceMinister_OnTarget));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 3: // fire sheriff
|
||||
{
|
||||
if (this.m_Town.Sheriff == null)
|
||||
{
|
||||
this.m_From.SendLocalizedMessage(1010350); // You need to elect a sheriff before you can fire one
|
||||
}
|
||||
else
|
||||
{
|
||||
this.m_From.SendLocalizedMessage(1010349); // You have fired your sheriff
|
||||
this.m_Town.Sheriff.SendLocalizedMessage(1010270); // You have been fired as Sheriff
|
||||
this.m_Town.Sheriff = null;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 4: // fire finance minister
|
||||
{
|
||||
if (this.m_Town.Finance == null)
|
||||
{
|
||||
this.m_From.SendLocalizedMessage(1010352); // You need to elect a financial minister before you can fire one
|
||||
}
|
||||
else
|
||||
{
|
||||
this.m_From.SendLocalizedMessage(1010351); // You have fired your financial Minister
|
||||
this.m_Town.Finance.SendLocalizedMessage(1010151); // You have been fired as Finance Minister
|
||||
this.m_Town.Finance = null;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void HireSheriff_OnTarget(Mobile from, object obj)
|
||||
{
|
||||
if (this.m_Town.Owner != this.m_Faction || !this.m_Faction.IsCommander(from))
|
||||
{
|
||||
from.SendLocalizedMessage(1010339); // You no longer control this city
|
||||
return;
|
||||
}
|
||||
else if (this.m_Town.Sheriff != null)
|
||||
{
|
||||
from.SendLocalizedMessage(1010342); // You must fire your Sheriff before you can elect a new one
|
||||
}
|
||||
else if (obj is Mobile)
|
||||
{
|
||||
Mobile targ = (Mobile)obj;
|
||||
PlayerState pl = PlayerState.Find(targ);
|
||||
|
||||
if (pl == null)
|
||||
{
|
||||
from.SendLocalizedMessage(1010337); // You must pick someone in a faction
|
||||
}
|
||||
else if (pl.Faction != this.m_Faction)
|
||||
{
|
||||
from.SendLocalizedMessage(1010338); // You must pick someone in the correct faction
|
||||
}
|
||||
else if (this.m_Faction.Commander == targ)
|
||||
{
|
||||
from.SendLocalizedMessage(1010335); // You cannot elect a commander to a town position
|
||||
}
|
||||
else if (pl.Sheriff != null || pl.Finance != null)
|
||||
{
|
||||
from.SendLocalizedMessage(1005245); // You must pick someone who does not already hold a city post
|
||||
}
|
||||
else
|
||||
{
|
||||
this.m_Town.Sheriff = targ;
|
||||
targ.SendLocalizedMessage(1010340); // You are now the Sheriff
|
||||
from.SendLocalizedMessage(1010341); // You have elected a Sheriff
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(1010334); // You must select a player to hold a city position!
|
||||
}
|
||||
}
|
||||
|
||||
private void HireFinanceMinister_OnTarget(Mobile from, object obj)
|
||||
{
|
||||
if (this.m_Town.Owner != this.m_Faction || !this.m_Faction.IsCommander(from))
|
||||
{
|
||||
from.SendLocalizedMessage(1010339); // You no longer control this city
|
||||
return;
|
||||
}
|
||||
else if (this.m_Town.Finance != null)
|
||||
{
|
||||
from.SendLocalizedMessage(1010342); // You must fire your Sheriff before you can elect a new one
|
||||
}
|
||||
else if (obj is Mobile)
|
||||
{
|
||||
Mobile targ = (Mobile)obj;
|
||||
PlayerState pl = PlayerState.Find(targ);
|
||||
|
||||
if (pl == null)
|
||||
{
|
||||
from.SendLocalizedMessage(1010337); // You must pick someone in a faction
|
||||
}
|
||||
else if (pl.Faction != this.m_Faction)
|
||||
{
|
||||
from.SendLocalizedMessage(1010338); // You must pick someone in the correct faction
|
||||
}
|
||||
else if (this.m_Faction.Commander == targ)
|
||||
{
|
||||
from.SendLocalizedMessage(1010335); // You cannot elect a commander to a town position
|
||||
}
|
||||
else if (pl.Sheriff != null || pl.Finance != null)
|
||||
{
|
||||
from.SendLocalizedMessage(1005245); // You must pick someone who does not already hold a city post
|
||||
}
|
||||
else
|
||||
{
|
||||
this.m_Town.Finance = targ;
|
||||
targ.SendLocalizedMessage(1010343); // You are now the Financial Minister
|
||||
from.SendLocalizedMessage(1010344); // You have elected a Financial Minister
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(1010334); // You must select a player to hold a city position!
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
67
Scripts/Services/Factions/Gumps/VoteGump.cs
Normal file
67
Scripts/Services/Factions/Gumps/VoteGump.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using System;
|
||||
using Server.Gumps;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class VoteGump : FactionGump
|
||||
{
|
||||
private readonly PlayerMobile m_From;
|
||||
private readonly Election m_Election;
|
||||
public VoteGump(PlayerMobile from, Election election)
|
||||
: base(50, 50)
|
||||
{
|
||||
this.m_From = from;
|
||||
this.m_Election = election;
|
||||
|
||||
bool canVote = election.CanVote(from);
|
||||
|
||||
this.AddPage(0);
|
||||
|
||||
this.AddBackground(0, 0, 420, 350, 5054);
|
||||
this.AddBackground(10, 10, 400, 330, 3000);
|
||||
|
||||
this.AddHtmlText(20, 20, 380, 20, election.Faction.Definition.Header, false, false);
|
||||
|
||||
if (canVote)
|
||||
this.AddHtmlLocalized(20, 60, 380, 20, 1011428, false, false); // VOTE FOR LEADERSHIP
|
||||
else
|
||||
this.AddHtmlLocalized(20, 60, 380, 20, 1038032, false, false); // You have already voted in this election.
|
||||
|
||||
for (int i = 0; i < election.Candidates.Count; ++i)
|
||||
{
|
||||
Candidate cd = election.Candidates[i];
|
||||
|
||||
if (canVote)
|
||||
this.AddButton(20, 100 + (i * 20), 4005, 4007, i + 1, GumpButtonType.Reply, 0);
|
||||
|
||||
this.AddLabel(55, 100 + (i * 20), 0, cd.Mobile.Name);
|
||||
this.AddLabel(300, 100 + (i * 20), 0, cd.Votes.ToString());
|
||||
}
|
||||
|
||||
this.AddButton(20, 310, 4005, 4007, 0, GumpButtonType.Reply, 0);
|
||||
this.AddHtmlLocalized(55, 310, 100, 20, 1011012, false, false); // CANCEL
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
if (info.ButtonID == 0)
|
||||
{
|
||||
this.m_From.SendGump(new FactionStoneGump(this.m_From, this.m_Election.Faction));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!this.m_Election.CanVote(this.m_From))
|
||||
return;
|
||||
|
||||
int index = info.ButtonID - 1;
|
||||
|
||||
if (index >= 0 && index < this.m_Election.Candidates.Count)
|
||||
this.m_Election.Candidates[index].Voters.Add(new Voter(this.m_From, this.m_Election.Candidates[index].Mobile));
|
||||
|
||||
this.m_From.SendGump(new VoteGump(this.m_From, this.m_Election));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
113
Scripts/Services/Factions/Instances/Factions/CouncilOfMages.cs
Normal file
113
Scripts/Services/Factions/Instances/Factions/CouncilOfMages.cs
Normal file
@@ -0,0 +1,113 @@
|
||||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class CouncilOfMages : Faction
|
||||
{
|
||||
private static Faction m_Instance;
|
||||
public CouncilOfMages()
|
||||
{
|
||||
m_Instance = this;
|
||||
|
||||
this.Definition =
|
||||
new FactionDefinition(
|
||||
1,
|
||||
1325, // blue
|
||||
1310, // bluish white
|
||||
1325, // join stone : blue
|
||||
1325, // broadcast : blue
|
||||
0x77, 0x3EB1, // war horse
|
||||
"Council of Mages", "council", "CoM",
|
||||
new TextDefinition(1011535, "COUNCIL OF MAGES"),
|
||||
new TextDefinition(1060770, "Council of Mages faction"),
|
||||
new TextDefinition(1011422, "<center>COUNCIL OF MAGES</center>"),
|
||||
new TextDefinition(1011449,
|
||||
"The council of Mages have their roots in the city of Moonglow, where " +
|
||||
"they once convened. They began as a small movement, dedicated to " +
|
||||
"calling forth the Stranger, who saved the lands once before. A " +
|
||||
"series of war and murders and misbegotten trials by those loyal to " +
|
||||
"Lord British has caused the group to take up the banner of war."),
|
||||
new TextDefinition(1011455, "This city is controlled by the Council of Mages."),
|
||||
new TextDefinition(1042253, "This sigil has been corrupted by the Council of Mages"),
|
||||
new TextDefinition(1041044, "The faction signup stone for the Council of Mages"),
|
||||
new TextDefinition(1041382, "The Faction Stone of the Council of Mages"),
|
||||
new TextDefinition(1011464, ": Council of Mages"),
|
||||
new TextDefinition(1005187, "Members of the Council of Mages will now be ignored."),
|
||||
new TextDefinition(1005188, "Members of the Council of Mages will now be warned to leave."),
|
||||
new TextDefinition(1005189, "Members of the Council of Mages will now be beaten with a stick."),
|
||||
Settings.NewCoMLocation ?
|
||||
// New CoM Location
|
||||
new StrongholdDefinition(
|
||||
new Rectangle2D[]
|
||||
{
|
||||
new Rectangle2D( 4463, 1488, 16, 31 ),
|
||||
new Rectangle2D( 4445, 1519, 47, 55 )
|
||||
},
|
||||
new Point3D(4469, 1486, 0),
|
||||
new Point3D(4457, 1544, 0),
|
||||
new Point3D[]
|
||||
{
|
||||
new Point3D( 4464, 1534, 21 ),
|
||||
new Point3D( 4464, 1536, 21 ),
|
||||
new Point3D( 4466, 1534, 21 ),
|
||||
new Point3D( 4466, 1536, 21 ),
|
||||
new Point3D( 4468, 1534, 21 ),
|
||||
new Point3D( 4468, 1536, 21 ),
|
||||
new Point3D( 4470, 1534, 21 ),
|
||||
new Point3D( 4470, 1536, 21 )
|
||||
},
|
||||
new Point3D(4458, 1544, 0))
|
||||
: // Old CoM Location
|
||||
new StrongholdDefinition(
|
||||
new Rectangle2D[]
|
||||
{
|
||||
new Rectangle2D(3756, 2232, 4, 23),
|
||||
new Rectangle2D(3760, 2227, 60, 28),
|
||||
new Rectangle2D(3782, 2219, 18, 8),
|
||||
new Rectangle2D(3778, 2255, 35, 17)
|
||||
},
|
||||
new Point3D(3750, 2241, 20),
|
||||
new Point3D(3795, 2259, 20),
|
||||
new Point3D[]
|
||||
{
|
||||
new Point3D(3793, 2255, 20),
|
||||
new Point3D(3793, 2252, 20),
|
||||
new Point3D(3793, 2249, 20),
|
||||
new Point3D(3793, 2246, 20),
|
||||
new Point3D(3797, 2255, 20),
|
||||
new Point3D(3797, 2252, 20),
|
||||
new Point3D(3797, 2249, 20),
|
||||
new Point3D(3797, 2246, 20)
|
||||
},
|
||||
new Point3D(3796, 2259, 20)),
|
||||
new RankDefinition[]
|
||||
{
|
||||
new RankDefinition(10, 991, 8, new TextDefinition(1060789, "Inquisitor of the Council")),
|
||||
new RankDefinition(9, 950, 7, new TextDefinition(1060788, "Archon of Principle")),
|
||||
new RankDefinition(8, 900, 6, new TextDefinition(1060787, "Luminary")),
|
||||
new RankDefinition(7, 800, 6, new TextDefinition(1060787, "Luminary")),
|
||||
new RankDefinition(6, 700, 5, new TextDefinition(1060786, "Diviner")),
|
||||
new RankDefinition(5, 600, 5, new TextDefinition(1060786, "Diviner")),
|
||||
new RankDefinition(4, 500, 5, new TextDefinition(1060786, "Diviner")),
|
||||
new RankDefinition(3, 400, 4, new TextDefinition(1060785, "Mystic")),
|
||||
new RankDefinition(2, 200, 4, new TextDefinition(1060785, "Mystic")),
|
||||
new RankDefinition(1, 0, 4, new TextDefinition(1060785, "Mystic"))
|
||||
},
|
||||
new GuardDefinition[]
|
||||
{
|
||||
new GuardDefinition(typeof(FactionHenchman), 0x1403, 5000, 1000, 10, new TextDefinition(1011526, "HENCHMAN"), new TextDefinition(1011510, "Hire Henchman")),
|
||||
new GuardDefinition(typeof(FactionMercenary), 0x0F62, 6000, 2000, 10, new TextDefinition(1011527, "MERCENARY"), new TextDefinition(1011511, "Hire Mercenary")),
|
||||
new GuardDefinition(typeof(FactionSorceress), 0x0E89, 7000, 3000, 10, new TextDefinition(1011507, "SORCERESS"), new TextDefinition(1011501, "Hire Sorceress")),
|
||||
new GuardDefinition(typeof(FactionWizard), 0x13F8, 8000, 4000, 10, new TextDefinition(1011508, "ELDER WIZARD"), new TextDefinition(1011502, "Hire Elder Wizard")),
|
||||
});
|
||||
}
|
||||
|
||||
public static Faction Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
88
Scripts/Services/Factions/Instances/Factions/Minax.cs
Normal file
88
Scripts/Services/Factions/Instances/Factions/Minax.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class Minax : Faction
|
||||
{
|
||||
private static Faction m_Instance;
|
||||
public Minax()
|
||||
{
|
||||
m_Instance = this;
|
||||
|
||||
this.Definition =
|
||||
new FactionDefinition(
|
||||
0,
|
||||
1645, // dark red
|
||||
1109, // shadow
|
||||
1645, // join stone : dark red
|
||||
1645, // broadcast : dark red
|
||||
0x78, 0x3EAF, // war horse
|
||||
"Minax", "minax", "Min",
|
||||
new TextDefinition(1011534, "MINAX"),
|
||||
new TextDefinition(1060769, "Minax faction"),
|
||||
new TextDefinition(1011421, "<center>FOLLOWERS OF MINAX</center>"),
|
||||
new TextDefinition(1011448,
|
||||
"The followers of Minax have taken control in the old lands, " +
|
||||
"and intend to hold it for as long as they can. Allying themselves " +
|
||||
"with orcs, headless, gazers, trolls, and other beasts, they seek " +
|
||||
"revenge against Lord British, for slights both real and imagined, " +
|
||||
"though some of the followers wish only to wreak havoc on the " +
|
||||
"unsuspecting populace."),
|
||||
new TextDefinition(1011453, "This city is controlled by Minax."),
|
||||
new TextDefinition(1042252, "This sigil has been corrupted by the Followers of Minax"),
|
||||
new TextDefinition(1041043, "The faction signup stone for the Followers of Minax"),
|
||||
new TextDefinition(1041381, "The Faction Stone of Minax"),
|
||||
new TextDefinition(1011463, ": Minax"),
|
||||
new TextDefinition(1005190, "Followers of Minax will now be ignored."),
|
||||
new TextDefinition(1005191, "Followers of Minax will now be told to go away."),
|
||||
new TextDefinition(1005192, "Followers of Minax will now be hanged by their toes."),
|
||||
new StrongholdDefinition(
|
||||
new Rectangle2D[]
|
||||
{
|
||||
new Rectangle2D(1097, 2570, 70, 50)
|
||||
},
|
||||
new Point3D(1172, 2593, 0),
|
||||
new Point3D(1117, 2587, 18),
|
||||
new Point3D[]
|
||||
{
|
||||
new Point3D(1113, 2601, 18),
|
||||
new Point3D(1113, 2598, 18),
|
||||
new Point3D(1113, 2595, 18),
|
||||
new Point3D(1113, 2592, 18),
|
||||
new Point3D(1116, 2601, 18),
|
||||
new Point3D(1116, 2598, 18),
|
||||
new Point3D(1116, 2595, 18),
|
||||
new Point3D(1116, 2592, 18)
|
||||
},
|
||||
new Point3D(1118, 2587, 18)),
|
||||
new RankDefinition[]
|
||||
{
|
||||
new RankDefinition(10, 991, 8, new TextDefinition(1060784, "Avenger of Mondain")),
|
||||
new RankDefinition(9, 950, 7, new TextDefinition(1060783, "Dread Knight")),
|
||||
new RankDefinition(8, 900, 6, new TextDefinition(1060782, "Warlord")),
|
||||
new RankDefinition(7, 800, 6, new TextDefinition(1060782, "Warlord")),
|
||||
new RankDefinition(6, 700, 5, new TextDefinition(1060781, "Executioner")),
|
||||
new RankDefinition(5, 600, 5, new TextDefinition(1060781, "Executioner")),
|
||||
new RankDefinition(4, 500, 5, new TextDefinition(1060781, "Executioner")),
|
||||
new RankDefinition(3, 400, 4, new TextDefinition(1060780, "Defiler")),
|
||||
new RankDefinition(2, 200, 4, new TextDefinition(1060780, "Defiler")),
|
||||
new RankDefinition(1, 0, 4, new TextDefinition(1060780, "Defiler"))
|
||||
},
|
||||
new GuardDefinition[]
|
||||
{
|
||||
new GuardDefinition(typeof(FactionHenchman), 0x1403, 5000, 1000, 10, new TextDefinition(1011526, "HENCHMAN"), new TextDefinition(1011510, "Hire Henchman")),
|
||||
new GuardDefinition(typeof(FactionMercenary), 0x0F62, 6000, 2000, 10, new TextDefinition(1011527, "MERCENARY"), new TextDefinition(1011511, "Hire Mercenary")),
|
||||
new GuardDefinition(typeof(FactionBerserker), 0x0F4B, 7000, 3000, 10, new TextDefinition(1011505, "BERSERKER"), new TextDefinition(1011499, "Hire Berserker")),
|
||||
new GuardDefinition(typeof(FactionDragoon), 0x1439, 8000, 4000, 10, new TextDefinition(1011506, "DRAGOON"), new TextDefinition(1011500, "Hire Dragoon")),
|
||||
});
|
||||
}
|
||||
|
||||
public static Faction Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
88
Scripts/Services/Factions/Instances/Factions/Shadowlords.cs
Normal file
88
Scripts/Services/Factions/Instances/Factions/Shadowlords.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class Shadowlords : Faction
|
||||
{
|
||||
private static Faction m_Instance;
|
||||
public Shadowlords()
|
||||
{
|
||||
m_Instance = this;
|
||||
|
||||
this.Definition =
|
||||
new FactionDefinition(
|
||||
3,
|
||||
1109, // shadow
|
||||
2211, // green
|
||||
1109, // join stone : shadow
|
||||
2211, // broadcast : green
|
||||
0x79, 0x3EB0, // war horse
|
||||
"Shadowlords", "shadow", "SL",
|
||||
new TextDefinition(1011537, "SHADOWLORDS"),
|
||||
new TextDefinition(1060772, "Shadowlords faction"),
|
||||
new TextDefinition(1011424, "<center>SHADES OF DARKNESS</center>"),
|
||||
new TextDefinition(1011451,
|
||||
"The Shadow Lords are a faction that has sprung up within the ranks of " +
|
||||
"Minax. Comprised mostly of undead and those who would seek to be " +
|
||||
"necromancers, they pose a threat to both the sides of good and evil. " +
|
||||
"Their plans have disrupted the hold Minax has over Felucca, and their " +
|
||||
"ultimate goal is to destroy all life."),
|
||||
new TextDefinition(1011456, "This city is controlled by the Shadow Lords."),
|
||||
new TextDefinition(1042255, "This sigil has been corrupted by the Shadowlords"),
|
||||
new TextDefinition(1041046, "The faction signup stone for the Shadowlords"),
|
||||
new TextDefinition(1041384, "The Faction Stone of the Shadowlords"),
|
||||
new TextDefinition(1011466, ": Shadowlords"),
|
||||
new TextDefinition(1005184, "Minions of the Shadowlords will now be ignored."),
|
||||
new TextDefinition(1005185, "Minions of the Shadowlords will now be warned of their impending deaths."),
|
||||
new TextDefinition(1005186, "Minions of the Shadowlords will now be attacked at will."),
|
||||
new StrongholdDefinition(
|
||||
new Rectangle2D[]
|
||||
{
|
||||
new Rectangle2D(960, 688, 8, 9),
|
||||
new Rectangle2D(944, 697, 24, 23)
|
||||
},
|
||||
new Point3D(969, 768, 0),
|
||||
new Point3D(947, 713, 0),
|
||||
new Point3D[]
|
||||
{
|
||||
new Point3D(953, 713, 20),
|
||||
new Point3D(953, 709, 20),
|
||||
new Point3D(953, 705, 20),
|
||||
new Point3D(953, 701, 20),
|
||||
new Point3D(957, 713, 20),
|
||||
new Point3D(957, 709, 20),
|
||||
new Point3D(957, 705, 20),
|
||||
new Point3D(957, 701, 20)
|
||||
},
|
||||
new Point3D(948, 713, 0)),
|
||||
new RankDefinition[]
|
||||
{
|
||||
new RankDefinition(10, 991, 8, new TextDefinition(1060799, "Purveyor of Darkness")),
|
||||
new RankDefinition(9, 950, 7, new TextDefinition(1060798, "Agent of Evil")),
|
||||
new RankDefinition(8, 900, 6, new TextDefinition(1060797, "Bringer of Sorrow")),
|
||||
new RankDefinition(7, 800, 6, new TextDefinition(1060797, "Bringer of Sorrow")),
|
||||
new RankDefinition(6, 700, 5, new TextDefinition(1060796, "Keeper of Lies")),
|
||||
new RankDefinition(5, 600, 5, new TextDefinition(1060796, "Keeper of Lies")),
|
||||
new RankDefinition(4, 500, 5, new TextDefinition(1060796, "Keeper of Lies")),
|
||||
new RankDefinition(3, 400, 4, new TextDefinition(1060795, "Servant")),
|
||||
new RankDefinition(2, 200, 4, new TextDefinition(1060795, "Servant")),
|
||||
new RankDefinition(1, 0, 4, new TextDefinition(1060795, "Servant"))
|
||||
},
|
||||
new GuardDefinition[]
|
||||
{
|
||||
new GuardDefinition(typeof(FactionHenchman), 0x1403, 5000, 1000, 10, new TextDefinition(1011526, "HENCHMAN"), new TextDefinition(1011510, "Hire Henchman")),
|
||||
new GuardDefinition(typeof(FactionMercenary), 0x0F62, 6000, 2000, 10, new TextDefinition(1011527, "MERCENARY"), new TextDefinition(1011511, "Hire Mercenary")),
|
||||
new GuardDefinition(typeof(FactionDeathKnight), 0x0F45, 7000, 3000, 10, new TextDefinition(1011512, "DEATH KNIGHT"), new TextDefinition(1011503, "Hire Death Knight")),
|
||||
new GuardDefinition(typeof(FactionNecromancer), 0x13F8, 8000, 4000, 10, new TextDefinition(1011513, "SHADOW MAGE"), new TextDefinition(1011504, "Hire Shadow Mage")),
|
||||
});
|
||||
}
|
||||
|
||||
public static Faction Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class TrueBritannians : Faction
|
||||
{
|
||||
private static Faction m_Instance;
|
||||
public TrueBritannians()
|
||||
{
|
||||
m_Instance = this;
|
||||
|
||||
this.Definition =
|
||||
new FactionDefinition(
|
||||
2,
|
||||
1254, // dark purple
|
||||
2125, // gold
|
||||
2214, // join stone : gold
|
||||
2125, // broadcast : gold
|
||||
0x76, 0x3EB2, // war horse
|
||||
"True Britannians", "true", "TB",
|
||||
new TextDefinition(1011536, "LORD BRITISH"),
|
||||
new TextDefinition(1060771, "True Britannians faction"),
|
||||
new TextDefinition(1011423, "<center>TRUE BRITANNIANS</center>"),
|
||||
new TextDefinition(1011450,
|
||||
"True Britannians are loyal to the throne of Lord British. They refuse " +
|
||||
"to give up their homelands to the vile Minax, and detest the Shadowlords " +
|
||||
"for their evil ways. In addition, the Council of Mages threatens the " +
|
||||
"existence of their ruler, and as such they have armed themselves, and " +
|
||||
"prepare for war with all."),
|
||||
new TextDefinition(1011454, "This city is controlled by Lord British."),
|
||||
new TextDefinition(1042254, "This sigil has been corrupted by the True Britannians"),
|
||||
new TextDefinition(1041045, "The faction signup stone for the True Britannians"),
|
||||
new TextDefinition(1041383, "The Faction Stone of the True Britannians"),
|
||||
new TextDefinition(1011465, ": True Britannians"),
|
||||
new TextDefinition(1005181, "Followers of Lord British will now be ignored."),
|
||||
new TextDefinition(1005182, "Followers of Lord British will now be warned of their impending doom."),
|
||||
new TextDefinition(1005183, "Followers of Lord British will now be attacked on sight."),
|
||||
new StrongholdDefinition(
|
||||
new Rectangle2D[]
|
||||
{
|
||||
new Rectangle2D(1292, 1556, 25, 25),
|
||||
new Rectangle2D(1292, 1676, 120, 25),
|
||||
new Rectangle2D(1388, 1556, 25, 25),
|
||||
new Rectangle2D(1317, 1563, 71, 18),
|
||||
new Rectangle2D(1300, 1581, 105, 95),
|
||||
new Rectangle2D(1405, 1612, 12, 21),
|
||||
new Rectangle2D(1405, 1633, 11, 5)
|
||||
},
|
||||
new Point3D(1419, 1622, 20),
|
||||
new Point3D(1330, 1621, 50),
|
||||
new Point3D[]
|
||||
{
|
||||
new Point3D(1328, 1627, 50),
|
||||
new Point3D(1328, 1621, 50),
|
||||
new Point3D(1334, 1627, 50),
|
||||
new Point3D(1334, 1621, 50),
|
||||
new Point3D(1340, 1627, 50),
|
||||
new Point3D(1340, 1621, 50),
|
||||
new Point3D(1345, 1621, 50),
|
||||
new Point3D(1345, 1627, 50)
|
||||
},
|
||||
new Point3D(1331, 1621, 50)),
|
||||
new RankDefinition[]
|
||||
{
|
||||
new RankDefinition(10, 991, 8, new TextDefinition(1060794, "Knight of the Codex")),
|
||||
new RankDefinition(9, 950, 7, new TextDefinition(1060793, "Knight of Virtue")),
|
||||
new RankDefinition(8, 900, 6, new TextDefinition(1060792, "Crusader")),
|
||||
new RankDefinition(7, 800, 6, new TextDefinition(1060792, "Crusader")),
|
||||
new RankDefinition(6, 700, 5, new TextDefinition(1060791, "Sentinel")),
|
||||
new RankDefinition(5, 600, 5, new TextDefinition(1060791, "Sentinel")),
|
||||
new RankDefinition(4, 500, 5, new TextDefinition(1060791, "Sentinel")),
|
||||
new RankDefinition(3, 400, 4, new TextDefinition(1060790, "Defender")),
|
||||
new RankDefinition(2, 200, 4, new TextDefinition(1060790, "Defender")),
|
||||
new RankDefinition(1, 0, 4, new TextDefinition(1060790, "Defender"))
|
||||
},
|
||||
new GuardDefinition[]
|
||||
{
|
||||
new GuardDefinition(typeof(FactionHenchman), 0x1403, 5000, 1000, 10, new TextDefinition(1011526, "HENCHMAN"), new TextDefinition(1011510, "Hire Henchman")),
|
||||
new GuardDefinition(typeof(FactionMercenary), 0x0F62, 6000, 2000, 10, new TextDefinition(1011527, "MERCENARY"), new TextDefinition(1011511, "Hire Mercenary")),
|
||||
new GuardDefinition(typeof(FactionKnight), 0x0F4D, 7000, 3000, 10, new TextDefinition(1011528, "KNIGHT"), new TextDefinition(1011497, "Hire Knight")),
|
||||
new GuardDefinition(typeof(FactionPaladin), 0x143F, 8000, 4000, 10, new TextDefinition(1011529, "PALADIN"), new TextDefinition(1011498, "Hire Paladin")),
|
||||
});
|
||||
}
|
||||
|
||||
public static Faction Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
26
Scripts/Services/Factions/Instances/Towns/Britain.cs
Normal file
26
Scripts/Services/Factions/Instances/Towns/Britain.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class Britain : Town
|
||||
{
|
||||
public Britain()
|
||||
{
|
||||
this.Definition =
|
||||
new TownDefinition(
|
||||
0,
|
||||
0x1869,
|
||||
"Britain",
|
||||
"Britain",
|
||||
new TextDefinition(1011433, "BRITAIN"),
|
||||
new TextDefinition(1011561, "TOWN STONE FOR BRITAIN"),
|
||||
new TextDefinition(1041034, "The Faction Sigil Monolith of Britain"),
|
||||
new TextDefinition(1041404, "The Faction Town Sigil Monolith of Britain"),
|
||||
new TextDefinition(1041413, "Faction Town Stone of Britain"),
|
||||
new TextDefinition(1041395, "Faction Town Sigil of Britain"),
|
||||
new TextDefinition(1041386, "Corrupted Faction Town Sigil of Britain"),
|
||||
new Point3D(1592, 1680, 10),
|
||||
new Point3D(1588, 1676, 10));
|
||||
}
|
||||
}
|
||||
}
|
||||
26
Scripts/Services/Factions/Instances/Towns/Magincia.cs
Normal file
26
Scripts/Services/Factions/Instances/Towns/Magincia.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class Magincia : Town
|
||||
{
|
||||
public Magincia()
|
||||
{
|
||||
this.Definition =
|
||||
new TownDefinition(
|
||||
7,
|
||||
0x1870,
|
||||
"Magincia",
|
||||
"Magincia",
|
||||
new TextDefinition(1011440, "MAGINCIA"),
|
||||
new TextDefinition(1011568, "TOWN STONE FOR MAGINCIA"),
|
||||
new TextDefinition(1041041, "The Faction Sigil Monolith of Magincia"),
|
||||
new TextDefinition(1041411, "The Faction Town Sigil Monolith of Magincia"),
|
||||
new TextDefinition(1041420, "Faction Town Stone of Magincia"),
|
||||
new TextDefinition(1041402, "Faction Town Sigil of Magincia"),
|
||||
new TextDefinition(1041393, "Corrupted Faction Town Sigil of Magincia"),
|
||||
new Point3D(3714, 2235, 20),
|
||||
new Point3D(3712, 2230, 20));
|
||||
}
|
||||
}
|
||||
}
|
||||
26
Scripts/Services/Factions/Instances/Towns/Minoc.cs
Normal file
26
Scripts/Services/Factions/Instances/Towns/Minoc.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class Minoc : Town
|
||||
{
|
||||
public Minoc()
|
||||
{
|
||||
this.Definition =
|
||||
new TownDefinition(
|
||||
2,
|
||||
0x186B,
|
||||
"Minoc",
|
||||
"Minoc",
|
||||
new TextDefinition(1011437, "MINOC"),
|
||||
new TextDefinition(1011564, "TOWN STONE FOR MINOC"),
|
||||
new TextDefinition(1041036, "The Faction Sigil Monolith of Minoc"),
|
||||
new TextDefinition(1041406, "The Faction Town Sigil Monolith Minoc"),
|
||||
new TextDefinition(1041415, "Faction Town Stone of Minoc"),
|
||||
new TextDefinition(1041397, "Faction Town Sigil of Minoc"),
|
||||
new TextDefinition(1041388, "Corrupted Faction Town Sigil of Minoc"),
|
||||
new Point3D(2471, 439, 15),
|
||||
new Point3D(2469, 445, 15));
|
||||
}
|
||||
}
|
||||
}
|
||||
26
Scripts/Services/Factions/Instances/Towns/Moonglow.cs
Normal file
26
Scripts/Services/Factions/Instances/Towns/Moonglow.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class Moonglow : Town
|
||||
{
|
||||
public Moonglow()
|
||||
{
|
||||
this.Definition =
|
||||
new TownDefinition(
|
||||
3,
|
||||
0x186C,
|
||||
"Moonglow",
|
||||
"Moonglow",
|
||||
new TextDefinition(1011435, "MOONGLOW"),
|
||||
new TextDefinition(1011563, "TOWN STONE FOR MOONGLOW"),
|
||||
new TextDefinition(1041037, "The Faction Sigil Monolith of Moonglow"),
|
||||
new TextDefinition(1041407, "The Faction Town Sigil Monolith of Moonglow"),
|
||||
new TextDefinition(1041416, "Faction Town Stone of Moonglow"),
|
||||
new TextDefinition(1041398, "Faction Town Sigil of Moonglow"),
|
||||
new TextDefinition(1041389, "Corrupted Faction Town Sigil of Moonglow"),
|
||||
new Point3D(4436, 1083, 0),
|
||||
new Point3D(4432, 1086, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
26
Scripts/Services/Factions/Instances/Towns/SkaraBrae.cs
Normal file
26
Scripts/Services/Factions/Instances/Towns/SkaraBrae.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class SkaraBrae : Town
|
||||
{
|
||||
public SkaraBrae()
|
||||
{
|
||||
this.Definition =
|
||||
new TownDefinition(
|
||||
6,
|
||||
0x186F,
|
||||
"Skara Brae",
|
||||
"Skara Brae",
|
||||
new TextDefinition(1011439, "SKARA BRAE"),
|
||||
new TextDefinition(1011567, "TOWN STONE FOR SKARA BRAE"),
|
||||
new TextDefinition(1041040, "The Faction Sigil Monolith of Skara Brae"),
|
||||
new TextDefinition(1041410, "The Faction Town Sigil Monolith of Skara Brae"),
|
||||
new TextDefinition(1041419, "Faction Town Stone of Skara Brae"),
|
||||
new TextDefinition(1041401, "Faction Town Sigil of Skara Brae"),
|
||||
new TextDefinition(1041392, "Corrupted Faction Town Sigil of Skara Brae"),
|
||||
new Point3D(576, 2200, 0),
|
||||
new Point3D(572, 2196, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
26
Scripts/Services/Factions/Instances/Towns/Trinsic.cs
Normal file
26
Scripts/Services/Factions/Instances/Towns/Trinsic.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class Trinsic : Town
|
||||
{
|
||||
public Trinsic()
|
||||
{
|
||||
this.Definition =
|
||||
new TownDefinition(
|
||||
1,
|
||||
0x186A,
|
||||
"Trinsic",
|
||||
"Trinsic",
|
||||
new TextDefinition(1011434, "TRINSIC"),
|
||||
new TextDefinition(1011562, "TOWN STONE FOR TRINSIC"),
|
||||
new TextDefinition(1041035, "The Faction Sigil Monolith of Trinsic"),
|
||||
new TextDefinition(1041405, "The Faction Town Sigil Monolith of Trinsic"),
|
||||
new TextDefinition(1041414, "Faction Town Stone of Trinsic"),
|
||||
new TextDefinition(1041396, "Faction Town Sigil of Trinsic"),
|
||||
new TextDefinition(1041387, "Corrupted Faction Town Sigil of Trinsic"),
|
||||
new Point3D(1914, 2717, 20),
|
||||
new Point3D(1909, 2720, 20));
|
||||
}
|
||||
}
|
||||
}
|
||||
26
Scripts/Services/Factions/Instances/Towns/Vesper.cs
Normal file
26
Scripts/Services/Factions/Instances/Towns/Vesper.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class Vesper : Town
|
||||
{
|
||||
public Vesper()
|
||||
{
|
||||
this.Definition =
|
||||
new TownDefinition(
|
||||
5,
|
||||
0x186E,
|
||||
"Vesper",
|
||||
"Vesper",
|
||||
new TextDefinition(1016413, "VESPER"),
|
||||
new TextDefinition(1011566, "TOWN STONE FOR VESPER"),
|
||||
new TextDefinition(1041039, "The Faction Sigil Monolith of Vesper"),
|
||||
new TextDefinition(1041409, "The Faction Town Sigil Monolith of Vesper"),
|
||||
new TextDefinition(1041418, "Faction Town Stone of Vesper"),
|
||||
new TextDefinition(1041400, "Faction Town Sigil of Vesper"),
|
||||
new TextDefinition(1041391, "Corrupted Faction Town Sigil of Vesper"),
|
||||
new Point3D(2982, 818, 0),
|
||||
new Point3D(2985, 821, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
26
Scripts/Services/Factions/Instances/Towns/Yew.cs
Normal file
26
Scripts/Services/Factions/Instances/Towns/Yew.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class Yew : Town
|
||||
{
|
||||
public Yew()
|
||||
{
|
||||
this.Definition =
|
||||
new TownDefinition(
|
||||
4,
|
||||
0x186D,
|
||||
"Yew",
|
||||
"Yew",
|
||||
new TextDefinition(1011438, "YEW"),
|
||||
new TextDefinition(1011565, "TOWN STONE FOR YEW"),
|
||||
new TextDefinition(1041038, "The Faction Sigil Monolith of Yew"),
|
||||
new TextDefinition(1041408, "The Faction Town Sigil Monolith of Yew"),
|
||||
new TextDefinition(1041417, "Faction Town Stone of Yew"),
|
||||
new TextDefinition(1041399, "Faction Town Sigil of Yew"),
|
||||
new TextDefinition(1041390, "Corrupted Faction Town Sigil of Yew"),
|
||||
new Point3D(548, 979, 0),
|
||||
new Point3D(542, 980, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
147
Scripts/Services/Factions/Items/BaseMonolith.cs
Normal file
147
Scripts/Services/Factions/Items/BaseMonolith.cs
Normal file
@@ -0,0 +1,147 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public abstract class BaseMonolith : BaseSystemController
|
||||
{
|
||||
private static List<BaseMonolith> m_Monoliths = new List<BaseMonolith>();
|
||||
private Town m_Town;
|
||||
private Faction m_Faction;
|
||||
private Sigil m_Sigil;
|
||||
public BaseMonolith(Town town, Faction faction)
|
||||
: base(0x1183)
|
||||
{
|
||||
this.Movable = false;
|
||||
this.Town = town;
|
||||
this.Faction = faction;
|
||||
m_Monoliths.Add(this);
|
||||
}
|
||||
|
||||
public BaseMonolith(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
m_Monoliths.Add(this);
|
||||
}
|
||||
|
||||
public static List<BaseMonolith> Monoliths
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Monoliths;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_Monoliths = value;
|
||||
}
|
||||
}
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
|
||||
public Sigil Sigil
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Sigil;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (this.m_Sigil == value)
|
||||
return;
|
||||
|
||||
this.m_Sigil = value;
|
||||
|
||||
if (this.m_Sigil != null && this.m_Sigil.LastMonolith != null && this.m_Sigil.LastMonolith != this && this.m_Sigil.LastMonolith.Sigil == this.m_Sigil)
|
||||
this.m_Sigil.LastMonolith.Sigil = null;
|
||||
|
||||
if (this.m_Sigil != null)
|
||||
this.m_Sigil.LastMonolith = this;
|
||||
|
||||
this.UpdateSigil();
|
||||
}
|
||||
}
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
|
||||
public Town Town
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Town;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_Town = value;
|
||||
this.OnTownChanged();
|
||||
}
|
||||
}
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
|
||||
public Faction Faction
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Faction;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_Faction = value;
|
||||
this.Hue = (this.m_Faction == null ? 0 : this.m_Faction.Definition.HuePrimary);
|
||||
}
|
||||
}
|
||||
public override void OnLocationChange(Point3D oldLocation)
|
||||
{
|
||||
base.OnLocationChange(oldLocation);
|
||||
this.UpdateSigil();
|
||||
}
|
||||
|
||||
public override void OnMapChange()
|
||||
{
|
||||
base.OnMapChange();
|
||||
this.UpdateSigil();
|
||||
}
|
||||
|
||||
public virtual void UpdateSigil()
|
||||
{
|
||||
if (this.m_Sigil == null || this.m_Sigil.Deleted)
|
||||
return;
|
||||
|
||||
this.m_Sigil.MoveToWorld(new Point3D(this.X, this.Y, this.Z + 18), this.Map);
|
||||
}
|
||||
|
||||
public virtual void OnTownChanged()
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
base.OnAfterDelete();
|
||||
m_Monoliths.Remove(this);
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
|
||||
Town.WriteReference(writer, this.m_Town);
|
||||
Faction.WriteReference(writer, this.m_Faction);
|
||||
|
||||
writer.Write((Item)this.m_Sigil);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
this.Town = Town.ReadReference(reader);
|
||||
this.Faction = Faction.ReadReference(reader);
|
||||
this.m_Sigil = reader.ReadItem() as Sigil;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
77
Scripts/Services/Factions/Items/BaseSystemController.cs
Normal file
77
Scripts/Services/Factions/Items/BaseSystemController.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public abstract class BaseSystemController : Item
|
||||
{
|
||||
private int m_LabelNumber;
|
||||
public BaseSystemController(int itemID)
|
||||
: base(itemID)
|
||||
{
|
||||
}
|
||||
|
||||
public BaseSystemController(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual int DefaultLabelNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.LabelNumber;
|
||||
}
|
||||
}
|
||||
public new virtual string DefaultName
|
||||
{
|
||||
get
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public override int LabelNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.m_LabelNumber > 0)
|
||||
return this.m_LabelNumber;
|
||||
|
||||
return this.DefaultLabelNumber;
|
||||
}
|
||||
}
|
||||
public virtual void AssignName(TextDefinition name)
|
||||
{
|
||||
if (name != null && name.Number > 0)
|
||||
{
|
||||
this.m_LabelNumber = name.Number;
|
||||
this.Name = null;
|
||||
}
|
||||
else if (name != null && name.String != null)
|
||||
{
|
||||
this.m_LabelNumber = 0;
|
||||
this.Name = name.String;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.m_LabelNumber = 0;
|
||||
this.Name = this.DefaultName;
|
||||
}
|
||||
|
||||
this.InvalidateProperties();
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
173
Scripts/Services/Factions/Items/Equipment/CollectionBox.cs
Normal file
173
Scripts/Services/Factions/Items/Equipment/CollectionBox.cs
Normal file
@@ -0,0 +1,173 @@
|
||||
using System;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
using Server.Gumps;
|
||||
using Server.Engines.VvV;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionCollectionBox : BaseCollectionItem
|
||||
{
|
||||
public Collection FactionCollection { get; private set; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Faction Faction
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (FactionCollection)
|
||||
{
|
||||
case Collection.Minax: return Minax.Instance;
|
||||
case Collection.TrueBritannians: return TrueBritannians.Instance;
|
||||
case Collection.Shadowlords: return Shadowlords.Instance;
|
||||
case Collection.CouncilOfMages: return CouncilOfMages.Instance;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public FactionCollectionBox(Faction faction)
|
||||
: base(0xE7D)
|
||||
{
|
||||
if (faction == Minax.Instance)
|
||||
FactionCollection = Collection.Minax;
|
||||
else if (faction == TrueBritannians.Instance)
|
||||
FactionCollection = Collection.TrueBritannians;
|
||||
else if (faction == Shadowlords.Instance)
|
||||
FactionCollection = Collection.Shadowlords;
|
||||
else
|
||||
FactionCollection = Collection.CouncilOfMages;
|
||||
|
||||
Hue = 0x48D;
|
||||
StartTier = 10000000;
|
||||
NextTier = 5000000;
|
||||
DailyDecay = 100000;
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (from.Alive)
|
||||
{
|
||||
if (from.NetState == null || !from.NetState.SupportsExpansion(Expansion.ML))
|
||||
{
|
||||
from.SendLocalizedMessage(1073651); // You must have Mondain's Legacy before proceeding...
|
||||
return;
|
||||
}
|
||||
else if (!Factions.Settings.Enabled && from.AccessLevel < AccessLevel.GameMaster)
|
||||
{
|
||||
from.SendLocalizedMessage(1042753, "Factions"); // ~1_SOMETHING~ has been temporarily disabled.
|
||||
return;
|
||||
}
|
||||
|
||||
if (from.InRange(Location, 2) && from is PlayerMobile && CanDonate((PlayerMobile)from))
|
||||
{
|
||||
from.CloseGump(typeof(CommunityCollectionGump));
|
||||
from.SendGump(new CommunityCollectionGump((PlayerMobile)from, this, Location));
|
||||
}
|
||||
else
|
||||
from.LocalOverheadMessage(Server.Network.MessageType.Regular, 0x3B2, 1019045); // I can't reach that.
|
||||
}
|
||||
}
|
||||
|
||||
public override bool CanDonate(PlayerMobile player)
|
||||
{
|
||||
Faction faction = Faction.Find(player);
|
||||
|
||||
if (faction == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return faction == this.Faction;
|
||||
}
|
||||
|
||||
public FactionCollectionBox(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override int LabelNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return 1073436;
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public override Collection CollectionID
|
||||
{
|
||||
get
|
||||
{
|
||||
return FactionCollection;
|
||||
}
|
||||
}
|
||||
|
||||
public override int MaxTier
|
||||
{
|
||||
get
|
||||
{
|
||||
return 12;
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
Donations.Add(new CollectionItem(typeof(Silver), 0xEF2, 1017384, 0x0, 1));
|
||||
|
||||
Rewards.Add(new FactionCollectionItem(typeof(StrongholdRune), 0x1F14, 1094700, 0, this.Faction, 150, 0));
|
||||
Rewards.Add(new FactionCollectionItem(typeof(ShrineGem), 0x1EA7, 1094711, 0, this.Faction, 100, 0));
|
||||
Rewards.Add(new FactionCollectionItem(typeof(SupernovaPotion), 3849, 1094718, 13, this.Faction, 100, 0));
|
||||
Rewards.Add(new FactionCollectionItem(typeof(GreaterStaminaPotion), 3849, 1094764, 437, this.Faction, 50, 0));
|
||||
Rewards.Add(new FactionCollectionItem(typeof(EnchantedBandage), 0xE21, 1094712, 0, this.Faction, 100, 0));
|
||||
Rewards.Add(new FactionCollectionItem(typeof(PowderOfPerseverance), 4102, 1094712, 2419, this.Faction, 300, 0));
|
||||
Rewards.Add(new FactionCollectionItem(typeof(MorphEarrings), 0x1087, 1094746, 0, this.Faction, 1000, 0));
|
||||
|
||||
Rewards.Add(new FactionCollectionItem(typeof(PrimerOnArmsTalisman), 12121, 1094704, 0, this.Faction, 3000, 7));
|
||||
Rewards.Add(new FactionCollectionItem(typeof(ClaininsSpellbook), 3834, 1094705, 0x84D, this.Faction, 4000, 9));
|
||||
Rewards.Add(new FactionCollectionItem(typeof(CrimsonCincture), 5435, 1075043, 0x485, this.Faction, 2000, 4));
|
||||
Rewards.Add(new FactionCollectionItem(typeof(CrystallineRing), 4234, 1075096, 1152, this.Faction, 4000, 9));
|
||||
Rewards.Add(new FactionCollectionItem(typeof(HumanFeyLeggings), 5054, 1075041, 0, this.Faction, 1000, 1));
|
||||
Rewards.Add(new FactionCollectionItem(typeof(FoldedSteelGlasses), 12216, 1073380, 1150, this.Faction, 4000, 9));
|
||||
Rewards.Add(new FactionCollectionItem(typeof(HeartOfTheLion), 5141, 1070817, 1281, this.Faction, 2000, 4));
|
||||
Rewards.Add(new FactionCollectionItem(typeof(HuntersHeaddress), 5447, 1061595, 1428, this.Faction, 2000, 4));
|
||||
Rewards.Add(new FactionCollectionItem(typeof(KasaOfTheRajin), 10136, 1070969, 0, this.Faction, 1000, 1));
|
||||
Rewards.Add(new FactionCollectionItem(typeof(MaceAndShieldGlasses), 12216, 1073381, 477, this.Faction, 5000, 10));
|
||||
Rewards.Add(new FactionCollectionItem(typeof(VesperOrderShield), 7108, 1073258, 0, this.Faction, 4000, 9));
|
||||
Rewards.Add(new FactionCollectionItem(typeof(OrnamentOfTheMagician), 4230, 1061105, 1364, this.Faction, 5000, 10));
|
||||
Rewards.Add(new FactionCollectionItem(typeof(RingOfTheVile), 4234, 1061102, 1271, this.Faction, 2000, 4));
|
||||
Rewards.Add(new FactionCollectionItem(typeof(RuneBeetleCarapace), 10109, 1070968, 0, this.Faction, 1000, 1));
|
||||
Rewards.Add(new FactionCollectionItem(typeof(SpiritOfTheTotem), 5445, 1061599, 1109, this.Faction, 3000, 7));
|
||||
Rewards.Add(new FactionCollectionItem(typeof(Stormgrip), 10130, 1070970, 0, this.Faction, 1000, 1));
|
||||
Rewards.Add(new FactionCollectionItem(typeof(InquisitorsResolution), 5140, 1060206, 1266, this.Faction, 5000, 10));
|
||||
Rewards.Add(new FactionCollectionItem(typeof(TomeOfLostKnowledge), 3834, 1070971, 1328, this.Faction, 3000, 7));
|
||||
Rewards.Add(new FactionCollectionItem(typeof(WizardsCrystalGlasses), 4102, 1094756, 0, this.Faction, 3000, 7));
|
||||
}
|
||||
|
||||
public override void IncreaseTier()
|
||||
{
|
||||
base.IncreaseTier();
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
|
||||
writer.Write((int)FactionCollection);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
FactionCollection = (Collection)reader.ReadInt();
|
||||
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
199
Scripts/Services/Factions/Items/Equipment/EnhanctedBandage.cs
Normal file
199
Scripts/Services/Factions/Items/Equipment/EnhanctedBandage.cs
Normal file
@@ -0,0 +1,199 @@
|
||||
using System;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
using System.Collections.Generic;
|
||||
using Server.Spells.First;
|
||||
using Server.Spells.Fourth;
|
||||
using Server.Spells.Necromancy;
|
||||
using Server.Spells.Mysticism;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class EnchantedBandage : Item, IFactionItem
|
||||
{
|
||||
public override int LabelNumber { get { return 1094712; } } // Enchanted Bandage
|
||||
|
||||
#region Factions
|
||||
private FactionItem m_FactionState;
|
||||
|
||||
public FactionItem FactionItemState
|
||||
{
|
||||
get { return m_FactionState; }
|
||||
set
|
||||
{
|
||||
m_FactionState = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
public EnchantedBandage()
|
||||
: base(0xE21)
|
||||
{
|
||||
Stackable = true;
|
||||
}
|
||||
|
||||
public override void GetProperties(ObjectPropertyList list)
|
||||
{
|
||||
base.GetProperties(list);
|
||||
FactionEquipment.AddFactionProperties(this, list);
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (from.InRange(GetWorldLocation(), 2))
|
||||
{
|
||||
if (FactionEquipment.CanUse(this, from))
|
||||
{
|
||||
from.RevealingAction();
|
||||
|
||||
from.SendLocalizedMessage(500948); // Who will you use the bandages on?
|
||||
|
||||
from.BeginTarget(-1, false, Server.Targeting.TargetFlags.Beneficial, (healer, targeted) =>
|
||||
{
|
||||
Mobile patient = targeted as Mobile;
|
||||
|
||||
if (patient != null)
|
||||
{
|
||||
if (EnchantedApple.GetTotalCurses(patient) == 0)
|
||||
{
|
||||
healer.SendLocalizedMessage(500955); // That being is not damaged!
|
||||
}
|
||||
else if (!Deleted && healer.CanBeBeneficial(patient, true, true))
|
||||
{
|
||||
healer.DoBeneficial(patient);
|
||||
|
||||
bool onSelf = (healer == patient);
|
||||
int dex = healer.Dex;
|
||||
|
||||
double seconds;
|
||||
double resDelay = (patient.Alive ? 0.0 : 5.0);
|
||||
|
||||
if (onSelf)
|
||||
{
|
||||
seconds = 9.4 + (0.6 * ((double)(120 - dex) / 10));
|
||||
}
|
||||
else
|
||||
{
|
||||
seconds = Math.Ceiling((double)4 - healer.Dex / 60);
|
||||
seconds = Math.Max(seconds, 2);
|
||||
}
|
||||
|
||||
if (Context.ContainsKey(healer))
|
||||
{
|
||||
Context[healer].Stop();
|
||||
}
|
||||
|
||||
Context[healer] = new InternalTimer(this, patient, healer, seconds);
|
||||
|
||||
if (!onSelf)
|
||||
{
|
||||
patient.SendLocalizedMessage(1008078, false, healer.Name); // : Attempting to heal you.
|
||||
}
|
||||
|
||||
healer.SendLocalizedMessage(500956); // You begin applying the bandages.
|
||||
|
||||
if (healer.NetState != null && healer.NetState.IsEnhancedClient)
|
||||
{
|
||||
healer.NetState.Send(new BandageTimerPacket((int)(seconds)));
|
||||
}
|
||||
|
||||
Consume();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(500295); // You are too far away to do that.
|
||||
}
|
||||
}
|
||||
|
||||
public static Dictionary<Mobile, Timer> Context = new Dictionary<Mobile, Timer>();
|
||||
|
||||
public class InternalTimer : Timer
|
||||
{
|
||||
public EnchantedBandage Bandage { get; set; }
|
||||
public Mobile Patient { get; set; }
|
||||
public Mobile Healer { get; set; }
|
||||
|
||||
public long Expires { get; set; }
|
||||
|
||||
public InternalTimer(EnchantedBandage bandage, Mobile patient, Mobile healer, double seconds)
|
||||
: base(TimeSpan.FromMilliseconds(250), TimeSpan.FromMilliseconds(250))
|
||||
{
|
||||
Bandage = bandage;
|
||||
Patient = patient;
|
||||
Healer = healer;
|
||||
|
||||
Expires = Core.TickCount + (long)(seconds * 1000);
|
||||
|
||||
Start();
|
||||
}
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
if (Core.TickCount >= Expires)
|
||||
{
|
||||
EndHeal();
|
||||
Stop();
|
||||
}
|
||||
}
|
||||
|
||||
private void EndHeal()
|
||||
{
|
||||
if (Context.ContainsKey(Healer))
|
||||
Context.Remove(Healer);
|
||||
|
||||
if (Patient != Healer && Patient.InRange(Healer.Location, 2))
|
||||
{
|
||||
Healer.PlaySound(0x57);
|
||||
|
||||
if (EnchantedApple.GetTotalCurses(Patient) == 0)
|
||||
Healer.SendLocalizedMessage(500968); // You apply the bandages, but they barely help.
|
||||
else
|
||||
Healer.SendLocalizedMessage(500969); // You finish applying the bandages.
|
||||
|
||||
EvilOmenSpell.TryEndEffect(Patient);
|
||||
StrangleSpell.RemoveCurse(Patient);
|
||||
CorpseSkinSpell.RemoveCurse(Patient);
|
||||
WeakenSpell.RemoveEffects(Patient);
|
||||
FeeblemindSpell.RemoveEffects(Patient);
|
||||
ClumsySpell.RemoveEffects(Patient);
|
||||
CurseSpell.RemoveEffect(Patient);
|
||||
MortalStrike.EndWound(Patient);
|
||||
BloodOathSpell.RemoveCurse(Patient);
|
||||
MindRotSpell.ClearMindRotScalar(Patient);
|
||||
SpellPlagueSpell.RemoveFromList(Patient);
|
||||
SleepSpell.EndSleep(Patient);
|
||||
|
||||
BuffInfo.RemoveBuff(Patient, BuffIcon.MassCurse);
|
||||
}
|
||||
else
|
||||
{
|
||||
Healer.SendLocalizedMessage(500295); // You are too far away to do that.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public EnchantedBandage(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
279
Scripts/Services/Factions/Items/Equipment/FactionEquipment.cs
Normal file
279
Scripts/Services/Factions/Items/Equipment/FactionEquipment.cs
Normal file
@@ -0,0 +1,279 @@
|
||||
using System;
|
||||
using Server.Mobiles;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public static class FactionEquipment
|
||||
{
|
||||
public static bool CanUse(IFactionItem item, Mobile m, int failmessage = 500294)
|
||||
{
|
||||
if (item == null)
|
||||
return true;
|
||||
|
||||
var state = PlayerState.Find(m);
|
||||
|
||||
if (state != null && state.Faction == item.FactionItemState.Faction)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (failmessage > 0)
|
||||
{
|
||||
m.SendLocalizedMessage(failmessage); // You cannot use that.
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool AddFactionProperties(IFactionItem item, ObjectPropertyList list)
|
||||
{
|
||||
if (item.FactionItemState != null)
|
||||
{
|
||||
list.Add(1041350); // faction item
|
||||
|
||||
if (item.FactionItemState.MinRank > 0)
|
||||
list.Add(1094805, item.FactionItemState.MinRank.ToString()); // Faction Rank: ~1_VALUE~
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void CheckProperties(Item item)
|
||||
{
|
||||
if (item is PrimerOnArmsTalisman && ((PrimerOnArmsTalisman)item).Attributes.AttackChance != 10)
|
||||
{
|
||||
((PrimerOnArmsTalisman)item).Attributes.AttackChance = 10;
|
||||
}
|
||||
|
||||
if (item is ClaininsSpellbook && ((ClaininsSpellbook)item).Attributes.LowerManaCost != 10)
|
||||
{
|
||||
((ClaininsSpellbook)item).Attributes.LowerManaCost = 10;
|
||||
}
|
||||
|
||||
if (item is CrimsonCincture && ((CrimsonCincture)item).Attributes.BonusDex != 10)
|
||||
{
|
||||
((CrimsonCincture)item).Attributes.BonusDex = 10;
|
||||
}
|
||||
|
||||
if (item is CrystallineRing && ((CrystallineRing)item).Attributes.CastRecovery != 3)
|
||||
{
|
||||
((CrystallineRing)item).Attributes.CastRecovery = 3;
|
||||
}
|
||||
|
||||
if (item is FeyLeggings)
|
||||
{
|
||||
if (((FeyLeggings)item).PhysicalBonus != 3)
|
||||
((FeyLeggings)item).PhysicalBonus = 3;
|
||||
|
||||
if (((FeyLeggings)item).FireBonus != 3)
|
||||
((FeyLeggings)item).FireBonus = 3;
|
||||
|
||||
if (((FeyLeggings)item).ColdBonus != 3)
|
||||
((FeyLeggings)item).ColdBonus = 3;
|
||||
|
||||
if (((FeyLeggings)item).EnergyBonus != 3)
|
||||
((FeyLeggings)item).EnergyBonus = 3;
|
||||
}
|
||||
|
||||
if (item is FoldedSteelGlasses && ((FoldedSteelGlasses)item).Attributes.DefendChance != 25)
|
||||
{
|
||||
((FoldedSteelGlasses)item).Attributes.DefendChance = 25;
|
||||
}
|
||||
|
||||
if (item is HeartOfTheLion)
|
||||
{
|
||||
if (((HeartOfTheLion)item).PhysicalBonus != 5)
|
||||
((HeartOfTheLion)item).PhysicalBonus = 5;
|
||||
|
||||
if (((HeartOfTheLion)item).FireBonus != 5)
|
||||
((HeartOfTheLion)item).FireBonus = 5;
|
||||
|
||||
if (((HeartOfTheLion)item).ColdBonus != 5)
|
||||
((HeartOfTheLion)item).ColdBonus = 5;
|
||||
|
||||
if (((HeartOfTheLion)item).PoisonBonus != 5)
|
||||
((HeartOfTheLion)item).PoisonBonus = 5;
|
||||
|
||||
if (((HeartOfTheLion)item).EnergyBonus != 5)
|
||||
((HeartOfTheLion)item).EnergyBonus = 5;
|
||||
}
|
||||
|
||||
if (item is HuntersHeaddress)
|
||||
{
|
||||
if (((HuntersHeaddress)item).Resistances.Physical != 8)
|
||||
((HuntersHeaddress)item).Resistances.Physical = 8;
|
||||
|
||||
if (((HuntersHeaddress)item).Resistances.Fire != 4)
|
||||
((HuntersHeaddress)item).Resistances.Fire = 4;
|
||||
|
||||
if (((HuntersHeaddress)item).Resistances.Cold != -8)
|
||||
((HuntersHeaddress)item).Resistances.Cold = -8;
|
||||
|
||||
if (((HuntersHeaddress)item).Resistances.Poison != 9)
|
||||
((HuntersHeaddress)item).Resistances.Poison = 9;
|
||||
|
||||
if (((HuntersHeaddress)item).Resistances.Energy != 3)
|
||||
((HuntersHeaddress)item).Resistances.Energy = 3;
|
||||
}
|
||||
|
||||
if (item is KasaOfTheRajin && ((KasaOfTheRajin)item).Attributes.DefendChance != 10)
|
||||
{
|
||||
((KasaOfTheRajin)item).Attributes.DefendChance = 10;
|
||||
}
|
||||
|
||||
if (item is MaceAndShieldGlasses && ((MaceAndShieldGlasses)item).Attributes.WeaponDamage != 10)
|
||||
{
|
||||
((MaceAndShieldGlasses)item).Attributes.WeaponDamage = 10;
|
||||
}
|
||||
|
||||
if (item is VesperOrderShield && ((VesperOrderShield)item).Attributes.CastSpeed != 0)
|
||||
{
|
||||
((VesperOrderShield)item).Attributes.CastSpeed = 0;
|
||||
|
||||
if (item.Name != "Order Shield")
|
||||
item.Name = "Order Shield";
|
||||
}
|
||||
|
||||
if (item is OrnamentOfTheMagician && ((OrnamentOfTheMagician)item).Attributes.RegenMana != 3)
|
||||
{
|
||||
((OrnamentOfTheMagician)item).Attributes.RegenMana = 3;
|
||||
}
|
||||
|
||||
if (item is RingOfTheVile && ((RingOfTheVile)item).Attributes.AttackChance != 25)
|
||||
{
|
||||
((RingOfTheVile)item).Attributes.AttackChance = 25;
|
||||
}
|
||||
|
||||
if (item is RuneBeetleCarapace)
|
||||
{
|
||||
if (((RuneBeetleCarapace)item).PhysicalBonus != 3)
|
||||
((RuneBeetleCarapace)item).PhysicalBonus = 3;
|
||||
|
||||
if (((RuneBeetleCarapace)item).FireBonus != 3)
|
||||
((RuneBeetleCarapace)item).FireBonus = 3;
|
||||
|
||||
if (((RuneBeetleCarapace)item).ColdBonus != 3)
|
||||
((RuneBeetleCarapace)item).ColdBonus = 3;
|
||||
|
||||
if (((RuneBeetleCarapace)item).PoisonBonus != 3)
|
||||
((RuneBeetleCarapace)item).PoisonBonus = 3;
|
||||
|
||||
if (((RuneBeetleCarapace)item).EnergyBonus != 3)
|
||||
((RuneBeetleCarapace)item).EnergyBonus = 3;
|
||||
}
|
||||
|
||||
if (item is SpiritOfTheTotem)
|
||||
{
|
||||
if (((SpiritOfTheTotem)item).Resistances.Fire != 7)
|
||||
((SpiritOfTheTotem)item).Resistances.Fire = 7;
|
||||
|
||||
if (((SpiritOfTheTotem)item).Resistances.Cold != 2)
|
||||
((SpiritOfTheTotem)item).Resistances.Cold = 2;
|
||||
|
||||
if (((SpiritOfTheTotem)item).Resistances.Poison != 6)
|
||||
((SpiritOfTheTotem)item).Resistances.Poison = 6;
|
||||
|
||||
if (((SpiritOfTheTotem)item).Resistances.Energy != 6)
|
||||
((SpiritOfTheTotem)item).Resistances.Energy = 6;
|
||||
}
|
||||
|
||||
if (item is Stormgrip && ((Stormgrip)item).Attributes.AttackChance != 10)
|
||||
{
|
||||
((Stormgrip)item).Attributes.AttackChance = 10;
|
||||
}
|
||||
|
||||
if (item is InquisitorsResolution)
|
||||
{
|
||||
if (((InquisitorsResolution)item).PhysicalBonus != 5)
|
||||
((InquisitorsResolution)item).PhysicalBonus = 5;
|
||||
|
||||
if (((InquisitorsResolution)item).FireBonus != 7)
|
||||
((InquisitorsResolution)item).FireBonus = 7;
|
||||
|
||||
if (((InquisitorsResolution)item).ColdBonus != -2)
|
||||
((InquisitorsResolution)item).ColdBonus = -2;
|
||||
|
||||
if (((InquisitorsResolution)item).PoisonBonus != 7)
|
||||
((InquisitorsResolution)item).PoisonBonus = 7;
|
||||
|
||||
if (((InquisitorsResolution)item).EnergyBonus != -7)
|
||||
((InquisitorsResolution)item).EnergyBonus = -7;
|
||||
}
|
||||
|
||||
if (item is TomeOfLostKnowledge && ((TomeOfLostKnowledge)item).Attributes.RegenMana != 3)
|
||||
{
|
||||
((TomeOfLostKnowledge)item).Attributes.RegenMana = 3;
|
||||
}
|
||||
|
||||
if (item is WizardsCrystalGlasses)
|
||||
{
|
||||
if (((WizardsCrystalGlasses)item).PhysicalBonus != 5)
|
||||
((WizardsCrystalGlasses)item).PhysicalBonus = 5;
|
||||
|
||||
if (((WizardsCrystalGlasses)item).FireBonus != 5)
|
||||
((WizardsCrystalGlasses)item).FireBonus = 5;
|
||||
|
||||
if (((WizardsCrystalGlasses)item).ColdBonus != 5)
|
||||
((WizardsCrystalGlasses)item).ColdBonus = 5;
|
||||
|
||||
if (((WizardsCrystalGlasses)item).PoisonBonus != 5)
|
||||
((WizardsCrystalGlasses)item).PoisonBonus = 5;
|
||||
|
||||
if (((WizardsCrystalGlasses)item).EnergyBonus != 5)
|
||||
((WizardsCrystalGlasses)item).EnergyBonus = 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class FactionCollectionItem : CollectionItem
|
||||
{
|
||||
public int MinRank { get; private set; }
|
||||
public Faction Faction { get; private set; }
|
||||
|
||||
public FactionCollectionItem(Type type, int id, int tooltip, int hue, Faction faction, double points, int minRank)
|
||||
: base(type, id, tooltip, hue, points)
|
||||
{
|
||||
Faction = faction;
|
||||
MinRank = minRank;
|
||||
}
|
||||
|
||||
public override void OnGiveReward(PlayerMobile to, Item item, IComunityCollection collection, int hue)
|
||||
{
|
||||
if(this.Faction != null)
|
||||
{
|
||||
FactionEquipment.CheckProperties(item);
|
||||
FactionItem.Imbue(item, Faction, false, -1, MinRank);
|
||||
|
||||
if (!(item is Spellbook || item is ShrineGem))
|
||||
item.LootType = LootType.Regular;
|
||||
|
||||
if (item is IWearableDurability)
|
||||
{
|
||||
((IWearableDurability)item).MaxHitPoints = 255;
|
||||
((IWearableDurability)item).HitPoints = 255;
|
||||
}
|
||||
|
||||
if (item is IOwnerRestricted)
|
||||
{
|
||||
((IOwnerRestricted)item).Owner = to;
|
||||
to.SendLocalizedMessage(1094803); // This faction reward is bound to you, and cannot be traded.
|
||||
}
|
||||
|
||||
item.InvalidateProperties();
|
||||
}
|
||||
|
||||
base.OnGiveReward(to, item, collection, hue);
|
||||
}
|
||||
|
||||
public override bool CanSelect(PlayerMobile from)
|
||||
{
|
||||
PlayerState state = PlayerState.Find(from);
|
||||
|
||||
|
||||
return from.AccessLevel > AccessLevel.Player || (state != null && state.Rank.Rank >= MinRank);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
using System;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
using Server.Gumps;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class PowderOfPerseverance : Item, IFactionItem
|
||||
{
|
||||
public override int LabelNumber { get { return 1094756; } } // Powder of Perseverance
|
||||
|
||||
#region Factions
|
||||
private FactionItem m_FactionState;
|
||||
|
||||
public FactionItem FactionItemState
|
||||
{
|
||||
get { return m_FactionState; }
|
||||
set
|
||||
{
|
||||
m_FactionState = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
public PowderOfPerseverance()
|
||||
: base(4102)
|
||||
{
|
||||
Hue = 2419;
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if(IsChildOf(from.Backpack))
|
||||
{
|
||||
if (FactionEquipment.CanUse(this, from))
|
||||
{
|
||||
from.BeginTarget(-1, false, Server.Targeting.TargetFlags.None, (m, targeted) =>
|
||||
{
|
||||
if (targeted is IFactionItem && targeted is IWearableDurability)
|
||||
{
|
||||
IWearableDurability durability = targeted as IWearableDurability;
|
||||
|
||||
if (durability.HitPoints >= durability.MaxHitPoints)
|
||||
{
|
||||
m.SendLocalizedMessage(1094761); // This item is already in perfect condition.
|
||||
}
|
||||
else if (durability.MaxHitPoints <= 125)
|
||||
{
|
||||
m.SendLocalizedMessage(1049083); // You cannot use the powder on that item.
|
||||
}
|
||||
else
|
||||
{
|
||||
if (durability.MaxHitPoints == 255)
|
||||
{
|
||||
durability.MaxHitPoints = 225;
|
||||
}
|
||||
else
|
||||
{
|
||||
durability.MaxHitPoints -= 25;
|
||||
}
|
||||
|
||||
durability.HitPoints = durability.MaxHitPoints;
|
||||
|
||||
m.SendLocalizedMessage(1049084); // You successfully use the powder on the item.
|
||||
m.SendLocalizedMessage(1094760); // You have used up your Powder of Perseverance.
|
||||
m.PlaySound(0x247);
|
||||
|
||||
Delete();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m.SendLocalizedMessage(1049083); // You cannot use the powder on that item.
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
|
||||
}
|
||||
}
|
||||
|
||||
public override void GetProperties(ObjectPropertyList list)
|
||||
{
|
||||
base.GetProperties(list);
|
||||
|
||||
list.Add(1060584, "1"); // uses remaining: ~1_val~
|
||||
|
||||
FactionEquipment.AddFactionProperties(this, list);
|
||||
}
|
||||
|
||||
public PowderOfPerseverance(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
125
Scripts/Services/Factions/Items/Equipment/ShrineGem.cs
Normal file
125
Scripts/Services/Factions/Items/Equipment/ShrineGem.cs
Normal file
@@ -0,0 +1,125 @@
|
||||
using System;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
using Server.Gumps;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class ShrineGem : Item, IFactionItem
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
EventSink.PlayerDeath += OnPlayerDeath;
|
||||
}
|
||||
|
||||
public static void OnPlayerDeath(PlayerDeathEventArgs e)
|
||||
{
|
||||
if (e.Mobile is PlayerMobile && e.Mobile.Backpack != null)
|
||||
{
|
||||
var state = PlayerState.Find(e.Mobile);
|
||||
|
||||
if(state != null)
|
||||
{
|
||||
ShrineGem gem = null;
|
||||
|
||||
foreach (var item in e.Mobile.Backpack.Items)
|
||||
{
|
||||
if (item is ShrineGem && ((ShrineGem)item).FactionItemState.Faction == state.Faction)
|
||||
{
|
||||
gem = (ShrineGem)item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Console.WriteLine("Gem: {0}", gem);
|
||||
if (gem != null)
|
||||
{
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(2.5), () =>
|
||||
{
|
||||
BaseGump.SendGump(new ConfirmCallbackGump((PlayerMobile)e.Mobile, 1094715, 1094716, gem, null,
|
||||
(m, obj) =>
|
||||
{
|
||||
ShrineGem g = obj as ShrineGem;
|
||||
|
||||
if (g != null && !g.Deleted && g.IsChildOf(m.Backpack))
|
||||
{
|
||||
Point3D p = _ShrineLocs[Utility.Random(_ShrineLocs.Length)];
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(1), () =>
|
||||
{
|
||||
m.PlaySound(0x1FC);
|
||||
m.MoveToWorld(p, m.Map);
|
||||
m.PlaySound(0x1FC);
|
||||
|
||||
g.Delete();
|
||||
});
|
||||
}
|
||||
}));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly Point3D[] _ShrineLocs = new Point3D[]
|
||||
{
|
||||
new Point3D(1470, 843, 0),
|
||||
new Point3D(1857, 865, -1),
|
||||
new Point3D(4220, 563, 36),
|
||||
new Point3D(1732, 3528, 0),
|
||||
new Point3D(1300, 644, 8),
|
||||
new Point3D(3355, 302, 9),
|
||||
new Point3D(1606, 2490, 5),
|
||||
new Point3D(2500, 3931, 3),
|
||||
new Point3D(4264, 3707, 0)
|
||||
};
|
||||
|
||||
public override int LabelNumber { get { return 1094711; } } // Shrine Gem
|
||||
|
||||
#region Factions
|
||||
private FactionItem m_FactionState;
|
||||
|
||||
public FactionItem FactionItemState
|
||||
{
|
||||
get { return m_FactionState; }
|
||||
set
|
||||
{
|
||||
m_FactionState = value;
|
||||
|
||||
Hue = m_FactionState != null ? m_FactionState.Faction.Definition.HuePrimary : 0;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
public ShrineGem()
|
||||
: base(0x1EA7)
|
||||
{
|
||||
LootType = LootType.Blessed;
|
||||
}
|
||||
|
||||
public override void GetProperties(ObjectPropertyList list)
|
||||
{
|
||||
base.GetProperties(list);
|
||||
FactionEquipment.AddFactionProperties(this, list);
|
||||
}
|
||||
|
||||
public ShrineGem(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
154
Scripts/Services/Factions/Items/Equipment/StrongholdRune.cs
Normal file
154
Scripts/Services/Factions/Items/Equipment/StrongholdRune.cs
Normal file
@@ -0,0 +1,154 @@
|
||||
using System;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class StrongholdRune : Item, IFactionItem
|
||||
{
|
||||
public override int LabelNumber { get { return 1094700; } } // Faction Stronghold Rune
|
||||
|
||||
#region Factions
|
||||
private FactionItem m_FactionState;
|
||||
|
||||
public FactionItem FactionItemState
|
||||
{
|
||||
get { return m_FactionState; }
|
||||
set
|
||||
{
|
||||
m_FactionState = value;
|
||||
|
||||
Hue = m_FactionState != null ? m_FactionState.Faction.Definition.HuePrimary : 0;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
public StrongholdRune()
|
||||
: base(0x1F14)
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile m)
|
||||
{
|
||||
if (IsChildOf(m.Backpack))
|
||||
{
|
||||
if (FactionEquipment.CanUse(this, m))
|
||||
{
|
||||
if (!IsInCooldown(m))
|
||||
{
|
||||
Timer.DelayCall<Mobile>(TimeSpan.FromSeconds(1), Warp, m);
|
||||
}
|
||||
else
|
||||
{
|
||||
m.SendLocalizedMessage(501789); // You must wait before trying again.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m.SendMessage("You are not the proper faction to use this item.");
|
||||
//TODO: Message
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void GetProperties(ObjectPropertyList list)
|
||||
{
|
||||
base.GetProperties(list);
|
||||
FactionEquipment.AddFactionProperties(this, list);
|
||||
}
|
||||
|
||||
private void Warp(Mobile m)
|
||||
{
|
||||
Point3D p = GetStoneLocation();
|
||||
Map map = Faction.Facet;
|
||||
|
||||
int x = p.X;
|
||||
int y = p.Y;
|
||||
int z = p.Z;
|
||||
|
||||
if (p != Point3D.Zero)
|
||||
{
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
x = p.X + Utility.RandomMinMax(-4, 4);
|
||||
y = p.Y + Utility.RandomMinMax(-4, 4);
|
||||
z = map.GetAverageZ(x, y);
|
||||
|
||||
Point3D temp = new Point3D(x, y, z);
|
||||
|
||||
if (map.CanSpawnMobile(temp))
|
||||
{
|
||||
p = temp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m.PlaySound(0x1FC);
|
||||
m.MoveToWorld(p, map);
|
||||
m.PlaySound(0x1FC);
|
||||
|
||||
m.SendLocalizedMessage(1094706); // Your faction stronghold rune has disappeared.
|
||||
|
||||
if (m.AccessLevel == AccessLevel.Player)
|
||||
Delete();
|
||||
|
||||
AddToCooldown(m);
|
||||
}
|
||||
}
|
||||
|
||||
private Point3D GetStoneLocation()
|
||||
{
|
||||
if (FactionItemState == null)
|
||||
{
|
||||
return Point3D.Zero;
|
||||
}
|
||||
|
||||
return FactionItemState.Faction.Definition.Stronghold.FactionStone;
|
||||
}
|
||||
|
||||
public static List<Mobile> Cooldown = new List<Mobile>();
|
||||
|
||||
public static bool IsInCooldown(Mobile m)
|
||||
{
|
||||
return Cooldown.Contains(m);
|
||||
}
|
||||
|
||||
public static void AddToCooldown(Mobile m)
|
||||
{
|
||||
Cooldown.Add(m);
|
||||
|
||||
int minutes = 30;
|
||||
|
||||
PlayerState ps = PlayerState.Find(m);
|
||||
|
||||
if(ps != null)
|
||||
minutes = 30 - (ps.Rank.Rank * 2);
|
||||
|
||||
Timer.DelayCall<Mobile>(TimeSpan.FromMinutes(minutes), mob =>
|
||||
{
|
||||
Cooldown.Remove(mob);
|
||||
}, m);
|
||||
}
|
||||
|
||||
public StrongholdRune(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
113
Scripts/Services/Factions/Items/FactionStone.cs
Normal file
113
Scripts/Services/Factions/Items/FactionStone.cs
Normal file
@@ -0,0 +1,113 @@
|
||||
using System;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionStone : BaseSystemController
|
||||
{
|
||||
private Faction m_Faction;
|
||||
[Constructable]
|
||||
public FactionStone()
|
||||
: this(null)
|
||||
{
|
||||
}
|
||||
|
||||
[Constructable]
|
||||
public FactionStone(Faction faction)
|
||||
: base(0xEDC)
|
||||
{
|
||||
this.Movable = false;
|
||||
this.Faction = faction;
|
||||
}
|
||||
|
||||
public FactionStone(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
|
||||
public Faction Faction
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Faction;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_Faction = value;
|
||||
|
||||
this.AssignName(this.m_Faction == null ? null : this.m_Faction.Definition.FactionStoneName);
|
||||
}
|
||||
}
|
||||
public override string DefaultName
|
||||
{
|
||||
get
|
||||
{
|
||||
return "faction stone";
|
||||
}
|
||||
}
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (this.m_Faction == null)
|
||||
return;
|
||||
|
||||
if (!from.InRange(this.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 (from is PlayerMobile)
|
||||
{
|
||||
Faction existingFaction = Faction.Find(from);
|
||||
|
||||
if (existingFaction == this.m_Faction || from.AccessLevel >= AccessLevel.GameMaster)
|
||||
{
|
||||
PlayerState pl = PlayerState.Find(from);
|
||||
|
||||
if (pl != null && pl.IsLeaving)
|
||||
from.SendLocalizedMessage(1005051); // You cannot use the faction stone until you have finished quitting your current faction
|
||||
else
|
||||
from.SendGump(new FactionStoneGump((PlayerMobile)from, this.m_Faction));
|
||||
}
|
||||
else if (existingFaction != null)
|
||||
{
|
||||
// TODO: Validate
|
||||
from.SendLocalizedMessage(1005053); // This is not your faction stone!
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendGump(new JoinStoneGump((PlayerMobile)from, this.m_Faction));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
|
||||
Faction.WriteReference(writer, this.m_Faction);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
this.Faction = Faction.ReadReference(reader);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
89
Scripts/Services/Factions/Items/JoinStone.cs
Normal file
89
Scripts/Services/Factions/Items/JoinStone.cs
Normal file
@@ -0,0 +1,89 @@
|
||||
using System;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class JoinStone : BaseSystemController
|
||||
{
|
||||
private Faction m_Faction;
|
||||
[Constructable]
|
||||
public JoinStone()
|
||||
: this(null)
|
||||
{
|
||||
}
|
||||
|
||||
[Constructable]
|
||||
public JoinStone(Faction faction)
|
||||
: base(0xEDC)
|
||||
{
|
||||
this.Movable = false;
|
||||
this.Faction = faction;
|
||||
}
|
||||
|
||||
public JoinStone(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
|
||||
public Faction Faction
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Faction;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_Faction = value;
|
||||
|
||||
this.Hue = (this.m_Faction == null ? 0 : this.m_Faction.Definition.HueJoin);
|
||||
this.AssignName(this.m_Faction == null ? null : this.m_Faction.Definition.SignupName);
|
||||
}
|
||||
}
|
||||
public override string DefaultName
|
||||
{
|
||||
get
|
||||
{
|
||||
return "faction signup stone";
|
||||
}
|
||||
}
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (this.m_Faction == null)
|
||||
return;
|
||||
|
||||
if (!from.InRange(this.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)
|
||||
from.SendGump(new JoinStoneGump((PlayerMobile)from, this.m_Faction));
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
|
||||
Faction.WriteReference(writer, this.m_Faction);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
this.Faction = Faction.ReadReference(reader);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
546
Scripts/Services/Factions/Items/Sigil.cs
Normal file
546
Scripts/Services/Factions/Items/Sigil.cs
Normal file
@@ -0,0 +1,546 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
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 BaseMonolith m_LastMonolith;
|
||||
|
||||
private Town m_Town;
|
||||
private Faction m_Corrupted;
|
||||
private Faction m_Corrupting;
|
||||
|
||||
private DateTime m_LastStolen;
|
||||
private DateTime m_GraceStart;
|
||||
private DateTime m_CorruptionStart;
|
||||
private DateTime m_PurificationStart;
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
|
||||
public DateTime LastStolen
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_LastStolen;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_LastStolen = value;
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
|
||||
public DateTime GraceStart
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_GraceStart;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_GraceStart = value;
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
|
||||
public DateTime CorruptionStart
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_CorruptionStart;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_CorruptionStart = value;
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
|
||||
public DateTime PurificationStart
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_PurificationStart;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_PurificationStart = value;
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
|
||||
public Town Town
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Town;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_Town = value;
|
||||
this.Update();
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
|
||||
public Faction Corrupted
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Corrupted;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_Corrupted = value;
|
||||
this.Update();
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
|
||||
public Faction Corrupting
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Corrupting;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_Corrupting = value;
|
||||
this.Update();
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
|
||||
public BaseMonolith LastMonolith
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_LastMonolith;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_LastMonolith = value;
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public bool IsBeingCorrupted
|
||||
{
|
||||
get
|
||||
{
|
||||
return (this.m_LastMonolith is StrongholdMonolith && this.m_LastMonolith.Faction == this.m_Corrupting && this.m_Corrupting != null);
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public bool IsCorrupted
|
||||
{
|
||||
get
|
||||
{
|
||||
return (this.m_Corrupted != null);
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public bool IsPurifying
|
||||
{
|
||||
get
|
||||
{
|
||||
return (this.m_PurificationStart != DateTime.MinValue);
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public bool IsCorrupting
|
||||
{
|
||||
get
|
||||
{
|
||||
return (this.m_Corrupting != null && this.m_Corrupting != this.m_Corrupted);
|
||||
}
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
this.ItemID = (this.m_Town == null ? 0x1869 : this.m_Town.Definition.SigilID);
|
||||
|
||||
if (this.m_Town == null)
|
||||
this.AssignName(null);
|
||||
else if (this.IsCorrupted || this.IsPurifying)
|
||||
this.AssignName(this.m_Town.Definition.CorruptedSigilName);
|
||||
else
|
||||
this.AssignName(this.m_Town.Definition.SigilName);
|
||||
|
||||
this.InvalidateProperties();
|
||||
}
|
||||
|
||||
public override void GetProperties(ObjectPropertyList list)
|
||||
{
|
||||
base.GetProperties(list);
|
||||
|
||||
if (this.IsCorrupted)
|
||||
TextDefinition.AddTo(list, this.m_Corrupted.Definition.SigilControl);
|
||||
else
|
||||
list.Add(1042256); // This sigil is not corrupted.
|
||||
|
||||
if (this.IsCorrupting)
|
||||
list.Add(1042257); // This sigil is in the process of being corrupted.
|
||||
else if (this.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 (this.IsCorrupted)
|
||||
{
|
||||
if (this.m_Corrupted.Definition.SigilControl.Number > 0)
|
||||
this.LabelTo(from, this.m_Corrupted.Definition.SigilControl.Number);
|
||||
else if (this.m_Corrupted.Definition.SigilControl.String != null)
|
||||
this.LabelTo(from, this.m_Corrupted.Definition.SigilControl.String);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.LabelTo(from, 1042256); // This sigil is not corrupted.
|
||||
}
|
||||
|
||||
if (this.IsCorrupting)
|
||||
this.LabelTo(from, 1042257); // This sigil is in the process of being corrupted.
|
||||
else if (this.IsPurifying)
|
||||
this.LabelTo(from, 1042258); // This sigil has been recently corrupted, and is undergoing purification.
|
||||
else
|
||||
this.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(object parent)
|
||||
{
|
||||
if (parent is Item)
|
||||
return ((Item)parent).RootParent as Mobile;
|
||||
|
||||
if (parent is Mobile)
|
||||
return (Mobile)parent;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public override void OnAdded(object parent)
|
||||
{
|
||||
base.OnAdded(parent);
|
||||
|
||||
Mobile mob = this.FindOwner(parent);
|
||||
|
||||
if (mob != null)
|
||||
mob.SolidHueOverride = OwnershipHue;
|
||||
}
|
||||
|
||||
public override void OnRemoved(object parent)
|
||||
{
|
||||
base.OnRemoved(parent);
|
||||
|
||||
Mobile mob = this.FindOwner(parent);
|
||||
|
||||
if (mob != null)
|
||||
mob.SolidHueOverride = -1;
|
||||
}
|
||||
|
||||
public Sigil(Town town)
|
||||
: base(0x1869)
|
||||
{
|
||||
this.Movable = false;
|
||||
this.Town = town;
|
||||
|
||||
m_Sigils.Add(this);
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (this.IsChildOf(from.Backpack))
|
||||
{
|
||||
from.BeginTarget(1, false, Targeting.TargetFlags.None, new TargetCallback(Sigil_OnTarget));
|
||||
from.SendLocalizedMessage(1042251); // Click on a sigil monolith or player
|
||||
}
|
||||
}
|
||||
|
||||
public static bool ExistsOn(Mobile mob, bool vvvOnly = false)
|
||||
{
|
||||
if (mob == null || mob.Backpack == null)
|
||||
return false;
|
||||
|
||||
Container pack = mob.Backpack;
|
||||
|
||||
if (Server.Engines.VvV.ViceVsVirtueSystem.Enabled && vvvOnly && pack.FindItemByType(typeof(Server.Engines.VvV.VvVSigil)) != null)
|
||||
return true;
|
||||
|
||||
return (pack.FindItemByType(typeof(Sigil)) != null || pack.FindItemByType(typeof(Server.Engines.VvV.VvVSigil)) != null);
|
||||
}
|
||||
|
||||
private void BeginCorrupting(Faction faction)
|
||||
{
|
||||
this.m_Corrupting = faction;
|
||||
this.m_CorruptionStart = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
private void ClearCorrupting()
|
||||
{
|
||||
this.m_Corrupting = null;
|
||||
this.m_CorruptionStart = DateTime.MinValue;
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public TimeSpan TimeUntilCorruption
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!this.IsBeingCorrupted)
|
||||
return TimeSpan.Zero;
|
||||
|
||||
TimeSpan ts = (this.m_CorruptionStart + CorruptionPeriod) - DateTime.UtcNow;
|
||||
|
||||
if (ts < TimeSpan.Zero)
|
||||
ts = TimeSpan.Zero;
|
||||
|
||||
return ts;
|
||||
}
|
||||
}
|
||||
|
||||
private void Sigil_OnTarget(Mobile from, object obj)
|
||||
{
|
||||
if (this.Deleted || !this.IsChildOf(from.Backpack))
|
||||
return;
|
||||
|
||||
#region Give To Mobile
|
||||
if (obj is Mobile)
|
||||
{
|
||||
if (obj is PlayerMobile)
|
||||
{
|
||||
PlayerMobile targ = (PlayerMobile)obj;
|
||||
|
||||
Faction toFaction = Faction.Find(targ);
|
||||
Faction 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 (Sigil.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)
|
||||
{
|
||||
Container pack = targ.Backpack;
|
||||
|
||||
if (pack != null)
|
||||
pack.DropItem(this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(1005221); //You cannot give the sigil to them
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
else if (obj is BaseMonolith)
|
||||
{
|
||||
#region Put in Stronghold
|
||||
if (obj is StrongholdMonolith)
|
||||
{
|
||||
StrongholdMonolith m = (StrongholdMonolith)obj;
|
||||
|
||||
if (m.Faction == null || m.Faction != Faction.Find(from))
|
||||
from.SendLocalizedMessage(1042246); // You can't place that on an enemy monolith
|
||||
else if (m.Town == null || m.Town != this.m_Town)
|
||||
from.SendLocalizedMessage(1042247); // That is not the correct faction monolith
|
||||
else
|
||||
{
|
||||
m.Sigil = this;
|
||||
|
||||
Faction newController = m.Faction;
|
||||
Faction oldController = this.m_Corrupting;
|
||||
|
||||
if (oldController == null)
|
||||
{
|
||||
if (this.m_Corrupted != newController)
|
||||
this.BeginCorrupting(newController);
|
||||
}
|
||||
else if (this.m_GraceStart > DateTime.MinValue && (this.m_GraceStart + CorruptionGrace) < DateTime.UtcNow)
|
||||
{
|
||||
if (this.m_Corrupted != newController)
|
||||
this.BeginCorrupting(newController); // grace time over, reset period
|
||||
else
|
||||
this.ClearCorrupting();
|
||||
|
||||
this.m_GraceStart = DateTime.MinValue;
|
||||
}
|
||||
else if (newController == oldController)
|
||||
{
|
||||
this.m_GraceStart = DateTime.MinValue; // returned within grace period
|
||||
}
|
||||
else if (this.m_GraceStart == DateTime.MinValue)
|
||||
{
|
||||
this.m_GraceStart = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
this.m_PurificationStart = DateTime.MinValue;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region Put in Town
|
||||
else if (obj is TownMonolith)
|
||||
{
|
||||
TownMonolith m = (TownMonolith)obj;
|
||||
|
||||
if (m.Town == null || m.Town != this.m_Town)
|
||||
from.SendLocalizedMessage(1042245); // This is not the correct town sigil monolith
|
||||
else if (this.m_Corrupted == null || this.m_Corrupted != Faction.Find(from))
|
||||
from.SendLocalizedMessage(1042244); // Your faction did not corrupt this sigil. Take it to your stronghold.
|
||||
else
|
||||
{
|
||||
m.Sigil = this;
|
||||
|
||||
this.m_Corrupting = null;
|
||||
this.m_PurificationStart = DateTime.UtcNow;
|
||||
this.m_CorruptionStart = DateTime.MinValue;
|
||||
|
||||
this.m_Town.Capture(this.m_Corrupted);
|
||||
this.m_Corrupted = null;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(1005224); // You can't use the sigil on that
|
||||
}
|
||||
|
||||
this.Update();
|
||||
}
|
||||
|
||||
public Sigil(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
m_Sigils.Add(this);
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
|
||||
Town.WriteReference(writer, this.m_Town);
|
||||
Faction.WriteReference(writer, this.m_Corrupted);
|
||||
Faction.WriteReference(writer, this.m_Corrupting);
|
||||
|
||||
writer.Write((Item)this.m_LastMonolith);
|
||||
|
||||
writer.Write(this.m_LastStolen);
|
||||
writer.Write(this.m_GraceStart);
|
||||
writer.Write(this.m_CorruptionStart);
|
||||
writer.Write(this.m_PurificationStart);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
this.m_Town = Town.ReadReference(reader);
|
||||
this.m_Corrupted = Faction.ReadReference(reader);
|
||||
this.m_Corrupting = Faction.ReadReference(reader);
|
||||
|
||||
this.m_LastMonolith = reader.ReadItem() as BaseMonolith;
|
||||
|
||||
this.m_LastStolen = reader.ReadDateTime();
|
||||
this.m_GraceStart = reader.ReadDateTime();
|
||||
this.m_CorruptionStart = reader.ReadDateTime();
|
||||
this.m_PurificationStart = reader.ReadDateTime();
|
||||
|
||||
this.Update();
|
||||
|
||||
Mobile mob = this.RootParent as Mobile;
|
||||
|
||||
if (mob != null)
|
||||
mob.SolidHueOverride = OwnershipHue;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool ReturnHome()
|
||||
{
|
||||
BaseMonolith monolith = this.m_LastMonolith;
|
||||
|
||||
if (monolith == null && this.m_Town != null)
|
||||
monolith = this.m_Town.Monolith;
|
||||
|
||||
if (monolith != null && !monolith.Deleted)
|
||||
monolith.Sigil = this;
|
||||
|
||||
return (monolith != null && !monolith.Deleted);
|
||||
}
|
||||
|
||||
public override void OnParentDeleted(object parent)
|
||||
{
|
||||
base.OnParentDeleted(parent);
|
||||
|
||||
this.ReturnHome();
|
||||
}
|
||||
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
base.OnAfterDelete();
|
||||
|
||||
m_Sigils.Remove(this);
|
||||
}
|
||||
|
||||
public override void Delete()
|
||||
{
|
||||
if (this.ReturnHome())
|
||||
return;
|
||||
|
||||
base.Delete();
|
||||
}
|
||||
|
||||
private static readonly List<Sigil> m_Sigils = new List<Sigil>();
|
||||
|
||||
public static List<Sigil> Sigils
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Sigils;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
63
Scripts/Services/Factions/Items/Silver.cs
Normal file
63
Scripts/Services/Factions/Items/Silver.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class Silver : Item
|
||||
{
|
||||
[Constructable]
|
||||
public Silver()
|
||||
: this(1)
|
||||
{
|
||||
}
|
||||
|
||||
[Constructable]
|
||||
public Silver(int amountFrom, int amountTo)
|
||||
: this(Utility.RandomMinMax(amountFrom, amountTo))
|
||||
{
|
||||
}
|
||||
|
||||
[Constructable]
|
||||
public Silver(int amount)
|
||||
: base(0xEF0)
|
||||
{
|
||||
this.Stackable = true;
|
||||
this.Amount = amount;
|
||||
}
|
||||
|
||||
public Silver(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override double DefaultWeight
|
||||
{
|
||||
get
|
||||
{
|
||||
return 0.02;
|
||||
}
|
||||
}
|
||||
public override int GetDropSound()
|
||||
{
|
||||
if (this.Amount <= 1)
|
||||
return 0x2E4;
|
||||
else if (this.Amount <= 5)
|
||||
return 0x2E5;
|
||||
else
|
||||
return 0x2E6;
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
48
Scripts/Services/Factions/Items/StrongholdMonolith.cs
Normal file
48
Scripts/Services/Factions/Items/StrongholdMonolith.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class StrongholdMonolith : BaseMonolith
|
||||
{
|
||||
public StrongholdMonolith()
|
||||
: this(null, null)
|
||||
{
|
||||
}
|
||||
|
||||
public StrongholdMonolith(Town town, Faction faction)
|
||||
: base(town, faction)
|
||||
{
|
||||
}
|
||||
|
||||
public StrongholdMonolith(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override int DefaultLabelNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return 1041042;
|
||||
}
|
||||
}// A Faction Sigil Monolith
|
||||
public override void OnTownChanged()
|
||||
{
|
||||
this.AssignName(this.Town == null ? null : this.Town.Definition.StrongholdMonolithName);
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
48
Scripts/Services/Factions/Items/TownMonolith.cs
Normal file
48
Scripts/Services/Factions/Items/TownMonolith.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class TownMonolith : BaseMonolith
|
||||
{
|
||||
public TownMonolith()
|
||||
: this(null)
|
||||
{
|
||||
}
|
||||
|
||||
public TownMonolith(Town town)
|
||||
: base(town, null)
|
||||
{
|
||||
}
|
||||
|
||||
public TownMonolith(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override int DefaultLabelNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return 1041403;
|
||||
}
|
||||
}// A Faction Town Sigil Monolith
|
||||
public override void OnTownChanged()
|
||||
{
|
||||
this.AssignName(this.Town == null ? null : this.Town.Definition.TownMonolithName);
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
94
Scripts/Services/Factions/Items/TownStone.cs
Normal file
94
Scripts/Services/Factions/Items/TownStone.cs
Normal file
@@ -0,0 +1,94 @@
|
||||
using System;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class TownStone : BaseSystemController
|
||||
{
|
||||
private Town m_Town;
|
||||
[Constructable]
|
||||
public TownStone()
|
||||
: this(null)
|
||||
{
|
||||
}
|
||||
|
||||
[Constructable]
|
||||
public TownStone(Town town)
|
||||
: base(0xEDE)
|
||||
{
|
||||
this.Movable = false;
|
||||
this.Town = town;
|
||||
}
|
||||
|
||||
public TownStone(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
|
||||
public Town Town
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Town;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_Town = value;
|
||||
|
||||
this.AssignName(this.m_Town == null ? null : this.m_Town.Definition.TownStoneName);
|
||||
}
|
||||
}
|
||||
public override string DefaultName
|
||||
{
|
||||
get
|
||||
{
|
||||
return "faction town stone";
|
||||
}
|
||||
}
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (this.m_Town == null)
|
||||
return;
|
||||
|
||||
Faction faction = Faction.Find(from);
|
||||
|
||||
if (faction == null && from.AccessLevel < AccessLevel.GameMaster)
|
||||
return; // TODO: Message?
|
||||
|
||||
if (this.m_Town.Owner == null || (from.AccessLevel < AccessLevel.GameMaster && faction != this.m_Town.Owner))
|
||||
from.SendLocalizedMessage(1010332); // Your faction does not control this town
|
||||
else if (!this.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)
|
||||
from.SendGump(new TownStoneGump((PlayerMobile)from, this.m_Town.Owner, this.m_Town));
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
|
||||
Town.WriteReference(writer, this.m_Town);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
this.Town = Town.ReadReference(reader);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
359
Scripts/Services/Factions/Items/Traps/BaseFactionTrap.cs
Normal file
359
Scripts/Services/Factions/Items/Traps/BaseFactionTrap.cs
Normal file
@@ -0,0 +1,359 @@
|
||||
using System;
|
||||
using Server.Items;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public enum AllowedPlacing
|
||||
{
|
||||
Everywhere,
|
||||
|
||||
AnyFactionTown,
|
||||
ControlledFactionTown,
|
||||
FactionStronghold
|
||||
}
|
||||
|
||||
public abstract class BaseFactionTrap : BaseTrap, IRevealableItem
|
||||
{
|
||||
private Faction m_Faction;
|
||||
private Mobile m_Placer;
|
||||
private DateTime m_TimeOfPlacement;
|
||||
private Timer m_Concealing;
|
||||
|
||||
public bool CheckWhenHidden { get { return true; } }
|
||||
|
||||
public BaseFactionTrap(Faction f, Mobile m, int itemID)
|
||||
: base(itemID)
|
||||
{
|
||||
Visible = false;
|
||||
|
||||
m_Faction = f;
|
||||
m_TimeOfPlacement = DateTime.UtcNow;
|
||||
m_Placer = m;
|
||||
}
|
||||
|
||||
public BaseFactionTrap(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Faction Faction
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Faction;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_Faction = value;
|
||||
}
|
||||
}
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Mobile Placer
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Placer;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_Placer = value;
|
||||
}
|
||||
}
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public DateTime TimeOfPlacement
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_TimeOfPlacement;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_TimeOfPlacement = value;
|
||||
}
|
||||
}
|
||||
public virtual int EffectSound
|
||||
{
|
||||
get
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
public virtual int SilverFromDisarm
|
||||
{
|
||||
get
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
}
|
||||
public virtual int MessageHue
|
||||
{
|
||||
get
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
public virtual int AttackMessage
|
||||
{
|
||||
get
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
public virtual int DisarmMessage
|
||||
{
|
||||
get
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
public virtual AllowedPlacing AllowedPlacing
|
||||
{
|
||||
get
|
||||
{
|
||||
return AllowedPlacing.Everywhere;
|
||||
}
|
||||
}
|
||||
public virtual TimeSpan ConcealPeriod
|
||||
{
|
||||
get
|
||||
{
|
||||
return TimeSpan.FromMinutes(1.0);
|
||||
}
|
||||
}
|
||||
public virtual TimeSpan DecayPeriod
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Core.AOS)
|
||||
return TimeSpan.FromDays(1.0);
|
||||
|
||||
return TimeSpan.MaxValue; // no decay
|
||||
}
|
||||
}
|
||||
public override void OnTrigger(Mobile from)
|
||||
{
|
||||
if (!IsEnemy(from))
|
||||
return;
|
||||
|
||||
Conceal();
|
||||
|
||||
DoVisibleEffect();
|
||||
Effects.PlaySound(Location, Map, EffectSound);
|
||||
DoAttackEffect(from);
|
||||
|
||||
int silverToAward = (from.Alive ? 20 : 40);
|
||||
|
||||
if (silverToAward > 0 && m_Placer != null && m_Faction != null)
|
||||
{
|
||||
PlayerState victimState = PlayerState.Find(from);
|
||||
|
||||
if (victimState != null && victimState.CanGiveSilverTo(m_Placer) && victimState.KillPoints > 0)
|
||||
{
|
||||
int silverGiven = m_Faction.AwardSilver(m_Placer, silverToAward);
|
||||
|
||||
if (silverGiven > 0)
|
||||
{
|
||||
// TODO: Get real message
|
||||
if (from.Alive)
|
||||
m_Placer.SendMessage("You have earned {0} silver pieces because {1} fell for your trap.", silverGiven, from.Name);
|
||||
else
|
||||
m_Placer.SendLocalizedMessage(1042736, String.Format("{0} silver\t{1}", silverGiven, from.Name)); // You have earned ~1_SILVER_AMOUNT~ pieces for vanquishing ~2_PLAYER_NAME~!
|
||||
}
|
||||
|
||||
victimState.OnGivenSilverTo(m_Placer);
|
||||
}
|
||||
}
|
||||
|
||||
from.LocalOverheadMessage(MessageType.Regular, MessageHue, AttackMessage);
|
||||
}
|
||||
|
||||
public abstract void DoVisibleEffect();
|
||||
|
||||
public abstract void DoAttackEffect(Mobile m);
|
||||
|
||||
public virtual int IsValidLocation()
|
||||
{
|
||||
return 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 (Item item in m.GetItemsInRange(p, 0))
|
||||
{
|
||||
if (item is BaseFactionTrap && ((BaseFactionTrap)item).Faction == Faction)
|
||||
return 1075263; // There is already a trap belonging to your faction at this location.;
|
||||
}
|
||||
}
|
||||
|
||||
switch( AllowedPlacing )
|
||||
{
|
||||
case AllowedPlacing.FactionStronghold:
|
||||
{
|
||||
StrongholdRegion region = (StrongholdRegion)Region.Find(p, m).GetRegion(typeof(StrongholdRegion));
|
||||
|
||||
if (region != null && region.Faction == m_Faction)
|
||||
return 0;
|
||||
|
||||
return 1010355; // This trap can only be placed in your stronghold
|
||||
}
|
||||
case AllowedPlacing.AnyFactionTown:
|
||||
{
|
||||
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));
|
||||
|
||||
if (town != null && town.Owner == m_Faction)
|
||||
return 0;
|
||||
|
||||
return 1010357; // This trap can only be placed in a town your faction controls
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void PrivateOverheadLocalizedMessage(Mobile to, int number, int hue, string name, string args)
|
||||
{
|
||||
if (to == null)
|
||||
return;
|
||||
|
||||
NetState ns = to.NetState;
|
||||
|
||||
if (ns != null)
|
||||
ns.Send(new MessageLocalized(Serial, ItemID, MessageType.Regular, hue, 3, number, name, args));
|
||||
}
|
||||
|
||||
public virtual bool CheckDecay()
|
||||
{
|
||||
TimeSpan decayPeriod = DecayPeriod;
|
||||
|
||||
if (decayPeriod == TimeSpan.MaxValue)
|
||||
return false;
|
||||
|
||||
if ((m_TimeOfPlacement + decayPeriod) < DateTime.UtcNow)
|
||||
{
|
||||
Timer.DelayCall(TimeSpan.Zero, new TimerCallback(Delete));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool CheckReveal(Mobile m)
|
||||
{
|
||||
if (Faction.Find(m) == null)
|
||||
return false;
|
||||
|
||||
return m.CheckTargetSkill(SkillName.DetectHidden, this, 80.0, 100.0);
|
||||
}
|
||||
|
||||
public virtual void OnRevealed(Mobile m)
|
||||
{
|
||||
m.SendLocalizedMessage(1042712, true, " " + (Faction == null ? "" : Faction.Definition.FriendlyName)); // You reveal a trap placed by a faction:
|
||||
|
||||
Visible = true;
|
||||
BeginConceal();
|
||||
}
|
||||
|
||||
public virtual void BeginConceal()
|
||||
{
|
||||
if (m_Concealing != null)
|
||||
m_Concealing.Stop();
|
||||
|
||||
m_Concealing = Timer.DelayCall(ConcealPeriod, new TimerCallback(Conceal));
|
||||
}
|
||||
|
||||
public virtual void Conceal()
|
||||
{
|
||||
if (m_Concealing != null)
|
||||
m_Concealing.Stop();
|
||||
|
||||
m_Concealing = null;
|
||||
|
||||
if (!Deleted)
|
||||
Visible = false;
|
||||
}
|
||||
|
||||
public virtual bool CheckPassiveDetect(Mobile m)
|
||||
{
|
||||
if (!CheckDecay() && m.InRange(Location, 6))
|
||||
{
|
||||
if (Faction.Find(m) != null && ((m.Skills[SkillName.DetectHidden].Value - 80.0) / 20.0) > Utility.RandomDouble())
|
||||
PrivateOverheadLocalizedMessage(m, 1010154, MessageHue, "", ""); // [Faction Trap]
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
|
||||
Faction.WriteReference(writer, m_Faction);
|
||||
writer.Write((Mobile)m_Placer);
|
||||
writer.Write((DateTime)m_TimeOfPlacement);
|
||||
|
||||
if (Visible)
|
||||
BeginConceal();
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
m_Faction = Faction.ReadReference(reader);
|
||||
m_Placer = reader.ReadMobile();
|
||||
m_TimeOfPlacement = reader.ReadDateTime();
|
||||
|
||||
if (Visible)
|
||||
BeginConceal();
|
||||
|
||||
CheckDecay();
|
||||
}
|
||||
|
||||
public override void OnDelete()
|
||||
{
|
||||
if (m_Faction != null && m_Faction.Traps.Contains(this))
|
||||
m_Faction.Traps.Remove(this);
|
||||
|
||||
base.OnDelete();
|
||||
}
|
||||
|
||||
public virtual bool IsEnemy(Mobile mob)
|
||||
{
|
||||
if (mob.Hidden && mob.IsStaff())
|
||||
return false;
|
||||
|
||||
if (!mob.Alive || mob.IsDeadBondedPet)
|
||||
return false;
|
||||
|
||||
Faction faction = Faction.Find(mob, true);
|
||||
|
||||
if (faction == null && mob is BaseFactionGuard)
|
||||
faction = ((BaseFactionGuard)mob).Faction;
|
||||
|
||||
if (faction == null)
|
||||
return false;
|
||||
|
||||
return (faction != m_Faction);
|
||||
}
|
||||
}
|
||||
}
|
||||
121
Scripts/Services/Factions/Items/Traps/BaseFactionTrapDeed.cs
Normal file
121
Scripts/Services/Factions/Items/Traps/BaseFactionTrapDeed.cs
Normal file
@@ -0,0 +1,121 @@
|
||||
using System;
|
||||
using Server.Engines.Craft;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public abstract class BaseFactionTrapDeed : Item, ICraftable
|
||||
{
|
||||
public abstract Type TrapType { get; }
|
||||
|
||||
private Faction m_Faction;
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Faction Faction
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Faction;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_Faction = value;
|
||||
|
||||
if (this.m_Faction != null)
|
||||
this.Hue = this.m_Faction.Definition.HuePrimary;
|
||||
}
|
||||
}
|
||||
|
||||
public BaseFactionTrapDeed(int itemID)
|
||||
: base(itemID)
|
||||
{
|
||||
this.Weight = 1.0;
|
||||
this.LootType = LootType.Blessed;
|
||||
}
|
||||
|
||||
public BaseFactionTrapDeed(bool createdFromDeed)
|
||||
: this(0x14F0)
|
||||
{
|
||||
}
|
||||
|
||||
public BaseFactionTrapDeed(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual BaseFactionTrap Construct(Mobile from)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Activator.CreateInstance(this.TrapType, new object[] { this.m_Faction, from }) as BaseFactionTrap;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
Faction faction = Faction.Find(from);
|
||||
|
||||
if (faction == null)
|
||||
from.SendLocalizedMessage(1010353, "", 0x23); // Only faction members may place faction traps
|
||||
else if (faction != this.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
|
||||
{
|
||||
BaseFactionTrap trap = this.Construct(from);
|
||||
|
||||
if (trap == null)
|
||||
return;
|
||||
|
||||
int 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);
|
||||
this.Delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
|
||||
Faction.WriteReference(writer, this.m_Faction);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
this.m_Faction = Faction.ReadReference(reader);
|
||||
}
|
||||
|
||||
#region ICraftable Members
|
||||
|
||||
public int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, ITool tool, CraftItem craftItem, int resHue)
|
||||
{
|
||||
this.ItemID = 0x14F0;
|
||||
this.Faction = Faction.Find(from);
|
||||
|
||||
return 1;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
134
Scripts/Services/Factions/Items/Traps/FactionExplosionTrap.cs
Normal file
134
Scripts/Services/Factions/Items/Traps/FactionExplosionTrap.cs
Normal file
@@ -0,0 +1,134 @@
|
||||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionExplosionTrap : BaseFactionTrap
|
||||
{
|
||||
[Constructable]
|
||||
public FactionExplosionTrap()
|
||||
: this(null)
|
||||
{
|
||||
}
|
||||
|
||||
public FactionExplosionTrap(Faction f)
|
||||
: this(f, null)
|
||||
{
|
||||
}
|
||||
|
||||
public FactionExplosionTrap(Faction f, Mobile m)
|
||||
: base(f, m, 0x11C1)
|
||||
{
|
||||
}
|
||||
|
||||
public FactionExplosionTrap(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override int LabelNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return 1044599;
|
||||
}
|
||||
}// faction explosion trap
|
||||
public override int AttackMessage
|
||||
{
|
||||
get
|
||||
{
|
||||
return 1010543;
|
||||
}
|
||||
}// You are enveloped in an explosion of fire!
|
||||
public override int DisarmMessage
|
||||
{
|
||||
get
|
||||
{
|
||||
return 1010539;
|
||||
}
|
||||
}// You carefully remove the pressure trigger and disable the trap.
|
||||
public override int EffectSound
|
||||
{
|
||||
get
|
||||
{
|
||||
return 0x307;
|
||||
}
|
||||
}
|
||||
public override int MessageHue
|
||||
{
|
||||
get
|
||||
{
|
||||
return 0x78;
|
||||
}
|
||||
}
|
||||
public override AllowedPlacing AllowedPlacing
|
||||
{
|
||||
get
|
||||
{
|
||||
return AllowedPlacing.AnyFactionTown;
|
||||
}
|
||||
}
|
||||
public override void DoVisibleEffect()
|
||||
{
|
||||
Effects.SendLocationEffect(this.GetWorldLocation(), this.Map, 0x36BD, 15, 10);
|
||||
}
|
||||
|
||||
public override void DoAttackEffect(Mobile m)
|
||||
{
|
||||
m.Damage(Utility.Dice(6, 10, 40), m);
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
|
||||
public class FactionExplosionTrapDeed : BaseFactionTrapDeed
|
||||
{
|
||||
public FactionExplosionTrapDeed()
|
||||
: base(0x36D2)
|
||||
{
|
||||
}
|
||||
|
||||
public FactionExplosionTrapDeed(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override Type TrapType
|
||||
{
|
||||
get
|
||||
{
|
||||
return typeof(FactionExplosionTrap);
|
||||
}
|
||||
}
|
||||
public override int LabelNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return 1044603;
|
||||
}
|
||||
}// faction explosion trap deed
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
134
Scripts/Services/Factions/Items/Traps/FactionGasTrap.cs
Normal file
134
Scripts/Services/Factions/Items/Traps/FactionGasTrap.cs
Normal file
@@ -0,0 +1,134 @@
|
||||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionGasTrap : BaseFactionTrap
|
||||
{
|
||||
[Constructable]
|
||||
public FactionGasTrap()
|
||||
: this(null)
|
||||
{
|
||||
}
|
||||
|
||||
public FactionGasTrap(Faction f)
|
||||
: this(f, null)
|
||||
{
|
||||
}
|
||||
|
||||
public FactionGasTrap(Faction f, Mobile m)
|
||||
: base(f, m, 0x113C)
|
||||
{
|
||||
}
|
||||
|
||||
public FactionGasTrap(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override int LabelNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return 1044598;
|
||||
}
|
||||
}// faction gas trap
|
||||
public override int AttackMessage
|
||||
{
|
||||
get
|
||||
{
|
||||
return 1010542;
|
||||
}
|
||||
}// A noxious green cloud of poison gas envelops you!
|
||||
public override int DisarmMessage
|
||||
{
|
||||
get
|
||||
{
|
||||
return 502376;
|
||||
}
|
||||
}// The poison leaks harmlessly away due to your deft touch.
|
||||
public override int EffectSound
|
||||
{
|
||||
get
|
||||
{
|
||||
return 0x230;
|
||||
}
|
||||
}
|
||||
public override int MessageHue
|
||||
{
|
||||
get
|
||||
{
|
||||
return 0x44;
|
||||
}
|
||||
}
|
||||
public override AllowedPlacing AllowedPlacing
|
||||
{
|
||||
get
|
||||
{
|
||||
return AllowedPlacing.FactionStronghold;
|
||||
}
|
||||
}
|
||||
public override void DoVisibleEffect()
|
||||
{
|
||||
Effects.SendLocationEffect(this.Location, this.Map, 0x3709, 28, 10, 0x1D3, 5);
|
||||
}
|
||||
|
||||
public override void DoAttackEffect(Mobile m)
|
||||
{
|
||||
m.ApplyPoison(m, Poison.Lethal);
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
|
||||
public class FactionGasTrapDeed : BaseFactionTrapDeed
|
||||
{
|
||||
public FactionGasTrapDeed()
|
||||
: base(0x11AB)
|
||||
{
|
||||
}
|
||||
|
||||
public FactionGasTrapDeed(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override Type TrapType
|
||||
{
|
||||
get
|
||||
{
|
||||
return typeof(FactionGasTrap);
|
||||
}
|
||||
}
|
||||
public override int LabelNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return 1044602;
|
||||
}
|
||||
}// faction gas trap deed
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
134
Scripts/Services/Factions/Items/Traps/FactionSawTrap.cs
Normal file
134
Scripts/Services/Factions/Items/Traps/FactionSawTrap.cs
Normal file
@@ -0,0 +1,134 @@
|
||||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionSawTrap : BaseFactionTrap
|
||||
{
|
||||
[Constructable]
|
||||
public FactionSawTrap()
|
||||
: this(null)
|
||||
{
|
||||
}
|
||||
|
||||
public FactionSawTrap(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public FactionSawTrap(Faction f)
|
||||
: this(f, null)
|
||||
{
|
||||
}
|
||||
|
||||
public FactionSawTrap(Faction f, Mobile m)
|
||||
: base(f, m, 0x11AC)
|
||||
{
|
||||
}
|
||||
|
||||
public override int LabelNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return 1041047;
|
||||
}
|
||||
}// faction saw trap
|
||||
public override int AttackMessage
|
||||
{
|
||||
get
|
||||
{
|
||||
return 1010544;
|
||||
}
|
||||
}// The blade cuts deep into your skin!
|
||||
public override int DisarmMessage
|
||||
{
|
||||
get
|
||||
{
|
||||
return 1010540;
|
||||
}
|
||||
}// You carefully dismantle the saw mechanism and disable the trap.
|
||||
public override int EffectSound
|
||||
{
|
||||
get
|
||||
{
|
||||
return 0x218;
|
||||
}
|
||||
}
|
||||
public override int MessageHue
|
||||
{
|
||||
get
|
||||
{
|
||||
return 0x5A;
|
||||
}
|
||||
}
|
||||
public override AllowedPlacing AllowedPlacing
|
||||
{
|
||||
get
|
||||
{
|
||||
return AllowedPlacing.ControlledFactionTown;
|
||||
}
|
||||
}
|
||||
public override void DoVisibleEffect()
|
||||
{
|
||||
Effects.SendLocationEffect(this.Location, this.Map, 0x11AD, 25, 10);
|
||||
}
|
||||
|
||||
public override void DoAttackEffect(Mobile m)
|
||||
{
|
||||
m.Damage(Utility.Dice(6, 10, 40), m);
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
|
||||
public class FactionSawTrapDeed : BaseFactionTrapDeed
|
||||
{
|
||||
public FactionSawTrapDeed()
|
||||
: base(0x1107)
|
||||
{
|
||||
}
|
||||
|
||||
public FactionSawTrapDeed(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override Type TrapType
|
||||
{
|
||||
get
|
||||
{
|
||||
return typeof(FactionSawTrap);
|
||||
}
|
||||
}
|
||||
public override int LabelNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return 1044604;
|
||||
}
|
||||
}// faction saw trap deed
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
134
Scripts/Services/Factions/Items/Traps/FactionSpikeTrap.cs
Normal file
134
Scripts/Services/Factions/Items/Traps/FactionSpikeTrap.cs
Normal file
@@ -0,0 +1,134 @@
|
||||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionSpikeTrap : BaseFactionTrap
|
||||
{
|
||||
[Constructable]
|
||||
public FactionSpikeTrap()
|
||||
: this(null)
|
||||
{
|
||||
}
|
||||
|
||||
public FactionSpikeTrap(Faction f)
|
||||
: this(f, null)
|
||||
{
|
||||
}
|
||||
|
||||
public FactionSpikeTrap(Faction f, Mobile m)
|
||||
: base(f, m, 0x11A0)
|
||||
{
|
||||
}
|
||||
|
||||
public FactionSpikeTrap(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override int LabelNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return 1044601;
|
||||
}
|
||||
}// faction spike trap
|
||||
public override int AttackMessage
|
||||
{
|
||||
get
|
||||
{
|
||||
return 1010545;
|
||||
}
|
||||
}// Large spikes in the ground spring up piercing your skin!
|
||||
public override int DisarmMessage
|
||||
{
|
||||
get
|
||||
{
|
||||
return 1010541;
|
||||
}
|
||||
}// You carefully dismantle the trigger on the spikes and disable the trap.
|
||||
public override int EffectSound
|
||||
{
|
||||
get
|
||||
{
|
||||
return 0x22E;
|
||||
}
|
||||
}
|
||||
public override int MessageHue
|
||||
{
|
||||
get
|
||||
{
|
||||
return 0x5A;
|
||||
}
|
||||
}
|
||||
public override AllowedPlacing AllowedPlacing
|
||||
{
|
||||
get
|
||||
{
|
||||
return AllowedPlacing.ControlledFactionTown;
|
||||
}
|
||||
}
|
||||
public override void DoVisibleEffect()
|
||||
{
|
||||
Effects.SendLocationEffect(this.Location, this.Map, 0x11A4, 12, 6);
|
||||
}
|
||||
|
||||
public override void DoAttackEffect(Mobile m)
|
||||
{
|
||||
m.Damage(Utility.Dice(6, 10, 40), m);
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
|
||||
public class FactionSpikeTrapDeed : BaseFactionTrapDeed
|
||||
{
|
||||
public FactionSpikeTrapDeed()
|
||||
: base(0x11A5)
|
||||
{
|
||||
}
|
||||
|
||||
public FactionSpikeTrapDeed(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override Type TrapType
|
||||
{
|
||||
get
|
||||
{
|
||||
return typeof(FactionSpikeTrap);
|
||||
}
|
||||
}
|
||||
public override int LabelNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return 1044605;
|
||||
}
|
||||
}// faction spike trap deed
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionTrapRemovalKit : Item
|
||||
{
|
||||
private int m_Charges;
|
||||
[Constructable]
|
||||
public FactionTrapRemovalKit()
|
||||
: base(7867)
|
||||
{
|
||||
this.LootType = LootType.Blessed;
|
||||
this.m_Charges = 25;
|
||||
}
|
||||
|
||||
public FactionTrapRemovalKit(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int Charges
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Charges;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_Charges = value;
|
||||
}
|
||||
}
|
||||
public override int LabelNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return 1041508;
|
||||
}
|
||||
}// a faction trap removal kit
|
||||
public void ConsumeCharge(Mobile consumer)
|
||||
{
|
||||
--this.m_Charges;
|
||||
|
||||
if (this.m_Charges <= 0)
|
||||
{
|
||||
this.Delete();
|
||||
|
||||
if (consumer != null)
|
||||
consumer.SendLocalizedMessage(1042531); // You have used all of the parts in your trap removal kit.
|
||||
}
|
||||
}
|
||||
|
||||
public override void GetProperties(ObjectPropertyList list)
|
||||
{
|
||||
base.GetProperties(list);
|
||||
|
||||
// NOTE: OSI does not list uses remaining; intentional difference
|
||||
list.Add(1060584, this.m_Charges.ToString()); // uses remaining: ~1_val~
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)1); // version
|
||||
|
||||
writer.WriteEncodedInt((int)this.m_Charges);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
this.m_Charges = reader.ReadEncodedInt();
|
||||
break;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
this.m_Charges = 25;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
119
Scripts/Services/Factions/Mobiles/FactionWarHorse.cs
Normal file
119
Scripts/Services/Factions/Mobiles/FactionWarHorse.cs
Normal file
@@ -0,0 +1,119 @@
|
||||
using System;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
[CorpseName("a war horse corpse")]
|
||||
public class FactionWarHorse : BaseMount
|
||||
{
|
||||
public const int SilverPrice = 500;
|
||||
public const int GoldPrice = 3000;
|
||||
private Faction m_Faction;
|
||||
[Constructable]
|
||||
public FactionWarHorse()
|
||||
: this(null)
|
||||
{
|
||||
}
|
||||
|
||||
public FactionWarHorse(Faction faction)
|
||||
: base("a war horse", 0xE2, 0x3EA0, AIType.AI_Melee, FightMode.Aggressor, 10, 1, 0.2, 0.4)
|
||||
{
|
||||
this.BaseSoundID = 0xA8;
|
||||
|
||||
this.SetStr(400);
|
||||
this.SetDex(125);
|
||||
this.SetInt(51, 55);
|
||||
|
||||
this.SetHits(240);
|
||||
this.SetMana(0);
|
||||
|
||||
this.SetDamage(5, 8);
|
||||
|
||||
this.SetDamageType(ResistanceType.Physical, 100);
|
||||
|
||||
this.SetResistance(ResistanceType.Physical, 40, 50);
|
||||
this.SetResistance(ResistanceType.Fire, 30, 40);
|
||||
this.SetResistance(ResistanceType.Cold, 30, 40);
|
||||
this.SetResistance(ResistanceType.Poison, 30, 40);
|
||||
this.SetResistance(ResistanceType.Energy, 30, 40);
|
||||
|
||||
this.SetSkill(SkillName.MagicResist, 25.1, 30.0);
|
||||
this.SetSkill(SkillName.Tactics, 29.3, 44.0);
|
||||
this.SetSkill(SkillName.Wrestling, 29.3, 44.0);
|
||||
|
||||
this.Fame = 300;
|
||||
this.Karma = 300;
|
||||
|
||||
this.Tamable = true;
|
||||
this.ControlSlots = 1;
|
||||
|
||||
this.Faction = faction;
|
||||
}
|
||||
|
||||
public FactionWarHorse(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)]
|
||||
public Faction Faction
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Faction;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_Faction = value;
|
||||
|
||||
this.Body = (this.m_Faction == null ? 0xE2 : this.m_Faction.Definition.WarHorseBody);
|
||||
this.ItemID = (this.m_Faction == null ? 0x3EA0 : this.m_Faction.Definition.WarHorseItem);
|
||||
}
|
||||
}
|
||||
public override FoodType FavoriteFood
|
||||
{
|
||||
get
|
||||
{
|
||||
return FoodType.FruitsAndVegies | FoodType.GrainsAndHay;
|
||||
}
|
||||
}
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
PlayerState pl = PlayerState.Find(from);
|
||||
|
||||
if (pl == null)
|
||||
from.SendLocalizedMessage(1010366); // You cannot mount a faction war horse!
|
||||
else if (pl.Faction != this.Faction)
|
||||
from.SendLocalizedMessage(1010367); // You cannot ride an opposing faction's war horse!
|
||||
else if (pl.Rank.Rank < 2)
|
||||
from.SendLocalizedMessage(1010368); // You must achieve a faction rank of at least two before riding a war horse!
|
||||
else
|
||||
base.OnDoubleClick(from);
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
|
||||
Faction.WriteReference(writer, this.m_Faction);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
this.Faction = Faction.ReadReference(reader);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
576
Scripts/Services/Factions/Mobiles/Guards/BaseFactionGuard.cs
Normal file
576
Scripts/Services/Factions/Mobiles/Guards/BaseFactionGuard.cs
Normal file
@@ -0,0 +1,576 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Factions.AI;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public abstract class BaseFactionGuard : BaseCreature
|
||||
{
|
||||
private static readonly Type[] m_StrongPotions = new Type[]
|
||||
{
|
||||
typeof(GreaterHealPotion), typeof(GreaterHealPotion), typeof(GreaterHealPotion),
|
||||
typeof(GreaterCurePotion), typeof(GreaterCurePotion), typeof(GreaterCurePotion),
|
||||
typeof(GreaterStrengthPotion), typeof(GreaterStrengthPotion),
|
||||
typeof(GreaterAgilityPotion), typeof(GreaterAgilityPotion),
|
||||
typeof(TotalRefreshPotion), typeof(TotalRefreshPotion),
|
||||
typeof(GreaterExplosionPotion)
|
||||
};
|
||||
private static readonly Type[] m_WeakPotions = new Type[]
|
||||
{
|
||||
typeof(HealPotion), typeof(HealPotion), typeof(HealPotion),
|
||||
typeof(CurePotion), typeof(CurePotion), typeof(CurePotion),
|
||||
typeof(StrengthPotion), typeof(StrengthPotion),
|
||||
typeof(AgilityPotion), typeof(AgilityPotion),
|
||||
typeof(RefreshPotion), typeof(RefreshPotion),
|
||||
typeof(ExplosionPotion)
|
||||
};
|
||||
private const int ListenRange = 12;
|
||||
private Faction m_Faction;
|
||||
private Town m_Town;
|
||||
private Orders m_Orders;
|
||||
private DateTime m_OrdersEnd;
|
||||
public BaseFactionGuard(string title)
|
||||
: base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4)
|
||||
{
|
||||
this.m_Orders = new Orders(this);
|
||||
this.Title = title;
|
||||
|
||||
this.RangeHome = 6;
|
||||
}
|
||||
|
||||
public BaseFactionGuard(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool BardImmune
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
[CommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)]
|
||||
public Faction Faction
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Faction;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.Unregister();
|
||||
this.m_Faction = value;
|
||||
this.Register();
|
||||
}
|
||||
}
|
||||
public Orders Orders
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Orders;
|
||||
}
|
||||
}
|
||||
[CommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)]
|
||||
public Town Town
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Town;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.Unregister();
|
||||
this.m_Town = value;
|
||||
this.Register();
|
||||
}
|
||||
}
|
||||
public abstract GuardAI GuardAI { get; }
|
||||
public override TimeSpan ReacquireDelay
|
||||
{
|
||||
get
|
||||
{
|
||||
return TimeSpan.FromSeconds(2.0);
|
||||
}
|
||||
}
|
||||
public override bool ClickTitle
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
protected override BaseAI ForcedAI
|
||||
{
|
||||
get
|
||||
{
|
||||
return new FactionGuardAI(this);
|
||||
}
|
||||
}
|
||||
public void Register()
|
||||
{
|
||||
if (this.m_Town != null && this.m_Faction != null)
|
||||
this.m_Town.RegisterGuard(this);
|
||||
}
|
||||
|
||||
public void Unregister()
|
||||
{
|
||||
if (this.m_Town != null)
|
||||
this.m_Town.UnregisterGuard(this);
|
||||
}
|
||||
|
||||
public override bool IsEnemy(Mobile m)
|
||||
{
|
||||
Faction ourFaction = this.m_Faction;
|
||||
Faction theirFaction = Faction.Find(m);
|
||||
|
||||
if (theirFaction == null && m is BaseFactionGuard)
|
||||
theirFaction = ((BaseFactionGuard)m).Faction;
|
||||
|
||||
if (ourFaction != null && theirFaction != null && ourFaction != theirFaction)
|
||||
{
|
||||
ReactionType reactionType = this.Orders.GetReaction(theirFaction).Type;
|
||||
|
||||
if (reactionType == ReactionType.Attack)
|
||||
return true;
|
||||
|
||||
if (theirFaction != null)
|
||||
{
|
||||
List<AggressorInfo> list = m.Aggressed;
|
||||
|
||||
for (int i = 0; i < list.Count; ++i)
|
||||
{
|
||||
AggressorInfo ai = list[i];
|
||||
|
||||
if (ai.Defender is BaseFactionGuard)
|
||||
{
|
||||
BaseFactionGuard bf = (BaseFactionGuard)ai.Defender;
|
||||
|
||||
if (bf.Faction == ourFaction)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void OnMovement(Mobile m, Point3D oldLocation)
|
||||
{
|
||||
if (m.Player && m.Alive && this.InRange(m, 10) && !this.InRange(oldLocation, 10) && this.InLOS(m) && this.m_Orders.GetReaction(Faction.Find(m)).Type == ReactionType.Warn)
|
||||
{
|
||||
this.Direction = this.GetDirectionTo(m);
|
||||
|
||||
string warning = null;
|
||||
|
||||
switch ( Utility.Random(6) )
|
||||
{
|
||||
case 0:
|
||||
warning = "I warn you, {0}, you would do well to leave this area before someone shows you the world of gray.";
|
||||
break;
|
||||
case 1:
|
||||
warning = "It would be wise to leave this area, {0}, lest your head become my commanders' trophy.";
|
||||
break;
|
||||
case 2:
|
||||
warning = "You are bold, {0}, for one of the meager {1}. Leave now, lest you be taught the taste of dirt.";
|
||||
break;
|
||||
case 3:
|
||||
warning = "Your presence here is an insult, {0}. Be gone now, knave.";
|
||||
break;
|
||||
case 4:
|
||||
warning = "Dost thou wish to be hung by your toes, {0}? Nay? Then come no closer.";
|
||||
break;
|
||||
case 5:
|
||||
warning = "Hey, {0}. Yeah, you. Get out of here before I beat you with a stick.";
|
||||
break;
|
||||
}
|
||||
|
||||
Faction faction = Faction.Find(m);
|
||||
|
||||
this.Say(warning, m.Name, faction == null ? "civilians" : faction.Definition.FriendlyName);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool HandlesOnSpeech(Mobile from)
|
||||
{
|
||||
if (this.InRange(from, ListenRange))
|
||||
return true;
|
||||
|
||||
return base.HandlesOnSpeech(from);
|
||||
}
|
||||
|
||||
public override void OnSpeech(SpeechEventArgs e)
|
||||
{
|
||||
base.OnSpeech(e);
|
||||
|
||||
Mobile from = e.Mobile;
|
||||
|
||||
if (!e.Handled && this.InRange(from, ListenRange) && from.Alive)
|
||||
{
|
||||
if (e.HasKeyword(0xE6) && (Insensitive.Equals(e.Speech, "orders") || this.WasNamed(e.Speech))) // *orders*
|
||||
{
|
||||
if (this.m_Town == null || !this.m_Town.IsSheriff(from))
|
||||
{
|
||||
this.Say(1042189); // I don't work for you!
|
||||
}
|
||||
else if (Town.FromRegion(this.Region) == this.m_Town)
|
||||
{
|
||||
this.Say(1042180); // Your orders, sire?
|
||||
this.m_OrdersEnd = DateTime.UtcNow + TimeSpan.FromSeconds(10.0);
|
||||
}
|
||||
}
|
||||
else if (DateTime.UtcNow < this.m_OrdersEnd)
|
||||
{
|
||||
if (this.m_Town != null && this.m_Town.IsSheriff(from) && Town.FromRegion(this.Region) == this.m_Town)
|
||||
{
|
||||
this.m_OrdersEnd = DateTime.UtcNow + TimeSpan.FromSeconds(10.0);
|
||||
|
||||
bool understood = true;
|
||||
ReactionType newType = 0;
|
||||
|
||||
if (Insensitive.Contains(e.Speech, "attack"))
|
||||
newType = ReactionType.Attack;
|
||||
else if (Insensitive.Contains(e.Speech, "warn"))
|
||||
newType = ReactionType.Warn;
|
||||
else if (Insensitive.Contains(e.Speech, "ignore"))
|
||||
newType = ReactionType.Ignore;
|
||||
else
|
||||
understood = false;
|
||||
|
||||
if (understood)
|
||||
{
|
||||
understood = false;
|
||||
|
||||
if (Insensitive.Contains(e.Speech, "civil"))
|
||||
{
|
||||
this.ChangeReaction(null, newType);
|
||||
understood = true;
|
||||
}
|
||||
|
||||
List<Faction> factions = Faction.Factions;
|
||||
|
||||
for (int i = 0; i < factions.Count; ++i)
|
||||
{
|
||||
Faction faction = factions[i];
|
||||
|
||||
if (faction != this.m_Faction && Insensitive.Contains(e.Speech, faction.Definition.Keyword))
|
||||
{
|
||||
this.ChangeReaction(faction, newType);
|
||||
understood = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (Insensitive.Contains(e.Speech, "patrol"))
|
||||
{
|
||||
this.Home = this.Location;
|
||||
this.RangeHome = 6;
|
||||
this.Combatant = null;
|
||||
this.m_Orders.Movement = MovementType.Patrol;
|
||||
this.Say(1005146); // This spot looks like it needs protection! I shall guard it with my life.
|
||||
understood = true;
|
||||
}
|
||||
else if (Insensitive.Contains(e.Speech, "follow"))
|
||||
{
|
||||
this.Home = this.Location;
|
||||
this.RangeHome = 6;
|
||||
this.Combatant = null;
|
||||
this.m_Orders.Follow = from;
|
||||
this.m_Orders.Movement = MovementType.Follow;
|
||||
this.Say(1005144); // Yes, Sire.
|
||||
understood = true;
|
||||
}
|
||||
|
||||
if (!understood)
|
||||
this.Say(1042183); // I'm sorry, I don't understand your orders...
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void GetProperties(ObjectPropertyList list)
|
||||
{
|
||||
base.GetProperties(list);
|
||||
|
||||
if (this.m_Faction != null && this.Map == Faction.Facet)
|
||||
list.Add(1060846, this.m_Faction.Definition.PropName); // Guard: ~1_val~
|
||||
}
|
||||
|
||||
public override void OnSingleClick(Mobile from)
|
||||
{
|
||||
if (this.m_Faction != null && this.Map == Faction.Facet)
|
||||
{
|
||||
string text = String.Concat("(Guard, ", this.m_Faction.Definition.FriendlyName, ")");
|
||||
|
||||
int hue = (Faction.Find(from) == this.m_Faction ? 98 : 38);
|
||||
|
||||
this.PrivateOverheadMessage(MessageType.Label, hue, true, text, from.NetState);
|
||||
}
|
||||
|
||||
base.OnSingleClick(from);
|
||||
}
|
||||
|
||||
public virtual void GenerateRandomHair()
|
||||
{
|
||||
Utility.AssignRandomHair(this);
|
||||
Utility.AssignRandomFacialHair(this, this.HairHue);
|
||||
}
|
||||
|
||||
public void PackStrongPotions(int min, int max)
|
||||
{
|
||||
this.PackStrongPotions(Utility.RandomMinMax(min, max));
|
||||
}
|
||||
|
||||
public void PackStrongPotions(int count)
|
||||
{
|
||||
for (int i = 0; i < count; ++i)
|
||||
this.PackStrongPotion();
|
||||
}
|
||||
|
||||
public void PackStrongPotion()
|
||||
{
|
||||
this.PackItem(Loot.Construct(m_StrongPotions));
|
||||
}
|
||||
|
||||
public void PackWeakPotions(int min, int max)
|
||||
{
|
||||
this.PackWeakPotions(Utility.RandomMinMax(min, max));
|
||||
}
|
||||
|
||||
public void PackWeakPotions(int count)
|
||||
{
|
||||
for (int i = 0; i < count; ++i)
|
||||
this.PackWeakPotion();
|
||||
}
|
||||
|
||||
public void PackWeakPotion()
|
||||
{
|
||||
this.PackItem(Loot.Construct(m_WeakPotions));
|
||||
}
|
||||
|
||||
public Item Immovable(Item item)
|
||||
{
|
||||
item.Movable = false;
|
||||
return item;
|
||||
}
|
||||
|
||||
public Item Newbied(Item item)
|
||||
{
|
||||
item.LootType = LootType.Newbied;
|
||||
return item;
|
||||
}
|
||||
|
||||
public Item Rehued(Item item, int hue)
|
||||
{
|
||||
item.Hue = hue;
|
||||
return item;
|
||||
}
|
||||
|
||||
public Item Layered(Item item, Layer layer)
|
||||
{
|
||||
item.Layer = layer;
|
||||
return item;
|
||||
}
|
||||
|
||||
public Item Resourced(BaseWeapon weapon, CraftResource resource)
|
||||
{
|
||||
weapon.Resource = resource;
|
||||
return weapon;
|
||||
}
|
||||
|
||||
public Item Resourced(BaseArmor armor, CraftResource resource)
|
||||
{
|
||||
armor.Resource = resource;
|
||||
return armor;
|
||||
}
|
||||
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
base.OnAfterDelete();
|
||||
this.Unregister();
|
||||
}
|
||||
|
||||
public override void OnDeath(Container c)
|
||||
{
|
||||
base.OnDeath(c);
|
||||
|
||||
c.Delete();
|
||||
}
|
||||
|
||||
public virtual void GenerateBody(bool isFemale, bool randomHair)
|
||||
{
|
||||
this.Hue = Utility.RandomSkinHue();
|
||||
|
||||
if (isFemale)
|
||||
{
|
||||
this.Female = true;
|
||||
this.Body = 401;
|
||||
this.Name = NameList.RandomName("female");
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Female = false;
|
||||
this.Body = 400;
|
||||
this.Name = NameList.RandomName("male");
|
||||
}
|
||||
|
||||
if (randomHair)
|
||||
this.GenerateRandomHair();
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
|
||||
Faction.WriteReference(writer, this.m_Faction);
|
||||
Town.WriteReference(writer, this.m_Town);
|
||||
|
||||
this.m_Orders.Serialize(writer);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
this.m_Faction = Faction.ReadReference(reader);
|
||||
this.m_Town = Town.ReadReference(reader);
|
||||
this.m_Orders = new Orders(this, reader);
|
||||
|
||||
Timer.DelayCall(TimeSpan.Zero, new TimerCallback(Register));
|
||||
}
|
||||
|
||||
private void ChangeReaction(Faction faction, ReactionType type)
|
||||
{
|
||||
if (faction == null)
|
||||
{
|
||||
switch ( type )
|
||||
{
|
||||
case ReactionType.Ignore:
|
||||
this.Say(1005179);
|
||||
break; // Civilians will now be ignored.
|
||||
case ReactionType.Warn:
|
||||
this.Say(1005180);
|
||||
break; // Civilians will now be warned of their impending deaths.
|
||||
case ReactionType.Attack:
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TextDefinition def = null;
|
||||
|
||||
switch ( type )
|
||||
{
|
||||
case ReactionType.Ignore:
|
||||
def = faction.Definition.GuardIgnore;
|
||||
break;
|
||||
case ReactionType.Warn:
|
||||
def = faction.Definition.GuardWarn;
|
||||
break;
|
||||
case ReactionType.Attack:
|
||||
def = faction.Definition.GuardAttack;
|
||||
break;
|
||||
}
|
||||
|
||||
if (def != null && def.Number > 0)
|
||||
this.Say(def.Number);
|
||||
else if (def != null && def.String != null)
|
||||
this.Say(def.String);
|
||||
}
|
||||
|
||||
this.m_Orders.SetReaction(faction, type);
|
||||
}
|
||||
|
||||
private bool WasNamed(string speech)
|
||||
{
|
||||
string name = this.Name;
|
||||
|
||||
return (name != null && Insensitive.StartsWith(speech, name));
|
||||
}
|
||||
}
|
||||
|
||||
public class VirtualMount : IMount
|
||||
{
|
||||
private readonly VirtualMountItem m_Item;
|
||||
public VirtualMount(VirtualMountItem item)
|
||||
{
|
||||
this.m_Item = item;
|
||||
}
|
||||
|
||||
public Mobile Rider
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Item.Rider;
|
||||
}
|
||||
set
|
||||
{
|
||||
}
|
||||
}
|
||||
public virtual void OnRiderDamaged(Mobile from, ref int amount, bool willKill)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class VirtualMountItem : Item, IMountItem
|
||||
{
|
||||
private readonly VirtualMount m_Mount;
|
||||
private Mobile m_Rider;
|
||||
public VirtualMountItem(Mobile mob)
|
||||
: base(0x3EA0)
|
||||
{
|
||||
this.Layer = Layer.Mount;
|
||||
|
||||
this.m_Rider = mob;
|
||||
this.m_Mount = new VirtualMount(this);
|
||||
}
|
||||
|
||||
public VirtualMountItem(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
this.m_Mount = new VirtualMount(this);
|
||||
}
|
||||
|
||||
public Mobile Rider
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Rider;
|
||||
}
|
||||
}
|
||||
public IMount Mount
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Mount;
|
||||
}
|
||||
}
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
|
||||
writer.Write((Mobile)this.m_Rider);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
this.m_Rider = reader.ReadMobile();
|
||||
|
||||
if (this.m_Rider == null)
|
||||
this.Delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
921
Scripts/Services/Factions/Mobiles/Guards/GuardAI.cs
Normal file
921
Scripts/Services/Factions/Mobiles/Guards/GuardAI.cs
Normal file
@@ -0,0 +1,921 @@
|
||||
#region References
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Server.Factions.AI;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
using Server.Spells;
|
||||
using Server.Spells.Fifth;
|
||||
using Server.Spells.First;
|
||||
using Server.Spells.Fourth;
|
||||
using Server.Spells.Second;
|
||||
using Server.Spells.Seventh;
|
||||
using Server.Spells.Sixth;
|
||||
using Server.Spells.Third;
|
||||
using Server.Targeting;
|
||||
#endregion
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public enum GuardAI
|
||||
{
|
||||
Bless = 0x01, // heal, cure, +stats
|
||||
Curse = 0x02, // poison, -stats
|
||||
Melee = 0x04, // weapons
|
||||
Magic = 0x08, // damage spells
|
||||
Smart = 0x10 // smart weapons/damage spells
|
||||
}
|
||||
|
||||
public class ComboEntry
|
||||
{
|
||||
private readonly Type m_Spell;
|
||||
private readonly TimeSpan m_Hold;
|
||||
private readonly int m_Chance;
|
||||
|
||||
public ComboEntry(Type spell)
|
||||
: this(spell, 100, TimeSpan.Zero)
|
||||
{ }
|
||||
|
||||
public ComboEntry(Type spell, int chance)
|
||||
: this(spell, chance, TimeSpan.Zero)
|
||||
{ }
|
||||
|
||||
public ComboEntry(Type spell, int chance, TimeSpan hold)
|
||||
{
|
||||
m_Spell = spell;
|
||||
m_Chance = chance;
|
||||
m_Hold = hold;
|
||||
}
|
||||
|
||||
public Type Spell { get { return m_Spell; } }
|
||||
public TimeSpan Hold { get { return m_Hold; } }
|
||||
public int Chance { get { return m_Chance; } }
|
||||
}
|
||||
|
||||
public class SpellCombo
|
||||
{
|
||||
public static readonly SpellCombo Simple = new SpellCombo(
|
||||
50,
|
||||
new ComboEntry(typeof(ParalyzeSpell), 20),
|
||||
new ComboEntry(typeof(ExplosionSpell), 100, TimeSpan.FromSeconds(2.8)),
|
||||
new ComboEntry(typeof(PoisonSpell), 30),
|
||||
new ComboEntry(typeof(EnergyBoltSpell)));
|
||||
|
||||
public static readonly SpellCombo Strong = new SpellCombo(
|
||||
90,
|
||||
new ComboEntry(typeof(ParalyzeSpell), 20),
|
||||
new ComboEntry(typeof(ExplosionSpell), 50, TimeSpan.FromSeconds(2.8)),
|
||||
new ComboEntry(typeof(PoisonSpell), 30),
|
||||
new ComboEntry(typeof(ExplosionSpell), 100, TimeSpan.FromSeconds(2.8)),
|
||||
new ComboEntry(typeof(EnergyBoltSpell)),
|
||||
new ComboEntry(typeof(PoisonSpell), 30),
|
||||
new ComboEntry(typeof(EnergyBoltSpell)));
|
||||
|
||||
private readonly int m_Mana;
|
||||
private readonly ComboEntry[] m_Entries;
|
||||
|
||||
public SpellCombo(int mana, params ComboEntry[] entries)
|
||||
{
|
||||
m_Mana = mana;
|
||||
m_Entries = entries;
|
||||
}
|
||||
|
||||
public int Mana { get { return m_Mana; } }
|
||||
public ComboEntry[] Entries { get { return m_Entries; } }
|
||||
|
||||
public static Spell Process(Mobile mob, Mobile targ, ref SpellCombo combo, ref int index, ref DateTime releaseTime)
|
||||
{
|
||||
while (++index < combo.m_Entries.Length)
|
||||
{
|
||||
ComboEntry entry = combo.m_Entries[index];
|
||||
|
||||
if (entry.Spell == typeof(PoisonSpell) && targ.Poisoned)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (entry.Chance > Utility.Random(100))
|
||||
{
|
||||
releaseTime = DateTime.UtcNow + entry.Hold;
|
||||
return (Spell)Activator.CreateInstance(entry.Spell, new object[] {mob, null});
|
||||
}
|
||||
}
|
||||
|
||||
combo = null;
|
||||
index = -1;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public class FactionGuardAI : BaseAI
|
||||
{
|
||||
private const int ManaReserve = 30;
|
||||
private readonly BaseFactionGuard m_Guard;
|
||||
private BandageContext m_Bandage;
|
||||
private DateTime m_BandageStart;
|
||||
private SpellCombo m_Combo;
|
||||
private int m_ComboIndex = -1;
|
||||
private DateTime m_ReleaseTarget;
|
||||
|
||||
public FactionGuardAI(BaseFactionGuard guard)
|
||||
: base(guard)
|
||||
{
|
||||
m_Guard = guard;
|
||||
}
|
||||
|
||||
public bool IsDamaged { get { return (m_Guard.Hits < m_Guard.HitsMax); } }
|
||||
public bool IsPoisoned { get { return m_Guard.Poisoned; } }
|
||||
|
||||
public TimeSpan TimeUntilBandage
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_Bandage != null && m_Bandage.Timer == null)
|
||||
{
|
||||
m_Bandage = null;
|
||||
}
|
||||
|
||||
if (m_Bandage == null)
|
||||
{
|
||||
return TimeSpan.MaxValue;
|
||||
}
|
||||
|
||||
TimeSpan ts = (m_BandageStart + m_Bandage.Timer.Delay) - DateTime.UtcNow;
|
||||
|
||||
if (ts < TimeSpan.FromSeconds(-1.0))
|
||||
{
|
||||
m_Bandage = null;
|
||||
return TimeSpan.MaxValue;
|
||||
}
|
||||
|
||||
if (ts < TimeSpan.Zero)
|
||||
{
|
||||
ts = TimeSpan.Zero;
|
||||
}
|
||||
|
||||
return ts;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsAllowed(GuardAI flag)
|
||||
{
|
||||
return ((m_Guard.GuardAI & flag) == flag);
|
||||
}
|
||||
|
||||
public bool DequipWeapon()
|
||||
{
|
||||
Container pack = m_Guard.Backpack;
|
||||
|
||||
if (pack == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Item weapon = m_Guard.Weapon as Item;
|
||||
|
||||
if (weapon != null && weapon.Parent == m_Guard && !(weapon is Fists))
|
||||
{
|
||||
pack.DropItem(weapon);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool EquipWeapon()
|
||||
{
|
||||
Container pack = m_Guard.Backpack;
|
||||
|
||||
if (pack == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Item weapon = pack.FindItemByType(typeof(BaseWeapon));
|
||||
|
||||
if (weapon == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return m_Guard.EquipItem(weapon);
|
||||
}
|
||||
|
||||
public bool StartBandage()
|
||||
{
|
||||
m_Bandage = null;
|
||||
|
||||
Container pack = m_Guard.Backpack;
|
||||
|
||||
if (pack == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Item bandage = pack.FindItemByType(typeof(Bandage));
|
||||
|
||||
if (bandage == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
m_Bandage = BandageContext.BeginHeal(m_Guard, m_Guard);
|
||||
m_BandageStart = DateTime.UtcNow;
|
||||
return (m_Bandage != null);
|
||||
}
|
||||
|
||||
public bool UseItemByType(Type type)
|
||||
{
|
||||
Container pack = m_Guard.Backpack;
|
||||
|
||||
if (pack == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Item item = pack.FindItemByType(type);
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool requip = DequipWeapon();
|
||||
|
||||
item.OnDoubleClick(m_Guard);
|
||||
|
||||
if (requip)
|
||||
{
|
||||
EquipWeapon();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public int GetStatMod(Mobile mob, StatType type)
|
||||
{
|
||||
int offset = 0;
|
||||
StatMod buff = mob.GetStatMod(String.Format("[Magic] {0} Buff", type));
|
||||
StatMod curse = mob.GetStatMod(String.Format("[Magic] {0} Curse", type));
|
||||
|
||||
if (buff != null)
|
||||
offset += buff.Offset;
|
||||
if (curse != null)
|
||||
offset += curse.Offset;
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
public Spell RandomOffenseSpell()
|
||||
{
|
||||
int maxCircle = (int)((m_Guard.Skills.Magery.Value + 20.0) / (100.0 / 7.0));
|
||||
|
||||
if (maxCircle < 1)
|
||||
{
|
||||
maxCircle = 1;
|
||||
}
|
||||
|
||||
switch (Utility.Random(maxCircle * 2))
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
return new MagicArrowSpell(m_Guard, null);
|
||||
case 2:
|
||||
case 3:
|
||||
return new HarmSpell(m_Guard, null);
|
||||
case 4:
|
||||
case 5:
|
||||
return new FireballSpell(m_Guard, null);
|
||||
case 6:
|
||||
case 7:
|
||||
return new LightningSpell(m_Guard, null);
|
||||
case 8:
|
||||
return new MindBlastSpell(m_Guard, null);
|
||||
case 9:
|
||||
return new ParalyzeSpell(m_Guard, null);
|
||||
case 10:
|
||||
return new EnergyBoltSpell(m_Guard, null);
|
||||
case 11:
|
||||
return new ExplosionSpell(m_Guard, null);
|
||||
default:
|
||||
return new FlameStrikeSpell(m_Guard, null);
|
||||
}
|
||||
}
|
||||
|
||||
public Mobile FindDispelTarget(bool activeOnly)
|
||||
{
|
||||
if (m_Mobile.Deleted || m_Mobile.Int < 95 || CanDispel(m_Mobile) || m_Mobile.AutoDispel)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (activeOnly)
|
||||
{
|
||||
var aggressed = m_Mobile.Aggressed;
|
||||
var aggressors = m_Mobile.Aggressors;
|
||||
|
||||
Mobile active = null;
|
||||
double activePrio = 0.0;
|
||||
|
||||
Mobile comb = m_Mobile.Combatant as Mobile;
|
||||
|
||||
if (comb != null && !comb.Deleted && comb.Alive && !comb.IsDeadBondedPet && m_Mobile.InRange(comb, 12) &&
|
||||
CanDispel(comb))
|
||||
{
|
||||
active = comb;
|
||||
activePrio = m_Mobile.GetDistanceToSqrt(comb);
|
||||
|
||||
if (activePrio <= 2)
|
||||
{
|
||||
return active;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < aggressed.Count; ++i)
|
||||
{
|
||||
AggressorInfo info = aggressed[i];
|
||||
Mobile m = info.Defender;
|
||||
|
||||
if (m != comb && m.Combatant == m_Mobile && m_Mobile.InRange(m, 12) && CanDispel(m))
|
||||
{
|
||||
double prio = m_Mobile.GetDistanceToSqrt(m);
|
||||
|
||||
if (active == null || prio < activePrio)
|
||||
{
|
||||
active = m;
|
||||
activePrio = prio;
|
||||
|
||||
if (activePrio <= 2)
|
||||
{
|
||||
return active;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < aggressors.Count; ++i)
|
||||
{
|
||||
AggressorInfo info = aggressors[i];
|
||||
Mobile m = info.Attacker;
|
||||
|
||||
if (m != comb && m.Combatant == m_Mobile && m_Mobile.InRange(m, 12) && CanDispel(m))
|
||||
{
|
||||
double prio = m_Mobile.GetDistanceToSqrt(m);
|
||||
|
||||
if (active == null || prio < activePrio)
|
||||
{
|
||||
active = m;
|
||||
activePrio = prio;
|
||||
|
||||
if (activePrio <= 2)
|
||||
{
|
||||
return active;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return active;
|
||||
}
|
||||
else
|
||||
{
|
||||
Map map = m_Mobile.Map;
|
||||
|
||||
if (map != null)
|
||||
{
|
||||
Mobile active = null, inactive = null;
|
||||
double actPrio = 0.0, inactPrio = 0.0;
|
||||
|
||||
Mobile comb = m_Mobile.Combatant as Mobile;
|
||||
|
||||
if (comb != null && !comb.Deleted && comb.Alive && !comb.IsDeadBondedPet && CanDispel(comb))
|
||||
{
|
||||
active = inactive = comb;
|
||||
actPrio = inactPrio = m_Mobile.GetDistanceToSqrt(comb);
|
||||
}
|
||||
|
||||
IPooledEnumerable eable = m_Mobile.GetMobilesInRange(12);
|
||||
|
||||
foreach (Mobile m in eable)
|
||||
{
|
||||
if (m != m_Mobile && CanDispel(m))
|
||||
{
|
||||
double prio = m_Mobile.GetDistanceToSqrt(m);
|
||||
|
||||
if (!activeOnly && (inactive == null || prio < inactPrio))
|
||||
{
|
||||
inactive = m;
|
||||
inactPrio = prio;
|
||||
}
|
||||
|
||||
if ((m_Mobile.Combatant == m || m.Combatant == m_Mobile) && (active == null || prio < actPrio))
|
||||
{
|
||||
active = m;
|
||||
actPrio = prio;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
eable.Free();
|
||||
|
||||
return active != null ? active : inactive;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool CanDispel(Mobile m)
|
||||
{
|
||||
return (m is BaseCreature && ((BaseCreature)m).Summoned && m_Mobile.CanBeHarmful(m, false) &&
|
||||
!((BaseCreature)m).IsAnimatedDead);
|
||||
}
|
||||
|
||||
public void RunTo(Mobile m)
|
||||
{
|
||||
/*if ( m.Paralyzed || m.Frozen )
|
||||
{
|
||||
if ( m_Mobile.InRange( m, 1 ) )
|
||||
RunFrom( m );
|
||||
else if ( !m_Mobile.InRange( m, m_Mobile.RangeFight > 2 ? m_Mobile.RangeFight : 2 ) && !MoveTo( m, true, 1 ) )
|
||||
OnFailedMove();
|
||||
}
|
||||
else
|
||||
{*/
|
||||
if (!m_Mobile.InRange(m, m_Mobile.RangeFight))
|
||||
{
|
||||
if (!MoveTo(m, true, 1))
|
||||
{
|
||||
OnFailedMove();
|
||||
}
|
||||
}
|
||||
else if (m_Mobile.InRange(m, m_Mobile.RangeFight - 1))
|
||||
{
|
||||
RunFrom(m);
|
||||
}
|
||||
/*}*/
|
||||
}
|
||||
|
||||
public void RunFrom(Mobile m)
|
||||
{
|
||||
Run((Direction)((int)m_Mobile.GetDirectionTo(m) - 4) & Direction.Mask);
|
||||
}
|
||||
|
||||
public void OnFailedMove()
|
||||
{
|
||||
/*if ( !m_Mobile.DisallowAllMoves && 20 > Utility.Random( 100 ) && IsAllowed( GuardAI.Magic ) )
|
||||
{
|
||||
if ( m_Mobile.Target != null )
|
||||
m_Mobile.Target.Cancel( m_Mobile, TargetCancelType.Canceled );
|
||||
new TeleportSpell( m_Mobile, null ).Cast();
|
||||
m_Mobile.DebugSay( "I am stuck, I'm going to try teleporting away" );
|
||||
}
|
||||
else*/
|
||||
if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true))
|
||||
{
|
||||
if (m_Mobile.Debug)
|
||||
{
|
||||
m_Mobile.DebugSay("My move is blocked, so I am going to attack {0}", m_Mobile.FocusMob.Name);
|
||||
}
|
||||
|
||||
m_Mobile.Combatant = m_Mobile.FocusMob;
|
||||
Action = ActionType.Combat;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Mobile.DebugSay("I am stuck");
|
||||
}
|
||||
}
|
||||
|
||||
public void Run(Direction d)
|
||||
{
|
||||
if ((m_Mobile.Spell != null && m_Mobile.Spell.IsCasting) || m_Mobile.Paralyzed || m_Mobile.Frozen ||
|
||||
m_Mobile.DisallowAllMoves)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_Mobile.Direction = d | Direction.Running;
|
||||
|
||||
if (!DoMove(m_Mobile.Direction, true))
|
||||
{
|
||||
OnFailedMove();
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Think()
|
||||
{
|
||||
if (m_Mobile.Deleted)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Mobile combatant = m_Guard.Combatant as Mobile;
|
||||
|
||||
if (combatant == null || combatant.Deleted || !combatant.Alive || combatant.IsDeadBondedPet ||
|
||||
!m_Mobile.CanSee(combatant) || !m_Mobile.CanBeHarmful(combatant, false) || combatant.Map != m_Mobile.Map)
|
||||
{
|
||||
// Our combatant is deleted, dead, hidden, or we cannot hurt them
|
||||
// Try to find another combatant
|
||||
if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true))
|
||||
{
|
||||
m_Mobile.Combatant = combatant = m_Mobile.FocusMob as Mobile;
|
||||
m_Mobile.FocusMob = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Mobile.Combatant = combatant = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (combatant != null && (!m_Mobile.InLOS(combatant) || !m_Mobile.InRange(combatant, 12)))
|
||||
{
|
||||
if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true))
|
||||
{
|
||||
m_Mobile.Combatant = combatant = m_Mobile.FocusMob as Mobile;
|
||||
m_Mobile.FocusMob = null;
|
||||
}
|
||||
else if (!m_Mobile.InRange(combatant, 36))
|
||||
{
|
||||
m_Mobile.Combatant = combatant = null;
|
||||
}
|
||||
}
|
||||
|
||||
Mobile dispelTarget = FindDispelTarget(true);
|
||||
|
||||
if (m_Guard.Target != null && m_ReleaseTarget == DateTime.MinValue)
|
||||
{
|
||||
m_ReleaseTarget = DateTime.UtcNow + TimeSpan.FromSeconds(10.0);
|
||||
}
|
||||
|
||||
if (m_Guard.Target != null && DateTime.UtcNow > m_ReleaseTarget)
|
||||
{
|
||||
Target targ = m_Guard.Target;
|
||||
|
||||
Mobile toHarm = (dispelTarget == null ? combatant : dispelTarget);
|
||||
|
||||
if ((targ.Flags & TargetFlags.Harmful) != 0 && toHarm != null)
|
||||
{
|
||||
if (m_Guard.Map == toHarm.Map && (targ.Range < 0 || m_Guard.InRange(toHarm, targ.Range)) && m_Guard.CanSee(toHarm) &&
|
||||
m_Guard.InLOS(toHarm))
|
||||
{
|
||||
targ.Invoke(m_Guard, toHarm);
|
||||
}
|
||||
else if (targ is DispelSpell.InternalTarget)
|
||||
{
|
||||
targ.Cancel(m_Guard, TargetCancelType.Canceled);
|
||||
}
|
||||
}
|
||||
else if ((targ.Flags & TargetFlags.Beneficial) != 0)
|
||||
{
|
||||
targ.Invoke(m_Guard, m_Guard);
|
||||
}
|
||||
else
|
||||
{
|
||||
targ.Cancel(m_Guard, TargetCancelType.Canceled);
|
||||
}
|
||||
|
||||
m_ReleaseTarget = DateTime.MinValue;
|
||||
}
|
||||
|
||||
if (dispelTarget != null)
|
||||
{
|
||||
if (Action != ActionType.Combat)
|
||||
{
|
||||
Action = ActionType.Combat;
|
||||
}
|
||||
|
||||
m_Guard.Warmode = true;
|
||||
|
||||
RunFrom(dispelTarget);
|
||||
}
|
||||
else if (combatant != null)
|
||||
{
|
||||
if (Action != ActionType.Combat)
|
||||
{
|
||||
Action = ActionType.Combat;
|
||||
}
|
||||
|
||||
m_Guard.Warmode = true;
|
||||
|
||||
RunTo(combatant);
|
||||
}
|
||||
else if (m_Guard.Orders.Movement != MovementType.Stand)
|
||||
{
|
||||
Mobile toFollow = null;
|
||||
|
||||
if (m_Guard.Town != null && m_Guard.Orders.Movement == MovementType.Follow)
|
||||
{
|
||||
toFollow = m_Guard.Orders.Follow;
|
||||
|
||||
if (toFollow == null)
|
||||
{
|
||||
toFollow = m_Guard.Town.Sheriff;
|
||||
}
|
||||
}
|
||||
|
||||
if (toFollow != null && toFollow.Map == m_Guard.Map && toFollow.InRange(m_Guard, m_Guard.RangePerception * 3) &&
|
||||
Town.FromRegion(toFollow.Region) == m_Guard.Town)
|
||||
{
|
||||
if (Action != ActionType.Combat)
|
||||
{
|
||||
Action = ActionType.Combat;
|
||||
}
|
||||
|
||||
if (m_Mobile.CurrentSpeed != m_Mobile.ActiveSpeed)
|
||||
{
|
||||
m_Mobile.CurrentSpeed = m_Mobile.ActiveSpeed;
|
||||
}
|
||||
|
||||
m_Guard.Warmode = true;
|
||||
|
||||
RunTo(toFollow);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Action != ActionType.Wander)
|
||||
{
|
||||
Action = ActionType.Wander;
|
||||
}
|
||||
|
||||
if (m_Mobile.CurrentSpeed != m_Mobile.PassiveSpeed)
|
||||
{
|
||||
m_Mobile.CurrentSpeed = m_Mobile.PassiveSpeed;
|
||||
}
|
||||
|
||||
m_Guard.Warmode = false;
|
||||
|
||||
WalkRandomInHome(2, 2, 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Action != ActionType.Wander)
|
||||
{
|
||||
Action = ActionType.Wander;
|
||||
}
|
||||
|
||||
m_Guard.Warmode = false;
|
||||
}
|
||||
|
||||
if ((IsDamaged || IsPoisoned) && m_Guard.Skills.Healing.Base > 20.0)
|
||||
{
|
||||
TimeSpan ts = TimeUntilBandage;
|
||||
|
||||
if (ts == TimeSpan.MaxValue)
|
||||
{
|
||||
StartBandage();
|
||||
}
|
||||
}
|
||||
|
||||
if (m_Mobile.Spell == null && Core.TickCount >= m_Mobile.NextSpellTime)
|
||||
{
|
||||
Spell spell = null;
|
||||
|
||||
DateTime toRelease = DateTime.MinValue;
|
||||
|
||||
if (IsPoisoned)
|
||||
{
|
||||
Poison p = m_Guard.Poison;
|
||||
|
||||
TimeSpan ts = TimeUntilBandage;
|
||||
|
||||
if (p != Poison.Lesser || ts == TimeSpan.MaxValue || TimeUntilBandage < TimeSpan.FromSeconds(1.5) ||
|
||||
(m_Guard.HitsMax - m_Guard.Hits) > Utility.Random(250))
|
||||
{
|
||||
if (IsAllowed(GuardAI.Bless))
|
||||
{
|
||||
spell = new CureSpell(m_Guard, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
UseItemByType(typeof(BaseCurePotion));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (IsDamaged && (m_Guard.HitsMax - m_Guard.Hits) > Utility.Random(200))
|
||||
{
|
||||
if (IsAllowed(GuardAI.Magic) && ((m_Guard.Hits * 100) / Math.Max(m_Guard.HitsMax, 1)) < 10 &&
|
||||
m_Guard.Home != Point3D.Zero && !Utility.InRange(m_Guard.Location, m_Guard.Home, 15) && m_Guard.Mana >= 11)
|
||||
{
|
||||
spell = new RecallSpell(m_Guard, null, new RunebookEntry(m_Guard.Home, m_Guard.Map, "Guard's Home", null, RecallRuneType.Normal), null);
|
||||
}
|
||||
else if (IsAllowed(GuardAI.Bless))
|
||||
{
|
||||
if (m_Guard.Mana >= 11 && (m_Guard.Hits + 30) < m_Guard.HitsMax)
|
||||
{
|
||||
spell = new GreaterHealSpell(m_Guard, null);
|
||||
}
|
||||
else if ((m_Guard.Hits + 10) < m_Guard.HitsMax &&
|
||||
(m_Guard.Mana < 11 || (m_Guard.NextCombatTime - Core.TickCount) > 2000))
|
||||
{
|
||||
spell = new HealSpell(m_Guard, null);
|
||||
}
|
||||
}
|
||||
else if (m_Guard.CanBeginAction(typeof(BaseHealPotion)))
|
||||
{
|
||||
UseItemByType(typeof(BaseHealPotion));
|
||||
}
|
||||
}
|
||||
else if (dispelTarget != null && (IsAllowed(GuardAI.Magic) || IsAllowed(GuardAI.Bless) || IsAllowed(GuardAI.Curse)))
|
||||
{
|
||||
if (!dispelTarget.Paralyzed && m_Guard.Mana > (ManaReserve + 20) && 40 > Utility.Random(100))
|
||||
{
|
||||
spell = new ParalyzeSpell(m_Guard, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
spell = new DispelSpell(m_Guard, null);
|
||||
}
|
||||
}
|
||||
|
||||
if (combatant != null)
|
||||
{
|
||||
if (m_Combo != null)
|
||||
{
|
||||
if (spell == null)
|
||||
{
|
||||
spell = SpellCombo.Process(m_Guard, combatant, ref m_Combo, ref m_ComboIndex, ref toRelease);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Combo = null;
|
||||
m_ComboIndex = -1;
|
||||
}
|
||||
}
|
||||
else if (20 > Utility.Random(100) && IsAllowed(GuardAI.Magic))
|
||||
{
|
||||
if (80 > Utility.Random(100))
|
||||
{
|
||||
m_Combo = (IsAllowed(GuardAI.Smart) ? SpellCombo.Simple : SpellCombo.Strong);
|
||||
m_ComboIndex = -1;
|
||||
|
||||
if (m_Guard.Mana >= (ManaReserve + m_Combo.Mana))
|
||||
{
|
||||
spell = SpellCombo.Process(m_Guard, combatant, ref m_Combo, ref m_ComboIndex, ref toRelease);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Combo = null;
|
||||
|
||||
if (m_Guard.Mana >= (ManaReserve + 40))
|
||||
{
|
||||
spell = RandomOffenseSpell();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (m_Guard.Mana >= (ManaReserve + 40))
|
||||
{
|
||||
spell = RandomOffenseSpell();
|
||||
}
|
||||
}
|
||||
|
||||
if (spell == null && 2 > Utility.Random(100) && m_Guard.Mana >= (ManaReserve + 10))
|
||||
{
|
||||
int strMod = GetStatMod(m_Guard, StatType.Str);
|
||||
int dexMod = GetStatMod(m_Guard, StatType.Dex);
|
||||
int intMod = GetStatMod(m_Guard, StatType.Int);
|
||||
|
||||
var types = new List<Type>();
|
||||
|
||||
if (strMod <= 0)
|
||||
{
|
||||
types.Add(typeof(StrengthSpell));
|
||||
}
|
||||
|
||||
if (dexMod <= 0 && IsAllowed(GuardAI.Melee))
|
||||
{
|
||||
types.Add(typeof(AgilitySpell));
|
||||
}
|
||||
|
||||
if (intMod <= 0 && IsAllowed(GuardAI.Magic))
|
||||
{
|
||||
types.Add(typeof(CunningSpell));
|
||||
}
|
||||
|
||||
if (IsAllowed(GuardAI.Bless))
|
||||
{
|
||||
if (types.Count > 1)
|
||||
{
|
||||
spell = new BlessSpell(m_Guard, null);
|
||||
}
|
||||
else if (types.Count == 1)
|
||||
{
|
||||
spell = (Spell)Activator.CreateInstance(types[0], new object[] {m_Guard, null});
|
||||
}
|
||||
}
|
||||
else if (types.Count > 0)
|
||||
{
|
||||
if (types[0] == typeof(StrengthSpell))
|
||||
{
|
||||
UseItemByType(typeof(BaseStrengthPotion));
|
||||
}
|
||||
else if (types[0] == typeof(AgilitySpell))
|
||||
{
|
||||
UseItemByType(typeof(BaseAgilityPotion));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (spell == null && 2 > Utility.Random(100) && m_Guard.Mana >= (ManaReserve + 10) && IsAllowed(GuardAI.Curse))
|
||||
{
|
||||
if (!combatant.Poisoned && 40 > Utility.Random(100))
|
||||
{
|
||||
spell = new PoisonSpell(m_Guard, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
int strMod = GetStatMod(combatant, StatType.Str);
|
||||
int dexMod = GetStatMod(combatant, StatType.Dex);
|
||||
int intMod = GetStatMod(combatant, StatType.Int);
|
||||
|
||||
var types = new List<Type>();
|
||||
|
||||
if (strMod >= 0)
|
||||
{
|
||||
types.Add(typeof(WeakenSpell));
|
||||
}
|
||||
|
||||
if (dexMod >= 0 && IsAllowed(GuardAI.Melee))
|
||||
{
|
||||
types.Add(typeof(ClumsySpell));
|
||||
}
|
||||
|
||||
if (intMod >= 0 && IsAllowed(GuardAI.Magic))
|
||||
{
|
||||
types.Add(typeof(FeeblemindSpell));
|
||||
}
|
||||
|
||||
if (types.Count > 1)
|
||||
{
|
||||
spell = new CurseSpell(m_Guard, null);
|
||||
}
|
||||
else if (types.Count == 1)
|
||||
{
|
||||
spell = (Spell)Activator.CreateInstance(types[0], new object[] {m_Guard, null});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (spell != null && (m_Guard.HitsMax - m_Guard.Hits + 10) > Utility.Random(100))
|
||||
{
|
||||
Type type = null;
|
||||
|
||||
if (spell is GreaterHealSpell)
|
||||
{
|
||||
type = typeof(BaseHealPotion);
|
||||
}
|
||||
else if (spell is CureSpell)
|
||||
{
|
||||
type = typeof(BaseCurePotion);
|
||||
}
|
||||
else if (spell is StrengthSpell)
|
||||
{
|
||||
type = typeof(BaseStrengthPotion);
|
||||
}
|
||||
else if (spell is AgilitySpell)
|
||||
{
|
||||
type = typeof(BaseAgilityPotion);
|
||||
}
|
||||
|
||||
if (type == typeof(BaseHealPotion) && !m_Guard.CanBeginAction(type))
|
||||
{
|
||||
type = null;
|
||||
}
|
||||
|
||||
if (type != null && m_Guard.Target == null && UseItemByType(type))
|
||||
{
|
||||
if (spell is GreaterHealSpell)
|
||||
{
|
||||
if ((m_Guard.Hits + 30) > m_Guard.HitsMax && (m_Guard.Hits + 10) < m_Guard.HitsMax)
|
||||
{
|
||||
spell = new HealSpell(m_Guard, null);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
spell = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (spell == null && m_Guard.Stam < (m_Guard.StamMax / 3) && IsAllowed(GuardAI.Melee))
|
||||
{
|
||||
UseItemByType(typeof(BaseRefreshPotion));
|
||||
}
|
||||
|
||||
if (spell == null || !spell.Cast())
|
||||
{
|
||||
EquipWeapon();
|
||||
}
|
||||
}
|
||||
else if (m_Mobile.Spell is Spell && ((Spell)m_Mobile.Spell).State == SpellState.Sequencing)
|
||||
{
|
||||
EquipWeapon();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
182
Scripts/Services/Factions/Mobiles/Guards/Orders.cs
Normal file
182
Scripts/Services/Factions/Mobiles/Guards/Orders.cs
Normal file
@@ -0,0 +1,182 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Factions.AI
|
||||
{
|
||||
public enum ReactionType
|
||||
{
|
||||
Ignore,
|
||||
Warn,
|
||||
Attack
|
||||
}
|
||||
|
||||
public enum MovementType
|
||||
{
|
||||
Stand,
|
||||
Patrol,
|
||||
Follow
|
||||
}
|
||||
|
||||
public class Reaction
|
||||
{
|
||||
private readonly Faction m_Faction;
|
||||
private ReactionType m_Type;
|
||||
public Reaction(Faction faction, ReactionType type)
|
||||
{
|
||||
this.m_Faction = faction;
|
||||
this.m_Type = type;
|
||||
}
|
||||
|
||||
public Reaction(GenericReader reader)
|
||||
{
|
||||
int version = reader.ReadEncodedInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
this.m_Faction = Faction.ReadReference(reader);
|
||||
this.m_Type = (ReactionType)reader.ReadEncodedInt();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Faction Faction
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Faction;
|
||||
}
|
||||
}
|
||||
public ReactionType Type
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Type;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_Type = value;
|
||||
}
|
||||
}
|
||||
public void Serialize(GenericWriter writer)
|
||||
{
|
||||
writer.WriteEncodedInt((int)0); // version
|
||||
|
||||
Faction.WriteReference(writer, this.m_Faction);
|
||||
writer.WriteEncodedInt((int)this.m_Type);
|
||||
}
|
||||
}
|
||||
|
||||
public class Orders
|
||||
{
|
||||
private readonly BaseFactionGuard m_Guard;
|
||||
private readonly List<Reaction> m_Reactions;
|
||||
private MovementType m_Movement;
|
||||
private Mobile m_Follow;
|
||||
public Orders(BaseFactionGuard guard)
|
||||
{
|
||||
this.m_Guard = guard;
|
||||
this.m_Reactions = new List<Reaction>();
|
||||
this.m_Movement = MovementType.Patrol;
|
||||
}
|
||||
|
||||
public Orders(BaseFactionGuard guard, GenericReader reader)
|
||||
{
|
||||
this.m_Guard = guard;
|
||||
|
||||
int version = reader.ReadEncodedInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
this.m_Follow = reader.ReadMobile();
|
||||
goto case 0;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
int count = reader.ReadEncodedInt();
|
||||
this.m_Reactions = new List<Reaction>(count);
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
this.m_Reactions.Add(new Reaction(reader));
|
||||
|
||||
this.m_Movement = (MovementType)reader.ReadEncodedInt();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public BaseFactionGuard Guard
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Guard;
|
||||
}
|
||||
}
|
||||
public MovementType Movement
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Movement;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_Movement = value;
|
||||
}
|
||||
}
|
||||
public Mobile Follow
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Follow;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_Follow = value;
|
||||
}
|
||||
}
|
||||
public Reaction GetReaction(Faction faction)
|
||||
{
|
||||
Reaction reaction;
|
||||
|
||||
for (int i = 0; i < this.m_Reactions.Count; ++i)
|
||||
{
|
||||
reaction = this.m_Reactions[i];
|
||||
|
||||
if (reaction.Faction == faction)
|
||||
return reaction;
|
||||
}
|
||||
|
||||
reaction = new Reaction(faction, (faction == null || faction == this.m_Guard.Faction) ? ReactionType.Ignore : ReactionType.Attack);
|
||||
this.m_Reactions.Add(reaction);
|
||||
|
||||
return reaction;
|
||||
}
|
||||
|
||||
public void SetReaction(Faction faction, ReactionType type)
|
||||
{
|
||||
Reaction reaction = this.GetReaction(faction);
|
||||
|
||||
reaction.Type = type;
|
||||
}
|
||||
|
||||
public void Serialize(GenericWriter writer)
|
||||
{
|
||||
writer.WriteEncodedInt((int)1); // version
|
||||
|
||||
writer.Write((Mobile)this.m_Follow);
|
||||
|
||||
writer.WriteEncodedInt((int)this.m_Reactions.Count);
|
||||
|
||||
for (int i = 0; i < this.m_Reactions.Count; ++i)
|
||||
this.m_Reactions[i].Serialize(writer);
|
||||
|
||||
writer.WriteEncodedInt((int)this.m_Movement);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
using System;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionBerserker : BaseFactionGuard
|
||||
{
|
||||
[Constructable]
|
||||
public FactionBerserker()
|
||||
: base("the berserker")
|
||||
{
|
||||
this.GenerateBody(false, false);
|
||||
|
||||
this.SetStr(126, 150);
|
||||
this.SetDex(61, 85);
|
||||
this.SetInt(81, 95);
|
||||
|
||||
this.SetDamageType(ResistanceType.Physical, 100);
|
||||
|
||||
this.SetResistance(ResistanceType.Physical, 30, 50);
|
||||
this.SetResistance(ResistanceType.Fire, 30, 50);
|
||||
this.SetResistance(ResistanceType.Cold, 30, 50);
|
||||
this.SetResistance(ResistanceType.Energy, 30, 50);
|
||||
this.SetResistance(ResistanceType.Poison, 30, 50);
|
||||
|
||||
this.VirtualArmor = 24;
|
||||
|
||||
this.SetSkill(SkillName.Swords, 100.0, 110.0);
|
||||
this.SetSkill(SkillName.Wrestling, 100.0, 110.0);
|
||||
this.SetSkill(SkillName.Tactics, 100.0, 110.0);
|
||||
this.SetSkill(SkillName.MagicResist, 100.0, 110.0);
|
||||
this.SetSkill(SkillName.Healing, 100.0, 110.0);
|
||||
this.SetSkill(SkillName.Anatomy, 100.0, 110.0);
|
||||
|
||||
this.SetSkill(SkillName.Magery, 100.0, 110.0);
|
||||
this.SetSkill(SkillName.EvalInt, 100.0, 110.0);
|
||||
this.SetSkill(SkillName.Meditation, 100.0, 110.0);
|
||||
|
||||
this.AddItem(this.Immovable(this.Rehued(new BodySash(), 1645)));
|
||||
this.AddItem(this.Immovable(this.Rehued(new Kilt(), 1645)));
|
||||
this.AddItem(this.Immovable(this.Rehued(new Sandals(), 1645)));
|
||||
this.AddItem(this.Newbied(new DoubleAxe()));
|
||||
|
||||
this.HairItemID = 0x2047; // Afro
|
||||
this.HairHue = 0x29;
|
||||
|
||||
this.FacialHairItemID = 0x204B; // Medium Short Beard
|
||||
this.FacialHairHue = 0x29;
|
||||
|
||||
this.PackItem(new Bandage(Utility.RandomMinMax(30, 40)));
|
||||
this.PackStrongPotions(6, 12);
|
||||
}
|
||||
|
||||
public FactionBerserker(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override GuardAI GuardAI
|
||||
{
|
||||
get
|
||||
{
|
||||
return GuardAI.Melee | GuardAI.Curse | GuardAI.Bless;
|
||||
}
|
||||
}
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
using System;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionDeathKnight : BaseFactionGuard
|
||||
{
|
||||
[Constructable]
|
||||
public FactionDeathKnight()
|
||||
: base("the death knight")
|
||||
{
|
||||
this.GenerateBody(false, false);
|
||||
this.Hue = 1;
|
||||
|
||||
this.SetStr(126, 150);
|
||||
this.SetDex(61, 85);
|
||||
this.SetInt(81, 95);
|
||||
|
||||
this.SetDamageType(ResistanceType.Physical, 100);
|
||||
|
||||
this.SetResistance(ResistanceType.Physical, 30, 50);
|
||||
this.SetResistance(ResistanceType.Fire, 30, 50);
|
||||
this.SetResistance(ResistanceType.Cold, 30, 50);
|
||||
this.SetResistance(ResistanceType.Energy, 30, 50);
|
||||
this.SetResistance(ResistanceType.Poison, 30, 50);
|
||||
|
||||
this.VirtualArmor = 24;
|
||||
|
||||
this.SetSkill(SkillName.Swords, 100.0, 110.0);
|
||||
this.SetSkill(SkillName.Wrestling, 100.0, 110.0);
|
||||
this.SetSkill(SkillName.Tactics, 100.0, 110.0);
|
||||
this.SetSkill(SkillName.MagicResist, 100.0, 110.0);
|
||||
this.SetSkill(SkillName.Healing, 100.0, 110.0);
|
||||
this.SetSkill(SkillName.Anatomy, 100.0, 110.0);
|
||||
|
||||
this.SetSkill(SkillName.Magery, 100.0, 110.0);
|
||||
this.SetSkill(SkillName.EvalInt, 100.0, 110.0);
|
||||
this.SetSkill(SkillName.Meditation, 100.0, 110.0);
|
||||
|
||||
Item shroud = new Item(0x204E);
|
||||
shroud.Layer = Layer.OuterTorso;
|
||||
|
||||
this.AddItem(this.Immovable(this.Rehued(shroud, 1109)));
|
||||
this.AddItem(this.Newbied(this.Rehued(new ExecutionersAxe(), 2211)));
|
||||
|
||||
this.PackItem(new Bandage(Utility.RandomMinMax(30, 40)));
|
||||
this.PackStrongPotions(6, 12);
|
||||
}
|
||||
|
||||
public FactionDeathKnight(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override GuardAI GuardAI
|
||||
{
|
||||
get
|
||||
{
|
||||
return GuardAI.Melee | GuardAI.Curse | GuardAI.Bless;
|
||||
}
|
||||
}
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
using System;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionDragoon : BaseFactionGuard
|
||||
{
|
||||
[Constructable]
|
||||
public FactionDragoon()
|
||||
: base("the dragoon")
|
||||
{
|
||||
this.GenerateBody(false, false);
|
||||
|
||||
this.SetStr(151, 175);
|
||||
this.SetDex(61, 85);
|
||||
this.SetInt(151, 175);
|
||||
|
||||
this.SetResistance(ResistanceType.Physical, 40, 60);
|
||||
this.SetResistance(ResistanceType.Fire, 40, 60);
|
||||
this.SetResistance(ResistanceType.Cold, 40, 60);
|
||||
this.SetResistance(ResistanceType.Energy, 40, 60);
|
||||
this.SetResistance(ResistanceType.Poison, 40, 60);
|
||||
|
||||
this.VirtualArmor = 32;
|
||||
|
||||
this.SetSkill(SkillName.Macing, 110.0, 120.0);
|
||||
this.SetSkill(SkillName.Wrestling, 110.0, 120.0);
|
||||
this.SetSkill(SkillName.Tactics, 110.0, 120.0);
|
||||
this.SetSkill(SkillName.MagicResist, 110.0, 120.0);
|
||||
this.SetSkill(SkillName.Healing, 110.0, 120.0);
|
||||
this.SetSkill(SkillName.Anatomy, 110.0, 120.0);
|
||||
|
||||
this.SetSkill(SkillName.Magery, 110.0, 120.0);
|
||||
this.SetSkill(SkillName.EvalInt, 110.0, 120.0);
|
||||
this.SetSkill(SkillName.Meditation, 110.0, 120.0);
|
||||
|
||||
this.AddItem(this.Immovable(this.Rehued(new Cloak(), 1645)));
|
||||
|
||||
this.AddItem(this.Immovable(this.Rehued(new PlateChest(), 1645)));
|
||||
this.AddItem(this.Immovable(this.Rehued(new PlateLegs(), 1109)));
|
||||
this.AddItem(this.Immovable(this.Rehued(new PlateArms(), 1109)));
|
||||
this.AddItem(this.Immovable(this.Rehued(new PlateGloves(), 1109)));
|
||||
this.AddItem(this.Immovable(this.Rehued(new PlateGorget(), 1109)));
|
||||
this.AddItem(this.Immovable(this.Rehued(new PlateHelm(), 1109)));
|
||||
|
||||
this.AddItem(this.Newbied(new WarHammer()));
|
||||
|
||||
this.AddItem(this.Immovable(this.Rehued(new VirtualMountItem(this), 1109)));
|
||||
|
||||
this.PackItem(new Bandage(Utility.RandomMinMax(30, 40)));
|
||||
this.PackStrongPotions(6, 12);
|
||||
}
|
||||
|
||||
public FactionDragoon(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override GuardAI GuardAI
|
||||
{
|
||||
get
|
||||
{
|
||||
return GuardAI.Magic | GuardAI.Melee | GuardAI.Smart | GuardAI.Bless | GuardAI.Curse;
|
||||
}
|
||||
}
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
using System;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionHenchman : BaseFactionGuard
|
||||
{
|
||||
[Constructable]
|
||||
public FactionHenchman()
|
||||
: base("the henchman")
|
||||
{
|
||||
this.GenerateBody(false, true);
|
||||
|
||||
this.SetStr(91, 115);
|
||||
this.SetDex(61, 85);
|
||||
this.SetInt(81, 95);
|
||||
|
||||
this.SetDamage(10, 14);
|
||||
|
||||
this.SetResistance(ResistanceType.Physical, 10, 30);
|
||||
this.SetResistance(ResistanceType.Fire, 10, 30);
|
||||
this.SetResistance(ResistanceType.Cold, 10, 30);
|
||||
this.SetResistance(ResistanceType.Energy, 10, 30);
|
||||
this.SetResistance(ResistanceType.Poison, 10, 30);
|
||||
|
||||
this.VirtualArmor = 8;
|
||||
|
||||
this.SetSkill(SkillName.Fencing, 80.0, 90.0);
|
||||
this.SetSkill(SkillName.Wrestling, 80.0, 90.0);
|
||||
this.SetSkill(SkillName.Tactics, 80.0, 90.0);
|
||||
this.SetSkill(SkillName.MagicResist, 80.0, 90.0);
|
||||
this.SetSkill(SkillName.Healing, 80.0, 90.0);
|
||||
this.SetSkill(SkillName.Anatomy, 80.0, 90.0);
|
||||
|
||||
this.AddItem(new StuddedChest());
|
||||
this.AddItem(new StuddedLegs());
|
||||
this.AddItem(new StuddedArms());
|
||||
this.AddItem(new StuddedGloves());
|
||||
this.AddItem(new StuddedGorget());
|
||||
this.AddItem(new Boots());
|
||||
this.AddItem(this.Newbied(new Spear()));
|
||||
|
||||
this.PackItem(new Bandage(Utility.RandomMinMax(10, 20)));
|
||||
this.PackWeakPotions(1, 4);
|
||||
}
|
||||
|
||||
public FactionHenchman(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override GuardAI GuardAI
|
||||
{
|
||||
get
|
||||
{
|
||||
return GuardAI.Melee;
|
||||
}
|
||||
}
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
using System;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionKnight : BaseFactionGuard
|
||||
{
|
||||
[Constructable]
|
||||
public FactionKnight()
|
||||
: base("the knight")
|
||||
{
|
||||
this.GenerateBody(false, false);
|
||||
|
||||
this.SetStr(126, 150);
|
||||
this.SetDex(61, 85);
|
||||
this.SetInt(81, 95);
|
||||
|
||||
this.SetDamageType(ResistanceType.Physical, 100);
|
||||
|
||||
this.SetResistance(ResistanceType.Physical, 30, 50);
|
||||
this.SetResistance(ResistanceType.Fire, 30, 50);
|
||||
this.SetResistance(ResistanceType.Cold, 30, 50);
|
||||
this.SetResistance(ResistanceType.Energy, 30, 50);
|
||||
this.SetResistance(ResistanceType.Poison, 30, 50);
|
||||
|
||||
this.VirtualArmor = 24;
|
||||
|
||||
this.SetSkill(SkillName.Swords, 100.0, 110.0);
|
||||
this.SetSkill(SkillName.Wrestling, 100.0, 110.0);
|
||||
this.SetSkill(SkillName.Tactics, 100.0, 110.0);
|
||||
this.SetSkill(SkillName.MagicResist, 100.0, 110.0);
|
||||
this.SetSkill(SkillName.Healing, 100.0, 110.0);
|
||||
this.SetSkill(SkillName.Anatomy, 100.0, 110.0);
|
||||
|
||||
this.SetSkill(SkillName.Magery, 100.0, 110.0);
|
||||
this.SetSkill(SkillName.EvalInt, 100.0, 110.0);
|
||||
this.SetSkill(SkillName.Meditation, 100.0, 110.0);
|
||||
|
||||
this.AddItem(this.Immovable(this.Rehued(new ChainChest(), 2125)));
|
||||
this.AddItem(this.Immovable(this.Rehued(new ChainLegs(), 2125)));
|
||||
this.AddItem(this.Immovable(this.Rehued(new ChainCoif(), 2125)));
|
||||
this.AddItem(this.Immovable(this.Rehued(new PlateArms(), 2125)));
|
||||
this.AddItem(this.Immovable(this.Rehued(new PlateGloves(), 2125)));
|
||||
|
||||
this.AddItem(this.Immovable(this.Rehued(new BodySash(), 1254)));
|
||||
this.AddItem(this.Immovable(this.Rehued(new Kilt(), 1254)));
|
||||
this.AddItem(this.Immovable(this.Rehued(new Sandals(), 1254)));
|
||||
|
||||
this.AddItem(this.Newbied(new Bardiche()));
|
||||
|
||||
this.PackItem(new Bandage(Utility.RandomMinMax(30, 40)));
|
||||
this.PackStrongPotions(6, 12);
|
||||
}
|
||||
|
||||
public FactionKnight(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override GuardAI GuardAI
|
||||
{
|
||||
get
|
||||
{
|
||||
return GuardAI.Magic | GuardAI.Melee | GuardAI.Smart | GuardAI.Curse | GuardAI.Bless;
|
||||
}
|
||||
}
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
using System;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionMercenary : BaseFactionGuard
|
||||
{
|
||||
[Constructable]
|
||||
public FactionMercenary()
|
||||
: base("the mercenary")
|
||||
{
|
||||
this.GenerateBody(false, true);
|
||||
|
||||
this.SetStr(116, 125);
|
||||
this.SetDex(61, 85);
|
||||
this.SetInt(81, 95);
|
||||
|
||||
this.SetResistance(ResistanceType.Physical, 20, 40);
|
||||
this.SetResistance(ResistanceType.Fire, 20, 40);
|
||||
this.SetResistance(ResistanceType.Cold, 20, 40);
|
||||
this.SetResistance(ResistanceType.Energy, 20, 40);
|
||||
this.SetResistance(ResistanceType.Poison, 20, 40);
|
||||
|
||||
this.VirtualArmor = 16;
|
||||
|
||||
this.SetSkill(SkillName.Fencing, 90.0, 100.0);
|
||||
this.SetSkill(SkillName.Wrestling, 90.0, 100.0);
|
||||
this.SetSkill(SkillName.Tactics, 90.0, 100.0);
|
||||
this.SetSkill(SkillName.MagicResist, 90.0, 100.0);
|
||||
this.SetSkill(SkillName.Healing, 90.0, 100.0);
|
||||
this.SetSkill(SkillName.Anatomy, 90.0, 100.0);
|
||||
|
||||
this.AddItem(new ChainChest());
|
||||
this.AddItem(new ChainLegs());
|
||||
this.AddItem(new RingmailArms());
|
||||
this.AddItem(new RingmailGloves());
|
||||
this.AddItem(new ChainCoif());
|
||||
this.AddItem(new Boots());
|
||||
this.AddItem(this.Newbied(new ShortSpear()));
|
||||
|
||||
this.PackItem(new Bandage(Utility.RandomMinMax(20, 30)));
|
||||
this.PackStrongPotions(3, 8);
|
||||
}
|
||||
|
||||
public FactionMercenary(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override GuardAI GuardAI
|
||||
{
|
||||
get
|
||||
{
|
||||
return GuardAI.Melee | GuardAI.Smart;
|
||||
}
|
||||
}
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionNecromancer : BaseFactionGuard
|
||||
{
|
||||
[Constructable]
|
||||
public FactionNecromancer()
|
||||
: base("the necromancer")
|
||||
{
|
||||
this.GenerateBody(false, false);
|
||||
this.Hue = 1;
|
||||
|
||||
this.SetStr(151, 175);
|
||||
this.SetDex(61, 85);
|
||||
this.SetInt(151, 175);
|
||||
|
||||
this.SetResistance(ResistanceType.Physical, 40, 60);
|
||||
this.SetResistance(ResistanceType.Fire, 40, 60);
|
||||
this.SetResistance(ResistanceType.Cold, 40, 60);
|
||||
this.SetResistance(ResistanceType.Energy, 40, 60);
|
||||
this.SetResistance(ResistanceType.Poison, 40, 60);
|
||||
|
||||
this.VirtualArmor = 32;
|
||||
|
||||
this.SetSkill(SkillName.Macing, 110.0, 120.0);
|
||||
this.SetSkill(SkillName.Wrestling, 110.0, 120.0);
|
||||
this.SetSkill(SkillName.Tactics, 110.0, 120.0);
|
||||
this.SetSkill(SkillName.MagicResist, 110.0, 120.0);
|
||||
this.SetSkill(SkillName.Healing, 110.0, 120.0);
|
||||
this.SetSkill(SkillName.Anatomy, 110.0, 120.0);
|
||||
|
||||
this.SetSkill(SkillName.Magery, 110.0, 120.0);
|
||||
this.SetSkill(SkillName.EvalInt, 110.0, 120.0);
|
||||
this.SetSkill(SkillName.Meditation, 110.0, 120.0);
|
||||
|
||||
Item shroud = new Item(0x204E);
|
||||
shroud.Layer = Layer.OuterTorso;
|
||||
|
||||
this.AddItem(this.Immovable(this.Rehued(shroud, 1109)));
|
||||
this.AddItem(this.Newbied(this.Rehued(new GnarledStaff(), 2211)));
|
||||
|
||||
this.PackItem(new Bandage(Utility.RandomMinMax(30, 40)));
|
||||
this.PackStrongPotions(6, 12);
|
||||
}
|
||||
|
||||
public FactionNecromancer(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override GuardAI GuardAI
|
||||
{
|
||||
get
|
||||
{
|
||||
return GuardAI.Magic | GuardAI.Smart | GuardAI.Bless | GuardAI.Curse;
|
||||
}
|
||||
}
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
using System;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionPaladin : BaseFactionGuard
|
||||
{
|
||||
[Constructable]
|
||||
public FactionPaladin()
|
||||
: base("the paladin")
|
||||
{
|
||||
this.GenerateBody(false, false);
|
||||
|
||||
this.SetStr(151, 175);
|
||||
this.SetDex(61, 85);
|
||||
this.SetInt(81, 95);
|
||||
|
||||
this.SetResistance(ResistanceType.Physical, 40, 60);
|
||||
this.SetResistance(ResistanceType.Fire, 40, 60);
|
||||
this.SetResistance(ResistanceType.Cold, 40, 60);
|
||||
this.SetResistance(ResistanceType.Energy, 40, 60);
|
||||
this.SetResistance(ResistanceType.Poison, 40, 60);
|
||||
|
||||
this.VirtualArmor = 32;
|
||||
|
||||
this.SetSkill(SkillName.Swords, 110.0, 120.0);
|
||||
this.SetSkill(SkillName.Wrestling, 110.0, 120.0);
|
||||
this.SetSkill(SkillName.Tactics, 110.0, 120.0);
|
||||
this.SetSkill(SkillName.MagicResist, 110.0, 120.0);
|
||||
this.SetSkill(SkillName.Healing, 110.0, 120.0);
|
||||
this.SetSkill(SkillName.Anatomy, 110.0, 120.0);
|
||||
|
||||
this.SetSkill(SkillName.Magery, 110.0, 120.0);
|
||||
this.SetSkill(SkillName.EvalInt, 110.0, 120.0);
|
||||
this.SetSkill(SkillName.Meditation, 110.0, 120.0);
|
||||
|
||||
this.AddItem(this.Immovable(this.Rehued(new PlateChest(), 2125)));
|
||||
this.AddItem(this.Immovable(this.Rehued(new PlateLegs(), 2125)));
|
||||
this.AddItem(this.Immovable(this.Rehued(new PlateHelm(), 2125)));
|
||||
this.AddItem(this.Immovable(this.Rehued(new PlateGorget(), 2125)));
|
||||
this.AddItem(this.Immovable(this.Rehued(new PlateArms(), 2125)));
|
||||
this.AddItem(this.Immovable(this.Rehued(new PlateGloves(), 2125)));
|
||||
|
||||
this.AddItem(this.Immovable(this.Rehued(new BodySash(), 1254)));
|
||||
this.AddItem(this.Immovable(this.Rehued(new Cloak(), 1254)));
|
||||
|
||||
this.AddItem(this.Newbied(new Halberd()));
|
||||
|
||||
this.AddItem(this.Immovable(this.Rehued(new VirtualMountItem(this), 1254)));
|
||||
|
||||
this.PackItem(new Bandage(Utility.RandomMinMax(30, 40)));
|
||||
this.PackStrongPotions(6, 12);
|
||||
}
|
||||
|
||||
public FactionPaladin(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override GuardAI GuardAI
|
||||
{
|
||||
get
|
||||
{
|
||||
return GuardAI.Magic | GuardAI.Melee | GuardAI.Smart | GuardAI.Curse | GuardAI.Bless;
|
||||
}
|
||||
}
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
using System;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionSorceress : BaseFactionGuard
|
||||
{
|
||||
[Constructable]
|
||||
public FactionSorceress()
|
||||
: base("the sorceress")
|
||||
{
|
||||
this.GenerateBody(true, false);
|
||||
|
||||
this.SetStr(126, 150);
|
||||
this.SetDex(61, 85);
|
||||
this.SetInt(126, 150);
|
||||
|
||||
this.SetDamageType(ResistanceType.Physical, 100);
|
||||
|
||||
this.SetResistance(ResistanceType.Physical, 30, 50);
|
||||
this.SetResistance(ResistanceType.Fire, 30, 50);
|
||||
this.SetResistance(ResistanceType.Cold, 30, 50);
|
||||
this.SetResistance(ResistanceType.Energy, 30, 50);
|
||||
this.SetResistance(ResistanceType.Poison, 30, 50);
|
||||
|
||||
this.VirtualArmor = 24;
|
||||
|
||||
this.SetSkill(SkillName.Macing, 100.0, 110.0);
|
||||
this.SetSkill(SkillName.Wrestling, 100.0, 110.0);
|
||||
this.SetSkill(SkillName.Tactics, 100.0, 110.0);
|
||||
this.SetSkill(SkillName.MagicResist, 100.0, 110.0);
|
||||
this.SetSkill(SkillName.Healing, 100.0, 110.0);
|
||||
this.SetSkill(SkillName.Anatomy, 100.0, 110.0);
|
||||
|
||||
this.SetSkill(SkillName.Magery, 100.0, 110.0);
|
||||
this.SetSkill(SkillName.EvalInt, 100.0, 110.0);
|
||||
this.SetSkill(SkillName.Meditation, 100.0, 110.0);
|
||||
|
||||
this.AddItem(this.Immovable(this.Rehued(new WizardsHat(), 1325)));
|
||||
this.AddItem(this.Immovable(this.Rehued(new Sandals(), 1325)));
|
||||
this.AddItem(this.Immovable(this.Rehued(new LeatherGorget(), 1325)));
|
||||
this.AddItem(this.Immovable(this.Rehued(new LeatherGloves(), 1325)));
|
||||
this.AddItem(this.Immovable(this.Rehued(new LeatherLegs(), 1325)));
|
||||
this.AddItem(this.Immovable(this.Rehued(new Skirt(), 1325)));
|
||||
this.AddItem(this.Immovable(this.Rehued(new FemaleLeatherChest(), 1325)));
|
||||
this.AddItem(this.Newbied(this.Rehued(new QuarterStaff(), 1310)));
|
||||
|
||||
this.PackItem(new Bandage(Utility.RandomMinMax(30, 40)));
|
||||
this.PackStrongPotions(6, 12);
|
||||
}
|
||||
|
||||
public FactionSorceress(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override GuardAI GuardAI
|
||||
{
|
||||
get
|
||||
{
|
||||
return GuardAI.Magic | GuardAI.Bless | GuardAI.Curse;
|
||||
}
|
||||
}
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
using System;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionWizard : BaseFactionGuard
|
||||
{
|
||||
[Constructable]
|
||||
public FactionWizard()
|
||||
: base("the wizard")
|
||||
{
|
||||
this.GenerateBody(false, false);
|
||||
|
||||
this.SetStr(151, 175);
|
||||
this.SetDex(61, 85);
|
||||
this.SetInt(151, 175);
|
||||
|
||||
this.SetDamageType(ResistanceType.Physical, 100);
|
||||
|
||||
this.SetResistance(ResistanceType.Physical, 40, 60);
|
||||
this.SetResistance(ResistanceType.Fire, 40, 60);
|
||||
this.SetResistance(ResistanceType.Cold, 40, 60);
|
||||
this.SetResistance(ResistanceType.Energy, 40, 60);
|
||||
this.SetResistance(ResistanceType.Poison, 40, 60);
|
||||
|
||||
this.VirtualArmor = 32;
|
||||
|
||||
this.SetSkill(SkillName.Macing, 110.0, 120.0);
|
||||
this.SetSkill(SkillName.Wrestling, 110.0, 120.0);
|
||||
this.SetSkill(SkillName.Tactics, 110.0, 120.0);
|
||||
this.SetSkill(SkillName.MagicResist, 110.0, 120.0);
|
||||
this.SetSkill(SkillName.Healing, 110.0, 120.0);
|
||||
this.SetSkill(SkillName.Anatomy, 110.0, 120.0);
|
||||
|
||||
this.SetSkill(SkillName.Magery, 110.0, 120.0);
|
||||
this.SetSkill(SkillName.EvalInt, 110.0, 120.0);
|
||||
this.SetSkill(SkillName.Meditation, 110.0, 120.0);
|
||||
|
||||
this.AddItem(this.Immovable(this.Rehued(new WizardsHat(), 1325)));
|
||||
this.AddItem(this.Immovable(this.Rehued(new Sandals(), 1325)));
|
||||
this.AddItem(this.Immovable(this.Rehued(new Robe(), 1310)));
|
||||
this.AddItem(this.Immovable(this.Rehued(new LeatherGloves(), 1325)));
|
||||
this.AddItem(this.Newbied(this.Rehued(new GnarledStaff(), 1310)));
|
||||
|
||||
this.PackItem(new Bandage(Utility.RandomMinMax(30, 40)));
|
||||
this.PackStrongPotions(6, 12);
|
||||
}
|
||||
|
||||
public FactionWizard(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override GuardAI GuardAI
|
||||
{
|
||||
get
|
||||
{
|
||||
return GuardAI.Magic | GuardAI.Smart | GuardAI.Bless | GuardAI.Curse;
|
||||
}
|
||||
}
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
134
Scripts/Services/Factions/Mobiles/Vendors/BaseFactionVendor.cs
Normal file
134
Scripts/Services/Factions/Mobiles/Vendors/BaseFactionVendor.cs
Normal file
@@ -0,0 +1,134 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public abstract class BaseFactionVendor : BaseVendor
|
||||
{
|
||||
private readonly List<SBInfo> m_SBInfos = new List<SBInfo>();
|
||||
private Town m_Town;
|
||||
private Faction m_Faction;
|
||||
public BaseFactionVendor(Town town, Faction faction, string title)
|
||||
: base(title)
|
||||
{
|
||||
this.Frozen = true;
|
||||
this.CantWalk = true;
|
||||
this.Female = false;
|
||||
this.BodyValue = 400;
|
||||
this.Name = NameList.RandomName("male");
|
||||
|
||||
this.RangeHome = 0;
|
||||
|
||||
this.m_Town = town;
|
||||
this.m_Faction = faction;
|
||||
this.Register();
|
||||
}
|
||||
|
||||
public BaseFactionVendor(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
|
||||
public Town Town
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Town;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.Unregister();
|
||||
this.m_Town = value;
|
||||
this.Register();
|
||||
}
|
||||
}
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)]
|
||||
public Faction Faction
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Faction;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.Unregister();
|
||||
this.m_Faction = value;
|
||||
this.Register();
|
||||
}
|
||||
}
|
||||
protected override List<SBInfo> SBInfos
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_SBInfos;
|
||||
}
|
||||
}
|
||||
public void Register()
|
||||
{
|
||||
if (this.m_Town != null && this.m_Faction != null)
|
||||
this.m_Town.RegisterVendor(this);
|
||||
}
|
||||
|
||||
public override bool OnMoveOver(Mobile m)
|
||||
{
|
||||
if (Core.ML)
|
||||
return true;
|
||||
|
||||
return base.OnMoveOver(m);
|
||||
}
|
||||
|
||||
public void Unregister()
|
||||
{
|
||||
if (this.m_Town != null)
|
||||
this.m_Town.UnregisterVendor(this);
|
||||
}
|
||||
|
||||
public override void InitSBInfo()
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
base.OnAfterDelete();
|
||||
|
||||
this.Unregister();
|
||||
}
|
||||
|
||||
public override bool CheckVendorAccess(Mobile from)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
|
||||
Town.WriteReference(writer, this.m_Town);
|
||||
Faction.WriteReference(writer, this.m_Faction);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
this.m_Town = Town.ReadReference(reader);
|
||||
this.m_Faction = Faction.ReadReference(reader);
|
||||
this.Register();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
this.Frozen = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionBoardVendor : BaseFactionVendor
|
||||
{
|
||||
public FactionBoardVendor(Town town, Faction faction)
|
||||
: base(town, faction, "the LumberMan")// NOTE: title inconsistant, as OSI
|
||||
{
|
||||
this.SetSkill(SkillName.Carpentry, 85.0, 100.0);
|
||||
this.SetSkill(SkillName.Lumberjacking, 60.0, 83.0);
|
||||
}
|
||||
|
||||
public FactionBoardVendor(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void InitSBInfo()
|
||||
{
|
||||
this.SBInfos.Add(new SBFactionBoard());
|
||||
}
|
||||
|
||||
public override void InitOutfit()
|
||||
{
|
||||
base.InitOutfit();
|
||||
|
||||
this.AddItem(new HalfApron());
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
|
||||
public class SBFactionBoard : SBInfo
|
||||
{
|
||||
private readonly List<GenericBuyInfo> m_BuyInfo = new InternalBuyInfo();
|
||||
private readonly IShopSellInfo m_SellInfo = new InternalSellInfo();
|
||||
public SBFactionBoard()
|
||||
{
|
||||
}
|
||||
|
||||
public override IShopSellInfo SellInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_SellInfo;
|
||||
}
|
||||
}
|
||||
public override List<GenericBuyInfo> BuyInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_BuyInfo;
|
||||
}
|
||||
}
|
||||
|
||||
public class InternalBuyInfo : List<GenericBuyInfo>
|
||||
{
|
||||
public InternalBuyInfo()
|
||||
{
|
||||
for (int i = 0; i < 5; ++i)
|
||||
this.Add(new GenericBuyInfo(typeof(Board), 3, 20, 0x1BD7, 0));
|
||||
}
|
||||
}
|
||||
|
||||
public class InternalSellInfo : GenericSellInfo
|
||||
{
|
||||
public InternalSellInfo()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionBottleVendor : BaseFactionVendor
|
||||
{
|
||||
public FactionBottleVendor(Town town, Faction faction)
|
||||
: base(town, faction, "the Bottle Seller")
|
||||
{
|
||||
this.SetSkill(SkillName.Alchemy, 85.0, 100.0);
|
||||
this.SetSkill(SkillName.TasteID, 65.0, 88.0);
|
||||
}
|
||||
|
||||
public FactionBottleVendor(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override VendorShoeType ShoeType
|
||||
{
|
||||
get
|
||||
{
|
||||
return Utility.RandomBool() ? VendorShoeType.Shoes : VendorShoeType.Sandals;
|
||||
}
|
||||
}
|
||||
public override void InitSBInfo()
|
||||
{
|
||||
this.SBInfos.Add(new SBFactionBottle());
|
||||
}
|
||||
|
||||
public override void InitOutfit()
|
||||
{
|
||||
base.InitOutfit();
|
||||
|
||||
this.AddItem(new Robe(Utility.RandomPinkHue()));
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
|
||||
public class SBFactionBottle : SBInfo
|
||||
{
|
||||
private readonly List<GenericBuyInfo> m_BuyInfo = new InternalBuyInfo();
|
||||
private readonly IShopSellInfo m_SellInfo = new InternalSellInfo();
|
||||
public SBFactionBottle()
|
||||
{
|
||||
}
|
||||
|
||||
public override IShopSellInfo SellInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_SellInfo;
|
||||
}
|
||||
}
|
||||
public override List<GenericBuyInfo> BuyInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_BuyInfo;
|
||||
}
|
||||
}
|
||||
|
||||
public class InternalBuyInfo : List<GenericBuyInfo>
|
||||
{
|
||||
public InternalBuyInfo()
|
||||
{
|
||||
for (int i = 0; i < 5; ++i)
|
||||
this.Add(new GenericBuyInfo(typeof(Bottle), 5, 20, 0xF0E, 0));
|
||||
}
|
||||
}
|
||||
|
||||
public class InternalSellInfo : GenericSellInfo
|
||||
{
|
||||
public InternalSellInfo()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionHorseVendor : BaseFactionVendor
|
||||
{
|
||||
public FactionHorseVendor(Town town, Faction faction)
|
||||
: base(town, faction, "the Horse Breeder")
|
||||
{
|
||||
this.SetSkill(SkillName.AnimalLore, 64.0, 100.0);
|
||||
this.SetSkill(SkillName.AnimalTaming, 90.0, 100.0);
|
||||
this.SetSkill(SkillName.Veterinary, 65.0, 88.0);
|
||||
}
|
||||
|
||||
public FactionHorseVendor(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override VendorShoeType ShoeType
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Female ? VendorShoeType.ThighBoots : VendorShoeType.Boots;
|
||||
}
|
||||
}
|
||||
public override void InitSBInfo()
|
||||
{
|
||||
}
|
||||
|
||||
public override int GetShoeHue()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public override void InitOutfit()
|
||||
{
|
||||
base.InitOutfit();
|
||||
|
||||
this.AddItem(Utility.RandomBool() ? (Item)new QuarterStaff() : (Item)new ShepherdsCrook());
|
||||
}
|
||||
|
||||
public override void VendorBuy(Mobile from)
|
||||
{
|
||||
if (this.Faction == null || Faction.Find(from, true) != this.Faction)
|
||||
this.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1042201, from.NetState); // You are not in my faction, I cannot sell you a horse!
|
||||
else if (FactionGump.Exists(from))
|
||||
from.SendLocalizedMessage(1042160); // You already have a faction menu open.
|
||||
else if (from is PlayerMobile)
|
||||
from.SendGump(new HorseBreederGump((PlayerMobile)from, this.Faction));
|
||||
}
|
||||
|
||||
public override void VendorSell(Mobile from)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool OnBuyItems(Mobile buyer, List<BuyItemResponse> list)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool OnSellItems(Mobile seller, List<SellItemResponse> list)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionOreVendor : BaseFactionVendor
|
||||
{
|
||||
public FactionOreVendor(Town town, Faction faction)
|
||||
: base(town, faction, "the Ore Man")
|
||||
{
|
||||
// NOTE: Skills verified
|
||||
this.SetSkill(SkillName.Carpentry, 85.0, 100.0);
|
||||
this.SetSkill(SkillName.Lumberjacking, 60.0, 83.0);
|
||||
}
|
||||
|
||||
public FactionOreVendor(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void InitSBInfo()
|
||||
{
|
||||
this.SBInfos.Add(new SBFactionOre());
|
||||
}
|
||||
|
||||
public override void InitOutfit()
|
||||
{
|
||||
base.InitOutfit();
|
||||
|
||||
this.AddItem(new HalfApron());
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
|
||||
public class SBFactionOre : SBInfo
|
||||
{
|
||||
private static readonly object[] m_FixedSizeArgs = { true };
|
||||
private readonly List<GenericBuyInfo> m_BuyInfo = new InternalBuyInfo();
|
||||
private readonly IShopSellInfo m_SellInfo = new InternalSellInfo();
|
||||
public SBFactionOre()
|
||||
{
|
||||
}
|
||||
|
||||
public override IShopSellInfo SellInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_SellInfo;
|
||||
}
|
||||
}
|
||||
public override List<GenericBuyInfo> BuyInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_BuyInfo;
|
||||
}
|
||||
}
|
||||
|
||||
public class InternalBuyInfo : List<GenericBuyInfo>
|
||||
{
|
||||
public InternalBuyInfo()
|
||||
{
|
||||
for (int i = 0; i < 5; ++i)
|
||||
this.Add(new GenericBuyInfo(typeof(IronOre), 16, 20, 0x19B8, 0, m_FixedSizeArgs));
|
||||
}
|
||||
}
|
||||
|
||||
public class InternalSellInfo : GenericSellInfo
|
||||
{
|
||||
public InternalSellInfo()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionReagentVendor : BaseFactionVendor
|
||||
{
|
||||
public FactionReagentVendor(Town town, Faction faction)
|
||||
: base(town, faction, "the Reagent Man")
|
||||
{
|
||||
this.SetSkill(SkillName.EvalInt, 65.0, 88.0);
|
||||
this.SetSkill(SkillName.Inscribe, 60.0, 83.0);
|
||||
this.SetSkill(SkillName.Magery, 64.0, 100.0);
|
||||
this.SetSkill(SkillName.Meditation, 60.0, 83.0);
|
||||
this.SetSkill(SkillName.MagicResist, 65.0, 88.0);
|
||||
this.SetSkill(SkillName.Wrestling, 36.0, 68.0);
|
||||
}
|
||||
|
||||
public FactionReagentVendor(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override VendorShoeType ShoeType
|
||||
{
|
||||
get
|
||||
{
|
||||
return Utility.RandomBool() ? VendorShoeType.Shoes : VendorShoeType.Sandals;
|
||||
}
|
||||
}
|
||||
public override void InitSBInfo()
|
||||
{
|
||||
this.SBInfos.Add(new SBFactionReagent());
|
||||
}
|
||||
|
||||
public override void InitOutfit()
|
||||
{
|
||||
base.InitOutfit();
|
||||
|
||||
this.AddItem(new Robe(Utility.RandomBlueHue()));
|
||||
this.AddItem(new GnarledStaff());
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
|
||||
public class SBFactionReagent : SBInfo
|
||||
{
|
||||
private readonly List<GenericBuyInfo> m_BuyInfo = new InternalBuyInfo();
|
||||
private readonly IShopSellInfo m_SellInfo = new InternalSellInfo();
|
||||
public SBFactionReagent()
|
||||
{
|
||||
}
|
||||
|
||||
public override IShopSellInfo SellInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_SellInfo;
|
||||
}
|
||||
}
|
||||
public override List<GenericBuyInfo> BuyInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_BuyInfo;
|
||||
}
|
||||
}
|
||||
|
||||
public class InternalBuyInfo : List<GenericBuyInfo>
|
||||
{
|
||||
public InternalBuyInfo()
|
||||
{
|
||||
for (int i = 0; i < 2; ++i)
|
||||
{
|
||||
this.Add(new GenericBuyInfo(typeof(BlackPearl), 5, 20, 0xF7A, 0));
|
||||
this.Add(new GenericBuyInfo(typeof(Bloodmoss), 5, 20, 0xF7B, 0));
|
||||
this.Add(new GenericBuyInfo(typeof(MandrakeRoot), 3, 20, 0xF86, 0));
|
||||
this.Add(new GenericBuyInfo(typeof(Garlic), 3, 20, 0xF84, 0));
|
||||
this.Add(new GenericBuyInfo(typeof(Ginseng), 3, 20, 0xF85, 0));
|
||||
this.Add(new GenericBuyInfo(typeof(Nightshade), 3, 20, 0xF88, 0));
|
||||
this.Add(new GenericBuyInfo(typeof(SpidersSilk), 3, 20, 0xF8D, 0));
|
||||
this.Add(new GenericBuyInfo(typeof(SulfurousAsh), 3, 20, 0xF8C, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class InternalSellInfo : GenericSellInfo
|
||||
{
|
||||
public InternalSellInfo()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user