using System; using System.IO; using System.Reflection; using System.Collections; using System.Collections.Generic; using Server; using Server.Accounting; using Server.ContextMenus; using Server.Engines.Help; using Server.Gumps; using Server.Items; using Server.Misc; using Server.Multis; using Server.Network; using Server.Regions; using Server.Spells; using Server.Spells.Fifth; using Server.Spells.Seventh; using Server.Targeting; using Server.Commands.Generic; using Server.Commands; using Server.DuelSystem; using Server.Factions; using Server.Engines.PartySystem; using Server.Guilds; namespace Server.Mobiles { public enum HideEffects { Default, WhiteGate, BlackGate, BlueGate, RedGate, Divine, Explosion, FlameStrike, BlueFlames, Lightning, Reaper, BigFlameStrike, BigDivine, BigGates, RadialFlames, BigWater } public class RealmPlayer : PlayerMobile { //Vote stone private DateTime m_LastVoteTime; [CommandProperty(AccessLevel.Counselor, AccessLevel.Seer)] public DateTime LastVoteTime { get{return m_LastVoteTime;} set{m_LastVoteTime = value;} } private int m_Votes; [CommandProperty(AccessLevel.Counselor, AccessLevel.Seer)] public int Votes { get { Account acct = this.Account as Account; if(acct == null) return 0; else { string tag = acct.GetTag("votes"); if(tag == null) acct.AddTag("votes", m_Votes.ToString()); else { try { return Convert.ToInt32(tag); } catch {} } } return 0; } set{ Account acct = this.Account as Account; if(acct != null) { acct.SetTag("votes", value.ToString()); } } } [CommandProperty(AccessLevel.GameMaster)] public int SetBodyMod { set{this.BodyMod = new Body(value);} get{return this.BodyMod.BodyID;} } [CommandProperty(AccessLevel.Counselor)] public int TotalHours { get { return this.GameTime.Hours + (this.GameTime.Days * 24); } } private static ArrayList m_Instances = new ArrayList(); public static ArrayList Instances{ get{ return m_Instances; } } private static ArrayList m_Duelists = new ArrayList(); public static ArrayList Duelists{ get{ return m_Duelists; } } // GM Hide Effects public HideEffects m_HideEffect; // Dueling Pits. private bool m_OpenRequest, m_CanRegenHits, m_BannedFromPits, m_FillCorpse; private bool m_IsHelper, m_EventBan, m_HasGMBody, m_UseNotoriety, m_AlwaysMurderer; private int m_Level, m_Score, m_Wins, m_Losses; /* * Dueling Pits. * Cannot override 'CanRegenHits.set' because 'Mobile.CanRegenHits' does not have * a overidable set accessor. The mothod SetCanRegenHits is used for toggling the * CanRegenHits property. */ public override bool CanRegenHits{ get{ return (Alive ? m_CanRegenHits : false); } } // Dueling Pits. public bool OpenRequest{ get{ return m_OpenRequest; } set{ m_OpenRequest = value; } } [CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)] public int Score{ get{ return m_Score; } set{ m_Score = value; } } [CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)] public int Wins{ get{ return m_Wins; } set{ m_Wins = value; } } [CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)] public int Losses{ get{ return m_Losses; } set{ m_Losses = value; } } [CommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster)] public int Level { get{ return m_Level; } set { if ( value < 0 ) value = 0; m_Level = value; if ( (m_Wins + m_Losses) >= 5 && !m_Duelists.Contains( this ) ) m_Duelists.Add( this ); } } // Dueling Pits. [CommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster)] public bool BannedFromPits { get{ return m_BannedFromPits; } set { m_BannedFromPits = value; if ( value ) { m_Wins = 0; m_Losses = 0; m_Level = 0; if ( m_Duelists.Contains( this ) ) m_Duelists.Remove( this ); } } } /* * Is a newbie helper. They are allowed in new player area but can't attack nor be * attack by anything. */ [CommandProperty(AccessLevel.Seer)] public bool FillCorpse{ get{ return m_FillCorpse; } set{ m_FillCorpse = value; } } [CommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster)] public bool IsHelper{ get{ return m_IsHelper; } set{ m_IsHelper = value; } } [CommandProperty(AccessLevel.Counselor, AccessLevel.Seer)] public bool EventBan{ get{ return m_EventBan; } set{ m_EventBan = value; } } [CommandProperty(AccessLevel.Counselor)] public HideEffects HideEffect { get{ return m_HideEffect; } set { if(this.AccessLevel < AccessLevel.Seer && this.Title != "[Developer]") { if(value == HideEffects.Reaper || value == HideEffects.BigFlameStrike || value == HideEffects.BigDivine || value == HideEffects.BigGates || value == HideEffects.BigWater || value == HideEffects.RadialFlames) { this.SendMessage(38, "You cannot use this Hide Effect."); } else { m_HideEffect = value; } } else { m_HideEffect = value; } } } [CommandProperty(AccessLevel.Administrator)] public bool UseNotoriety { get{ return m_UseNotoriety; } set { if ( AccessLevel == AccessLevel.Administrator ) m_UseNotoriety = value; else m_UseNotoriety = false; Delta( MobileDelta.Noto ); } } [CommandProperty(AccessLevel.Administrator)] public bool HasGMBody { get{ return m_HasGMBody; } set { if ( AccessLevel > AccessLevel.Player ) m_HasGMBody = value; else m_HasGMBody = false; if ( m_HasGMBody ) BodyValue = 0x3DB; else if ( Female ) BodyValue = 0x191; else BodyValue = 0x190; } } // They are made murderers (perminatly red) until toggled off. [CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)] public bool AlwaysMurderer { get{ return m_AlwaysMurderer; } set { m_AlwaysMurderer = value; Delta( MobileDelta.Noto ); } } /* * New code for donation reward system * [CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator )] public override bool Donated { get { return base.Donated; } set { base.Donated = value; if ( value ) this.Account.SetTag( "protected", value.ToString() ); } } */ /* * Old Code for Donation Reward System */ [CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator )] public bool Donated { get { Account acct = (Account)this.Account; return Convert.ToBoolean( acct.GetTag( "donated" ) ); } set { Account acct = (Account)this.Account; acct.SetTag( "donated", value.ToString() ); if ( value ) acct.SetTag( "protected", value.ToString() ); } } //Account Cleanup [CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator )] public bool ProtectAccount { get { Account acct = (Account)this.Account; return Convert.ToBoolean( acct.GetTag( "protected" ) ); } set { Account acct = (Account)this.Account; acct.SetTag( "protected", value.ToString() ); } } [CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator )] public bool FastWalkExempt { get { Account acct = (Account)this.Account; return Convert.ToBoolean( acct.GetTag( "FastWalkExempt" ) ); } set { Account acct = (Account)this.Account; acct.SetTag( "FastWalkExempt", value.ToString() ); if ( value ) { acct.RemoveTag( "FastWalk" ); acct.RemoveTag( "LastFastWalk" ); } } } private Item m_LastBOD; [CommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster )] public Item LastBOD { get{return m_LastBOD;} set{m_LastBOD = value;} } private int m_MaxHouses; [CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator )] public int MaxHouses { get{return m_MaxHouses;} set{m_MaxHouses = value;} } //Object Constructor: Also known as .ctor public RealmPlayer() { m_CanRegenHits = true; m_Instances.Add( this ); m_MaxHouses = 2; } public RealmPlayer( Serial s ) : base( s ) { } public override void Serialize( GenericWriter writer ) { base.Serialize( writer ); //Version 3: Added MaxHouses //Version 2: Addition of LastBOD //Version 1: Addition of voting stone writer.Write( (int) 3 ); // version writer.Write( (int) m_MaxHouses ); writer.Write( m_LastBOD as Item ); writer.Write( (DateTime) m_LastVoteTime); writer.Write( (int) m_Votes); //Event system writer.Write( (bool) m_EventBan ); // Dueling Pits writer.Write( m_Score ); writer.Write( m_Level ); writer.Write( m_BannedFromPits ); writer.Write( m_Wins ); writer.Write( m_Losses ); writer.Write( (bool) m_IsHelper ); writer.Write( (int) m_HideEffect ); writer.Write( (bool) m_HasGMBody ); writer.Write( (bool) m_UseNotoriety ); writer.Write( (bool) m_AlwaysMurderer ); } public override void Deserialize( GenericReader reader ) { base.Deserialize( reader ); int version = reader.ReadInt(); // version //Default values for updates: if(version == 0) { m_LastVoteTime = DateTime.Now.Subtract(TimeSpan.FromHours(24)); m_Votes = 0; } if(version == 2) m_MaxHouses = 2; switch ( version ) { case 5: case 4: case 3: { m_MaxHouses = reader.ReadInt(); goto case 2; } case 2: { m_LastBOD = reader.ReadItem(); goto case 1; } case 1: { m_LastVoteTime = reader.ReadDateTime(); m_Votes = reader.ReadInt(); goto case 0; } case 0: { m_EventBan = reader.ReadBool(); m_Score = reader.ReadInt(); m_Level = reader.ReadInt(); m_BannedFromPits = reader.ReadBool(); m_Wins = reader.ReadInt(); m_Losses = reader.ReadInt(); m_IsHelper = reader.ReadBool(); m_HideEffect = (HideEffects) reader.ReadInt(); m_HasGMBody = reader.ReadBool(); m_UseNotoriety = reader.ReadBool(); m_AlwaysMurderer = reader.ReadBool(); break; } } m_Instances.Add( this ); // Dueling Pits if ( (m_Wins + m_Losses) >= 5 ) m_Duelists.Add( this ); // Dueling Pits m_CanRegenHits = true; } public bool Wearing(Type type) { foreach(Item i in Items) { if(i.GetType() == type) return true; } return false; } public static new void Initialize() { CommandSystem.Register( "FindOwner", AccessLevel.GameMaster, new CommandEventHandler( FindOwner_OnCommand ) ); CommandSystem.Register( "GameTime", AccessLevel.Player, new CommandEventHandler( GameTime_OnCommand ) ); } [Usage( "FindOwner" )] [Description( "Find the owner of an item." )] private static void FindOwner_OnCommand( CommandEventArgs e ) { Mobile from = e.Mobile; if(e.Length == 1 && e.GetString(0).ToLower() == "root") { from.Target = new FindOwnerTarget(true); } else { from.Target = new FindOwnerTarget(false); } } [Usage( "GameTime" )] [Description( "Display your game time in hours." )] private static void GameTime_OnCommand( CommandEventArgs e ) { Mobile from = e.Mobile; if(from is PlayerMobile) { TimeSpan time = ((PlayerMobile)from).GameTime; from.SendMessage("Your game time is {0} days, {1} hours, {2} minutes, and {3} seconds.", time.Days.ToString(), time.Hours.ToString(), time.Minutes.ToString(), time.Seconds.ToString()); } } private class FindOwnerTarget : Target { private bool m_Root; public FindOwnerTarget(bool root) : base(-1, false, TargetFlags.None) { m_Root = root; } protected override void OnTarget(Mobile from, object targeted) { if(targeted is Item) { if(m_Root) { ArrayList list = new ArrayList(); list.Add(((Item)targeted).RootParent); from.SendGump(new InterfaceGump(from, list, 0)); } else { Mobile owner = FindOwner((Item)targeted); if(owner == null) { from.SendMessage("No owner was found for that item."); } else { from.SendMessage("The type of the found owner was {0}.", owner.GetType().Name); ArrayList list = new ArrayList(); list.Add(owner); from.SendGump(new InterfaceGump(from, list, 0)); } } } } } public static Mobile FindOwner(Item item) { if(item.RootParent is Item) { item = (Item) item.RootParent; } if(item.RootParent is BaseCreature) { BaseCreature bc = (BaseCreature) item.RootParent; if(bc.ControlMaster != null) { return bc.ControlMaster as Mobile; } else if(bc.SummonMaster != null) { return bc.SummonMaster as Mobile; } else { return bc as Mobile; } } if(item.RootParent is PlayerMobile) { return item.RootParent as Mobile; } if(item != null) { BaseHouse house = BaseHouse.FindHouseAt(item); if(house != null && house.Owner != null) return house.Owner; } return null; } public override void OnAosSingleClick( Mobile from ) { if ( Map == Faction.Facet ) { PlayerState pl = PlayerState.Find( this ); if ( pl != null ) { string text; bool ascii = false; Faction faction = pl.Faction; if ( faction.Commander == this ) text = String.Concat( this.Female ? "(Commanding Lady of the " : "(Commanding Lord of the ", faction.Definition.FriendlyName, ")" ); else if ( pl.Sheriff != null ) text = String.Concat( "(The Sheriff of ", pl.Sheriff.Definition.FriendlyName, ", ", faction.Definition.FriendlyName, ")" ); else if ( pl.Finance != null ) text = String.Concat( "(The Finance Minister of ", pl.Finance.Definition.FriendlyName, ", ", faction.Definition.FriendlyName, ")" ); else { ascii = true; if ( pl.MerchantTitle != MerchantTitle.None ) text = String.Concat( "(", MerchantTitles.GetInfo( pl.MerchantTitle ).Title.String, ", ", faction.Definition.FriendlyName, ")" ); else text = String.Concat( "(", pl.Rank.Title.String, ", ", faction.Definition.FriendlyName, ")" ); } int hue = ( Faction.Find( from ) == faction ? 98 : 38 ); PrivateOverheadMessage( MessageType.Label, hue, ascii, text, from.NetState ); } } base.OnAosSingleClick( from ); } public override void OnDeath( Container c ) { base.OnDeath( c ); //find the killer Mobile killer = FindMostRecentDamager(false); if(killer == null) return; //find the killer's guild BaseGuild killerguild = killer.Guild; if(killerguild == null) return; //find the victim's guild BaseGuild guild = Guild; if(guild == null) return; //check to see if they're in the same guild if(guild == killerguild) return; //check to see fi they're partied if(Party != null && killer.Party == Party) return; //add a kill for the killer's guild //if(killerguild is Guild) { //((Guild)killerguild).AddKill(guild); //Console.WriteLine("Adding kill {0}", DateTime.Now.ToString()); } if ( m_FillCorpse ) { ArrayList toGive = new ArrayList(); List list = Aggressors; for ( int i = 0; i < list.Count; ++i ) { AggressorInfo info = (AggressorInfo)list[i]; if ( info.Attacker.Player && info.Attacker.Alive && (DateTime.Now - info.LastCombatTime) < TimeSpan.FromSeconds( 30.0 ) && !toGive.Contains( info.Attacker ) ) toGive.Add( info.Attacker ); } list = Aggressed; for ( int i = 0; i < list.Count; ++i ) { AggressorInfo info = (AggressorInfo)list[i]; if ( info.Defender.Player && info.Defender.Alive && (DateTime.Now - info.LastCombatTime) < TimeSpan.FromSeconds( 30.0 ) && !toGive.Contains( info.Defender ) ) toGive.Add( info.Defender ); } if ( toGive.Count > 0 ) { for ( int i = 0; i < toGive.Count; ++i ) { int level; double random = Utility.RandomDouble(); if ( 0.1 >= random ) level = 20; else if ( 0.4 >= random ) level = 15; else level = 10; Mobile m = (Mobile)toGive[i]; PowerScroll ps = PowerScroll.CreateRandom( level, level ); if ( !m.PlaceInBackpack( ps ) ) ps.Delete(); BankCheck check = new BankCheck( Utility.Random( 10000, 20000 ) ); if ( !m.PlaceInBackpack( check ) ) check.Delete(); } } } if ( Region is Server.DuelSystem.DuelRegion ) { m_CanRegenHits = false; ((Server.DuelSystem.DuelRegion)Region).Pit.End(); return false; } return base.OnBeforeDeath(); } // Dueling Pits public void SetCanRegenHits( bool value ) { m_CanRegenHits = value; } public override void OnAfterDelete() { base.OnAfterDelete(); if ( m_Instances.Contains( this ) ) m_Instances.Remove( this ); if ( m_Duelists.Contains( this ) ) m_Duelists.Remove( this ); } public override void Resurrect() { base.Resurrect(); Item item = FindItemOnLayer( Layer.OuterTorso ); if ( item != null && item is DeathRobe ) item.Delete(); //Counselor body. It allows you to walk through doors. if ( m_HasGMBody && this.AccessLevel > AccessLevel.Player ) { if ( BodyValue != 0x3DB ) BodyValue = 0x3DB; } } public override void OnAfterResurrect() { base.OnAfterResurrect(); Mobile m = this as Mobile; if(m == null) return; } public override void OnBeneficialAction( Mobile target, bool isCriminal ) { if(Guild == null || target.Guild == null || Guild != target.Guild || ((Guild)Guild).IsAlly((Guild)target.Guild)) base.OnBeneficialAction(target, isCriminal); } public void AllianceMessage(SpeechEventArgs regArgs, BaseGuild guild, string text, MessageType type, int hue) { if(guild is Guild) { Guild g = (Guild) guild; if(g.Allies.Count == 0) { SendMessage("Your guild has no allies."); return; } } } } }