diff --git a/Scripts/Engines/Spawner/PremiumSpawner/PSCount.cs b/Scripts/Engines/Spawner/PremiumSpawner/PSCount.cs new file mode 100644 index 0000000..1eb4b1d --- /dev/null +++ b/Scripts/Engines/Spawner/PremiumSpawner/PSCount.cs @@ -0,0 +1,45 @@ +using System; +using System.IO; +using Server; +using System.Text; +using System.Collections.Generic; +using System.Net; +using Server.Mobiles; +using Server.Network; +using Server.Commands; + +namespace Server.Commands +{ + public class PSpawnerCount + { + public static void Initialize() + { + Register( "pscount", AccessLevel.Administrator, new CommandEventHandler( Clearall_OnCommand ) ); + } + + public static void Register( string command, AccessLevel access, CommandEventHandler handler ) + { + CommandSystem.Register( command, access, handler ); + } + + [Usage( "pscount" )] + [Description( "Count PremiumSpawners." )] + public static void Clearall_OnCommand( CommandEventArgs e ) + { + Mobile from = e.Mobile; + DateTime time = DateTime.Now; + + List pspawnerlist = new List(); + + foreach ( Item pspawner in World.Items.Values ) + { + if ( pspawner.Parent == null && pspawner is PremiumSpawner) + { + pspawnerlist.Add( pspawner ); + } + } + + from.SendMessage( "Premium Spawners: {0}", pspawnerlist.Count ); + } + } +} \ No newline at end of file diff --git a/Scripts/Engines/Spawner/PremiumSpawner/PremiumSpawner.cs b/Scripts/Engines/Spawner/PremiumSpawner/PremiumSpawner.cs new file mode 100644 index 0000000..b6ef9fe --- /dev/null +++ b/Scripts/Engines/Spawner/PremiumSpawner/PremiumSpawner.cs @@ -0,0 +1,1515 @@ +//Engine r147 +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using System.Text; +using Server; +using Server.Commands; +using Server.Items; +using Server.Network; +using CPA = Server.CommandPropertyAttribute; + +namespace Server.Mobiles +{ + public class PremiumSpawner : Item + { + private int m_Team; + private int m_HomeRange; // = old SpawnRange + private int m_WalkingRange = -1; // = old HomeRange + private int m_SpawnID = 99; + private int m_Count; + private int m_CountA; + private int m_CountB; + private int m_CountC; + private int m_CountD; + private int m_CountE; + private TimeSpan m_MinDelay; + private TimeSpan m_MaxDelay; + private List m_CreaturesName; // creatures to be spawned + private List m_Creatures; // spawned creatures + private List m_CreaturesNameA; + private List m_CreaturesA; + private List m_CreaturesNameB; + private List m_CreaturesB; + private List m_CreaturesNameC; + private List m_CreaturesC; + private List m_CreaturesNameD; + private List m_CreaturesD; + private List m_CreaturesNameE; + private List m_CreaturesE; + private DateTime m_End; + private InternalTimer m_Timer; + private bool m_Running; + private bool m_Water; + private bool m_Group; + private WayPoint m_WayPoint; + + public bool IsFull{ get{ return ( m_Creatures != null && m_Creatures.Count >= m_Count ); } } + public bool IsFulla{ get{ return ( m_CreaturesA != null && m_CreaturesA.Count >= m_CountA ); } } + public bool IsFullb{ get{ return ( m_CreaturesB != null && m_CreaturesB.Count >= m_CountB ); } } + public bool IsFullc{ get{ return ( m_CreaturesC != null && m_CreaturesC.Count >= m_CountC ); } } + public bool IsFulld{ get{ return ( m_CreaturesD != null && m_CreaturesD.Count >= m_CountD ); } } + public bool IsFulle{ get{ return ( m_CreaturesE != null && m_CreaturesE.Count >= m_CountE ); } } + + public List CreaturesName + { + get { return m_CreaturesName; } + set + { + m_CreaturesName = value; + if ( m_CreaturesName.Count < 1 ) + Stop(); + + InvalidateProperties(); + } + } + + public List SubSpawnerA + { + get { return m_CreaturesNameA; } + set + { + m_CreaturesNameA = value; + if ( m_CreaturesNameA.Count < 1 ) + Stop(); + + InvalidateProperties(); + } + } + + public List SubSpawnerB + { + get { return m_CreaturesNameB; } + set + { + m_CreaturesNameB = value; + if ( m_CreaturesNameB.Count < 1 ) + Stop(); + + InvalidateProperties(); + } + } + + public List SubSpawnerC + { + get { return m_CreaturesNameC; } + set + { + m_CreaturesNameC = value; + if ( m_CreaturesNameC.Count < 1 ) + Stop(); + + InvalidateProperties(); + } + } + + public List SubSpawnerD + { + get { return m_CreaturesNameD; } + set + { + m_CreaturesNameD = value; + if ( m_CreaturesNameD.Count < 1 ) + Stop(); + + InvalidateProperties(); + } + } + + public List SubSpawnerE + { + get { return m_CreaturesNameE; } + set + { + m_CreaturesNameE = value; + if ( m_CreaturesNameE.Count < 1 ) + Stop(); + + InvalidateProperties(); + } + } + + public List Creatures + { + get { return m_Creatures; } + set + { + m_Creatures = value; + if ( m_Creatures.Count < 1 ) + Stop(); + + InvalidateProperties(); + } + } + + public List CreaturesA + { + get { return m_CreaturesA; } + set + { + m_CreaturesA = value; + if ( m_CreaturesA.Count < 1 ) + Stop(); + + InvalidateProperties(); + } + } + + public List CreaturesB + { + get { return m_CreaturesB; } + set + { + m_CreaturesB = value; + if ( m_CreaturesB.Count < 1 ) + Stop(); + + InvalidateProperties(); + } + } + + public List CreaturesC + { + get { return m_CreaturesC; } + set + { + m_CreaturesC = value; + if ( m_CreaturesC.Count < 1 ) + Stop(); + + InvalidateProperties(); + } + } + + public List CreaturesD + { + get { return m_CreaturesD; } + set + { + m_CreaturesD = value; + if ( m_CreaturesD.Count < 1 ) + Stop(); + + InvalidateProperties(); + } + } + + public List CreaturesE + { + get { return m_CreaturesE; } + set + { + m_CreaturesE = value; + if ( m_CreaturesE.Count < 1 ) + Stop(); + + InvalidateProperties(); + } + } + + public virtual int CreaturesNameCount { get { return m_CreaturesName.Count; } } + public virtual int CreaturesNameCountA { get { return m_CreaturesNameA.Count; } } + public virtual int CreaturesNameCountB { get { return m_CreaturesNameB.Count; } } + public virtual int CreaturesNameCountC { get { return m_CreaturesNameC.Count; } } + public virtual int CreaturesNameCountD { get { return m_CreaturesNameD.Count; } } + public virtual int CreaturesNameCountE { get { return m_CreaturesNameE.Count; } } + + public override void OnAfterDuped( Item newItem ) + { + PremiumSpawner s = newItem as PremiumSpawner; + + if ( s == null ) + return; + + s.m_CreaturesName = new List( m_CreaturesName ); + s.m_CreaturesNameA = new List( m_CreaturesNameA ); + s.m_CreaturesNameB = new List( m_CreaturesNameB ); + s.m_CreaturesNameC = new List( m_CreaturesNameC ); + s.m_CreaturesNameD = new List( m_CreaturesNameD ); + s.m_CreaturesNameE = new List( m_CreaturesNameE ); + } + + [CommandProperty( AccessLevel.GameMaster )] + public int Count + { + get { return m_Count; } + set { m_Count = value; InvalidateProperties(); } + } + + [CommandProperty( AccessLevel.GameMaster )] + public int CountA + { + get { return m_CountA; } + set { m_CountA = value; InvalidateProperties(); } + } + + [CommandProperty( AccessLevel.GameMaster )] + public int CountB + { + get { return m_CountB; } + set { m_CountB = value; InvalidateProperties(); } + } + + [CommandProperty( AccessLevel.GameMaster )] + public int CountC + { + get { return m_CountC; } + set { m_CountC = value; InvalidateProperties(); } + } + + [CommandProperty( AccessLevel.GameMaster )] + public int CountD + { + get { return m_CountD; } + set { m_CountD = value; InvalidateProperties(); } + } + + [CommandProperty( AccessLevel.GameMaster )] + public int CountE + { + get { return m_CountE; } + set { m_CountE = value; InvalidateProperties(); } + } + + [CommandProperty( AccessLevel.GameMaster )] + public WayPoint WayPoint + { + get + { + return m_WayPoint; + } + set + { + m_WayPoint = value; + } + } + + [CommandProperty( AccessLevel.GameMaster )] + public bool Running + { + get { return m_Running; } + set + { + if ( value ) + Start(); + else + Stop(); + + InvalidateProperties(); + } + } + + [CommandProperty( AccessLevel.GameMaster )] + public int HomeRange + { + get { return m_HomeRange; } + set { m_HomeRange = value; InvalidateProperties(); } + } + + [CommandProperty( AccessLevel.GameMaster )] + public int WalkingRange + { + get { return m_WalkingRange; } + set { m_WalkingRange = value; InvalidateProperties(); } + } + + [CommandProperty( AccessLevel.GameMaster )] + public int SpawnID + { + get { return m_SpawnID; } + set { m_SpawnID = value; InvalidateProperties(); } + } + + [CommandProperty( AccessLevel.GameMaster )] + public int Team + { + get { return m_Team; } + set { m_Team = value; InvalidateProperties(); } + } + + [CommandProperty( AccessLevel.GameMaster )] + public TimeSpan MinDelay + { + get { return m_MinDelay; } + set { m_MinDelay = value; InvalidateProperties(); } + } + + [CommandProperty( AccessLevel.GameMaster )] + public TimeSpan MaxDelay + { + get { return m_MaxDelay; } + set { m_MaxDelay = value; InvalidateProperties(); } + } + + [CommandProperty( AccessLevel.GameMaster )] + public TimeSpan NextSpawn + { + get + { + if ( m_Running ) + return m_End - DateTime.Now; + else + return TimeSpan.FromSeconds( 0 ); + } + set + { + Start(); + DoTimer( value ); + } + } + + [CommandProperty( AccessLevel.GameMaster )] + public bool Group + { + get { return m_Group; } + set { m_Group = value; InvalidateProperties(); } + } + + [Constructable] + public PremiumSpawner( int amount, int subamountA, int subamountB, int subamountC, int subamountD, int subamountE, int spawnid, int minDelay, int maxDelay, int team, int homeRange, int walkingRange, string creatureName, string creatureNameA, string creatureNameB, string creatureNameC, string creatureNameD, string creatureNameE ) : base( 0x1f13 ) + { + List creaturesName = new List(); + creaturesName.Add( creatureName ); + + List creatureNameAA = new List(); + creaturesName.Add( creatureNameA ); + + List creatureNameBB = new List(); + creaturesName.Add( creatureNameB ); + + List creatureNameCC = new List(); + creaturesName.Add( creatureNameC ); + + List creatureNameDD = new List(); + creaturesName.Add( creatureNameD ); + + List creatureNameEE = new List(); + creaturesName.Add( creatureNameE ); + + InitSpawn( amount, subamountA, subamountB, subamountC, subamountD, subamountE, spawnid, TimeSpan.FromMinutes( minDelay ), TimeSpan.FromMinutes( maxDelay ), team, homeRange, walkingRange, creaturesName, creatureNameAA, creatureNameBB, creatureNameCC, creatureNameDD, creatureNameEE ); + } + + [Constructable] + public PremiumSpawner( string creatureName ) : base( 0x1f13 ) + { + List creaturesName = new List(); + creaturesName.Add( creatureName ); + + List creatureNameAA = new List(); + List creatureNameBB = new List(); + List creatureNameCC = new List(); + List creatureNameDD = new List(); + List creatureNameEE = new List(); + + InitSpawn( 1, 0, 0, 0, 0, 0, 99, TimeSpan.FromMinutes( 5 ), TimeSpan.FromMinutes( 10 ), 0, 4, -1, creaturesName, creatureNameAA, creatureNameBB, creatureNameCC, creatureNameDD, creatureNameEE ); + } + + [Constructable] + public PremiumSpawner() : base( 0x1f13 ) + { + List creaturesName = new List(); + + List creatureNameAA = new List(); + List creatureNameBB = new List(); + List creatureNameCC = new List(); + List creatureNameDD = new List(); + List creatureNameEE = new List(); + + InitSpawn( 1, 0, 0, 0, 0, 0, 99, TimeSpan.FromMinutes( 5 ), TimeSpan.FromMinutes( 10 ), 0, 4, -1, creaturesName, creatureNameAA, creatureNameBB, creatureNameCC, creatureNameDD, creatureNameEE ); + } + + public PremiumSpawner( int amount, int subamountA, int subamountB, int subamountC, int subamountD, int subamountE, int spawnid, TimeSpan minDelay, TimeSpan maxDelay, int team, int homeRange, int walkingRange, List creaturesName, List creatureNameAA, List creatureNameBB, List creatureNameCC, List creatureNameDD, List creatureNameEE ) + : base( 0x1f13 ) + { + InitSpawn( amount, subamountA, subamountB, subamountC, subamountD, subamountE, spawnid, minDelay, maxDelay, team, homeRange, walkingRange, creaturesName, creatureNameAA, creatureNameBB, creatureNameCC, creatureNameDD, creatureNameEE ); + } + + public override string DefaultName + { + get { return "PremiumSpawner"; } + } + + public void InitSpawn( int amount, int subamountA, int subamountB, int subamountC, int subamountD, int subamountE, int SpawnID, TimeSpan minDelay, TimeSpan maxDelay, int team, int homeRange, int walkingRange, List creaturesName, List creatureNameAA, List creatureNameBB, List creatureNameCC, List creatureNameDD, List creatureNameEE ) + { + Name = "PremiumSpawner"; + m_SpawnID = SpawnID; + Visible = false; + Movable = false; + m_Running = true; + m_Water = false; + m_Group = false; + m_MinDelay = minDelay; + m_MaxDelay = maxDelay; + m_Count = amount; + m_CountA = subamountA; + m_CountB = subamountB; + m_CountC = subamountC; + m_CountD = subamountD; + m_CountE = subamountE; + m_Team = team; + m_HomeRange = homeRange; + m_WalkingRange = walkingRange; + m_CreaturesName = creaturesName; + m_CreaturesNameA = creatureNameAA; + m_CreaturesNameB = creatureNameBB; + m_CreaturesNameC = creatureNameCC; + m_CreaturesNameD = creatureNameDD; + m_CreaturesNameE = creatureNameEE; + m_Creatures = new List(); + m_CreaturesA = new List(); + m_CreaturesB = new List(); + m_CreaturesC = new List(); + m_CreaturesD = new List(); + m_CreaturesE = new List(); + DoTimer( TimeSpan.FromSeconds( 1 ) ); + } + + public PremiumSpawner( Serial serial ) : base( serial ) + { + } + + public override void OnDoubleClick( Mobile from ) + { + if ( from.AccessLevel < AccessLevel.GameMaster ) + return; + + PremiumSpawnerGump g = new PremiumSpawnerGump( this ); + from.SendGump( g ); + } + + public override void GetProperties( ObjectPropertyList list ) + { + base.GetProperties( list ); + + if ( m_Running ) + { + list.Add( 1060742 ); // active + + list.Add( 1060656, m_Count.ToString() ); + list.Add( 1061169, m_HomeRange.ToString() ); + list.Add( 1060658, "walking range\t{0}", m_WalkingRange ); + + list.Add( 1060663, "SpawnID\t{0}", m_SpawnID.ToString() ); + +// list.Add( 1060659, "group\t{0}", m_Group ); +// list.Add( 1060660, "team\t{0}", m_Team ); + list.Add( 1060661, "speed\t{0} to {1}", m_MinDelay, m_MaxDelay ); + + for ( int i = 0; i < 2 && i < m_CreaturesName.Count; ++i ) + list.Add( 1060662 + i, "{0}\t{1}", m_CreaturesName[i], CountCreatures( Creatures, m_CreaturesName[i] ) ); + } + else + { + list.Add( 1060743 ); // inactive + } + } + + public override void OnSingleClick( Mobile from ) + { + base.OnSingleClick( from ); + + if ( m_Running ) + LabelTo( from, "[Running]" ); + else + LabelTo( from, "[Off]" ); + } + + public void SpawnWater() + { + } + + public void Start() + { + if ( !m_Running ) + { + if ( m_CreaturesName.Count > 0 || m_CreaturesNameA.Count > 0 || m_CreaturesNameB.Count > 0 || m_CreaturesNameC.Count > 0 || m_CreaturesNameD.Count > 0 || m_CreaturesNameE.Count > 0 ) + { + m_Running = true; + DoTimer(); + } + } + } + + public void Stop() + { + if ( m_Running ) + { + m_Timer.Stop(); + m_Running = false; + RemoveCreatures(m_Creatures); + RemoveCreatures(m_CreaturesA); + RemoveCreatures(m_CreaturesB); + RemoveCreatures(m_CreaturesC); + RemoveCreatures(m_CreaturesD); + RemoveCreatures(m_CreaturesE); + } + } + + public static string ParseType( string s ) + { + return s.Split( null, 2 )[0]; + } + + public void Defrag( List m_Beings ) + { + bool removed = false; + + for ( int i = 0; i < m_Beings.Count; ++i ) + { + IEntity e = m_Beings[i]; + + if ( e is Item ) + { + Item item = (Item)e; + + if ( item.Deleted || item.Parent != null ) + { + m_Beings.RemoveAt( i ); + --i; + removed = true; + } + } + else if ( e is Mobile ) + { + Mobile m = (Mobile)e; + + if ( m.Deleted ) + { + m_Beings.RemoveAt( i ); + --i; + removed = true; + } + else if ( m is BaseCreature ) + { + BaseCreature bc = (BaseCreature)m; + if ( bc.Controlled || bc.IsStabled ) + { + m_Beings.RemoveAt( i ); + --i; + removed = true; + } + } + } + else + { + m_Beings.RemoveAt( i ); + --i; + removed = true; + } + } + + if ( removed ) + InvalidateProperties(); + } + + public void OnTick() + { + DoTimer(); + + if ( m_Group ) + { + Defrag(m_Creatures); + Defrag(m_CreaturesA); + Defrag(m_CreaturesB); + Defrag(m_CreaturesC); + Defrag(m_CreaturesD); + Defrag(m_CreaturesE); + + if ( m_Creatures.Count == 0 || m_CreaturesA.Count == 0 || m_CreaturesB.Count == 0 || m_CreaturesC.Count == 0 || m_CreaturesD.Count == 0 || m_CreaturesE.Count == 0 ) + { + Respawn(); + } + else + { + return; + } + } + else + { + Spawn(CreaturesNameCount, m_Creatures, m_Count, m_CreaturesName); + Spawn(CreaturesNameCountA, m_CreaturesA, m_CountA, m_CreaturesNameA); + Spawn(CreaturesNameCountB, m_CreaturesB, m_CountB, m_CreaturesNameB); + Spawn(CreaturesNameCountC, m_CreaturesC, m_CountC, m_CreaturesNameC); + Spawn(CreaturesNameCountD, m_CreaturesD, m_CountD, m_CreaturesNameD); + Spawn(CreaturesNameCountE, m_CreaturesE, m_CountE, m_CreaturesNameE); + } + } + + public void Respawn() // remove all creatures and spawn all again + { + RemoveCreatures(m_Creatures); + RemoveCreatures(m_CreaturesA); + RemoveCreatures(m_CreaturesB); + RemoveCreatures(m_CreaturesC); + RemoveCreatures(m_CreaturesD); + RemoveCreatures(m_CreaturesE); + + for ( int i = 0; i < m_Count; i++ ) + Spawn(CreaturesNameCount, m_Creatures, m_Count, m_CreaturesName); + for ( int i = 0; i < m_CountA; i++ ) + Spawn(CreaturesNameCountA, m_CreaturesA, m_CountA, m_CreaturesNameA); + for ( int i = 0; i < m_CountB; i++ ) + Spawn(CreaturesNameCountB, m_CreaturesB, m_CountB, m_CreaturesNameB); + for ( int i = 0; i < m_CountC; i++ ) + Spawn(CreaturesNameCountC, m_CreaturesC, m_CountC, m_CreaturesNameC); + for ( int i = 0; i < m_CountD; i++ ) + Spawn(CreaturesNameCountD, m_CreaturesD, m_CountD, m_CreaturesNameD); + for ( int i = 0; i < m_CountE; i++ ) + Spawn(CreaturesNameCountE, m_CreaturesE, m_CountE, m_CreaturesNameE); + } + + public void Spawn( int CreatNameCount, List m_Creat, int m_Countt, List m_CreatName ) + { + if ( CreatNameCount > 0 ) + SpawnTwo( Utility.Random( CreatNameCount ), CreatNameCount, m_Creat, m_Countt, m_CreatName ); + + } + + // Used only by PremiumSpawnerGump(line 415-45) + // BROKEN + public void SpawnFromGump( List m_subspawnName, List m_subspawn, int subCount, int subNameCount, string creatureName ) + { + for ( int i = 0; i < m_subspawnName.Count; i++ ) + { + if ( m_subspawnName[i] == creatureName ) + { + SpawnTwo( i, subNameCount, m_subspawn, subCount, m_subspawnName ); + break; + } + } + } + + protected virtual IEntity CreateSpawnedObject( int index, List m_CreatName ) + { + if ( index >= m_CreatName.Count ) + return null; + + Type type = ScriptCompiler.FindTypeByName( ParseType( m_CreatName[index] ) ); + + if ( type != null ) + { + try + { + return Build( CommandSystem.Split( m_CreatName[index] ) ); + } + catch + { + } + } + + return null; + } + + public static IEntity Build( string[] args ) + { + string name = args[0]; + + Add.FixArgs( ref args ); + + string[,] props = null; + + for ( int i = 0; i < args.Length; ++i ) + { + if ( Insensitive.Equals( args[i], "set" ) ) + { + int remains = args.Length - i - 1; + + if ( remains >= 2 ) + { + props = new string[remains / 2, 2]; + + remains /= 2; + + for ( int j = 0; j < remains; ++j ) + { + props[j, 0] = args[i + (j * 2) + 1]; + props[j, 1] = args[i + (j * 2) + 2]; + } + + Add.FixSetString( ref args, i ); + } + + break; + } + } + + Type type = ScriptCompiler.FindTypeByName( name ); + + if ( !Add.IsEntity( type ) ) { + return null; + } + + PropertyInfo[] realProps = null; + + if ( props != null ) + { + realProps = new PropertyInfo[props.GetLength( 0 )]; + + PropertyInfo[] allProps = type.GetProperties( BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public ); + + for ( int i = 0; i < realProps.Length; ++i ) + { + PropertyInfo thisProp = null; + + string propName = props[i, 0]; + + for ( int j = 0; thisProp == null && j < allProps.Length; ++j ) + { + if ( Insensitive.Equals( propName, allProps[j].Name ) ) + thisProp = allProps[j]; + } + + if ( thisProp != null ) + { + CPA attr = Properties.GetCPA( thisProp ); + + if ( attr != null && AccessLevel.GameMaster >= attr.WriteLevel && thisProp.CanWrite && !attr.ReadOnly ) + realProps[i] = thisProp; + } + } + } + + ConstructorInfo[] ctors = type.GetConstructors(); + + for ( int i = 0; i < ctors.Length; ++i ) + { + ConstructorInfo ctor = ctors[i]; + + if ( !Add.IsConstructable( ctor, AccessLevel.GameMaster ) ) + continue; + + ParameterInfo[] paramList = ctor.GetParameters(); + + if ( args.Length == paramList.Length ) + { + object[] paramValues = Add.ParseValues( paramList, args ); + + if ( paramValues == null ) + continue; + + object built = ctor.Invoke( paramValues ); + + if ( built != null && realProps != null ) + { + for ( int j = 0; j < realProps.Length; ++j ) + { + if ( realProps[j] == null ) + continue; + + string result = Properties.InternalSetValue( built, realProps[j], props[j, 1] ); + } + } + + return (IEntity)built; + } + } + + return null; + } + + public void SpawnTwo( int index, int CreatNameCount, List m_Creat, int m_Countt, List m_CreatName ) + { + Map map = Map; + + if ( map == null || map == Map.Internal || CreatNameCount == 0 || index >= CreatNameCount || Parent != null ) + return; + + Defrag(m_Creatures); + Defrag(m_CreaturesA); + Defrag(m_CreaturesB); + Defrag(m_CreaturesC); + Defrag(m_CreaturesD); + Defrag(m_CreaturesE); + + if ( m_Creat.Count >= m_Countt ) + return; + + + IEntity ent = CreateSpawnedObject( index, m_CreatName ); + + if ( ent is Mobile ) + { + Mobile m = (Mobile)ent; + + if ( m.CanSwim ) + { + m_Water = true; + } + else + { + m_Water = false; + } + + m_Creat.Add( m ); + + + Point3D loc = ( m is BaseVendor ? this.Location : GetSpawnPosition() ); + + if ( m is WanderingHealer || m is EvilWanderingHealer || m is EvilHealer ) + { + loc = GetSpawnPosition(); + } + + m.OnBeforeSpawn( loc, map ); + InvalidateProperties(); + + + m.MoveToWorld( loc, map ); + + if ( m is BaseCreature ) + { + BaseCreature c = (BaseCreature)m; + + if( m_WalkingRange >= 0 ) + c.RangeHome = m_WalkingRange; + else + c.RangeHome = m_HomeRange; + + c.CurrentWayPoint = m_WayPoint; + + if ( m_Team > 0 ) + c.Team = m_Team; + + c.Home = this.Location; + } + + m.OnAfterSpawn(); + } + else if ( ent is Item ) + { + Item item = (Item)ent; + + m_Creat.Add( item ); + + Point3D loc = GetSpawnPosition(); + + item.OnBeforeSpawn( loc, map ); + InvalidateProperties(); + + item.MoveToWorld( loc, map ); + + item.OnAfterSpawn(); + } + } + + public Point3D GetSpawnPosition() + { + Map map = Map; + + if ( map == null ) + return Location; + + // Try 10 times to find a Spawnable location. + for ( int i = 0; i < 10; i++ ) + { + int x, y; + + if ( m_HomeRange > 0 ) { + x = Location.X + (Utility.Random( (m_HomeRange * 2) + 1 ) - m_HomeRange); + y = Location.Y + (Utility.Random( (m_HomeRange * 2) + 1 ) - m_HomeRange); + } else { + x = Location.X; + y = Location.Y; + } + + int z = Map.GetAverageZ( x, y ); + + if ( m_Water ) + { + TileMatrix tiles = Map.Tiles; + LandTile _tile = tiles.GetLandTile(x,y); + int id = _tile.ID; + if((id >= 168 && id <= 171) || id == 100) + { + return new Point3D( x, y, this.Z ); + } + else + { + continue; + } + } + + if ( Map.CanSpawnMobile( new Point2D( x, y ), this.Z ) ) + return new Point3D( x, y, this.Z ); + else if ( Map.CanSpawnMobile( new Point2D( x, y ), z ) ) + return new Point3D( x, y, z ); + } + + return this.Location; + } + + public void DoTimer() + { + if ( !m_Running ) + return; + + int minSeconds = (int)m_MinDelay.TotalSeconds; + int maxSeconds = (int)m_MaxDelay.TotalSeconds; + + TimeSpan delay = TimeSpan.FromSeconds( Utility.RandomMinMax( minSeconds, maxSeconds ) ); + DoTimer( delay ); + } + + public void DoTimer( TimeSpan delay ) + { + if ( !m_Running ) + return; + + m_End = DateTime.Now + delay; + + if ( m_Timer != null ) + m_Timer.Stop(); + + m_Timer = new InternalTimer( this, delay ); + m_Timer.Start(); + } + + private class InternalTimer : Timer + { + private PremiumSpawner m_PremiumSpawner; + + public InternalTimer( PremiumSpawner spawner, TimeSpan delay ) : base( delay ) + { + if ( spawner.IsFull || spawner.IsFulla || spawner.IsFullb || spawner.IsFullc || spawner.IsFulld || spawner.IsFulle ) + Priority = TimerPriority.FiveSeconds; + else + Priority = TimerPriority.OneSecond; + + m_PremiumSpawner = spawner; + } + + protected override void OnTick() + { + if ( m_PremiumSpawner != null ) + if ( !m_PremiumSpawner.Deleted ) + m_PremiumSpawner.OnTick(); + } + } + + // Used only by PremiumSpawnerGump (except 1st, used here too) + public int CountCreatures( List m_subspawn, string creatureName ) + { + Defrag(m_subspawn); + + int count = 0; + + for ( int i = 0; i < m_subspawn.Count; ++i ) + if ( Insensitive.Equals( creatureName, m_subspawn[i].GetType().Name ) ) + ++count; + + return count; + } + + // Used only by PremiumSpawnerGump (lines 446-76) + // BROKEN + public void RemoveCreaturesFromGump( List m_subspawn, string creatureName ) + { + Defrag(m_subspawn); + + for ( int i = 0; i < m_subspawn.Count; ++i ) + { + IEntity e = m_subspawn[i]; + + if ( Insensitive.Equals( creatureName, e.GetType().Name ) ) + e.Delete(); + } + + InvalidateProperties(); + } + + // Used only here + public void RemoveCreatures( List m_Creatur ) + { + Defrag(m_Creatur); + + for ( int i = 0; i < m_Creatur.Count; ++i ) + m_Creatur[i].Delete(); + + InvalidateProperties(); + } + + //Used by PremiumSpawnerGump + public void BringToHome( List m_Beings ) + { + for ( int i = 0; i < m_Beings.Count; ++i ) + { + IEntity e = m_Beings[i]; + + if ( e is Mobile ) + { + Mobile m = (Mobile)e; + + m.MoveToWorld( Location, Map ); + } + else if ( e is Item ) + { + Item item = (Item)e; + + item.MoveToWorld( Location, Map ); + } + } + } + + //Used by PremiumSpawnerGump + public void BringToHome() + { + Defrag(m_Creatures); + Defrag(m_CreaturesA); + Defrag(m_CreaturesB); + Defrag(m_CreaturesC); + Defrag(m_CreaturesD); + Defrag(m_CreaturesE); + + BringToHome(m_Creatures); + BringToHome(m_CreaturesA); + BringToHome(m_CreaturesB); + BringToHome(m_CreaturesC); + BringToHome(m_CreaturesD); + BringToHome(m_CreaturesE); + } + + public override void OnDelete() + { + base.OnDelete(); + + RemoveCreatures(m_Creatures); + RemoveCreatures(m_CreaturesA); + RemoveCreatures(m_CreaturesB); + RemoveCreatures(m_CreaturesC); + RemoveCreatures(m_CreaturesD); + RemoveCreatures(m_CreaturesE); + if ( m_Timer != null ) + m_Timer.Stop(); + } + + public override void Serialize( GenericWriter writer ) + { + base.Serialize( writer ); + + writer.Write( (int) 4 ); // version + writer.Write( m_WalkingRange ); + + writer.Write( m_SpawnID ); + writer.Write( m_CountA ); + writer.Write( m_CountB ); + writer.Write( m_CountC ); + writer.Write( m_CountD ); + writer.Write( m_CountE ); + + writer.Write( m_WayPoint ); + + writer.Write( m_Group ); + + writer.Write( m_MinDelay ); + writer.Write( m_MaxDelay ); + writer.Write( m_Count ); + writer.Write( m_Team ); + writer.Write( m_HomeRange ); + writer.Write( m_Running ); + + if ( m_Running ) + writer.WriteDeltaTime( m_End ); + + writer.Write( m_CreaturesName.Count ); + + for ( int i = 0; i < m_CreaturesName.Count; ++i ) + writer.Write( m_CreaturesName[i] ); + + writer.Write( m_CreaturesNameA.Count ); + + for ( int i = 0; i < m_CreaturesNameA.Count; ++i ) + writer.Write( (string)m_CreaturesNameA[i] ); + + writer.Write( m_CreaturesNameB.Count ); + + for ( int i = 0; i < m_CreaturesNameB.Count; ++i ) + writer.Write( (string)m_CreaturesNameB[i] ); + + writer.Write( m_CreaturesNameC.Count ); + + for ( int i = 0; i < m_CreaturesNameC.Count; ++i ) + writer.Write( (string)m_CreaturesNameC[i] ); + + writer.Write( m_CreaturesNameD.Count ); + + for ( int i = 0; i < m_CreaturesNameD.Count; ++i ) + writer.Write( (string)m_CreaturesNameD[i] ); + + writer.Write( m_CreaturesNameE.Count ); + + for ( int i = 0; i < m_CreaturesNameE.Count; ++i ) + writer.Write( (string)m_CreaturesNameE[i] ); + + writer.Write( m_Creatures.Count ); + + for ( int i = 0; i < m_Creatures.Count; ++i ) + { + IEntity e = m_Creatures[i]; + + if ( e is Item ) + writer.Write( (Item)e ); + else if ( e is Mobile ) + writer.Write( (Mobile)e ); + else + writer.Write( Serial.MinusOne ); + } + + writer.Write( m_CreaturesA.Count ); + + for ( int i = 0; i < m_CreaturesA.Count; ++i ) + { + IEntity e = m_CreaturesA[i]; + + if ( e is Item ) + writer.Write( (Item)e ); + else if ( e is Mobile ) + writer.Write( (Mobile)e ); + else + writer.Write( Serial.MinusOne ); + } + + writer.Write( m_CreaturesB.Count ); + + for ( int i = 0; i < m_CreaturesB.Count; ++i ) + { + IEntity e = m_CreaturesB[i]; + + if ( e is Item ) + writer.Write( (Item)e ); + else if ( e is Mobile ) + writer.Write( (Mobile)e ); + else + writer.Write( Serial.MinusOne ); + } + + writer.Write( m_CreaturesC.Count ); + + for ( int i = 0; i < m_CreaturesC.Count; ++i ) + { + IEntity e = m_CreaturesC[i]; + + if ( e is Item ) + writer.Write( (Item)e ); + else if ( e is Mobile ) + writer.Write( (Mobile)e ); + else + writer.Write( Serial.MinusOne ); + } + + writer.Write( m_CreaturesD.Count ); + + for ( int i = 0; i < m_CreaturesD.Count; ++i ) + { + IEntity e = m_CreaturesD[i]; + + if ( e is Item ) + writer.Write( (Item)e ); + else if ( e is Mobile ) + writer.Write( (Mobile)e ); + else + writer.Write( Serial.MinusOne ); + } + + writer.Write( m_CreaturesE.Count ); + + for ( int i = 0; i < m_CreaturesE.Count; ++i ) + { + IEntity e = m_CreaturesE[i]; + + if ( e is Item ) + writer.Write( (Item)e ); + else if ( e is Mobile ) + writer.Write( (Mobile)e ); + else + writer.Write( Serial.MinusOne ); + } + + } + + private static WarnTimer m_WarnTimer; + + public override void Deserialize( GenericReader reader ) + { + base.Deserialize( reader ); + + int version = reader.ReadInt(); + + switch ( version ) + { + case 4: + { + m_WalkingRange = reader.ReadInt(); + m_SpawnID = reader.ReadInt(); + m_CountA = reader.ReadInt(); + m_CountB = reader.ReadInt(); + m_CountC = reader.ReadInt(); + m_CountD = reader.ReadInt(); + m_CountE = reader.ReadInt(); + + goto case 3; + } + case 3: + case 2: + { + m_WayPoint = reader.ReadItem() as WayPoint; + + goto case 1; + } + + case 1: + { + m_Group = reader.ReadBool(); + + goto case 0; + } + + case 0: + { + m_MinDelay = reader.ReadTimeSpan(); + m_MaxDelay = reader.ReadTimeSpan(); + m_Count = reader.ReadInt(); + m_Team = reader.ReadInt(); + m_HomeRange = reader.ReadInt(); + m_Running = reader.ReadBool(); + + TimeSpan ts = TimeSpan.Zero; + + if ( m_Running ) + ts = reader.ReadDeltaTime() - DateTime.Now; + + int size = reader.ReadInt(); + m_CreaturesName = new List( size ); + for ( int i = 0; i < size; ++i ) + { + string creatureString = reader.ReadString(); + + m_CreaturesName.Add( creatureString ); + string typeName = ParseType( creatureString ); + + if ( ScriptCompiler.FindTypeByName( typeName ) == null ) + { + if ( m_WarnTimer == null ) + m_WarnTimer = new WarnTimer(); + + m_WarnTimer.Add( Location, Map, typeName ); + } + } + + int sizeA = reader.ReadInt(); + m_CreaturesNameA = new List( sizeA ); + for ( int i = 0; i < sizeA; ++i ) + { + string creatureString = reader.ReadString(); + + m_CreaturesNameA.Add( creatureString ); + string typeName = ParseType( creatureString ); + + if ( ScriptCompiler.FindTypeByName( typeName ) == null ) + { + if ( m_WarnTimer == null ) + m_WarnTimer = new WarnTimer(); + + m_WarnTimer.Add( Location, Map, typeName ); + } + } + + int sizeB = reader.ReadInt(); + m_CreaturesNameB = new List( sizeB ); + for ( int i = 0; i < sizeB; ++i ) + { + string creatureString = reader.ReadString(); + + m_CreaturesNameB.Add( creatureString ); + string typeName = ParseType( creatureString ); + + if ( ScriptCompiler.FindTypeByName( typeName ) == null ) + { + if ( m_WarnTimer == null ) + m_WarnTimer = new WarnTimer(); + + m_WarnTimer.Add( Location, Map, typeName ); + } + } + + int sizeC = reader.ReadInt(); + m_CreaturesNameC = new List( sizeC ); + for ( int i = 0; i < sizeC; ++i ) + { + string creatureString = reader.ReadString(); + + m_CreaturesNameC.Add( creatureString ); + string typeName = ParseType( creatureString ); + + if ( ScriptCompiler.FindTypeByName( typeName ) == null ) + { + if ( m_WarnTimer == null ) + m_WarnTimer = new WarnTimer(); + + m_WarnTimer.Add( Location, Map, typeName ); + } + } + + int sizeD = reader.ReadInt(); + m_CreaturesNameD = new List( sizeD ); + for ( int i = 0; i < sizeD; ++i ) + { + string creatureString = reader.ReadString(); + + m_CreaturesNameD.Add( creatureString ); + string typeName = ParseType( creatureString ); + + if ( ScriptCompiler.FindTypeByName( typeName ) == null ) + { + if ( m_WarnTimer == null ) + m_WarnTimer = new WarnTimer(); + + m_WarnTimer.Add( Location, Map, typeName ); + } + } + + int sizeE = reader.ReadInt(); + m_CreaturesNameE = new List( sizeE ); + for ( int i = 0; i < sizeE; ++i ) + { + string creatureString = reader.ReadString(); + + m_CreaturesNameE.Add( creatureString ); + string typeName = ParseType( creatureString ); + + if ( ScriptCompiler.FindTypeByName( typeName ) == null ) + { + if ( m_WarnTimer == null ) + m_WarnTimer = new WarnTimer(); + + m_WarnTimer.Add( Location, Map, typeName ); + } + } + + int count = reader.ReadInt(); + m_Creatures = new List( count ); + for ( int i = 0; i < count; ++i ) + { + IEntity e = World.FindEntity( reader.ReadInt() ); + + if ( e != null ) + m_Creatures.Add( e ); + } + + int countA = reader.ReadInt(); + m_CreaturesA = new List( countA ); + for ( int i = 0; i < countA; ++i ) + { + IEntity e = World.FindEntity( reader.ReadInt() ); + + if ( e != null ) + m_CreaturesA.Add( e ); + } + + int countB = reader.ReadInt(); + m_CreaturesB = new List( countB ); + for ( int i = 0; i < countB; ++i ) + { + IEntity e = World.FindEntity( reader.ReadInt() ); + + if ( e != null ) + m_CreaturesB.Add( e ); + } + + int countC = reader.ReadInt(); + m_CreaturesC = new List( countC ); + for ( int i = 0; i < countC; ++i ) + { + IEntity e = World.FindEntity( reader.ReadInt() ); + + if ( e != null ) + m_CreaturesC.Add( e ); + } + + int countD = reader.ReadInt(); + m_CreaturesD = new List( countD ); + for ( int i = 0; i < countD; ++i ) + { + IEntity e = World.FindEntity( reader.ReadInt() ); + + if ( e != null ) + m_CreaturesD.Add( e ); + } + + int countE = reader.ReadInt(); + m_CreaturesE = new List( countE ); + for ( int i = 0; i < countE; ++i ) + { + IEntity e = World.FindEntity( reader.ReadInt() ); + + if ( e != null ) + m_CreaturesE.Add( e ); + } + + if ( m_Running ) + DoTimer( ts ); + + break; + } + } + + if ( version < 3 && Weight == 0 ) + Weight = -1; + } + + private class WarnTimer : Timer + { + private List m_List; + + private class WarnEntry + { + public Point3D m_Point; + public Map m_Map; + public string m_Name; + + public WarnEntry( Point3D p, Map map, string name ) + { + m_Point = p; + m_Map = map; + m_Name = name; + } + } + + public WarnTimer() : base( TimeSpan.FromSeconds( 1.0 ) ) + { + m_List = new List(); + Start(); + } + + public void Add( Point3D p, Map map, string name ) + { + m_List.Add( new WarnEntry( p, map, name ) ); + } + + protected override void OnTick() + { + try + { + Console.WriteLine( "Warning: {0} bad spawns detected, logged: 'PremiumBadspawn.log'", m_List.Count ); + + using ( StreamWriter op = new StreamWriter( "PremiumBadspawn.log", true ) ) + { + op.WriteLine( "# Bad spawns : {0}", DateTime.Now ); + op.WriteLine( "# Format: X Y Z F Name" ); + op.WriteLine(); + + foreach ( WarnEntry e in m_List ) + op.WriteLine( "{0}\t{1}\t{2}\t{3}\t{4}", e.m_Point.X, e.m_Point.Y, e.m_Point.Z, e.m_Map, e.m_Name ); + + op.WriteLine(); + op.WriteLine(); + } + } + catch + { + } + } + } + } +} diff --git a/Scripts/Engines/Spawner/PremiumSpawner/PremiumSpawnerGump.cs b/Scripts/Engines/Spawner/PremiumSpawner/PremiumSpawnerGump.cs new file mode 100644 index 0000000..29f9825 --- /dev/null +++ b/Scripts/Engines/Spawner/PremiumSpawner/PremiumSpawnerGump.cs @@ -0,0 +1,496 @@ +//Engine r120 +using System; +using System.Collections; +using Server.Network; +using Server.Gumps; +using System.Collections.Generic; + +namespace Server.Mobiles +{ + public class PremiumSpawnerGump : Gump + { + private PremiumSpawner m_Spawner; + + public void AddBlackAlpha( int x, int y, int width, int height ) + { + AddImageTiled( x, y, width, height, 2624 ); + AddAlphaRegion( x, y, width, height ); + } + + public PremiumSpawnerGump( PremiumSpawner spawner ) : base( 50, 50 ) + { + m_Spawner = spawner; + + AddPage( 1 ); + + AddBackground( 0, 0, 350, 360, 5054 ); + + AddLabel( 80, 1, 52, "Creatures List 1" ); + + AddLabel( 215, 3, 52, "PREMIUM SPAWNER" ); + AddBlackAlpha( 213, 23, 125, 270 ); + + AddButton( 260, 40, 0xFB7, 0xFB9, 1000, GumpButtonType.Reply, 0 ); + AddLabel( 260, 60, 52, "Okay" ); + + AddButton( 260, 90, 0xFB4, 0xFB6, 200, GumpButtonType.Reply, 0 ); + AddLabel( 232, 110, 52, "Bring to Home" ); + + AddButton( 260, 140, 0xFA8, 0xFAA, 300, GumpButtonType.Reply, 0 ); + AddLabel( 232, 160, 52, "Total Respawn" ); + + AddButton( 260, 190, 0xFAB, 0xFAD, 400, GumpButtonType.Reply, 0 ); + AddLabel( 245, 210, 52, "Properties" ); + + AddButton( 260, 240, 0xFB1, 0xFB3, 500, GumpButtonType.Reply, 0 ); + AddLabel( 256, 260, 52, "Cancel" ); + + AddButton( 230, 320, 5603, 5607, 0, GumpButtonType.Page, 6 ); + AddButton( 302, 320, 5601, 5605, 0, GumpButtonType.Page, 2 ); + AddLabel( 258, 320, 52, "- 1 -" ); + + for ( int i = 0; i < 15; i++ ) + { + // AddButton ( x, y, image, imageOnClick, ButtonID ) + AddButton( 5, ( 22 * i ) + 20, 0xFA5, 0xFA7, (1 + i), GumpButtonType.Reply, 0 ); // > (spawn this creature) + AddButton( 38, ( 22 * i ) + 20, 0xFA2, 0xFA4, (91 + i), GumpButtonType.Reply, 0 ); // X (remove this creature) + + AddImageTiled( 71, ( 22 * i ) + 20, 119, 23, 0xA40 ); + AddImageTiled( 72, ( 22 * i ) + 21, 117, 21, 0xBBC ); + + string str = ""; + + if ( i < spawner.CreaturesName.Count ) + { + str = (string)spawner.CreaturesName[i]; + int count = m_Spawner.CountCreatures( m_Spawner.Creatures, str ); + + AddLabel( 192, ( 22 * i ) + 20, 0, count.ToString() ); + } + + AddTextEntry( 75, ( 22 * i ) + 21, 114, 21, 0, 101 + i, str ); + } + + AddPage( 2 ); + + AddBackground( 0, 0, 350, 360, 5054 ); + + AddLabel( 80, 1, 52, "Creatures List 2" ); + + AddLabel( 215, 3, 52, "PREMIUM SPAWNER" ); + AddBlackAlpha( 213, 23, 125, 270 ); + + AddButton( 260, 40, 0xFB7, 0xFB9, 1000, GumpButtonType.Reply, 0 ); + AddLabel( 260, 60, 52, "Okay" ); + + AddButton( 260, 90, 0xFB4, 0xFB6, 200, GumpButtonType.Reply, 0 ); + AddLabel( 232, 110, 52, "Bring to Home" ); + + AddButton( 260, 140, 0xFA8, 0xFAA, 300, GumpButtonType.Reply, 0 ); + AddLabel( 232, 160, 52, "Total Respawn" ); + + AddButton( 260, 190, 0xFAB, 0xFAD, 400, GumpButtonType.Reply, 0 ); + AddLabel( 245, 210, 52, "Properties" ); + + AddButton( 260, 240, 0xFB1, 0xFB3, 500, GumpButtonType.Reply, 0 ); + AddLabel( 256, 260, 52, "Cancel" ); + + AddButton( 230, 320, 5603, 5607, 0, GumpButtonType.Page, 1 ); + AddButton( 302, 320, 5601, 5605, 0, GumpButtonType.Page, 3 ); + AddLabel( 258, 320, 52, "- 2 -" ); + + for ( int i = 0; i < 15; i++ ) + { + AddButton( 5, ( 22 * i ) + 20, 0xFA5, 0xFA7, (16 + i), GumpButtonType.Reply, 0 ); + AddButton( 38, ( 22 * i ) + 20, 0xFA2, 0xFA4, (106 + i), GumpButtonType.Reply, 0 ); + + AddImageTiled( 71, ( 22 * i ) + 20, 119, 23, 0xA40 ); + AddImageTiled( 72, ( 22 * i ) + 21, 117, 21, 0xBBC ); + + string str = ""; + + if ( i < spawner.SubSpawnerA.Count ) + { + str = (string)spawner.SubSpawnerA[i]; + int count = m_Spawner.CountCreatures( m_Spawner.CreaturesA, str ); + + AddLabel( 192, ( 22 * i ) + 20, 0, count.ToString() ); + } + + AddTextEntry( 75, ( 22 * i ) + 21, 114, 21, 0, 201 + i, str ); + } + + AddPage( 3 ); + + AddBackground( 0, 0, 350, 360, 5054 ); + + AddLabel( 80, 1, 52, "Creatures List 3" ); + + AddLabel( 215, 3, 52, "PREMIUM SPAWNER" ); + AddBlackAlpha( 213, 23, 125, 270 ); + + AddButton( 260, 40, 0xFB7, 0xFB9, 1000, GumpButtonType.Reply, 0 ); + AddLabel( 260, 60, 52, "Okay" ); + + AddButton( 260, 90, 0xFB4, 0xFB6, 200, GumpButtonType.Reply, 0 ); + AddLabel( 232, 110, 52, "Bring to Home" ); + + AddButton( 260, 140, 0xFA8, 0xFAA, 300, GumpButtonType.Reply, 0 ); + AddLabel( 232, 160, 52, "Total Respawn" ); + + AddButton( 260, 190, 0xFAB, 0xFAD, 400, GumpButtonType.Reply, 0 ); + AddLabel( 245, 210, 52, "Properties" ); + + AddButton( 260, 240, 0xFB1, 0xFB3, 500, GumpButtonType.Reply, 0 ); + AddLabel( 256, 260, 52, "Cancel" ); + + AddButton( 230, 320, 5603, 5607, 0, GumpButtonType.Page, 2 ); + AddButton( 302, 320, 5601, 5605, 0, GumpButtonType.Page, 4 ); + AddLabel( 258, 320, 52, "- 3 -" ); + + for ( int i = 0; i < 15; i++ ) + { + AddButton( 5, ( 22 * i ) + 20, 0xFA5, 0xFA7, (31 + i), GumpButtonType.Reply, 0 ); + AddButton( 38, ( 22 * i ) + 20, 0xFA2, 0xFA4, (121 + i), GumpButtonType.Reply, 0 ); + + AddImageTiled( 71, ( 22 * i ) + 20, 119, 23, 0xA40 ); + AddImageTiled( 72, ( 22 * i ) + 21, 117, 21, 0xBBC ); + + string str = ""; + + if ( i < spawner.SubSpawnerB.Count ) + { + str = (string)spawner.SubSpawnerB[i]; + int count = m_Spawner.CountCreatures( m_Spawner.CreaturesB, str ); + + AddLabel( 192, ( 22 * i ) + 20, 0, count.ToString() ); + } + + AddTextEntry( 75, ( 22 * i ) + 21, 114, 21, 0, 301 + i, str ); + } + + AddPage( 4 ); + + AddBackground( 0, 0, 350, 360, 5054 ); + + AddLabel( 80, 1, 52, "Creatures List 4" ); + + AddLabel( 215, 3, 52, "PREMIUM SPAWNER" ); + AddBlackAlpha( 213, 23, 125, 270 ); + + AddButton( 260, 40, 0xFB7, 0xFB9, 1000, GumpButtonType.Reply, 0 ); + AddLabel( 260, 60, 52, "Okay" ); + + AddButton( 260, 90, 0xFB4, 0xFB6, 200, GumpButtonType.Reply, 0 ); + AddLabel( 232, 110, 52, "Bring to Home" ); + + AddButton( 260, 140, 0xFA8, 0xFAA, 300, GumpButtonType.Reply, 0 ); + AddLabel( 232, 160, 52, "Total Respawn" ); + + AddButton( 260, 190, 0xFAB, 0xFAD, 400, GumpButtonType.Reply, 0 ); + AddLabel( 245, 210, 52, "Properties" ); + + AddButton( 260, 240, 0xFB1, 0xFB3, 500, GumpButtonType.Reply, 0 ); + AddLabel( 256, 260, 52, "Cancel" ); + + AddButton( 230, 320, 5603, 5607, 0, GumpButtonType.Page, 3 ); + AddButton( 302, 320, 5601, 5605, 0, GumpButtonType.Page, 5 ); + AddLabel( 258, 320, 52, "- 4 -" ); + + for ( int i = 0; i < 15; i++ ) + { + AddButton( 5, ( 22 * i ) + 20, 0xFA5, 0xFA7, (46 + i), GumpButtonType.Reply, 0 ); + AddButton( 38, ( 22 * i ) + 20, 0xFA2, 0xFA4, (136 + i), GumpButtonType.Reply, 0 ); + + AddImageTiled( 71, ( 22 * i ) + 20, 119, 23, 0xA40 ); + AddImageTiled( 72, ( 22 * i ) + 21, 117, 21, 0xBBC ); + + string str = ""; + + if ( i < spawner.SubSpawnerC.Count ) + { + str = (string)spawner.SubSpawnerC[i]; + int count = m_Spawner.CountCreatures( m_Spawner.CreaturesC, str ); + + AddLabel( 192, ( 22 * i ) + 20, 0, count.ToString() ); + } + + AddTextEntry( 75, ( 22 * i ) + 21, 114, 21, 0, 401 + i, str ); + } + + AddPage( 5 ); + + AddBackground( 0, 0, 350, 360, 5054 ); + + AddLabel( 80, 1, 52, "Creatures List 5" ); + + AddLabel( 215, 3, 52, "PREMIUM SPAWNER" ); + AddBlackAlpha( 213, 23, 125, 270 ); + + AddButton( 260, 40, 0xFB7, 0xFB9, 1000, GumpButtonType.Reply, 0 ); + AddLabel( 260, 60, 52, "Okay" ); + + AddButton( 260, 90, 0xFB4, 0xFB6, 200, GumpButtonType.Reply, 0 ); + AddLabel( 232, 110, 52, "Bring to Home" ); + + AddButton( 260, 140, 0xFA8, 0xFAA, 300, GumpButtonType.Reply, 0 ); + AddLabel( 232, 160, 52, "Total Respawn" ); + + AddButton( 260, 190, 0xFAB, 0xFAD, 400, GumpButtonType.Reply, 0 ); + AddLabel( 245, 210, 52, "Properties" ); + + AddButton( 260, 240, 0xFB1, 0xFB3, 500, GumpButtonType.Reply, 0 ); + AddLabel( 256, 260, 52, "Cancel" ); + + AddButton( 230, 320, 5603, 5607, 0, GumpButtonType.Page, 4 ); + AddButton( 302, 320, 5601, 5605, 0, GumpButtonType.Page, 6 ); + AddLabel( 258, 320, 52, "- 5 -" ); + + for ( int i = 0; i < 15; i++ ) + { + AddButton( 5, ( 22 * i ) + 20, 0xFA5, 0xFA7, (61 + i), GumpButtonType.Reply, 0 ); + AddButton( 38, ( 22 * i ) + 20, 0xFA2, 0xFA4, (151 + i), GumpButtonType.Reply, 0 ); + + AddImageTiled( 71, ( 22 * i ) + 20, 119, 23, 0xA40 ); + AddImageTiled( 72, ( 22 * i ) + 21, 117, 21, 0xBBC ); + + string str = ""; + + if ( i < spawner.SubSpawnerD.Count ) + { + str = (string)spawner.SubSpawnerD[i]; + int count = m_Spawner.CountCreatures( m_Spawner.CreaturesD, str ); + + AddLabel( 192, ( 22 * i ) + 20, 0, count.ToString() ); + } + + AddTextEntry( 75, ( 22 * i ) + 21, 114, 21, 0, 501 + i, str ); + } + + AddPage( 6 ); + + AddBackground( 0, 0, 350, 360, 5054 ); + + AddLabel( 80, 1, 52, "Creatures List 6" ); + + AddLabel( 215, 3, 52, "PREMIUM SPAWNER" ); + AddBlackAlpha( 213, 23, 125, 270 ); + + AddButton( 260, 40, 0xFB7, 0xFB9, 1000, GumpButtonType.Reply, 0 ); + AddLabel( 260, 60, 52, "Okay" ); + + AddButton( 260, 90, 0xFB4, 0xFB6, 200, GumpButtonType.Reply, 0 ); + AddLabel( 232, 110, 52, "Bring to Home" ); + + AddButton( 260, 140, 0xFA8, 0xFAA, 300, GumpButtonType.Reply, 0 ); + AddLabel( 232, 160, 52, "Total Respawn" ); + + AddButton( 260, 190, 0xFAB, 0xFAD, 400, GumpButtonType.Reply, 0 ); + AddLabel( 245, 210, 52, "Properties" ); + + AddButton( 260, 240, 0xFB1, 0xFB3, 500, GumpButtonType.Reply, 0 ); + AddLabel( 256, 260, 52, "Cancel" ); + + AddButton( 230, 320, 5603, 5607, 0, GumpButtonType.Page, 5 ); + AddButton( 302, 320, 5601, 5605, 0, GumpButtonType.Page, 1 ); + AddLabel( 258, 320, 52, "- 6 -" ); + + for ( int i = 0; i < 15; i++ ) + { + AddButton( 5, ( 22 * i ) + 20, 0xFA5, 0xFA7, (76 + i), GumpButtonType.Reply, 0 ); + AddButton( 38, ( 22 * i ) + 20, 0xFA2, 0xFA4, (166 + i), GumpButtonType.Reply, 0 ); + + AddImageTiled( 71, ( 22 * i ) + 20, 119, 23, 0xA40 ); + AddImageTiled( 72, ( 22 * i ) + 21, 117, 21, 0xBBC ); + + string str = ""; + + if ( i < spawner.SubSpawnerE.Count ) + { + str = (string)spawner.SubSpawnerE[i]; + int count = m_Spawner.CountCreatures( m_Spawner.CreaturesE, str ); + + AddLabel( 192, ( 22 * i ) + 20, 0, count.ToString() ); + } + + AddTextEntry( 75, ( 22 * i ) + 21, 114, 21, 0, 601 + i, str ); + } + + } + + public List CreateArray( RelayInfo info, Mobile from, int TextIndex ) + { + List creaturesName = new List(); + + for ( int i = 0; i < 15; i++ ) + { + TextRelay te = info.GetTextEntry( TextIndex + i ); + + if ( te != null ) + { + string str = te.Text; + + if ( str.Length > 0 ) + { + str = str.Trim(); + + string t = Spawner.ParseType( str ); + + Type type = ScriptCompiler.FindTypeByName( t ); + + if ( type != null ) + creaturesName.Add( str ); + else + from.SendMessage( "{0} is not a valid type name.", t ); + } + } + } + + return creaturesName; + } + + public string GetEntry( int Type, RelayInfo info ) + { + TextRelay entry = info.GetTextEntry( Type ); + return entry.Text; + } + + public override void OnResponse( NetState state, RelayInfo info ) + { + if ( m_Spawner.Deleted ) + return; + + switch ( info.ButtonID ) + { + case 0: // Cancel (mouse's right button click anywhere on the gump) + { + break; + } + case 200: // Bring everything home + { + m_Spawner.BringToHome(); + break; + } + case 300: // Total respawn + { + // 1st save changes + m_Spawner.CreaturesName = CreateArray( info, state.Mobile, 100 ); + m_Spawner.SubSpawnerA = CreateArray( info, state.Mobile, 200 ); + m_Spawner.SubSpawnerB = CreateArray( info, state.Mobile, 300 ); + m_Spawner.SubSpawnerC = CreateArray( info, state.Mobile, 400 ); + m_Spawner.SubSpawnerD = CreateArray( info, state.Mobile, 500 ); + m_Spawner.SubSpawnerE = CreateArray( info, state.Mobile, 600 ); + // then respwan + m_Spawner.Respawn(); + m_Spawner.Running = true; + break; + } + case 400: // Props + { + state.Mobile.SendGump( new PropertiesGump( state.Mobile, m_Spawner ) ); + state.Mobile.SendGump( new PremiumSpawnerGump( m_Spawner ) ); + break; + } + case 500: // Cancel button + { + break; + } + case 1000: // Okay + { + m_Spawner.CreaturesName = CreateArray( info, state.Mobile, 100 ); + m_Spawner.SubSpawnerA = CreateArray( info, state.Mobile, 200 ); + m_Spawner.SubSpawnerB = CreateArray( info, state.Mobile, 300 ); + m_Spawner.SubSpawnerC = CreateArray( info, state.Mobile, 400 ); + m_Spawner.SubSpawnerD = CreateArray( info, state.Mobile, 500 ); + m_Spawner.SubSpawnerE = CreateArray( info, state.Mobile, 600 ); + m_Spawner.Running = true; + break; + } + default: + { //ButtonID: 1-90 spawn; 91-180 remove + int ID = info.ButtonID; + + int Type = 0; + + // Spawn creature + if ( (ID >= 1) && (ID <= 15) ) + { + Type += 100 + ID; + m_Spawner.SpawnFromGump( m_Spawner.CreaturesName, m_Spawner.Creatures, m_Spawner.Count, m_Spawner.CreaturesNameCount, GetEntry(Type, info) ); + } + else if ( (ID >= 16) && (ID <= 30) ) + { + Type += 200 + ID - 15; + m_Spawner.SpawnFromGump( m_Spawner.SubSpawnerA, m_Spawner.CreaturesA, m_Spawner.CountA, m_Spawner.CreaturesNameCountA, GetEntry(Type, info) ); + } + else if ( (ID >= 31) && (ID <= 45) ) + { + Type += 300 + ID - 30; + m_Spawner.SpawnFromGump( m_Spawner.SubSpawnerB, m_Spawner.CreaturesB, m_Spawner.CountB, m_Spawner.CreaturesNameCountB, GetEntry(Type, info) ); + } + else if ( (ID >= 46) && (ID <= 60) ) + { + Type += 400 + ID - 45; + m_Spawner.SpawnFromGump( m_Spawner.SubSpawnerC, m_Spawner.CreaturesC, m_Spawner.CountC, m_Spawner.CreaturesNameCountC, GetEntry(Type, info) ); + } + else if ( (ID >= 61) && (ID <= 75) ) + { + Type += 500 + ID - 60; + m_Spawner.SpawnFromGump( m_Spawner.SubSpawnerD, m_Spawner.CreaturesD, m_Spawner.CountD, m_Spawner.CreaturesNameCountD, GetEntry(Type, info) ); + } + else if ( (ID >= 76) && (ID <= 90) ) + { + Type += 600 + ID - 75; + m_Spawner.SpawnFromGump( m_Spawner.SubSpawnerE, m_Spawner.CreaturesE, m_Spawner.CountE, m_Spawner.CreaturesNameCountE, GetEntry(Type, info) ); + } + // Remove creature + else if ( (ID >= 91) && (ID <= 105) ) + { + Type += 100 + ID - 90; + m_Spawner.RemoveCreaturesFromGump( m_Spawner.Creatures, GetEntry(Type, info) ); + } + else if ( (ID >= 106) && (ID <= 120) ) + { + Type += 200 + ID - 105; + m_Spawner.RemoveCreaturesFromGump( m_Spawner.CreaturesA, GetEntry(Type, info) ); + } + else if ( (ID >= 121) && (ID <= 135) ) + { + Type += 300 + ID - 120; + m_Spawner.RemoveCreaturesFromGump( m_Spawner.CreaturesB, GetEntry(Type, info) ); + } + else if ( (ID >= 136) && (ID <= 150) ) + { + Type += 400 + ID - 135; + m_Spawner.RemoveCreaturesFromGump( m_Spawner.CreaturesC, GetEntry(Type, info) ); + } + else if ( (ID >= 151) && (ID <= 165) ) + { + Type += 500 + ID - 150; + m_Spawner.RemoveCreaturesFromGump( m_Spawner.CreaturesD, GetEntry(Type, info) ); + } + else if ( (ID >= 166) && (ID <= 180) ) + { + Type += 600 + ID - 165; + m_Spawner.RemoveCreaturesFromGump( m_Spawner.CreaturesE, GetEntry(Type, info) ); + } + + string entry = GetEntry(Type, info); + + if ( entry != null && entry.Length > 0 ) + { + m_Spawner.CreaturesName = CreateArray( info, state.Mobile, 100 ); + m_Spawner.SubSpawnerA = CreateArray( info, state.Mobile, 200 ); + m_Spawner.SubSpawnerB = CreateArray( info, state.Mobile, 300 ); + m_Spawner.SubSpawnerC = CreateArray( info, state.Mobile, 400 ); + m_Spawner.SubSpawnerD = CreateArray( info, state.Mobile, 500 ); + m_Spawner.SubSpawnerE = CreateArray( info, state.Mobile, 600 ); + m_Spawner.Running = true; + } + + break; + } + } + } + } +} diff --git a/Scripts/Engines/Spawner/PremiumSpawner/PremiumSpawnerGumps.cs b/Scripts/Engines/Spawner/PremiumSpawner/PremiumSpawnerGumps.cs new file mode 100644 index 0000000..bd19b80 --- /dev/null +++ b/Scripts/Engines/Spawner/PremiumSpawner/PremiumSpawnerGumps.cs @@ -0,0 +1,419 @@ +// Engine r117 +using System; +using System.Collections; +using System.IO; +using Server; +using Server.Mobiles; +using Server.Items; +using Server.Commands; +using Server.Network; +using Server.Gumps; +using Server.Regions; + +namespace Server.Commands +{ + public class OptionsGumps + { + public OptionsGumps() + { + } + + public static void Initialize() + { + CommandSystem.Register( "GumpSaveRegion", AccessLevel.Administrator, new CommandEventHandler( OptionsGumps1_OnCommand ) ); + CommandSystem.Register( "GumpSaveCoordinate", AccessLevel.Administrator, new CommandEventHandler( OptionsGumps2_OnCommand ) ); + CommandSystem.Register( "GumpRemoveID", AccessLevel.Administrator, new CommandEventHandler( OptionsGumps3_OnCommand ) ); + CommandSystem.Register( "GumpRemoveCoordinate", AccessLevel.Administrator, new CommandEventHandler( OptionsGumps4_OnCommand ) ); + CommandSystem.Register( "GumpRemoveRegion", AccessLevel.Administrator, new CommandEventHandler( OptionsGumps5_OnCommand ) ); + } + + [Usage( "[GumpSaveRegion" )] + [Description( "Gump to Save inside Region" )] + private static void OptionsGumps1_OnCommand( CommandEventArgs e ) + { + e.Mobile.SendGump( new GumpSaveRegion( e ) ); + } + + [Usage( "[GumpSaveCoordinate" )] + [Description( "Gump to save by coordinates" )] + private static void OptionsGumps2_OnCommand( CommandEventArgs e ) + { + e.Mobile.SendGump( new GumpSaveCoordinate( e ) ); + } + + [Usage( "[GumpRemoveID" )] + [Description( "Gump to remove by ID" )] + private static void OptionsGumps3_OnCommand( CommandEventArgs e ) + { + e.Mobile.SendGump( new GumpRemoveID( e ) ); + } + + [Usage( "[GumpRemoveCoordinate" )] + [Description( "Gump to remove by coordinates" )] + private static void OptionsGumps4_OnCommand( CommandEventArgs e ) + { + e.Mobile.SendGump( new GumpRemoveCoordinate( e ) ); + } + + [Usage( "[GumpRemoveRegion" )] + [Description( "Gump to remove inside region" )] + private static void OptionsGumps5_OnCommand( CommandEventArgs e ) + { + e.Mobile.SendGump( new GumpRemoveRegion( e ) ); + } + } +} + +namespace Server.Gumps +{ + public class GumpSaveRegion : Gump + { + private CommandEventArgs m_CommandEventArgs; + + public GumpSaveRegion( CommandEventArgs e ) : base( 50,50 ) + { + m_CommandEventArgs = e; + Closable = true; + Dragable = true; + Mobile from = e.Mobile; + + AddPage(1); + //x, y, width, hight + AddBackground( 0, 0, 232, 210, 5054 ); + + AddImageTiled( 15, 30, 120, 20, 3004 ); + AddTextEntry( 15, 30, 120, 20, 0, 0, @"region to save"); + AddLabel( 15, 10, 52, "Enter a Region:" ); + AddButton( 140, 32, 0x15E1, 0x15E5, 101, GumpButtonType.Reply, 0 ); + + AddLabel( 15, 60, 52, "Tip:" ); + AddHtml( 15, 80, 200, 110, "This will SAVE the spawners, in a specified region, to Data/Nerun's Distro/Spawns/'region name'.map. Type [where if you don't know the region you are. Copy to the text box the name of the region. You also can open Data/Regions.xml to a full list of regions.
Example: you type [where and appear 'your region is town of Britain'. Type 'Britain' in text box.", true, true ); + } + + public override void OnResponse(NetState state, RelayInfo info) + { + Mobile from = state.Mobile; + + switch ( info.ButtonID ) + { + case 0: // close the gump + { + break; + } + + case 101: + { + TextRelay oRegion = info.GetTextEntry( 0 ); + string sRegion = oRegion.Text; + if( sRegion != "" ) + { + string prefix = Server.Commands.CommandSystem.Prefix; + CommandSystem.Handle( from, String.Format( "{0}Spawngen save {1}", prefix, sRegion ) ); + } + else + { + from.SendMessage( "You must specify a region!" ); + string prefix = Server.Commands.CommandSystem.Prefix; + CommandSystem.Handle( from, String.Format( "{0}GumpSaveRegion", prefix ) ); + } + break; + } + } + } + } + + public class GumpRemoveRegion : Gump + { + private CommandEventArgs m_CommandEventArgs; + + public GumpRemoveRegion( CommandEventArgs e ) : base( 50,50 ) + { + m_CommandEventArgs = e; + Closable = true; + Dragable = true; + Mobile from = e.Mobile; + + AddPage(1); + + AddBackground( 0, 0, 232, 210, 5054 ); + + AddImageTiled( 15, 30, 120, 20, 3004 ); + AddTextEntry( 15, 30, 120, 20, 0, 0, @"region to remove"); + AddLabel( 15, 10, 52, "Enter a Region:" ); + AddButton( 140, 32, 0x15E1, 0x15E5, 101, GumpButtonType.Reply, 0 ); + + AddLabel( 15, 60, 52, "Tip:" ); + AddHtml( 15, 80, 200, 110, "This will REMOVE the spawners, in a specified region. Type [where if you don't know the region you are. Copy to the text box the name of the region. You also can open Data/Regions.xml to a full list of regions.
Example: you type [where and appear 'your region is town of Britain'. Type 'Britain' in text box.", true, true ); + } + + public override void OnResponse(NetState state, RelayInfo info) + { + Mobile from = state.Mobile; + + switch ( info.ButtonID ) + { + case 0: // close the gump + { + break; + } + + case 101: + { + TextRelay oRegion = info.GetTextEntry( 0 ); + string sRegion = oRegion.Text; + if( sRegion != "" ) + { + string prefix = Server.Commands.CommandSystem.Prefix; + CommandSystem.Handle( from, String.Format( "{0}Spawngen remove {1}", prefix, sRegion ) ); + } + else + { + from.SendMessage( "You must specify a region!" ); + string prefix = Server.Commands.CommandSystem.Prefix; + CommandSystem.Handle( from, String.Format( "{0}GumpRemoveRegion", prefix ) ); + } + break; + } + } + } + } + + public class GumpRemoveID : Gump + { + private CommandEventArgs m_CommandEventArgs; + + public GumpRemoveID( CommandEventArgs e ) : base( 50,50 ) + { + m_CommandEventArgs = e; + Closable = true; + Dragable = true; + Mobile from = e.Mobile; + + AddPage(1); + + AddBackground( 0, 0, 232, 210, 5054 ); + + AddImageTiled( 15, 30, 120, 20, 3004 ); + AddTextEntry( 15, 30, 120, 20, 0, 0, @"SpawnID to remove"); + AddLabel( 15, 10, 52, "Enter a SpawnID:" ); + AddButton( 140, 32, 0x15E1, 0x15E5, 101, GumpButtonType.Reply, 0 ); + + AddLabel( 15, 60, 52, "Tip:" ); + AddHtml( 15, 80, 200, 110, "This command was made to UNLOAD your own custom maps. This will REMOVE the spawners with the specified ID. Type '[get spawnid' in a spawner to know your ID. Remember: 'By Hand' spawns, i.e., those done with '[add premiumspawner' have ID = 1.", true, true ); + } + + public override void OnResponse(NetState state, RelayInfo info) + { + Mobile from = state.Mobile; + + switch ( info.ButtonID ) + { + case 0: // close the gump + { + break; + } + + case 101: + { + TextRelay oID = info.GetTextEntry( 0 ); + string sID = oID.Text; + if( sID != "" ) + { + try + { + int UnloadID = Convert.ToInt32( sID ); + string prefix = Server.Commands.CommandSystem.Prefix; + CommandSystem.Handle( from, String.Format( "{0}Spawngen unload {1}", prefix, UnloadID ) ); + } + catch + { + from.SendMessage( "SpawnID must be a number!" ); + string prefix = Server.Commands.CommandSystem.Prefix; + CommandSystem.Handle( from, String.Format( "{0}GumpRemoveID", prefix ) ); + } + } + + else + { + from.SendMessage( "You must specify an SpawnID!" ); + string prefix = Server.Commands.CommandSystem.Prefix; + CommandSystem.Handle( from, String.Format( "{0}GumpRemoveID", prefix ) ); + } + break; + } + } + } + } + + public class GumpSaveCoordinate : Gump + { + private CommandEventArgs m_CommandEventArgs; + + public GumpSaveCoordinate( CommandEventArgs e ) : base( 50,50 ) + { + m_CommandEventArgs = e; + Closable = true; + Dragable = true; + Mobile from = e.Mobile; + + AddPage(1); + + AddBackground( 0, 0, 232, 235, 5054 ); + + AddImageTiled( 15, 30, 37, 20, 3004 ); + AddTextEntry( 15, 30, 37, 20, 0, 0, @"X1"); + + AddImageTiled( 57, 30, 37, 20, 3004 ); + AddTextEntry( 57, 30, 37, 20, 0, 1, @"Y1"); + + AddImageTiled( 15, 55, 37, 20, 3004 ); + AddTextEntry( 15, 55, 37, 20, 0, 2, @"X2"); + + AddImageTiled( 57, 55, 37, 20, 3004 ); + AddTextEntry( 57, 55, 37, 20, 0, 3, @"Y2"); + + AddLabel( 15, 10, 52, "Enter Coordinates:" ); + AddButton( 140, 32, 0x15E1, 0x15E5, 101, GumpButtonType.Reply, 0 ); + + AddLabel( 15, 85, 52, "Tip:" ); + AddHtml( 15, 105, 200, 110, "This will SAVE spawners inside specified coordinates. You can use [where in the first point and again [where in the second point to get the X and Y coordinates. You need 2: X1, Y1 for first point and X2, Y2 for the second point. The objective is determine a 'box'. This command will save all spawners inside this box.", true, true ); + } + + public override void OnResponse(NetState state, RelayInfo info) + { + Mobile from = state.Mobile; + + switch ( info.ButtonID ) + { + case 0: // close the gump + { + break; + } + + case 101: + { + TextRelay oX1 = info.GetTextEntry( 0 ); + TextRelay oY1 = info.GetTextEntry( 1 ); + TextRelay oX2 = info.GetTextEntry( 2 ); + TextRelay oY2 = info.GetTextEntry( 3 ); + string sX1 = oX1.Text; + string sY1 = oY1.Text; + string sX2 = oX2.Text; + string sY2 = oY2.Text; + if( sX1 != "" && sY1 != "" && sX2 != "" && sY2 != "" ) + { + try + { + int iX1 = Convert.ToInt32( sX1 ); + int iY1 = Convert.ToInt32( sY1 ); + int iX2 = Convert.ToInt32( sX2 ); + int iY2 = Convert.ToInt32( sY2 ); + string prefix = Server.Commands.CommandSystem.Prefix; + CommandSystem.Handle( from, String.Format( "{0}Spawngen save {1} {2} {3} {4}", prefix, iX1, iY1, iX2, iY2 ) ); + } + catch + { + from.SendMessage( "Coordinates must be numbers!" ); + string prefix = Server.Commands.CommandSystem.Prefix; + CommandSystem.Handle( from, String.Format( "{0}GumpSaveCoordinate", prefix ) ); + } + } + + else + { + from.SendMessage( "You must specify all coordinates!" ); + string prefix = Server.Commands.CommandSystem.Prefix; + CommandSystem.Handle( from, String.Format( "{0}GumpSaveCoordinate", prefix ) ); + } + break; + } + } + } + } + + public class GumpRemoveCoordinate : Gump + { + private CommandEventArgs m_CommandEventArgs; + + public GumpRemoveCoordinate( CommandEventArgs e ) : base( 50,50 ) + { + m_CommandEventArgs = e; + Closable = true; + Dragable = true; + Mobile from = e.Mobile; + + AddPage(1); + + AddBackground( 0, 0, 232, 235, 5054 ); + + AddImageTiled( 15, 30, 37, 20, 3004 ); + AddTextEntry( 15, 30, 37, 20, 0, 0, @"X1"); + + AddImageTiled( 57, 30, 37, 20, 3004 ); + AddTextEntry( 57, 30, 37, 20, 0, 1, @"Y1"); + + AddImageTiled( 15, 55, 37, 20, 3004 ); + AddTextEntry( 15, 55, 37, 20, 0, 2, @"X2"); + + AddImageTiled( 57, 55, 37, 20, 3004 ); + AddTextEntry( 57, 55, 37, 20, 0, 3, @"Y2"); + + AddLabel( 15, 10, 52, "Enter Coordinates:" ); + AddButton( 140, 32, 0x15E1, 0x15E5, 101, GumpButtonType.Reply, 0 ); + + AddLabel( 15, 85, 52, "Tip:" ); + AddHtml( 15, 105, 200, 110, "This will REMOVE spawners inside specified coordinates. You can use [where in the first point and again [where in the second point to get the X and Y coordinates. You need 2: X1, Y1 for first point and X2, Y2 for the second point. The objective is determine a 'box'. This command will remove all spawners inside this box.", true, true ); + } + + public override void OnResponse(NetState state, RelayInfo info) + { + Mobile from = state.Mobile; + + switch ( info.ButtonID ) + { + case 0: // close the gump + { + break; + } + + case 101: + { + TextRelay oX1 = info.GetTextEntry( 0 ); + TextRelay oY1 = info.GetTextEntry( 1 ); + TextRelay oX2 = info.GetTextEntry( 2 ); + TextRelay oY2 = info.GetTextEntry( 3 ); + string sX1 = oX1.Text; + string sY1 = oY1.Text; + string sX2 = oX2.Text; + string sY2 = oY2.Text; + if( sX1 != "" && sY1 != "" && sX2 != "" && sY2 != "" ) + { + try + { + int iX1 = Convert.ToInt32( sX1 ); + int iY1 = Convert.ToInt32( sY1 ); + int iX2 = Convert.ToInt32( sX2 ); + int iY2 = Convert.ToInt32( sY2 ); + string prefix = Server.Commands.CommandSystem.Prefix; + CommandSystem.Handle( from, String.Format( "{0}Spawngen remove {1} {2} {3} {4}", prefix, iX1, iY1, iX2, iY2 ) ); + } + catch + { + from.SendMessage( "Coordinates must be numbers!" ); + string prefix = Server.Commands.CommandSystem.Prefix; + CommandSystem.Handle( from, String.Format( "{0}GumpRemoveCoordinate", prefix ) ); + } + } + + else + { + from.SendMessage( "You must specify all coordinates!" ); + string prefix = Server.Commands.CommandSystem.Prefix; + CommandSystem.Handle( from, String.Format( "{0}GumpRemoveCoordinate", prefix ) ); + } + break; + } + } + } + } +} \ No newline at end of file diff --git a/Scripts/Engines/Spawner/PremiumSpawner/PremiumSpawnerMainGump.cs b/Scripts/Engines/Spawner/PremiumSpawner/PremiumSpawnerMainGump.cs new file mode 100644 index 0000000..07221ef --- /dev/null +++ b/Scripts/Engines/Spawner/PremiumSpawner/PremiumSpawnerMainGump.cs @@ -0,0 +1,288 @@ +// Engine r153 +using System; +using Server; +using Server.Gumps; +using Server.Network; +using Server.Commands; + +namespace Server.Gumps +{ + public class PremiumSpawnerMainGump : Gump + { + public static void Initialize() + { + CommandSystem.Register("PremiumSpawner", AccessLevel.Administrator, new CommandEventHandler(PremiumSpawner_OnCommand)); + CommandSystem.Register("Spawner", AccessLevel.Administrator, new CommandEventHandler(PremiumSpawner_OnCommand)); + } + + [Usage("PremiumSpawner")] + [Aliases( "Spawner" )] + [Description("PremiumSpawner main gump.")] + public static void PremiumSpawner_OnCommand(CommandEventArgs e) + { + Mobile from = e.Mobile; + + if (from.HasGump(typeof(PremiumSpawnerMainGump))) + from.CloseGump(typeof(PremiumSpawnerMainGump)); + from.SendGump(new PremiumSpawnerMainGump(from)); + } + + public PremiumSpawnerMainGump(Mobile from) : this() + { + } + + public void AddBlackAlpha( int x, int y, int width, int height ) + { + AddImageTiled( x, y, width, height, 2624 ); + AddAlphaRegion( x, y, width, height ); + } + + public PremiumSpawnerMainGump() : base( 0, 0 ) + { + this.Closable=true; + this.Disposable=true; + this.Dragable=true; + //PAGE 1 + AddPage(1); + AddBackground(93, 68, 256, 423, 9200); + AddHtml( 98, 75, 244, 44, " PREMIUM SPAWNER
" + "by Nerun Rev.154", (bool)true, (bool)false); + AddBlackAlpha(100, 124, 241, 71); + AddLabel(109, 126, 52, @"WORLD CREATION"); + AddLabel(126, 148, 52, @"Let there be light (Create World)"); + AddLabel(126, 170, 52, @"Apocalypse now (Clear All Facets)"); + AddButton(109, 151, 1210, 1209, 101, GumpButtonType.Reply, 0); + AddButton(109, 173, 1210, 1209, 102, GumpButtonType.Reply, 0); + AddBlackAlpha(100, 200, 241, 89); + AddLabel(109, 202, 52, @"SELECT SPAWNS BY EXPANSION"); + AddLabel(126, 224, 52, @"UO Classic spawns (pre-T2A)"); + AddLabel(126, 244, 52, @"UO Mondain's Legacy spawns"); + AddLabel(126, 264, 52, @"UO KR, SA and HS spawns"); + //AddLabel(238, 224, 52, @"UO:ML spawns"); + //AddLabel(238, 244, 52, @"UO:KR, SA and HS spawns"); + //AddLabel(238, 264, 52, @"teste"); + AddButton(109, 227, 1210, 1209, 103, GumpButtonType.Reply, 0); + AddButton(109, 247, 1210, 1209, 104, GumpButtonType.Reply, 0); + AddButton(109, 267, 1210, 1209, 105, GumpButtonType.Reply, 0); + //AddButton(221, 227, 1210, 1209, 106, GumpButtonType.Reply, 0); + //AddButton(221, 247, 1210, 1209, 107, GumpButtonType.Reply, 0); + //AddButton(221, 267, 1210, 1209, 108, GumpButtonType.Reply, 0); + AddBlackAlpha(100, 294, 241, 89); + AddLabel(109, 296, 52, @"REMOVE SPAWNS BY EXPANSION"); + AddLabel(126, 318, 52, @"UO Classic spawns (pre-T2A)"); + AddLabel(126, 338, 52, @"UO Mondain's Legacy spawns"); + AddLabel(126, 358, 52, @"UO KR, SA and HS spawns"); + //AddLabel(238, 318, 52, @"Ter Mur"); + //AddLabel(238, 338, 52, @"Tokuno"); + //AddLabel(238, 358, 52, @"Trammel"); + AddButton(109, 321, 1210, 1209, 109, GumpButtonType.Reply, 0); + AddButton(109, 341, 1210, 1209, 110, GumpButtonType.Reply, 0); + AddButton(109, 361, 1210, 1209, 111, GumpButtonType.Reply, 0); + //AddButton(221, 321, 1210, 1209, 112, GumpButtonType.Reply, 0); + //AddButton(221, 341, 1210, 1209, 113, GumpButtonType.Reply, 0); + //AddButton(221, 361, 1210, 1209, 114, GumpButtonType.Reply, 0); + AddBlackAlpha(100, 388, 241, 68); + AddLabel(109, 391, 52, @"SMART PLAYER RANGE SENSITIVE"); + AddLabel(126, 413, 52, @"Generate Spawns' Overseer"); + AddLabel(126, 432, 52, @"Remove Spawns' Overseer"); + AddButton(109, 416, 1210, 1209, 115, GumpButtonType.Reply, 0); + AddButton(109, 435, 1210, 1209, 116, GumpButtonType.Reply, 0); + //Page change + AddLabel(207, 463, 200, @"1/3"); + AddButton(235, 465, 5601, 5605, 0, GumpButtonType.Page, 2); //advance + + // PAGE 2 + AddPage(2); + AddBackground(93, 68, 256, 423, 9200); + AddHtml( 98, 75, 244, 44, " PREMIUM SPAWNER
" + "by Nerun Rev.154", (bool)true, (bool)false); + AddBlackAlpha(100, 124, 241, 114); + AddLabel(109, 126, 52, @"SAVE SPAWNERS"); + AddLabel(126, 148, 52, @"All spawns (spawns.map)"); + AddLabel(126, 170, 52, @"'By hand' spawns (byhand.map)"); + AddLabel(126, 192, 52, @"Spawns inside region (region.map)"); + AddLabel(126, 214, 52, @"Spawns inside coordinates"); + AddButton(109, 151, 1210, 1209, 117, GumpButtonType.Reply, 0); + AddButton(109, 173, 1210, 1209, 118, GumpButtonType.Reply, 0); + AddButton(109, 195, 1210, 1209, 119, GumpButtonType.Reply, 0); + AddButton(109, 217, 1210, 1209, 120, GumpButtonType.Reply, 0); + AddBlackAlpha(100, 244, 241, 134); + AddLabel(109, 246, 52, @"REMOVE SPAWNERS"); + AddLabel(126, 268, 52, @"All spawners in ALL facets"); + AddLabel(126, 290, 52, @"All spawners in THIS facet"); + AddLabel(126, 312, 52, @"Remove spawners by SpawnID"); + AddLabel(126, 334, 52, @"Remove inside coordinates"); + AddLabel(126, 355, 52, @"Remove spawners inside region"); + AddButton(109, 271, 1210, 1209, 121, GumpButtonType.Reply, 0); + AddButton(109, 293, 1210, 1209, 122, GumpButtonType.Reply, 0); + AddButton(109, 315, 1210, 1209, 123, GumpButtonType.Reply, 0); + AddButton(109, 337, 1210, 1209, 124, GumpButtonType.Reply, 0); + AddButton(109, 358, 1210, 1209, 125, GumpButtonType.Reply, 0); + AddBlackAlpha(100, 385, 241, 71); + AddLabel(109, 387, 52, @"EDITOR"); + AddLabel(126, 408, 52, @"Spawn Editor (edit, find and list"); + AddLabel(126, 427, 52, @"all PremiumSpawners in the world)"); + AddButton(109, 411, 1210, 1209, 126, GumpButtonType.Reply, 0); + //Page change + AddLabel(207, 463, 200, @"2/3"); + AddButton(189, 465, 5603, 5607, 0, GumpButtonType.Page, 1); //back + AddButton(235, 465, 5601, 5605, 0, GumpButtonType.Page, 3); //advance + + //PAGE 3 + AddPage(3); + AddBackground(93, 68, 256, 423, 9200); + AddHtml( 98, 75, 244, 44, " PREMIUM SPAWNER
" + "by Nerun Rev.154", (bool)true, (bool)false); + AddBlackAlpha(101, 124, 241, 47); + AddLabel(109, 126, 52, @"CONVERSION UTILITY"); + AddLabel(127, 148, 52, @"RunUO Spawners to Premium"); + AddButton(110, 151, 1210, 1209, 127, GumpButtonType.Reply, 0); + AddBlackAlpha(101, 177, 241, 134); + AddLabel(109, 179, 52, @"CUSTOM REGIONS IN A BOX"); + AddLabel(127, 201, 52, @"Add a Region Controler"); + AddLabel(127, 222, 52, @"(double-click the Region"); + AddLabel(127, 243, 52, @"Controller to configure it region."); + AddLabel(127, 264, 52, @"Every Controller control one"); + AddLabel(127, 286, 52, @"region. Don't forget to prop)"); + AddButton(110, 204, 1210, 1209, 128, GumpButtonType.Reply, 0); + //Page change + AddLabel(207, 463, 200, @"3/3"); + AddButton(189, 465, 5603, 5607, 0, GumpButtonType.Page, 2); //back + } + + public static void DoThis( Mobile from, string command) + { + string prefix = Server.Commands.CommandSystem.Prefix; + CommandSystem.Handle( from, String.Format( "{0}{1}", prefix, command ) ); + CommandSystem.Handle( from, String.Format( "{0}spawner", prefix ) ); + } + + public override void OnResponse(NetState sender, RelayInfo info) + { + Mobile from = sender.Mobile; + + switch(info.ButtonID) + { + case 0: + { + //Quit + break; + } + case 101: + { + DoThis( from, "createworld" ); + break; + } + case 102: + { + DoThis( from, "clearall" ); + break; + } + case 103: + { + from.Say( "SPAWNING UO Classic..." ); + DoThis( from, "spawngen uoclassic/UOClassic.map" ); + break; + } + case 104: + { + DoThis( from, "SpawnUOML" ); + break; + } + case 105: + { + DoThis( from, "SpawnCurrent" ); + break; + } + //DoThis( from106, "" ); + //DoThis( from107, "" ); + //DoThis( from108, "" ); + case 109: + { + DoThis( from, "spawngen unload 1000" ); + break; + } + case 110: + { + DoThis( from, "UnloadUOML" ); + break; + } + case 111: + { + DoThis( from, "UnloadCurrent" ); + break; + } + //DoThis( from112, "" ); + //DoThis( from113, "" ); + //DoThis( from114, "" ); + case 115: + { + DoThis( from, "GenSeers" ); + break; + } + case 116: + { + DoThis( from, "RemSeers" ); + break; + } + case 117: + { + DoThis( from, "spawngen save" ); + break; + } + case 118: + { + DoThis( from, "spawngen savebyhand" ); + break; + } + case 119: + { + DoThis( from, "GumpSaveRegion" ); + break; + } + case 120: + { + DoThis( from, "GumpSaveCoordinate" ); + break; + } + case 121: + { + DoThis( from, "spawngen remove" ); + break; + } + case 122: + { + DoThis( from, "spawngen cleanfacet" ); + break; + } + case 123: + { + DoThis( from, "GumpRemoveID" ); + break; + } + case 124: + { + DoThis( from, "GumpRemoveCoordinate" ); + break; + } + case 125: + { + DoThis( from, "GumpRemoveRegion" ); + break; + } + case 126: + { + DoThis( from, "SpawnEditor" ); + break; + } + case 127: + { + DoThis( from, "RunUOSpawnerExporter" ); + break; + } + case 128: + { + DoThis( from, "Add RegionControl" ); + break; + } + } + } + } +} diff --git a/Scripts/Engines/Spawner/PremiumSpawner/RunUOSpawnerExporter.cs b/Scripts/Engines/Spawner/PremiumSpawner/RunUOSpawnerExporter.cs new file mode 100644 index 0000000..52e0f05 --- /dev/null +++ b/Scripts/Engines/Spawner/PremiumSpawner/RunUOSpawnerExporter.cs @@ -0,0 +1,161 @@ +//Engine r154 +using System; +using System.IO; +using System.Text; +using System.Collections.Generic; +using Server; +using Server.Mobiles; +using Server.Items; + +namespace Server.Commands +{ + public class RunUOSpawnerExporter + { + public const bool Enabled = true; + + public static bool IsLinux + { + get + { + int p = (int) Environment.OSVersion.Platform; + return (p == 4) || (p == 6) || (p == 128); + } + } + + public static void Initialize() + { + CommandSystem.Register( "RunUOSpawnerExporter" , AccessLevel.Administrator, new CommandEventHandler( RunUOSpawnerExporter_OnCommand ) ); + CommandSystem.Register( "RSE" , AccessLevel.Administrator, new CommandEventHandler( RunUOSpawnerExporter_OnCommand ) ); + } + + public static int ConvertToInt( TimeSpan ts ) + { + return ( ( ts.Hours * 60 ) + ts.Minutes + (ts.Seconds/60) ); + } + + [Usage( "RunUOSpawnerExporter" )] + [Aliases( "RSE" )] + [Description( "Convert RunUO Spawners to PremiumSpawners." )] + public static void RunUOSpawnerExporter_OnCommand( CommandEventArgs e ) + { + Map map = e.Mobile.Map; + List list = new List(); + + string bar = "\\"; + + if (IsLinux == true) + bar = "/"; + + string path = @"."+bar+"Data"+bar+"Nerun's Distro"+bar+"Spawns"+bar; + + if ( !Directory.Exists( path ) ) + Directory.CreateDirectory( path ); + + using ( StreamWriter op = new StreamWriter( String.Format( path+"{0}-exported.map", map ) ) ) + { + + if ( map == null || map == Map.Internal ) + { + e.Mobile.SendMessage( "You may not run that command here." ); + return; + } + + e.Mobile.SendMessage( "Converting Spawners..." ); + + op.WriteLine( "#######################################" ); + op.WriteLine( "## Converted By RunUOSpawnerExporter ##" ); + op.WriteLine( "## Developed by Nerun ##" ); + op.WriteLine( "#######################################" ); + + foreach ( Item item in World.Items.Values ) + { + if ( item.Map == map && item.Parent == null && item is Spawner ) + list.Add( item ); + } + + foreach ( Spawner spawner in list ) + { + string mapfinal = ""; + + string walkrange = ""; + + if(map == Map.Maps[0]) + { + mapfinal = "1"; + } + else if(map == Map.Maps[1]) + { + mapfinal = "2"; + } + else if(map == Map.Maps[2]) + { + mapfinal = "3"; + } + else if(map == Map.Maps[3]) + { + mapfinal = "4"; + } + else if(map == Map.Maps[4]) + { + mapfinal = "5"; + } + else + { + mapfinal = "6"; + } + + if( spawner.WalkingRange == -1 ) + { + walkrange = spawner.HomeRange.ToString(); + } + else + { + walkrange = spawner.WalkingRange.ToString(); + } + + int MinDelay = ConvertToInt(spawner.MinDelay); + + if (MinDelay < 1) + { + MinDelay = 1; + } + + int MaxDelay = ConvertToInt(spawner.MaxDelay); + + if (MaxDelay < MinDelay) + { + MaxDelay = MinDelay; + } + + string towrite = "*|"; + + if( spawner.SpawnNames.Count > 0 ) + { + towrite = "*|" + spawner.SpawnNames[0]; + + for ( int i = 1; i < spawner.SpawnNames.Count; ++i ) + { + towrite = towrite + ":" + spawner.SpawnNames[i].ToString(); + } + } + + if ( spawner.SpawnNames.Count > 0 && spawner.Running == true ) + { + op.WriteLine( "{0}||||||{1}|{2}|{3}|{4}|{5}|{6}|{7}|{8}|1|{9}|0|0|0|0|0", towrite, spawner.X, spawner.Y, spawner.Z, mapfinal, MinDelay, MaxDelay, walkrange, spawner.HomeRange, spawner.Count); + } + + if( spawner.SpawnNames.Count == 0 ) + { + op.WriteLine( "## Void: {0}||||||{1}|{2}|{3}|{4}|{5}|{6}|{7}|{8}|1|{9}|0|0|0|0|0", towrite, spawner.X, spawner.Y, spawner.Z, mapfinal, MinDelay, MaxDelay, walkrange, spawner.HomeRange, spawner.Count); + } + + if( spawner.SpawnNames.Count > 0 && spawner.Running == false ) + { + op.WriteLine( "## Inactive: {0}||||||{1}|{2}|{3}|{4}|{5}|{6}|{7}|{8}|1|{9}|0|0|0|0|0", towrite, spawner.X, spawner.Y, spawner.Z, mapfinal, MinDelay, MaxDelay, walkrange, spawner.HomeRange, spawner.Count); + } + } + e.Mobile.SendMessage( String.Format( "You exported {0} RunUO Spawner{1} from this facet.", list.Count, list.Count == 1 ? "" : "s" ) ); + } + } + } +} diff --git a/Scripts/Engines/Spawner/PremiumSpawner/SpawnEditor.cs b/Scripts/Engines/Spawner/PremiumSpawner/SpawnEditor.cs new file mode 100644 index 0000000..c3b3ff4 --- /dev/null +++ b/Scripts/Engines/Spawner/PremiumSpawner/SpawnEditor.cs @@ -0,0 +1,1017 @@ +///////////////////////////////////// +// SPAWN EDITOR // +// This SpawnEditor is a huge mod // +// of "ZenArcher's SpawnEditor v2" // +// By Nerun // +///////////////////////////////////// +using System; +using System.IO; +using System.Collections; +using System.Collections.Generic; +using Server; +using Server.Items; +using Server.Mobiles; +using Server.Network; +using Server.Regions; +using Server.Commands; + +namespace Server.Gumps +{ + public class SpawnEditorGump : Gump + { + private int m_page; + private ArrayList m_tempList; + public Item m_selSpawner; + + public int page + { + get{ return m_page; } + set{ m_page = value; } + } + + public Item selSpawner + { + get{ return m_selSpawner; } + set{ m_selSpawner = value; } + } + + public ArrayList tempList + { + get{ return m_tempList; } + set{ m_tempList = value; } + } + + public static void Initialize() + { + CommandSystem.Register( "SpawnEditor", AccessLevel.GameMaster, new CommandEventHandler( SpawnEditor_OnCommand ) ); + CommandSystem.Register( "Editor", AccessLevel.GameMaster, new CommandEventHandler( SpawnEditor_OnCommand ) ); + } + + public static void Register( string command, AccessLevel access, CommandEventHandler handler ) + { + CommandSystem.Register( command, access, handler ); + } + + [Usage( "SpawnEditor" )] + [Aliases( "Editor" )] + [Description( "Used to find and edit spawns" )] + public static void SpawnEditor_OnCommand( CommandEventArgs e ) + { + Mobile from = e.Mobile; + SpawnEditor_OnCommand( from ); + } + + public static void SpawnEditor_OnCommand( Mobile from ) + { + ArrayList worldList = new ArrayList(); + ArrayList facetList = new ArrayList(); + + Type type = ScriptCompiler.FindTypeByName( "PremiumSpawner", true ); + + if ( type == typeof( Item ) || type.IsSubclassOf( typeof( Item ) ) ) + { + bool isAbstract = type.IsAbstract; + + foreach ( Item item in World.Items.Values ) + { + if ( isAbstract ? item.GetType().IsSubclassOf( type ) : item.GetType() == type ) + worldList.Add( item ); + } + } + + foreach( PremiumSpawner worldSpnr in worldList ) + { + if( worldSpnr.Map == from.Map ) + facetList.Add( worldSpnr ); + } + +//TODO: Sort spawner list + + SpawnEditor_OnCommand( from, 0, facetList ); + } + + public static void SpawnEditor_OnCommand( Mobile from, int page, ArrayList currentList ) + { + SpawnEditor_OnCommand( from, page, currentList, 0 ); + } + + public static void SpawnEditor_OnCommand( Mobile from, int page, ArrayList currentList, int selected ) + { + SpawnEditor_OnCommand( from, page, currentList, selected, null ); + } + + public static void SpawnEditor_OnCommand( Mobile from, int page, ArrayList currentList, int selected, Item selSpawner ) + { + from.SendGump( new SpawnEditorGump( from, page, currentList, selected, selSpawner ) ); + } + + public SpawnEditorGump( Mobile from, int page, ArrayList currentList, int selected, Item spwnr ) : base( 50, 40 ) + { + tempList = new ArrayList(); + Mobile m = from; + m_page = page; + Region r = from.Region; + Map map = from.Map; + int buttony = 60; + int buttonID = 1; + int listnum = 0; + + tempList = currentList; + + selSpawner = spwnr; + + AddPage(0); + + AddBackground( 0, 0, 600, 450, 5054 ); + AddImageTiled( 8, 8, 584, 40, 2624 ); + AddAlphaRegion( 8, 8, 584, 40 ); + AddImageTiled( 8, 50, 250, 396, 2624 ); + AddAlphaRegion( 8, 50, 250, 396 ); + AddImageTiled( 260, 50, 332, 396, 2624 ); + AddAlphaRegion( 260, 50, 332, 396 ); + AddLabel( 220, 20, 52, "PREMIUM SPAWNER EDITOR" ); + AddButton( 550, 405, 0x158A, 0x158B, 10002, GumpButtonType.Reply, 1 ); //Quit Button + AddButton( 275, 412, 0x845, 0x846, 10008, GumpButtonType.Reply, 0 ); // Refresh button + AddLabel( 300, 410, 52, "Refresh" ); + + if( currentList.Count == 0 ) + AddLabel( 50, 210, 52, "No Premium Spawners Found" ); + else + { + if( page == 0 ) + { + if( currentList.Count < 15 ) + listnum = currentList.Count; + else + listnum = 15; + + for( int x = 0; x < listnum; x++ ) + { + Item spawnr = null; + + if( currentList[x] is Item ) + spawnr = currentList[x] as Item; + + string gumpMsg = ""; + + Point3D spawnr3D = new Point3D( ( new Point2D( spawnr.X, spawnr.Y ) ), spawnr.Z ); + Region spawnrRegion = Region.Find( spawnr3D, map ); + + if( spawnrRegion.ToString() == "" ) + gumpMsg = "PremiumSpawner at " + spawnr.X.ToString() + ", " + spawnr.Y.ToString(); + else + gumpMsg = spawnrRegion.ToString(); + + AddButton( 25, buttony, 0x845, 0x846, buttonID, GumpButtonType.Reply, 0 ); + AddLabel( 55, buttony, 52, gumpMsg ); + buttony += 25; + buttonID += 1; + } + } + + else if( page > 0 ) + { + if( currentList.Count < 15 + ( 15 * page ) ) + listnum = currentList.Count; + else + listnum = 15 + ( 15 * page ); + + for( int x = 15 * page; x < listnum; x++ ) + { + Item spawnr = null; + buttonID = x+1; + + if( currentList[x] is Item ) + spawnr = currentList[x] as Item; + + string gumpMsg = ""; + + Point3D spawnr3D = new Point3D( ( new Point2D( spawnr.X, spawnr.Y ) ), spawnr.Z ); + Region spawnrRegion = Region.Find( spawnr3D, map ); + + if( spawnrRegion.ToString() == "" ) + gumpMsg = "PremiumSpawner at " + spawnr.X.ToString() + ", " + spawnr.Y.ToString(); + else + gumpMsg = spawnrRegion.ToString(); + + AddButton( 25, buttony, 0x845, 0x846, buttonID, GumpButtonType.Reply, 0 ); + AddLabel( 55, buttony, 52, gumpMsg ); + buttony += 25; + } + } + } + + if( page == 0 && currentList.Count > 15 ) + AddButton( 450, 20, 0x15E1, 0x15E5, 10000, GumpButtonType.Reply, 0 ); + else if( page > 0 && currentList.Count > 15 + ( page * 15 ) ) + AddButton( 450, 20, 0x15E1, 0x15E5, 10000, GumpButtonType.Reply, 0 ); + + if( page != 0 ) + AddButton( 150, 20, 0x15E3, 0x15E7, 10001, GumpButtonType.Reply, 0 ); + + int pageNum = (int)currentList.Count / 15; + int rem = currentList.Count % 15; + int totPages = 0; + + string stotPages = ""; + + if( rem > 0 ) + { + totPages = pageNum + 1; + stotPages = totPages.ToString(); + } + else + stotPages = pageNum.ToString(); + + string pageText = "Page " + ( page + 1 ) + " of " + stotPages; + + AddLabel( 40, 20, 52, pageText ); + + if( selected == 0 ) + InitializeStartingRightPanel(); + else if( selected == 1 ) + InitializeSelectedRightPanel(); + } + + public void InitializeStartingRightPanel() + { + AddLabel( 275, 65, 52, "Filter to current region only" ); + AddButton( 500, 65, 0x15E1, 0x15E5, 10003, GumpButtonType.Reply, 0 ); + + AddTextField( 275, 140, 50, 20, 0 ); + AddLabel( 275, 115, 52, "Filter by Distance" ); + AddButton( 500, 115, 0x15E1, 0x15E5, 10004, GumpButtonType.Reply, 0 ); + + AddTextField( 275, 190, 120, 20, 1 ); + AddLabel( 275, 165, 52, "Search Spawners by Creature" ); + AddButton( 500, 165, 0x15E1, 0x15E5, 10009, GumpButtonType.Reply, 0 ); + + AddTextField( 275, 240, 50, 20, 2 ); + AddLabel( 275, 215, 52, "Search Spawners by SpawnID" ); + AddButton( 500, 215, 0x15E1, 0x15E5, 10010, GumpButtonType.Reply, 0 ); + } + + public void InitializeSelectedRightPanel() + { + string spX = selSpawner.X.ToString(); + string spY = selSpawner.Y.ToString(); + string spnText = "PremiumSpawner at " + spX + ", " + spY; + + AddLabel( 350, 65, 52, spnText ); + + PremiumSpawner initSpn = selSpawner as PremiumSpawner; + int strNum = 0; + string spns = "Containing: "; + string spnsNEW = ""; + string spns1 = ""; + string spns2 = ""; + string spns3 = ""; + + for( int i = 0; i < initSpn.CreaturesName.Count; i++ ) + { + if( strNum == 0 ) + { + if( i < initSpn.CreaturesName.Count - 1 ) + { + if( spns.Length + initSpn.CreaturesName[i].ToString().Length < 50 ) + spnsNEW += (string)initSpn.CreaturesName[i] + ", "; + else + { + strNum = 1; + spns1 += (string)initSpn.CreaturesName[i] + ", "; + } + } + else + spnsNEW += (string)initSpn.CreaturesName[i]; + } + else if( strNum == 1 ) + { + if( i < initSpn.CreaturesName.Count - 1 ) + { + if( spns1.Length + initSpn.CreaturesName[i].ToString().Length < 50 ) + spns1 += (string)initSpn.CreaturesName[i] + ", "; + else + { + strNum = 2; + spns2 += (string)initSpn.CreaturesName[i] + ", "; + } + } + else + { + if( spns1.Length + initSpn.CreaturesName[i].ToString().Length < 50 ) + spns1 += (string)initSpn.CreaturesName[i]; + else + { + strNum = 3; + spns2 += (string)initSpn.CreaturesName[i]; + } + } + } + else if( strNum == 2 ) + { + if( i < initSpn.CreaturesName.Count - 1 ) + { + if( spns2.Length + initSpn.CreaturesName[i].ToString().Length < 50 ) + spns2 += (string)initSpn.CreaturesName[i] + ", "; + else + { + strNum = 3; + spns3 += (string)initSpn.CreaturesName[i] + ", "; + } + } + else + { + if( spns2.Length + initSpn.CreaturesName[i].ToString().Length < 50 ) + spns2 += (string)initSpn.CreaturesName[i]; + else + { + strNum = 4; + spns3 += (string)initSpn.CreaturesName[i]; + } + } + } + else if( strNum == 3 ) + { + if( i < initSpn.CreaturesName.Count - 1 ) + spns3 += (string)initSpn.CreaturesName[i] + ", "; + else + spns3 += (string)initSpn.CreaturesName[i]; + } + } + + string spnsNEWa = ""; + string spns1a = ""; + string spns2a = ""; + string spns3a = ""; + + for( int i = 0; i < initSpn.SubSpawnerA.Count; i++ ) + { + if( strNum == 0 ) + { + if( i < initSpn.SubSpawnerA.Count - 1 ) + { + if( spns.Length + initSpn.SubSpawnerA[i].ToString().Length < 50 ) + spnsNEWa += (string)initSpn.SubSpawnerA[i] + ", "; + else + { + strNum = 1; + spns1a += (string)initSpn.SubSpawnerA[i] + ", "; + } + } + else + spnsNEWa += (string)initSpn.SubSpawnerA[i]; + } + else if( strNum == 1 ) + { + if( i < initSpn.SubSpawnerA.Count - 1 ) + { + if( spns1a.Length + initSpn.SubSpawnerA[i].ToString().Length < 50 ) + spns1a += (string)initSpn.SubSpawnerA[i] + ", "; + else + { + strNum = 2; + spns2a += (string)initSpn.SubSpawnerA[i] + ", "; + } + } + else + { + if( spns1a.Length + initSpn.SubSpawnerA[i].ToString().Length < 50 ) + spns1a += (string)initSpn.SubSpawnerA[i]; + else + { + strNum = 3; + spns2a += (string)initSpn.SubSpawnerA[i]; + } + } + } + else if( strNum == 2 ) + { + if( i < initSpn.SubSpawnerA.Count - 1 ) + { + if( spns2a.Length + initSpn.SubSpawnerA[i].ToString().Length < 50 ) + spns2a += (string)initSpn.SubSpawnerA[i] + ", "; + else + { + strNum = 3; + spns3a += (string)initSpn.SubSpawnerA[i] + ", "; + } + } + else + { + if( spns2a.Length + initSpn.SubSpawnerA[i].ToString().Length < 50 ) + spns2a += (string)initSpn.SubSpawnerA[i]; + else + { + strNum = 4; + spns3a += (string)initSpn.SubSpawnerA[i]; + } + } + } + else if( strNum == 3 ) + { + if( i < initSpn.SubSpawnerA.Count - 1 ) + spns3a += (string)initSpn.SubSpawnerA[i] + ", "; + else + spns3a += (string)initSpn.SubSpawnerA[i]; + } + } + + string spnsNEWb = ""; + string spns1b = ""; + string spns2b = ""; + string spns3b = ""; + + for( int i = 0; i < initSpn.SubSpawnerB.Count; i++ ) + { + if( strNum == 0 ) + { + if( i < initSpn.SubSpawnerB.Count - 1 ) + { + if( spns.Length + initSpn.SubSpawnerB[i].ToString().Length < 50 ) + spnsNEWb += (string)initSpn.SubSpawnerB[i] + ", "; + else + { + strNum = 1; + spns1b += (string)initSpn.SubSpawnerB[i] + ", "; + } + } + else + spnsNEWb += (string)initSpn.SubSpawnerB[i]; + } + else if( strNum == 1 ) + { + if( i < initSpn.SubSpawnerB.Count - 1 ) + { + if( spns1b.Length + initSpn.SubSpawnerB[i].ToString().Length < 50 ) + spns1b += (string)initSpn.SubSpawnerB[i] + ", "; + else + { + strNum = 2; + spns2b += (string)initSpn.SubSpawnerB[i] + ", "; + } + } + else + { + if( spns1b.Length + initSpn.SubSpawnerB[i].ToString().Length < 50 ) + spns1b += (string)initSpn.SubSpawnerB[i]; + else + { + strNum = 3; + spns2b += (string)initSpn.SubSpawnerB[i]; + } + } + } + else if( strNum == 2 ) + { + if( i < initSpn.SubSpawnerB.Count - 1 ) + { + if( spns2b.Length + initSpn.SubSpawnerB[i].ToString().Length < 50 ) + spns2b += (string)initSpn.SubSpawnerB[i] + ", "; + else + { + strNum = 3; + spns3b += (string)initSpn.SubSpawnerB[i] + ", "; + } + } + else + { + if( spns2b.Length + initSpn.SubSpawnerB[i].ToString().Length < 50 ) + spns2b += (string)initSpn.SubSpawnerB[i]; + else + { + strNum = 4; + spns3b += (string)initSpn.SubSpawnerB[i]; + } + } + } + else if( strNum == 3 ) + { + if( i < initSpn.SubSpawnerB.Count - 1 ) + spns3b += (string)initSpn.SubSpawnerB[i] + ", "; + else + spns3b += (string)initSpn.SubSpawnerB[i]; + } + } + + string spnsNEWc = ""; + string spns1c = ""; + string spns2c = ""; + string spns3c = ""; + + for( int i = 0; i < initSpn.SubSpawnerC.Count; i++ ) + { + if( strNum == 0 ) + { + if( i < initSpn.SubSpawnerC.Count - 1 ) + { + if( spns.Length + initSpn.SubSpawnerC[i].ToString().Length < 50 ) + spnsNEWc += (string)initSpn.SubSpawnerC[i] + ", "; + else + { + strNum = 1; + spns1c += (string)initSpn.SubSpawnerC[i] + ", "; + } + } + else + spnsNEWc += (string)initSpn.SubSpawnerC[i]; + } + else if( strNum == 1 ) + { + if( i < initSpn.SubSpawnerC.Count - 1 ) + { + if( spns1c.Length + initSpn.SubSpawnerC[i].ToString().Length < 50 ) + spns1c += (string)initSpn.SubSpawnerC[i] + ", "; + else + { + strNum = 2; + spns2c += (string)initSpn.SubSpawnerC[i] + ", "; + } + } + else + { + if( spns1c.Length + initSpn.SubSpawnerC[i].ToString().Length < 50 ) + spns1c += (string)initSpn.SubSpawnerC[i]; + else + { + strNum = 3; + spns2c += (string)initSpn.SubSpawnerC[i]; + } + } + } + else if( strNum == 2 ) + { + if( i < initSpn.SubSpawnerC.Count - 1 ) + { + if( spns2c.Length + initSpn.SubSpawnerC[i].ToString().Length < 50 ) + spns2c += (string)initSpn.SubSpawnerC[i] + ", "; + else + { + strNum = 3; + spns3c += (string)initSpn.SubSpawnerC[i] + ", "; + } + } + else + { + if( spns2c.Length + initSpn.SubSpawnerC[i].ToString().Length < 50 ) + spns2c += (string)initSpn.SubSpawnerC[i]; + else + { + strNum = 4; + spns3c += (string)initSpn.SubSpawnerC[i]; + } + } + } + else if( strNum == 3 ) + { + if( i < initSpn.SubSpawnerC.Count - 1 ) + spns3c += (string)initSpn.SubSpawnerC[i] + ", "; + else + spns3c += (string)initSpn.SubSpawnerC[i]; + } + } + + string spnsNEWd = ""; + string spns1d = ""; + string spns2d = ""; + string spns3d = ""; + + for( int i = 0; i < initSpn.SubSpawnerD.Count; i++ ) + { + if( strNum == 0 ) + { + if( i < initSpn.SubSpawnerD.Count - 1 ) + { + if( spns.Length + initSpn.SubSpawnerD[i].ToString().Length < 50 ) + spnsNEWd += (string)initSpn.SubSpawnerD[i] + ", "; + else + { + strNum = 1; + spns1d += (string)initSpn.SubSpawnerD[i] + ", "; + } + } + else + spnsNEWd += (string)initSpn.SubSpawnerD[i]; + } + else if( strNum == 1 ) + { + if( i < initSpn.SubSpawnerD.Count - 1 ) + { + if( spns1d.Length + initSpn.SubSpawnerD[i].ToString().Length < 50 ) + spns1d += (string)initSpn.SubSpawnerD[i] + ", "; + else + { + strNum = 2; + spns2d += (string)initSpn.SubSpawnerD[i] + ", "; + } + } + else + { + if( spns1d.Length + initSpn.SubSpawnerD[i].ToString().Length < 50 ) + spns1d += (string)initSpn.SubSpawnerD[i]; + else + { + strNum = 3; + spns2d += (string)initSpn.SubSpawnerD[i]; + } + } + } + else if( strNum == 2 ) + { + if( i < initSpn.SubSpawnerD.Count - 1 ) + { + if( spns2d.Length + initSpn.SubSpawnerD[i].ToString().Length < 50 ) + spns2d += (string)initSpn.SubSpawnerD[i] + ", "; + else + { + strNum = 3; + spns3d += (string)initSpn.SubSpawnerD[i] + ", "; + } + } + else + { + if( spns2d.Length + initSpn.SubSpawnerD[i].ToString().Length < 50 ) + spns2d += (string)initSpn.SubSpawnerD[i]; + else + { + strNum = 4; + spns3d += (string)initSpn.SubSpawnerD[i]; + } + } + } + else if( strNum == 3 ) + { + if( i < initSpn.SubSpawnerD.Count - 1 ) + spns3d += (string)initSpn.SubSpawnerD[i] + ", "; + else + spns3d += (string)initSpn.SubSpawnerD[i]; + } + } + + string spnsNEWe = ""; + string spns1e = ""; + string spns2e = ""; + string spns3e = ""; + + for( int i = 0; i < initSpn.SubSpawnerE.Count; i++ ) + { + if( strNum == 0 ) + { + if( i < initSpn.SubSpawnerE.Count - 1 ) + { + if( spns.Length + initSpn.SubSpawnerE[i].ToString().Length < 50 ) + spnsNEWe += (string)initSpn.SubSpawnerE[i] + ", "; + else + { + strNum = 1; + spns1e += (string)initSpn.SubSpawnerE[i] + ", "; + } + } + else + spnsNEWe += (string)initSpn.SubSpawnerE[i]; + } + else if( strNum == 1 ) + { + if( i < initSpn.SubSpawnerE.Count - 1 ) + { + if( spns1e.Length + initSpn.SubSpawnerE[i].ToString().Length < 50 ) + spns1e += (string)initSpn.SubSpawnerE[i] + ", "; + else + { + strNum = 2; + spns2e += (string)initSpn.SubSpawnerE[i] + ", "; + } + } + else + { + if( spns1e.Length + initSpn.SubSpawnerE[i].ToString().Length < 50 ) + spns1e += (string)initSpn.SubSpawnerE[i]; + else + { + strNum = 3; + spns2e += (string)initSpn.SubSpawnerE[i]; + } + } + } + else if( strNum == 2 ) + { + if( i < initSpn.SubSpawnerE.Count - 1 ) + { + if( spns2e.Length + initSpn.SubSpawnerE[i].ToString().Length < 50 ) + spns2e += (string)initSpn.SubSpawnerE[i] + ", "; + else + { + strNum = 3; + spns3e += (string)initSpn.SubSpawnerE[i] + ", "; + } + } + else + { + if( spns2e.Length + initSpn.SubSpawnerE[i].ToString().Length < 50 ) + spns2e += (string)initSpn.SubSpawnerE[i]; + else + { + strNum = 4; + spns3e += (string)initSpn.SubSpawnerE[i]; + } + } + } + else if( strNum == 3 ) + { + if( i < initSpn.SubSpawnerE.Count - 1 ) + spns3e += (string)initSpn.SubSpawnerE[i] + ", "; + else + spns3e += (string)initSpn.SubSpawnerE[i]; + } + } + + AddLabel( 275, 85, 52, spns ); + AddLabel( 280, 110, 52, "[1]" ); + AddLabel( 280, 180, 52, "[2]" ); + AddLabel( 280, 250, 52, "[3]" ); + AddLabel( 425, 110, 52, "[4]" ); + AddLabel( 425, 180, 52, "[5]" ); + AddLabel( 425, 250, 52, "[6]" ); + AddHtml( 300, 110, 115, 65, spnsNEW, true, true ); + AddHtml( 300, 180, 115, 65, spnsNEWa, true, true ); + AddHtml( 300, 250, 115, 65, spnsNEWb, true, true ); + AddHtml( 445, 110, 115, 65, spnsNEWc, true, true ); + AddHtml( 445, 180, 115, 65, spnsNEWd, true, true ); + AddHtml( 445, 250, 115, 65, spnsNEWe, true, true ); + if( spns1 != "" ) + AddLabel( 275, 105, 200, spns1 ); + + if( spns2 != "" ) + AddLabel( 275, 125, 200, spns2 ); + + if( spns3 != "" ) + AddLabel( 275, 145, 200, spns3 ); + + AddLabel( 320, 320, 52, "Go to Spawner" ); + AddButton( 525, 320, 0x15E1, 0x15E5, 10005, GumpButtonType.Reply, 1 ); + AddLabel( 320, 345, 52, "Delete Selected Spawner" ); + AddButton( 525, 345, 0x15E1, 0x15E5, 10006, GumpButtonType.Reply, 0 ); + AddLabel( 320, 370, 52, "Edit Spawns" ); + AddButton( 525, 370, 0x15E1, 0x15E5, 10007, GumpButtonType.Reply, 0 ); + } + + public List CreateArray( RelayInfo info, Mobile from ) + { + List creaturesName = new List(); + + for ( int i = 0; i < 13; i++ ) + { + TextRelay te = info.GetTextEntry( i ); + + if ( te != null ) + { + string str = te.Text; + + if ( str.Length > 0 ) + { + str = str.Trim(); + + Type type = SpawnerType.GetType( str ); + + if ( type != null ) + creaturesName.Add( str ); + else + AddLabel( 70, 230, 39, "Invalid Search String" ); + } + } + } + + return creaturesName; + } + + public override void OnResponse( NetState state, RelayInfo info ) + { + Mobile from = state.Mobile; + int buttonNum = 0; + ArrayList currentList = new ArrayList( tempList ); + int page = m_page; + + if( info.ButtonID > 0 && info.ButtonID < 10000 ) + buttonNum = 1; + else + buttonNum = info.ButtonID; + + switch( buttonNum ) + { + case 0: + { + //Close + break; + } + case 1: + { + selSpawner = currentList[ info.ButtonID - 1 ] as Item; + SpawnEditor_OnCommand( from, page, currentList, 1, selSpawner ); + break; + } + case 10000: + { + if( m_page * 10 < currentList.Count ) + { + page = m_page += 1; + SpawnEditor_OnCommand( from, page, currentList ); + } + break; + } + case 10001: + { + if( m_page != 0 ) + { + page = m_page -= 1; + SpawnEditor_OnCommand( from, page, currentList ); + } + break; + } + case 10002: + { + //Close + break; + } + case 10003: // Filter to current region only + { + FilterByRegion( from, tempList, from.Region, from.Map, page ); + break; + } + case 10004: // Filter by Distance + { + TextRelay oDis = info.GetTextEntry( 0 ); + string sDis = ( oDis == null ? "" : oDis.Text.Trim() ); + if( sDis != "" ) + { + try + { + int distance = Convert.ToInt32( sDis ); + FilterByDistance( tempList, from, distance, page ); } + catch + { + from.SendMessage( "Distance must be a number" ); + SpawnEditor_OnCommand( from, page, currentList ); + } + } + else + { + from.SendMessage( "You must specify a distance" ); + SpawnEditor_OnCommand( from, page, currentList ); + } + break; + } + case 10005: // Go to Spawner + { + from.Location = new Point3D( selSpawner.X, selSpawner.Y, selSpawner.Z ); + SpawnEditor_OnCommand( from, page, currentList, 1, selSpawner ); + break; + } + case 10006: // Delete Selected Spawner + { + selSpawner.Delete(); + SpawnEditor_OnCommand( from ); + break; + } + case 10007: // Edit Spawns (Premium Sapwner Gump) + { + from.SendGump( new PremiumSpawnerGump( selSpawner as PremiumSpawner ) ); + SpawnEditor_OnCommand( from, page, currentList, 1, selSpawner ); + break; + } + case 10008: // Refresh button + { + SpawnEditor_OnCommand( from ); + break; + } + case 10009: // Search Spawners by Creature + { + TextRelay oSearch = info.GetTextEntry( 1 ); + string sSearch = ( oSearch == null ? null : oSearch.Text.Trim() ); + SearchByName( tempList, from, sSearch, page ); + break; + } + case 10010: // Search Spawners by SpawnID + { + TextRelay oID = info.GetTextEntry( 2 ); + string sID = ( oID == null ? "" : oID.Text.Trim() ); + if( sID != "" ) + { + try + { + int SearchID = Convert.ToInt32( sID ); + SearchByID( tempList, from, SearchID, page ); } + catch + { + from.SendMessage( "SpawnID must be a number" ); + SpawnEditor_OnCommand( from, page, currentList ); + } + } + else + { + from.SendMessage( "You must specify a SpawnID" ); + SpawnEditor_OnCommand( from, page, currentList ); + } + break; + } + } + } + + + public static void FilterByRegion( Mobile from, ArrayList facetList, Region regr, Map regmap, int page ) + { + ArrayList filregList = new ArrayList(); + + foreach( Item regItem in facetList ) + { + Point2D p2 = new Point2D( regItem.X, regItem.Y ); + Point3D p = new Point3D( p2, regItem.Z ); + + if( Region.Find( p, regmap ) == regr ) + filregList.Add( regItem ); + } + + from.SendGump( new SpawnEditorGump( from, 0, filregList, 0, null ) ); + } + + public static void FilterByDistance( ArrayList currentList, Mobile m, int dis, int page ) + { + ArrayList fildisList = new ArrayList(); + + for( int z = 0; z < currentList.Count; z ++ ) + { + Item disItem = currentList[z] as Item; + + if( disItem.X >= m.X - dis && disItem.X <= m.X + dis && disItem.Y >= m.Y - dis && disItem.Y <= m.Y + dis ) + fildisList.Add( disItem ); + } + + m.SendGump( new SpawnEditorGump( m, 0, fildisList, 0, null ) ); + } + + public static void SearchByName( ArrayList currentList, Mobile from, string search, int page ) + { + ArrayList searchList = new ArrayList(); + + foreach( PremiumSpawner spn in currentList ) + { + foreach( string str in spn.CreaturesName ) + { + if( str.ToLower().IndexOf( search ) >= 0 ) + searchList.Add( spn ); + } + + foreach( string str in spn.SubSpawnerA ) + { + if( str.ToLower().IndexOf( search ) >= 0 ) + searchList.Add( spn ); + } + + foreach( string str in spn.SubSpawnerB ) + { + if( str.ToLower().IndexOf( search ) >= 0 ) + searchList.Add( spn ); + } + + foreach( string str in spn.SubSpawnerC ) + { + if( str.ToLower().IndexOf( search ) >= 0 ) + searchList.Add( spn ); + } + + foreach( string str in spn.SubSpawnerD ) + { + if( str.ToLower().IndexOf( search ) >= 0 ) + searchList.Add( spn ); + } + + foreach( string str in spn.SubSpawnerE ) + { + if( str.ToLower().IndexOf( search ) >= 0 ) + searchList.Add( spn ); + } + } + + from.SendGump( new SpawnEditorGump( from, 0, searchList, 0, null ) ); + } + + public static void SearchByID( ArrayList currentList, Mobile from, int SearchID, int page ) + { + ArrayList searchList = new ArrayList(); + + foreach( PremiumSpawner spn in currentList ) + { + if ( ((PremiumSpawner)spn).SpawnID == SearchID ) + { + searchList.Add( spn ); + } + } + + from.SendGump( new SpawnEditorGump( from, 0, searchList, 0, null ) ); + } + + public void AddTextField( int x, int y, int width, int height, int index ) + { + AddBackground( x - 2, y - 2, width + 4, height + 4, 0x2486 ); + AddTextEntry( x + 2, y + 2, width - 4, height - 4, 0, index, "" ); + } + } +} diff --git a/Scripts/Engines/Spawner/PremiumSpawner/SpawnGen.cs b/Scripts/Engines/Spawner/PremiumSpawner/SpawnGen.cs new file mode 100644 index 0000000..2ba86dc --- /dev/null +++ b/Scripts/Engines/Spawner/PremiumSpawner/SpawnGen.cs @@ -0,0 +1,642 @@ +//Engine r117 +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO; +using System.Text; +using Server; +using Server.Mobiles; +using Server.Items; +using Server.Network; +using Server.Commands; +using Server.Regions; + +namespace Server +{ + public class SpawnGenerator + { + private static int m_Count; + private static int m_MapOverride = -1; + private static int m_IDOverride = -1; + private static double m_MinTimeOverride = -1; + private static double m_MaxTimeOverride = -1; + private const bool TotalRespawn = true; + private const int Team = 0; + + public static void Initialize() + { + CommandSystem.Register( "SpawnGen", AccessLevel.Administrator, new CommandEventHandler( SpawnGen_OnCommand ) ); + } + + [Usage( "SpawnGen []|[unload ]|[remove |]|[save |][savebyhand][cleanfacet]" )] + [Description( "Complex command, it generate and remove spawners." )] + private static void SpawnGen_OnCommand( CommandEventArgs e ) + { + //wrong use + if ( e.ArgString == null || e.ArgString == "" ) + { + e.Mobile.SendMessage( "Usage: SpawnGen []|[remove ||]|[save ||]" ); + } + //[spawngen remove and [spawngen remove region + else if ( e.Arguments[0].ToLower() == "remove" && e.Arguments.Length == 2 ) + { + Remove( e.Mobile, e.Arguments[1].ToLower() ); + } + //[spawngen remove x1 y1 x2 y2 + else if ( e.Arguments[0].ToLower() == "remove" && e.Arguments.Length == 5 ) + { + int x1 = Utility.ToInt32( e.Arguments[1] ); + int y1 = Utility.ToInt32( e.Arguments[2] ); + int x2 = Utility.ToInt32( e.Arguments[3] ); + int y2 = Utility.ToInt32( e.Arguments[4] ); + RemoveByCoord( e.Mobile, x1, y1, x2, y2 ); + } + //[spawngen remove + else if ( e.ArgString.ToLower() == "remove" ) + { + Remove( e.Mobile, "" ); + } + //[spawngen save and [spawngen save region + else if ( e.Arguments[0].ToLower() == "save" && e.Arguments.Length == 2 ) + { + Save( e.Mobile, e.Arguments[1].ToLower() ); + } + //[spawngen unload SpawnID + else if ( e.Arguments[0].ToLower() == "unload" && e.Arguments.Length == 2 ) + { + int ID = Utility.ToInt32( e.Arguments[1] ); + Unload( ID ); + } + //[spawngen savebyhand + else if ( e.Arguments[0].ToLower() == "savebyhand" ) + { + SaveByHand(); + } + //[spawngen cleanfacet + else if ( e.Arguments[0].ToLower() == "cleanfacet" ) + { + CleanFacet( e.Mobile ); + } + ////[spawngen save x1 y1 x2 y2 + else if ( e.Arguments[0].ToLower() == "save" && e.Arguments.Length == 5 ) + { + int x1 = Utility.ToInt32( e.Arguments[1] ); + int y1 = Utility.ToInt32( e.Arguments[2] ); + int x2 = Utility.ToInt32( e.Arguments[3] ); + int y2 = Utility.ToInt32( e.Arguments[4] ); + SaveByCoord( e.Mobile, x1, y1, x2, y2 ); + } + //[spawngen save + else if ( e.ArgString.ToLower() == "save" ) + { + Save( e.Mobile, "" ); + } + else + { + Parse( e.Mobile, e.ArgString ); + } + } + + public static void Talk( string alfa ) + { + World.Broadcast( 0x35, true, "Spawns are being {0}, please wait.", alfa ); + } + + public static string GetRegion(Item item) + { + Region re = Region.Find(item.Location, item.Map); + string regname = re.ToString().ToLower(); + return regname; + } + + //[spawngen remove and [spawngen remove region + private static void Remove( Mobile from, string region ) + { + DateTime aTime = DateTime.Now; + int count = 0; + List itemtodo = new List(); + + string prefix = Server.Commands.CommandSystem.Prefix; + + if( region == null || region == "" ) + { + CommandSystem.Handle( from, String.Format( "{0}Global remove where premiumspawner", prefix ) ); + } + else + { + foreach( Item itemdel in World.Items.Values ) + { + if( itemdel is PremiumSpawner && itemdel.Map == from.Map ) + { + if( GetRegion(itemdel) == region ) + { + itemtodo.Add(itemdel); + count += 1; + } + } + } + + GenericRemove( itemtodo, count, aTime); + } + } + + //[spawngen unload SpawnID + private static void Unload( int ID ) + { + DateTime aTime = DateTime.Now; + int count = 0; + List itemtodo = new List(); + + foreach ( Item itemremove in World.Items.Values ) + { + if ( itemremove is PremiumSpawner && ((PremiumSpawner)itemremove).SpawnID == ID ) + { + itemtodo.Add( itemremove ); + count +=1; + } + } + + GenericRemove( itemtodo, count, aTime); + } + + //[spawngen remove x1 y1 x2 y2 + private static void RemoveByCoord( Mobile from, int x1, int y1, int x2, int y2 ) + { + DateTime aTime = DateTime.Now; + int count = 0; + List itemtodo = new List(); + + foreach ( Item itemremove in World.Items.Values ) + { + if ( itemremove is PremiumSpawner && ( ( itemremove.X >= x1 && itemremove.X <= x2 ) && ( itemremove.Y >= y1 && itemremove.Y <= y2 ) && itemremove.Map == from.Map ) ) + { + itemtodo.Add( itemremove ); + count +=1; + } + } + + GenericRemove( itemtodo, count, aTime); + } + + //[spawngen cleanfacet + //this is the old [SpawnRem + public static void CleanFacet( Mobile from ) + { + DateTime aTime = DateTime.Now; + int count = 0; + List itemtodo = new List(); + + foreach ( Item itemremove in World.Items.Values ) + { + if ( itemremove is PremiumSpawner && itemremove.Map == from.Map && itemremove.Parent == null ) + { + itemtodo.Add( itemremove ); + count +=1; + } + } + + GenericRemove( itemtodo, count, aTime); + } + + private static void GenericRemove( List colecao, int count, DateTime aTime ) + { + if( colecao.Count == 0 ) + { + World.Broadcast( 0x35, true, "There are no PremiumSpawners to be removed." ); + } + else + { + Talk("removed"); + + foreach ( Item item in colecao ) + { + item.Delete(); + } + + DateTime bTime = DateTime.Now; + World.Broadcast( 0x35, true, "{0} PremiumSpawners have been removed in {1:F1} seconds.", count, (bTime - aTime).TotalSeconds ); + } + } + + //[spawngen save and [spawngen save region + private static void Save( Mobile from, string region ) + { + DateTime aTime = DateTime.Now; + int count = 0; + List itemtodo = new List(); + string mapanome = region; + + if( region == "" ) + mapanome = "Spawns"; + + foreach ( Item itemsave in World.Items.Values ) + { + if ( itemsave is PremiumSpawner && ( region == null || region == "" ) ) + { + itemtodo.Add( itemsave ); + count +=1; + } + + else if ( itemsave is PremiumSpawner && itemsave.Map == from.Map ) + { + if ( GetRegion(itemsave) == region ) + { + itemtodo.Add( itemsave ); + count += 1; + } + } + } + + GenericSave( itemtodo, mapanome, count, aTime ); + } + + //[spawngen SaveByHand + private static void SaveByHand() + { + DateTime aTime = DateTime.Now; + int count = 0; + List itemtodo = new List(); + string mapanome = "SpawnsByHand"; + + foreach ( Item itemsave in World.Items.Values ) + { + if ( itemsave is PremiumSpawner && ((PremiumSpawner)itemsave).SpawnID == 99 ) + { + itemtodo.Add( itemsave ); + count +=1; + } + } + + GenericSave( itemtodo, mapanome, count, aTime ); + } + + //[spawngen save x1 y1 x2 y2 + private static void SaveByCoord( Mobile from, int x1, int y1, int x2, int y2 ) + { + DateTime aTime = DateTime.Now; + int count = 0; + List itemtodo = new List(); + string mapanome = "SpawnsByCoords"; + + foreach ( Item itemsave in World.Items.Values ) + { + if ( itemsave is PremiumSpawner && ( ( itemsave.X >= x1 && itemsave.X <= x2 ) && ( itemsave.Y >= y1 && itemsave.Y <= y2 ) && itemsave.Map == from.Map ) ) + { + itemtodo.Add( itemsave ); + count +=1; + } + } + + GenericSave( itemtodo, mapanome, count, aTime ); + } + + private static void GenericSave( List colecao, string mapa, int count, DateTime startTime ) + { + List itemssave = new List( colecao ); + string mapanome = mapa; + + if( itemssave.Count == 0 ) + { + World.Broadcast( 0x35, true, "There are no PremiumSpawners to be saved." ); + } + else + { + Talk("saved"); + + if ( !Directory.Exists( "Data/Spawns" ) ) + Directory.CreateDirectory( "Data/Spawns" ); + + string escreva = "Data/Spawns/" + mapanome + ".map"; + + using ( StreamWriter op = new StreamWriter( escreva ) ) + { + foreach ( PremiumSpawner itemsave2 in itemssave ) + { + int mapnumber = 0; + switch ( itemsave2.Map.ToString() ) + { + case "Vaelen": + mapnumber = 1; + break; + case "Trammel": + mapnumber = 2; + break; + case "Ilshenar": + mapnumber = 3; + break; + case "Malas": + mapnumber = 4; + break; + case "Tokuno": + mapnumber = 5; + break; + case "TerMur": + mapnumber = 6; + break; + default: + mapnumber = 7; + Console.WriteLine( "Monster Parser: Warning, unknown map {0}", itemsave2.Map ); + break; + } + + string timer1a = itemsave2.MinDelay.ToString(); + string[] timer1b = timer1a.Split( ':' ); //Broke the string hh:mm:ss in an array (hh, mm, ss) + int timer1c = ( Utility.ToInt32( timer1b[0] ) * 60 ) + Utility.ToInt32( timer1b[1] ); //multiply hh * 60 to find mm, then add mm + string timer1d = timer1c.ToString(); + if ( Utility.ToInt32( timer1b[0] ) == 0 && Utility.ToInt32( timer1b[1] ) == 0 ) //If hh and mm are 0, use seconds, else drop ss + timer1d = Utility.ToInt32( timer1b[2] ) + "s"; + + string timer2a = itemsave2.MaxDelay.ToString(); + string[] timer2b = timer2a.Split( ':' ); + int timer2c = ( Utility.ToInt32( timer2b[0] ) * 60 ) + Utility.ToInt32( timer2b[1] ); + string timer2d = timer2c.ToString(); + if ( Utility.ToInt32( timer2b[0] ) == 0 && Utility.ToInt32( timer2b[1] ) == 0 ) + timer2d = Utility.ToInt32( timer2b[2] ) + "s"; + + string towrite = ""; + string towriteA = ""; + string towriteB = ""; + string towriteC = ""; + string towriteD = ""; + string towriteE = ""; + + if ( itemsave2.CreaturesName.Count > 0 ) + towrite = itemsave2.CreaturesName[0].ToString(); + + if ( itemsave2.SubSpawnerA.Count > 0 ) + towriteA = itemsave2.SubSpawnerA[0].ToString(); + + if ( itemsave2.SubSpawnerB.Count > 0 ) + towriteB = itemsave2.SubSpawnerB[0].ToString(); + + if ( itemsave2.SubSpawnerC.Count > 0 ) + towriteC = itemsave2.SubSpawnerC[0].ToString(); + + if ( itemsave2.SubSpawnerD.Count > 0 ) + towriteD = itemsave2.SubSpawnerD[0].ToString(); + + if ( itemsave2.SubSpawnerE.Count > 0 ) + towriteE = itemsave2.SubSpawnerE[0].ToString(); + + for ( int i = 1; i < itemsave2.CreaturesName.Count; ++i ) + { + if ( itemsave2.CreaturesName.Count > 0 ) + towrite = towrite + ":" + itemsave2.CreaturesName[i].ToString(); + } + + for ( int i = 1; i < itemsave2.SubSpawnerA.Count; ++i ) + { + if ( itemsave2.SubSpawnerA.Count > 0 ) + towriteA = towriteA + ":" + itemsave2.SubSpawnerA[i].ToString(); + } + + for ( int i = 1; i < itemsave2.SubSpawnerB.Count; ++i ) + { + if ( itemsave2.SubSpawnerB.Count > 0 ) + towriteB = towriteB + ":" + itemsave2.SubSpawnerB[i].ToString(); + } + + for ( int i = 1; i < itemsave2.SubSpawnerC.Count; ++i ) + { + if ( itemsave2.SubSpawnerC.Count > 0 ) + towriteC = towriteC + ":" + itemsave2.SubSpawnerC[i].ToString(); + } + + for ( int i = 1; i < itemsave2.SubSpawnerD.Count; ++i ) + { + if ( itemsave2.SubSpawnerD.Count > 0 ) + towriteD = towriteD + ":" + itemsave2.SubSpawnerD[i].ToString(); + } + + for ( int i = 1; i < itemsave2.SubSpawnerE.Count; ++i ) + { + if ( itemsave2.SubSpawnerE.Count > 0 ) + towriteE = towriteE + ":" + itemsave2.SubSpawnerE[i].ToString(); + } + + op.WriteLine( "*|{0}|{1}|{2}|{3}|{4}|{5}|{6}|{7}|{8}|{9}|{10}|{11}|{12}|{13}|{14}|{15}|{16}|{17}|{18}|{19}|{20}", towrite, towriteA, towriteB, towriteC, towriteD, towriteE, itemsave2.X, itemsave2.Y, itemsave2.Z, mapnumber, timer1d, timer2d, itemsave2.WalkingRange, itemsave2.HomeRange, itemsave2.SpawnID, itemsave2.Count, itemsave2.CountA, itemsave2.CountB, itemsave2.CountC, itemsave2.CountD, itemsave2.CountE ); + } + } + + DateTime endTime = DateTime.Now; + World.Broadcast( 0x35, true, "{0} spawns have been saved. The entire process took {1:F1} seconds.", count, (endTime - startTime).TotalSeconds ); + } + } + + public static void Parse( Mobile from, string filename ) + { + string monster_path1 = Path.Combine( Core.BaseDirectory, "Data/Spawns" ); + string monster_path = Path.Combine( monster_path1, filename ); + m_Count = 0; + + if ( File.Exists( monster_path ) ) + { + from.SendMessage( "Spawning {0}...", filename ); + m_MapOverride = -1; + m_IDOverride = -1; + m_MinTimeOverride = -1; + m_MaxTimeOverride = -1; + + using ( StreamReader ip = new StreamReader( monster_path ) ) + { + string line; + + while ( (line = ip.ReadLine()) != null ) + { + string[] split = line.Split( '|' ); + string[] splitA = line.Split( ' ' ); + + if ( splitA.Length == 2 ) + { + if ( splitA[0].ToLower() == "overridemap" ) + m_MapOverride = Utility.ToInt32( splitA[1] ); + if ( splitA[0].ToLower() == "overrideid" ) + m_IDOverride = Utility.ToInt32( splitA[1] ); + if ( splitA[0].ToLower() == "overridemintime" ) + m_MinTimeOverride = Utility.ToDouble( splitA[1] ); + if ( splitA[0].ToLower() == "overridemaxtime" ) + m_MaxTimeOverride = Utility.ToDouble( splitA[1] ); + } + + if ( split.Length < 19 ) + continue; + + switch( split[0].ToLower() ) + { + //Comment Line + case "##": + break; + //Place By class + case "*": + PlaceNPC( split[2].Split(':'), split[3].Split(':'), split[4].Split(':'), split[5].Split(':'), split[6].Split(':'), split[7], split[8], split[9], split[10], split[11], split[12], split[14], split[13], split[15], split[16], split[17], split[18], split[19], split[20], split[21], split[1].Split(':') ); + break; + //Place By Type + case "r": + PlaceNPC( split[2].Split(':'), split[3].Split(':'), split[4].Split(':'), split[5].Split(':'), split[6].Split(':'), split[7], split[8], split[9], split[10], split[11], split[12], split[14], split[13], split[15], split[16], split[17], split[18], split[19], split[20], split[1], "bloodmoss", "sulfurousash", "spiderssilk", "mandrakeroot", "gravedust", "nightshade", "ginseng", "garlic", "batwing", "pigiron", "noxcrystal", "daemonblood", "blackpearl"); + break; + } + } + } + + m_MapOverride = -1; + m_IDOverride = -1; + m_MinTimeOverride = -1; + m_MaxTimeOverride = -1; + + from.SendMessage( "Done, added {0} spawners",m_Count ); + } + else + { + from.SendMessage( "{0} not found!", monster_path ); + } + } + + public static void PlaceNPC( string[] fakespawnsA, string[] fakespawnsB, string[] fakespawnsC, string[] fakespawnsD, string[] fakespawnsE, string sx, string sy, string sz, string sm, string smintime, string smaxtime, string swalkingrange, string shomerange, string sspawnid, string snpccount, string sfakecountA, string sfakecountB, string sfakecountC, string sfakecountD, string sfakecountE, params string[] types ) + { + if ( types.Length == 0 ) + return; + + int x = Utility.ToInt32( sx ); + int y = Utility.ToInt32( sy ); + int z = Utility.ToInt32( sz ); + int map = Utility.ToInt32( sm ); + + //MinTime + string samintime = smintime; + + if ( smintime.Contains("s") || smintime.Contains("m") || smintime.Contains("h") ) + samintime = smintime.Remove(smintime.Length - 1); + + double dmintime = Utility.ToDouble( samintime ); + + if ( m_MinTimeOverride != -1 ) + dmintime = m_MinTimeOverride; + + TimeSpan mintime = TimeSpan.FromMinutes( dmintime ); + + if ( smintime.Contains("s") ) + mintime = TimeSpan.FromSeconds( dmintime ); + else if ( smintime.Contains("m") ) + mintime = TimeSpan.FromMinutes( dmintime ); + else if ( smintime.Contains("h") ) + mintime = TimeSpan.FromHours( dmintime ); + + //MaxTime + + string samaxtime = smaxtime; + + if ( smaxtime.Contains("s") || smaxtime.Contains("m") || smaxtime.Contains("h") ) + samaxtime = smaxtime.Remove(smaxtime.Length - 1); + + double dmaxtime = Utility.ToDouble( samaxtime ); + + if ( m_MaxTimeOverride != -1 ) + { + if ( m_MaxTimeOverride < dmintime ) + dmaxtime = dmintime; + else + dmaxtime = m_MaxTimeOverride; + } + + TimeSpan maxtime = TimeSpan.FromMinutes( dmaxtime ); + + if ( smaxtime.Contains("s") ) + maxtime = TimeSpan.FromSeconds( dmaxtime ); + else if ( smaxtime.Contains("m") ) + maxtime = TimeSpan.FromMinutes( dmaxtime ); + else if ( smaxtime.Contains("h") ) + maxtime = TimeSpan.FromHours( dmaxtime ); + + // + int homerange = Utility.ToInt32( shomerange ); + int walkingrange = Utility.ToInt32( swalkingrange ); + int spawnid = Utility.ToInt32( sspawnid ); + int npccount = Utility.ToInt32( snpccount ); + int fakecountA = Utility.ToInt32( sfakecountA ); + int fakecountB = Utility.ToInt32( sfakecountB ); + int fakecountC = Utility.ToInt32( sfakecountC ); + int fakecountD = Utility.ToInt32( sfakecountD ); + int fakecountE = Utility.ToInt32( sfakecountE ); + + if ( m_MapOverride != -1 ) + map = m_MapOverride; + + if ( m_IDOverride != -1 ) + spawnid = m_IDOverride; + + switch ( map ) + { + case 0://Trammel and Felucca + MakeSpawner( types, fakespawnsA, fakespawnsB, fakespawnsC, fakespawnsD, fakespawnsE, x, y, z, Map.Felucca, mintime, maxtime, walkingrange, homerange, spawnid, npccount, fakecountA, fakecountB, fakecountC, fakecountD, fakecountE ); + MakeSpawner( types, fakespawnsA, fakespawnsB, fakespawnsC, fakespawnsD, fakespawnsE, x, y, z, Map.Trammel, mintime, maxtime, walkingrange, homerange, spawnid, npccount, fakecountA, fakecountB, fakecountC, fakecountD, fakecountE ); + break; + case 1://Felucca + MakeSpawner( types, fakespawnsA, fakespawnsB, fakespawnsC, fakespawnsD, fakespawnsE, x, y, z, Map.Felucca, mintime, maxtime, walkingrange, homerange, spawnid, npccount, fakecountA, fakecountB, fakecountC, fakecountD, fakecountE ); + break; + case 2://Trammel + MakeSpawner( types, fakespawnsA, fakespawnsB, fakespawnsC, fakespawnsD, fakespawnsE, x, y, z, Map.Trammel, mintime, maxtime, walkingrange, homerange, spawnid, npccount, fakecountA, fakecountB, fakecountC, fakecountD, fakecountE ); + break; + case 3://Ilshenar + MakeSpawner( types, fakespawnsA, fakespawnsB, fakespawnsC, fakespawnsD, fakespawnsE, x, y, z, Map.Ilshenar, mintime, maxtime, walkingrange, homerange, spawnid, npccount, fakecountA, fakecountB, fakecountC, fakecountD, fakecountE ); + break; + case 4://Malas + MakeSpawner( types, fakespawnsA, fakespawnsB, fakespawnsC, fakespawnsD, fakespawnsE, x, y, z, Map.Malas, mintime, maxtime, walkingrange, homerange, spawnid, npccount, fakecountA, fakecountB, fakecountC, fakecountD, fakecountE ); + break; + case 5://Tokuno + MakeSpawner( types, fakespawnsA, fakespawnsB, fakespawnsC, fakespawnsD, fakespawnsE, x, y, z, Map.Maps[4], mintime, maxtime, walkingrange, homerange, spawnid, npccount, fakecountA, fakecountB, fakecountC, fakecountD, fakecountE ); + break; + case 6://TerMur + MakeSpawner( types, fakespawnsA, fakespawnsB, fakespawnsC, fakespawnsD, fakespawnsE, x, y, z, Map.Maps[5], mintime, maxtime, walkingrange, homerange, spawnid, npccount, fakecountA, fakecountB, fakecountC, fakecountD, fakecountE ); + break; + + default: + Console.WriteLine( "Spawn Parser: Warning, unknown map {0}", map ); + break; + } + } + + private static void MakeSpawner( string[] types, string[] fakespawnsA, string[] fakespawnsB, string[] fakespawnsC, string[] fakespawnsD, string[] fakespawnsE, int x, int y, int z, Map map, TimeSpan mintime, TimeSpan maxtime, int walkingrange, int homerange, int spawnid, int npccount, int fakecountA, int fakecountB, int fakecountC, int fakecountD, int fakecountE ) + { + if ( types.Length == 0 ) + return; + + List tipos = new List( types ); + List noneA = new List(); + List noneB = new List(); + List noneC = new List(); + List noneD = new List(); + List noneE = new List(); + + if ( fakespawnsA[0] != "" ) + noneA = new List( fakespawnsA ); + + if ( fakespawnsB[0] != "" ) + noneB = new List( fakespawnsB ); + + if ( fakespawnsC[0] != "" ) + noneC = new List( fakespawnsC ); + + if ( fakespawnsD[0] != "" ) + noneD = new List( fakespawnsD ); + + if ( fakespawnsE[0] != "" ) + noneE = new List( fakespawnsE ); + + PremiumSpawner spawner = new PremiumSpawner( npccount, fakecountA, fakecountB, fakecountC, fakecountD, fakecountE, spawnid, mintime, maxtime, Team, walkingrange, homerange, tipos, noneA, noneB, noneC, noneD, noneE ); + + spawner.MoveToWorld( new Point3D( x, y, z ), map ); + + if ( TotalRespawn ) + { + spawner.Respawn(); + + if ( ((PremiumSpawner)spawner).SpawnID == 132 ) // if is ChampionSpawn + { + spawner.BringToHome(); + } + } + + m_Count++; + } + } +} diff --git a/Scripts/Engines/Spawner/PremiumSpawner/SpawnMaps.cs b/Scripts/Engines/Spawner/PremiumSpawner/SpawnMaps.cs new file mode 100644 index 0000000..b277a9d --- /dev/null +++ b/Scripts/Engines/Spawner/PremiumSpawner/SpawnMaps.cs @@ -0,0 +1,412 @@ +// Engine r133 +#define RunUo2_0 +using System; +using System.Collections.Generic; +using Server; +using Server.Gumps; +using Server.Network; +using Server.Commands; + +namespace Server.Gumps +{ + public class SpawnCurrentGump : Gump + { + Mobile caller; + + public static void Initialize() + { +#if(RunUo2_0) + CommandSystem.Register("SpawnCurrent", AccessLevel.Administrator, new CommandEventHandler(SpawnCurrent_OnCommand)); +#else + Register("SpawnCurrent", AccessLevel.Administrator, new CommandEventHandler(SpawnCurrent_OnCommand)); +#endif + } + + [Usage("SpawnCurrent")] + [Description("Generate PremiumSpawners around the world with a gump.")] + public static void SpawnCurrent_OnCommand(CommandEventArgs e) + { + Mobile from = e.Mobile; + + if (from.HasGump(typeof(SpawnCurrentGump))) + from.CloseGump(typeof(SpawnCurrentGump)); + from.SendGump(new SpawnCurrentGump(from)); + } + + public SpawnCurrentGump(Mobile from) : this() + { + caller = from; + } + + public void AddBlackAlpha( int x, int y, int width, int height ) + { + AddImageTiled( x, y, width, height, 2624 ); + AddAlphaRegion( x, y, width, height ); + } + + public SpawnCurrentGump() : base( 30, 30 ) + { + this.Closable=true; + this.Disposable=true; + this.Dragable=true; + AddPage(1); + AddBackground(58, 22, 474, 540, 9200); + AddImage(305, 306, 1418); // Castle + AddBlackAlpha(66, 30, 458, 33); + AddLabel(213, 37, 52, @"SELECT MAPS TO SPAWN"); + AddBlackAlpha(66, 87, 239, 447); + AddLabel(69, 67, 200, @"DUNGEONS"); + AddLabel(69, 90, 52, @"Blighted Grove"); + AddLabel(69, 112, 52, @"Britain Sewer"); + AddLabel(69, 133, 52, @"Covetous"); + AddLabel(69, 154, 52, @"Deceit"); + AddLabel(69, 174, 52, @"Despise"); + AddLabel(69, 196, 52, @"Destard"); + AddLabel(69, 217, 52, @"Fire"); + AddLabel(69, 237, 52, @"Graveyards"); + AddLabel(69, 258, 52, @"Hythloth"); + AddLabel(69, 280, 52, @"Ice"); + AddLabel(69, 301, 52, @"Khaldun"); + AddLabel(69, 322, 52, @"Orc Caves"); + AddLabel(69, 343, 52, @"Painted Caves"); + AddLabel(69, 363, 52, @"Palace of Paroxysmus"); + AddLabel(69, 384, 52, @"Prism of Light"); + AddLabel(69, 405, 52, @"Sanctuary"); + AddLabel(69, 427, 52, @"Shame"); + AddLabel(69, 448, 52, @"Solen Hive"); + AddLabel(69, 469, 52, @"Terathan Keep"); + AddLabel(69, 489, 52, @"Trinsic Passage"); + AddLabel(69, 510, 52, @"Wrong"); + AddLabel(194, 66, 200, @"Felucca"); + AddCheck(210, 91, 210, 211, true, 201); + AddCheck(210, 112, 210, 211, true, 202); + AddCheck(210, 133, 210, 211, true, 203); + AddCheck(210, 154, 210, 211, true, 204); + AddCheck(210, 175, 210, 211, true, 205); + AddCheck(210, 196, 210, 211, true, 206); + AddCheck(210, 217, 210, 211, true, 207); + AddCheck(210, 238, 210, 211, true, 208); + AddCheck(210, 259, 210, 211, true, 209); + AddCheck(210, 280, 210, 211, true, 210); + AddCheck(210, 301, 210, 211, true, 228); + AddCheck(210, 322, 210, 211, true, 212); + AddCheck(210, 343, 210, 211, true, 214); + AddCheck(210, 364, 210, 211, true, 215); + AddCheck(210, 385, 210, 211, true, 216); + AddCheck(210, 406, 210, 211, true, 217); + AddCheck(210, 427, 210, 211, true, 219); + AddCheck(210, 448, 210, 211, true, 220); + AddCheck(210, 469, 210, 211, true, 221); + AddCheck(210, 490, 210, 211, true, 224); + AddCheck(210, 511, 210, 211, true, 227); + AddLabel(250, 66, 200, @"Trammel"); + AddCheck(268, 91, 210, 211, true, 101); + AddCheck(268, 112, 210, 211, true, 102); + AddCheck(268, 133, 210, 211, true, 103); + AddCheck(268, 154, 210, 211, true, 104); + AddCheck(268, 175, 210, 211, true, 105); + AddCheck(268, 196, 210, 211, true, 106); + AddCheck(268, 217, 210, 211, true, 107); + AddCheck(268, 238, 210, 211, true, 108); + AddCheck(268, 259, 210, 211, true, 109); + AddCheck(268, 280, 210, 211, true, 110); + //There is no Khaldun in Trammel (ID 128 reserved) + AddCheck(268, 322, 210, 211, true, 112); + AddCheck(268, 343, 210, 211, true, 114); + AddCheck(268, 364, 210, 211, true, 115); + AddCheck(268, 385, 210, 211, true, 116); + AddCheck(268, 406, 210, 211, true, 117); + AddCheck(268, 427, 210, 211, true, 119); + AddCheck(268, 448, 210, 211, true, 120); + AddCheck(268, 469, 210, 211, true, 121); + AddCheck(268, 490, 210, 211, true, 124); + AddCheck(268, 511, 210, 211, true, 127); + AddBlackAlpha(311, 87, 213, 70); + AddLabel(315, 67, 200, @"TOWNS"); + AddLabel(315, 91, 52, @"Animals"); + AddLabel(315, 112, 52, @"People (*)"); + AddLabel(315, 133, 52, @"Vendors"); + AddLabel(413, 66, 200, @"Felucca"); + AddCheck(429, 91, 210, 211, true, 222); + AddCheck(429, 112, 210, 211, true, 223); + AddCheck(429, 133, 210, 211, true, 225); + AddLabel(469, 66, 200, @"Trammel"); + AddCheck(487, 91, 210, 211, true, 122); + AddCheck(487, 112, 210, 211, true, 123); + AddCheck(487, 133, 210, 211, true, 125); + AddBlackAlpha(311, 183, 213, 114); + AddLabel(315, 162, 200, @"OUTDOORS"); + AddLabel(316, 187, 52, @"Animals"); + AddLabel(316, 207, 52, @"Lost Lands"); + AddLabel(316, 229, 52, @"Spawns"); + AddLabel(316, 249, 52, @"Reagents"); + AddLabel(316, 270, 52, @"Sea Life"); + AddLabel(413, 162, 200, @"Felucca"); + AddCheck(429, 187, 210, 211, true, 226); + AddCheck(429, 208, 210, 211, true, 211); + AddCheck(429, 229, 210, 211, true, 213); + AddCheck(429, 250, 210, 211, true, 229); + AddCheck(429, 271, 210, 211, true, 218); + AddLabel(469, 162, 200, @"Trammel"); + AddCheck(487, 187, 210, 211, true, 126); + AddCheck(487, 208, 210, 211, true, 111); + AddCheck(487, 229, 210, 211, true, 113); + AddCheck(487, 250, 210, 211, true, 129); + AddCheck(487, 271, 210, 211, true, 118); + AddLabel(316, 305, 200, @"(*) Escortables, Hireables,"); + AddLabel(316, 324, 200, @"Town Criers, Order and Chaos"); + AddLabel(316, 344, 200, @"guards etc."); + // END + AddLabel(361, 453, 52, @"Page: 1/2"); //Page + AddButton(423, 455, 5601, 5605, 0, GumpButtonType.Page, 2); // Change Page + + //PAGE 2 + AddPage(2); + AddBackground(58, 22, 474, 540, 9200); + AddImage(305, 306, 1418); // Castle + AddBlackAlpha(66, 30, 458, 33); + AddLabel(213, 37, 52, @"SELECT MAPS TO SPAWN"); + AddBlackAlpha(66, 87, 174, 300); + AddLabel(74, 67, 200, @"ILSHENAR"); + AddLabel(74, 90, 52, @"Ancient Lair"); + AddLabel(74, 112, 52, @"Ankh"); + AddLabel(74, 133, 52, @"Blood"); + AddLabel(74, 154, 52, @"Exodus"); + AddLabel(74, 174, 52, @"Mushroom"); + AddLabel(74, 196, 52, @"Outdoors"); + AddLabel(74, 217, 52, @"Ratman Cave"); + AddLabel(74, 237, 52, @"Rock"); + AddLabel(74, 258, 52, @"Sorcerers"); + AddLabel(74, 280, 52, @"Spectre"); + AddLabel(74, 301, 52, @"Towns"); + AddLabel(74, 322, 52, @"Twisted Weald"); + AddLabel(74, 343, 52, @"Vendors"); + AddLabel(74, 363, 52, @"Wisp"); + AddCheck(215, 91, 210, 211, true, 301); + AddCheck(215, 112, 210, 211, true, 302); + AddCheck(215, 133, 210, 211, true, 303); + AddCheck(215, 154, 210, 211, true, 304); + AddCheck(215, 175, 210, 211, true, 305); + AddCheck(215, 196, 210, 211, true, 306); + AddCheck(215, 217, 210, 211, true, 307); + AddCheck(215, 238, 210, 211, true, 308); + AddCheck(215, 259, 210, 211, true, 309); + AddCheck(215, 280, 210, 211, true, 310); + AddCheck(215, 301, 210, 211, true, 311); + AddCheck(215, 322, 210, 211, true, 314); + AddCheck(215, 343, 210, 211, true, 312); + AddCheck(215, 364, 210, 211, true, 313); + AddBlackAlpha(66, 414, 174, 133); + AddLabel(74, 393, 200, @"TOKUNO"); + AddLabel(74, 416, 52, @"Fan Dancers Dojo"); + AddLabel(74, 438, 52, @"Outdoors"); + AddLabel(74, 459, 52, @"Towns Life"); + AddLabel(74, 480, 52, @"Vendors"); + AddLabel(74, 500, 52, @"Wild Life"); + AddLabel(74, 522, 52, @"Yomutso Mines"); + AddCheck(215, 417, 210, 211, true, 501); + AddCheck(215, 438, 210, 211, true, 502); + AddCheck(215, 459, 210, 211, true, 503); + AddCheck(215, 480, 210, 211, true, 504); + AddCheck(215, 501, 210, 211, true, 505); + AddCheck(215, 522, 210, 211, true, 506); + AddBlackAlpha(246, 87, 174, 178); + AddLabel(253, 67, 200, @"MALAS"); + AddLabel(253, 90, 52, @"Bedlam"); + AddLabel(253, 112, 52, @"Citadel"); + AddLabel(253, 133, 52, @"Doom"); + AddLabel(253, 154, 52, @"Labyrinth"); + AddLabel(253, 174, 52, @"North (*)"); + AddLabel(253, 196, 52, @"Orc Forts"); + AddLabel(253, 217, 52, @"South (*)"); + AddLabel(253, 238, 52, @"Vendors"); + AddCheck(394, 91, 210, 211, true, 408); + AddCheck(394, 112, 210, 211, true, 406); + AddCheck(394, 133, 210, 211, true, 401); + AddCheck(394, 154, 210, 211, true, 407); + AddCheck(394, 175, 210, 211, true, 402); + AddCheck(394, 196, 210, 211, true, 403); + AddCheck(394, 217, 210, 211, true, 404); + AddCheck(394, 238, 210, 211, true, 405); + AddLabel(428, 91, 200, @"(*) Wild"); + AddLabel(428, 109, 200, @"Animals and"); + AddLabel(428, 129, 200, @"monsters."); + AddBlackAlpha(246, 292, 174, 117); + AddLabel(253, 272, 200, @"TER MUR"); + AddLabel(253, 295, 52, @"Abyss"); + AddLabel(253, 316, 52, @"TerMur"); + AddLabel(253, 337, 52, @"Underworld"); + AddLabel(253, 358, 52, @"Vendors"); + AddCheck(394, 296, 210, 211, true, 601); + AddCheck(394, 317, 210, 211, true, 602); + AddCheck(394, 338, 210, 211, true, 603); + AddCheck(394, 359, 210, 211, true, 604); + //END + AddLabel(381, 453, 52, @"Page: 2/2"); //Page + AddButton(361, 455, 5603, 5607, 0, GumpButtonType.Page, 1); //Change Page + AddButton(282, 452, 240, 239, 1, GumpButtonType.Reply, 0); // Apply + } + + public static void SpawnThis( Mobile from, List ListSwitches, int switche, int map, string mapfile) + { + string folder = ""; + + if( map == 1 ) + folder = "felucca"; + else if( map == 2) + folder = "trammel"; + else if( map == 3) + folder = "ilshenar"; + else if( map == 4) + folder = "malas"; + else if( map == 5) + folder = "tokuno"; + else if( map == 6) + folder = "termur"; + + string prefix = Server.Commands.CommandSystem.Prefix; + + if( ListSwitches.Contains( switche ) == true ) + CommandSystem.Handle( from, String.Format( "{0}Spawngen {1}/{2}.map", prefix, folder, mapfile ) ); + } + + public override void OnResponse(NetState sender, RelayInfo info) + { + Mobile from = sender.Mobile; + + switch(info.ButtonID) + { + case 0: //Closed or Cancel + { + break; + } + default: + { + // Make sure that the APPLY button was pressed + if( info.ButtonID == 1 ) + { + // Get the array of switches selected + List Selections = new List( info.Switches ); + + //TRAMMEL + from.Say( "SPAWNING TRAMMEL..." ); + // DUNGEONS + SpawnThis(from, Selections, 101, 2, "BlightedGrove"); + SpawnThis(from, Selections, 102, 2, "BritainSewer"); + SpawnThis(from, Selections, 103, 2, "Covetous"); + SpawnThis(from, Selections, 104, 2, "Deceit"); + SpawnThis(from, Selections, 105, 2, "Despise"); + SpawnThis(from, Selections, 106, 2, "Destard"); + SpawnThis(from, Selections, 107, 2, "Fire"); + SpawnThis(from, Selections, 108, 2, "Graveyards"); + SpawnThis(from, Selections, 109, 2, "Hythloth"); + SpawnThis(from, Selections, 110, 2, "Ice"); + //There is no Khaldun (118) + SpawnThis(from, Selections, 112, 2, "OrcCaves"); + SpawnThis(from, Selections, 114, 2, "PaintedCaves"); + SpawnThis(from, Selections, 115, 2, "PalaceOfParoxysmus"); + SpawnThis(from, Selections, 116, 2, "PrismOfLight"); + SpawnThis(from, Selections, 117, 2, "Sanctuary"); + SpawnThis(from, Selections, 119, 2, "Shame"); + SpawnThis(from, Selections, 120, 2, "SolenHive"); + SpawnThis(from, Selections, 121, 2, "TerathanKeep"); + SpawnThis(from, Selections, 124, 2, "TrinsicPassage"); + SpawnThis(from, Selections, 127, 2, "Wrong"); + //TOWNS + SpawnThis(from, Selections, 122, 2, "TownsLife"); + SpawnThis(from, Selections, 123, 2, "TownsPeople"); + SpawnThis(from, Selections, 125, 2, "Vendors"); + //OUTDOORS + SpawnThis(from, Selections, 126, 2, "WildLife"); + SpawnThis(from, Selections, 111, 2, "LostLands"); + SpawnThis(from, Selections, 113, 2, "Outdoors"); + SpawnThis(from, Selections, 129, 2, "Reagents"); + SpawnThis(from, Selections, 118, 2, "SeaLife"); + + //FELUCCA + from.Say( "SPAWNING FELUCCA..." ); + // DUNGEONS + SpawnThis(from, Selections, 201, 1, "BlightedGrove"); + SpawnThis(from, Selections, 202, 1, "BritainSewer"); + SpawnThis(from, Selections, 203, 1, "Covetous"); + SpawnThis(from, Selections, 204, 1, "Deceit"); + SpawnThis(from, Selections, 205, 1, "Despise"); + SpawnThis(from, Selections, 206, 1, "Destard"); + SpawnThis(from, Selections, 207, 1, "Fire"); + SpawnThis(from, Selections, 208, 1, "Graveyards"); + SpawnThis(from, Selections, 209, 1, "Hythloth"); + SpawnThis(from, Selections, 210, 1, "Ice"); + SpawnThis(from, Selections, 229, 1, "Khaldun"); + SpawnThis(from, Selections, 212, 1, "OrcCaves"); + SpawnThis(from, Selections, 214, 1, "PaintedCaves"); + SpawnThis(from, Selections, 215, 1, "PalaceOfParoxysmus"); + SpawnThis(from, Selections, 216, 1, "PrismOfLight"); + SpawnThis(from, Selections, 217, 1, "Sanctuary"); + SpawnThis(from, Selections, 219, 1, "Shame"); + SpawnThis(from, Selections, 220, 1, "SolenHive"); + SpawnThis(from, Selections, 221, 1, "TerathanKeep"); + SpawnThis(from, Selections, 224, 1, "TrinsicPassage"); + SpawnThis(from, Selections, 227, 1, "Wrong"); + //TOWNS + SpawnThis(from, Selections, 222, 1, "TownsLife"); + SpawnThis(from, Selections, 223, 1, "TownsPeople"); + SpawnThis(from, Selections, 225, 1, "Vendors"); + //OUTDOORS + SpawnThis(from, Selections, 226, 1, "WildLife"); + SpawnThis(from, Selections, 211, 1, "LostLands"); + SpawnThis(from, Selections, 213, 1, "Outdoors"); + SpawnThis(from, Selections, 229, 1, "Reagents"); + SpawnThis(from, Selections, 218, 1, "SeaLife"); + + //ILSHENAR + from.Say( "SPAWNING ILSHENAR..." ); + SpawnThis(from, Selections, 301, 3, "Ancientlair"); + SpawnThis(from, Selections, 302, 3, "Ankh"); + SpawnThis(from, Selections, 303, 3, "Blood"); + SpawnThis(from, Selections, 304, 3, "Exodus"); + SpawnThis(from, Selections, 305, 3, "Mushroom"); + SpawnThis(from, Selections, 306, 3, "Outdoors"); + SpawnThis(from, Selections, 307, 3, "Ratmancave"); + SpawnThis(from, Selections, 308, 3, "Rock"); + SpawnThis(from, Selections, 309, 3, "Sorcerers"); + SpawnThis(from, Selections, 310, 3, "Spectre"); + SpawnThis(from, Selections, 311, 3, "Towns"); + SpawnThis(from, Selections, 314, 3, "TwistedWeald"); + SpawnThis(from, Selections, 312, 3, "Vendors"); + SpawnThis(from, Selections, 313, 3, "Wisp"); + + //MALAS + from.Say( "SPAWNING MALAS..." ); + SpawnThis(from, Selections, 408, 4, "Bedlam"); + SpawnThis(from, Selections, 406, 4, "Citadel"); + SpawnThis(from, Selections, 401, 4, "Doom"); + SpawnThis(from, Selections, 407, 4, "Labyrinth"); + SpawnThis(from, Selections, 402, 4, "North"); + SpawnThis(from, Selections, 403, 4, "OrcForts"); + SpawnThis(from, Selections, 404, 4, "South"); + SpawnThis(from, Selections, 405, 4, "Vendors"); + + //TOKUNO + from.Say( "SPAWNING TOKUNO..." ); + SpawnThis(from, Selections, 501, 5, "FanDancersDojo"); + SpawnThis(from, Selections, 502, 5, "Outdoors"); + SpawnThis(from, Selections, 503, 5, "TownsLife"); + SpawnThis(from, Selections, 504, 5, "Vendors"); + SpawnThis(from, Selections, 505, 5, "WildLife"); + SpawnThis(from, Selections, 506, 5, "YomutsoMines"); + + //TER MUR + from.Say( "SPAWNING TER MUR..." ); + SpawnThis(from, Selections, 601, 6, "Abyss"); + SpawnThis(from, Selections, 602, 6, "TerMur"); + SpawnThis(from, Selections, 603, 6, "Underworld"); + SpawnThis(from, Selections, 604, 6, "Vendors"); + + from.Say( "SPAWN GENERATION COMPLETED" ); + } + break; + } + } + } + } +} \ No newline at end of file diff --git a/Scripts/Engines/Spawner/PremiumSpawner/SpawnMapsUOML.cs b/Scripts/Engines/Spawner/PremiumSpawner/SpawnMapsUOML.cs new file mode 100644 index 0000000..6f44cf7 --- /dev/null +++ b/Scripts/Engines/Spawner/PremiumSpawner/SpawnMapsUOML.cs @@ -0,0 +1,393 @@ +// Engine r93 +#define RunUo2_0 +using System; +using System.Collections.Generic; +using Server; +using Server.Gumps; +using Server.Network; +using Server.Commands; + +namespace Server.Gumps +{ + public class SpawnUOMLGump : Gump + { + Mobile caller; + + public static void Initialize() + { +#if(RunUo2_0) + CommandSystem.Register("SpawnUOML", AccessLevel.Administrator, new CommandEventHandler(SpawnUOML_OnCommand)); +#else + Register("SpawnUOML", AccessLevel.Administrator, new CommandEventHandler(SpawnUOML_OnCommand)); +#endif + } + + [Usage("SpawnUOML")] + [Description("Generate PremiumSpawners around the world with a gump.")] + public static void SpawnUOML_OnCommand(CommandEventArgs e) + { + Mobile from = e.Mobile; + + if (from.HasGump(typeof(SpawnUOMLGump))) + from.CloseGump(typeof(SpawnUOMLGump)); + from.SendGump(new SpawnUOMLGump(from)); + } + + public SpawnUOMLGump(Mobile from) : this() + { + caller = from; + } + + public void AddBlackAlpha( int x, int y, int width, int height ) + { + AddImageTiled( x, y, width, height, 2624 ); + AddAlphaRegion( x, y, width, height ); + } + + public SpawnUOMLGump() : base( 30, 30 ) + { + this.Closable=true; + this.Disposable=true; + this.Dragable=true; + AddPage(1); + AddBackground(58, 22, 474, 540, 9200); + AddImage(305, 306, 1418); // Castle + AddBlackAlpha(66, 30, 458, 33); + AddLabel(213, 37, 52, @"SELECT MAPS TO SPAWN"); + AddBlackAlpha(66, 87, 239, 447); + AddLabel(69, 67, 200, @"DUNGEONS"); + AddLabel(69, 90, 52, @"Blighted Grove"); + AddLabel(69, 112, 52, @"Britain Sewer"); + AddLabel(69, 133, 52, @"Covetous"); + AddLabel(69, 154, 52, @"Deceit"); + AddLabel(69, 174, 52, @"Despise"); + AddLabel(69, 196, 52, @"Destard"); + AddLabel(69, 217, 52, @"Fire"); + AddLabel(69, 237, 52, @"Graveyards"); + AddLabel(69, 258, 52, @"Hythloth"); + AddLabel(69, 280, 52, @"Ice"); + AddLabel(69, 301, 52, @"Khaldun"); + AddLabel(69, 322, 52, @"Orc Caves"); + AddLabel(69, 343, 52, @"Painted Caves"); + AddLabel(69, 363, 52, @"Palace of Paroxysmus"); + AddLabel(69, 384, 52, @"Prism of Light"); + AddLabel(69, 405, 52, @"Sanctuary"); + AddLabel(69, 427, 52, @"Shame"); + AddLabel(69, 448, 52, @"Solen Hive"); + AddLabel(69, 469, 52, @"Terathan Keep"); + AddLabel(69, 489, 52, @"Trinsic Passage"); + AddLabel(69, 510, 52, @"Wrong"); + AddLabel(194, 66, 200, @"Felucca"); + AddCheck(210, 91, 210, 211, true, 201); + AddCheck(210, 112, 210, 211, true, 202); + AddCheck(210, 133, 210, 211, true, 203); + AddCheck(210, 154, 210, 211, true, 204); + AddCheck(210, 175, 210, 211, true, 205); + AddCheck(210, 196, 210, 211, true, 206); + AddCheck(210, 217, 210, 211, true, 207); + AddCheck(210, 238, 210, 211, true, 208); + AddCheck(210, 259, 210, 211, true, 209); + AddCheck(210, 280, 210, 211, true, 210); + AddCheck(210, 301, 210, 211, true, 228); + AddCheck(210, 322, 210, 211, true, 212); + AddCheck(210, 343, 210, 211, true, 214); + AddCheck(210, 364, 210, 211, true, 215); + AddCheck(210, 385, 210, 211, true, 216); + AddCheck(210, 406, 210, 211, true, 217); + AddCheck(210, 427, 210, 211, true, 219); + AddCheck(210, 448, 210, 211, true, 220); + AddCheck(210, 469, 210, 211, true, 221); + AddCheck(210, 490, 210, 211, true, 224); + AddCheck(210, 511, 210, 211, true, 227); + AddLabel(250, 66, 200, @"Trammel"); + AddCheck(268, 91, 210, 211, true, 101); + AddCheck(268, 112, 210, 211, true, 102); + AddCheck(268, 133, 210, 211, true, 103); + AddCheck(268, 154, 210, 211, true, 104); + AddCheck(268, 175, 210, 211, true, 105); + AddCheck(268, 196, 210, 211, true, 106); + AddCheck(268, 217, 210, 211, true, 107); + AddCheck(268, 238, 210, 211, true, 108); + AddCheck(268, 259, 210, 211, true, 109); + AddCheck(268, 280, 210, 211, true, 110); + //There is no Khaldun in Trammel (ID 128 reserved) + AddCheck(268, 322, 210, 211, true, 112); + AddCheck(268, 343, 210, 211, true, 114); + AddCheck(268, 364, 210, 211, true, 115); + AddCheck(268, 385, 210, 211, true, 116); + AddCheck(268, 406, 210, 211, true, 117); + AddCheck(268, 427, 210, 211, true, 119); + AddCheck(268, 448, 210, 211, true, 120); + AddCheck(268, 469, 210, 211, true, 121); + AddCheck(268, 490, 210, 211, true, 124); + AddCheck(268, 511, 210, 211, true, 127); + AddBlackAlpha(311, 87, 213, 70); + AddLabel(315, 67, 200, @"TOWNS"); + AddLabel(315, 91, 52, @"Animals"); + AddLabel(315, 112, 52, @"People (*)"); + AddLabel(315, 133, 52, @"Vendors"); + AddLabel(413, 66, 200, @"Felucca"); + AddCheck(429, 91, 210, 211, true, 222); + AddCheck(429, 112, 210, 211, true, 223); + AddCheck(429, 133, 210, 211, true, 225); + AddLabel(469, 66, 200, @"Trammel"); + AddCheck(487, 91, 210, 211, true, 122); + AddCheck(487, 112, 210, 211, true, 123); + AddCheck(487, 133, 210, 211, true, 125); + AddBlackAlpha(311, 183, 213, 114); + AddLabel(315, 162, 200, @"OUTDOORS"); + AddLabel(316, 187, 52, @"Animals"); + AddLabel(316, 207, 52, @"Lost Lands"); + AddLabel(316, 229, 52, @"Spawns"); + AddLabel(316, 249, 52, @"Reagents"); + AddLabel(316, 270, 52, @"Sea Life"); + AddLabel(413, 162, 200, @"Felucca"); + AddCheck(429, 187, 210, 211, true, 226); + AddCheck(429, 208, 210, 211, true, 211); + AddCheck(429, 229, 210, 211, true, 213); + AddCheck(429, 250, 210, 211, true, 229); + AddCheck(429, 271, 210, 211, true, 218); + AddLabel(469, 162, 200, @"Trammel"); + AddCheck(487, 187, 210, 211, true, 126); + AddCheck(487, 208, 210, 211, true, 111); + AddCheck(487, 229, 210, 211, true, 113); + AddCheck(487, 250, 210, 211, true, 129); + AddCheck(487, 271, 210, 211, true, 118); + AddLabel(316, 305, 200, @"(*) Escortables, Hireables,"); + AddLabel(316, 324, 200, @"Town Criers, Order and Chaos"); + AddLabel(316, 344, 200, @"guards etc."); + // END + AddLabel(361, 453, 52, @"Page: 1/2"); //Page + AddButton(423, 455, 5601, 5605, 0, GumpButtonType.Page, 2); // Change Page + + //PAGE 2 + AddPage(2); + AddBackground(58, 22, 474, 540, 9200); + AddImage(305, 306, 1418); // Castle + AddBlackAlpha(66, 30, 458, 33); + AddLabel(213, 37, 52, @"SELECT MAPS TO SPAWN"); + AddBlackAlpha(66, 87, 174, 300); + AddLabel(74, 67, 200, @"ILSHENAR"); + AddLabel(74, 90, 52, @"Ancient Lair"); + AddLabel(74, 112, 52, @"Ankh"); + AddLabel(74, 133, 52, @"Blood"); + AddLabel(74, 154, 52, @"Exodus"); + AddLabel(74, 174, 52, @"Mushroom"); + AddLabel(74, 196, 52, @"Outdoors"); + AddLabel(74, 217, 52, @"Ratman Cave"); + AddLabel(74, 237, 52, @"Rock"); + AddLabel(74, 258, 52, @"Sorcerers"); + AddLabel(74, 280, 52, @"Spectre"); + AddLabel(74, 301, 52, @"Towns"); + AddLabel(74, 322, 52, @"Twisted Weald"); + AddLabel(74, 343, 52, @"Vendors"); + AddLabel(74, 363, 52, @"Wisp"); + AddCheck(215, 91, 210, 211, true, 301); + AddCheck(215, 112, 210, 211, true, 302); + AddCheck(215, 133, 210, 211, true, 303); + AddCheck(215, 154, 210, 211, true, 304); + AddCheck(215, 175, 210, 211, true, 305); + AddCheck(215, 196, 210, 211, true, 306); + AddCheck(215, 217, 210, 211, true, 307); + AddCheck(215, 238, 210, 211, true, 308); + AddCheck(215, 259, 210, 211, true, 309); + AddCheck(215, 280, 210, 211, true, 310); + AddCheck(215, 301, 210, 211, true, 311); + AddCheck(215, 322, 210, 211, true, 314); + AddCheck(215, 343, 210, 211, true, 312); + AddCheck(215, 364, 210, 211, true, 313); + AddBlackAlpha(66, 414, 174, 133); + AddLabel(74, 393, 200, @"TOKUNO"); + AddLabel(74, 416, 52, @"Fan Dancers Dojo"); + AddLabel(74, 438, 52, @"Outdoors"); + AddLabel(74, 459, 52, @"Towns Life"); + AddLabel(74, 480, 52, @"Vendors"); + AddLabel(74, 500, 52, @"Wild Life"); + AddLabel(74, 522, 52, @"Yomutso Mines"); + AddCheck(215, 417, 210, 211, true, 501); + AddCheck(215, 438, 210, 211, true, 502); + AddCheck(215, 459, 210, 211, true, 503); + AddCheck(215, 480, 210, 211, true, 504); + AddCheck(215, 501, 210, 211, true, 505); + AddCheck(215, 522, 210, 211, true, 506); + AddBlackAlpha(246, 87, 174, 178); + AddLabel(253, 67, 200, @"MALAS"); + AddLabel(253, 90, 52, @"Bedlam"); + AddLabel(253, 112, 52, @"Citadel"); + AddLabel(253, 133, 52, @"Doom"); + AddLabel(253, 154, 52, @"Labyrinth"); + AddLabel(253, 174, 52, @"North (*)"); + AddLabel(253, 196, 52, @"Orc Forts"); + AddLabel(253, 217, 52, @"South (*)"); + AddLabel(253, 238, 52, @"Vendors"); + AddCheck(394, 91, 210, 211, true, 408); + AddCheck(394, 112, 210, 211, true, 406); + AddCheck(394, 133, 210, 211, true, 401); + AddCheck(394, 154, 210, 211, true, 407); + AddCheck(394, 175, 210, 211, true, 402); + AddCheck(394, 196, 210, 211, true, 403); + AddCheck(394, 217, 210, 211, true, 404); + AddCheck(394, 238, 210, 211, true, 405); + AddLabel(428, 91, 200, @"(*) Wild"); + AddLabel(428, 109, 200, @"Animals and"); + AddLabel(428, 129, 200, @"monsters."); + //END + AddLabel(381, 453, 52, @"Page: 2/2"); //Page + AddButton(361, 455, 5603, 5607, 0, GumpButtonType.Page, 1); //Change Page + AddButton(282, 452, 240, 239, 1, GumpButtonType.Reply, 0); // Apply + } + + public static void SpawnThis( Mobile from, List ListSwitches, int switche, int map, string mapfile) + { + string folder = ""; + + if( map == 1 ) + folder = "felucca"; + else if( map == 2) + folder = "trammel"; + else if( map == 3) + folder = "ilshenar"; + else if( map == 4) + folder = "malas"; + else if( map == 5) + folder = "tokuno"; + + string prefix = Server.Commands.CommandSystem.Prefix; + + if( ListSwitches.Contains( switche ) == true ) + CommandSystem.Handle( from, String.Format( "{0}Spawngen uoml/{1}/{2}.map", prefix, folder, mapfile ) ); + } + + public override void OnResponse(NetState sender, RelayInfo info) + { + Mobile from = sender.Mobile; + + switch(info.ButtonID) + { + case 0: //Closed or Cancel + { + break; + } + default: + { + // Make sure that the APPLY button was pressed + if( info.ButtonID == 1 ) + { + // Get the array of switches selected + List Selections = new List( info.Switches ); + + //TRAMMEL + from.Say( "SPAWNING TRAMMEL..." ); + // DUNGEONS + SpawnThis(from, Selections, 101, 2, "BlightedGrove"); + SpawnThis(from, Selections, 102, 2, "BritainSewer"); + SpawnThis(from, Selections, 103, 2, "Covetous"); + SpawnThis(from, Selections, 104, 2, "Deceit"); + SpawnThis(from, Selections, 105, 2, "Despise"); + SpawnThis(from, Selections, 106, 2, "Destard"); + SpawnThis(from, Selections, 107, 2, "Fire"); + SpawnThis(from, Selections, 108, 2, "Graveyards"); + SpawnThis(from, Selections, 109, 2, "Hythloth"); + SpawnThis(from, Selections, 110, 2, "Ice"); + //There is no Khaldun (118) + SpawnThis(from, Selections, 112, 2, "OrcCaves"); + SpawnThis(from, Selections, 114, 2, "PaintedCaves"); + SpawnThis(from, Selections, 115, 2, "PalaceOfParoxysmus"); + SpawnThis(from, Selections, 116, 2, "PrismOfLight"); + SpawnThis(from, Selections, 117, 2, "Sanctuary"); + SpawnThis(from, Selections, 119, 2, "Shame"); + SpawnThis(from, Selections, 120, 2, "SolenHive"); + SpawnThis(from, Selections, 121, 2, "TerathanKeep"); + SpawnThis(from, Selections, 124, 2, "TrinsicPassage"); + SpawnThis(from, Selections, 127, 2, "Wrong"); + //TOWNS + SpawnThis(from, Selections, 122, 2, "TownsLife"); + SpawnThis(from, Selections, 123, 2, "TownsPeople"); + SpawnThis(from, Selections, 125, 2, "Vendors"); + //OUTDOORS + SpawnThis(from, Selections, 126, 2, "WildLife"); + SpawnThis(from, Selections, 111, 2, "LostLands"); + SpawnThis(from, Selections, 113, 2, "Outdoors"); + SpawnThis(from, Selections, 129, 2, "Reagents"); + SpawnThis(from, Selections, 118, 2, "SeaLife"); + + //FELUCCA + from.Say( "SPAWNING FELUCCA..." ); + // DUNGEONS + SpawnThis(from, Selections, 201, 1, "BlightedGrove"); + SpawnThis(from, Selections, 202, 1, "BritainSewer"); + SpawnThis(from, Selections, 203, 1, "Covetous"); + SpawnThis(from, Selections, 204, 1, "Deceit"); + SpawnThis(from, Selections, 205, 1, "Despise"); + SpawnThis(from, Selections, 206, 1, "Destard"); + SpawnThis(from, Selections, 207, 1, "Fire"); + SpawnThis(from, Selections, 208, 1, "Graveyards"); + SpawnThis(from, Selections, 209, 1, "Hythloth"); + SpawnThis(from, Selections, 210, 1, "Ice"); + SpawnThis(from, Selections, 229, 1, "Khaldun"); + SpawnThis(from, Selections, 212, 1, "OrcCaves"); + SpawnThis(from, Selections, 214, 1, "PaintedCaves"); + SpawnThis(from, Selections, 215, 1, "PalaceOfParoxysmus"); + SpawnThis(from, Selections, 216, 1, "PrismOfLight"); + SpawnThis(from, Selections, 217, 1, "Sanctuary"); + SpawnThis(from, Selections, 219, 1, "Shame"); + SpawnThis(from, Selections, 220, 1, "SolenHive"); + SpawnThis(from, Selections, 221, 1, "TerathanKeep"); + SpawnThis(from, Selections, 224, 1, "TrinsicPassage"); + SpawnThis(from, Selections, 227, 1, "Wrong"); + //TOWNS + SpawnThis(from, Selections, 222, 1, "TownsLife"); + SpawnThis(from, Selections, 223, 1, "TownsPeople"); + SpawnThis(from, Selections, 225, 1, "Vendors"); + //OUTDOORS + SpawnThis(from, Selections, 226, 1, "WildLife"); + SpawnThis(from, Selections, 211, 1, "LostLands"); + SpawnThis(from, Selections, 213, 1, "Outdoors"); + SpawnThis(from, Selections, 229, 1, "Reagents"); + SpawnThis(from, Selections, 218, 1, "SeaLife"); + + //ILSHENAR + from.Say( "SPAWNING ILSHENAR..." ); + SpawnThis(from, Selections, 301, 3, "Ancientlair"); + SpawnThis(from, Selections, 302, 3, "Ankh"); + SpawnThis(from, Selections, 303, 3, "Blood"); + SpawnThis(from, Selections, 304, 3, "Exodus"); + SpawnThis(from, Selections, 305, 3, "Mushroom"); + SpawnThis(from, Selections, 306, 3, "Outdoors"); + SpawnThis(from, Selections, 307, 3, "Ratmancave"); + SpawnThis(from, Selections, 308, 3, "Rock"); + SpawnThis(from, Selections, 309, 3, "Sorcerers"); + SpawnThis(from, Selections, 310, 3, "Spectre"); + SpawnThis(from, Selections, 311, 3, "Towns"); + SpawnThis(from, Selections, 314, 3, "TwistedWeald"); + SpawnThis(from, Selections, 312, 3, "Vendors"); + SpawnThis(from, Selections, 313, 3, "Wisp"); + + //MALAS + from.Say( "SPAWNING MALAS..." ); + SpawnThis(from, Selections, 408, 4, "Bedlam"); + SpawnThis(from, Selections, 406, 4, "Citadel"); + SpawnThis(from, Selections, 401, 4, "Doom"); + SpawnThis(from, Selections, 407, 4, "Labyrinth"); + SpawnThis(from, Selections, 402, 4, "North"); + SpawnThis(from, Selections, 403, 4, "OrcForts"); + SpawnThis(from, Selections, 404, 4, "South"); + SpawnThis(from, Selections, 405, 4, "Vendors"); + + //TOKUNO + from.Say( "SPAWNING TOKUNO..." ); + SpawnThis(from, Selections, 501, 5, "FanDancersDojo"); + SpawnThis(from, Selections, 502, 5, "Outdoors"); + SpawnThis(from, Selections, 503, 5, "TownsLife"); + SpawnThis(from, Selections, 504, 5, "Vendors"); + SpawnThis(from, Selections, 505, 5, "WildLife"); + SpawnThis(from, Selections, 506, 5, "YomutsoMines"); + + from.Say( "SPAWN GENERATION COMPLETED" ); + } + break; + } + } + } + } +} \ No newline at end of file diff --git a/Scripts/Engines/Spawner/PremiumSpawner/SpawnsOverseer.cs b/Scripts/Engines/Spawner/PremiumSpawner/SpawnsOverseer.cs new file mode 100644 index 0000000..071109f --- /dev/null +++ b/Scripts/Engines/Spawner/PremiumSpawner/SpawnsOverseer.cs @@ -0,0 +1,369 @@ +/************************* + * By Nerun * + * Engine r103 * + ************************* + */ + +using System; +using System.IO; +using Server; +using Server.Mobiles; +using System.Collections.Generic; +using Server.Network; + +namespace Server.Items +{ + public class SpawnsOverseer : Item + { + private int m_Range; + private int m_InRangeDelay; + private int m_OutRangeDelay; + private int m_Overseeing; + private CheckTimer m_Timer; + private bool m_Enable; + private bool m_Gatekeeper; + private TimeSpan m_CurrentDelay; // players out dungeon + private DateTime m_End; + + [CommandProperty( AccessLevel.GameMaster )] + public bool Enable + { + get { return m_Enable; } + set + { + if ( value ) + Begin(); + + else + End(); + + InvalidateProperties(); + } + } + + [CommandProperty( AccessLevel.GameMaster )] + public bool Gatekeeper + { + get { return m_Gatekeeper; } + set { m_Gatekeeper = value; InvalidateProperties(); } + } + + [CommandProperty( AccessLevel.GameMaster )] + public int Range + { + get { return m_Range; } + set { m_Range = value; InvalidateProperties(); } + } + + [CommandProperty( AccessLevel.GameMaster )] + public TimeSpan CurrentDelay + { + get { return m_CurrentDelay; } + set { m_CurrentDelay = value; InvalidateProperties(); } + } + + [CommandProperty( AccessLevel.GameMaster )] + public TimeSpan NextDelay + { + get + { + if ( m_Enable ) + return m_End - DateTime.Now; + else + return TimeSpan.FromSeconds( 0 ); + } + set + { + Begin(); + DoTimer( value ); + } + } + + [CommandProperty( AccessLevel.GameMaster )] + public int InRangeDelay + { + get { return m_InRangeDelay; } + set { m_InRangeDelay = value; InvalidateProperties(); } + } + + [CommandProperty( AccessLevel.GameMaster )] + public int OutRangeDelay + { + get { return m_OutRangeDelay; } + set { m_OutRangeDelay = value; InvalidateProperties(); } + } + + [CommandProperty( AccessLevel.GameMaster )] + public int Overseeing + { + get { return m_Overseeing; } + set { m_Overseeing = value; InvalidateProperties(); } + } + + public void Begin() + { + if ( !m_Enable ) + { + m_Enable = true; + DoTimer(); + } + } + + public void End() + { + if ( m_Enable ) + { + m_Timer.Stop(); + m_Enable = false; + } + } + + public void Restart() + { + if ( m_Enable ) + { + m_Timer.Stop(); + DoTimer(); + } + } + + public void DoTimer() + { + if ( !m_Enable ) + return; + + int mSeconds = (int)m_CurrentDelay.TotalSeconds; + + TimeSpan delay = TimeSpan.FromSeconds( mSeconds ); + DoTimer( delay ); + } + + public void DoTimer( TimeSpan delay ) + { + if ( !m_Enable ) + return; + + if ( m_Timer != null ) + m_Timer.Stop(); + + m_End = DateTime.Now + delay; + + m_Timer = new CheckTimer( this, delay ); + m_Timer.Start(); + } + + [Constructable] + public SpawnsOverseer() : this( 20, 30, 5, 0 ) + { + } + + [Constructable] + public SpawnsOverseer( int startrange ) : this( startrange, 30, 5, 0 ) + { + } + + [Constructable] + public SpawnsOverseer( int startrange, int startIRD, int startORD, int startOverseeing ) : base( 0x1F1E ) + { + InitSeer( startrange, startIRD, startORD, startOverseeing ); + } + + private void InitSeer( int startrange, int startIRD, int startORD, int startOverseeing ) + { + Name = "Spawns' Overseer"; + Movable = false; + Light = LightType.Circle150; + Weight = 1; + Visible = false; + Enable = true; + Gatekeeper = false; + Range = startrange; + CurrentDelay = TimeSpan.FromSeconds( 5 ); + InRangeDelay = startIRD; //minutes + OutRangeDelay = startORD; //seconds + Overseeing = startOverseeing; //PremiumSpawners under control + } + + public override void GetProperties( ObjectPropertyList list ) + { + base.GetProperties( list ); + + if ( m_Enable ) + { + list.Add( 1060742 ); // active + + list.Add( 1060662, "Range\t{0}", Range.ToString() ); + list.Add( 1060663, "In Range Delay\t{0} min", InRangeDelay.ToString() ); + list.Add( 1060661, "Out Range Delay\t{0} sec", OutRangeDelay.ToString() ); + list.Add( 1060658, "Overseeing\t{0} PremiumSpawners", Overseeing.ToString() ); + } + else + { + list.Add( 1060743 ); // inactive + } + } + + private class CheckTimer : Timer + { + private SpawnsOverseer m_SpawnsOverseer; + + public CheckTimer( SpawnsOverseer Crystal, TimeSpan delay ) : base( delay, delay ) + { + Priority = TimerPriority.OneSecond; + + m_SpawnsOverseer = Crystal; + } + + protected override void OnTick() + { + if ( ( m_SpawnsOverseer != null ) && ( !m_SpawnsOverseer.Deleted ) ) + { + m_SpawnsOverseer.OnTickDoThis(); + } + + else + { + Stop(); + } + } + } + + public void OnTickDoThis() + { + + if ( this.Gatekeeper == false) // Gatekeeper mode OFF + { + List ClosePremiumSpawners = new List(); + + List ClosePlayers = new List(); + + List MobsCleaning = new List(); + + List ItemsCleaning = new List(); + + foreach ( Item item in this.GetItemsInRange( Range ) ) + { + if( item is PremiumSpawner ) + ClosePremiumSpawners.Add( item ); + } + + if ( ClosePremiumSpawners.Count > 0 ) + { + this.Overseeing = ClosePremiumSpawners.Count; + + foreach ( Mobile m in this.GetMobilesInRange( Range ) ) + { + if( m is PlayerMobile && m.AccessLevel == AccessLevel.Player || m is PlayerMobile && m.AccessLevel > AccessLevel.Player && m.Hidden == false ) // if player or GM not hidden + ClosePlayers.Add( m ); + } + + if ( ClosePlayers.Count > 0 ) // at least one player close + { + this.CurrentDelay = TimeSpan.FromMinutes( InRangeDelay ); // time to new check + Restart(); + + foreach ( Item pspawner in ClosePremiumSpawners ) // for each PremiumSpawner close (in the List) + { + if ( ((PremiumSpawner)pspawner).Running == false ) // if it is inactive + { + ((PremiumSpawner)pspawner).Running = true; // activate it! + ((PremiumSpawner)pspawner).NextSpawn = TimeSpan.FromSeconds( 1 ); // and do a total respawn of it! + } + } + } + + else if ( ClosePlayers.Count <= 0 ) // nobody close + { + this.CurrentDelay = TimeSpan.FromSeconds( OutRangeDelay ); // time to new check + Restart(); + + foreach ( Item pspawner in ClosePremiumSpawners ) // for each PremiumSpawner close (in the List) + { + if ( ((PremiumSpawner)pspawner).Running == true ) // if it is active + { + ((PremiumSpawner)pspawner).Running = false; // make inactive! + + // NOW delete items and mobiles (not only the spawned, but all movable in range) + + foreach ( Mobile mobdel in this.GetMobilesInRange( Range ) ) + { + if( mobdel is BaseCreature || mobdel is TownCrier ) + MobsCleaning.Add( mobdel ); + } + + if ( MobsCleaning.Count > 0 ) + { + foreach ( Mobile mDel in MobsCleaning ) + mDel.Delete(); + } + + foreach ( Item itemdel in this.GetItemsInRange( Range ) ) + { + if( itemdel.Movable == true ) //se for um item móvel (não decoração) + ItemsCleaning.Add( itemdel ); + } + + if ( ItemsCleaning.Count > 0 ) + { + foreach ( Item iDel in ItemsCleaning ) + iDel.Delete(); + } + } + } + } + } + + else if ( ClosePremiumSpawners.Count <= 0 ) // if SpawnsOverseer has no PremiumSpawner to seer, deactivate it + { + this.Enable = false; + this.CurrentDelay = TimeSpan.FromSeconds( OutRangeDelay ); + this.Overseeing = ClosePremiumSpawners.Count; + } + } + + else // Gatekeeper mode ON + { + + } + } + + public SpawnsOverseer( Serial serial ) : base( serial ) + { + } + + public override void Serialize( GenericWriter writer ) + { + base.Serialize( writer ); + + writer.Write( (int) 0 ); + + writer.Write( m_Range ); + writer.Write( m_InRangeDelay ); + writer.Write( m_OutRangeDelay ); + writer.Write( m_Overseeing ); + writer.Write( m_Gatekeeper ); + writer.Write( m_Enable ); + if ( m_Enable ) + writer.WriteDeltaTime( m_End ); + } + + public override void Deserialize( GenericReader reader ) + + { + base.Deserialize( reader ); + + int version = reader.ReadInt(); + + m_Range = reader.ReadInt(); + m_InRangeDelay = reader.ReadInt(); + m_OutRangeDelay = reader.ReadInt(); + m_Overseeing = reader.ReadInt(); + m_Gatekeeper = reader.ReadBool(); + m_Enable = reader.ReadBool(); + TimeSpan ts = TimeSpan.Zero; + if ( m_Enable ) + ts = reader.ReadDeltaTime() - DateTime.Now; + DoTimer( ts ); + } + } +} diff --git a/Scripts/Engines/Spawner/PremiumSpawner/SpawnsOverseerCommand.cs b/Scripts/Engines/Spawner/PremiumSpawner/SpawnsOverseerCommand.cs new file mode 100644 index 0000000..1bef0d4 --- /dev/null +++ b/Scripts/Engines/Spawner/PremiumSpawner/SpawnsOverseerCommand.cs @@ -0,0 +1,459 @@ +// Engine r117 +using System; +using System.IO; +using System.Collections; +using System.Collections.Generic; +using Server; +using Server.Items; +using Server.Mobiles; + +namespace Server.Commands +{ + public class GenOverseer + { + public static void Initialize() + { + CommandSystem.Register( "GenSeers", AccessLevel.Administrator, new CommandEventHandler( GenOverseer_OnCommand ) ); + CommandSystem.Register( "GenOverseers", AccessLevel.Administrator, new CommandEventHandler( GenOverseer_OnCommand ) ); + CommandSystem.Register( "GenSeer", AccessLevel.Administrator, new CommandEventHandler( GenOverseer_OnCommand ) ); + CommandSystem.Register( "GenOverseer", AccessLevel.Administrator, new CommandEventHandler( GenOverseer_OnCommand ) ); + } + + [Usage( "GenSeers" )] + [Aliases( "GenSeer, GenOverseer and GenOverseers" )] + [Description( "Generates Spawns' Overseers around the world." )] + private static void GenOverseer_OnCommand( CommandEventArgs e ) + { + m_Mobile = e.Mobile; + m_Count = 0; + + m_Mobile.SendMessage( "Generating Spawns' Overseers, please wait." ); + + Generate( "Data/Nerun's Distro/Spawns/overseers/trammel", Map.Trammel ); + Generate( "Data/Nerun's Distro/Spawns/overseers/felucca", Map.Felucca ); + Generate( "Data/Nerun's Distro/Spawns/overseers/ilshenar", Map.Ilshenar ); + Generate( "Data/Nerun's Distro/Spawns/overseers/malas", Map.Malas ); + Generate( "Data/Nerun's Distro/Spawns/overseers/tokuno", Map.Tokuno ); + Generate( "Data/Nerun's Distro/Spawns/overseers/termur", Map.TerMur ); + + m_Mobile.SendMessage( "Spawns' Overseers generation complete. {0} seers were generated.", m_Count ); + } + + public static void Generate( string folder, params Map[] maps ) + { + if ( !Directory.Exists( folder ) ) + return; + + string[] files = Directory.GetFiles( folder, "*.cfg" ); + + for ( int i = 0; i < files.Length; ++i ) + { + ArrayList list = DecorationListSeers.ReadAll( files[i] ); + + for ( int j = 0; j < list.Count; ++j ) + m_Count += ((DecorationListSeers)list[j]).Generate( maps ); + } + } + + private static Mobile m_Mobile; + private static int m_Count; + } + + public class DecorationListSeers + { + private Type m_Type; + private int m_ItemID; + private string[] m_Params; + private ArrayList m_Entries; + + public DecorationListSeers() + { + } + + private static Type typeofStatic = typeof( Static ); + private static Type typeofLocalizedStatic = typeof( LocalizedStatic ); + + public Item Construct() + { + Item item; + + try + { + if ( m_Type == typeofStatic ) + { + item = new Static( m_ItemID ); + } + else if ( m_Type == typeofLocalizedStatic ) + { + int labelNumber = 0; + + for ( int i = 0; i < m_Params.Length; ++i ) + { + if ( m_Params[i].StartsWith( "LabelNumber" ) ) + { + int indexOf = m_Params[i].IndexOf( '=' ); + + if ( indexOf >= 0 ) + { + labelNumber = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) ); + break; + } + } + } + + item = new LocalizedStatic( m_ItemID, labelNumber ); + } + else + { + item = (Item)Activator.CreateInstance( m_Type ); + } + } + catch ( Exception e ) + { + throw new Exception( String.Format( "Bad type: {0}", m_Type ), e ); + } + + if ( item is Server.Items.SpawnsOverseer ) + { + Server.Items.SpawnsOverseer sp = (Server.Items.SpawnsOverseer)item; + + for ( int i = 0; i < m_Params.Length; ++i ) + { + if ( m_Params[i].StartsWith( "Range" ) ) + { + int indexOf = m_Params[i].IndexOf( '=' ); + + if ( indexOf >= 0 ) + sp.Range = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) ); + } + else if ( m_Params[i].StartsWith( "InRangeDelay" ) ) + { + int indexOf = m_Params[i].IndexOf( '=' ); + + if ( indexOf >= 0 ) + sp.InRangeDelay = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) ); + } + else if ( m_Params[i].StartsWith( "OutRangeDelay" ) ) + { + int indexOf = m_Params[i].IndexOf( '=' ); + + if ( indexOf >= 0 ) + sp.OutRangeDelay = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) ); + } + } + } + + item.Movable = false; + + for ( int i = 0; i < m_Params.Length; ++i ) + { + if ( m_Params[i].StartsWith( "Light" ) ) + { + int indexOf = m_Params[i].IndexOf( '=' ); + + if ( indexOf >= 0 ) + item.Light = (LightType)Enum.Parse( typeof( LightType ), m_Params[i].Substring( ++indexOf ), true ); + } + else if ( m_Params[i].StartsWith( "Hue" ) ) + { + int indexOf = m_Params[i].IndexOf( '=' ); + + if ( indexOf >= 0 ) + { + int hue = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) ); + + if ( item is DyeTub ) + ((DyeTub)item).DyedHue = hue; + else + item.Hue = hue; + } + } + else if ( m_Params[i].StartsWith( "Name" ) ) + { + int indexOf = m_Params[i].IndexOf( '=' ); + + if ( indexOf >= 0 ) + item.Name = m_Params[i].Substring( ++indexOf ); + } + else if ( m_Params[i].StartsWith( "Amount" ) ) + { + int indexOf = m_Params[i].IndexOf( '=' ); + + if ( indexOf >= 0 ) + { + // Must supress stackable warnings + + bool wasStackable = item.Stackable; + + item.Stackable = true; + item.Amount = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) ); + item.Stackable = wasStackable; + } + } + } + + return item; + } + + private static Queue m_DeleteQueue = new Queue(); + + private static bool FindItem( int x, int y, int z, Map map, Item srcItem ) + { + int itemID = srcItem.ItemID; + + bool res = false; + + IPooledEnumerable eable; + + if ( (TileData.ItemTable[itemID & TileData.MaxItemValue].Flags & TileFlag.LightSource) != 0 ) + { + eable = map.GetItemsInRange( new Point3D( x, y, z ), 0 ); + + LightType lt = srcItem.Light; + string srcName = srcItem.ItemData.Name; + + foreach ( Item item in eable ) + { + if ( item.Z == z ) + { + if ( item.ItemID == itemID ) + { + if ( item.Light != lt ) + m_DeleteQueue.Enqueue( item ); + else + res = true; + } + else if ( (item.ItemData.Flags & TileFlag.LightSource) != 0 && item.ItemData.Name == srcName ) + { + m_DeleteQueue.Enqueue( item ); + } + } + } + } + else + { + eable = map.GetItemsInRange( new Point3D( x, y, z ), 0 ); + + foreach ( Item item in eable ) + { + if ( item.Z == z && item.ItemID == itemID ) + { + eable.Free(); + return true; + } + } + } + + eable.Free(); + + while ( m_DeleteQueue.Count > 0 ) + ((Item)m_DeleteQueue.Dequeue()).Delete(); + + return res; + } + + public int Generate( Map[] maps ) + { + int count = 0; + + Item item = null; + + for ( int i = 0; i < m_Entries.Count; ++i ) + { + DecorationEntrySeers entry = (DecorationEntrySeers)m_Entries[i]; + Point3D loc = entry.Location; + string extra = entry.Extra; + + for ( int j = 0; j < maps.Length; ++j ) + { + if ( item == null ) + item = Construct(); + + if ( item == null ) + continue; + + if ( FindItem( loc.X, loc.Y, loc.Z, maps[j], item ) ) + { + } + else + { + item.MoveToWorld( loc, maps[j] ); + ++count; + + item = null; + } + } + } + + if ( item != null ) + item.Delete(); + + return count; + } + + public static ArrayList ReadAll( string path ) + { + using ( StreamReader ip = new StreamReader( path ) ) + { + ArrayList list = new ArrayList(); + + for ( DecorationListSeers v = Read( ip ); v != null; v = Read( ip ) ) + list.Add( v ); + + return list; + } + } + + private static string[] m_EmptyParams = new string[0]; + + public static DecorationListSeers Read( StreamReader ip ) + { + string line; + + while ( (line = ip.ReadLine()) != null ) + { + line = line.Trim(); + + if ( line.Length > 0 && !line.StartsWith( "#" ) ) + break; + } + + if ( string.IsNullOrEmpty( line ) ) + return null; + + DecorationListSeers list = new DecorationListSeers(); + + int indexOf = line.IndexOf( ' ' ); + + list.m_Type = ScriptCompiler.FindTypeByName( line.Substring( 0, indexOf++ ), true ); + + if ( list.m_Type == null ) + throw new ArgumentException( String.Format( "Type not found for header: '{0}'", line ) ); + + line = line.Substring( indexOf ); + indexOf = line.IndexOf( '(' ); + if ( indexOf >= 0 ) + { + list.m_ItemID = Utility.ToInt32( line.Substring( 0, indexOf - 1 ) ); + + string parms = line.Substring( ++indexOf ); + + if ( line.EndsWith( ")" ) ) + parms = parms.Substring( 0, parms.Length - 1 ); + + list.m_Params = parms.Split( ';' ); + + for ( int i = 0; i < list.m_Params.Length; ++i ) + list.m_Params[i] = list.m_Params[i].Trim(); + } + else + { + list.m_ItemID = Utility.ToInt32( line ); + list.m_Params = m_EmptyParams; + } + + list.m_Entries = new ArrayList(); + + while ( (line = ip.ReadLine()) != null ) + { + line = line.Trim(); + + if ( line.Length == 0 ) + break; + + if ( line.StartsWith( "#" ) ) + continue; + + list.m_Entries.Add( new DecorationEntrySeers( line ) ); + } + + return list; + } + } + + public class DecorationEntrySeers + { + private Point3D m_Location; + private string m_Extra; + + public Point3D Location{ get{ return m_Location; } } + public string Extra{ get{ return m_Extra; } } + + public DecorationEntrySeers( string line ) + { + string x, y, z; + + Pop( out x, ref line ); + Pop( out y, ref line ); + Pop( out z, ref line ); + + m_Location = new Point3D( Utility.ToInt32( x ), Utility.ToInt32( y ), Utility.ToInt32( z ) ); + m_Extra = line; + } + + public void Pop( out string v, ref string line ) + { + int space = line.IndexOf( ' ' ); + + if ( space >= 0 ) + { + v = line.Substring( 0, space++ ); + line = line.Substring( space ); + } + else + { + v = line; + line = ""; + } + } + } + + public class RemOverseer + { + public static void Initialize() + { + CommandSystem.Register( "RemOverseers", AccessLevel.Administrator, new CommandEventHandler( RemOverseers_OnCommand ) ); + CommandSystem.Register( "RemSeers", AccessLevel.Administrator, new CommandEventHandler( RemOverseers_OnCommand ) ); + CommandSystem.Register( "RemOverseer", AccessLevel.Administrator, new CommandEventHandler( RemOverseers_OnCommand ) ); + CommandSystem.Register( "RemSeer", AccessLevel.Administrator, new CommandEventHandler( RemOverseers_OnCommand ) ); + } + + [Usage( "RemSeers" )] + [Aliases( "RemSeer, RemOverseer, RemOverseers" )] + [Description( "Remove all Overseers in all facets." )] + public static void RemOverseers_OnCommand( CommandEventArgs e ) + { + Mobile from = e.Mobile; + World.Broadcast( 0x35, true, "Overseers are being removed, please wait." ); + DateTime startTime = DateTime.Now; + int count = 0; + List itemsremove = new List(); + + foreach ( Item itemremove in World.Items.Values ) + { + if ( itemremove is SpawnsOverseer && itemremove.Parent == null ) + { + itemsremove.Add( itemremove ); + count +=1; + } + } + + foreach ( Item itemremove2 in itemsremove ) + { + itemremove2.Delete(); + } + + foreach ( Item premiums in World.Items.Values ) + { + if ( premiums is PremiumSpawner && premiums.Parent == null && ((PremiumSpawner)premiums).Running == false ) + { + ((PremiumSpawner)premiums).Running = true; + ((PremiumSpawner)premiums).NextSpawn = TimeSpan.FromSeconds( 1 ); + } + } + + DateTime endTime = DateTime.Now; + World.Broadcast( 0x35, true, "{0} Overseers has been removed in {1:F1} seconds.", count, (endTime - startTime).TotalSeconds ); + } + } +} diff --git a/Scripts/Gumps/AdminGump.cs b/Scripts/Gumps/AdminGump.cs index 17fc78d..7f83a00 100644 --- a/Scripts/Gumps/AdminGump.cs +++ b/Scripts/Gumps/AdminGump.cs @@ -370,7 +370,7 @@ namespace Server.Gumps AddButtonLabeled( 20, 175, GetButtonID( 3, 101 ), "Teleporters" ); AddButtonLabeled( 220, 175, GetButtonID( 3, 102 ), "Moongates" ); - AddButtonLabeled( 20, 200, GetButtonID( 3, 103 ), "Vendors" ); + AddButtonLabeled( 20, 200, GetButtonID( 3, 103 ), "--Empty--" ); AddButtonLabeled( 220, 200, GetButtonID( 3, 106 ), "Decoration" ); AddButtonLabeled( 20, 225, GetButtonID( 3, 104 ), "Doors" ); @@ -1763,7 +1763,7 @@ namespace Server.Gumps case 100: InvokeCommand( "DocGen" ); notice = "Documentation has been generated."; break; case 101: InvokeCommand( "TelGen" ); notice = "Teleporters have been generated."; break; case 102: InvokeCommand( "MoonGen" ); notice = "Moongates have been generated."; break; - case 103: InvokeCommand( "UOAMVendors" ); notice = "Vendor spawners have been generated."; break; + case 103: InvokeCommand( "" ); notice = "--Empty--."; break; case 104: InvokeCommand( "DoorGen" ); notice = "Doors have been generated."; break; case 105: InvokeCommand( "SignGen" ); notice = "Signs have been generated."; break; case 106: InvokeCommand( "Decorate" ); notice = "Decoration has been generated."; break; @@ -3048,4 +3048,4 @@ namespace Server.Gumps } } } -} \ No newline at end of file +}