#W# Source and Scripts added. Added Scripts/Settings.cs to expose some basic tweak able settings.
This commit is contained in:
parent
b51c58f514
commit
3045c83799
3512 changed files with 627673 additions and 0 deletions
564
Scripts/Engines/Factions/Core/Election.cs
Normal file
564
Scripts/Engines/Factions/Core/Election.cs
Normal file
|
|
@ -0,0 +1,564 @@
|
|||
using System;
|
||||
using System.Net;
|
||||
using System.Collections;
|
||||
using Server;
|
||||
using Server.Mobiles;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
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 List<Candidate> m_Candidates;
|
||||
|
||||
private ElectionState m_State;
|
||||
private DateTime m_LastStateTime;
|
||||
|
||||
public Faction Faction{ get{ return m_Faction; } }
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
private Timer m_Timer;
|
||||
|
||||
public void StartTimer()
|
||||
{
|
||||
m_Timer = Timer.DelayCall( TimeSpan.FromMinutes( 1.0 ), TimeSpan.FromMinutes( 1.0 ), new TimerCallback( Slice ) );
|
||||
}
|
||||
|
||||
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 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.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 Mobile m_From;
|
||||
private Mobile m_Candidate;
|
||||
|
||||
private IPAddress m_Address;
|
||||
private DateTime m_Time;
|
||||
|
||||
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 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 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 Mobile m_Mobile;
|
||||
private List<Voter> m_Voters;
|
||||
|
||||
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 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 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 );
|
||||
}
|
||||
}
|
||||
|
||||
public enum ElectionState
|
||||
{
|
||||
Pending,
|
||||
Campaign,
|
||||
Election
|
||||
}
|
||||
}
|
||||
1437
Scripts/Engines/Factions/Core/Faction.cs
Normal file
1437
Scripts/Engines/Factions/Core/Faction.cs
Normal file
File diff suppressed because it is too large
Load diff
146
Scripts/Engines/Factions/Core/FactionItem.cs
Normal file
146
Scripts/Engines/Factions/Core/FactionItem.cs
Normal file
|
|
@ -0,0 +1,146 @@
|
|||
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 Item m_Item;
|
||||
private Faction m_Faction;
|
||||
private DateTime m_Expiration;
|
||||
|
||||
public Item Item{ get{ return m_Item; } }
|
||||
public Faction Faction{ get{ return m_Faction; } }
|
||||
public DateTime Expiration{ get{ return m_Expiration; } }
|
||||
|
||||
public bool HasExpired
|
||||
{
|
||||
get
|
||||
{
|
||||
if ( m_Item == null || m_Item.Deleted )
|
||||
return true;
|
||||
|
||||
return ( m_Expiration != DateTime.MinValue && DateTime.UtcNow >= m_Expiration );
|
||||
}
|
||||
}
|
||||
|
||||
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 FactionItem( Item item, Faction faction )
|
||||
{
|
||||
m_Item = item;
|
||||
m_Faction = faction;
|
||||
}
|
||||
|
||||
public FactionItem( GenericReader reader, Faction faction )
|
||||
{
|
||||
int version = reader.ReadEncodedInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
m_Item = reader.ReadItem();
|
||||
m_Expiration = reader.ReadDateTime();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_Faction = faction;
|
||||
}
|
||||
|
||||
public void Serialize( GenericWriter writer )
|
||||
{
|
||||
writer.WriteEncodedInt( (int) 0 );
|
||||
|
||||
writer.Write( (Item) m_Item );
|
||||
writer.Write( (DateTime) 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 )
|
||||
{
|
||||
if ( !(item is IFactionItem) )
|
||||
return item;
|
||||
|
||||
FactionItem state = Find( item );
|
||||
|
||||
if ( state == null )
|
||||
{
|
||||
state = new FactionItem( item, faction );
|
||||
state.Attach();
|
||||
}
|
||||
|
||||
if ( expire )
|
||||
state.StartExpiration();
|
||||
|
||||
item.Hue = hue;
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
312
Scripts/Engines/Factions/Core/FactionState.cs
Normal file
312
Scripts/Engines/Factions/Core/FactionState.cs
Normal file
|
|
@ -0,0 +1,312 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionState
|
||||
{
|
||||
private Faction m_Faction;
|
||||
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;
|
||||
|
||||
private const int BroadcastsPerPeriod = 2;
|
||||
private static readonly TimeSpan BroadcastPeriod = TimeSpan.FromHours( 1.0 );
|
||||
|
||||
private DateTime[] m_LastBroadcasts = new DateTime[BroadcastsPerPeriod];
|
||||
|
||||
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 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 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 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 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:
|
||||
{
|
||||
m_Election = new Election( reader );
|
||||
|
||||
goto case 0;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
m_Faction = Faction.ReadReference( reader );
|
||||
|
||||
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 )
|
||||
m_Members.Add( pl );
|
||||
}
|
||||
|
||||
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 );
|
||||
|
||||
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() )
|
||||
m_FactionTraps.Add( trap );
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( version < 1 )
|
||||
m_Election = new Election( m_Faction );
|
||||
}
|
||||
|
||||
public void Serialize( GenericWriter writer )
|
||||
{
|
||||
writer.WriteEncodedInt( (int) 5 ); // 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] );
|
||||
}
|
||||
}
|
||||
}
|
||||
80
Scripts/Engines/Factions/Core/Generator.cs
Normal file
80
Scripts/Engines/Factions/Core/Generator.cs
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
using System;
|
||||
using Server.Commands;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class Generator
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
CommandSystem.Register( "GenerateFactions", AccessLevel.Administrator, new CommandEventHandler( GenerateFactions_OnCommand ) );
|
||||
}
|
||||
|
||||
public static void GenerateFactions_OnCommand( CommandEventArgs e )
|
||||
{
|
||||
new FactionPersistance();
|
||||
|
||||
List<Faction> factions = Faction.Factions;
|
||||
|
||||
foreach ( Faction faction in factions )
|
||||
Generate( faction );
|
||||
|
||||
List<Town> towns = Town.Towns;
|
||||
|
||||
foreach ( Town town in towns )
|
||||
Generate( town );
|
||||
}
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
if ( !CheckExistance( def.TownStone, facet, typeof( TownStone ) ) )
|
||||
new TownStone( town ).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 ) ) )
|
||||
new JoinStone( faction ).MoveToWorld( stronghold.JoinStone, facet );
|
||||
|
||||
if ( !CheckExistance( stronghold.FactionStone, facet, typeof( FactionStone ) ) )
|
||||
new FactionStone( faction ).MoveToWorld( stronghold.FactionStone, facet );
|
||||
|
||||
for ( int i = 0; i < stronghold.Monoliths.Length; ++i )
|
||||
{
|
||||
Point3D monolith = stronghold.Monoliths[i];
|
||||
|
||||
if ( !CheckExistance( monolith, facet, typeof( StrongholdMonolith ) ) )
|
||||
new StrongholdMonolith( towns[i], faction ).MoveToWorld( monolith, 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
27
Scripts/Engines/Factions/Core/GuardList.cs
Normal file
27
Scripts/Engines/Factions/Core/GuardList.cs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
using System;
|
||||
using Server;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class GuardList
|
||||
{
|
||||
private GuardDefinition m_Definition;
|
||||
private List<BaseFactionGuard> m_Guards;
|
||||
|
||||
public GuardDefinition Definition{ get{ return m_Definition; } }
|
||||
public List<BaseFactionGuard> Guards{ get{ return m_Guards; } }
|
||||
|
||||
public BaseFactionGuard Construct()
|
||||
{
|
||||
try{ return Activator.CreateInstance( m_Definition.Type ) as BaseFactionGuard; }
|
||||
catch{ return null; }
|
||||
}
|
||||
|
||||
public GuardList( GuardDefinition definition )
|
||||
{
|
||||
m_Definition = definition;
|
||||
m_Guards = new List<BaseFactionGuard>();
|
||||
}
|
||||
}
|
||||
}
|
||||
159
Scripts/Engines/Factions/Core/Keywords.cs
Normal file
159
Scripts/Engines/Factions/Core/Keywords.cs
Normal file
|
|
@ -0,0 +1,159 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using Server;
|
||||
using Server.Network;
|
||||
using Server.Factions;
|
||||
using Server.Mobiles;
|
||||
|
||||
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.AccessLevel == AccessLevel.Player && !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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
87
Scripts/Engines/Factions/Core/MerchantTitles.cs
Normal file
87
Scripts/Engines/Factions/Core/MerchantTitles.cs
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public enum MerchantTitle
|
||||
{
|
||||
None,
|
||||
Scribe,
|
||||
Carpenter,
|
||||
Blacksmith,
|
||||
Bowyer,
|
||||
Tialor
|
||||
}
|
||||
|
||||
public class MerchantTitleInfo
|
||||
{
|
||||
private SkillName m_Skill;
|
||||
private double m_Requirement;
|
||||
private TextDefinition m_Title;
|
||||
private TextDefinition m_Label;
|
||||
private TextDefinition m_Assigned;
|
||||
|
||||
public SkillName Skill{ get{ return m_Skill; } }
|
||||
public double Requirement{ get{ return m_Requirement; } }
|
||||
public TextDefinition Title{ get{ return m_Title; } }
|
||||
public TextDefinition Label{ get{ return m_Label; } }
|
||||
public TextDefinition Assigned{ get{ return m_Assigned; } }
|
||||
|
||||
public MerchantTitleInfo( SkillName skill, double requirement, TextDefinition title, TextDefinition label, TextDefinition assigned )
|
||||
{
|
||||
m_Skill = skill;
|
||||
m_Requirement = requirement;
|
||||
m_Title = title;
|
||||
m_Label = label;
|
||||
m_Assigned = assigned;
|
||||
}
|
||||
}
|
||||
|
||||
public class MerchantTitles
|
||||
{
|
||||
private static 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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
94
Scripts/Engines/Factions/Core/Persistance.cs
Normal file
94
Scripts/Engines/Factions/Core/Persistance.cs
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionPersistance : Item
|
||||
{
|
||||
private static FactionPersistance m_Instance;
|
||||
|
||||
public static FactionPersistance Instance{ get{ return m_Instance; } }
|
||||
|
||||
public override string DefaultName
|
||||
{
|
||||
get { return "Faction Persistance - Internal"; }
|
||||
}
|
||||
|
||||
public FactionPersistance() : base( 1 )
|
||||
{
|
||||
Movable = false;
|
||||
|
||||
if ( m_Instance == null || m_Instance.Deleted )
|
||||
m_Instance = this;
|
||||
else
|
||||
base.Delete();
|
||||
}
|
||||
|
||||
private enum PersistedType
|
||||
{
|
||||
Terminator,
|
||||
Faction,
|
||||
Town
|
||||
}
|
||||
|
||||
public FactionPersistance( Serial serial ) : base( serial )
|
||||
{
|
||||
m_Instance = this;
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.Write( (int) 0 ); // 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 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Delete()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
255
Scripts/Engines/Factions/Core/PlayerState.cs
Normal file
255
Scripts/Engines/Factions/Core/PlayerState.cs
Normal file
|
|
@ -0,0 +1,255 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Mobiles;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class PlayerState : IComparable
|
||||
{
|
||||
private Mobile m_Mobile;
|
||||
private Faction m_Faction;
|
||||
private 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;
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool m_InvalidateRank = true;
|
||||
private int m_RankIndex = -1;
|
||||
|
||||
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 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();
|
||||
pm.InvalidateMyRunUO();
|
||||
}
|
||||
}
|
||||
|
||||
public void Attach()
|
||||
{
|
||||
if ( m_Mobile is PlayerMobile )
|
||||
((PlayerMobile)m_Mobile).FactionPlayerState = this;
|
||||
}
|
||||
|
||||
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 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 static PlayerState Find( Mobile mob )
|
||||
{
|
||||
if ( mob is PlayerMobile )
|
||||
return ((PlayerMobile)mob).FactionPlayerState;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public int CompareTo( object obj )
|
||||
{
|
||||
return ((PlayerState)obj).m_KillPoints - m_KillPoints;
|
||||
}
|
||||
}
|
||||
}
|
||||
78
Scripts/Engines/Factions/Core/Reflector.cs
Normal file
78
Scripts/Engines/Factions/Core/Reflector.cs
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
using System;
|
||||
using System.Reflection;
|
||||
using System.Collections;
|
||||
using Server;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class Reflector
|
||||
{
|
||||
private static List<Town> m_Towns;
|
||||
|
||||
public static List<Town> Towns
|
||||
{
|
||||
get
|
||||
{
|
||||
if ( m_Towns == null )
|
||||
ProcessTypes();
|
||||
|
||||
return m_Towns;
|
||||
}
|
||||
}
|
||||
|
||||
private static List<Faction> m_Factions;
|
||||
|
||||
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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
23
Scripts/Engines/Factions/Core/SilverGivenEntry.cs
Normal file
23
Scripts/Engines/Factions/Core/SilverGivenEntry.cs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class SilverGivenEntry
|
||||
{
|
||||
public static readonly TimeSpan ExpirePeriod = TimeSpan.FromHours( 3.0 );
|
||||
|
||||
private Mobile m_GivenTo;
|
||||
private DateTime m_TimeOfGift;
|
||||
|
||||
public Mobile GivenTo{ get{ return m_GivenTo; } }
|
||||
public DateTime TimeOfGift{ get{ return m_TimeOfGift; } }
|
||||
|
||||
public bool IsExpired{ get{ return ( m_TimeOfGift + ExpirePeriod ) < DateTime.UtcNow; } }
|
||||
|
||||
public SilverGivenEntry( Mobile givenTo )
|
||||
{
|
||||
m_GivenTo = givenTo;
|
||||
m_TimeOfGift = DateTime.UtcNow;
|
||||
}
|
||||
}
|
||||
}
|
||||
51
Scripts/Engines/Factions/Core/StrongholdRegion.cs
Normal file
51
Scripts/Engines/Factions/Core/StrongholdRegion.cs
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using Server;
|
||||
using Server.Mobiles;
|
||||
using Server.Regions;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class StrongholdRegion : BaseRegion
|
||||
{
|
||||
private Faction m_Faction;
|
||||
|
||||
public Faction Faction
|
||||
{
|
||||
get{ return m_Faction; }
|
||||
set{ m_Faction = value; }
|
||||
}
|
||||
|
||||
public StrongholdRegion( Faction faction ) : base( faction.Definition.FriendlyName, Faction.Facet, Region.DefaultPriority, faction.Definition.Stronghold.Area )
|
||||
{
|
||||
m_Faction = faction;
|
||||
|
||||
Register();
|
||||
}
|
||||
|
||||
public override bool OnMoveInto( Mobile m, Direction d, Point3D newLocation, Point3D oldLocation )
|
||||
{
|
||||
if ( !base.OnMoveInto( m, d, newLocation, oldLocation ) )
|
||||
return false;
|
||||
|
||||
if ( m.AccessLevel >= AccessLevel.Counselor || Contains( oldLocation ) )
|
||||
return true;
|
||||
|
||||
if ( m is PlayerMobile ) {
|
||||
PlayerMobile pm = (PlayerMobile)m;
|
||||
|
||||
if ( pm.DuelContext != null ) {
|
||||
m.SendMessage( "You may not enter this area while participating in a duel or a tournament." );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return ( Faction.Find( m, true, true ) != null );
|
||||
}
|
||||
|
||||
public override bool AllowHousing( Mobile from, Point3D p )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
554
Scripts/Engines/Factions/Core/Town.cs
Normal file
554
Scripts/Engines/Factions/Core/Town.cs
Normal file
|
|
@ -0,0 +1,554 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using Server;
|
||||
using Server.Targeting;
|
||||
using Server.Mobiles;
|
||||
using Server.Commands;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
[CustomEnum( new string[]{ "Britain", "Magincia", "Minoc", "Moonglow", "Skara Brae", "Trinsic", "Vesper", "Yew" } )]
|
||||
public abstract class Town : IComparable
|
||||
{
|
||||
private TownDefinition m_Definition;
|
||||
private TownState m_State;
|
||||
|
||||
public TownDefinition Definition
|
||||
{
|
||||
get{ return m_Definition; }
|
||||
set{ m_Definition = value; }
|
||||
}
|
||||
|
||||
public TownState State
|
||||
{
|
||||
get{ return m_State; }
|
||||
set{ m_State = value; ConstructGuardLists(); }
|
||||
}
|
||||
|
||||
public int Silver
|
||||
{
|
||||
get{ return m_State.Silver; }
|
||||
set{ m_State.Silver = value; }
|
||||
}
|
||||
|
||||
public Faction Owner
|
||||
{
|
||||
get{ return m_State.Owner; }
|
||||
set{ Capture( value ); }
|
||||
}
|
||||
|
||||
public Mobile Sheriff
|
||||
{
|
||||
get{ return m_State.Sheriff; }
|
||||
set{ m_State.Sheriff = value; }
|
||||
}
|
||||
|
||||
public Mobile Finance
|
||||
{
|
||||
get{ return m_State.Finance; }
|
||||
set{ m_State.Finance = value; }
|
||||
}
|
||||
|
||||
public int Tax
|
||||
{
|
||||
get{ return m_State.Tax; }
|
||||
set{ m_State.Tax = value; }
|
||||
}
|
||||
|
||||
public DateTime LastTaxChange
|
||||
{
|
||||
get{ return m_State.LastTaxChange; }
|
||||
set{ m_State.LastTaxChange = value; }
|
||||
}
|
||||
|
||||
public static readonly TimeSpan TaxChangePeriod = TimeSpan.FromHours( 12.0 );
|
||||
public static readonly TimeSpan IncomePeriod = TimeSpan.FromDays( 1.0 );
|
||||
|
||||
public bool TaxChangeReady
|
||||
{
|
||||
get{ return ( m_State.LastTaxChange + TaxChangePeriod ) < DateTime.UtcNow; }
|
||||
}
|
||||
|
||||
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 int FinanceUpkeep
|
||||
{
|
||||
get
|
||||
{
|
||||
List<VendorList> vendorLists = 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 = 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 + m_State.Tax)) / 100; }
|
||||
}
|
||||
|
||||
public int NetCashFlow
|
||||
{
|
||||
get{ return DailyIncome - FinanceUpkeep - 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 m_State.LastIncome; }
|
||||
set{ m_State.LastIncome = value; }
|
||||
}
|
||||
|
||||
public void BeginOrderFiring( Mobile from )
|
||||
{
|
||||
bool isFinance = IsFinance( from );
|
||||
bool isSheriff = 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 = IsFinance( from );
|
||||
bool isSheriff = 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 );
|
||||
}
|
||||
}
|
||||
|
||||
private Timer m_IncomeTimer;
|
||||
|
||||
public void StartIncomeTimer()
|
||||
{
|
||||
if ( m_IncomeTimer != null )
|
||||
m_IncomeTimer.Stop();
|
||||
|
||||
m_IncomeTimer = Timer.DelayCall( TimeSpan.FromMinutes( 1.0 ), TimeSpan.FromMinutes( 1.0 ), new TimerCallback( CheckIncome ) );
|
||||
}
|
||||
|
||||
public void StopIncomeTimer()
|
||||
{
|
||||
if ( m_IncomeTimer != null )
|
||||
m_IncomeTimer.Stop();
|
||||
|
||||
m_IncomeTimer = null;
|
||||
}
|
||||
|
||||
public void CheckIncome()
|
||||
{
|
||||
if ( (LastIncome + IncomePeriod) > DateTime.UtcNow || Owner == null )
|
||||
return;
|
||||
|
||||
ProcessIncome();
|
||||
}
|
||||
|
||||
public void ProcessIncome()
|
||||
{
|
||||
LastIncome = DateTime.UtcNow;
|
||||
|
||||
int flow = NetCashFlow;
|
||||
|
||||
if ( (Silver + flow) < 0 )
|
||||
{
|
||||
ArrayList toDelete = BuildFinanceList();
|
||||
|
||||
while ( (Silver + flow) < 0 && toDelete.Count > 0 )
|
||||
{
|
||||
int index = Utility.Random( toDelete.Count );
|
||||
Mobile mob = (Mobile)toDelete[index];
|
||||
|
||||
mob.Delete();
|
||||
|
||||
toDelete.RemoveAt( index );
|
||||
flow = NetCashFlow;
|
||||
}
|
||||
}
|
||||
|
||||
Silver += flow;
|
||||
}
|
||||
|
||||
public ArrayList BuildFinanceList()
|
||||
{
|
||||
ArrayList list = new ArrayList();
|
||||
|
||||
List<VendorList> vendorLists = VendorLists;
|
||||
|
||||
for ( int i = 0; i < vendorLists.Count; ++i )
|
||||
list.AddRange( vendorLists[i].Vendors );
|
||||
|
||||
List<GuardList> guardLists = GuardLists;
|
||||
|
||||
for ( int i = 0; i < guardLists.Count; ++i )
|
||||
list.AddRange( guardLists[i].Guards );
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
private List<VendorList> m_VendorLists;
|
||||
private List<GuardList> m_GuardLists;
|
||||
|
||||
public List<VendorList> VendorLists
|
||||
{
|
||||
get{ return m_VendorLists; }
|
||||
set{ m_VendorLists = value; }
|
||||
}
|
||||
|
||||
public List<GuardList> GuardLists
|
||||
{
|
||||
get{ return m_GuardLists; }
|
||||
set{ m_GuardLists = value; }
|
||||
}
|
||||
|
||||
public void ConstructGuardLists()
|
||||
{
|
||||
GuardDefinition[] defs = ( Owner == null ? new GuardDefinition[0] : Owner.Definition.Guards );
|
||||
|
||||
m_GuardLists = new List<GuardList>();
|
||||
|
||||
for ( int i = 0; i < defs.Length; ++i )
|
||||
m_GuardLists.Add( new GuardList( defs[i] ) );
|
||||
}
|
||||
|
||||
public GuardList FindGuardList( Type type )
|
||||
{
|
||||
List<GuardList> guardLists = 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;
|
||||
|
||||
m_VendorLists = new List<VendorList>();
|
||||
|
||||
for ( int i = 0; i < defs.Length; ++i )
|
||||
m_VendorLists.Add( new VendorList( defs[i] ) );
|
||||
}
|
||||
|
||||
public VendorList FindVendorList( Type type )
|
||||
{
|
||||
List<VendorList> vendorLists = 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 = 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 = 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 = 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 = FindVendorList( vendor.GetType() );
|
||||
|
||||
if ( vendorList == null )
|
||||
return false;
|
||||
|
||||
if ( !vendorList.Vendors.Contains( vendor ) )
|
||||
return false;
|
||||
|
||||
vendorList.Vendors.Remove( vendor );
|
||||
return true;
|
||||
}
|
||||
|
||||
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 Town()
|
||||
{
|
||||
m_State = new TownState( this );
|
||||
ConstructVendorLists();
|
||||
ConstructGuardLists();
|
||||
StartIncomeTimer();
|
||||
}
|
||||
|
||||
public bool IsSheriff( Mobile mob )
|
||||
{
|
||||
if ( mob == null || mob.Deleted )
|
||||
return false;
|
||||
|
||||
return ( mob.AccessLevel >= AccessLevel.GameMaster || mob == Sheriff );
|
||||
}
|
||||
|
||||
public bool IsFinance( Mobile mob )
|
||||
{
|
||||
if ( mob == null || mob.Deleted )
|
||||
return false;
|
||||
|
||||
return ( mob.AccessLevel >= AccessLevel.GameMaster || mob == Finance );
|
||||
}
|
||||
|
||||
public static List<Town> Towns { get { return Reflector.Towns; } }
|
||||
|
||||
public const int SilverCaptureBonus = 10000;
|
||||
|
||||
public void Capture( Faction f )
|
||||
{
|
||||
if ( m_State.Owner == f )
|
||||
return;
|
||||
|
||||
if ( m_State.Owner == null ) // going from unowned to owned
|
||||
{
|
||||
LastIncome = DateTime.UtcNow;
|
||||
f.Silver += SilverCaptureBonus;
|
||||
}
|
||||
else if ( f == null ) // going from owned to unowned
|
||||
{
|
||||
LastIncome = DateTime.MinValue;
|
||||
}
|
||||
else // otherwise changing hands, income timer doesn't change
|
||||
{
|
||||
f.Silver += SilverCaptureBonus;
|
||||
}
|
||||
|
||||
m_State.Owner = f;
|
||||
|
||||
Sheriff = null;
|
||||
Finance = null;
|
||||
|
||||
TownMonolith monolith = this.Monolith;
|
||||
|
||||
if ( monolith != null )
|
||||
monolith.Faction = f;
|
||||
|
||||
List<VendorList> vendorLists = 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 = 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();
|
||||
}
|
||||
|
||||
ConstructGuardLists();
|
||||
}
|
||||
|
||||
public int CompareTo( object obj )
|
||||
{
|
||||
return m_Definition.Sort - ((Town)obj).m_Definition.Sort;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return m_Definition.FriendlyName;
|
||||
}
|
||||
|
||||
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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
168
Scripts/Engines/Factions/Core/TownState.cs
Normal file
168
Scripts/Engines/Factions/Core/TownState.cs
Normal file
|
|
@ -0,0 +1,168 @@
|
|||
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 Town Town
|
||||
{
|
||||
get{ return m_Town; }
|
||||
set{ m_Town = value; }
|
||||
}
|
||||
|
||||
public Faction Owner
|
||||
{
|
||||
get{ return m_Owner; }
|
||||
set{ m_Owner = value; }
|
||||
}
|
||||
|
||||
public Mobile Sheriff
|
||||
{
|
||||
get{ return m_Sheriff; }
|
||||
set
|
||||
{
|
||||
if ( m_Sheriff != null )
|
||||
{
|
||||
PlayerState pl = PlayerState.Find( m_Sheriff );
|
||||
|
||||
if ( pl != null )
|
||||
pl.Sheriff = null;
|
||||
}
|
||||
|
||||
m_Sheriff = value;
|
||||
|
||||
if ( m_Sheriff != null )
|
||||
{
|
||||
PlayerState pl = PlayerState.Find( m_Sheriff );
|
||||
|
||||
if ( pl != null )
|
||||
pl.Sheriff = m_Town;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Mobile Finance
|
||||
{
|
||||
get{ return m_Finance; }
|
||||
set
|
||||
{
|
||||
if ( m_Finance != null )
|
||||
{
|
||||
PlayerState pl = PlayerState.Find( m_Finance );
|
||||
|
||||
if ( pl != null )
|
||||
pl.Finance = null;
|
||||
}
|
||||
|
||||
m_Finance = value;
|
||||
|
||||
if ( m_Finance != null )
|
||||
{
|
||||
PlayerState pl = PlayerState.Find( m_Finance );
|
||||
|
||||
if ( pl != null )
|
||||
pl.Finance = m_Town;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int Silver
|
||||
{
|
||||
get{ return m_Silver; }
|
||||
set{ m_Silver = value; }
|
||||
}
|
||||
|
||||
public int Tax
|
||||
{
|
||||
get{ return m_Tax; }
|
||||
set{ m_Tax = value; }
|
||||
}
|
||||
|
||||
public DateTime LastTaxChange
|
||||
{
|
||||
get{ return m_LastTaxChange; }
|
||||
set{ m_LastTaxChange = value; }
|
||||
}
|
||||
|
||||
public DateTime LastIncome
|
||||
{
|
||||
get{ return m_LastIncome; }
|
||||
set{ m_LastIncome = value; }
|
||||
}
|
||||
|
||||
public TownState( Town town )
|
||||
{
|
||||
m_Town = town;
|
||||
}
|
||||
|
||||
public TownState( GenericReader reader )
|
||||
{
|
||||
int version = reader.ReadEncodedInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 3:
|
||||
{
|
||||
m_LastIncome = reader.ReadDateTime();
|
||||
|
||||
goto case 2;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
m_Tax = reader.ReadEncodedInt();
|
||||
m_LastTaxChange = reader.ReadDateTime();
|
||||
|
||||
goto case 1;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
m_Silver = reader.ReadEncodedInt();
|
||||
|
||||
goto case 0;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
m_Town = Town.ReadReference( reader );
|
||||
m_Owner = Faction.ReadReference( reader );
|
||||
|
||||
m_Sheriff = reader.ReadMobile();
|
||||
m_Finance = reader.ReadMobile();
|
||||
|
||||
m_Town.State = this;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Serialize( GenericWriter writer )
|
||||
{
|
||||
writer.WriteEncodedInt( (int) 3 ); // version
|
||||
|
||||
writer.Write( (DateTime) m_LastIncome );
|
||||
|
||||
writer.WriteEncodedInt( (int) m_Tax );
|
||||
writer.Write( (DateTime) m_LastTaxChange );
|
||||
|
||||
writer.WriteEncodedInt( (int) m_Silver );
|
||||
|
||||
Town.WriteReference( writer, m_Town );
|
||||
Faction.WriteReference( writer, m_Owner );
|
||||
|
||||
writer.Write( (Mobile) m_Sheriff );
|
||||
writer.Write( (Mobile) m_Finance );
|
||||
}
|
||||
}
|
||||
}
|
||||
27
Scripts/Engines/Factions/Core/VendorList.cs
Normal file
27
Scripts/Engines/Factions/Core/VendorList.cs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
using System;
|
||||
using Server;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class VendorList
|
||||
{
|
||||
private VendorDefinition m_Definition;
|
||||
private List<BaseFactionVendor> m_Vendors;
|
||||
|
||||
public VendorDefinition Definition{ get{ return m_Definition; } }
|
||||
public List<BaseFactionVendor> Vendors { get { return m_Vendors; } }
|
||||
|
||||
public BaseFactionVendor Construct( Town town, Faction faction )
|
||||
{
|
||||
try{ return Activator.CreateInstance( m_Definition.Type, new object[]{ town, faction } ) as BaseFactionVendor; }
|
||||
catch{ return null; }
|
||||
}
|
||||
|
||||
public VendorList( VendorDefinition definition )
|
||||
{
|
||||
m_Definition = definition;
|
||||
m_Vendors = new List<BaseFactionVendor>();
|
||||
}
|
||||
}
|
||||
}
|
||||
100
Scripts/Engines/Factions/Definitions/FactionDefinition.cs
Normal file
100
Scripts/Engines/Factions/Definitions/FactionDefinition.cs
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionDefinition
|
||||
{
|
||||
private int m_Sort;
|
||||
|
||||
private int m_HuePrimary;
|
||||
private int m_HueSecondary;
|
||||
private int m_HueJoin;
|
||||
private int m_HueBroadcast;
|
||||
|
||||
private int m_WarHorseBody;
|
||||
private int m_WarHorseItem;
|
||||
|
||||
private string m_FriendlyName;
|
||||
private string m_Keyword;
|
||||
private string m_Abbreviation;
|
||||
|
||||
private TextDefinition m_Name;
|
||||
private TextDefinition m_PropName;
|
||||
private TextDefinition m_Header;
|
||||
private TextDefinition m_About;
|
||||
private TextDefinition m_CityControl;
|
||||
private TextDefinition m_SigilControl;
|
||||
private TextDefinition m_SignupName;
|
||||
private TextDefinition m_FactionStoneName;
|
||||
private TextDefinition m_OwnerLabel;
|
||||
|
||||
private TextDefinition m_GuardIgnore, m_GuardWarn, m_GuardAttack;
|
||||
|
||||
private StrongholdDefinition m_Stronghold;
|
||||
|
||||
private RankDefinition[] m_Ranks;
|
||||
private GuardDefinition[] m_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; } }
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionItemDefinition
|
||||
{
|
||||
private int m_SilverCost;
|
||||
private Type m_VendorType;
|
||||
|
||||
public int SilverCost{ get{ return m_SilverCost; } }
|
||||
public Type VendorType{ get{ return m_VendorType; } }
|
||||
|
||||
public FactionItemDefinition( int silverCost, Type vendorType )
|
||||
{
|
||||
m_SilverCost = silverCost;
|
||||
m_VendorType = vendorType;
|
||||
}
|
||||
|
||||
private static FactionItemDefinition m_MetalArmor = new FactionItemDefinition( 1000, typeof( Blacksmith ) );
|
||||
private static FactionItemDefinition m_Weapon = new FactionItemDefinition( 1000, typeof( Blacksmith ) );
|
||||
private static FactionItemDefinition m_RangedWeapon = new FactionItemDefinition( 1000, typeof( Bowyer ) );
|
||||
private static FactionItemDefinition m_LeatherArmor = new FactionItemDefinition( 750, typeof( Tailor ) );
|
||||
private static FactionItemDefinition m_Clothing = new FactionItemDefinition( 200, typeof( Tailor ) );
|
||||
private static FactionItemDefinition m_Scroll = new FactionItemDefinition( 500, typeof( Mage ) );
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
42
Scripts/Engines/Factions/Definitions/GuardDefinition.cs
Normal file
42
Scripts/Engines/Factions/Definitions/GuardDefinition.cs
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
using System;
|
||||
using Server;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class GuardDefinition
|
||||
{
|
||||
private Type m_Type;
|
||||
|
||||
private int m_Price;
|
||||
private int m_Upkeep;
|
||||
private int m_Maximum;
|
||||
|
||||
private int m_ItemID;
|
||||
|
||||
private TextDefinition m_Header;
|
||||
private TextDefinition m_Label;
|
||||
|
||||
public Type Type{ get{ return m_Type; } }
|
||||
|
||||
public int Price{ get{ return m_Price; } }
|
||||
public int Upkeep{ get{ return m_Upkeep; } }
|
||||
public int Maximum{ get{ return m_Maximum; } }
|
||||
public int ItemID{ get{ return m_ItemID; } }
|
||||
|
||||
public TextDefinition Header{ get{ return m_Header; } }
|
||||
public TextDefinition Label{ get{ return m_Label; } }
|
||||
|
||||
public GuardDefinition( Type type, int itemID, int price, int upkeep, int maximum, TextDefinition header, TextDefinition label )
|
||||
{
|
||||
m_Type = type;
|
||||
|
||||
m_Price = price;
|
||||
m_Upkeep = upkeep;
|
||||
m_Maximum = maximum;
|
||||
m_ItemID = itemID;
|
||||
|
||||
m_Header = header;
|
||||
m_Label = label;
|
||||
}
|
||||
}
|
||||
}
|
||||
25
Scripts/Engines/Factions/Definitions/RankDefinition.cs
Normal file
25
Scripts/Engines/Factions/Definitions/RankDefinition.cs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class RankDefinition
|
||||
{
|
||||
private int m_Rank;
|
||||
private int m_Required;
|
||||
private int m_MaxWearables;
|
||||
private TextDefinition m_Title;
|
||||
|
||||
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; } }
|
||||
|
||||
public RankDefinition( int rank, int required, int maxWearables, TextDefinition title )
|
||||
{
|
||||
m_Rank = rank;
|
||||
m_Required = required;
|
||||
m_Title = title;
|
||||
m_MaxWearables = maxWearables;
|
||||
}
|
||||
}
|
||||
}
|
||||
27
Scripts/Engines/Factions/Definitions/StrongholdDefintion.cs
Normal file
27
Scripts/Engines/Factions/Definitions/StrongholdDefintion.cs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class StrongholdDefinition
|
||||
{
|
||||
private Rectangle2D[] m_Area;
|
||||
private Point3D m_JoinStone;
|
||||
private Point3D m_FactionStone;
|
||||
private Point3D[] m_Monoliths;
|
||||
|
||||
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 StrongholdDefinition( Rectangle2D[] area, Point3D joinStone, Point3D factionStone, Point3D[] monoliths )
|
||||
{
|
||||
m_Area = area;
|
||||
m_JoinStone = joinStone;
|
||||
m_FactionStone = factionStone;
|
||||
m_Monoliths = monoliths;
|
||||
}
|
||||
}
|
||||
}
|
||||
59
Scripts/Engines/Factions/Definitions/TownDefinition.cs
Normal file
59
Scripts/Engines/Factions/Definitions/TownDefinition.cs
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class TownDefinition
|
||||
{
|
||||
private int m_Sort;
|
||||
private int m_SigilID;
|
||||
|
||||
private string m_Region;
|
||||
|
||||
private string m_FriendlyName;
|
||||
|
||||
private TextDefinition m_TownName;
|
||||
private TextDefinition m_TownStoneHeader;
|
||||
private TextDefinition m_StrongholdMonolithName;
|
||||
private TextDefinition m_TownMonolithName;
|
||||
private TextDefinition m_TownStoneName;
|
||||
private TextDefinition m_SigilName;
|
||||
private TextDefinition m_CorruptedSigilName;
|
||||
|
||||
private Point3D m_Monolith;
|
||||
private Point3D m_TownStone;
|
||||
|
||||
public int Sort{ get{ return m_Sort; } }
|
||||
public int SigilID{ get{ return m_SigilID; } }
|
||||
|
||||
public string Region{ get{ return m_Region; } }
|
||||
public string FriendlyName{ get{ return m_FriendlyName; } }
|
||||
|
||||
public TextDefinition TownName{ get{ return m_TownName; } }
|
||||
public TextDefinition TownStoneHeader{ get{ return m_TownStoneHeader; } }
|
||||
public TextDefinition StrongholdMonolithName{ get{ return m_StrongholdMonolithName; } }
|
||||
public TextDefinition TownMonolithName{ get{ return m_TownMonolithName; } }
|
||||
public TextDefinition TownStoneName{ get{ return m_TownStoneName; } }
|
||||
public TextDefinition SigilName{ get{ return m_SigilName; } }
|
||||
public TextDefinition CorruptedSigilName{ get{ return m_CorruptedSigilName; } }
|
||||
|
||||
public Point3D Monolith{ get{ return m_Monolith; } }
|
||||
public Point3D TownStone{ get{ return 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 )
|
||||
{
|
||||
m_Sort = sort;
|
||||
m_SigilID = sigilID;
|
||||
m_Region = region;
|
||||
m_FriendlyName = friendlyName;
|
||||
m_TownName = townName;
|
||||
m_TownStoneHeader = townStoneHeader;
|
||||
m_StrongholdMonolithName = strongholdMonolithName;
|
||||
m_TownMonolithName = townMonolithName;
|
||||
m_TownStoneName = townStoneName;
|
||||
m_SigilName = sigilName;
|
||||
m_CorruptedSigilName = corruptedSigilName;
|
||||
m_Monolith = monolith;
|
||||
m_TownStone = townStone;
|
||||
}
|
||||
}
|
||||
}
|
||||
83
Scripts/Engines/Factions/Definitions/VendorDefinition.cs
Normal file
83
Scripts/Engines/Factions/Definitions/VendorDefinition.cs
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
using System;
|
||||
using Server;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class VendorDefinition
|
||||
{
|
||||
private Type m_Type;
|
||||
|
||||
private int m_Price;
|
||||
private int m_Upkeep;
|
||||
private int m_Maximum;
|
||||
|
||||
private int m_ItemID;
|
||||
|
||||
private TextDefinition m_Header;
|
||||
private TextDefinition m_Label;
|
||||
|
||||
public Type Type{ get{ return m_Type; } }
|
||||
|
||||
public int Price{ get{ return m_Price; } }
|
||||
public int Upkeep{ get{ return m_Upkeep; } }
|
||||
public int Maximum{ get{ return m_Maximum; } }
|
||||
public int ItemID{ get{ return m_ItemID; } }
|
||||
|
||||
public TextDefinition Header{ get{ return m_Header; } }
|
||||
public TextDefinition Label{ get{ return m_Label; } }
|
||||
|
||||
public VendorDefinition( Type type, int itemID, int price, int upkeep, int maximum, TextDefinition header, TextDefinition label )
|
||||
{
|
||||
m_Type = type;
|
||||
|
||||
m_Price = price;
|
||||
m_Upkeep = upkeep;
|
||||
m_Maximum = maximum;
|
||||
m_ItemID = itemID;
|
||||
|
||||
m_Header = header;
|
||||
m_Label = label;
|
||||
}
|
||||
|
||||
private static 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" )
|
||||
)
|
||||
};
|
||||
|
||||
public static VendorDefinition[] Definitions{ get{ return m_Definitions; } }
|
||||
}
|
||||
}
|
||||
128
Scripts/Engines/Factions/Gumps/ElectionGump.cs
Normal file
128
Scripts/Engines/Factions/Gumps/ElectionGump.cs
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class ElectionGump : FactionGump
|
||||
{
|
||||
private PlayerMobile m_From;
|
||||
private Election m_Election;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
218
Scripts/Engines/Factions/Gumps/ElectionManagementGump.cs
Normal file
218
Scripts/Engines/Factions/Gumps/ElectionManagementGump.cs
Normal file
|
|
@ -0,0 +1,218 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class ElectionManagementGump : Gump
|
||||
{
|
||||
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 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 const int LabelColor = 0xFFFFFF;
|
||||
|
||||
private Election m_Election;
|
||||
private Candidate m_Candidate;
|
||||
private int m_Page;
|
||||
|
||||
public override void OnResponse( NetState sender, RelayInfo info )
|
||||
{
|
||||
Mobile from = sender.Mobile;
|
||||
int bid = info.ButtonID;
|
||||
|
||||
if ( m_Candidate == null )
|
||||
{
|
||||
if ( bid == 0 )
|
||||
{
|
||||
}
|
||||
else if ( bid == 1 )
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
bid -= 2;
|
||||
|
||||
if ( bid >= 0 && bid < m_Election.Candidates.Count )
|
||||
from.SendGump( new ElectionManagementGump( m_Election, m_Election.Candidates[bid], 0 ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( bid == 0 )
|
||||
{
|
||||
from.SendGump( new ElectionManagementGump( m_Election ) );
|
||||
}
|
||||
else if ( bid == 1 )
|
||||
{
|
||||
m_Election.RemoveCandidate( m_Candidate.Mobile );
|
||||
from.SendGump( new ElectionManagementGump( m_Election ) );
|
||||
}
|
||||
else if ( bid == 2 && m_Page > 0 )
|
||||
{
|
||||
from.SendGump( new ElectionManagementGump( m_Election, m_Candidate, m_Page - 1 ) );
|
||||
}
|
||||
else if ( bid == 3 && (m_Page + 1) * 10 < m_Candidate.Voters.Count )
|
||||
{
|
||||
from.SendGump( new ElectionManagementGump( m_Election, m_Candidate, m_Page + 1 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
bid -= 4;
|
||||
|
||||
if ( bid >= 0 && bid < m_Candidate.Voters.Count )
|
||||
{
|
||||
m_Candidate.Voters.RemoveAt( bid );
|
||||
from.SendGump( new ElectionManagementGump( m_Election, m_Candidate, m_Page ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ElectionManagementGump( Election election ) : this( election, null, 0 )
|
||||
{
|
||||
}
|
||||
|
||||
public ElectionManagementGump( Election election, Candidate candidate, int page ) : base( 40, 40 )
|
||||
{
|
||||
m_Election = election;
|
||||
m_Candidate = candidate;
|
||||
m_Page = page;
|
||||
|
||||
AddPage( 0 );
|
||||
|
||||
if ( candidate != null )
|
||||
{
|
||||
AddBackground( 0, 0, 448, 354, 9270 );
|
||||
AddAlphaRegion( 10, 10, 428, 334 );
|
||||
|
||||
AddHtml( 10, 10, 428, 20, Color( Center( "Candidate Management" ), LabelColor ), false, false );
|
||||
|
||||
AddHtml( 45, 35, 100, 20, Color( "Player Name:", LabelColor ), false, false );
|
||||
AddHtml( 145, 35, 100, 20, Color( candidate.Mobile == null ? "null" : candidate.Mobile.Name, LabelColor ), false, false );
|
||||
|
||||
AddHtml( 45, 55, 100, 20, Color( "Vote Count:", LabelColor ), false, false );
|
||||
AddHtml( 145, 55, 100, 20, Color( candidate.Votes.ToString(), LabelColor ), false, false );
|
||||
|
||||
AddButton( 12, 73, 4005, 4007, 1, GumpButtonType.Reply, 0 );
|
||||
AddHtml( 45, 75, 100, 20, Color( "Drop Candidate", LabelColor ), false, false );
|
||||
|
||||
AddImageTiled( 13, 99, 422, 242, 9264 );
|
||||
AddImageTiled( 14, 100, 420, 240, 9274 );
|
||||
AddAlphaRegion( 14, 100, 420, 240 );
|
||||
|
||||
AddHtml( 14, 100, 420, 20, Color( Center( "Voters" ), LabelColor ), false, false );
|
||||
|
||||
if ( page > 0 )
|
||||
AddButton( 397, 104, 0x15E3, 0x15E7, 2, GumpButtonType.Reply, 0 );
|
||||
else
|
||||
AddImage( 397, 104, 0x25EA );
|
||||
|
||||
if ( (page + 1) * 10 < candidate.Voters.Count )
|
||||
AddButton( 414, 104, 0x15E1, 0x15E5, 3, GumpButtonType.Reply, 0 );
|
||||
else
|
||||
AddImage( 414, 104, 0x25E6 );
|
||||
|
||||
|
||||
AddHtml( 14, 120, 30, 20, Color( Center( "DEL" ), LabelColor ), false, false );
|
||||
AddHtml( 47, 120, 150, 20, Color( "Name", LabelColor ), false, false );
|
||||
AddHtml( 195, 120, 100, 20, Color( Center( "Address" ), LabelColor ), false, false );
|
||||
AddHtml( 295, 120, 80, 20, Color( Center( "Time" ), LabelColor ), false, false );
|
||||
AddHtml( 355, 120, 60, 20, Color( 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];
|
||||
|
||||
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 )
|
||||
{
|
||||
AddHtml( x + 2, 140 + (idx * 20), 150, 20, Color( ((Mobile)obj).Name, LabelColor ), false, false );
|
||||
x += 150;
|
||||
}
|
||||
else if ( obj is System.Net.IPAddress )
|
||||
{
|
||||
AddHtml( x, 140 + (idx * 20), 100, 20, Color( Center( obj.ToString() ), LabelColor ), false, false );
|
||||
x += 100;
|
||||
}
|
||||
else if ( obj is DateTime )
|
||||
{
|
||||
AddHtml( x, 140 + (idx * 20), 80, 20, Color( Center( FormatTimeSpan( ((DateTime)obj) - election.LastStateTime ) ), LabelColor ), false, false );
|
||||
x += 80;
|
||||
}
|
||||
else if ( obj is int )
|
||||
{
|
||||
AddHtml( x, 140 + (idx * 20), 60, 20, Color( Center( (int)obj + "%" ), LabelColor ), false, false );
|
||||
x += 60;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AddBackground( 0, 0, 288, 334, 9270 );
|
||||
AddAlphaRegion( 10, 10, 268, 314 );
|
||||
|
||||
AddHtml( 10, 10, 268, 20, Color( Center( "Election Management" ), LabelColor ), false, false );
|
||||
|
||||
AddHtml( 45, 35, 100, 20, Color( "Current State:", LabelColor ), false, false );
|
||||
AddHtml( 145, 35, 100, 20, Color( election.State.ToString(), LabelColor ), false, false );
|
||||
|
||||
AddButton( 12, 53, 4005, 4007, 1, GumpButtonType.Reply, 0 );
|
||||
AddHtml( 45, 55, 100, 20, Color( "Transition Time:", LabelColor ), false, false );
|
||||
AddHtml( 145, 55, 100, 20, Color( FormatTimeSpan( election.NextStateTime ), LabelColor ), false, false );
|
||||
|
||||
AddImageTiled( 13, 79, 262, 242, 9264 );
|
||||
AddImageTiled( 14, 80, 260, 240, 9274 );
|
||||
AddAlphaRegion( 14, 80, 260, 240 );
|
||||
|
||||
AddHtml( 14, 80, 260, 20, Color( Center( "Candidates" ), LabelColor ), false, false );
|
||||
AddHtml( 14, 100, 30, 20, Color( Center( "-->" ), LabelColor ), false, false );
|
||||
AddHtml( 47, 100, 150, 20, Color( "Name", LabelColor ), false, false );
|
||||
AddHtml( 195, 100, 80, 20, Color( 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;
|
||||
|
||||
AddButton( 13, 118 + (i * 20), 4005, 4007, 2 + i, GumpButtonType.Reply, 0 );
|
||||
AddHtml( 47, 120 + (i * 20), 150, 20, Color( mob.Name, LabelColor ), false, false );
|
||||
AddHtml( 195, 120 + (i * 20), 80, 20, Color( Center( cd.Votes.ToString() ), LabelColor ), false, false );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
51
Scripts/Engines/Factions/Gumps/FactionGump.cs
Normal file
51
Scripts/Engines/Factions/Gumps/FactionGump.cs
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public abstract class FactionGump : Gump
|
||||
{
|
||||
public virtual int ButtonTypes{ get{ return 10; } }
|
||||
|
||||
public int ToButtonID( int type, int index )
|
||||
{
|
||||
return 1 + (index * ButtonTypes) + type;
|
||||
}
|
||||
|
||||
public bool FromButtonID( int buttonID, out int type, out int index )
|
||||
{
|
||||
int offset = buttonID - 1;
|
||||
|
||||
if ( offset >= 0 )
|
||||
{
|
||||
type = offset % ButtonTypes;
|
||||
index = offset / ButtonTypes;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
type = index = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool Exists( Mobile mob )
|
||||
{
|
||||
return ( mob.FindGump( typeof( FactionGump ) ) != null );
|
||||
}
|
||||
|
||||
public void AddHtmlText( int x, int y, int width, int height, TextDefinition text, bool back, bool scroll )
|
||||
{
|
||||
if ( text != null && text.Number > 0 )
|
||||
AddHtmlLocalized( x, y, width, height, text.Number, back, scroll );
|
||||
else if ( text != null && text.String != null )
|
||||
AddHtml( x, y, width, height, text.String, back, scroll );
|
||||
}
|
||||
|
||||
public FactionGump( int x, int y ) : base( x, y )
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
104
Scripts/Engines/Factions/Gumps/FactionImbueGump.cs
Normal file
104
Scripts/Engines/Factions/Gumps/FactionImbueGump.cs
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
using Server.Gumps;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
using Server.Engines.Craft;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionImbueGump : FactionGump
|
||||
{
|
||||
private Item m_Item;
|
||||
private Mobile m_Mobile;
|
||||
private Faction m_Faction;
|
||||
private CraftSystem m_CraftSystem;
|
||||
private BaseTool m_Tool;
|
||||
private object m_Notice;
|
||||
private int m_Quality;
|
||||
|
||||
private FactionItemDefinition m_Definition;
|
||||
|
||||
public FactionImbueGump( int quality, Item item, Mobile from, CraftSystem craftSystem, BaseTool tool, object notice, int availableSilver, Faction faction, FactionItemDefinition def ) : base( 100, 200 )
|
||||
{
|
||||
m_Item = item;
|
||||
m_Mobile = from;
|
||||
m_Faction = faction;
|
||||
m_CraftSystem = craftSystem;
|
||||
m_Tool = tool;
|
||||
m_Notice = notice;
|
||||
m_Quality = quality;
|
||||
m_Definition = def;
|
||||
|
||||
AddPage( 0 );
|
||||
|
||||
AddBackground( 0, 0, 320, 270, 5054 );
|
||||
AddBackground( 10, 10, 300, 250, 3000 );
|
||||
|
||||
AddHtmlLocalized( 20, 20, 210, 25, 1011569, false, false ); // Imbue with Faction properties?
|
||||
|
||||
|
||||
AddHtmlLocalized( 20, 60, 170, 25, 1018302, false, false ); // Item quality:
|
||||
AddHtmlLocalized( 175, 60, 100, 25, 1018305 - m_Quality, false, false ); // Exceptional, Average, Low
|
||||
|
||||
AddHtmlLocalized( 20, 80, 170, 25, 1011572, false, false ); // Item Cost :
|
||||
AddLabel( 175, 80, 0x34, def.SilverCost.ToString( "N0" ) ); // NOTE: Added 'N0'
|
||||
|
||||
AddHtmlLocalized( 20, 100, 170, 25, 1011573, false, false ); // Your Silver :
|
||||
AddLabel( 175, 100, 0x34, availableSilver.ToString( "N0" ) ); // NOTE: Added 'N0'
|
||||
|
||||
|
||||
AddRadio( 20, 140, 210, 211, true, 1 );
|
||||
AddLabel( 55, 140, m_Faction.Definition.HuePrimary - 1, "*****" );
|
||||
AddHtmlLocalized( 150, 140, 150, 25, 1011570, false, false ); // Primary Color
|
||||
|
||||
AddRadio( 20, 160, 210, 211, false, 2 );
|
||||
AddLabel( 55, 160, m_Faction.Definition.HueSecondary - 1, "*****" );
|
||||
AddHtmlLocalized( 150, 160, 150, 25, 1011571, false, false ); // Secondary Color
|
||||
|
||||
|
||||
AddHtmlLocalized( 55, 200, 200, 25, 1011011, false, false ); // CONTINUE
|
||||
AddButton( 20, 200, 4005, 4007, 1, GumpButtonType.Reply, 0 );
|
||||
|
||||
AddHtmlLocalized( 55, 230, 200, 25, 1011012, false, false ); // CANCEL
|
||||
AddButton( 20, 230, 4005, 4007, 0, GumpButtonType.Reply, 0 );
|
||||
}
|
||||
|
||||
public override void OnResponse( NetState sender, RelayInfo info )
|
||||
{
|
||||
if ( info.ButtonID == 1 )
|
||||
{
|
||||
Container pack = m_Mobile.Backpack;
|
||||
|
||||
if ( pack != null && m_Item.IsChildOf( pack ) )
|
||||
{
|
||||
if ( pack.ConsumeTotal( typeof( Silver ), m_Definition.SilverCost ) )
|
||||
{
|
||||
int hue;
|
||||
|
||||
if ( m_Item is SpellScroll )
|
||||
hue = 0;
|
||||
else if ( info.IsSwitched( 1 ) )
|
||||
hue = m_Faction.Definition.HuePrimary;
|
||||
else
|
||||
hue = m_Faction.Definition.HueSecondary;
|
||||
|
||||
FactionItem.Imbue( m_Item, m_Faction, true, hue );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Mobile.SendLocalizedMessage( 1042204 ); // You do not have enough silver.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( m_Tool != null && !m_Tool.Deleted && m_Tool.UsesRemaining > 0 )
|
||||
m_Mobile.SendGump( new CraftGump( m_Mobile, m_CraftSystem, m_Tool, m_Notice ) );
|
||||
else if ( m_Notice is string )
|
||||
m_Mobile.SendMessage( (string) m_Notice );
|
||||
else if ( m_Notice is int && ((int)m_Notice) > 0 )
|
||||
m_Mobile.SendLocalizedMessage( (int) m_Notice );
|
||||
}
|
||||
}
|
||||
}
|
||||
347
Scripts/Engines/Factions/Gumps/FactionStoneGump.cs
Normal file
347
Scripts/Engines/Factions/Gumps/FactionStoneGump.cs
Normal file
|
|
@ -0,0 +1,347 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionStoneGump : FactionGump
|
||||
{
|
||||
private PlayerMobile m_From;
|
||||
private 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
|
||||
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
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
281
Scripts/Engines/Factions/Gumps/FinanceGump.cs
Normal file
281
Scripts/Engines/Factions/Gumps/FinanceGump.cs
Normal file
|
|
@ -0,0 +1,281 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
using Server.Mobiles;
|
||||
using Server.Multis;
|
||||
using Server.Network;
|
||||
using Server.Targeting;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FinanceGump : FactionGump
|
||||
{
|
||||
private PlayerMobile m_From;
|
||||
private Faction m_Faction;
|
||||
private Town m_Town;
|
||||
|
||||
private static 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 )
|
||||
{
|
||||
m_From = from;
|
||||
m_Faction = faction;
|
||||
m_Town = town;
|
||||
|
||||
|
||||
AddPage( 0 );
|
||||
|
||||
AddBackground( 0, 0, 320, 410, 5054 );
|
||||
AddBackground( 10, 10, 300, 390, 3000 );
|
||||
|
||||
#region General
|
||||
AddPage( 1 );
|
||||
|
||||
AddHtmlLocalized( 20, 30, 260, 25, 1011541, false, false ); // FINANCE MINISTER
|
||||
|
||||
|
||||
AddHtmlLocalized( 55, 90, 200, 25, 1011539, false, false ); // CHANGE PRICES
|
||||
AddButton( 20, 90, 4005, 4007, 0, GumpButtonType.Page, 2 );
|
||||
|
||||
AddHtmlLocalized( 55, 120, 200, 25, 1011540, false, false ); // BUY SHOPKEEPERS
|
||||
AddButton( 20, 120, 4005, 4007, 0, GumpButtonType.Page, 3 );
|
||||
|
||||
AddHtmlLocalized( 55, 150, 200, 25, 1011495, false, false ); // VIEW FINANCES
|
||||
AddButton( 20, 150, 4005, 4007, 0, GumpButtonType.Page, 4 );
|
||||
|
||||
AddHtmlLocalized( 55, 360, 200, 25, 1011441, false, false ); // EXIT
|
||||
AddButton( 20, 360, 4005, 4007, 0, GumpButtonType.Reply, 0 );
|
||||
#endregion
|
||||
|
||||
#region Change Prices
|
||||
AddPage( 2 );
|
||||
|
||||
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);
|
||||
|
||||
AddRadio( x, y, 208, 209, ( town.Tax == ofs ), i+1 );
|
||||
|
||||
if ( ofs < 0 )
|
||||
AddLabel( x + 35, y, 0x26, String.Concat( "- ", -ofs, "%" ) );
|
||||
else
|
||||
AddLabel( x + 35, y, 0x12A, String.Concat( "+ ", ofs, "%" ) );
|
||||
}
|
||||
|
||||
AddRadio( 20, 270, 208, 209, ( town.Tax == 0 ), 0 );
|
||||
AddHtmlLocalized( 55, 270, 90, 25, 1011542, false, false ); // normal
|
||||
|
||||
AddHtmlLocalized( 55, 330, 200, 25, 1011509, false, false ); // Set Prices
|
||||
AddButton( 20, 330, 4005, 4007, ToButtonID( 0, 0 ), GumpButtonType.Reply, 0 );
|
||||
|
||||
AddHtmlLocalized( 55, 360, 200, 25, 1011067, false, false ); // Previous page
|
||||
AddButton( 20, 360, 4005, 4007, 0, GumpButtonType.Page, 1 );
|
||||
#endregion
|
||||
|
||||
#region Buy Shopkeepers
|
||||
AddPage( 3 );
|
||||
|
||||
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];
|
||||
|
||||
AddButton( 20, 90 + (i * 40), 4005, 4007, 0, GumpButtonType.Page, 5 + i );
|
||||
AddItem( 55, 90 + (i * 40), list.Definition.ItemID );
|
||||
AddHtmlText( 100, 90 + (i * 40), 200, 25, list.Definition.Label, false, false );
|
||||
}
|
||||
|
||||
AddHtmlLocalized( 55, 360, 200, 25, 1011067, false, false ); // Previous page
|
||||
AddButton( 20, 360, 4005, 4007, 0, GumpButtonType.Page, 1 );
|
||||
#endregion
|
||||
|
||||
#region View Finances
|
||||
AddPage( 4 );
|
||||
|
||||
int financeUpkeep = town.FinanceUpkeep;
|
||||
int sheriffUpkeep = town.SheriffUpkeep;
|
||||
int dailyIncome = town.DailyIncome;
|
||||
int netCashFlow = town.NetCashFlow;
|
||||
|
||||
|
||||
AddHtmlLocalized( 20, 30, 300, 25, 1011524, false, false ); // FINANCE STATEMENT
|
||||
|
||||
AddHtmlLocalized( 20, 80, 300, 25, 1011538, false, false ); // Current total money for town :
|
||||
AddLabel( 20, 100, 0x44, town.Silver.ToString() );
|
||||
|
||||
AddHtmlLocalized( 20, 130, 300, 25, 1011520, false, false ); // Finance Minister Upkeep :
|
||||
AddLabel( 20, 150, 0x44, financeUpkeep.ToString( "N0" ) ); // NOTE: Added 'N0'
|
||||
|
||||
AddHtmlLocalized( 20, 180, 300, 25, 1011521, false, false ); // Sheriff Upkeep :
|
||||
AddLabel( 20, 200, 0x44, sheriffUpkeep.ToString( "N0" ) ); // NOTE: Added 'N0'
|
||||
|
||||
AddHtmlLocalized( 20, 230, 300, 25, 1011522, false, false ); // Town Income :
|
||||
AddLabel( 20, 250, 0x44, dailyIncome.ToString( "N0" ) ); // NOTE: Added 'N0'
|
||||
|
||||
AddHtmlLocalized( 20, 280, 300, 25, 1011523, false, false ); // Net Cash flow per day :
|
||||
AddLabel( 20, 300, 0x44, netCashFlow.ToString( "N0" ) ); // NOTE: Added 'N0'
|
||||
|
||||
AddHtmlLocalized( 55, 360, 200, 25, 1011067, false, false ); // Previous page
|
||||
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];
|
||||
|
||||
AddPage( 5 + i );
|
||||
|
||||
AddHtmlText( 60, 30, 300, 25, vendorList.Definition.Header, false, false );
|
||||
AddItem( 20, 30, vendorList.Definition.ItemID );
|
||||
|
||||
AddHtmlLocalized( 20, 90, 200, 25, 1011514, false, false ); // You have :
|
||||
AddLabel( 230, 90, 0x26, vendorList.Vendors.Count.ToString() );
|
||||
|
||||
AddHtmlLocalized( 20, 120, 200, 25, 1011515, false, false ); // Maximum :
|
||||
AddLabel( 230, 120, 0x256, vendorList.Definition.Maximum.ToString() );
|
||||
|
||||
AddHtmlLocalized( 20, 150, 200, 25, 1011516, false, false ); // Cost :
|
||||
AddLabel( 230, 150, 0x44, vendorList.Definition.Price.ToString( "N0" ) ); // NOTE: Added 'N0'
|
||||
|
||||
AddHtmlLocalized( 20, 180, 200, 25, 1011517, false, false ); // Daily Pay :
|
||||
AddLabel( 230, 180, 0x37, vendorList.Definition.Upkeep.ToString( "N0" ) ); // NOTE: Added 'N0'
|
||||
|
||||
AddHtmlLocalized( 20, 210, 200, 25, 1011518, false, false ); // Current Silver :
|
||||
AddLabel( 230, 210, 0x44, town.Silver.ToString( "N0" ) ); // NOTE: Added 'N0'
|
||||
|
||||
AddHtmlLocalized( 20, 240, 200, 25, 1011519, false, false ); // Current Payroll :
|
||||
AddLabel( 230, 240, 0x44, financeUpkeep.ToString( "N0" ) ); // NOTE: Added 'N0'
|
||||
|
||||
AddHtmlText( 55, 300, 200, 25, vendorList.Definition.Label, false, false );
|
||||
if ( town.Silver >= vendorList.Definition.Price )
|
||||
AddButton( 20, 300, 4005, 4007, ToButtonID( 1, i ), GumpButtonType.Reply, 0 );
|
||||
else
|
||||
AddImage( 20, 300, 4020 );
|
||||
|
||||
AddHtmlLocalized( 55, 360, 200, 25, 1011067, false, false ); // Previous page
|
||||
AddButton( 20, 360, 4005, 4007, 0, GumpButtonType.Page, 3 );
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
public override void OnResponse( NetState sender, RelayInfo info )
|
||||
{
|
||||
if ( !m_Town.IsFinance( m_From ) || m_Town.Owner != m_Faction )
|
||||
{
|
||||
m_From.SendLocalizedMessage( 1010339 ); // You no longer control this city
|
||||
return;
|
||||
}
|
||||
|
||||
int type, index;
|
||||
|
||||
if ( !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 ( m_Town.Tax == newTax )
|
||||
break;
|
||||
|
||||
if ( m_From.AccessLevel == AccessLevel.Player && !m_Town.TaxChangeReady )
|
||||
{
|
||||
TimeSpan remaining = DateTime.UtcNow - ( m_Town.LastTaxChange + Town.TaxChangePeriod );
|
||||
|
||||
if ( remaining.TotalMinutes < 4 )
|
||||
m_From.SendLocalizedMessage( 1042165 ); // You must wait a short while before changing prices again.
|
||||
else if ( remaining.TotalMinutes < 10 )
|
||||
m_From.SendLocalizedMessage( 1042166 ); // You must wait several minutes before changing prices again.
|
||||
else if ( remaining.TotalHours < 1 )
|
||||
m_From.SendLocalizedMessage( 1042167 ); // You must wait up to an hour before changing prices again.
|
||||
else if ( remaining.TotalHours < 4 )
|
||||
m_From.SendLocalizedMessage( 1042168 ); // You must wait a few hours before changing prices again.
|
||||
else
|
||||
m_From.SendLocalizedMessage( 1042169 ); // You must wait several hours before changing prices again.
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Town.Tax = newTax;
|
||||
|
||||
if ( m_From.AccessLevel == AccessLevel.Player )
|
||||
m_Town.LastTaxChange = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 1: // make vendor
|
||||
{
|
||||
List<VendorList> vendorLists = m_Town.VendorLists;
|
||||
|
||||
if ( index >= 0 && index < vendorLists.Count )
|
||||
{
|
||||
VendorList vendorList = vendorLists[index];
|
||||
|
||||
Town town = Town.FromRegion( m_From.Region );
|
||||
|
||||
if ( Town.FromRegion( m_From.Region ) != m_Town )
|
||||
{
|
||||
m_From.SendLocalizedMessage( 1010305 ); // You must be in your controlled city to buy Items
|
||||
}
|
||||
else if ( vendorList.Vendors.Count >= vendorList.Definition.Maximum )
|
||||
{
|
||||
m_From.SendLocalizedMessage( 1010306 ); // You currently have too many of this enhancement type to place another
|
||||
}
|
||||
else if ( BaseBoat.FindBoatAt( m_From.Location, m_From.Map ) != null ) {
|
||||
m_From.SendMessage( "You cannot place a vendor here" );
|
||||
}
|
||||
else if ( m_Town.Silver >= vendorList.Definition.Price )
|
||||
{
|
||||
BaseFactionVendor vendor = vendorList.Construct( m_Town, m_Faction );
|
||||
|
||||
if ( vendor != null )
|
||||
{
|
||||
m_Town.Silver -= vendorList.Definition.Price;
|
||||
|
||||
vendor.MoveToWorld( m_From.Location, m_From.Map );
|
||||
vendor.Home = vendor.Location;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
92
Scripts/Engines/Factions/Gumps/HorseBreederGump.cs
Normal file
92
Scripts/Engines/Factions/Gumps/HorseBreederGump.cs
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
using Server.Gumps;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class HorseBreederGump : FactionGump
|
||||
{
|
||||
private PlayerMobile m_From;
|
||||
private Faction m_Faction;
|
||||
|
||||
public HorseBreederGump( PlayerMobile from, Faction faction ) : base( 20, 30 )
|
||||
{
|
||||
m_From = from;
|
||||
m_Faction = faction;
|
||||
|
||||
AddPage( 0 );
|
||||
|
||||
AddBackground( 0, 0, 320, 280, 5054 );
|
||||
AddBackground( 10, 10, 300, 260, 3000 );
|
||||
|
||||
AddHtmlText( 20, 30, 300, 25, faction.Definition.Header, false, false );
|
||||
|
||||
AddHtmlLocalized( 20, 60, 300, 25, 1018306, false, false ); // Purchase a Faction War Horse
|
||||
AddItem( 70, 120, 0x3FFE );
|
||||
|
||||
AddItem( 150, 120, 0xEF2 );
|
||||
AddLabel( 190, 122, 0x3E3, FactionWarHorse.SilverPrice.ToString( "N0" ) ); // NOTE: Added 'N0'
|
||||
|
||||
AddItem( 150, 150, 0xEEF );
|
||||
AddLabel( 190, 152, 0x3E3, FactionWarHorse.GoldPrice.ToString( "N0" ) ); // NOTE: Added 'N0'
|
||||
|
||||
AddHtmlLocalized( 55, 210, 200, 25, 1011011, false, false ); // CONTINUE
|
||||
AddButton( 20, 210, 4005, 4007, 1, GumpButtonType.Reply, 0 );
|
||||
|
||||
AddHtmlLocalized( 55, 240, 200, 25, 1011012, false, false ); // CANCEL
|
||||
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( m_From ) != m_Faction )
|
||||
return;
|
||||
|
||||
Container pack = m_From.Backpack;
|
||||
|
||||
if ( pack == null )
|
||||
return;
|
||||
|
||||
FactionWarHorse horse = new FactionWarHorse( m_Faction );
|
||||
|
||||
if ( (m_From.Followers + horse.ControlSlots) > 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 = m_From;
|
||||
|
||||
horse.ControlOrder = OrderType.Follow;
|
||||
horse.ControlTarget = m_From;
|
||||
|
||||
horse.MoveToWorld( m_From.Location, m_From.Map );
|
||||
}
|
||||
else
|
||||
{
|
||||
horse.Delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
52
Scripts/Engines/Factions/Gumps/JoinStoneGump.cs
Normal file
52
Scripts/Engines/Factions/Gumps/JoinStoneGump.cs
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class JoinStoneGump : FactionGump
|
||||
{
|
||||
private PlayerMobile m_From;
|
||||
private Faction m_Faction;
|
||||
|
||||
public JoinStoneGump( 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 );
|
||||
|
||||
|
||||
AddHtmlText( 20, 30, 510, 20, faction.Definition.Header, false, false );
|
||||
AddHtmlText( 20, 130, 510, 100, faction.Definition.About, true, true );
|
||||
|
||||
|
||||
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 );
|
||||
|
||||
|
||||
AddButton( 20, 400, 4005, 4007, 1, GumpButtonType.Reply, 0 );
|
||||
AddHtmlLocalized( 55, 400, 200, 20, 1011425, false, false ); // JOIN THIS FACTION
|
||||
|
||||
AddButton( 300, 400, 4005, 4007, 0, GumpButtonType.Reply, 0 );
|
||||
AddHtmlLocalized( 335, 400, 200, 20, 1011012, false, false ); // CANCEL
|
||||
}
|
||||
|
||||
public override void OnResponse( NetState sender, RelayInfo info )
|
||||
{
|
||||
if ( info.ButtonID == 1 )
|
||||
m_Faction.OnJoinAccepted( m_From );
|
||||
}
|
||||
}
|
||||
}
|
||||
92
Scripts/Engines/Factions/Gumps/LeaveFactionGump.cs
Normal file
92
Scripts/Engines/Factions/Gumps/LeaveFactionGump.cs
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
using Server.Guilds;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class LeaveFactionGump : FactionGump
|
||||
{
|
||||
private PlayerMobile m_From;
|
||||
private Faction m_Faction;
|
||||
|
||||
public LeaveFactionGump( PlayerMobile from, Faction faction ) : base( 20, 30 )
|
||||
{
|
||||
m_From = from;
|
||||
m_Faction = faction;
|
||||
|
||||
AddBackground( 0, 0, 270, 120, 5054 );
|
||||
AddBackground( 10, 10, 250, 100, 3000 );
|
||||
|
||||
if ( from.Guild is Guild && ((Guild)from.Guild).Leader == from )
|
||||
AddHtmlLocalized( 20, 15, 230, 60, 1018057, true, true ); // Are you sure you want your entire guild to leave this faction?
|
||||
else
|
||||
AddHtmlLocalized( 20, 15, 230, 60, 1018063, true, true ); // Are you sure you want to leave this faction?
|
||||
|
||||
AddHtmlLocalized( 55, 80, 75, 20, 1011011, false, false ); // CONTINUE
|
||||
AddButton( 20, 80, 4005, 4007, 1, GumpButtonType.Reply, 0 );
|
||||
|
||||
AddHtmlLocalized( 170, 80, 75, 20, 1011012, false, false ); // CANCEL
|
||||
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 = m_From.Guild as Guild;
|
||||
|
||||
if ( guild == null )
|
||||
{
|
||||
PlayerState pl = PlayerState.Find( m_From );
|
||||
|
||||
if ( pl != null )
|
||||
{
|
||||
pl.Leaving = DateTime.UtcNow;
|
||||
|
||||
if ( Faction.LeavePeriod == TimeSpan.FromDays( 3.0 ) )
|
||||
m_From.SendLocalizedMessage( 1005065 ); // You will be removed from the faction in 3 days
|
||||
else
|
||||
m_From.SendMessage( "You will be removed from the faction in {0} days.", Faction.LeavePeriod.TotalDays );
|
||||
}
|
||||
}
|
||||
else if ( guild.Leader != m_From )
|
||||
{
|
||||
m_From.SendLocalizedMessage( 1005061 ); // You cannot quit the faction because you are not the guild master
|
||||
}
|
||||
else
|
||||
{
|
||||
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
|
||||
{
|
||||
m_From.SendLocalizedMessage( 500737 ); // Canceled resignation.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
182
Scripts/Engines/Factions/Gumps/SheriffGump.cs
Normal file
182
Scripts/Engines/Factions/Gumps/SheriffGump.cs
Normal file
|
|
@ -0,0 +1,182 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
using Server.Mobiles;
|
||||
using Server.Multis;
|
||||
using Server.Network;
|
||||
using Server.Targeting;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class SheriffGump : FactionGump
|
||||
{
|
||||
private PlayerMobile m_From;
|
||||
private Faction m_Faction;
|
||||
private Town m_Town;
|
||||
|
||||
private void CenterItem( int itemID, int x, int y, int w, int h )
|
||||
{
|
||||
Rectangle2D rc = ItemBounds.Table[itemID];
|
||||
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 )
|
||||
{
|
||||
m_From = from;
|
||||
m_Faction = faction;
|
||||
m_Town = town;
|
||||
|
||||
|
||||
AddPage( 0 );
|
||||
|
||||
AddBackground( 0, 0, 320, 410, 5054 );
|
||||
AddBackground( 10, 10, 300, 390, 3000 );
|
||||
|
||||
#region General
|
||||
AddPage( 1 );
|
||||
|
||||
AddHtmlLocalized( 20, 30, 260, 25, 1011431, false, false ); // Sheriff
|
||||
|
||||
AddHtmlLocalized( 55, 90, 200, 25, 1011494, false, false ); // HIRE GUARDS
|
||||
AddButton( 20, 90, 4005, 4007, 0, GumpButtonType.Page, 3 );
|
||||
|
||||
AddHtmlLocalized( 55, 120, 200, 25, 1011495, false, false ); // VIEW FINANCES
|
||||
AddButton( 20, 120, 4005, 4007, 0, GumpButtonType.Page, 2 );
|
||||
|
||||
AddHtmlLocalized( 55, 360, 200, 25, 1011441, false, false ); // Exit
|
||||
AddButton( 20, 360, 4005, 4007, 0, GumpButtonType.Reply, 0 );
|
||||
#endregion
|
||||
|
||||
#region Finances
|
||||
AddPage( 2 );
|
||||
|
||||
int financeUpkeep = town.FinanceUpkeep;
|
||||
int sheriffUpkeep = town.SheriffUpkeep;
|
||||
int dailyIncome = town.DailyIncome;
|
||||
int netCashFlow = town.NetCashFlow;
|
||||
|
||||
AddHtmlLocalized( 20, 30, 300, 25, 1011524, false, false ); // FINANCE STATEMENT
|
||||
|
||||
AddHtmlLocalized( 20, 80, 300, 25, 1011538, false, false ); // Current total money for town :
|
||||
AddLabel( 20, 100, 0x44, town.Silver.ToString( "N0" ) ); // NOTE: Added 'N0'
|
||||
|
||||
AddHtmlLocalized( 20, 130, 300, 25, 1011520, false, false ); // Finance Minister Upkeep :
|
||||
AddLabel( 20, 150, 0x44, financeUpkeep.ToString( "N0" ) ); // NOTE: Added 'N0'
|
||||
|
||||
AddHtmlLocalized( 20, 180, 300, 25, 1011521, false, false ); // Sheriff Upkeep :
|
||||
AddLabel( 20, 200, 0x44, sheriffUpkeep.ToString( "N0" ) ); // NOTE: Added 'N0'
|
||||
|
||||
AddHtmlLocalized( 20, 230, 300, 25, 1011522, false, false ); // Town Income :
|
||||
AddLabel( 20, 250, 0x44, dailyIncome.ToString( "N0" ) ); // NOTE: Added 'N0'
|
||||
|
||||
AddHtmlLocalized( 20, 280, 300, 25, 1011523, false, false ); // Net Cash flow per day :
|
||||
AddLabel( 20, 300, 0x44, netCashFlow.ToString( "N0" ) ); // NOTE: Added 'N0'
|
||||
|
||||
AddHtmlLocalized( 55, 360, 200, 25, 1011067, false, false ); // Previous page
|
||||
AddButton( 20, 360, 4005, 4007, 0, GumpButtonType.Page, 1 );
|
||||
#endregion
|
||||
|
||||
#region Hire Guards
|
||||
AddPage( 3 );
|
||||
|
||||
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);
|
||||
|
||||
AddButton( 20, y, 4005, 4007, 0, GumpButtonType.Page, 4 + i );
|
||||
CenterItem( guardList.Definition.ItemID, 50, y - 20, 70, 60 );
|
||||
AddHtmlText( 120, y, 200, 25, guardList.Definition.Header, false, false );
|
||||
}
|
||||
|
||||
AddHtmlLocalized( 55, 360, 200, 25, 1011067, false, false ); // Previous page
|
||||
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];
|
||||
|
||||
AddPage( 4 + i );
|
||||
|
||||
AddHtmlText( 90, 30, 300, 25, guardList.Definition.Header, false, false );
|
||||
CenterItem( guardList.Definition.ItemID, 10, 10, 80, 80 );
|
||||
|
||||
AddHtmlLocalized( 20, 90, 200, 25, 1011514, false, false ); // You have :
|
||||
AddLabel( 230, 90, 0x26, guardList.Guards.Count.ToString() );
|
||||
|
||||
AddHtmlLocalized( 20, 120, 200, 25, 1011515, false, false ); // Maximum :
|
||||
AddLabel( 230, 120, 0x12A, guardList.Definition.Maximum.ToString() );
|
||||
|
||||
AddHtmlLocalized( 20, 150, 200, 25, 1011516, false, false ); // Cost :
|
||||
AddLabel( 230, 150, 0x44, guardList.Definition.Price.ToString( "N0" ) ); // NOTE: Added 'N0'
|
||||
|
||||
AddHtmlLocalized( 20, 180, 200, 25, 1011517, false, false ); // Daily Pay :
|
||||
AddLabel( 230, 180, 0x37, guardList.Definition.Upkeep.ToString( "N0" ) ); // NOTE: Added 'N0'
|
||||
|
||||
AddHtmlLocalized( 20, 210, 200, 25, 1011518, false, false ); // Current Silver :
|
||||
AddLabel( 230, 210, 0x44, town.Silver.ToString( "N0" ) ); // NOTE: Added 'N0'
|
||||
|
||||
AddHtmlLocalized( 20, 240, 200, 25, 1011519, false, false ); // Current Payroll :
|
||||
AddLabel( 230, 240, 0x44, sheriffUpkeep.ToString( "N0" ) ); // NOTE: Added 'N0'
|
||||
|
||||
AddHtmlText( 55, 300, 200, 25, guardList.Definition.Label, false, false );
|
||||
AddButton( 20, 300, 4005, 4007, 1 + i, GumpButtonType.Reply, 0 );
|
||||
|
||||
AddHtmlLocalized( 55, 360, 200, 25, 1011067, false, false ); // Previous page
|
||||
AddButton( 20, 360, 4005, 4007, 0, GumpButtonType.Page, 3 );
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
public override void OnResponse( NetState sender, RelayInfo info )
|
||||
{
|
||||
if ( !m_Town.IsSheriff( m_From ) || m_Town.Owner != m_Faction )
|
||||
{
|
||||
m_From.SendLocalizedMessage( 1010339 ); // You no longer control this city
|
||||
return;
|
||||
}
|
||||
|
||||
int index = info.ButtonID - 1;
|
||||
|
||||
if ( index >= 0 && index < m_Town.GuardLists.Count )
|
||||
{
|
||||
GuardList guardList = m_Town.GuardLists[index];
|
||||
Town town = Town.FromRegion( m_From.Region );
|
||||
|
||||
if ( Town.FromRegion( m_From.Region ) != m_Town )
|
||||
{
|
||||
m_From.SendLocalizedMessage( 1010305 ); // You must be in your controlled city to buy Items
|
||||
}
|
||||
else if ( guardList.Guards.Count >= guardList.Definition.Maximum )
|
||||
{
|
||||
m_From.SendLocalizedMessage( 1010306 ); // You currently have too many of this enhancement type to place another
|
||||
}
|
||||
else if ( BaseBoat.FindBoatAt( m_From.Location, m_From.Map ) != null ) {
|
||||
m_From.SendMessage( "You cannot place a guard here" );
|
||||
}
|
||||
else if ( m_Town.Silver >= guardList.Definition.Price )
|
||||
{
|
||||
BaseFactionGuard guard = guardList.Construct();
|
||||
|
||||
if ( guard != null )
|
||||
{
|
||||
guard.Faction = m_Faction;
|
||||
guard.Town = m_Town;
|
||||
|
||||
m_Town.Silver -= guardList.Definition.Price;
|
||||
|
||||
guard.MoveToWorld( m_From.Location, m_From.Map );
|
||||
guard.Home = guard.Location;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
206
Scripts/Engines/Factions/Gumps/TownStoneGump.cs
Normal file
206
Scripts/Engines/Factions/Gumps/TownStoneGump.cs
Normal file
|
|
@ -0,0 +1,206 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
using Server.Targeting;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class TownStoneGump : FactionGump
|
||||
{
|
||||
private PlayerMobile m_From;
|
||||
private Faction m_Faction;
|
||||
private Town m_Town;
|
||||
|
||||
public TownStoneGump( PlayerMobile from, Faction faction, Town town ) : base( 50, 50 )
|
||||
{
|
||||
m_From = from;
|
||||
m_Faction = faction;
|
||||
m_Town = town;
|
||||
|
||||
AddPage( 0 );
|
||||
|
||||
AddBackground( 0, 0, 320, 250, 5054 );
|
||||
AddBackground( 10, 10, 300, 230, 3000 );
|
||||
|
||||
AddHtmlText( 25, 30, 250, 25, town.Definition.TownStoneHeader, false, false );
|
||||
|
||||
AddHtmlLocalized( 55, 60, 150, 25, 1011557, false, false ); // Hire Sheriff
|
||||
AddButton( 20, 60, 4005, 4007, 1, GumpButtonType.Reply, 0 );
|
||||
|
||||
AddHtmlLocalized( 55, 90, 150, 25, 1011559, false, false ); // Hire Finance Minister
|
||||
AddButton( 20, 90, 4005, 4007, 2, GumpButtonType.Reply, 0 );
|
||||
|
||||
AddHtmlLocalized( 55, 120, 150, 25, 1011558, false, false ); // Fire Sheriff
|
||||
AddButton( 20, 120, 4005, 4007, 3, GumpButtonType.Reply, 0 );
|
||||
|
||||
AddHtmlLocalized( 55, 150, 150, 25, 1011560, false, false ); // Fire Finance Minister
|
||||
AddButton( 20, 150, 4005, 4007, 4, GumpButtonType.Reply, 0 );
|
||||
|
||||
AddHtmlLocalized( 55, 210, 150, 25, 1011441, false, false ); // EXIT
|
||||
AddButton( 20, 210, 4005, 4007, 0, GumpButtonType.Reply, 0 );
|
||||
}
|
||||
|
||||
public override void OnResponse( NetState sender, RelayInfo info )
|
||||
{
|
||||
if ( m_Town.Owner != m_Faction || !m_Faction.IsCommander( m_From ) )
|
||||
{
|
||||
m_From.SendLocalizedMessage( 1010339 ); // You no longer control this city
|
||||
return;
|
||||
}
|
||||
|
||||
switch ( info.ButtonID )
|
||||
{
|
||||
case 1: // hire sheriff
|
||||
{
|
||||
if ( m_Town.Sheriff != null )
|
||||
{
|
||||
m_From.SendLocalizedMessage( 1010342 ); // You must fire your Sheriff before you can elect a new one
|
||||
}
|
||||
else
|
||||
{
|
||||
m_From.SendLocalizedMessage( 1010347 ); // Who shall be your new sheriff
|
||||
m_From.BeginTarget( 12, false, TargetFlags.None, new TargetCallback( HireSheriff_OnTarget ) );
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 2: // hire finance minister
|
||||
{
|
||||
if ( m_Town.Finance != null )
|
||||
{
|
||||
m_From.SendLocalizedMessage( 1010345 ); // You must fire your finance minister before you can elect a new one
|
||||
}
|
||||
else
|
||||
{
|
||||
m_From.SendLocalizedMessage( 1010348 ); // Who shall be your new Minister of Finances?
|
||||
m_From.BeginTarget( 12, false, TargetFlags.None, new TargetCallback( HireFinanceMinister_OnTarget ) );
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 3: // fire sheriff
|
||||
{
|
||||
if ( m_Town.Sheriff == null )
|
||||
{
|
||||
m_From.SendLocalizedMessage( 1010350 ); // You need to elect a sheriff before you can fire one
|
||||
}
|
||||
else
|
||||
{
|
||||
m_From.SendLocalizedMessage( 1010349 ); // You have fired your sheriff
|
||||
m_Town.Sheriff.SendLocalizedMessage( 1010270 ); // You have been fired as Sheriff
|
||||
m_Town.Sheriff = null;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 4: // fire finance minister
|
||||
{
|
||||
if ( m_Town.Finance == null )
|
||||
{
|
||||
m_From.SendLocalizedMessage( 1010352 ); // You need to elect a financial minister before you can fire one
|
||||
}
|
||||
else
|
||||
{
|
||||
m_From.SendLocalizedMessage( 1010351 ); // You have fired your financial Minister
|
||||
m_Town.Finance.SendLocalizedMessage( 1010151 ); // You have been fired as Finance Minister
|
||||
m_Town.Finance = null;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void HireSheriff_OnTarget( Mobile from, object obj )
|
||||
{
|
||||
if ( m_Town.Owner != m_Faction || !m_Faction.IsCommander( from ) )
|
||||
{
|
||||
from.SendLocalizedMessage( 1010339 ); // You no longer control this city
|
||||
return;
|
||||
}
|
||||
else if ( 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 != m_Faction )
|
||||
{
|
||||
from.SendLocalizedMessage( 1010338 ); // You must pick someone in the correct faction
|
||||
}
|
||||
else if ( 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
|
||||
{
|
||||
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 ( m_Town.Owner != m_Faction || !m_Faction.IsCommander( from ) )
|
||||
{
|
||||
from.SendLocalizedMessage( 1010339 ); // You no longer control this city
|
||||
return;
|
||||
}
|
||||
else if ( 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 != m_Faction )
|
||||
{
|
||||
from.SendLocalizedMessage( 1010338 ); // You must pick someone in the correct faction
|
||||
}
|
||||
else if ( 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
|
||||
{
|
||||
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!
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
68
Scripts/Engines/Factions/Gumps/VoteGump.cs
Normal file
68
Scripts/Engines/Factions/Gumps/VoteGump.cs
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class VoteGump : FactionGump
|
||||
{
|
||||
private PlayerMobile m_From;
|
||||
private Election m_Election;
|
||||
|
||||
public override void OnResponse( NetState sender, RelayInfo info )
|
||||
{
|
||||
if ( info.ButtonID == 0 )
|
||||
{
|
||||
m_From.SendGump( new FactionStoneGump( m_From, m_Election.Faction ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !m_Election.CanVote( m_From ) )
|
||||
return;
|
||||
|
||||
int index = info.ButtonID - 1;
|
||||
|
||||
if ( index >= 0 && index < m_Election.Candidates.Count )
|
||||
m_Election.Candidates[index].Voters.Add( new Voter( m_From, m_Election.Candidates[index].Mobile ) );
|
||||
|
||||
m_From.SendGump( new VoteGump( m_From, m_Election ) );
|
||||
}
|
||||
}
|
||||
|
||||
public VoteGump( PlayerMobile from, Election election ) : base( 50, 50 )
|
||||
{
|
||||
m_From = from;
|
||||
m_Election = election;
|
||||
|
||||
bool canVote = election.CanVote( from );
|
||||
|
||||
AddPage( 0 );
|
||||
|
||||
AddBackground( 0, 0, 420, 350, 5054 );
|
||||
AddBackground( 10, 10, 400, 330, 3000 );
|
||||
|
||||
AddHtmlText( 20, 20, 380, 20, election.Faction.Definition.Header, false, false );
|
||||
|
||||
if ( canVote )
|
||||
AddHtmlLocalized( 20, 60, 380, 20, 1011428, false, false ); // VOTE FOR LEADERSHIP
|
||||
else
|
||||
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 )
|
||||
AddButton( 20, 100 + (i * 20), 4005, 4007, i + 1, GumpButtonType.Reply, 0 );
|
||||
|
||||
AddLabel( 55, 100 + (i * 20), 0, cd.Mobile.Name );
|
||||
AddLabel( 300, 100 + (i * 20), 0, cd.Votes.ToString() );
|
||||
}
|
||||
|
||||
AddButton( 20, 310, 4005, 4007, 0, GumpButtonType.Reply, 0 );
|
||||
AddHtmlLocalized( 55, 310, 100, 20, 1011012, false, false ); // CANCEL
|
||||
}
|
||||
}
|
||||
}
|
||||
107
Scripts/Engines/Factions/Instances/Factions/CouncilOfMages.cs
Normal file
107
Scripts/Engines/Factions/Instances/Factions/CouncilOfMages.cs
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
using System;
|
||||
using Server;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class CouncilOfMages : Faction
|
||||
{
|
||||
private static Faction m_Instance;
|
||||
|
||||
public static Faction Instance{ get{ return m_Instance; } }
|
||||
|
||||
public CouncilOfMages()
|
||||
{
|
||||
m_Instance = 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." ),
|
||||
// Moonglow
|
||||
new StrongholdDefinition(
|
||||
new Rectangle2D[]
|
||||
{
|
||||
new Rectangle2D( 4463, 1487, 15, 35 ),
|
||||
new Rectangle2D( 4450, 1522, 35, 48 ),
|
||||
},
|
||||
new Point3D( 4469, 1486, 0 ),
|
||||
new Point3D( 4457, 1544, 0 ),
|
||||
new Point3D[]
|
||||
{
|
||||
new Point3D( 4464, 1534, 21 ),
|
||||
new Point3D( 4470, 1536, 21 ),
|
||||
new Point3D( 4468, 1534, 21 ),
|
||||
new Point3D( 4470, 1534, 21 ),
|
||||
new Point3D( 4468, 1536, 21 ),
|
||||
new Point3D( 4466, 1534, 21 ),
|
||||
new Point3D( 4466, 1536, 21 ),
|
||||
new Point3D( 4464, 1536, 21 )
|
||||
} ),
|
||||
// Magincia
|
||||
/* 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 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" ) ),
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
84
Scripts/Engines/Factions/Instances/Factions/Minax.cs
Normal file
84
Scripts/Engines/Factions/Instances/Factions/Minax.cs
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
using System;
|
||||
using Server;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class Minax : Faction
|
||||
{
|
||||
private static Faction m_Instance;
|
||||
|
||||
public static Faction Instance{ get{ return m_Instance; } }
|
||||
|
||||
public Minax()
|
||||
{
|
||||
m_Instance = 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 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" ) ),
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
84
Scripts/Engines/Factions/Instances/Factions/Shadowlords.cs
Normal file
84
Scripts/Engines/Factions/Instances/Factions/Shadowlords.cs
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
using System;
|
||||
using Server;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class Shadowlords : Faction
|
||||
{
|
||||
private static Faction m_Instance;
|
||||
|
||||
public static Faction Instance{ get{ return m_Instance; } }
|
||||
|
||||
public Shadowlords()
|
||||
{
|
||||
m_Instance = 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 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" ) ),
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
using System;
|
||||
using Server;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class TrueBritannians : Faction
|
||||
{
|
||||
private static Faction m_Instance;
|
||||
|
||||
public static Faction Instance{ get{ return m_Instance; } }
|
||||
|
||||
public TrueBritannians()
|
||||
{
|
||||
m_Instance = 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 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" ) ),
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
26
Scripts/Engines/Factions/Instances/Towns/Britain.cs
Normal file
26
Scripts/Engines/Factions/Instances/Towns/Britain.cs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class Britain : Town
|
||||
{
|
||||
public Britain()
|
||||
{
|
||||
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/Engines/Factions/Instances/Towns/Magincia.cs
Normal file
26
Scripts/Engines/Factions/Instances/Towns/Magincia.cs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class Magincia : Town
|
||||
{
|
||||
public Magincia()
|
||||
{
|
||||
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/Engines/Factions/Instances/Towns/Minoc.cs
Normal file
26
Scripts/Engines/Factions/Instances/Towns/Minoc.cs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class Minoc : Town
|
||||
{
|
||||
public Minoc()
|
||||
{
|
||||
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/Engines/Factions/Instances/Towns/Moonglow.cs
Normal file
26
Scripts/Engines/Factions/Instances/Towns/Moonglow.cs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class Moonglow : Town
|
||||
{
|
||||
public Moonglow()
|
||||
{
|
||||
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/Engines/Factions/Instances/Towns/SkaraBrae.cs
Normal file
26
Scripts/Engines/Factions/Instances/Towns/SkaraBrae.cs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class SkaraBrae : Town
|
||||
{
|
||||
public SkaraBrae()
|
||||
{
|
||||
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/Engines/Factions/Instances/Towns/Trinsic.cs
Normal file
26
Scripts/Engines/Factions/Instances/Towns/Trinsic.cs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class Trinsic : Town
|
||||
{
|
||||
public Trinsic()
|
||||
{
|
||||
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/Engines/Factions/Instances/Towns/Vesper.cs
Normal file
26
Scripts/Engines/Factions/Instances/Towns/Vesper.cs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class Vesper : Town
|
||||
{
|
||||
public Vesper()
|
||||
{
|
||||
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/Engines/Factions/Instances/Towns/Yew.cs
Normal file
26
Scripts/Engines/Factions/Instances/Towns/Yew.cs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class Yew : Town
|
||||
{
|
||||
public Yew()
|
||||
{
|
||||
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 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
136
Scripts/Engines/Factions/Items/BaseMonolith.cs
Normal file
136
Scripts/Engines/Factions/Items/BaseMonolith.cs
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public abstract class BaseMonolith : BaseSystemController
|
||||
{
|
||||
private Town m_Town;
|
||||
private Faction m_Faction;
|
||||
private Sigil m_Sigil;
|
||||
|
||||
[CommandProperty( AccessLevel.Counselor, AccessLevel.Administrator )]
|
||||
public Sigil Sigil
|
||||
{
|
||||
get{ return m_Sigil; }
|
||||
set
|
||||
{
|
||||
if ( m_Sigil == value )
|
||||
return;
|
||||
|
||||
m_Sigil = value;
|
||||
|
||||
if ( m_Sigil != null && m_Sigil.LastMonolith != null && m_Sigil.LastMonolith != this && m_Sigil.LastMonolith.Sigil == m_Sigil )
|
||||
m_Sigil.LastMonolith.Sigil = null;
|
||||
|
||||
if ( m_Sigil != null )
|
||||
m_Sigil.LastMonolith = this;
|
||||
|
||||
UpdateSigil();
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.Counselor, AccessLevel.Administrator )]
|
||||
public Town Town
|
||||
{
|
||||
get{ return m_Town; }
|
||||
set
|
||||
{
|
||||
m_Town = value;
|
||||
OnTownChanged();
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.Counselor, AccessLevel.Administrator )]
|
||||
public Faction Faction
|
||||
{
|
||||
get{ return m_Faction; }
|
||||
set
|
||||
{
|
||||
m_Faction = value;
|
||||
Hue = ( m_Faction == null ? 0 : m_Faction.Definition.HuePrimary );
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnLocationChange( Point3D oldLocation )
|
||||
{
|
||||
base.OnLocationChange( oldLocation );
|
||||
UpdateSigil();
|
||||
}
|
||||
|
||||
public override void OnMapChange()
|
||||
{
|
||||
base.OnMapChange();
|
||||
UpdateSigil();
|
||||
}
|
||||
|
||||
public virtual void UpdateSigil()
|
||||
{
|
||||
if ( m_Sigil == null || m_Sigil.Deleted )
|
||||
return;
|
||||
|
||||
m_Sigil.MoveToWorld( new Point3D( X, Y, Z + 18 ), Map );
|
||||
}
|
||||
|
||||
public virtual void OnTownChanged()
|
||||
{
|
||||
}
|
||||
|
||||
public BaseMonolith( Town town, Faction faction ) : base( 0x1183 )
|
||||
{
|
||||
Movable = false;
|
||||
Town = town;
|
||||
Faction = faction;
|
||||
m_Monoliths.Add( this );
|
||||
}
|
||||
|
||||
public BaseMonolith( Serial serial ) : base( serial )
|
||||
{
|
||||
m_Monoliths.Add( this );
|
||||
}
|
||||
|
||||
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, m_Town );
|
||||
Faction.WriteReference( writer, m_Faction );
|
||||
|
||||
writer.Write( (Item) m_Sigil );
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
Town = Town.ReadReference( reader );
|
||||
Faction = Faction.ReadReference( reader );
|
||||
m_Sigil = reader.ReadItem() as Sigil;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static List<BaseMonolith> m_Monoliths = new List<BaseMonolith>();
|
||||
|
||||
public static List<BaseMonolith> Monoliths
|
||||
{
|
||||
get{ return m_Monoliths; }
|
||||
set{ m_Monoliths = value; }
|
||||
}
|
||||
}
|
||||
}
|
||||
66
Scripts/Engines/Factions/Items/BaseSystemController.cs
Normal file
66
Scripts/Engines/Factions/Items/BaseSystemController.cs
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public abstract class BaseSystemController : Item
|
||||
{
|
||||
private int m_LabelNumber;
|
||||
|
||||
public virtual int DefaultLabelNumber{ get{ return base.LabelNumber; } }
|
||||
public new virtual string DefaultName{ get{ return null; } }
|
||||
|
||||
public override int LabelNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
if ( m_LabelNumber > 0 )
|
||||
return m_LabelNumber;
|
||||
|
||||
return DefaultLabelNumber;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void AssignName( TextDefinition name )
|
||||
{
|
||||
if ( name != null && name.Number > 0 )
|
||||
{
|
||||
m_LabelNumber = name.Number;
|
||||
Name = null;
|
||||
}
|
||||
else if ( name != null && name.String != null )
|
||||
{
|
||||
m_LabelNumber = 0;
|
||||
Name = name.String;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_LabelNumber = 0;
|
||||
Name = DefaultName;
|
||||
}
|
||||
|
||||
InvalidateProperties();
|
||||
}
|
||||
|
||||
public BaseSystemController( int itemID ) : base( itemID )
|
||||
{
|
||||
}
|
||||
|
||||
public BaseSystemController( 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
105
Scripts/Engines/Factions/Items/FactionStone.cs
Normal file
105
Scripts/Engines/Factions/Items/FactionStone.cs
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionStone : BaseSystemController
|
||||
{
|
||||
private Faction m_Faction;
|
||||
|
||||
[CommandProperty( AccessLevel.Counselor, AccessLevel.Administrator )]
|
||||
public Faction Faction
|
||||
{
|
||||
get{ return m_Faction; }
|
||||
set
|
||||
{
|
||||
m_Faction = value;
|
||||
|
||||
AssignName( m_Faction == null ? null : m_Faction.Definition.FactionStoneName );
|
||||
}
|
||||
}
|
||||
|
||||
public override string DefaultName { get { return "faction stone"; } }
|
||||
|
||||
[Constructable]
|
||||
public FactionStone() : this( null )
|
||||
{
|
||||
}
|
||||
|
||||
[Constructable]
|
||||
public FactionStone( Faction faction ) : base( 0xEDC )
|
||||
{
|
||||
Movable = false;
|
||||
Faction = faction;
|
||||
}
|
||||
|
||||
public override void OnDoubleClick( Mobile from )
|
||||
{
|
||||
if ( m_Faction == null )
|
||||
return;
|
||||
|
||||
if ( !from.InRange( GetWorldLocation(), 2 ) )
|
||||
{
|
||||
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that.
|
||||
}
|
||||
else if ( FactionGump.Exists( from ) )
|
||||
{
|
||||
from.SendLocalizedMessage( 1042160 ); // You already have a faction menu open.
|
||||
}
|
||||
else if ( from is PlayerMobile )
|
||||
{
|
||||
Faction existingFaction = Faction.Find( from );
|
||||
|
||||
if ( existingFaction == 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, m_Faction ) );
|
||||
}
|
||||
else if ( existingFaction != null )
|
||||
{
|
||||
// TODO: Validate
|
||||
from.SendLocalizedMessage( 1005053 ); // This is not your faction stone!
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendGump( new JoinStoneGump( (PlayerMobile) from, m_Faction ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public FactionStone( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.Write( (int) 0 ); // version
|
||||
|
||||
Faction.WriteReference( writer, m_Faction );
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
Faction = Faction.ReadReference( reader );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
81
Scripts/Engines/Factions/Items/JoinStone.cs
Normal file
81
Scripts/Engines/Factions/Items/JoinStone.cs
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class JoinStone : BaseSystemController
|
||||
{
|
||||
private Faction m_Faction;
|
||||
|
||||
[CommandProperty( AccessLevel.Counselor, AccessLevel.Administrator )]
|
||||
public Faction Faction
|
||||
{
|
||||
get{ return m_Faction; }
|
||||
set
|
||||
{
|
||||
m_Faction = value;
|
||||
|
||||
Hue = ( m_Faction == null ? 0 : m_Faction.Definition.HueJoin );
|
||||
AssignName( m_Faction == null ? null : m_Faction.Definition.SignupName );
|
||||
}
|
||||
}
|
||||
|
||||
public override string DefaultName { get { return "faction signup stone"; } }
|
||||
|
||||
[Constructable]
|
||||
public JoinStone() : this( null )
|
||||
{
|
||||
}
|
||||
|
||||
[Constructable]
|
||||
public JoinStone( Faction faction ) : base( 0xEDC )
|
||||
{
|
||||
Movable = false;
|
||||
Faction = faction;
|
||||
}
|
||||
|
||||
public override void OnDoubleClick( Mobile from )
|
||||
{
|
||||
if ( m_Faction == null )
|
||||
return;
|
||||
|
||||
if ( !from.InRange( GetWorldLocation(), 2 ) )
|
||||
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that.
|
||||
else if ( FactionGump.Exists( from ) )
|
||||
from.SendLocalizedMessage( 1042160 ); // You already have a faction menu open.
|
||||
else if ( Faction.Find( from ) == null && from is PlayerMobile )
|
||||
from.SendGump( new JoinStoneGump( (PlayerMobile) from, m_Faction ) );
|
||||
}
|
||||
|
||||
public JoinStone( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.Write( (int) 0 ); // version
|
||||
|
||||
Faction.WriteReference( writer, m_Faction );
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
Faction = Faction.ReadReference( reader );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using Server;
|
||||
using Server.Mobiles;
|
||||
using Server.Factions;
|
||||
|
||||
namespace Server {
|
||||
public sealed class BloodRose : PowerFactionItem {
|
||||
public override string DefaultName {
|
||||
get {
|
||||
return "blood rose";
|
||||
}
|
||||
}
|
||||
|
||||
public BloodRose()
|
||||
: base( Utility.RandomList( 6378, 9035 ) ) {
|
||||
Hue = 2118;
|
||||
}
|
||||
|
||||
public BloodRose( Serial serial )
|
||||
: base( serial ) {
|
||||
}
|
||||
|
||||
public override bool Use( Mobile from ) {
|
||||
if ( from.GetStatMod( "blood-rose" ) == null ) {
|
||||
from.PlaySound( Utility.Random( 0x3A, 3 ) );
|
||||
|
||||
if ( from.Body.IsHuman && !from.Mounted ) {
|
||||
from.Animate( 34, 5, 1, true, false, 0 );
|
||||
}
|
||||
|
||||
int amount = Utility.Dice( 3, 3, 3 );
|
||||
int time = Utility.RandomMinMax( 5, 30 );
|
||||
|
||||
from.FixedParticles( 0x373A, 10, 15, 5018, EffectLayer.Waist );
|
||||
|
||||
from.PlaySound( 0x1EE );
|
||||
from.AddStatMod( new StatMod( StatType.All, "blood-rose", amount, TimeSpan.FromMinutes( time ) ) );
|
||||
|
||||
return true;
|
||||
} else {
|
||||
from.SendLocalizedMessage( 1062927 ); // You have eaten one of these recently and eating another would provide no benefit.
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer ) {
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.WriteEncodedInt( ( int ) 0 ); // version
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader ) {
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadEncodedInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
using Server.Multis;
|
||||
using Server.Mobiles;
|
||||
using Server.Factions;
|
||||
|
||||
namespace Server {
|
||||
public sealed class ClarityPotion : PowerFactionItem {
|
||||
public override string DefaultName {
|
||||
get {
|
||||
return "clarity potion";
|
||||
}
|
||||
}
|
||||
|
||||
public ClarityPotion()
|
||||
: base( 3628 ) {
|
||||
Hue = 1154;
|
||||
}
|
||||
|
||||
public ClarityPotion( Serial serial )
|
||||
: base( serial ) {
|
||||
}
|
||||
|
||||
public override bool Use( Mobile from ) {
|
||||
if ( from.BeginAction( typeof( ClarityPotion ) ) ) {
|
||||
int amount = Utility.Dice( 3, 3, 3 );
|
||||
int time = Utility.RandomMinMax( 5, 30 );
|
||||
|
||||
from.PlaySound( 0x2D6 );
|
||||
|
||||
if ( from.Body.IsHuman ) {
|
||||
from.Animate( 34, 5, 1, true, false, 0 );
|
||||
}
|
||||
|
||||
from.FixedParticles( 0x375A, 10, 15, 5011, EffectLayer.Head );
|
||||
from.PlaySound( 0x1EB );
|
||||
|
||||
StatMod mod = from.GetStatMod( "Concussion" );
|
||||
|
||||
if ( mod != null ) {
|
||||
from.RemoveStatMod( "Concussion" );
|
||||
from.Mana -= mod.Offset;
|
||||
}
|
||||
|
||||
from.PlaySound( 0x1EE );
|
||||
from.AddStatMod( new StatMod( StatType.Int, "clarity-potion", amount, TimeSpan.FromMinutes( time ) ) );
|
||||
|
||||
Timer.DelayCall( TimeSpan.FromMinutes( time ), delegate() {
|
||||
from.EndAction( typeof( ClarityPotion ) );
|
||||
} );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer ) {
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.WriteEncodedInt( ( int ) 0 ); // version
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader ) {
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadEncodedInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
using Server.Multis;
|
||||
using Server.Mobiles;
|
||||
using Server.Factions;
|
||||
|
||||
namespace Server {
|
||||
public sealed class GemOfEmpowerment : PowerFactionItem {
|
||||
public override string DefaultName {
|
||||
get {
|
||||
return "gem of empowerment";
|
||||
}
|
||||
}
|
||||
|
||||
public GemOfEmpowerment()
|
||||
: base( 7955 ) {
|
||||
Hue = 1154;
|
||||
}
|
||||
|
||||
public GemOfEmpowerment( Serial serial )
|
||||
: base( serial ) {
|
||||
}
|
||||
|
||||
public override bool Use( Mobile from ) {
|
||||
if ( Faction.ClearSkillLoss( from ) ) {
|
||||
from.LocalOverheadMessage( Server.Network.MessageType.Regular, 2219, false, "The gem shatters as you invoke its power." );
|
||||
from.PlaySound( 909 );
|
||||
|
||||
from.FixedEffect( 0x373A, 10, 30 );
|
||||
from.PlaySound( 0x209 );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer ) {
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.WriteEncodedInt( ( int ) 0 ); // version
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader ) {
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadEncodedInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,165 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using Server;
|
||||
using Server.Mobiles;
|
||||
using Server.Factions;
|
||||
using System.IO;
|
||||
|
||||
namespace Server {
|
||||
public abstract class PowerFactionItem : Item {
|
||||
public abstract bool Use( Mobile mob );
|
||||
|
||||
private sealed class DestructionTimer : Timer {
|
||||
private Mobile _mobile;
|
||||
|
||||
private bool _screamed;
|
||||
|
||||
public DestructionTimer( Mobile mob )
|
||||
: base( TimeSpan.FromSeconds( 5 ), TimeSpan.FromSeconds( 0.1 ), 10 ) {
|
||||
_mobile = mob;
|
||||
}
|
||||
|
||||
protected override void OnTick() {
|
||||
if ( _mobile.Alive ) {
|
||||
if ( !_screamed ) {
|
||||
_screamed = true;
|
||||
|
||||
_mobile.PlaySound( _mobile.Female ? 814 : 1088 );
|
||||
_mobile.PublicOverheadMessage( Server.Network.MessageType.Regular, 2118, false, "Aaaaah!" );
|
||||
}
|
||||
|
||||
_mobile.Damage( Utility.Dice( 2, 6, 0 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class WeightedItem {
|
||||
private int _weight;
|
||||
private Type _type;
|
||||
|
||||
public int Weight {
|
||||
get {
|
||||
return _weight;
|
||||
}
|
||||
}
|
||||
|
||||
public Type Type {
|
||||
get {
|
||||
return _type;
|
||||
}
|
||||
}
|
||||
|
||||
public WeightedItem( int weight, Type type ) {
|
||||
_weight = weight;
|
||||
_type = type;
|
||||
}
|
||||
|
||||
public Item Construct() {
|
||||
return Activator.CreateInstance( _type ) as Item;
|
||||
}
|
||||
}
|
||||
|
||||
private static WeightedItem[] _items = {
|
||||
new WeightedItem( 30, typeof( GemOfEmpowerment ) ),
|
||||
new WeightedItem( 25, typeof( BloodRose ) ),
|
||||
new WeightedItem( 20, typeof( ClarityPotion ) ),
|
||||
new WeightedItem( 15, typeof( UrnOfAscension ) ),
|
||||
new WeightedItem( 10, typeof( StormsEye ) )
|
||||
};
|
||||
|
||||
public static void CheckSpawn( Mobile killer, Mobile victim ) {
|
||||
if ( killer != null && victim != null ) {
|
||||
PlayerState ps = PlayerState.Find( victim );
|
||||
|
||||
if ( ps != null ) {
|
||||
int chance = ps.Rank.Rank;
|
||||
|
||||
if ( chance > Utility.Random( 100 ) ) {
|
||||
int weight = 0;
|
||||
|
||||
foreach ( WeightedItem item in _items ) {
|
||||
weight += item.Weight;
|
||||
}
|
||||
|
||||
weight = Utility.Random( weight );
|
||||
|
||||
foreach ( WeightedItem item in _items ) {
|
||||
if ( weight < item.Weight ) {
|
||||
Item obj = item.Construct();
|
||||
|
||||
if ( obj != null ) {
|
||||
killer.AddToBackpack( obj );
|
||||
|
||||
killer.SendSound( 1470 );
|
||||
killer.LocalOverheadMessage(
|
||||
Server.Network.MessageType.Regular, 2119, false,
|
||||
"You notice a strange item on the corpse, and decide to pick it up."
|
||||
);
|
||||
|
||||
try {
|
||||
using ( StreamWriter op = new StreamWriter( "faction-power-items.log", true ) ) {
|
||||
op.WriteLine( "{0}\t{1}\t{2}\t{3}", DateTime.UtcNow, killer, victim, obj );
|
||||
}
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
} else {
|
||||
weight -= item.Weight;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnDoubleClick( Mobile from ) {
|
||||
if ( !IsChildOf( from.Backpack ) ) {
|
||||
from.SendLocalizedMessage( 1042038 ); // You must have the object in your backpack to use it.
|
||||
} else if ( from is PlayerMobile && ((PlayerMobile)from).DuelContext != null ) {
|
||||
from.SendMessage( "You can't use that." );
|
||||
} else if ( Faction.Find( from ) == null ) {
|
||||
from.LocalOverheadMessage( Server.Network.MessageType.Regular, 2119, false, "The object vanishes from your hands as you touch it." );
|
||||
|
||||
Timer.DelayCall( TimeSpan.FromSeconds( 1.0 ), delegate() {
|
||||
from.LocalOverheadMessage( Server.Network.MessageType.Regular, 2118, false, "You feel a strange tingling sensation throughout your body." );
|
||||
} );
|
||||
|
||||
Timer.DelayCall( TimeSpan.FromSeconds( 4.0 ), delegate() {
|
||||
from.LocalOverheadMessage( Server.Network.MessageType.Regular, 2118, false, "Your skin begins to burn." );
|
||||
} );
|
||||
|
||||
new DestructionTimer( from ).Start();
|
||||
Delete();
|
||||
|
||||
//from.SendMessage( "You must be in a faction to use this item." );
|
||||
} else if ( Use( from ) ) {
|
||||
from.RevealingAction();
|
||||
Consume();
|
||||
}
|
||||
}
|
||||
|
||||
public PowerFactionItem( int itemId )
|
||||
: base( itemId ) {
|
||||
}
|
||||
|
||||
public PowerFactionItem( Serial serial )
|
||||
: base( serial ) {
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer ) {
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.WriteEncodedInt( ( int ) 0 ); // version
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader ) {
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadEncodedInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
118
Scripts/Engines/Factions/Items/Power Faction Items/StormsEye.cs
Normal file
118
Scripts/Engines/Factions/Items/Power Faction Items/StormsEye.cs
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using Server;
|
||||
using Server.Spells;
|
||||
using Server.Gumps;
|
||||
using Server.Multis;
|
||||
using Server.Mobiles;
|
||||
using Server.Factions;
|
||||
|
||||
namespace Server {
|
||||
public sealed class StormsEye : PowerFactionItem {
|
||||
public override string DefaultName {
|
||||
get {
|
||||
return "storms eye";
|
||||
}
|
||||
}
|
||||
|
||||
public StormsEye()
|
||||
: base( 3967 ) {
|
||||
Hue = 1165;
|
||||
}
|
||||
|
||||
public StormsEye( Serial serial )
|
||||
: base( serial ) {
|
||||
}
|
||||
|
||||
public override bool Use( Mobile user ) {
|
||||
if ( this.Movable ) {
|
||||
user.BeginTarget( 12, true, Server.Targeting.TargetFlags.None, delegate( Mobile from, object obj ) {
|
||||
if ( this.Movable && !this.Deleted ) {
|
||||
IPoint3D pt = obj as IPoint3D;
|
||||
|
||||
if ( pt != null ) {
|
||||
SpellHelper.GetSurfaceTop( ref pt );
|
||||
|
||||
Point3D origin = new Point3D( pt );
|
||||
Map facet = from.Map;
|
||||
|
||||
if ( facet != null && facet.CanFit( pt.X, pt.Y, pt.Z, 16, false, false, true ) ) {
|
||||
this.Movable = false;
|
||||
|
||||
Effects.SendMovingEffect(
|
||||
from, new Entity( Serial.Zero, origin, facet ),
|
||||
this.ItemID & 0x3FFF, 7, 0, false, false, this.Hue - 1, 0
|
||||
);
|
||||
|
||||
Timer.DelayCall( TimeSpan.FromSeconds( 0.5 ), delegate() {
|
||||
this.Delete();
|
||||
|
||||
Effects.PlaySound( origin, facet, 530 );
|
||||
Effects.PlaySound( origin, facet, 263 );
|
||||
|
||||
Effects.SendLocationEffect(
|
||||
origin, facet,
|
||||
14284, 96, 1, 0, 2
|
||||
);
|
||||
|
||||
Timer.DelayCall( TimeSpan.FromSeconds( 1.0 ), delegate() {
|
||||
List<Mobile> targets = new List<Mobile>();
|
||||
|
||||
foreach ( Mobile mob in facet.GetMobilesInRange( origin, 12 ) ) {
|
||||
if ( from.CanBeHarmful( mob, false ) && mob.InLOS( new Point3D( origin, origin.Z + 1 ) ) ) {
|
||||
if ( Faction.Find( mob ) != null ) {
|
||||
targets.Add( mob );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( Mobile mob in targets ) {
|
||||
int damage = ( mob.Hits * 6 ) / 10;
|
||||
|
||||
if ( !mob.Player && damage < 10 ) {
|
||||
damage = 10;
|
||||
} else if ( damage > 75 ) {
|
||||
damage = 75;
|
||||
}
|
||||
|
||||
Effects.SendMovingEffect(
|
||||
new Entity( Serial.Zero, new Point3D( origin, origin.Z + 4 ), facet ), mob,
|
||||
14068, 1, 32, false, false, 1111, 2
|
||||
);
|
||||
|
||||
from.DoHarmful( mob );
|
||||
|
||||
SpellHelper.Damage( TimeSpan.FromSeconds( 0.50 ), mob, from, damage / 3, 0, 0, 0, 0, 100 );
|
||||
SpellHelper.Damage( TimeSpan.FromSeconds( 0.70 ), mob, from, damage / 3, 0, 0, 0, 0, 100 );
|
||||
SpellHelper.Damage( TimeSpan.FromSeconds( 1.00 ), mob, from, damage / 3, 0, 0, 0, 0, 100 );
|
||||
|
||||
Timer.DelayCall( TimeSpan.FromSeconds( 0.50 ), delegate() {
|
||||
mob.PlaySound( 0x1FB );
|
||||
} );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
}
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer ) {
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.WriteEncodedInt( ( int ) 0 ); // version
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader ) {
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadEncodedInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
using Server.Multis;
|
||||
using Server.Mobiles;
|
||||
using Server.Factions;
|
||||
|
||||
namespace Server {
|
||||
public sealed class UrnOfAscension : PowerFactionItem {
|
||||
public override string DefaultName {
|
||||
get {
|
||||
return "urn of ascension";
|
||||
}
|
||||
}
|
||||
|
||||
public UrnOfAscension()
|
||||
: base( 9246 ) {
|
||||
}
|
||||
|
||||
public UrnOfAscension( Serial serial )
|
||||
: base( serial ) {
|
||||
}
|
||||
|
||||
public override bool Use( Mobile from ) {
|
||||
Faction ourFaction = Faction.Find( from );
|
||||
|
||||
bool used = false;
|
||||
|
||||
foreach ( Mobile mob in from.GetMobilesInRange( 8 ) ) {
|
||||
if ( mob.Player && !mob.Alive && from.InLOS( mob ) ) {
|
||||
if ( Faction.Find( mob ) != ourFaction ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
BaseHouse house = BaseHouse.FindHouseAt( mob );
|
||||
|
||||
if ( house == null || ( house.IsFriend( from ) || house.IsFriend( mob ) ) ) {
|
||||
Faction.ClearSkillLoss( mob );
|
||||
|
||||
mob.SendGump( new ResurrectGump( mob, from, ResurrectMessage.Generic ) );
|
||||
used = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( used ) {
|
||||
from.LocalOverheadMessage( Server.Network.MessageType.Regular, 2219, false, "The urn shatters as you invoke its power." );
|
||||
from.PlaySound( 64 );
|
||||
|
||||
Effects.PlaySound( from.Location, from.Map, 1481 );
|
||||
}
|
||||
|
||||
return used;
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer ) {
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.WriteEncodedInt( ( int ) 0 ); // version
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader ) {
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadEncodedInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
471
Scripts/Engines/Factions/Items/Sigil.cs
Normal file
471
Scripts/Engines/Factions/Items/Sigil.cs
Normal file
|
|
@ -0,0 +1,471 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
using System.Collections.Generic;
|
||||
|
||||
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 m_LastStolen; }
|
||||
set{ m_LastStolen = value; }
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.Counselor, AccessLevel.Administrator )]
|
||||
public DateTime GraceStart
|
||||
{
|
||||
get{ return m_GraceStart; }
|
||||
set{ m_GraceStart = value; }
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.Counselor, AccessLevel.Administrator )]
|
||||
public DateTime CorruptionStart
|
||||
{
|
||||
get{ return m_CorruptionStart; }
|
||||
set{ m_CorruptionStart = value; }
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.Counselor, AccessLevel.Administrator )]
|
||||
public DateTime PurificationStart
|
||||
{
|
||||
get{ return m_PurificationStart; }
|
||||
set{ m_PurificationStart = value; }
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.Counselor, AccessLevel.Administrator )]
|
||||
public Town Town
|
||||
{
|
||||
get{ return m_Town; }
|
||||
set{ m_Town = value; Update(); }
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.Counselor, AccessLevel.Administrator )]
|
||||
public Faction Corrupted
|
||||
{
|
||||
get{ return m_Corrupted; }
|
||||
set{ m_Corrupted = value; Update(); }
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.Counselor, AccessLevel.Administrator )]
|
||||
public Faction Corrupting
|
||||
{
|
||||
get{ return m_Corrupting; }
|
||||
set{ m_Corrupting = value; Update(); }
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.Counselor, AccessLevel.Administrator )]
|
||||
public BaseMonolith LastMonolith
|
||||
{
|
||||
get{ return m_LastMonolith; }
|
||||
set{ m_LastMonolith = value; }
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.Counselor )]
|
||||
public bool IsBeingCorrupted
|
||||
{
|
||||
get{ return ( m_LastMonolith is StrongholdMonolith && m_LastMonolith.Faction == m_Corrupting && m_Corrupting != null ); }
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.Counselor )]
|
||||
public bool IsCorrupted
|
||||
{
|
||||
get{ return ( m_Corrupted != null ); }
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.Counselor )]
|
||||
public bool IsPurifying
|
||||
{
|
||||
get{ return ( m_PurificationStart != DateTime.MinValue ); }
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.Counselor )]
|
||||
public bool IsCorrupting
|
||||
{
|
||||
get{ return ( m_Corrupting != null && m_Corrupting != m_Corrupted ); }
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
ItemID = ( m_Town == null ? 0x1869 : m_Town.Definition.SigilID );
|
||||
|
||||
if ( m_Town == null )
|
||||
AssignName( null );
|
||||
else if ( IsCorrupted || IsPurifying )
|
||||
AssignName( m_Town.Definition.CorruptedSigilName );
|
||||
else
|
||||
AssignName( m_Town.Definition.SigilName );
|
||||
|
||||
InvalidateProperties();
|
||||
}
|
||||
|
||||
public override void GetProperties( ObjectPropertyList list )
|
||||
{
|
||||
base.GetProperties( list );
|
||||
|
||||
if ( IsCorrupted )
|
||||
TextDefinition.AddTo( list, m_Corrupted.Definition.SigilControl );
|
||||
else
|
||||
list.Add( 1042256 ); // This sigil is not corrupted.
|
||||
|
||||
if ( IsCorrupting )
|
||||
list.Add( 1042257 ); // This sigil is in the process of being corrupted.
|
||||
else if ( IsPurifying )
|
||||
list.Add( 1042258 ); // This sigil has recently been corrupted, and is undergoing purification.
|
||||
else
|
||||
list.Add( 1042259 ); // This sigil is not in the process of being corrupted.
|
||||
}
|
||||
|
||||
public override void OnSingleClick( Mobile from )
|
||||
{
|
||||
base.OnSingleClick( from );
|
||||
|
||||
if ( IsCorrupted )
|
||||
{
|
||||
if ( m_Corrupted.Definition.SigilControl.Number > 0 )
|
||||
LabelTo( from, m_Corrupted.Definition.SigilControl.Number );
|
||||
else if ( m_Corrupted.Definition.SigilControl.String != null )
|
||||
LabelTo( from, m_Corrupted.Definition.SigilControl.String );
|
||||
}
|
||||
else
|
||||
{
|
||||
LabelTo( from, 1042256 ); // This sigil is not corrupted.
|
||||
}
|
||||
|
||||
if ( IsCorrupting )
|
||||
LabelTo( from, 1042257 ); // This sigil is in the process of being corrupted.
|
||||
else if ( IsPurifying )
|
||||
LabelTo( from, 1042258 ); // This sigil has been recently corrupted, and is undergoing purification.
|
||||
else
|
||||
LabelTo( from, 1042259 ); // This sigil is not in the process of being corrupted.
|
||||
}
|
||||
|
||||
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(IEntity parent)
|
||||
{
|
||||
base.OnAdded( parent );
|
||||
|
||||
Mobile mob = FindOwner( parent );
|
||||
|
||||
if ( mob != null )
|
||||
mob.SolidHueOverride = OwnershipHue;
|
||||
}
|
||||
|
||||
public override void OnRemoved(IEntity parent)
|
||||
{
|
||||
base.OnRemoved( parent );
|
||||
|
||||
Mobile mob = FindOwner( parent );
|
||||
|
||||
if ( mob != null )
|
||||
mob.SolidHueOverride = -1;
|
||||
}
|
||||
|
||||
public Sigil( Town town ) : base( 0x1869 )
|
||||
{
|
||||
Movable = false;
|
||||
Town = town;
|
||||
|
||||
m_Sigils.Add( this );
|
||||
}
|
||||
|
||||
public override void OnDoubleClick( Mobile from )
|
||||
{
|
||||
if ( 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 )
|
||||
{
|
||||
Container pack = mob.Backpack;
|
||||
|
||||
return ( pack != null && pack.FindItemByType( typeof( Sigil ) ) != null );
|
||||
}
|
||||
|
||||
private void BeginCorrupting( Faction faction )
|
||||
{
|
||||
m_Corrupting = faction;
|
||||
m_CorruptionStart = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
private void ClearCorrupting()
|
||||
{
|
||||
m_Corrupting = null;
|
||||
m_CorruptionStart = DateTime.MinValue;
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public TimeSpan TimeUntilCorruption
|
||||
{
|
||||
get
|
||||
{
|
||||
if ( !IsBeingCorrupted )
|
||||
return TimeSpan.Zero;
|
||||
|
||||
TimeSpan ts = ( m_CorruptionStart + CorruptionPeriod ) - DateTime.UtcNow;
|
||||
|
||||
if ( ts < TimeSpan.Zero )
|
||||
ts = TimeSpan.Zero;
|
||||
|
||||
return ts;
|
||||
}
|
||||
}
|
||||
|
||||
private void Sigil_OnTarget( Mobile from, object obj )
|
||||
{
|
||||
if ( Deleted || !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 != m_Town )
|
||||
from.SendLocalizedMessage( 1042247 ); // That is not the correct faction monolith
|
||||
else
|
||||
{
|
||||
m.Sigil = this;
|
||||
|
||||
Faction newController = m.Faction;
|
||||
Faction oldController = m_Corrupting;
|
||||
|
||||
if ( oldController == null )
|
||||
{
|
||||
if ( m_Corrupted != newController )
|
||||
BeginCorrupting( newController );
|
||||
}
|
||||
else if ( m_GraceStart > DateTime.MinValue && (m_GraceStart + CorruptionGrace) < DateTime.UtcNow )
|
||||
{
|
||||
if ( m_Corrupted != newController )
|
||||
BeginCorrupting( newController ); // grace time over, reset period
|
||||
else
|
||||
ClearCorrupting();
|
||||
|
||||
m_GraceStart = DateTime.MinValue;
|
||||
}
|
||||
else if ( newController == oldController )
|
||||
{
|
||||
m_GraceStart = DateTime.MinValue; // returned within grace period
|
||||
}
|
||||
else if ( m_GraceStart == DateTime.MinValue )
|
||||
{
|
||||
m_GraceStart = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
m_PurificationStart = DateTime.MinValue;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Put in Town
|
||||
else if ( obj is TownMonolith )
|
||||
{
|
||||
TownMonolith m = (TownMonolith)obj;
|
||||
|
||||
if ( m.Town == null || m.Town != m_Town )
|
||||
from.SendLocalizedMessage( 1042245 ); // This is not the correct town sigil monolith
|
||||
else if ( m_Corrupted == null || m_Corrupted != Faction.Find( from ) )
|
||||
from.SendLocalizedMessage( 1042244 ); // Your faction did not corrupt this sigil. Take it to your stronghold.
|
||||
else
|
||||
{
|
||||
m.Sigil = this;
|
||||
|
||||
m_Corrupting = null;
|
||||
m_PurificationStart = DateTime.UtcNow;
|
||||
m_CorruptionStart = DateTime.MinValue;
|
||||
|
||||
m_Town.Capture( m_Corrupted );
|
||||
m_Corrupted = null;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage( 1005224 ); // You can't use the sigil on that
|
||||
}
|
||||
|
||||
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, m_Town );
|
||||
Faction.WriteReference( writer, m_Corrupted );
|
||||
Faction.WriteReference( writer, m_Corrupting );
|
||||
|
||||
writer.Write( (Item) m_LastMonolith );
|
||||
|
||||
writer.Write( m_LastStolen );
|
||||
writer.Write( m_GraceStart );
|
||||
writer.Write( m_CorruptionStart );
|
||||
writer.Write( m_PurificationStart );
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
m_Town = Town.ReadReference( reader );
|
||||
m_Corrupted = Faction.ReadReference( reader );
|
||||
m_Corrupting = Faction.ReadReference( reader );
|
||||
|
||||
m_LastMonolith = reader.ReadItem() as BaseMonolith;
|
||||
|
||||
m_LastStolen = reader.ReadDateTime();
|
||||
m_GraceStart = reader.ReadDateTime();
|
||||
m_CorruptionStart = reader.ReadDateTime();
|
||||
m_PurificationStart = reader.ReadDateTime();
|
||||
|
||||
Update();
|
||||
|
||||
Mobile mob = RootParent as Mobile;
|
||||
|
||||
if ( mob != null )
|
||||
mob.SolidHueOverride = OwnershipHue;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool ReturnHome()
|
||||
{
|
||||
BaseMonolith monolith = m_LastMonolith;
|
||||
|
||||
if ( monolith == null && m_Town != null )
|
||||
monolith = m_Town.Monolith;
|
||||
|
||||
if ( monolith != null && !monolith.Deleted )
|
||||
monolith.Sigil = this;
|
||||
|
||||
return ( monolith != null && !monolith.Deleted );
|
||||
}
|
||||
|
||||
public override void OnParentDeleted(IEntity parent)
|
||||
{
|
||||
base.OnParentDeleted( parent );
|
||||
|
||||
ReturnHome();
|
||||
}
|
||||
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
base.OnAfterDelete();
|
||||
|
||||
m_Sigils.Remove( this );
|
||||
}
|
||||
|
||||
public override void Delete()
|
||||
{
|
||||
if ( ReturnHome() )
|
||||
return;
|
||||
|
||||
base.Delete();
|
||||
}
|
||||
|
||||
private static List<Sigil> m_Sigils = new List<Sigil>();
|
||||
|
||||
public static List<Sigil> Sigils{ get{ return m_Sigils; } }
|
||||
}
|
||||
}
|
||||
58
Scripts/Engines/Factions/Items/Silver.cs
Normal file
58
Scripts/Engines/Factions/Items/Silver.cs
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
using System;
|
||||
using Server;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class Silver : Item
|
||||
{
|
||||
public override double DefaultWeight
|
||||
{
|
||||
get { return 0.02; }
|
||||
}
|
||||
|
||||
[Constructable]
|
||||
public Silver() : this( 1 )
|
||||
{
|
||||
}
|
||||
|
||||
[Constructable]
|
||||
public Silver( int amountFrom, int amountTo ) : this( Utility.RandomMinMax( amountFrom, amountTo ) )
|
||||
{
|
||||
}
|
||||
|
||||
[Constructable]
|
||||
public Silver( int amount ) : base( 0xEF0 )
|
||||
{
|
||||
Stackable = true;
|
||||
Amount = amount;
|
||||
}
|
||||
|
||||
public Silver( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
public override int GetDropSound()
|
||||
{
|
||||
if ( Amount <= 1 )
|
||||
return 0x2E4;
|
||||
else if ( 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
40
Scripts/Engines/Factions/Items/StrongholdMonolith.cs
Normal file
40
Scripts/Engines/Factions/Items/StrongholdMonolith.cs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class StrongholdMonolith : BaseMonolith
|
||||
{
|
||||
public override int DefaultLabelNumber{ get{ return 1041042; } } // A Faction Sigil Monolith
|
||||
|
||||
public override void OnTownChanged()
|
||||
{
|
||||
AssignName( Town == null ? null : Town.Definition.StrongholdMonolithName );
|
||||
}
|
||||
|
||||
public StrongholdMonolith() : this( null, null )
|
||||
{
|
||||
}
|
||||
|
||||
public StrongholdMonolith( Town town, Faction faction ) : base( town, faction )
|
||||
{
|
||||
}
|
||||
|
||||
public StrongholdMonolith( 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
40
Scripts/Engines/Factions/Items/TownMonolith.cs
Normal file
40
Scripts/Engines/Factions/Items/TownMonolith.cs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
using System;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class TownMonolith : BaseMonolith
|
||||
{
|
||||
public override int DefaultLabelNumber{ get{ return 1041403; } } // A Faction Town Sigil Monolith
|
||||
|
||||
public override void OnTownChanged()
|
||||
{
|
||||
AssignName( Town == null ? null : Town.Definition.TownMonolithName );
|
||||
}
|
||||
|
||||
public TownMonolith() : this( null )
|
||||
{
|
||||
}
|
||||
|
||||
public TownMonolith( Town town ) : base( town, null )
|
||||
{
|
||||
}
|
||||
|
||||
public TownMonolith( 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
87
Scripts/Engines/Factions/Items/TownStone.cs
Normal file
87
Scripts/Engines/Factions/Items/TownStone.cs
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class TownStone : BaseSystemController
|
||||
{
|
||||
private Town m_Town;
|
||||
|
||||
[CommandProperty( AccessLevel.Counselor, AccessLevel.Administrator )]
|
||||
public Town Town
|
||||
{
|
||||
get{ return m_Town; }
|
||||
set
|
||||
{
|
||||
m_Town = value;
|
||||
|
||||
AssignName( m_Town == null ? null : m_Town.Definition.TownStoneName );
|
||||
}
|
||||
}
|
||||
|
||||
public override string DefaultName { get { return "faction town stone"; } }
|
||||
|
||||
[Constructable]
|
||||
public TownStone() : this( null )
|
||||
{
|
||||
}
|
||||
|
||||
[Constructable]
|
||||
public TownStone( Town town ) : base( 0xEDE )
|
||||
{
|
||||
Movable = false;
|
||||
Town = town;
|
||||
}
|
||||
|
||||
public override void OnDoubleClick( Mobile from )
|
||||
{
|
||||
if ( m_Town == null )
|
||||
return;
|
||||
|
||||
Faction faction = Faction.Find( from );
|
||||
|
||||
if ( faction == null && from.AccessLevel < AccessLevel.GameMaster )
|
||||
return; // TODO: Message?
|
||||
|
||||
if ( m_Town.Owner == null || ( from.AccessLevel < AccessLevel.GameMaster && faction != m_Town.Owner ) )
|
||||
from.SendLocalizedMessage( 1010332 ); // Your faction does not control this town
|
||||
else if ( !m_Town.Owner.IsCommander( from ) )
|
||||
from.SendLocalizedMessage( 1005242 ); // Only faction Leaders can use townstones
|
||||
else if ( FactionGump.Exists( from ) )
|
||||
from.SendLocalizedMessage( 1042160 ); // You already have a faction menu open.
|
||||
else if ( from is PlayerMobile )
|
||||
from.SendGump( new TownStoneGump( (PlayerMobile)from, m_Town.Owner, m_Town ) );
|
||||
}
|
||||
|
||||
public TownStone( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.Write( (int) 0 ); // version
|
||||
|
||||
Town.WriteReference( writer, m_Town );
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
Town = Town.ReadReference( reader );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
294
Scripts/Engines/Factions/Items/Traps/BaseFactionTrap.cs
Normal file
294
Scripts/Engines/Factions/Items/Traps/BaseFactionTrap.cs
Normal file
|
|
@ -0,0 +1,294 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
using Server.Network;
|
||||
using Server.Regions;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public enum AllowedPlacing
|
||||
{
|
||||
Everywhere,
|
||||
|
||||
AnyFactionTown,
|
||||
ControlledFactionTown,
|
||||
FactionStronghold
|
||||
}
|
||||
|
||||
public abstract class BaseFactionTrap : BaseTrap
|
||||
{
|
||||
private Faction m_Faction;
|
||||
private Mobile m_Placer;
|
||||
private DateTime m_TimeOfPlacement;
|
||||
|
||||
private Timer m_Concealing;
|
||||
|
||||
[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( this.Location, this.Map, this.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 == this.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 override void OnMovement( Mobile m, Point3D oldLocation )
|
||||
{
|
||||
base.OnMovement( m, oldLocation );
|
||||
|
||||
if ( !CheckDecay() && CheckRange( m.Location, oldLocation, 6 ) )
|
||||
{
|
||||
if ( Faction.Find( m ) != null && ((m.Skills[SkillName.DetectHidden].Value - 80.0) / 20.0) > Utility.RandomDouble() )
|
||||
PrivateOverheadLocalizedMessage( m, 1010154, MessageHue, "", "" ); // [Faction Trap]
|
||||
}
|
||||
}
|
||||
|
||||
public void PrivateOverheadLocalizedMessage( Mobile to, int number, int hue, string name, string args )
|
||||
{
|
||||
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 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 )
|
||||
{
|
||||
}
|
||||
|
||||
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 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 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.AccessLevel > AccessLevel.Player )
|
||||
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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
112
Scripts/Engines/Factions/Items/Traps/BaseFactionTrapDeed.cs
Normal file
112
Scripts/Engines/Factions/Items/Traps/BaseFactionTrapDeed.cs
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
using System;
|
||||
using Server.Mobiles;
|
||||
using Server.Targeting;
|
||||
using Server.Items;
|
||||
using Server;
|
||||
using Server.Engines.Craft;
|
||||
|
||||
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 m_Faction; }
|
||||
set
|
||||
{
|
||||
m_Faction = value;
|
||||
|
||||
if ( m_Faction != null )
|
||||
Hue = m_Faction.Definition.HuePrimary;
|
||||
}
|
||||
}
|
||||
|
||||
public BaseFactionTrapDeed( int itemID ) : base( itemID )
|
||||
{
|
||||
Weight = 1.0;
|
||||
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( TrapType, new object[]{ 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 != 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 = 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 );
|
||||
Delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.Write( (int) 0 ); // version
|
||||
|
||||
Faction.WriteReference( writer, m_Faction );
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
m_Faction = Faction.ReadReference( reader );
|
||||
}
|
||||
#region ICraftable Members
|
||||
|
||||
public int OnCraft( int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue )
|
||||
{
|
||||
ItemID = 0x14F0;
|
||||
Faction = Faction.Find( from );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
85
Scripts/Engines/Factions/Items/Traps/FactionExplosionTrap.cs
Normal file
85
Scripts/Engines/Factions/Items/Traps/FactionExplosionTrap.cs
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
using System;
|
||||
using Server;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionExplosionTrap : BaseFactionTrap
|
||||
{
|
||||
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( GetWorldLocation(), Map, 0x36BD, 15, 10 );
|
||||
}
|
||||
|
||||
public override void DoAttackEffect( Mobile m )
|
||||
{
|
||||
m.Damage( Utility.Dice( 6, 10, 40 ), m );
|
||||
}
|
||||
|
||||
[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 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 override Type TrapType{ get{ return typeof( FactionExplosionTrap ); } }
|
||||
public override int LabelNumber{ get{ return 1044603; } } // faction explosion trap deed
|
||||
|
||||
public FactionExplosionTrapDeed() : base( 0x36D2 )
|
||||
{
|
||||
}
|
||||
|
||||
public FactionExplosionTrapDeed( 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
85
Scripts/Engines/Factions/Items/Traps/FactionGasTrap.cs
Normal file
85
Scripts/Engines/Factions/Items/Traps/FactionGasTrap.cs
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
using System;
|
||||
using Server;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionGasTrap : BaseFactionTrap
|
||||
{
|
||||
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 );
|
||||
}
|
||||
|
||||
[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 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 override Type TrapType{ get{ return typeof( FactionGasTrap ); } }
|
||||
public override int LabelNumber{ get{ return 1044602; } } // faction gas trap deed
|
||||
|
||||
public FactionGasTrapDeed() : base( 0x11AB )
|
||||
{
|
||||
}
|
||||
|
||||
public FactionGasTrapDeed( 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
85
Scripts/Engines/Factions/Items/Traps/FactionSawTrap.cs
Normal file
85
Scripts/Engines/Factions/Items/Traps/FactionSawTrap.cs
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
using System;
|
||||
using Server;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionSawTrap : BaseFactionTrap
|
||||
{
|
||||
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 );
|
||||
}
|
||||
|
||||
[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 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 override Type TrapType{ get{ return typeof( FactionSawTrap ); } }
|
||||
public override int LabelNumber{ get{ return 1044604; } } // faction saw trap deed
|
||||
|
||||
public FactionSawTrapDeed() : base( 0x1107 )
|
||||
{
|
||||
}
|
||||
|
||||
public FactionSawTrapDeed( 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
85
Scripts/Engines/Factions/Items/Traps/FactionSpikeTrap.cs
Normal file
85
Scripts/Engines/Factions/Items/Traps/FactionSpikeTrap.cs
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
using System;
|
||||
using Server;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionSpikeTrap : BaseFactionTrap
|
||||
{
|
||||
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 );
|
||||
}
|
||||
|
||||
[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 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 override Type TrapType{ get{ return typeof( FactionSpikeTrap ); } }
|
||||
public override int LabelNumber{ get{ return 1044605; } } // faction spike trap deed
|
||||
|
||||
public FactionSpikeTrapDeed() : base( 0x11A5 )
|
||||
{
|
||||
}
|
||||
|
||||
public FactionSpikeTrapDeed( 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionTrapRemovalKit : Item
|
||||
{
|
||||
private int m_Charges;
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public int Charges
|
||||
{
|
||||
get{ return m_Charges; }
|
||||
set{ m_Charges = value; }
|
||||
}
|
||||
|
||||
public override int LabelNumber{ get{ return 1041508; } } // a faction trap removal kit
|
||||
|
||||
[Constructable]
|
||||
public FactionTrapRemovalKit() : base( 7867 )
|
||||
{
|
||||
LootType = LootType.Blessed;
|
||||
m_Charges = 25;
|
||||
}
|
||||
|
||||
public void ConsumeCharge( Mobile consumer )
|
||||
{
|
||||
--m_Charges;
|
||||
|
||||
if ( m_Charges <= 0 )
|
||||
{
|
||||
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, m_Charges.ToString() ); // uses remaining: ~1_val~
|
||||
}
|
||||
|
||||
public FactionTrapRemovalKit( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.Write( (int) 1 ); // version
|
||||
|
||||
writer.WriteEncodedInt( (int) m_Charges );
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
m_Charges = reader.ReadEncodedInt();
|
||||
break;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
m_Charges = 25;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
112
Scripts/Engines/Factions/Mobiles/FactionWarHorse.cs
Normal file
112
Scripts/Engines/Factions/Mobiles/FactionWarHorse.cs
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
[CorpseName( "a war horse corpse" )]
|
||||
public class FactionWarHorse : BaseMount
|
||||
{
|
||||
private Faction m_Faction;
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster, AccessLevel.Administrator )]
|
||||
public Faction Faction
|
||||
{
|
||||
get{ return m_Faction; }
|
||||
set
|
||||
{
|
||||
m_Faction = value;
|
||||
|
||||
Body = ( m_Faction == null ? 0xE2 : m_Faction.Definition.WarHorseBody );
|
||||
ItemID = ( m_Faction == null ? 0x3EA0 : m_Faction.Definition.WarHorseItem );
|
||||
}
|
||||
}
|
||||
|
||||
public const int SilverPrice = 500;
|
||||
public const int GoldPrice = 3000;
|
||||
|
||||
[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 )
|
||||
{
|
||||
BaseSoundID = 0xA8;
|
||||
|
||||
SetStr( 400 );
|
||||
SetDex( 125 );
|
||||
SetInt( 51, 55 );
|
||||
|
||||
SetHits( 240 );
|
||||
SetMana( 0 );
|
||||
|
||||
SetDamage( 5, 8 );
|
||||
|
||||
SetDamageType( ResistanceType.Physical, 100 );
|
||||
|
||||
SetResistance( ResistanceType.Physical, 40, 50 );
|
||||
SetResistance( ResistanceType.Fire, 30, 40 );
|
||||
SetResistance( ResistanceType.Cold, 30, 40 );
|
||||
SetResistance( ResistanceType.Poison, 30, 40 );
|
||||
SetResistance( ResistanceType.Energy, 30, 40 );
|
||||
|
||||
SetSkill( SkillName.MagicResist, 25.1, 30.0 );
|
||||
SetSkill( SkillName.Tactics, 29.3, 44.0 );
|
||||
SetSkill( SkillName.Wrestling, 29.3, 44.0 );
|
||||
|
||||
Fame = 300;
|
||||
Karma = 300;
|
||||
|
||||
Tamable = true;
|
||||
ControlSlots = 1;
|
||||
|
||||
Faction = faction;
|
||||
}
|
||||
|
||||
public override FoodType FavoriteFood{ get{ return FoodType.FruitsAndVegies | FoodType.GrainsAndHay; } }
|
||||
|
||||
public FactionWarHorse( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
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, m_Faction );
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
Faction = Faction.ReadReference( reader );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
515
Scripts/Engines/Factions/Mobiles/Guards/BaseFactionGuard.cs
Normal file
515
Scripts/Engines/Factions/Mobiles/Guards/BaseFactionGuard.cs
Normal file
|
|
@ -0,0 +1,515 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
using Server.Factions.AI;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public abstract class BaseFactionGuard : BaseCreature
|
||||
{
|
||||
private Faction m_Faction;
|
||||
private Town m_Town;
|
||||
private Orders m_Orders;
|
||||
|
||||
public override bool BardImmune{ get{ return true; } }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster, AccessLevel.Administrator )]
|
||||
public Faction Faction
|
||||
{
|
||||
get{ return m_Faction; }
|
||||
set{ Unregister(); m_Faction = value; Register(); }
|
||||
}
|
||||
|
||||
public Orders Orders
|
||||
{
|
||||
get{ return m_Orders; }
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster, AccessLevel.Administrator )]
|
||||
public Town Town
|
||||
{
|
||||
get{ return m_Town; }
|
||||
set{ Unregister(); m_Town = value; Register(); }
|
||||
}
|
||||
|
||||
public void Register()
|
||||
{
|
||||
if ( m_Town != null && m_Faction != null )
|
||||
m_Town.RegisterGuard( this );
|
||||
}
|
||||
|
||||
public void Unregister()
|
||||
{
|
||||
if ( m_Town != null )
|
||||
m_Town.UnregisterGuard( this );
|
||||
}
|
||||
|
||||
public abstract GuardAI GuardAI{ get; }
|
||||
|
||||
protected override BaseAI ForcedAI
|
||||
{
|
||||
get { return new FactionGuardAI( this ); }
|
||||
}
|
||||
|
||||
public override TimeSpan ReacquireDelay{ get{ return TimeSpan.FromSeconds( 2.0 ); } }
|
||||
|
||||
public override bool IsEnemy( Mobile m )
|
||||
{
|
||||
Faction ourFaction = 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 = 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 && InRange( m, 10 ) && !InRange( oldLocation, 10 ) && InLOS( m ) && m_Orders.GetReaction( Faction.Find( m ) ).Type == ReactionType.Warn )
|
||||
{
|
||||
Direction = 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 );
|
||||
|
||||
Say( warning, m.Name, faction == null ? "civilians" : faction.Definition.FriendlyName );
|
||||
}
|
||||
}
|
||||
|
||||
private const int ListenRange = 12;
|
||||
|
||||
public override bool HandlesOnSpeech( Mobile from )
|
||||
{
|
||||
if ( InRange( from, ListenRange ) )
|
||||
return true;
|
||||
|
||||
return base.HandlesOnSpeech( from );
|
||||
}
|
||||
|
||||
private DateTime m_OrdersEnd;
|
||||
|
||||
private void ChangeReaction( Faction faction, ReactionType type )
|
||||
{
|
||||
if ( faction == null )
|
||||
{
|
||||
switch ( type )
|
||||
{
|
||||
case ReactionType.Ignore: Say( 1005179 ); break; // Civilians will now be ignored.
|
||||
case ReactionType.Warn: 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 )
|
||||
Say( def.Number );
|
||||
else if ( def != null && def.String != null )
|
||||
Say( def.String );
|
||||
}
|
||||
|
||||
m_Orders.SetReaction( faction, type );
|
||||
}
|
||||
|
||||
private bool WasNamed( string speech )
|
||||
{
|
||||
string name = this.Name;
|
||||
|
||||
return ( name != null && Insensitive.StartsWith( speech, name ) );
|
||||
}
|
||||
|
||||
public override void OnSpeech( SpeechEventArgs e )
|
||||
{
|
||||
base.OnSpeech( e );
|
||||
|
||||
Mobile from = e.Mobile;
|
||||
|
||||
if ( !e.Handled && InRange( from, ListenRange ) && from.Alive )
|
||||
{
|
||||
if ( e.HasKeyword( 0xE6 ) && (Insensitive.Equals( e.Speech, "orders" ) || WasNamed( e.Speech )) ) // *orders*
|
||||
{
|
||||
if ( m_Town == null || !m_Town.IsSheriff( from ) )
|
||||
{
|
||||
this.Say( 1042189 ); // I don't work for you!
|
||||
}
|
||||
else if ( Town.FromRegion( this.Region ) == m_Town )
|
||||
{
|
||||
this.Say( 1042180 ); // Your orders, sire?
|
||||
m_OrdersEnd = DateTime.UtcNow + TimeSpan.FromSeconds( 10.0 );
|
||||
}
|
||||
}
|
||||
else if ( DateTime.UtcNow < m_OrdersEnd )
|
||||
{
|
||||
if ( m_Town != null && m_Town.IsSheriff( from ) && Town.FromRegion( this.Region ) == m_Town )
|
||||
{
|
||||
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" ) )
|
||||
{
|
||||
ChangeReaction( null, newType );
|
||||
understood = true;
|
||||
}
|
||||
|
||||
List<Faction> factions = Faction.Factions;
|
||||
|
||||
for ( int i = 0; i < factions.Count; ++i )
|
||||
{
|
||||
Faction faction = factions[i];
|
||||
|
||||
if ( faction != m_Faction && Insensitive.Contains( e.Speech, faction.Definition.Keyword ) )
|
||||
{
|
||||
ChangeReaction( faction, newType );
|
||||
understood = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( Insensitive.Contains( e.Speech, "patrol" ) )
|
||||
{
|
||||
Home = Location;
|
||||
RangeHome = 6;
|
||||
Combatant = null;
|
||||
m_Orders.Movement = MovementType.Patrol;
|
||||
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" ) )
|
||||
{
|
||||
Home = Location;
|
||||
RangeHome = 6;
|
||||
Combatant = null;
|
||||
m_Orders.Follow = from;
|
||||
m_Orders.Movement = MovementType.Follow;
|
||||
Say( 1005144 ); // Yes, Sire.
|
||||
understood = true;
|
||||
}
|
||||
|
||||
if ( !understood )
|
||||
Say( 1042183 ); // I'm sorry, I don't understand your orders...
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void GetProperties( ObjectPropertyList list )
|
||||
{
|
||||
base.GetProperties( list );
|
||||
|
||||
if ( m_Faction != null && Map == Faction.Facet )
|
||||
list.Add( 1060846, m_Faction.Definition.PropName ); // Guard: ~1_val~
|
||||
}
|
||||
|
||||
public override void OnSingleClick( Mobile from )
|
||||
{
|
||||
if ( m_Faction != null && Map == Faction.Facet )
|
||||
{
|
||||
string text = String.Concat( "(Guard, ", m_Faction.Definition.FriendlyName, ")" );
|
||||
|
||||
int hue = ( Faction.Find( from ) == m_Faction ? 98 : 38 );
|
||||
|
||||
PrivateOverheadMessage( MessageType.Label, hue, true, text, from.NetState );
|
||||
}
|
||||
|
||||
base.OnSingleClick( from );
|
||||
}
|
||||
|
||||
public virtual void GenerateRandomHair()
|
||||
{
|
||||
Utility.AssignRandomHair( this );
|
||||
Utility.AssignRandomFacialHair( this, HairHue );
|
||||
}
|
||||
|
||||
private static 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 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 )
|
||||
};
|
||||
|
||||
public void PackStrongPotions( int min, int max )
|
||||
{
|
||||
PackStrongPotions( Utility.RandomMinMax( min, max ) );
|
||||
}
|
||||
|
||||
public void PackStrongPotions( int count )
|
||||
{
|
||||
for ( int i = 0; i < count; ++i )
|
||||
PackStrongPotion();
|
||||
}
|
||||
|
||||
public void PackStrongPotion()
|
||||
{
|
||||
PackItem( Loot.Construct( m_StrongPotions ) );
|
||||
}
|
||||
|
||||
public void PackWeakPotions( int min, int max )
|
||||
{
|
||||
PackWeakPotions( Utility.RandomMinMax( min, max ) );
|
||||
}
|
||||
|
||||
public void PackWeakPotions( int count )
|
||||
{
|
||||
for ( int i = 0; i < count; ++i )
|
||||
PackWeakPotion();
|
||||
}
|
||||
|
||||
public void PackWeakPotion()
|
||||
{
|
||||
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();
|
||||
Unregister();
|
||||
}
|
||||
|
||||
public override void OnDeath( Container c )
|
||||
{
|
||||
base.OnDeath( c );
|
||||
|
||||
c.Delete();
|
||||
}
|
||||
|
||||
public virtual void GenerateBody( bool isFemale, bool randomHair )
|
||||
{
|
||||
Hue = Utility.RandomSkinHue();
|
||||
|
||||
if ( isFemale )
|
||||
{
|
||||
Female = true;
|
||||
Body = 401;
|
||||
Name = NameList.RandomName( "female" );
|
||||
}
|
||||
else
|
||||
{
|
||||
Female = false;
|
||||
Body = 400;
|
||||
Name = NameList.RandomName( "male" );
|
||||
}
|
||||
|
||||
if ( randomHair )
|
||||
GenerateRandomHair();
|
||||
}
|
||||
|
||||
public override bool ClickTitle{ get{ return false; } }
|
||||
|
||||
public BaseFactionGuard( string title ) : base( AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4 )
|
||||
{
|
||||
m_Orders = new Orders( this );
|
||||
Title = title;
|
||||
|
||||
RangeHome = 6;
|
||||
}
|
||||
|
||||
public BaseFactionGuard( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.Write( (int) 0 ); // version
|
||||
|
||||
Faction.WriteReference( writer, m_Faction );
|
||||
Town.WriteReference( writer, m_Town );
|
||||
|
||||
m_Orders.Serialize( writer );
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
m_Faction = Faction.ReadReference( reader );
|
||||
m_Town = Town.ReadReference( reader );
|
||||
m_Orders = new Orders( this, reader );
|
||||
|
||||
Timer.DelayCall( TimeSpan.Zero, new TimerCallback( Register ) );
|
||||
}
|
||||
}
|
||||
|
||||
public class VirtualMount : IMount
|
||||
{
|
||||
private VirtualMountItem m_Item;
|
||||
|
||||
public Mobile Rider
|
||||
{
|
||||
get{ return m_Item.Rider; }
|
||||
set{}
|
||||
}
|
||||
|
||||
public VirtualMount( VirtualMountItem item )
|
||||
{
|
||||
m_Item = item;
|
||||
}
|
||||
|
||||
public virtual void OnRiderDamaged( int amount, Mobile from, bool willKill )
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class VirtualMountItem : Item, IMountItem
|
||||
{
|
||||
private Mobile m_Rider;
|
||||
private VirtualMount m_Mount;
|
||||
|
||||
public Mobile Rider{ get{ return m_Rider; } }
|
||||
|
||||
public VirtualMountItem( Mobile mob ) : base( 0x3EA0 )
|
||||
{
|
||||
Layer = Layer.Mount;
|
||||
|
||||
m_Rider = mob;
|
||||
m_Mount = new VirtualMount( this );
|
||||
}
|
||||
|
||||
public IMount Mount
|
||||
{
|
||||
get{ return m_Mount; }
|
||||
}
|
||||
|
||||
public VirtualMountItem( Serial serial ) : base( serial )
|
||||
{
|
||||
m_Mount = new VirtualMount( this );
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.Write( (int) 0 ); // version
|
||||
|
||||
writer.Write( (Mobile) m_Rider );
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
m_Rider = reader.ReadMobile();
|
||||
|
||||
if ( m_Rider == null )
|
||||
Delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
779
Scripts/Engines/Factions/Mobiles/Guards/GuardAI.cs
Normal file
779
Scripts/Engines/Factions/Mobiles/Guards/GuardAI.cs
Normal file
|
|
@ -0,0 +1,779 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
using Server.Targeting;
|
||||
using Server.Factions.AI;
|
||||
using Server.Spells;
|
||||
using Server.Spells.First;
|
||||
using Server.Spells.Second;
|
||||
using Server.Spells.Third;
|
||||
using Server.Spells.Fourth;
|
||||
using Server.Spells.Fifth;
|
||||
using Server.Spells.Sixth;
|
||||
using Server.Spells.Seventh;
|
||||
|
||||
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 Type m_Spell;
|
||||
private TimeSpan m_Hold;
|
||||
private int m_Chance;
|
||||
|
||||
public Type Spell{ get{ return m_Spell; } }
|
||||
public TimeSpan Hold{ get{ return m_Hold; } }
|
||||
public int Chance{ get{ return 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 class SpellCombo
|
||||
{
|
||||
private int m_Mana;
|
||||
private ComboEntry[] m_Entries;
|
||||
|
||||
public int Mana{ get{ return m_Mana; } }
|
||||
public ComboEntry[] Entries{ get{ return m_Entries; } }
|
||||
|
||||
public SpellCombo( int mana, params ComboEntry[] entries )
|
||||
{
|
||||
m_Mana = mana;
|
||||
m_Entries = entries;
|
||||
}
|
||||
|
||||
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 ) )
|
||||
);
|
||||
|
||||
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 BaseFactionGuard m_Guard;
|
||||
|
||||
private BandageContext m_Bandage;
|
||||
private DateTime m_BandageStart;
|
||||
|
||||
private SpellCombo m_Combo;
|
||||
private int m_ComboIndex = -1;
|
||||
private DateTime m_ReleaseTarget;
|
||||
|
||||
private const int ManaReserve = 30;
|
||||
|
||||
public bool IsAllowed( GuardAI flag )
|
||||
{
|
||||
return ( ( m_Guard.GuardAI & flag ) == flag );
|
||||
}
|
||||
|
||||
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 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 )
|
||||
{
|
||||
StatMod mod = mob.GetStatMod( String.Format( "[Magic] {0} Offset", type ) );
|
||||
|
||||
if ( mod == null )
|
||||
return 0;
|
||||
|
||||
return mod.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 )
|
||||
{
|
||||
List<AggressorInfo> aggressed = m_Mobile.Aggressed;
|
||||
List<AggressorInfo> aggressors = m_Mobile.Aggressors;
|
||||
|
||||
Mobile active = null;
|
||||
double activePrio = 0.0;
|
||||
|
||||
Mobile comb = m_Mobile.Combatant;
|
||||
|
||||
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;
|
||||
|
||||
if ( comb != null && !comb.Deleted && comb.Alive && !comb.IsDeadBondedPet && CanDispel( comb ) )
|
||||
{
|
||||
active = inactive = comb;
|
||||
actPrio = inactPrio = m_Mobile.GetDistanceToSqrt( comb );
|
||||
}
|
||||
|
||||
foreach ( Mobile m in m_Mobile.GetMobilesInRange( 12 ) )
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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( (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 FactionGuardAI( BaseFactionGuard guard ) : base( guard )
|
||||
{
|
||||
m_Guard = guard;
|
||||
}
|
||||
|
||||
public override bool Think()
|
||||
{
|
||||
if ( m_Mobile.Deleted )
|
||||
return false;
|
||||
|
||||
Mobile combatant = m_Guard.Combatant;
|
||||
|
||||
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;
|
||||
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;
|
||||
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 >= 0 )
|
||||
{
|
||||
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 ), 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 );
|
||||
|
||||
List<Type> 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 );
|
||||
|
||||
List<Type> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
147
Scripts/Engines/Factions/Mobiles/Guards/Orders.cs
Normal file
147
Scripts/Engines/Factions/Mobiles/Guards/Orders.cs
Normal file
|
|
@ -0,0 +1,147 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Factions.AI
|
||||
{
|
||||
public enum ReactionType
|
||||
{
|
||||
Ignore,
|
||||
Warn,
|
||||
Attack
|
||||
}
|
||||
|
||||
public enum MovementType
|
||||
{
|
||||
Stand,
|
||||
Patrol,
|
||||
Follow
|
||||
}
|
||||
|
||||
public class Reaction
|
||||
{
|
||||
private Faction m_Faction;
|
||||
private ReactionType m_Type;
|
||||
|
||||
public Faction Faction{ get{ return m_Faction; } }
|
||||
public ReactionType Type{ get{ return m_Type; } set{ m_Type = value; } }
|
||||
|
||||
public Reaction( Faction faction, ReactionType type )
|
||||
{
|
||||
m_Faction = faction;
|
||||
m_Type = type;
|
||||
}
|
||||
|
||||
public Reaction( GenericReader reader )
|
||||
{
|
||||
int version = reader.ReadEncodedInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
m_Faction = Faction.ReadReference( reader );
|
||||
m_Type = (ReactionType) reader.ReadEncodedInt();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Serialize( GenericWriter writer )
|
||||
{
|
||||
writer.WriteEncodedInt( (int) 0 ); // version
|
||||
|
||||
Faction.WriteReference( writer, m_Faction );
|
||||
writer.WriteEncodedInt( (int) m_Type );
|
||||
}
|
||||
}
|
||||
|
||||
public class Orders
|
||||
{
|
||||
private BaseFactionGuard m_Guard;
|
||||
|
||||
private List<Reaction> m_Reactions;
|
||||
private MovementType m_Movement;
|
||||
private Mobile m_Follow;
|
||||
|
||||
public BaseFactionGuard Guard{ get{ return m_Guard; } }
|
||||
|
||||
public MovementType Movement{ get{ return m_Movement; } set{ m_Movement = value; } }
|
||||
public Mobile Follow{ get{ return m_Follow; } set{ m_Follow = value; } }
|
||||
|
||||
public Reaction GetReaction( Faction faction )
|
||||
{
|
||||
Reaction reaction;
|
||||
|
||||
for ( int i = 0; i < m_Reactions.Count; ++i )
|
||||
{
|
||||
reaction = m_Reactions[i];
|
||||
|
||||
if ( reaction.Faction == faction )
|
||||
return reaction;
|
||||
}
|
||||
|
||||
reaction = new Reaction( faction, ( faction == null || faction == m_Guard.Faction ) ? ReactionType.Ignore : ReactionType.Attack );
|
||||
m_Reactions.Add( reaction );
|
||||
|
||||
return reaction;
|
||||
}
|
||||
|
||||
public void SetReaction( Faction faction, ReactionType type )
|
||||
{
|
||||
Reaction reaction = GetReaction( faction );
|
||||
|
||||
reaction.Type = type;
|
||||
}
|
||||
|
||||
public Orders( BaseFactionGuard guard )
|
||||
{
|
||||
m_Guard = guard;
|
||||
m_Reactions = new List<Reaction>();
|
||||
m_Movement = MovementType.Patrol;
|
||||
}
|
||||
|
||||
public Orders( BaseFactionGuard guard, GenericReader reader )
|
||||
{
|
||||
m_Guard = guard;
|
||||
|
||||
int version = reader.ReadEncodedInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
m_Follow = reader.ReadMobile();
|
||||
goto case 0;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
int count = reader.ReadEncodedInt();
|
||||
m_Reactions = new List<Reaction>( count );
|
||||
|
||||
for ( int i = 0; i < count; ++i )
|
||||
m_Reactions.Add( new Reaction( reader ) );
|
||||
|
||||
m_Movement = (MovementType)reader.ReadEncodedInt();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Serialize( GenericWriter writer )
|
||||
{
|
||||
writer.WriteEncodedInt( (int) 1 ); // version
|
||||
|
||||
writer.Write( (Mobile) m_Follow );
|
||||
|
||||
writer.WriteEncodedInt( (int) m_Reactions.Count );
|
||||
|
||||
for ( int i = 0; i < m_Reactions.Count; ++i )
|
||||
m_Reactions[i].Serialize( writer );
|
||||
|
||||
writer.WriteEncodedInt( (int) m_Movement );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionBerserker : BaseFactionGuard
|
||||
{
|
||||
public override GuardAI GuardAI{ get{ return GuardAI.Melee | GuardAI.Curse | GuardAI.Bless; } }
|
||||
|
||||
[Constructable]
|
||||
public FactionBerserker() : base( "the berserker" )
|
||||
{
|
||||
GenerateBody( false, false );
|
||||
|
||||
SetStr( 126, 150 );
|
||||
SetDex( 61, 85 );
|
||||
SetInt( 81, 95 );
|
||||
|
||||
SetDamageType( ResistanceType.Physical, 100 );
|
||||
|
||||
SetResistance( ResistanceType.Physical, 30, 50 );
|
||||
SetResistance( ResistanceType.Fire, 30, 50 );
|
||||
SetResistance( ResistanceType.Cold, 30, 50 );
|
||||
SetResistance( ResistanceType.Energy, 30, 50 );
|
||||
SetResistance( ResistanceType.Poison, 30, 50 );
|
||||
|
||||
VirtualArmor = 24;
|
||||
|
||||
SetSkill( SkillName.Swords, 100.0, 110.0 );
|
||||
SetSkill( SkillName.Wrestling, 100.0, 110.0 );
|
||||
SetSkill( SkillName.Tactics, 100.0, 110.0 );
|
||||
SetSkill( SkillName.MagicResist, 100.0, 110.0 );
|
||||
SetSkill( SkillName.Healing, 100.0, 110.0 );
|
||||
SetSkill( SkillName.Anatomy, 100.0, 110.0 );
|
||||
|
||||
SetSkill( SkillName.Magery, 100.0, 110.0 );
|
||||
SetSkill( SkillName.EvalInt, 100.0, 110.0 );
|
||||
SetSkill( SkillName.Meditation, 100.0, 110.0 );
|
||||
|
||||
AddItem( Immovable( Rehued( new BodySash(), 1645 ) ) );
|
||||
AddItem( Immovable( Rehued( new Kilt(), 1645 ) ) );
|
||||
AddItem( Immovable( Rehued( new Sandals(), 1645 ) ) );
|
||||
AddItem( Newbied( new DoubleAxe() ) );
|
||||
|
||||
HairItemID = 0x2047; // Afro
|
||||
HairHue = 0x29;
|
||||
|
||||
FacialHairItemID = 0x204B; // Medium Short Beard
|
||||
FacialHairHue = 0x29;
|
||||
|
||||
PackItem( new Bandage( Utility.RandomMinMax( 30, 40 ) ) );
|
||||
PackStrongPotions( 6, 12 );
|
||||
}
|
||||
|
||||
public FactionBerserker( 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionDeathKnight : BaseFactionGuard
|
||||
{
|
||||
public override GuardAI GuardAI{ get{ return GuardAI.Melee | GuardAI.Curse | GuardAI.Bless; } }
|
||||
|
||||
[Constructable]
|
||||
public FactionDeathKnight() : base( "the death knight" )
|
||||
{
|
||||
GenerateBody( false, false );
|
||||
Hue = 1;
|
||||
|
||||
SetStr( 126, 150 );
|
||||
SetDex( 61, 85 );
|
||||
SetInt( 81, 95 );
|
||||
|
||||
SetDamageType( ResistanceType.Physical, 100 );
|
||||
|
||||
SetResistance( ResistanceType.Physical, 30, 50 );
|
||||
SetResistance( ResistanceType.Fire, 30, 50 );
|
||||
SetResistance( ResistanceType.Cold, 30, 50 );
|
||||
SetResistance( ResistanceType.Energy, 30, 50 );
|
||||
SetResistance( ResistanceType.Poison, 30, 50 );
|
||||
|
||||
VirtualArmor = 24;
|
||||
|
||||
SetSkill( SkillName.Swords, 100.0, 110.0 );
|
||||
SetSkill( SkillName.Wrestling, 100.0, 110.0 );
|
||||
SetSkill( SkillName.Tactics, 100.0, 110.0 );
|
||||
SetSkill( SkillName.MagicResist, 100.0, 110.0 );
|
||||
SetSkill( SkillName.Healing, 100.0, 110.0 );
|
||||
SetSkill( SkillName.Anatomy, 100.0, 110.0 );
|
||||
|
||||
SetSkill( SkillName.Magery, 100.0, 110.0 );
|
||||
SetSkill( SkillName.EvalInt, 100.0, 110.0 );
|
||||
SetSkill( SkillName.Meditation, 100.0, 110.0 );
|
||||
|
||||
Item shroud = new Item( 0x204E );
|
||||
shroud.Layer = Layer.OuterTorso;
|
||||
|
||||
AddItem( Immovable( Rehued( shroud, 1109 ) ) );
|
||||
AddItem( Newbied( Rehued( new ExecutionersAxe(), 2211 ) ) );
|
||||
|
||||
PackItem( new Bandage( Utility.RandomMinMax( 30, 40 ) ) );
|
||||
PackStrongPotions( 6, 12 );
|
||||
}
|
||||
|
||||
public FactionDeathKnight( 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionDragoon : BaseFactionGuard
|
||||
{
|
||||
public override GuardAI GuardAI{ get{ return GuardAI.Magic | GuardAI.Melee | GuardAI.Smart | GuardAI.Bless | GuardAI.Curse; } }
|
||||
|
||||
[Constructable]
|
||||
public FactionDragoon() : base( "the dragoon" )
|
||||
{
|
||||
GenerateBody( false, false );
|
||||
|
||||
SetStr( 151, 175 );
|
||||
SetDex( 61, 85 );
|
||||
SetInt( 151, 175 );
|
||||
|
||||
SetResistance( ResistanceType.Physical, 40, 60 );
|
||||
SetResistance( ResistanceType.Fire, 40, 60 );
|
||||
SetResistance( ResistanceType.Cold, 40, 60 );
|
||||
SetResistance( ResistanceType.Energy, 40, 60 );
|
||||
SetResistance( ResistanceType.Poison, 40, 60 );
|
||||
|
||||
VirtualArmor = 32;
|
||||
|
||||
SetSkill( SkillName.Macing, 110.0, 120.0 );
|
||||
SetSkill( SkillName.Wrestling, 110.0, 120.0 );
|
||||
SetSkill( SkillName.Tactics, 110.0, 120.0 );
|
||||
SetSkill( SkillName.MagicResist, 110.0, 120.0 );
|
||||
SetSkill( SkillName.Healing, 110.0, 120.0 );
|
||||
SetSkill( SkillName.Anatomy, 110.0, 120.0 );
|
||||
|
||||
SetSkill( SkillName.Magery, 110.0, 120.0 );
|
||||
SetSkill( SkillName.EvalInt, 110.0, 120.0 );
|
||||
SetSkill( SkillName.Meditation, 110.0, 120.0 );
|
||||
|
||||
AddItem( Immovable( Rehued( new Cloak(), 1645 ) ) );
|
||||
|
||||
AddItem( Immovable( Rehued( new PlateChest(), 1645 ) ) );
|
||||
AddItem( Immovable( Rehued( new PlateLegs(), 1109 ) ) );
|
||||
AddItem( Immovable( Rehued( new PlateArms(), 1109 ) ) );
|
||||
AddItem( Immovable( Rehued( new PlateGloves(), 1109 ) ) );
|
||||
AddItem( Immovable( Rehued( new PlateGorget(), 1109 ) ) );
|
||||
AddItem( Immovable( Rehued( new PlateHelm(), 1109 ) ) );
|
||||
|
||||
AddItem( Newbied( new WarHammer() ) );
|
||||
|
||||
AddItem( Immovable( Rehued( new VirtualMountItem( this ), 1109 ) ) );
|
||||
|
||||
PackItem( new Bandage( Utility.RandomMinMax( 30, 40 ) ) );
|
||||
PackStrongPotions( 6, 12 );
|
||||
}
|
||||
|
||||
public FactionDragoon( 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionHenchman : BaseFactionGuard
|
||||
{
|
||||
public override GuardAI GuardAI{ get{ return GuardAI.Melee; } }
|
||||
|
||||
[Constructable]
|
||||
public FactionHenchman() : base( "the henchman" )
|
||||
{
|
||||
GenerateBody( false, true );
|
||||
|
||||
SetStr( 91, 115 );
|
||||
SetDex( 61, 85 );
|
||||
SetInt( 81, 95 );
|
||||
|
||||
SetDamage( 10, 14 );
|
||||
|
||||
SetResistance( ResistanceType.Physical, 10, 30 );
|
||||
SetResistance( ResistanceType.Fire, 10, 30 );
|
||||
SetResistance( ResistanceType.Cold, 10, 30 );
|
||||
SetResistance( ResistanceType.Energy, 10, 30 );
|
||||
SetResistance( ResistanceType.Poison, 10, 30 );
|
||||
|
||||
VirtualArmor = 8;
|
||||
|
||||
SetSkill( SkillName.Fencing, 80.0, 90.0 );
|
||||
SetSkill( SkillName.Wrestling, 80.0, 90.0 );
|
||||
SetSkill( SkillName.Tactics, 80.0, 90.0 );
|
||||
SetSkill( SkillName.MagicResist, 80.0, 90.0 );
|
||||
SetSkill( SkillName.Healing, 80.0, 90.0 );
|
||||
SetSkill( SkillName.Anatomy, 80.0, 90.0 );
|
||||
|
||||
AddItem( new StuddedChest() );
|
||||
AddItem( new StuddedLegs() );
|
||||
AddItem( new StuddedArms() );
|
||||
AddItem( new StuddedGloves() );
|
||||
AddItem( new StuddedGorget() );
|
||||
AddItem( new Boots() );
|
||||
AddItem( Newbied( new Spear() ) );
|
||||
|
||||
PackItem( new Bandage( Utility.RandomMinMax( 10, 20 ) ) );
|
||||
PackWeakPotions( 1, 4 );
|
||||
}
|
||||
|
||||
public FactionHenchman( 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionKnight : BaseFactionGuard
|
||||
{
|
||||
public override GuardAI GuardAI{ get{ return GuardAI.Magic | GuardAI.Melee | GuardAI.Smart | GuardAI.Curse | GuardAI.Bless; } }
|
||||
|
||||
[Constructable]
|
||||
public FactionKnight() : base( "the knight" )
|
||||
{
|
||||
GenerateBody( false, false );
|
||||
|
||||
SetStr( 126, 150 );
|
||||
SetDex( 61, 85 );
|
||||
SetInt( 81, 95 );
|
||||
|
||||
SetDamageType( ResistanceType.Physical, 100 );
|
||||
|
||||
SetResistance( ResistanceType.Physical, 30, 50 );
|
||||
SetResistance( ResistanceType.Fire, 30, 50 );
|
||||
SetResistance( ResistanceType.Cold, 30, 50 );
|
||||
SetResistance( ResistanceType.Energy, 30, 50 );
|
||||
SetResistance( ResistanceType.Poison, 30, 50 );
|
||||
|
||||
VirtualArmor = 24;
|
||||
|
||||
SetSkill( SkillName.Swords, 100.0, 110.0 );
|
||||
SetSkill( SkillName.Wrestling, 100.0, 110.0 );
|
||||
SetSkill( SkillName.Tactics, 100.0, 110.0 );
|
||||
SetSkill( SkillName.MagicResist, 100.0, 110.0 );
|
||||
SetSkill( SkillName.Healing, 100.0, 110.0 );
|
||||
SetSkill( SkillName.Anatomy, 100.0, 110.0 );
|
||||
|
||||
SetSkill( SkillName.Magery, 100.0, 110.0 );
|
||||
SetSkill( SkillName.EvalInt, 100.0, 110.0 );
|
||||
SetSkill( SkillName.Meditation, 100.0, 110.0 );
|
||||
|
||||
AddItem( Immovable( Rehued( new ChainChest(), 2125 ) ) );
|
||||
AddItem( Immovable( Rehued( new ChainLegs(), 2125 ) ) );
|
||||
AddItem( Immovable( Rehued( new ChainCoif(), 2125 ) ) );
|
||||
AddItem( Immovable( Rehued( new PlateArms(), 2125 ) ) );
|
||||
AddItem( Immovable( Rehued( new PlateGloves(), 2125 ) ) );
|
||||
|
||||
AddItem( Immovable( Rehued( new BodySash(), 1254 ) ) );
|
||||
AddItem( Immovable( Rehued( new Kilt(), 1254 ) ) );
|
||||
AddItem( Immovable( Rehued( new Sandals(), 1254 ) ) );
|
||||
|
||||
AddItem( Newbied( new Bardiche() ) );
|
||||
|
||||
PackItem( new Bandage( Utility.RandomMinMax( 30, 40 ) ) );
|
||||
PackStrongPotions( 6, 12 );
|
||||
}
|
||||
|
||||
public FactionKnight( 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionMercenary : BaseFactionGuard
|
||||
{
|
||||
public override GuardAI GuardAI{ get{ return GuardAI.Melee | GuardAI.Smart; } }
|
||||
|
||||
[Constructable]
|
||||
public FactionMercenary() : base( "the mercenary" )
|
||||
{
|
||||
GenerateBody( false, true );
|
||||
|
||||
SetStr( 116, 125 );
|
||||
SetDex( 61, 85 );
|
||||
SetInt( 81, 95 );
|
||||
|
||||
SetResistance( ResistanceType.Physical, 20, 40 );
|
||||
SetResistance( ResistanceType.Fire, 20, 40 );
|
||||
SetResistance( ResistanceType.Cold, 20, 40 );
|
||||
SetResistance( ResistanceType.Energy, 20, 40 );
|
||||
SetResistance( ResistanceType.Poison, 20, 40 );
|
||||
|
||||
VirtualArmor = 16;
|
||||
|
||||
SetSkill( SkillName.Fencing, 90.0, 100.0 );
|
||||
SetSkill( SkillName.Wrestling, 90.0, 100.0 );
|
||||
SetSkill( SkillName.Tactics, 90.0, 100.0 );
|
||||
SetSkill( SkillName.MagicResist, 90.0, 100.0 );
|
||||
SetSkill( SkillName.Healing, 90.0, 100.0 );
|
||||
SetSkill( SkillName.Anatomy, 90.0, 100.0 );
|
||||
|
||||
AddItem( new ChainChest() );
|
||||
AddItem( new ChainLegs() );
|
||||
AddItem( new RingmailArms() );
|
||||
AddItem( new RingmailGloves() );
|
||||
AddItem( new ChainCoif() );
|
||||
AddItem( new Boots() );
|
||||
AddItem( Newbied( new ShortSpear() ) );
|
||||
|
||||
PackItem( new Bandage( Utility.RandomMinMax( 20, 30 ) ) );
|
||||
PackStrongPotions( 3, 8 );
|
||||
}
|
||||
|
||||
public FactionMercenary( 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionNecromancer : BaseFactionGuard
|
||||
{
|
||||
public override GuardAI GuardAI{ get{ return GuardAI.Magic | GuardAI.Smart | GuardAI.Bless | GuardAI.Curse; } }
|
||||
|
||||
[Constructable]
|
||||
public FactionNecromancer() : base( "the necromancer" )
|
||||
{
|
||||
GenerateBody( false, false );
|
||||
Hue = 1;
|
||||
|
||||
SetStr( 151, 175 );
|
||||
SetDex( 61, 85 );
|
||||
SetInt( 151, 175 );
|
||||
|
||||
SetResistance( ResistanceType.Physical, 40, 60 );
|
||||
SetResistance( ResistanceType.Fire, 40, 60 );
|
||||
SetResistance( ResistanceType.Cold, 40, 60 );
|
||||
SetResistance( ResistanceType.Energy, 40, 60 );
|
||||
SetResistance( ResistanceType.Poison, 40, 60 );
|
||||
|
||||
VirtualArmor = 32;
|
||||
|
||||
SetSkill( SkillName.Macing, 110.0, 120.0 );
|
||||
SetSkill( SkillName.Wrestling, 110.0, 120.0 );
|
||||
SetSkill( SkillName.Tactics, 110.0, 120.0 );
|
||||
SetSkill( SkillName.MagicResist, 110.0, 120.0 );
|
||||
SetSkill( SkillName.Healing, 110.0, 120.0 );
|
||||
SetSkill( SkillName.Anatomy, 110.0, 120.0 );
|
||||
|
||||
SetSkill( SkillName.Magery, 110.0, 120.0 );
|
||||
SetSkill( SkillName.EvalInt, 110.0, 120.0 );
|
||||
SetSkill( SkillName.Meditation, 110.0, 120.0 );
|
||||
|
||||
Item shroud = new Item( 0x204E );
|
||||
shroud.Layer = Layer.OuterTorso;
|
||||
|
||||
AddItem( Immovable( Rehued( shroud, 1109 ) ) );
|
||||
AddItem( Newbied( Rehued( new GnarledStaff(), 2211 ) ) );
|
||||
|
||||
PackItem( new Bandage( Utility.RandomMinMax( 30, 40 ) ) );
|
||||
PackStrongPotions( 6, 12 );
|
||||
}
|
||||
|
||||
public FactionNecromancer( 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionPaladin : BaseFactionGuard
|
||||
{
|
||||
public override GuardAI GuardAI{ get{ return GuardAI.Magic | GuardAI.Melee | GuardAI.Smart | GuardAI.Curse | GuardAI.Bless; } }
|
||||
|
||||
[Constructable]
|
||||
public FactionPaladin() : base( "the paladin" )
|
||||
{
|
||||
GenerateBody( false, false );
|
||||
|
||||
SetStr( 151, 175 );
|
||||
SetDex( 61, 85 );
|
||||
SetInt( 81, 95 );
|
||||
|
||||
SetResistance( ResistanceType.Physical, 40, 60 );
|
||||
SetResistance( ResistanceType.Fire, 40, 60 );
|
||||
SetResistance( ResistanceType.Cold, 40, 60 );
|
||||
SetResistance( ResistanceType.Energy, 40, 60 );
|
||||
SetResistance( ResistanceType.Poison, 40, 60 );
|
||||
|
||||
VirtualArmor = 32;
|
||||
|
||||
SetSkill( SkillName.Swords, 110.0, 120.0 );
|
||||
SetSkill( SkillName.Wrestling, 110.0, 120.0 );
|
||||
SetSkill( SkillName.Tactics, 110.0, 120.0 );
|
||||
SetSkill( SkillName.MagicResist, 110.0, 120.0 );
|
||||
SetSkill( SkillName.Healing, 110.0, 120.0 );
|
||||
SetSkill( SkillName.Anatomy, 110.0, 120.0 );
|
||||
|
||||
SetSkill( SkillName.Magery, 110.0, 120.0 );
|
||||
SetSkill( SkillName.EvalInt, 110.0, 120.0 );
|
||||
SetSkill( SkillName.Meditation, 110.0, 120.0 );
|
||||
|
||||
AddItem( Immovable( Rehued( new PlateChest(), 2125 ) ) );
|
||||
AddItem( Immovable( Rehued( new PlateLegs(), 2125 ) ) );
|
||||
AddItem( Immovable( Rehued( new PlateHelm(), 2125 ) ) );
|
||||
AddItem( Immovable( Rehued( new PlateGorget(), 2125 ) ) );
|
||||
AddItem( Immovable( Rehued( new PlateArms(), 2125 ) ) );
|
||||
AddItem( Immovable( Rehued( new PlateGloves(), 2125 ) ) );
|
||||
|
||||
AddItem( Immovable( Rehued( new BodySash(), 1254 ) ) );
|
||||
AddItem( Immovable( Rehued( new Cloak(), 1254 ) ) );
|
||||
|
||||
AddItem( Newbied( new Halberd() ) );
|
||||
|
||||
AddItem( Immovable( Rehued( new VirtualMountItem( this ), 1254 ) ) );
|
||||
|
||||
PackItem( new Bandage( Utility.RandomMinMax( 30, 40 ) ) );
|
||||
PackStrongPotions( 6, 12 );
|
||||
}
|
||||
|
||||
public FactionPaladin( 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionSorceress : BaseFactionGuard
|
||||
{
|
||||
public override GuardAI GuardAI{ get{ return GuardAI.Magic | GuardAI.Bless | GuardAI.Curse; } }
|
||||
|
||||
[Constructable]
|
||||
public FactionSorceress() : base( "the sorceress" )
|
||||
{
|
||||
GenerateBody( true, false );
|
||||
|
||||
SetStr( 126, 150 );
|
||||
SetDex( 61, 85 );
|
||||
SetInt( 126, 150 );
|
||||
|
||||
SetDamageType( ResistanceType.Physical, 100 );
|
||||
|
||||
SetResistance( ResistanceType.Physical, 30, 50 );
|
||||
SetResistance( ResistanceType.Fire, 30, 50 );
|
||||
SetResistance( ResistanceType.Cold, 30, 50 );
|
||||
SetResistance( ResistanceType.Energy, 30, 50 );
|
||||
SetResistance( ResistanceType.Poison, 30, 50 );
|
||||
|
||||
VirtualArmor = 24;
|
||||
|
||||
SetSkill( SkillName.Macing, 100.0, 110.0 );
|
||||
SetSkill( SkillName.Wrestling, 100.0, 110.0 );
|
||||
SetSkill( SkillName.Tactics, 100.0, 110.0 );
|
||||
SetSkill( SkillName.MagicResist, 100.0, 110.0 );
|
||||
SetSkill( SkillName.Healing, 100.0, 110.0 );
|
||||
SetSkill( SkillName.Anatomy, 100.0, 110.0 );
|
||||
|
||||
SetSkill( SkillName.Magery, 100.0, 110.0 );
|
||||
SetSkill( SkillName.EvalInt, 100.0, 110.0 );
|
||||
SetSkill( SkillName.Meditation, 100.0, 110.0 );
|
||||
|
||||
AddItem( Immovable( Rehued( new WizardsHat(), 1325 ) ) );
|
||||
AddItem( Immovable( Rehued( new Sandals(), 1325 ) ) );
|
||||
AddItem( Immovable( Rehued( new LeatherGorget(), 1325 ) ) );
|
||||
AddItem( Immovable( Rehued( new LeatherGloves(), 1325 ) ) );
|
||||
AddItem( Immovable( Rehued( new LeatherLegs(), 1325 ) ) );
|
||||
AddItem( Immovable( Rehued( new Skirt(), 1325 ) ) );
|
||||
AddItem( Immovable( Rehued( new FemaleLeatherChest(), 1325 ) ) );
|
||||
AddItem( Newbied( Rehued( new QuarterStaff(), 1310 ) ) );
|
||||
|
||||
PackItem( new Bandage( Utility.RandomMinMax( 30, 40 ) ) );
|
||||
PackStrongPotions( 6, 12 );
|
||||
}
|
||||
|
||||
public FactionSorceress( 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
using System;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionWizard : BaseFactionGuard
|
||||
{
|
||||
public override GuardAI GuardAI{ get{ return GuardAI.Magic | GuardAI.Smart | GuardAI.Bless | GuardAI.Curse; } }
|
||||
|
||||
[Constructable]
|
||||
public FactionWizard() : base( "the wizard" )
|
||||
{
|
||||
GenerateBody( false, false );
|
||||
|
||||
SetStr( 151, 175 );
|
||||
SetDex( 61, 85 );
|
||||
SetInt( 151, 175 );
|
||||
|
||||
SetDamageType( ResistanceType.Physical, 100 );
|
||||
|
||||
SetResistance( ResistanceType.Physical, 40, 60 );
|
||||
SetResistance( ResistanceType.Fire, 40, 60 );
|
||||
SetResistance( ResistanceType.Cold, 40, 60 );
|
||||
SetResistance( ResistanceType.Energy, 40, 60 );
|
||||
SetResistance( ResistanceType.Poison, 40, 60 );
|
||||
|
||||
VirtualArmor = 32;
|
||||
|
||||
SetSkill( SkillName.Macing, 110.0, 120.0 );
|
||||
SetSkill( SkillName.Wrestling, 110.0, 120.0 );
|
||||
SetSkill( SkillName.Tactics, 110.0, 120.0 );
|
||||
SetSkill( SkillName.MagicResist, 110.0, 120.0 );
|
||||
SetSkill( SkillName.Healing, 110.0, 120.0 );
|
||||
SetSkill( SkillName.Anatomy, 110.0, 120.0 );
|
||||
|
||||
SetSkill( SkillName.Magery, 110.0, 120.0 );
|
||||
SetSkill( SkillName.EvalInt, 110.0, 120.0 );
|
||||
SetSkill( SkillName.Meditation, 110.0, 120.0 );
|
||||
|
||||
AddItem( Immovable( Rehued( new WizardsHat(), 1325 ) ) );
|
||||
AddItem( Immovable( Rehued( new Sandals(), 1325 ) ) );
|
||||
AddItem( Immovable( Rehued( new Robe(), 1310 ) ) );
|
||||
AddItem( Immovable( Rehued( new LeatherGloves(), 1325 ) ) );
|
||||
AddItem( Newbied( Rehued( new GnarledStaff(), 1310 ) ) );
|
||||
|
||||
PackItem( new Bandage( Utility.RandomMinMax( 30, 40 ) ) );
|
||||
PackStrongPotions( 6, 12 );
|
||||
}
|
||||
|
||||
public FactionWizard( 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
115
Scripts/Engines/Factions/Mobiles/Vendors/BaseFactionVendor.cs
Normal file
115
Scripts/Engines/Factions/Mobiles/Vendors/BaseFactionVendor.cs
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public abstract class BaseFactionVendor : BaseVendor
|
||||
{
|
||||
private Town m_Town;
|
||||
private Faction m_Faction;
|
||||
|
||||
[CommandProperty( AccessLevel.Counselor, AccessLevel.Administrator )]
|
||||
public Town Town
|
||||
{
|
||||
get{ return m_Town; }
|
||||
set{ Unregister(); m_Town = value; Register(); }
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.Counselor, AccessLevel.Administrator )]
|
||||
public Faction Faction
|
||||
{
|
||||
get{ return m_Faction; }
|
||||
set{ Unregister(); m_Faction = value; Register(); }
|
||||
}
|
||||
|
||||
public void Register()
|
||||
{
|
||||
if ( m_Town != null && m_Faction != null )
|
||||
m_Town.RegisterVendor( this );
|
||||
}
|
||||
|
||||
public override bool OnMoveOver( Mobile m )
|
||||
{
|
||||
if ( Core.ML )
|
||||
return true;
|
||||
|
||||
return base.OnMoveOver( m );
|
||||
}
|
||||
|
||||
public void Unregister()
|
||||
{
|
||||
if ( m_Town != null )
|
||||
m_Town.UnregisterVendor( this );
|
||||
}
|
||||
|
||||
private List<SBInfo> m_SBInfos = new List<SBInfo>();
|
||||
protected override List<SBInfo> SBInfos{ get { return m_SBInfos; } }
|
||||
|
||||
public override void InitSBInfo()
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
base.OnAfterDelete();
|
||||
|
||||
Unregister();
|
||||
}
|
||||
|
||||
public override bool CheckVendorAccess( Mobile from )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public BaseFactionVendor( Town town, Faction faction, string title ) : base( title )
|
||||
{
|
||||
Frozen = true;
|
||||
CantWalk = true;
|
||||
Female = false;
|
||||
BodyValue = 400;
|
||||
Name = NameList.RandomName( "male" );
|
||||
|
||||
RangeHome = 0;
|
||||
|
||||
m_Town = town;
|
||||
m_Faction = faction;
|
||||
Register();
|
||||
}
|
||||
|
||||
public BaseFactionVendor( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.Write( (int) 0 ); // version
|
||||
|
||||
Town.WriteReference( writer, m_Town );
|
||||
Faction.WriteReference( writer, m_Faction );
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
m_Town = Town.ReadReference( reader );
|
||||
m_Faction = Faction.ReadReference( reader );
|
||||
Register();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Frozen = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server;
|
||||
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
|
||||
{
|
||||
SetSkill( SkillName.Carpentry, 85.0, 100.0 );
|
||||
SetSkill( SkillName.Lumberjacking, 60.0, 83.0 );
|
||||
}
|
||||
|
||||
public override void InitSBInfo()
|
||||
{
|
||||
SBInfos.Add( new SBFactionBoard() );
|
||||
}
|
||||
|
||||
public override void InitOutfit()
|
||||
{
|
||||
base.InitOutfit();
|
||||
|
||||
AddItem( new HalfApron() );
|
||||
}
|
||||
|
||||
public FactionBoardVendor( 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();
|
||||
}
|
||||
}
|
||||
|
||||
public class SBFactionBoard : SBInfo
|
||||
{
|
||||
private List<GenericBuyInfo> m_BuyInfo = new InternalBuyInfo();
|
||||
private IShopSellInfo m_SellInfo = new InternalSellInfo();
|
||||
|
||||
public SBFactionBoard()
|
||||
{
|
||||
}
|
||||
|
||||
public override IShopSellInfo SellInfo { get { return m_SellInfo; } }
|
||||
public override List<GenericBuyInfo> BuyInfo { get { return m_BuyInfo; } }
|
||||
|
||||
public class InternalBuyInfo : List<GenericBuyInfo>
|
||||
{
|
||||
public InternalBuyInfo()
|
||||
{
|
||||
for ( int i = 0; i < 5; ++i )
|
||||
Add( new GenericBuyInfo( typeof( Board ), 3, 20, 0x1BD7, 0 ) );
|
||||
}
|
||||
}
|
||||
|
||||
public class InternalSellInfo : GenericSellInfo
|
||||
{
|
||||
public InternalSellInfo()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,81 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server;
|
||||
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" )
|
||||
{
|
||||
SetSkill( SkillName.Alchemy, 85.0, 100.0 );
|
||||
SetSkill( SkillName.TasteID, 65.0, 88.0 );
|
||||
}
|
||||
|
||||
public override void InitSBInfo()
|
||||
{
|
||||
SBInfos.Add( new SBFactionBottle() );
|
||||
}
|
||||
|
||||
public override VendorShoeType ShoeType
|
||||
{
|
||||
get{ return Utility.RandomBool() ? VendorShoeType.Shoes : VendorShoeType.Sandals; }
|
||||
}
|
||||
|
||||
public override void InitOutfit()
|
||||
{
|
||||
base.InitOutfit();
|
||||
|
||||
AddItem( new Robe( Utility.RandomPinkHue() ) );
|
||||
}
|
||||
|
||||
public FactionBottleVendor( 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();
|
||||
}
|
||||
}
|
||||
|
||||
public class SBFactionBottle : SBInfo
|
||||
{
|
||||
private List<GenericBuyInfo> m_BuyInfo = new InternalBuyInfo();
|
||||
private IShopSellInfo m_SellInfo = new InternalSellInfo();
|
||||
|
||||
public SBFactionBottle()
|
||||
{
|
||||
}
|
||||
|
||||
public override IShopSellInfo SellInfo { get { return m_SellInfo; } }
|
||||
public override List<GenericBuyInfo> BuyInfo { get { return m_BuyInfo; } }
|
||||
|
||||
public class InternalBuyInfo : List<GenericBuyInfo>
|
||||
{
|
||||
public InternalBuyInfo()
|
||||
{
|
||||
for ( int i = 0; i < 5; ++i )
|
||||
Add( new GenericBuyInfo( typeof( Bottle ), 5, 20, 0xF0E, 0 ) );
|
||||
}
|
||||
}
|
||||
|
||||
public class InternalSellInfo : GenericSellInfo
|
||||
{
|
||||
public InternalSellInfo()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class FactionHorseVendor : BaseFactionVendor
|
||||
{
|
||||
public FactionHorseVendor( Town town, Faction faction ) : base( town, faction, "the Horse Breeder" )
|
||||
{
|
||||
SetSkill( SkillName.AnimalLore, 64.0, 100.0 );
|
||||
SetSkill( SkillName.AnimalTaming, 90.0, 100.0 );
|
||||
SetSkill( SkillName.Veterinary, 65.0, 88.0 );
|
||||
}
|
||||
|
||||
public override void InitSBInfo()
|
||||
{
|
||||
}
|
||||
|
||||
public override VendorShoeType ShoeType
|
||||
{
|
||||
get{ return Female ? VendorShoeType.ThighBoots : VendorShoeType.Boots; }
|
||||
}
|
||||
|
||||
public override int GetShoeHue()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public override void InitOutfit()
|
||||
{
|
||||
base.InitOutfit();
|
||||
|
||||
AddItem( Utility.RandomBool() ? (Item)new QuarterStaff() : (Item)new ShepherdsCrook() );
|
||||
}
|
||||
|
||||
public FactionHorseVendor( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
public override void VendorBuy( Mobile from )
|
||||
{
|
||||
if ( this.Faction == null || Faction.Find( from, true ) != this.Faction )
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
79
Scripts/Engines/Factions/Mobiles/Vendors/FactionOreVendor.cs
Normal file
79
Scripts/Engines/Factions/Mobiles/Vendors/FactionOreVendor.cs
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server;
|
||||
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
|
||||
SetSkill( SkillName.Carpentry, 85.0, 100.0 );
|
||||
SetSkill( SkillName.Lumberjacking, 60.0, 83.0 );
|
||||
}
|
||||
|
||||
public override void InitSBInfo()
|
||||
{
|
||||
SBInfos.Add( new SBFactionOre() );
|
||||
}
|
||||
|
||||
public override void InitOutfit()
|
||||
{
|
||||
base.InitOutfit();
|
||||
|
||||
AddItem( new HalfApron() );
|
||||
}
|
||||
|
||||
public FactionOreVendor( 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();
|
||||
}
|
||||
}
|
||||
|
||||
public class SBFactionOre : SBInfo
|
||||
{
|
||||
private static readonly object[] m_FixedSizeArgs = { true };
|
||||
|
||||
private List<GenericBuyInfo> m_BuyInfo = new InternalBuyInfo();
|
||||
private IShopSellInfo m_SellInfo = new InternalSellInfo();
|
||||
|
||||
public SBFactionOre()
|
||||
{
|
||||
}
|
||||
|
||||
public override IShopSellInfo SellInfo { get { return m_SellInfo; } }
|
||||
public override List<GenericBuyInfo> BuyInfo { get { return m_BuyInfo; } }
|
||||
|
||||
public class InternalBuyInfo : List<GenericBuyInfo>
|
||||
{
|
||||
public InternalBuyInfo()
|
||||
{
|
||||
for ( int i = 0; i < 5; ++i )
|
||||
Add( new GenericBuyInfo( typeof( IronOre ), 16, 20, 0x19B8, 0, m_FixedSizeArgs ) );
|
||||
}
|
||||
}
|
||||
|
||||
public class InternalSellInfo : GenericSellInfo
|
||||
{
|
||||
public InternalSellInfo()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server;
|
||||
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" )
|
||||
{
|
||||
SetSkill( SkillName.EvalInt, 65.0, 88.0 );
|
||||
SetSkill( SkillName.Inscribe, 60.0, 83.0 );
|
||||
SetSkill( SkillName.Magery, 64.0, 100.0 );
|
||||
SetSkill( SkillName.Meditation, 60.0, 83.0 );
|
||||
SetSkill( SkillName.MagicResist, 65.0, 88.0 );
|
||||
SetSkill( SkillName.Wrestling, 36.0, 68.0 );
|
||||
}
|
||||
|
||||
public override void InitSBInfo()
|
||||
{
|
||||
SBInfos.Add( new SBFactionReagent() );
|
||||
}
|
||||
|
||||
public override VendorShoeType ShoeType
|
||||
{
|
||||
get{ return Utility.RandomBool() ? VendorShoeType.Shoes : VendorShoeType.Sandals; }
|
||||
}
|
||||
|
||||
public override void InitOutfit()
|
||||
{
|
||||
base.InitOutfit();
|
||||
|
||||
AddItem( new Robe( Utility.RandomBlueHue() ) );
|
||||
AddItem( new GnarledStaff() );
|
||||
}
|
||||
|
||||
public FactionReagentVendor( 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();
|
||||
}
|
||||
}
|
||||
|
||||
public class SBFactionReagent : SBInfo
|
||||
{
|
||||
private List<GenericBuyInfo> m_BuyInfo = new InternalBuyInfo();
|
||||
private IShopSellInfo m_SellInfo = new InternalSellInfo();
|
||||
|
||||
public SBFactionReagent()
|
||||
{
|
||||
}
|
||||
|
||||
public override IShopSellInfo SellInfo { get { return m_SellInfo; } }
|
||||
public override List<GenericBuyInfo> BuyInfo { get { return m_BuyInfo; } }
|
||||
|
||||
public class InternalBuyInfo : List<GenericBuyInfo>
|
||||
{
|
||||
public InternalBuyInfo()
|
||||
{
|
||||
for ( int i = 0; i < 2; ++i )
|
||||
{
|
||||
Add( new GenericBuyInfo( typeof( BlackPearl ), 5, 20, 0xF7A, 0 ) );
|
||||
Add( new GenericBuyInfo( typeof( Bloodmoss ), 5, 20, 0xF7B, 0 ) );
|
||||
Add( new GenericBuyInfo( typeof( MandrakeRoot ), 3, 20, 0xF86, 0 ) );
|
||||
Add( new GenericBuyInfo( typeof( Garlic ), 3, 20, 0xF84, 0 ) );
|
||||
Add( new GenericBuyInfo( typeof( Ginseng ), 3, 20, 0xF85, 0 ) );
|
||||
Add( new GenericBuyInfo( typeof( Nightshade ), 3, 20, 0xF88, 0 ) );
|
||||
Add( new GenericBuyInfo( typeof( SpidersSilk ), 3, 20, 0xF8D, 0 ) );
|
||||
Add( new GenericBuyInfo( typeof( SulfurousAsh ), 3, 20, 0xF8C, 0 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class InternalSellInfo : GenericSellInfo
|
||||
{
|
||||
public InternalSellInfo()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue