Overwrite

Complete Overwrite of the Folder with the free shard. ServUO 57.3 has been added.
This commit is contained in:
Unstable Kitsune
2023-11-28 23:20:26 -05:00
parent 3cd54811de
commit b918192e4e
11608 changed files with 2644205 additions and 47 deletions

View File

@@ -0,0 +1,220 @@
using System;
using System.Collections.Generic;
using Server.Items;
using Server.Mobiles;
namespace Server.EventSystem
{
public abstract class BaseEvent
{
#region Private Variables
private bool m_Enabled;
private bool m_Started;
//private Point3D m_StartingLocation;
//private Map m_StartingMap;
private EventTimer m_EventTimer;
#endregion
#region Public Variables
public bool Enabled { get { return m_Enabled; } }
public bool Started { get { return m_Started; } }
/*[CommandProperty( AccessLevel.Administrator )]
public Point3D StartingLocation { get { return m_StartingLocation; } set { m_StartingLocation = value; } }
[CommandProperty( AccessLevel.Administrator )]
public Map StartingMap { get { return m_StartingMap; } set { m_StartingMap = value; } }*/
public EventTimer EventTimer { get { return m_EventTimer; } set { m_EventTimer = value; } }
#endregion
#region Abstract Properties/Methods
public abstract EventType EventType { get; }
public abstract string EventName { get; }
public abstract TimeSpan TimerFrequency { get; }
public abstract Map StartingMap { get; }
public abstract Point3D StartingLocation { get; }
protected abstract void OnEnable();
protected abstract void OnDisable();
public abstract void OnStart();
protected abstract void OnStop();
public abstract void OnTick( int ticks );
#endregion
#region Constructor
public BaseEvent()
{
}
#endregion
#region Virtual Methods
public virtual void Enable()
{
if ( !m_Enabled )
{
m_Enabled = true;
OnEnable();
}
}
public virtual void Disable()
{
if ( m_Enabled )
{
m_Enabled = false;
OnDisable();
}
}
public virtual void Start()
{
if ( !m_Started )
{
m_Started = true;
if ( m_EventTimer != null )
m_EventTimer.Stop();
if ( TimerFrequency != TimeSpan.Zero )
{
m_EventTimer = new EventTimer( this );
m_EventTimer.Start();
}
OnStart();
}
}
public virtual void Stop()
{
if ( m_Started )
{
m_Started = false;
if ( m_EventTimer != null )
{
m_EventTimer.Stop();
m_EventTimer = null;
}
OnStop();
}
}
public virtual void RefreshPlayer( Mobile from )
{
if ( from == null )
return;
if ( !from.Alive )
from.Resurrect();
Container pack = from.Backpack;
Item holding = from.Holding;
if ( holding != null && pack != null )
pack.DropItem( holding );
from.RevealingAction();
from.Poison = null;
from.StatMods.Clear();
Factions.Faction.ClearSkillLoss( from );
from.Hits = from.HitsMax;
from.Mana = from.ManaMax;
from.Stam = from.StamMax;
Targeting.Target.Cancel( from );
from.MagicDamageAbsorb = 0;
from.MeleeDamageAbsorb = 0;
Spells.Second.ProtectionSpell.Registry.Remove( from );
DefensiveSpell.Nullify( from );
from.Combatant = null;
from.Delta( MobileDelta.Noto ); //Update notoriety
}
public virtual void Serialize( GenericWriter writer )
{
writer.Write( (int)0 ); //version
}
public virtual void Deserialize( GenericReader reader )
{
int version = reader.ReadInt();
switch ( version )
{
case 0:
{
break;
}
}
}
#endregion
#region Public Methods
public void Announce( int hue, string message, params object[] args )
{
World.Broadcast( hue, false, String.Format( "[{0}]: {1}", EventName, message ), args );
}
public void LocalAnnounce( Point3D p, Map map, int range, int hue, string message, params object[] args )
{
IPooledEnumerable eable = map.GetMobilesInRange( p, range );
foreach (Mobile mobile in eable)
{
if (mobile != null && mobile is PlayerMobile)
{
mobile.SendMessage(hue, message, args);
}
}
eable.Free(); //get rid of our enumerable.
}
public void SpawnGates()
{
Action<Point3D> spawnGate = delegate( Point3D loc ) { new EventGate( this ).MoveToWorld( loc, Map.Felucca ); };
MoongateLocations.Banks.ForEach( spawnGate );
MoongateLocations.Shrines.ForEach( spawnGate );
}
public void DespawnGates()
{
List<Item> gates = new List<Item>();
foreach ( Item i in World.Items.Values )
{
if ( i is EventGate )
gates.Add( i );
}
foreach ( Item gate in gates )
gate.Delete();
}
#endregion
}
}

View File

@@ -0,0 +1,12 @@
using System;
namespace Server.EventSystem
{
public class EventConfig
{
public static Type[] EnabledEvents = new Type[]
{
typeof( TownInvasion )
};
}
}

View File

@@ -0,0 +1,33 @@
using System;
namespace Server.EventSystem
{
public class EquipmentLayers
{
public static Layer[] ToClear = new Layer[]
{
Layer.Cloak,
Layer.Talisman,
Layer.Bracelet,
Layer.Earrings,
Layer.Ring,
Layer.Shirt,
Layer.Pants,
Layer.InnerLegs,
Layer.Shoes,
Layer.Arms,
Layer.InnerTorso,
Layer.MiddleTorso,
Layer.OuterLegs,
Layer.Neck,
Layer.Waist,
Layer.Gloves,
Layer.OuterTorso,
Layer.OneHanded,
Layer.TwoHanded,
Layer.FacialHair,
Layer.Hair,
Layer.Helm
};
}
}

View File

@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
namespace Server.EventSystem
{
public static class MoongateLocations
{
public static List<Point3D> Banks = new List<Point3D>( new Point3D[]
{
new Point3D( 1420, 1699, 0 ),
new Point3D( 2723, 2190, 0 ),
new Point3D( 2237, 1195, 0 ),
new Point3D( 5272, 3992, 37 ),
new Point3D( 1324, 3781, 0 ),
new Point3D( 2496, 564, 0 ),
new Point3D( 4462, 1176, 0 ),
new Point3D( 3770, 1318, 0 ),
new Point3D( 3688, 2524, 0 ),
new Point3D( 5675, 3143, 12 ),
new Point3D( 2894, 3472, 15 ),
new Point3D( 594, 2154, 0 ),
new Point3D( 1821, 2818, 0 ),
new Point3D( 2898, 670, 0 ),
new Point3D( 630, 858, 0 ),
new Point3D( 3034, 3374, 15 )
} );
public static List<Point3D> Shrines = new List<Point3D>( new Point3D[]
{
new Point3D( 1461, 840, 0 ),
new Point3D( 1855, 875, 0 ),
new Point3D( 4217, 560, 36 ),
new Point3D( 1729, 3523, 0 ),
new Point3D( 4268, 3702, 0 ),
new Point3D( 1297, 633, 16 ),
new Point3D( 3352, 293, 4 ),
new Point3D( 1600, 2484, 5 ),
new Point3D( 2490, 3935, 0 )
} );
}
}

View File

@@ -0,0 +1,164 @@
using System;
using System.Collections.Generic;
using Server.Items;
using Server.Mobiles;
namespace Server.EventSystem
{
public class EventCore
{
#region Variables
public static List<BaseEvent> Events;
#endregion
#region Initialize
public static void Initialize()
{
//Hook Serialize/Deserialize
if ( EventPersistance.Instance == null )
new EventPersistance();
if ( Events == null )
Events = CreateEvents();
//Register EventSinks
EventSink.ServerStarted += new ServerStartedEventHandler( EventSink_ServerStarted );
//Commands.CommandSystem.Register( "MonsterBash", AccessLevel.GameMaster, new Commands.CommandEventHandler( MonsterBash_OnCommand ) );
//Commands.CommandSystem.Register( "StartMonsterBash", AccessLevel.GameMaster, new Commands.CommandEventHandler( StartMonsterBash_OnCommand ) );
Commands.CommandSystem.Register( "TownInvasion", AccessLevel.GameMaster, new Commands.CommandEventHandler( TownInvasion_OnCommand ) );
Commands.CommandSystem.Register( "StartTownInvasion", AccessLevel.GameMaster, new Commands.CommandEventHandler( StartTownInvasion_OnCommand ) );
}
#endregion
#region OnCommand
/*private static void MonsterBash_OnCommand( Commands.CommandEventArgs e )
{
e.Mobile.SendGump( new EventPropertiesGump( e.Mobile, FindEvent( EventType.MonsterBash ) ) );
}
private static void StartMonsterBash_OnCommand( Commands.CommandEventArgs e )
{
FindEvent( EventType.MonsterBash ).Start();
}*/
private static void TownInvasion_OnCommand( Commands.CommandEventArgs e )
{
e.Mobile.SendGump( new EventPropertiesGump( e.Mobile, FindEvent( EventType.TownInvasion ) ) );
}
private static void StartTownInvasion_OnCommand( Commands.CommandEventArgs e )
{
FindEvent( EventType.TownInvasion ).Start();
}
#endregion
#region EventSinks
private static void EventSink_ServerStarted()
{
/*Timer.DelayCall( TimeSpan.FromSeconds( 0.0 ), delegate
{
//Load Event Data
BaseEvent e = FindEvent( EventType.MonsterBash );
if ( e != null )
e.Start();
} );*/
}
#endregion
#region Private Methods
private static List<BaseEvent> CreateEvents()
{
List<BaseEvent> events = new List<BaseEvent>();
for ( int i = 0; i < EventConfig.EnabledEvents.Length; ++i )
{
object e = Activator.CreateInstance( EventConfig.EnabledEvents[i] );
if ( e != null && e is BaseEvent )
events.Add( e as BaseEvent );
}
return events;
}
#endregion
#region Public Methods
public static BaseEvent FindEvent( EventType e )
{
foreach ( BaseEvent b in Events )
{
if ( b.EventType == e )
return b;
}
return null;
}
public static void Serialize( GenericWriter writer )
{
writer.Write( (int)0 ); //version
writer.Write( Events.Count );
Events.ForEach( delegate( BaseEvent e )
{
writer.Write( e.GetType().ToString() );
e.Serialize( writer );
} );
}
public static void Deserialize( GenericReader reader )
{
int version = reader.ReadInt();
if ( Events != null )
Events.Clear();
Events = new List<BaseEvent>();
//Load events from configuration
List<Type> fromConfig = new List<Type>( EventConfig.EnabledEvents );
int count = reader.ReadInt();
for ( int i = 0; i < count; ++i )
{
string strType = reader.ReadString();
Type rType = ScriptCompiler.FindTypeByFullName( strType, true );
if ( rType != null )
{
object type = Activator.CreateInstance( rType );
if ( type != null && type is BaseEvent )
{
( (BaseEvent)type ).Deserialize( reader );
//Only add it if it's in the config file
if ( fromConfig.Contains( rType ) )
Events.Add( type as BaseEvent );
}
}
}
//Enable Registered BaseEvents
Events.ForEach( delegate( BaseEvent e ) { e.Enable(); } );
}
#endregion
}
}

View File

@@ -0,0 +1,10 @@
using System;
namespace Server.EventSystem
{
public enum EventType
{
None,
TownInvasion
}
}

View File

@@ -0,0 +1,24 @@
using System;
namespace Server.EventSystem
{
public class EventTimer : Timer
{
private BaseEvent m_Event;
private int m_Ticks;
public EventTimer( BaseEvent e )
: base( e.TimerFrequency, e.TimerFrequency )
{
m_Event = e;
m_Ticks = 0;
}
protected override void OnTick()
{
++m_Ticks;
m_Event.OnTick( m_Ticks );
}
}
}

View File

@@ -0,0 +1,30 @@
using System;
namespace Server.EventSystem
{
public enum TownMonsterType
{
Abyss,
Arachnid,
DragonKind,
Elementals,
Humanoid,
OrcsandRatmen,
OreElementals,
Ophidian,
Snakes,
Undead
}
public enum TownChampionType
{
Barracoon,
Harrower,
LordOaks,
Mephitis,
Neira,
Rikktor,
Semidar,
Serado
}
}

View File

@@ -0,0 +1,181 @@
using System;
using Server.Network;
using Server.Items;
namespace Server.Mobiles
{
[CorpseName("Corpse of the neighborhood watch")]
public class InvasionAnnouncer : Lich
{
private static bool m_Talked;
private static string m_BroadcastMessage = "Everything is looking fine at the moment. Travel safe.";
private static bool m_GaveNews;
[Constructable]
public InvasionAnnouncer() : base()
{
Title = "the Neighborhood Watch";
Blessed = true;
CantWalk = true;
SpeechHue = Utility.RandomDyedHue();
Hue = Utility.RandomSkinHue();
if ( Female = Utility.RandomBool() )
{
Body = 0x191;
Name = NameList.RandomName( "female" );
switch( Utility.Random( 2 ) )
{
case 0: AddItem( new LeatherSkirt() ); break;
case 1: AddItem( new LeatherShorts() ); break;
}
switch( Utility.Random( 5 ) )
{
case 0: AddItem( new FemaleLeatherChest() ); break;
case 1: AddItem( new FemaleStuddedChest() ); break;
case 2: AddItem( new LeatherBustierArms() ); break;
case 3: AddItem( new StuddedBustierArms() ); break;
case 4: AddItem( new FemalePlateChest() ); break;
}
}
else
{
Body = 0x190;
Name = NameList.RandomName( "male" );
AddItem( new PlateChest() );
AddItem( new PlateArms() );
AddItem( new PlateLegs() );
switch( Utility.Random( 3 ) )
{
case 0: AddItem( new Doublet( Utility.RandomNondyedHue() ) ); break;
case 1: AddItem( new Tunic( Utility.RandomNondyedHue() ) ); break;
case 2: AddItem( new BodySash( Utility.RandomNondyedHue() ) ); break;
}
}
Utility.AssignRandomHair( this );
if( Utility.RandomBool() )
Utility.AssignRandomFacialHair( this, HairHue );
Halberd Weapon = new Halberd();
Weapon.Movable = false;
Weapon.Crafter = this;
//Weapon.Quality = Weapon.Exceptional;
AddItem( Weapon );
Container pack = new Backpack();
pack.Movable = false;
pack.DropItem( new Gold( 10, 25 ) );
AddItem( pack );
Skills[SkillName.Anatomy].Base = 120.0;
Skills[SkillName.Tactics].Base = 120.0;
Skills[SkillName.Swords].Base = 120.0;
Skills[SkillName.MagicResist].Base = 120.0;
Skills[SkillName.DetectHidden].Base = 100.0;
}
public InvasionAnnouncer( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 0 ); // version
writer.Write( (string) m_BroadcastMessage);
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
m_BroadcastMessage = reader.ReadString();
}
public override void OnMovement( Mobile m, Point3D oldLocation )
{
if( m_Talked == false )
{
if ( m.InRange( this, 3 ) && m is PlayerMobile)
{
m_Talked = true;
this.Say( m_BroadcastMessage );
this.Move( GetDirectionTo( m.Location ) );
SpamTimer t = new SpamTimer();
t.Start();
}
}
}
public override void OnSpeech( SpeechEventArgs e )
{
base.OnSpeech( e );
if ( !e.Handled && InRange( e.Mobile, 3 ) )
{
if ( e.HasKeyword( 0x30 ) && m_GaveNews == false )
{
m_GaveNews = true;
this.Say( m_BroadcastMessage );
this.Move( GetDirectionTo( e.Mobile.Location ) );
NewsTimer t = new NewsTimer();
t.Start();
}
}
}
private class SpamTimer : Timer
{
public SpamTimer() : base( TimeSpan.FromMinutes( 1 ) )
{
Priority = TimerPriority.OneSecond;
}
protected override void OnTick()
{
m_Talked = false;
}
}
private class NewsTimer : Timer
{
public NewsTimer() : base( TimeSpan.FromSeconds( 30 ) )
{
Priority = TimerPriority.OneSecond;
}
protected override void OnTick()
{
m_GaveNews = false;
}
}
public static void SetAnnouncement( string str )
{
m_BroadcastMessage = str;
}
public static void DeleteAnnouncements()
{
m_BroadcastMessage = "Everything is looking fine at the moment. Travel safe.";
}
}
}

View File

@@ -0,0 +1,157 @@
using System;
using Server.Mobiles;
namespace Server.EventSystem
{
public class MonsterTownSpawnEntry
{
#region MonsterSpawnEntries
public static MonsterTownSpawnEntry[] Undead = new MonsterTownSpawnEntry[]
{
//Monster //Amount
new MonsterTownSpawnEntry( typeof( Zombie ), 65 ),
new MonsterTownSpawnEntry( typeof( Skeleton ), 65 ),
new MonsterTownSpawnEntry( typeof( SkeletalMage ), 40 ),
new MonsterTownSpawnEntry( typeof( BoneKnight ), 45 ),
new MonsterTownSpawnEntry( typeof( SkeletalKnight ), 45 ),
new MonsterTownSpawnEntry( typeof( Lich ), 45 ),
new MonsterTownSpawnEntry( typeof( Ghoul ), 40 ),
new MonsterTownSpawnEntry( typeof( BoneMagi ), 40 ),
new MonsterTownSpawnEntry( typeof( Wraith ), 35 ),
new MonsterTownSpawnEntry( typeof( RottingCorpse ), 35 ),
new MonsterTownSpawnEntry( typeof( LichLord ), 35 ),
new MonsterTownSpawnEntry( typeof( Spectre ), 30 ),
new MonsterTownSpawnEntry( typeof( Shade ), 30 ),
new MonsterTownSpawnEntry( typeof( AncientLich ), 30 )
};
public static MonsterTownSpawnEntry[] Humanoid = new MonsterTownSpawnEntry[]
{
//Monster //Amount
new MonsterTownSpawnEntry( typeof( Brigand ), 60 ),
new MonsterTownSpawnEntry( typeof( Executioner ), 30 ),
new MonsterTownSpawnEntry( typeof( EvilMage ), 70 ),
new MonsterTownSpawnEntry( typeof( EvilMageLord ), 40 ),
new MonsterTownSpawnEntry( typeof( Ettin ), 45 ),
new MonsterTownSpawnEntry( typeof( Ogre ), 45 ),
new MonsterTownSpawnEntry( typeof( OgreLord ), 40 ),
new MonsterTownSpawnEntry( typeof( ArcticOgreLord ), 40 ),
new MonsterTownSpawnEntry( typeof( Troll ), 55 ),
new MonsterTownSpawnEntry( typeof( Cyclops ), 55 ),
new MonsterTownSpawnEntry( typeof( Titan ), 40 )
};
public static MonsterTownSpawnEntry[] OrcsandRatmen = new MonsterTownSpawnEntry[]
{
//Monster //Amount
new MonsterTownSpawnEntry( typeof( Orc ), 80 ),
new MonsterTownSpawnEntry( typeof( OrcishMage ), 45 ),
new MonsterTownSpawnEntry( typeof( OrcishLord ), 55 ),
new MonsterTownSpawnEntry( typeof( OrcCaptain ), 50 ),
new MonsterTownSpawnEntry( typeof( OrcBomber ), 55 ),
new MonsterTownSpawnEntry( typeof( OrcBrute ), 40 ),
new MonsterTownSpawnEntry( typeof( Ratman ), 80 ),
new MonsterTownSpawnEntry( typeof( RatmanArcher ), 50 ),
new MonsterTownSpawnEntry( typeof( RatmanMage ), 45 )
};
public static MonsterTownSpawnEntry[] Elementals = new MonsterTownSpawnEntry[]
{
//Monster //Amount
new MonsterTownSpawnEntry( typeof( EarthElemental ), 95 ),
new MonsterTownSpawnEntry( typeof( AirElemental ), 70 ),
new MonsterTownSpawnEntry( typeof( FireElemental ), 60 ),
new MonsterTownSpawnEntry( typeof( WaterElemental ), 60 ),
new MonsterTownSpawnEntry( typeof( SnowElemental ), 40 ),
new MonsterTownSpawnEntry( typeof( IceElemental ), 40 ),
new MonsterTownSpawnEntry( typeof( Efreet ), 45 ),
new MonsterTownSpawnEntry( typeof( PoisonElemental ), 35 ),
new MonsterTownSpawnEntry( typeof( BloodElemental ), 35 )
};
public static MonsterTownSpawnEntry[] OreElementals = new MonsterTownSpawnEntry[]
{
//Monster //Amount
new MonsterTownSpawnEntry( typeof( DullCopperElemental ), 90 ),
new MonsterTownSpawnEntry( typeof( CopperElemental ), 80 ),
new MonsterTownSpawnEntry( typeof( BronzeElemental ), 50 ),
new MonsterTownSpawnEntry( typeof( ShadowIronElemental ), 60 ),
new MonsterTownSpawnEntry( typeof( GoldenElemental ), 55 ),
new MonsterTownSpawnEntry( typeof( AgapiteElemental ), 45 ),
new MonsterTownSpawnEntry( typeof( VeriteElemental ), 40 ),
new MonsterTownSpawnEntry( typeof( ValoriteElemental ), 40 )
};
public static MonsterTownSpawnEntry[] Ophidian = new MonsterTownSpawnEntry[]
{
//Monster //Amount
new MonsterTownSpawnEntry( typeof( OphidianWarrior ), 170 ),
new MonsterTownSpawnEntry( typeof( OphidianMage ), 70 ),
new MonsterTownSpawnEntry( typeof( OphidianArchmage ), 60 ),
new MonsterTownSpawnEntry( typeof( OphidianKnight ), 55 ),
new MonsterTownSpawnEntry( typeof( OphidianMatriarch ), 45 )
};
public static MonsterTownSpawnEntry[] Arachnid = new MonsterTownSpawnEntry[]
{
//Monster //Amount
new MonsterTownSpawnEntry( typeof( Scorpion ), 75 ),
new MonsterTownSpawnEntry( typeof( GiantSpider ), 75 ),
new MonsterTownSpawnEntry( typeof( TerathanDrone ), 75 ),
new MonsterTownSpawnEntry( typeof( TerathanWarrior ), 70 ),
new MonsterTownSpawnEntry( typeof( TerathanMatriarch ), 45 ),
new MonsterTownSpawnEntry( typeof( TerathanAvenger ), 45 ),
new MonsterTownSpawnEntry( typeof( DreadSpider ), 40 ),
new MonsterTownSpawnEntry( typeof( FrostSpider ), 35 )
};
public static MonsterTownSpawnEntry[] Snakes = new MonsterTownSpawnEntry[]
{
//Monster //Amount
new MonsterTownSpawnEntry( typeof( Snake ), 95 ),
new MonsterTownSpawnEntry( typeof( GiantSerpent ), 95 ),
new MonsterTownSpawnEntry( typeof( LavaSnake ), 50 ),
new MonsterTownSpawnEntry( typeof( LavaSerpent ), 55 ),
new MonsterTownSpawnEntry( typeof( IceSnake ), 50 ),
new MonsterTownSpawnEntry( typeof( IceSerpent ), 55 ),
new MonsterTownSpawnEntry( typeof( SilverSerpent ), 40 )
};
public static MonsterTownSpawnEntry[] Abyss = new MonsterTownSpawnEntry[]
{
//Monster //Amount
new MonsterTownSpawnEntry( typeof( Gargoyle ), 160 ),
new MonsterTownSpawnEntry( typeof( StoneGargoyle ), 60 ),
new MonsterTownSpawnEntry( typeof( FireGargoyle ), 60 ),
new MonsterTownSpawnEntry( typeof( Daemon ), 60 ),
new MonsterTownSpawnEntry( typeof( IceFiend ), 50 ),
new MonsterTownSpawnEntry( typeof( Balron ), 30 )
};
public static MonsterTownSpawnEntry[] DragonKind = new MonsterTownSpawnEntry[]
{
//Monster //Amount
new MonsterTownSpawnEntry( typeof( Wyvern ), 160 ),
new MonsterTownSpawnEntry( typeof( Drake ), 60 ),
new MonsterTownSpawnEntry( typeof( Dragon ), 60 ),
new MonsterTownSpawnEntry( typeof( WhiteWyrm ), 60 ),
new MonsterTownSpawnEntry( typeof( ShadowWyrm ), 50 ),
new MonsterTownSpawnEntry( typeof( AncientWyrm ), 30 )
};
#endregion
private Type m_Monster;
private int m_Amount;
public Type Monster { get { return m_Monster; } set { m_Monster = value; } }
public int Amount { get { return m_Amount; } set { m_Amount = value; } }
public MonsterTownSpawnEntry( Type monster, int amount )
{
m_Monster = monster;
m_Amount = amount;
}
}
}

View File

@@ -0,0 +1,507 @@
using System;
using System.Collections.Generic;
using Server.Mobiles;
using Server.Regions;
using Server.Misc;
using Server.Commands;
namespace Server.EventSystem
{
public class TownInvasion : BaseEvent
{
public static TimeSpan m_TIEventRate = TimeSpan.FromHours( 12.0 );
#region Private Variables
private int m_MinSpawnZ;
private int m_MaxSpawnZ;
private int m_LastMsg;
private bool m_Broadcast = true;
private bool m_FinalStage;
private Point3D m_Top = new Point3D(4394, 1058, 30);
private Point3D m_Bottom = new Point3D(4481, 1173, 0);
private Map m_SpawnMap = Map.Felucca;
private List<Mobile> m_Spawned;
private TownMonsterType m_TownMonsterType = TownMonsterType.OrcsandRatmen;
private TownChampionType m_TownChampionType = TownChampionType.Barracoon;
private double m_ParagonChance = 0.05;
private bool m_AlwaysMurderer = false;
private bool m_IsRunning;
private DateTime m_TimeNextScheduledEvent = DateTime.MinValue;
private DateTime m_TimeLastEvent = DateTime.MinValue;
private string m_TownInvaded = "Moonglow";
#endregion
#region Public Variables
[CommandProperty( AccessLevel.Administrator )]
public int MinSpawnZ { get { return m_MinSpawnZ; } set { m_MinSpawnZ = value; } }
[CommandProperty( AccessLevel.Administrator )]
public int MaxSpawnZ { get { return m_MaxSpawnZ; } set { m_MaxSpawnZ = value; } }
[CommandProperty( AccessLevel.GameMaster )]
public bool Broadcast { get { return m_Broadcast; } set { m_Broadcast = value; } }
[CommandProperty( AccessLevel.Administrator )]
public Point3D Top { get { return m_Top; } set { m_Top = value; } }
[CommandProperty( AccessLevel.Administrator )]
public Point3D Bottom { get { return m_Bottom; } set { m_Bottom = value; } }
[CommandProperty( AccessLevel.Administrator )]
public Map SpawnMap { get { return m_SpawnMap; } set { m_SpawnMap = value; } }
public List<Mobile> Spawned { get { return m_Spawned; } set { m_Spawned = value; } }
[CommandProperty( AccessLevel.GameMaster )]
public TownMonsterType TownMonsterType { get { return m_TownMonsterType; } set { m_TownMonsterType = value; } }
[CommandProperty( AccessLevel.GameMaster )]
public TownChampionType TownChampionType { get { return m_TownChampionType; } set { m_TownChampionType = value; } }
[CommandProperty( AccessLevel.GameMaster )]
public double ParagonChance { get { return m_ParagonChance; } set { m_ParagonChance = value; } }
[CommandProperty( AccessLevel.GameMaster )]
public bool AlwaysMurderer { get { return m_AlwaysMurderer; } set { m_AlwaysMurderer = value; } }
[CommandProperty( AccessLevel.GameMaster )]
public bool IsRunning { get { return m_IsRunning; } set { m_IsRunning = value; } }
[CommandProperty( AccessLevel.GameMaster, true )]
public DateTime TimeNextScheduledEvent { get { return m_TimeNextScheduledEvent; } set { m_TimeNextScheduledEvent = value; } }
[CommandProperty( AccessLevel.GameMaster, true )]
public DateTime TimeLastEvent { get { return m_TimeLastEvent; } set { m_TimeLastEvent = value; } }
[CommandProperty( AccessLevel.GameMaster )]
public TimeSpan TIEventRate { get { return m_TIEventRate; } set { m_TIEventRate = value; } }
[CommandProperty( AccessLevel.GameMaster )]
public string TownInvaded { get { return m_TownInvaded; } set { m_TownInvaded = value; } }
#endregion
#region Property Overrides
public override EventType EventType { get { return EventType.TownInvasion; } }
public override string EventName { get { return "Town Invasion"; } }
public override TimeSpan TimerFrequency { get { return TimeSpan.FromSeconds( 1.0 ); } }
public override Map StartingMap { get { return Map.Felucca; } }
public override Point3D StartingLocation { get { return new Point3D(6804, 2233, 0); } }
#endregion
#region Constructor
public TownInvasion()
{
m_Spawned = new List<Mobile>();
}
#endregion
#region Method Overrides
protected override void OnEnable()
{
}
protected override void OnDisable()
{
}
public override void OnStart()
{
if( !this.IsRunning )
{
switch( Utility.Random(6) )
{
/*case 0: //Britain Doesn't Get Invaded Anymore
{
this.Top = new Point3D(1426, 1554, 30);
this.Bottom = new Point3D(1490, 1735, 0);
this.MinSpawnZ = 0;
this.MaxSpawnZ = 31;
this.SpawnMap = Map.Felucca;
this.TownInvaded = "Britain";
this.TownMonsterType = TownMonsterType.OrcsandRatmen;
this.TownChampionType = TownChampionType.Barracoon;
break;
}*/
case 0: //Moonglow
{
this.Top = new Point3D(4394, 1058, 30);
this.Bottom = new Point3D(4481, 1173, 0);
this.MinSpawnZ = 0;
this.MaxSpawnZ = 31;
this.SpawnMap = Map.Felucca;
this.TownInvaded = "Moonglow";
this.TownMonsterType = TownMonsterType.Abyss;
this.TownChampionType = TownChampionType.Rikktor;
break;
}
case 1: //Minoc
{
this.Top = new Point3D(2443, 420, 15);
this.Bottom = new Point3D(2520, 539, 0);
this.MinSpawnZ = 0;
this.MaxSpawnZ = 16;
this.SpawnMap = Map.Felucca;
this.TownInvaded = "Minoc";
this.TownMonsterType = TownMonsterType.OreElementals;
this.TownChampionType = TownChampionType.LordOaks;
break;
}
case 2: //Delucia
{
this.Top = new Point3D(5171, 3980, 41);
this.Bottom = new Point3D(5300, 4040, 39);
this.MinSpawnZ = 39;
this.MaxSpawnZ = 42;
this.SpawnMap = Map.Felucca;
this.TownInvaded = "Delucia";
this.TownMonsterType = TownMonsterType.Ophidian;
this.TownChampionType = TownChampionType.Mephitis;
break;
}
case 3: //Ocllo
{
this.Top = new Point3D(3617, 2482, 0);
this.Bottom = new Point3D(3712, 2630, 20);
this.MinSpawnZ = 0;
this.MaxSpawnZ = 21;
this.SpawnMap = Map.Felucca;
this.TownInvaded = "Ocllo";
this.TownMonsterType = TownMonsterType.Elementals;
this.TownChampionType = TownChampionType.Semidar;
break;
}
case 4: //Skara Brae
{
this.Top = new Point3D(577, 2131, -90);
this.Bottom = new Point3D(634, 2234, -90);
this.MinSpawnZ = 0;
this.MaxSpawnZ = 1;
this.SpawnMap = Map.Felucca;
this.TownInvaded = "Skara Brae";
this.TownMonsterType = TownMonsterType.Humanoid;
this.TownChampionType = TownChampionType.Serado;
break;
}
case 5: //Yew
{
this.Top = new Point3D(457, 913, 30);
this.Bottom = new Point3D(662, 1117, 0);
this.MinSpawnZ = 0;
this.MaxSpawnZ = 0;
this.SpawnMap = Map.Felucca;
this.TownInvaded = "Yew";
this.TownMonsterType = TownMonsterType.OrcsandRatmen;
this.TownChampionType = TownChampionType.Barracoon;
break;
}
}
foreach ( Region r in Region.Regions )
{
if ( r is GuardedRegion && r.Name == this.TownInvaded )
{
((GuardedRegion)r).Disabled = true;
}
}
Spawn();
this.m_TimeLastEvent = DateTime.Now;
this.m_TimeNextScheduledEvent = DateTime.Now + TIEventRate;
//World.Broadcast( 0x35, true, "{0} is being invaded! The guards have fled! Help save it's citzens!", this.m_TownInvaded);
string bc = this.m_TownInvaded + " is being invaded! The guards have fled! Help save it's citizens!";
Server.Mobiles.InvasionAnnouncer.SetAnnouncement( bc );
this.IsRunning = true;
}
}
protected override void OnStop()
{
Despawn();
foreach ( Region r in Region.Regions )
{
if ( r is GuardedRegion && r.Name == this.TownInvaded )
{
((GuardedRegion)r).Disabled = false;
}
}
Server.Mobiles.InvasionAnnouncer.DeleteAnnouncements();
this.IsRunning = false; //it's not running anymore
}
public override void OnTick( int ticks )
{
int count = 0;
for ( int i = 0; i < m_Spawned.Count; ++i )
if ( m_Spawned[i] != null && !m_Spawned[i].Deleted && m_Spawned[i].Alive )
++count;
if ( !m_FinalStage ) //Monsters
{
if ( count == 0 ) //All monsters have been slayed
SpawnChamp();
}
else //Champion
{
if ( count == 0 ) //Champion is dead
{
if ( m_Broadcast )
Announce( 1161, "The city of {0} has been saved and the guards have returned to their posts. The citizens of {1} thank you!", m_TownInvaded, m_TownInvaded );
Stop();
}
}
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int)3 ); //version
//v 3
writer.Write( m_Spawned, true );
// v 2
writer.Write( m_IsRunning );
// v 1
writer.Write( m_ParagonChance );
writer.Write( m_AlwaysMurderer );
writer.Write( m_TimeNextScheduledEvent );
writer.Write( m_TimeLastEvent );
writer.Write( m_TIEventRate );
// v 0
writer.Write( m_MinSpawnZ );
writer.Write( m_MaxSpawnZ );
writer.Write( m_Broadcast );
writer.Write( m_Top );
writer.Write( m_Bottom );
writer.Write( m_SpawnMap );
writer.WriteEncodedInt( (int)m_TownMonsterType );
writer.WriteEncodedInt( (int)m_TownChampionType );
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
switch ( version )
{
case 3:
{
m_Spawned = reader.ReadStrongMobileList();
goto case 2;
}
case 2:
{
m_IsRunning = reader.ReadBool();
goto case 1;
}
case 1:
{
m_ParagonChance = reader.ReadDouble();
m_AlwaysMurderer = reader.ReadBool();
m_TimeNextScheduledEvent = reader.ReadDateTime();
m_TimeLastEvent = reader.ReadDateTime();
m_TIEventRate = reader.ReadTimeSpan();
goto case 0;
}
case 0:
{
m_MinSpawnZ = reader.ReadInt();
m_MaxSpawnZ = reader.ReadInt();
m_Broadcast = reader.ReadBool();
m_Top = reader.ReadPoint3D();
m_Bottom = reader.ReadPoint3D();
m_SpawnMap = reader.ReadMap();
m_TownMonsterType = (TownMonsterType)reader.ReadEncodedInt();
m_TownChampionType = (TownChampionType)reader.ReadEncodedInt();
break;
}
}
OnStop();
m_IsRunning = false;
//m_Spawned = new List<Mobile>();
}
#endregion
#region Private Methods
private void Spawn()
{
Despawn();
MonsterTownSpawnEntry[] entries = null;
switch ( m_TownMonsterType )
{
default:
case TownMonsterType.Abyss: entries = MonsterTownSpawnEntry.Abyss; break;
case TownMonsterType.Arachnid: entries = MonsterTownSpawnEntry.Arachnid; break;
case TownMonsterType.DragonKind: entries = MonsterTownSpawnEntry.DragonKind; break;
case TownMonsterType.Elementals: entries = MonsterTownSpawnEntry.Elementals; break;
case TownMonsterType.Humanoid: entries = MonsterTownSpawnEntry.Humanoid; break;
case TownMonsterType.Ophidian: entries = MonsterTownSpawnEntry.Ophidian; break;
case TownMonsterType.OrcsandRatmen: entries = MonsterTownSpawnEntry.OrcsandRatmen; break;
case TownMonsterType.OreElementals: entries = MonsterTownSpawnEntry.OreElementals; break;
case TownMonsterType.Snakes: entries = MonsterTownSpawnEntry.Snakes; break;
case TownMonsterType.Undead: entries = MonsterTownSpawnEntry.Undead; break;
}
for ( int i = 0; i < entries.Length; ++i )
for ( int count = 0; count < entries[i].Amount; ++count )
AddMonster( entries[i].Monster );
}
private void Despawn()
{
foreach ( Mobile m in m_Spawned )
if ( m != null && !m.Deleted )
m.Delete();
m_Spawned.Clear();
m_FinalStage = false;
}
private Point3D FindSpawnLocation()
{
int x, y, z;
do
{
x = Utility.Random( m_Top.X, ( m_Bottom.X - m_Top.X ) );
y = Utility.Random( m_Top.Y, ( m_Bottom.Y - m_Top.Y ) );
z = SpawnMap.GetAverageZ( x, y );
}
while ( !SpawnMap.CanSpawnMobile( x, y, z ) );
return new Point3D( x, y, z );
}
private void AddMonster( Type type )
{
object monster = Activator.CreateInstance( type );
if ( monster != null && monster is Mobile )
{
Point3D location = FindSpawnLocation();
Mobile from = (Mobile)monster;
if ( m_FinalStage )
{
Announce( 1161, "{0} has come to take over {1}! Please save it's citizens!", from.Name, m_TownInvaded );
//TODO: Pack Goodies
}
from.MoveToWorld( location, SpawnMap );
if ( from is BaseCreature )
{
( (BaseCreature)from ).Tamable = false;
if ( !(from is BaseChampion) && !(from is Harrower) && !(from is BaseVendor) && !(from is BaseEscortable) && !(from is Clone) )
{
//if( Utility.RandomDouble() < m_ParagonChance )
//( (BaseCreature)from ).IsParagon = true;
if( m_AlwaysMurderer )
( (BaseCreature)from ).Kills = 6;
}
}
m_Spawned.Add( from );
}
}
public void SpawnChamp()
{
Despawn();
m_FinalStage = true;
switch ( m_TownChampionType )
{
default:
case TownChampionType.Barracoon: AddMonster( typeof( Barracoon ) ); break;
case TownChampionType.Harrower: AddMonster( typeof( Harrower ) ); break;
case TownChampionType.LordOaks: AddMonster( typeof( LordOaks ) ); break;
case TownChampionType.Mephitis: AddMonster( typeof( Mephitis ) ); break;
case TownChampionType.Neira: AddMonster( typeof( Neira ) ); break;
case TownChampionType.Rikktor: AddMonster( typeof( Rikktor ) ); break;
case TownChampionType.Semidar: AddMonster( typeof( Semidar ) ); break;
case TownChampionType.Serado: AddMonster( typeof( Serado ) ); break;
}
}
#endregion
}
public class TIWorldTimer : Timer
{
public static void Initialize()
{
new TIWorldTimer().Start();
}
public TIWorldTimer() : base( TownInvasion.m_TIEventRate, TownInvasion.m_TIEventRate )
{
Priority = TimerPriority.OneMinute;
}
protected override void OnTick()
{
BaseEvent evnt = Server.EventSystem.EventCore.FindEvent( EventType.TownInvasion );
if( evnt != null ) //don't run a new one if one is running already.
{
evnt.Start();
}
}
}
}

View File

@@ -0,0 +1,765 @@
using System;
using System.Reflection;
using System.Collections;
using Server;
using Server.Commands.Generic;
using Server.Gumps;
using Server.Network;
using Server.Menus;
using Server.Menus.Questions;
using Server.Targeting;
using CPA = Server.CommandPropertyAttribute;
namespace Server.EventSystem
{
public class EventPropertiesGump : Gump
{
private ArrayList m_List;
private int m_Page;
private Mobile m_Mobile;
private object m_Object;
private Stack m_Stack;
public static readonly bool OldStyle = PropsConfig.OldStyle;
public static readonly int GumpOffsetX = PropsConfig.GumpOffsetX;
public static readonly int GumpOffsetY = PropsConfig.GumpOffsetY;
public static readonly int TextHue = PropsConfig.TextHue;
public static readonly int TextOffsetX = PropsConfig.TextOffsetX;
public static readonly int OffsetGumpID = PropsConfig.OffsetGumpID;
public static readonly int HeaderGumpID = PropsConfig.HeaderGumpID;
public static readonly int EntryGumpID = PropsConfig.EntryGumpID;
public static readonly int BackGumpID = PropsConfig.BackGumpID;
public static readonly int SetGumpID = PropsConfig.SetGumpID;
public static readonly int SetWidth = PropsConfig.SetWidth;
public static readonly int SetOffsetX = PropsConfig.SetOffsetX, SetOffsetY = PropsConfig.SetOffsetY;
public static readonly int SetButtonID1 = PropsConfig.SetButtonID1;
public static readonly int SetButtonID2 = PropsConfig.SetButtonID2;
public static readonly int PrevWidth = PropsConfig.PrevWidth;
public static readonly int PrevOffsetX = PropsConfig.PrevOffsetX, PrevOffsetY = PropsConfig.PrevOffsetY;
public static readonly int PrevButtonID1 = PropsConfig.PrevButtonID1;
public static readonly int PrevButtonID2 = PropsConfig.PrevButtonID2;
public static readonly int NextWidth = PropsConfig.NextWidth;
public static readonly int NextOffsetX = PropsConfig.NextOffsetX, NextOffsetY = PropsConfig.NextOffsetY;
public static readonly int NextButtonID1 = PropsConfig.NextButtonID1;
public static readonly int NextButtonID2 = PropsConfig.NextButtonID2;
public static readonly int OffsetSize = PropsConfig.OffsetSize;
public static readonly int EntryHeight = PropsConfig.EntryHeight;
public static readonly int BorderSize = PropsConfig.BorderSize;
private static bool PrevLabel = OldStyle, NextLabel = OldStyle;
private static readonly int PrevLabelOffsetX = PrevWidth + 1;
private static readonly int PrevLabelOffsetY = 0;
private static readonly int NextLabelOffsetX = -29;
private static readonly int NextLabelOffsetY = 0;
private static readonly int NameWidth = 107;
private static readonly int ValueWidth = 128;
private static readonly int EntryCount = 15;
private static readonly int TypeWidth = NameWidth + OffsetSize + ValueWidth;
private static readonly int TotalWidth = OffsetSize + NameWidth + OffsetSize + ValueWidth + OffsetSize + SetWidth + OffsetSize;
private static readonly int TotalHeight = OffsetSize + ( ( EntryHeight + OffsetSize ) * ( EntryCount + 1 ) );
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize;
public EventPropertiesGump( Mobile mobile, object o )
: base( GumpOffsetX, GumpOffsetY )
{
m_Mobile = mobile;
m_Object = o;
m_List = BuildList();
Initialize( 0 );
}
public EventPropertiesGump( Mobile mobile, object o, Stack stack, StackEntry parent )
: base( GumpOffsetX, GumpOffsetY )
{
m_Mobile = mobile;
m_Object = o;
m_Stack = stack;
m_List = BuildList();
if ( parent != null )
{
if ( m_Stack == null )
m_Stack = new Stack();
m_Stack.Push( parent );
}
Initialize( 0 );
}
public EventPropertiesGump( Mobile mobile, object o, Stack stack, ArrayList list, int page )
: base( GumpOffsetX, GumpOffsetY )
{
m_Mobile = mobile;
m_Object = o;
m_List = list;
m_Stack = stack;
Initialize( page );
}
private void Initialize( int page )
{
m_Page = page;
int count = m_List.Count - ( page * EntryCount );
if ( count < 0 )
count = 0;
else if ( count > EntryCount )
count = EntryCount;
int lastIndex = ( page * EntryCount ) + count - 1;
if ( lastIndex >= 0 && lastIndex < m_List.Count && m_List[lastIndex] == null )
--count;
int totalHeight = OffsetSize + ( ( EntryHeight + OffsetSize ) * ( count + 1 ) );
AddPage( 0 );
AddBackground( 0, 0, BackWidth, BorderSize + totalHeight + BorderSize, BackGumpID );
AddImageTiled( BorderSize, BorderSize, TotalWidth - ( OldStyle ? SetWidth + OffsetSize : 0 ), totalHeight, OffsetGumpID );
int x = BorderSize + OffsetSize;
int y = BorderSize + OffsetSize;
int emptyWidth = TotalWidth - PrevWidth - NextWidth - ( OffsetSize * 4 ) - ( OldStyle ? SetWidth + OffsetSize : 0 );
if ( OldStyle )
AddImageTiled( x, y, TotalWidth - ( OffsetSize * 3 ) - SetWidth, EntryHeight, HeaderGumpID );
else
AddImageTiled( x, y, PrevWidth, EntryHeight, HeaderGumpID );
if ( page > 0 )
{
AddButton( x + PrevOffsetX, y + PrevOffsetY, PrevButtonID1, PrevButtonID2, 1, GumpButtonType.Reply, 0 );
if ( PrevLabel )
AddLabel( x + PrevLabelOffsetX, y + PrevLabelOffsetY, TextHue, "Previous" );
}
x += PrevWidth + OffsetSize;
if ( !OldStyle )
AddImageTiled( x - ( OldStyle ? OffsetSize : 0 ), y, emptyWidth + ( OldStyle ? OffsetSize * 2 : 0 ), EntryHeight, HeaderGumpID );
x += emptyWidth + OffsetSize;
if ( !OldStyle )
AddImageTiled( x, y, NextWidth, EntryHeight, HeaderGumpID );
if ( ( page + 1 ) * EntryCount < m_List.Count )
{
AddButton( x + NextOffsetX, y + NextOffsetY, NextButtonID1, NextButtonID2, 2, GumpButtonType.Reply, 1 );
if ( NextLabel )
AddLabel( x + NextLabelOffsetX, y + NextLabelOffsetY, TextHue, "Next" );
}
for ( int i = 0, index = page * EntryCount; i < count && index < m_List.Count; ++i, ++index )
{
x = BorderSize + OffsetSize;
y += EntryHeight + OffsetSize;
object o = m_List[index];
if ( o == null )
{
AddImageTiled( x - OffsetSize, y, TotalWidth, EntryHeight, BackGumpID + 4 );
}
else if ( o is Type )
{
Type type = (Type)o;
AddImageTiled( x, y, TypeWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, TypeWidth - TextOffsetX, EntryHeight, TextHue, type.Name );
x += TypeWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
}
else if ( o is PropertyInfo )
{
PropertyInfo prop = (PropertyInfo)o;
AddImageTiled( x, y, NameWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, NameWidth - TextOffsetX, EntryHeight, TextHue, prop.Name );
x += NameWidth + OffsetSize;
AddImageTiled( x, y, ValueWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, ValueWidth - TextOffsetX, EntryHeight, TextHue, ValueToString( prop ) );
x += ValueWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
CPA cpa = GetCPA( prop );
if ( prop.CanWrite && cpa != null && m_Mobile.AccessLevel >= cpa.WriteLevel && !cpa.ReadOnly )
AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, i + 3, GumpButtonType.Reply, 0 );
}
}
}
public static string[] m_BoolNames = new string[] { "True", "False" };
public static object[] m_BoolValues = new object[] { true, false };
public static string[] m_PoisonNames = new string[] { "None", "Lesser", "Regular", "Greater", "Deadly", "Lethal" };
public static object[] m_PoisonValues = new object[] { null, Poison.Lesser, Poison.Regular, Poison.Greater, Poison.Deadly, Poison.Lethal };
public class StackEntry
{
public object m_Object;
public PropertyInfo m_Property;
public StackEntry( object obj, PropertyInfo prop )
{
m_Object = obj;
m_Property = prop;
}
}
public override void OnResponse( NetState state, RelayInfo info )
{
Mobile from = state.Mobile;
if ( !BaseCommand.IsAccessible( from, m_Object ) )
{
from.SendMessage( "You may no longer access their properties." );
return;
}
switch ( info.ButtonID )
{
case 0: // Closed
{
if ( m_Stack != null && m_Stack.Count > 0 )
{
StackEntry entry = (StackEntry)m_Stack.Pop();
from.SendGump( new EventPropertiesGump( from, entry.m_Object, m_Stack, null ) );
}
break;
}
case 1: // Previous
{
if ( m_Page > 0 )
from.SendGump( new EventPropertiesGump( from, m_Object, m_Stack, m_List, m_Page - 1 ) );
break;
}
case 2: // Next
{
if ( ( m_Page + 1 ) * EntryCount < m_List.Count )
from.SendGump( new EventPropertiesGump( from, m_Object, m_Stack, m_List, m_Page + 1 ) );
break;
}
default:
{
int index = ( m_Page * EntryCount ) + ( info.ButtonID - 3 );
if ( index >= 0 && index < m_List.Count )
{
PropertyInfo prop = m_List[index] as PropertyInfo;
if ( prop == null )
return;
CPA attr = GetCPA( prop );
if ( !prop.CanWrite || attr == null || from.AccessLevel < attr.WriteLevel || attr.ReadOnly )
return;
Type type = prop.PropertyType;
if ( IsType( type, typeofMobile ) || IsType( type, typeofItem ) )
from.SendGump( new EventSetObjectGump( prop, from, m_Object, m_Stack, type, m_Page, m_List ) );
else if ( IsType( type, typeofType ) )
from.Target = new EventSetObjectTarget( prop, from, m_Object, m_Stack, type, m_Page, m_List );
else if ( IsType( type, typeofPoint3D ) )
from.SendGump( new EventSetPoint3DGump( prop, from, m_Object, m_Stack, m_Page, m_List ) );
else if ( IsType( type, typeofPoint2D ) )
from.SendGump( new EventSetPoint2DGump( prop, from, m_Object, m_Stack, m_Page, m_List ) );
else if ( IsType( type, typeofTimeSpan ) )
from.SendGump( new EventSetTimeSpanGump( prop, from, m_Object, m_Stack, m_Page, m_List ) );
else if ( IsCustomEnum( type ) )
from.SendGump( new EventSetCustomEnumGump( prop, from, m_Object, m_Stack, m_Page, m_List, GetCustomEnumNames( type ) ) );
else if ( IsType( type, typeofEnum ) )
from.SendGump( new EventSetListOptionGump( prop, from, m_Object, m_Stack, m_Page, m_List, Enum.GetNames( type ), GetObjects( Enum.GetValues( type ) ) ) );
else if ( IsType( type, typeofBool ) )
from.SendGump( new EventSetListOptionGump( prop, from, m_Object, m_Stack, m_Page, m_List, m_BoolNames, m_BoolValues ) );
else if ( IsType( type, typeofString ) || IsType( type, typeofReal ) || IsType( type, typeofNumeric ) )
from.SendGump( new EventSetGump( prop, from, m_Object, m_Stack, m_Page, m_List ) );
else if ( IsType( type, typeofPoison ) )
from.SendGump( new EventSetListOptionGump( prop, from, m_Object, m_Stack, m_Page, m_List, m_PoisonNames, m_PoisonValues ) );
else if ( IsType( type, typeofMap ) )
from.SendGump( new EventSetListOptionGump( prop, from, m_Object, m_Stack, m_Page, m_List, Map.GetMapNames(), Map.GetMapValues() ) );
else if ( IsType( type, typeofSkills ) && m_Object is Mobile )
{
from.SendGump( new EventPropertiesGump( from, m_Object, m_Stack, m_List, m_Page ) );
from.SendGump( new SkillsGump( from, (Mobile)m_Object ) );
}
else if ( HasAttribute( type, typeofPropertyObject, true ) )
{
object obj = prop.GetValue( m_Object, null );
if ( obj != null )
from.SendGump( new EventPropertiesGump( from, obj, m_Stack, new StackEntry( m_Object, prop ) ) );
else
from.SendGump( new EventPropertiesGump( from, m_Object, m_Stack, m_List, m_Page ) );
}
}
break;
}
}
}
private static object[] GetObjects( Array a )
{
object[] list = new object[a.Length];
for ( int i = 0; i < list.Length; ++i )
list[i] = a.GetValue( i );
return list;
}
private static bool IsCustomEnum( Type type )
{
return type.IsDefined( typeofCustomEnum, false );
}
public static void OnValueChanged( object obj, PropertyInfo prop, Stack stack )
{
if ( stack == null || stack.Count == 0 )
return;
if ( !prop.PropertyType.IsValueType )
return;
StackEntry peek = (StackEntry)stack.Peek();
if ( peek.m_Property.CanWrite )
peek.m_Property.SetValue( peek.m_Object, obj, null );
}
private static string[] GetCustomEnumNames( Type type )
{
object[] attrs = type.GetCustomAttributes( typeofCustomEnum, false );
if ( attrs.Length == 0 )
return new string[0];
CustomEnumAttribute ce = attrs[0] as CustomEnumAttribute;
if ( ce == null )
return new string[0];
return ce.Names;
}
private static bool HasAttribute( Type type, Type check, bool inherit )
{
object[] objs = type.GetCustomAttributes( check, inherit );
return ( objs != null && objs.Length > 0 );
}
private static bool IsType( Type type, Type check )
{
return type == check || type.IsSubclassOf( check );
}
private static bool IsType( Type type, Type[] check )
{
for ( int i = 0; i < check.Length; ++i )
if ( IsType( type, check[i] ) )
return true;
return false;
}
private static Type typeofMobile = typeof( Mobile );
private static Type typeofItem = typeof( Item );
private static Type typeofType = typeof( Type );
private static Type typeofPoint3D = typeof( Point3D );
private static Type typeofPoint2D = typeof( Point2D );
private static Type typeofTimeSpan = typeof( TimeSpan );
private static Type typeofCustomEnum = typeof( CustomEnumAttribute );
private static Type typeofEnum = typeof( Enum );
private static Type typeofBool = typeof( Boolean );
private static Type typeofString = typeof( String );
private static Type typeofPoison = typeof( Poison );
private static Type typeofMap = typeof( Map );
private static Type typeofSkills = typeof( Skills );
private static Type typeofPropertyObject = typeof( PropertyObjectAttribute );
private static Type typeofNoSort = typeof( NoSortAttribute );
private static Type[] typeofReal = new Type[]
{
typeof( Single ),
typeof( Double )
};
private static Type[] typeofNumeric = new Type[]
{
typeof( Byte ),
typeof( Int16 ),
typeof( Int32 ),
typeof( Int64 ),
typeof( SByte ),
typeof( UInt16 ),
typeof( UInt32 ),
typeof( UInt64 )
};
private string ValueToString( PropertyInfo prop )
{
return ValueToString( m_Object, prop );
}
public static string ValueToString( object obj, PropertyInfo prop )
{
try
{
return ValueToString( prop.GetValue( obj, null ) );
}
catch ( Exception e )
{
return String.Format( "!{0}!", e.GetType() );
}
}
public static string ValueToString( object o )
{
if ( o == null )
{
return "-null-";
}
else if ( o is string )
{
return String.Format( "\"{0}\"", (string)o );
}
else if ( o is bool )
{
return o.ToString();
}
else if ( o is char )
{
return String.Format( "0x{0:X} '{1}'", (int)(char)o, (char)o );
}
else if ( o is Serial )
{
Serial s = (Serial)o;
if ( s.IsValid )
{
if ( s.IsItem )
{
return String.Format( "(I) 0x{0:X}", s.Value );
}
else if ( s.IsMobile )
{
return String.Format( "(M) 0x{0:X}", s.Value );
}
}
return String.Format( "(?) 0x{0:X}", s.Value );
}
else if ( o is byte || o is sbyte || o is short || o is ushort || o is int || o is uint || o is long || o is ulong )
{
return String.Format( "{0} (0x{0:X})", o );
}
else if ( o is Mobile )
{
return String.Format( "(M) 0x{0:X} \"{1}\"", ( (Mobile)o ).Serial.Value, ( (Mobile)o ).Name );
}
else if ( o is Item )
{
return String.Format( "(I) 0x{0:X}", ( (Item)o ).Serial );
}
else if ( o is Type )
{
return ( (Type)o ).Name;
}
else
{
return o.ToString();
}
}
private ArrayList BuildList()
{
Type type = m_Object.GetType();
PropertyInfo[] props = type.GetProperties( BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public );
ArrayList groups = GetGroups( type, props );
ArrayList list = new ArrayList();
for ( int i = 0; i < groups.Count; ++i )
{
DictionaryEntry de = (DictionaryEntry)groups[i];
ArrayList groupList = (ArrayList)de.Value;
if ( !HasAttribute( (Type)de.Key, typeofNoSort, false ) )
groupList.Sort( PropertySorter.Instance );
if ( i != 0 )
list.Add( null );
list.Add( de.Key );
list.AddRange( groupList );
}
return list;
}
private static Type typeofCPA = typeof( CPA );
private static Type typeofObject = typeof( object );
private static CPA GetCPA( PropertyInfo prop )
{
object[] attrs = prop.GetCustomAttributes( typeofCPA, false );
if ( attrs.Length > 0 )
return attrs[0] as CPA;
else
return null;
}
private ArrayList GetGroups( Type objectType, PropertyInfo[] props )
{
Hashtable groups = new Hashtable();
for ( int i = 0; i < props.Length; ++i )
{
PropertyInfo prop = props[i];
if ( prop.CanRead )
{
CPA attr = GetCPA( prop );
if ( attr != null && m_Mobile.AccessLevel >= attr.ReadLevel )
{
Type type = prop.DeclaringType;
while ( true )
{
Type baseType = type.BaseType;
if ( baseType == null || baseType == typeofObject )
break;
if ( baseType.GetProperty( prop.Name, prop.PropertyType ) != null )
type = baseType;
else
break;
}
ArrayList list = (ArrayList)groups[type];
if ( list == null )
groups[type] = list = new ArrayList();
list.Add( prop );
}
}
}
ArrayList sorted = new ArrayList( groups );
sorted.Sort( new GroupComparer( objectType ) );
return sorted;
}
public static object GetObjectFromString( Type t, string s )
{
if ( t == typeof( string ) )
{
return s;
}
else if ( t == typeof( byte ) || t == typeof( sbyte ) || t == typeof( short ) || t == typeof( ushort ) || t == typeof( int ) || t == typeof( uint ) || t == typeof( long ) || t == typeof( ulong ) )
{
if ( s.StartsWith( "0x" ) )
{
if ( t == typeof( ulong ) || t == typeof( uint ) || t == typeof( ushort ) || t == typeof( byte ) )
{
return Convert.ChangeType( Convert.ToUInt64( s.Substring( 2 ), 16 ), t );
}
else
{
return Convert.ChangeType( Convert.ToInt64( s.Substring( 2 ), 16 ), t );
}
}
else
{
return Convert.ChangeType( s, t );
}
}
else if ( t == typeof( double ) || t == typeof( float ) )
{
return Convert.ChangeType( s, t );
}
else if ( t.IsDefined( typeof( ParsableAttribute ), false ) )
{
MethodInfo parseMethod = t.GetMethod( "Parse", new Type[] { typeof( string ) } );
return parseMethod.Invoke( null, new object[] { s } );
}
throw new Exception( "bad" );
}
private static string GetStringFromObject( object o )
{
if ( o == null )
{
return "-null-";
}
else if ( o is string )
{
return String.Format( "\"{0}\"", (string)o );
}
else if ( o is bool )
{
return o.ToString();
}
else if ( o is char )
{
return String.Format( "0x{0:X} '{1}'", (int)(char)o, (char)o );
}
else if ( o is Serial )
{
Serial s = (Serial)o;
if ( s.IsValid )
{
if ( s.IsItem )
{
return String.Format( "(I) 0x{0:X}", s.Value );
}
else if ( s.IsMobile )
{
return String.Format( "(M) 0x{0:X}", s.Value );
}
}
return String.Format( "(?) 0x{0:X}", s.Value );
}
else if ( o is byte || o is sbyte || o is short || o is ushort || o is int || o is uint || o is long || o is ulong )
{
return String.Format( "{0} (0x{0:X})", o );
}
else if ( o is Mobile )
{
return String.Format( "(M) 0x{0:X} \"{1}\"", ( (Mobile)o ).Serial.Value, ( (Mobile)o ).Name );
}
else if ( o is Item )
{
return String.Format( "(I) 0x{0:X}", ( (Item)o ).Serial );
}
else if ( o is Type )
{
return ( (Type)o ).Name;
}
else
{
return o.ToString();
}
}
private class PropertySorter : IComparer
{
public static readonly PropertySorter Instance = new PropertySorter();
private PropertySorter()
{
}
public int Compare( object x, object y )
{
if ( x == null && y == null )
return 0;
else if ( x == null )
return -1;
else if ( y == null )
return 1;
PropertyInfo a = x as PropertyInfo;
PropertyInfo b = y as PropertyInfo;
if ( a == null || b == null )
throw new ArgumentException();
return a.Name.CompareTo( b.Name );
}
}
private class GroupComparer : IComparer
{
private Type m_Start;
public GroupComparer( Type start )
{
m_Start = start;
}
private static Type typeofObject = typeof( Object );
private int GetDistance( Type type )
{
Type current = m_Start;
int dist;
for ( dist = 0; current != null && current != typeofObject && current != type; ++dist )
current = current.BaseType;
return dist;
}
public int Compare( object x, object y )
{
if ( x == null && y == null )
return 0;
else if ( x == null )
return -1;
else if ( y == null )
return 1;
if ( !( x is DictionaryEntry ) || !( y is DictionaryEntry ) )
throw new ArgumentException();
DictionaryEntry de1 = (DictionaryEntry)x;
DictionaryEntry de2 = (DictionaryEntry)y;
Type a = (Type)de1.Key;
Type b = (Type)de2.Key;
return GetDistance( a ).CompareTo( GetDistance( b ) );
}
}
}
}

View File

@@ -0,0 +1,296 @@
using System;
using System.Reflection;
using System.Collections;
using System.Collections.Generic;
using Server;
using Server.Gumps;
using Server.Network;
using Server.HuePickers;
using Server.Commands;
namespace Server.EventSystem
{
public class EventSetBodyGump : Gump
{
private PropertyInfo m_Property;
private Mobile m_Mobile;
private object m_Object;
private Stack m_Stack;
private int m_Page;
private ArrayList m_List;
private int m_OurPage;
private ArrayList m_OurList;
private ModelBodyType m_OurType;
private const int LabelColor32 = 0xFFFFFF;
private const int SelectedColor32 = 0x8080FF;
private const int TextColor32 = 0xFFFFFF;
public EventSetBodyGump( PropertyInfo prop, Mobile mobile, object o, Stack stack, int page, ArrayList list )
: this( prop, mobile, o, stack, page, list, 0, null, ModelBodyType.Invalid )
{
}
public string Center( string text )
{
return String.Format( "<CENTER>{0}</CENTER>", text );
}
public string Color( string text, int color )
{
return String.Format( "<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", color, text );
}
public void AddTypeButton( int x, int y, int buttonID, string text, ModelBodyType type )
{
bool isSelection = (m_OurType == type);
AddButton( x, y - 1, isSelection ? 4006 : 4005, 4007, buttonID, GumpButtonType.Reply, 0 );
AddHtml( x + 35, y, 200, 20, Color( text, isSelection ? SelectedColor32 : LabelColor32 ), false, false );
}
public EventSetBodyGump( PropertyInfo prop, Mobile mobile, object o, Stack stack, int page, ArrayList list, int ourPage, ArrayList ourList, ModelBodyType ourType )
: base( 20, 30 )
{
m_Property = prop;
m_Mobile = mobile;
m_Object = o;
m_Stack = stack;
m_Page = page;
m_List = list;
m_OurPage = ourPage;
m_OurList = ourList;
m_OurType = ourType;
AddPage( 0 );
AddBackground( 0, 0, 525, 328, 5054 );
AddImageTiled( 10, 10, 505, 20, 0xA40 );
AddAlphaRegion( 10, 10, 505, 20 );
AddImageTiled( 10, 35, 505, 283, 0xA40 );
AddAlphaRegion( 10, 35, 505, 283 );
AddTypeButton( 10, 10, 1, "Monster", ModelBodyType.Monsters );
AddTypeButton( 130, 10, 2, "Animal", ModelBodyType.Animals );
AddTypeButton( 250, 10, 3, "Marine", ModelBodyType.Sea );
AddTypeButton( 370, 10, 4, "Human", ModelBodyType.Human );
AddImage( 480, 12, 0x25EA );
AddImage( 497, 12, 0x25E6 );
if( ourList == null )
{
AddLabel( 15, 40, 0x480, "Choose a body type above." );
}
else if( ourList.Count == 0 )
{
AddLabel( 15, 40, 0x480, "The server must have UO:3D installed to use this feature." );
}
else
{
for( int i = 0, index = (ourPage * 12); i < 12 && index >= 0 && index < ourList.Count; ++i, ++index )
{
InternalEntry entry = (InternalEntry)ourList[index];
int itemID = entry.ItemID;
Rectangle2D bounds = ItemBounds.Table[itemID & 0x3FFF];
int x = 15 + ((i % 4) * 125);
int y = 40 + ((i / 4) * 93);
AddItem( x + ((120 - bounds.Width) / 2) - bounds.X, y + ((69 - bounds.Height) / 2) - bounds.Y, itemID );
AddButton( x + 6, y + 66, 0x98D, 0x98D, 7 + index, GumpButtonType.Reply, 0 );
x += 6;
y += 67;
AddHtml( x + 0, y - 1, 108, 21, Center( entry.DisplayName ), false, false );
AddHtml( x + 0, y + 1, 108, 21, Center( entry.DisplayName ), false, false );
AddHtml( x - 1, y + 0, 108, 21, Center( entry.DisplayName ), false, false );
AddHtml( x + 1, y + 0, 108, 21, Center( entry.DisplayName ), false, false );
AddHtml( x + 0, y + 0, 108, 21, Color( Center( entry.DisplayName ), TextColor32 ), false, false );
}
if( ourPage > 0 )
AddButton( 480, 12, 0x15E3, 0x15E7, 5, GumpButtonType.Reply, 0 );
if( (ourPage + 1) * 12 < ourList.Count )
AddButton( 497, 12, 0x15E1, 0x15E5, 6, GumpButtonType.Reply, 0 );
}
}
public override void OnResponse( NetState sender, RelayInfo info )
{
int index = info.ButtonID - 1;
if( index == -1 )
{
m_Mobile.SendGump( new EventPropertiesGump( m_Mobile, m_Object, m_Stack, m_List, m_Page ) );
}
else if( index >= 0 && index < 4 )
{
if( m_Monster == null )
LoadLists();
ModelBodyType type;
ArrayList list;
switch( index )
{
default:
case 0: type = ModelBodyType.Monsters; list = m_Monster; break;
case 1: type = ModelBodyType.Animals; list = m_Animal; break;
case 2: type = ModelBodyType.Sea; list = m_Sea; break;
case 3: type = ModelBodyType.Human; list = m_Human; break;
}
m_Mobile.SendGump( new EventSetBodyGump( m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List, 0, list, type ) );
}
else if( m_OurList != null )
{
index -= 4;
if( index == 0 && m_OurPage > 0 )
{
m_Mobile.SendGump( new EventSetBodyGump( m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List, m_OurPage - 1, m_OurList, m_OurType ) );
}
else if( index == 1 && ((m_OurPage + 1) * 12) < m_OurList.Count )
{
m_Mobile.SendGump( new EventSetBodyGump( m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List, m_OurPage + 1, m_OurList, m_OurType ) );
}
else
{
index -= 2;
if( index >= 0 && index < m_OurList.Count )
{
try
{
InternalEntry entry = (InternalEntry)m_OurList[index];
CommandLogging.LogChangeProperty( m_Mobile, m_Object, m_Property.Name, entry.Body.ToString() );
m_Property.SetValue( m_Object, entry.Body, null );
EventPropertiesGump.OnValueChanged( m_Object, m_Property, m_Stack );
}
catch
{
m_Mobile.SendMessage( "An exception was caught. The property may not have changed." );
}
m_Mobile.SendGump( new EventSetBodyGump( m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List, m_OurPage, m_OurList, m_OurType ) );
}
}
}
}
private static ArrayList m_Monster, m_Animal, m_Sea, m_Human;
private static void LoadLists()
{
m_Monster = new ArrayList();
m_Animal = new ArrayList();
m_Sea = new ArrayList();
m_Human = new ArrayList();
List<BodyEntry> entries = Docs.LoadBodies();
for( int i = 0; i < entries.Count; ++i )
{
BodyEntry oldEntry = (BodyEntry)entries[i];
int bodyID = oldEntry.Body.BodyID;
if( ((Body)bodyID).IsEmpty )
continue;
ArrayList list = null;
switch( oldEntry.BodyType )
{
case ModelBodyType.Monsters: list = m_Monster; break;
case ModelBodyType.Animals: list = m_Animal; break;
case ModelBodyType.Sea: list = m_Sea; break;
case ModelBodyType.Human: list = m_Human; break;
}
if( list == null )
continue;
int itemID = ShrinkTable.Lookup( bodyID, -1 );
if( itemID != -1 )
list.Add( new InternalEntry( bodyID, itemID, oldEntry.Name ) );
}
m_Monster.Sort();
m_Animal.Sort();
m_Sea.Sort();
m_Human.Sort();
}
private class InternalEntry : IComparable
{
private int m_Body;
private int m_ItemID;
private string m_Name;
private string m_DisplayName;
public int Body { get { return m_Body; } }
public int ItemID { get { return m_ItemID; } }
public string Name { get { return m_Name; } }
public string DisplayName { get { return m_DisplayName; } }
private static string[] m_GroupNames = new string[]
{
"ogres_", "ettins_", "walking_dead_", "gargoyles_",
"orcs_", "flails_", "daemons_", "arachnids_",
"dragons_", "elementals_", "serpents_", "gazers_",
"liche_", "spirits_", "harpies_", "headless_",
"lizard_race_", "mongbat_", "rat_race_", "scorpions_",
"trolls_", "slimes_", "skeletons_", "ethereals_",
"terathan_", "imps_", "cyclops_", "krakens_",
"frogs_", "ophidians_", "centaurs_", "mages_",
"fey_race_", "genies_", "paladins_", "shadowlords_",
"succubi_", "lizards_", "rodents_", "birds_",
"bovines_", "bruins_", "canines_", "deer_",
"equines_", "felines_", "fowl_", "gorillas_",
"kirin_", "llamas_", "ostards_", "porcines_",
"ruminants_", "walrus_", "dolphins_", "sea_horse_",
"sea_serpents_", "character_", "h_", "titans_"
};
public InternalEntry( int body, int itemID, string name )
{
m_Body = body;
m_ItemID = itemID;
m_Name = name;
m_DisplayName = name.ToLower();
for( int i = 0; i < m_GroupNames.Length; ++i )
{
if( m_DisplayName.StartsWith( m_GroupNames[i] ) )
{
m_DisplayName = m_DisplayName.Substring( m_GroupNames[i].Length );
break;
}
}
m_DisplayName = m_DisplayName.Replace( '_', ' ' );
}
public int CompareTo( object obj )
{
InternalEntry comp = (InternalEntry)obj;
int v = m_Name.CompareTo( comp.m_Name );
if( v == 0 )
m_Body.CompareTo( comp.m_Body );
return v;
}
}
}
}

View File

@@ -0,0 +1,51 @@
using System;
using System.Reflection;
using System.Collections;
using Server;
using Server.Gumps;
using Server.Network;
using Server.Commands;
namespace Server.EventSystem
{
public class EventSetCustomEnumGump : EventSetListOptionGump
{
private string[] m_Names;
public EventSetCustomEnumGump( PropertyInfo prop, Mobile mobile, object o, Stack stack, int propspage, ArrayList list, string[] names ) : base( prop, mobile, o, stack, propspage, list, names, null )
{
m_Names = names;
}
public override void OnResponse( NetState sender, RelayInfo relayInfo )
{
int index = relayInfo.ButtonID - 1;
if ( index >= 0 && index < m_Names.Length )
{
try
{
MethodInfo info = m_Property.PropertyType.GetMethod( "Parse", new Type[]{ typeof( string ) } );
string result = "";
if ( info != null )
result = Properties.SetDirect( m_Mobile, m_Object, m_Object, m_Property, m_Property.Name, info.Invoke( null, new object[] { m_Names[index] } ), true );
else if ( m_Property.PropertyType == typeof( Enum ) || m_Property.PropertyType.IsSubclassOf( typeof( Enum ) ) )
result = Properties.SetDirect( m_Mobile, m_Object, m_Object, m_Property, m_Property.Name, Enum.Parse( m_Property.PropertyType, m_Names[index], false ), true );
m_Mobile.SendMessage( result );
if ( result == "Property has been set." )
EventPropertiesGump.OnValueChanged( m_Object, m_Property, m_Stack );
}
catch
{
m_Mobile.SendMessage( "An exception was caught. The property may not have changed." );
}
}
m_Mobile.SendGump( new EventPropertiesGump( m_Mobile, m_Object, m_Stack, m_List, m_Page ) );
}
}
}

View File

@@ -0,0 +1,282 @@
using System;
using System.Reflection;
using System.Collections;
using Server;
using Server.Gumps;
using Server.Network;
using Server.HuePickers;
using Server.Commands;
namespace Server.EventSystem
{
public class EventSetGump : Gump
{
private PropertyInfo m_Property;
private Mobile m_Mobile;
private object m_Object;
private Stack m_Stack;
private int m_Page;
private ArrayList m_List;
public static readonly bool OldStyle = PropsConfig.OldStyle;
public static readonly int GumpOffsetX = PropsConfig.GumpOffsetX;
public static readonly int GumpOffsetY = PropsConfig.GumpOffsetY;
public static readonly int TextHue = PropsConfig.TextHue;
public static readonly int TextOffsetX = PropsConfig.TextOffsetX;
public static readonly int OffsetGumpID = PropsConfig.OffsetGumpID;
public static readonly int HeaderGumpID = PropsConfig.HeaderGumpID;
public static readonly int EntryGumpID = PropsConfig.EntryGumpID;
public static readonly int BackGumpID = PropsConfig.BackGumpID;
public static readonly int SetGumpID = PropsConfig.SetGumpID;
public static readonly int SetWidth = PropsConfig.SetWidth;
public static readonly int SetOffsetX = PropsConfig.SetOffsetX, SetOffsetY = PropsConfig.SetOffsetY;
public static readonly int SetButtonID1 = PropsConfig.SetButtonID1;
public static readonly int SetButtonID2 = PropsConfig.SetButtonID2;
public static readonly int PrevWidth = PropsConfig.PrevWidth;
public static readonly int PrevOffsetX = PropsConfig.PrevOffsetX, PrevOffsetY = PropsConfig.PrevOffsetY;
public static readonly int PrevButtonID1 = PropsConfig.PrevButtonID1;
public static readonly int PrevButtonID2 = PropsConfig.PrevButtonID2;
public static readonly int NextWidth = PropsConfig.NextWidth;
public static readonly int NextOffsetX = PropsConfig.NextOffsetX, NextOffsetY = PropsConfig.NextOffsetY;
public static readonly int NextButtonID1 = PropsConfig.NextButtonID1;
public static readonly int NextButtonID2 = PropsConfig.NextButtonID2;
public static readonly int OffsetSize = PropsConfig.OffsetSize;
public static readonly int EntryHeight = PropsConfig.EntryHeight;
public static readonly int BorderSize = PropsConfig.BorderSize;
private static readonly int EntryWidth = 212;
private static readonly int TotalWidth = OffsetSize + EntryWidth + OffsetSize + SetWidth + OffsetSize;
private static readonly int TotalHeight = OffsetSize + ( 2 * ( EntryHeight + OffsetSize ) );
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize;
public EventSetGump( PropertyInfo prop, Mobile mobile, object o, Stack stack, int page, ArrayList list )
: base( GumpOffsetX, GumpOffsetY )
{
m_Property = prop;
m_Mobile = mobile;
m_Object = o;
m_Stack = stack;
m_Page = page;
m_List = list;
bool canNull = !prop.PropertyType.IsValueType;
bool canDye = prop.IsDefined( typeof( HueAttribute ), false );
bool isBody = prop.IsDefined( typeof( BodyAttribute ), false );
object val = prop.GetValue( m_Object, null );
string initialText;
if ( val == null )
initialText = "";
else
initialText = val.ToString();
AddPage( 0 );
AddBackground( 0, 0, BackWidth, BackHeight + ( canNull ? ( EntryHeight + OffsetSize ) : 0 ) + ( canDye ? ( EntryHeight + OffsetSize ) : 0 ) + ( isBody ? ( EntryHeight + OffsetSize ) : 0 ), BackGumpID );
AddImageTiled( BorderSize, BorderSize, TotalWidth - ( OldStyle ? SetWidth + OffsetSize : 0 ), TotalHeight + ( canNull ? ( EntryHeight + OffsetSize ) : 0 ) + ( canDye ? ( EntryHeight + OffsetSize ) : 0 ) + ( isBody ? ( EntryHeight + OffsetSize ) : 0 ), OffsetGumpID );
int x = BorderSize + OffsetSize;
int y = BorderSize + OffsetSize;
AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, prop.Name );
x += EntryWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
x = BorderSize + OffsetSize;
y += EntryHeight + OffsetSize;
AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
AddTextEntry( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, 0, initialText );
x += EntryWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 1, GumpButtonType.Reply, 0 );
if ( canNull )
{
x = BorderSize + OffsetSize;
y += EntryHeight + OffsetSize;
AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "Null" );
x += EntryWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 2, GumpButtonType.Reply, 0 );
}
if ( canDye )
{
x = BorderSize + OffsetSize;
y += EntryHeight + OffsetSize;
AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "Hue Picker" );
x += EntryWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 3, GumpButtonType.Reply, 0 );
}
if ( isBody )
{
x = BorderSize + OffsetSize;
y += EntryHeight + OffsetSize;
AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "Body Picker" );
x += EntryWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 4, GumpButtonType.Reply, 0 );
}
}
private class InternalPicker : HuePicker
{
private PropertyInfo m_Property;
private Mobile m_Mobile;
private object m_Object;
private Stack m_Stack;
private int m_Page;
private ArrayList m_List;
public InternalPicker( PropertyInfo prop, Mobile mobile, object o, Stack stack, int page, ArrayList list )
: base( ( (IHued)o ).HuedItemID )
{
m_Property = prop;
m_Mobile = mobile;
m_Object = o;
m_Stack = stack;
m_Page = page;
m_List = list;
}
public override void OnResponse( int hue )
{
try
{
CommandLogging.LogChangeProperty( m_Mobile, m_Object, m_Property.Name, hue.ToString() );
m_Property.SetValue( m_Object, hue, null );
EventPropertiesGump.OnValueChanged( m_Object, m_Property, m_Stack );
}
catch
{
m_Mobile.SendMessage( "An exception was caught. The property may not have changed." );
}
m_Mobile.SendGump( new EventPropertiesGump( m_Mobile, m_Object, m_Stack, m_List, m_Page ) );
}
}
public override void OnResponse( NetState sender, RelayInfo info )
{
object toSet;
bool shouldSet, shouldSend = true;
switch ( info.ButtonID )
{
case 1:
{
TextRelay text = info.GetTextEntry( 0 );
if ( text != null )
{
try
{
toSet = EventPropertiesGump.GetObjectFromString( m_Property.PropertyType, text.Text );
shouldSet = true;
}
catch
{
toSet = null;
shouldSet = false;
m_Mobile.SendMessage( "Bad format" );
}
}
else
{
toSet = null;
shouldSet = false;
}
break;
}
case 2: // Null
{
toSet = null;
shouldSet = true;
break;
}
case 3: // Hue Picker
{
toSet = null;
shouldSet = false;
shouldSend = false;
m_Mobile.SendHuePicker( new InternalPicker( m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List ) );
break;
}
case 4: // Body Picker
{
toSet = null;
shouldSet = false;
shouldSend = false;
m_Mobile.SendGump( new EventSetBodyGump( m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List ) );
break;
}
default:
{
toSet = null;
shouldSet = false;
break;
}
}
if ( shouldSet )
{
try
{
CommandLogging.LogChangeProperty( m_Mobile, m_Object, m_Property.Name, toSet == null ? "(null)" : toSet.ToString() );
m_Property.SetValue( m_Object, toSet, null );
EventPropertiesGump.OnValueChanged( m_Object, m_Property, m_Stack );
}
catch
{
m_Mobile.SendMessage( "An exception was caught. The property may not have changed." );
}
}
if ( shouldSend )
m_Mobile.SendGump( new EventPropertiesGump( m_Mobile, m_Object, m_Stack, m_List, m_Page ) );
}
}
}

View File

@@ -0,0 +1,188 @@
using System;
using System.Reflection;
using System.Collections;
using Server;
using Server.Gumps;
using Server.Network;
using Server.Commands;
namespace Server.EventSystem
{
public class EventSetListOptionGump : Gump
{
protected PropertyInfo m_Property;
protected Mobile m_Mobile;
protected object m_Object;
protected Stack m_Stack;
protected int m_Page;
protected ArrayList m_List;
public static readonly bool OldStyle = PropsConfig.OldStyle;
public static readonly int GumpOffsetX = PropsConfig.GumpOffsetX;
public static readonly int GumpOffsetY = PropsConfig.GumpOffsetY;
public static readonly int TextHue = PropsConfig.TextHue;
public static readonly int TextOffsetX = PropsConfig.TextOffsetX;
public static readonly int OffsetGumpID = PropsConfig.OffsetGumpID;
public static readonly int HeaderGumpID = PropsConfig.HeaderGumpID;
public static readonly int EntryGumpID = PropsConfig.EntryGumpID;
public static readonly int BackGumpID = PropsConfig.BackGumpID;
public static readonly int SetGumpID = PropsConfig.SetGumpID;
public static readonly int SetWidth = PropsConfig.SetWidth;
public static readonly int SetOffsetX = PropsConfig.SetOffsetX, SetOffsetY = PropsConfig.SetOffsetY;
public static readonly int SetButtonID1 = PropsConfig.SetButtonID1;
public static readonly int SetButtonID2 = PropsConfig.SetButtonID2;
public static readonly int PrevWidth = PropsConfig.PrevWidth;
public static readonly int PrevOffsetX = PropsConfig.PrevOffsetX, PrevOffsetY = PropsConfig.PrevOffsetY;
public static readonly int PrevButtonID1 = PropsConfig.PrevButtonID1;
public static readonly int PrevButtonID2 = PropsConfig.PrevButtonID2;
public static readonly int NextWidth = PropsConfig.NextWidth;
public static readonly int NextOffsetX = PropsConfig.NextOffsetX, NextOffsetY = PropsConfig.NextOffsetY;
public static readonly int NextButtonID1 = PropsConfig.NextButtonID1;
public static readonly int NextButtonID2 = PropsConfig.NextButtonID2;
public static readonly int OffsetSize = PropsConfig.OffsetSize;
public static readonly int EntryHeight = PropsConfig.EntryHeight;
public static readonly int BorderSize = PropsConfig.BorderSize;
private static readonly int EntryWidth = 212;
private static readonly int EntryCount = 13;
private static readonly int TotalWidth = OffsetSize + EntryWidth + OffsetSize + SetWidth + OffsetSize;
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
private static bool PrevLabel = OldStyle, NextLabel = OldStyle;
private static readonly int PrevLabelOffsetX = PrevWidth + 1;
private static readonly int PrevLabelOffsetY = 0;
private static readonly int NextLabelOffsetX = -29;
private static readonly int NextLabelOffsetY = 0;
protected object[] m_Values;
public EventSetListOptionGump( PropertyInfo prop, Mobile mobile, object o, Stack stack, int propspage, ArrayList list, string[] names, object[] values ) : base( GumpOffsetX, GumpOffsetY )
{
m_Property = prop;
m_Mobile = mobile;
m_Object = o;
m_Stack = stack;
m_Page = propspage;
m_List = list;
m_Values = values;
int pages = (names.Length + EntryCount - 1) / EntryCount;
int index = 0;
for ( int page = 1; page <= pages; ++page )
{
AddPage( page );
int start = (page - 1) * EntryCount;
int count = names.Length - start;
if ( count > EntryCount )
count = EntryCount;
int totalHeight = OffsetSize + ((count + 2) * (EntryHeight + OffsetSize));
int backHeight = BorderSize + totalHeight + BorderSize;
AddBackground( 0, 0, BackWidth, backHeight, BackGumpID );
AddImageTiled( BorderSize, BorderSize, TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0), totalHeight, OffsetGumpID );
int x = BorderSize + OffsetSize;
int y = BorderSize + OffsetSize;
int emptyWidth = TotalWidth - PrevWidth - NextWidth - (OffsetSize * 4) - (OldStyle ? SetWidth + OffsetSize : 0);
AddImageTiled( x, y, PrevWidth, EntryHeight, HeaderGumpID );
if ( page > 1 )
{
AddButton( x + PrevOffsetX, y + PrevOffsetY, PrevButtonID1, PrevButtonID2, 0, GumpButtonType.Page, page - 1 );
if ( PrevLabel )
AddLabel( x + PrevLabelOffsetX, y + PrevLabelOffsetY, TextHue, "Previous" );
}
x += PrevWidth + OffsetSize;
if ( !OldStyle )
AddImageTiled( x - (OldStyle ? OffsetSize : 0), y, emptyWidth + (OldStyle ? OffsetSize * 2 : 0), EntryHeight, HeaderGumpID );
x += emptyWidth + OffsetSize;
if ( !OldStyle )
AddImageTiled( x, y, NextWidth, EntryHeight, HeaderGumpID );
if ( page < pages )
{
AddButton( x + NextOffsetX, y + NextOffsetY, NextButtonID1, NextButtonID2, 0, GumpButtonType.Page, page + 1 );
if ( NextLabel )
AddLabel( x + NextLabelOffsetX, y + NextLabelOffsetY, TextHue, "Next" );
}
AddRect( 0, prop.Name, 0 );
for ( int i = 0; i < count; ++i )
AddRect( i + 1, names[index], ++index );
}
}
private void AddRect( int index, string str, int button )
{
int x = BorderSize + OffsetSize;
int y = BorderSize + OffsetSize + ((index + 1) * (EntryHeight + OffsetSize));
AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, str );
x += EntryWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
if ( button != 0 )
AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, button, GumpButtonType.Reply, 0 );
}
public override void OnResponse( NetState sender, RelayInfo info )
{
int index = info.ButtonID - 1;
if ( index >= 0 && index < m_Values.Length )
{
try
{
object toSet = m_Values[index];
string result = Properties.SetDirect( m_Mobile, m_Object, m_Object, m_Property, m_Property.Name, toSet, true );
m_Mobile.SendMessage( result );
if ( result == "Property has been set." )
EventPropertiesGump.OnValueChanged( m_Object, m_Property, m_Stack );
}
catch
{
m_Mobile.SendMessage( "An exception was caught. The property may not have changed." );
}
}
m_Mobile.SendGump( new EventPropertiesGump( m_Mobile, m_Object, m_Stack, m_List, m_Page ) );
}
}
}

View File

@@ -0,0 +1,310 @@
using System;
using System.Reflection;
using System.Collections;
using Server;
using Server.Gumps;
using Server.Commands.Generic;
using Server.Network;
using Server.Prompts;
using Server.Commands;
namespace Server.EventSystem
{
public class EventSetObjectGump : Gump
{
private PropertyInfo m_Property;
private Mobile m_Mobile;
private object m_Object;
private Stack m_Stack;
private Type m_Type;
private int m_Page;
private ArrayList m_List;
public static readonly bool OldStyle = PropsConfig.OldStyle;
public static readonly int GumpOffsetX = PropsConfig.GumpOffsetX;
public static readonly int GumpOffsetY = PropsConfig.GumpOffsetY;
public static readonly int TextHue = PropsConfig.TextHue;
public static readonly int TextOffsetX = PropsConfig.TextOffsetX;
public static readonly int OffsetGumpID = PropsConfig.OffsetGumpID;
public static readonly int HeaderGumpID = PropsConfig.HeaderGumpID;
public static readonly int EntryGumpID = PropsConfig.EntryGumpID;
public static readonly int BackGumpID = PropsConfig.BackGumpID;
public static readonly int SetGumpID = PropsConfig.SetGumpID;
public static readonly int SetWidth = PropsConfig.SetWidth;
public static readonly int SetOffsetX = PropsConfig.SetOffsetX, SetOffsetY = PropsConfig.SetOffsetY;
public static readonly int SetButtonID1 = PropsConfig.SetButtonID1;
public static readonly int SetButtonID2 = PropsConfig.SetButtonID2;
public static readonly int PrevWidth = PropsConfig.PrevWidth;
public static readonly int PrevOffsetX = PropsConfig.PrevOffsetX, PrevOffsetY = PropsConfig.PrevOffsetY;
public static readonly int PrevButtonID1 = PropsConfig.PrevButtonID1;
public static readonly int PrevButtonID2 = PropsConfig.PrevButtonID2;
public static readonly int NextWidth = PropsConfig.NextWidth;
public static readonly int NextOffsetX = PropsConfig.NextOffsetX, NextOffsetY = PropsConfig.NextOffsetY;
public static readonly int NextButtonID1 = PropsConfig.NextButtonID1;
public static readonly int NextButtonID2 = PropsConfig.NextButtonID2;
public static readonly int OffsetSize = PropsConfig.OffsetSize;
public static readonly int EntryHeight = PropsConfig.EntryHeight;
public static readonly int BorderSize = PropsConfig.BorderSize;
private static readonly int EntryWidth = 212;
private static readonly int TotalWidth = OffsetSize + EntryWidth + OffsetSize + SetWidth + OffsetSize;
private static readonly int TotalHeight = OffsetSize + ( 5 * ( EntryHeight + OffsetSize ) );
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize;
public EventSetObjectGump( PropertyInfo prop, Mobile mobile, object o, Stack stack, Type type, int page, ArrayList list )
: base( GumpOffsetX, GumpOffsetY )
{
m_Property = prop;
m_Mobile = mobile;
m_Object = o;
m_Stack = stack;
m_Type = type;
m_Page = page;
m_List = list;
string initialText = EventPropertiesGump.ValueToString( o, prop );
AddPage( 0 );
AddBackground( 0, 0, BackWidth, BackHeight, BackGumpID );
AddImageTiled( BorderSize, BorderSize, TotalWidth - ( OldStyle ? SetWidth + OffsetSize : 0 ), TotalHeight, OffsetGumpID );
int x = BorderSize + OffsetSize;
int y = BorderSize + OffsetSize;
AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, prop.Name );
x += EntryWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
x = BorderSize + OffsetSize;
y += EntryHeight + OffsetSize;
AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, initialText );
x += EntryWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 1, GumpButtonType.Reply, 0 );
x = BorderSize + OffsetSize;
y += EntryHeight + OffsetSize;
AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "Change by Serial" );
x += EntryWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 2, GumpButtonType.Reply, 0 );
x = BorderSize + OffsetSize;
y += EntryHeight + OffsetSize;
AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "Nullify" );
x += EntryWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 3, GumpButtonType.Reply, 0 );
x = BorderSize + OffsetSize;
y += EntryHeight + OffsetSize;
AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "View Properties" );
x += EntryWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 4, GumpButtonType.Reply, 0 );
}
private class InternalPrompt : Prompt
{
private PropertyInfo m_Property;
private Mobile m_Mobile;
private object m_Object;
private Stack m_Stack;
private Type m_Type;
private int m_Page;
private ArrayList m_List;
public InternalPrompt( PropertyInfo prop, Mobile mobile, object o, Stack stack, Type type, int page, ArrayList list )
{
m_Property = prop;
m_Mobile = mobile;
m_Object = o;
m_Stack = stack;
m_Type = type;
m_Page = page;
m_List = list;
}
public override void OnCancel( Mobile from )
{
m_Mobile.SendGump( new EventSetObjectGump( m_Property, m_Mobile, m_Object, m_Stack, m_Type, m_Page, m_List ) );
}
public override void OnResponse( Mobile from, string text )
{
object toSet;
bool shouldSet;
try
{
int serial = Utility.ToInt32( text );
toSet = World.FindEntity( serial );
if ( toSet == null )
{
shouldSet = false;
m_Mobile.SendMessage( "No object with that serial was found." );
}
else if ( !m_Type.IsAssignableFrom( toSet.GetType() ) )
{
toSet = null;
shouldSet = false;
m_Mobile.SendMessage( "The object with that serial could not be assigned to a property of type : {0}", m_Type.Name );
}
else
{
shouldSet = true;
}
}
catch
{
toSet = null;
shouldSet = false;
m_Mobile.SendMessage( "Bad format" );
}
if ( shouldSet )
{
try
{
CommandLogging.LogChangeProperty( m_Mobile, m_Object, m_Property.Name, toSet == null ? "(null)" : toSet.ToString() );
m_Property.SetValue( m_Object, toSet, null );
EventPropertiesGump.OnValueChanged( m_Object, m_Property, m_Stack );
}
catch
{
m_Mobile.SendMessage( "An exception was caught. The property may not have changed." );
}
}
m_Mobile.SendGump( new EventSetObjectGump( m_Property, m_Mobile, m_Object, m_Stack, m_Type, m_Page, m_List ) );
}
}
public override void OnResponse( NetState sender, RelayInfo info )
{
object toSet;
bool shouldSet, shouldSend = true;
object viewProps = null;
switch ( info.ButtonID )
{
case 0: // closed
{
m_Mobile.SendGump( new EventPropertiesGump( m_Mobile, m_Object, m_Stack, m_List, m_Page ) );
toSet = null;
shouldSet = false;
shouldSend = false;
break;
}
case 1: // Change by Target
{
m_Mobile.Target = new EventSetObjectTarget( m_Property, m_Mobile, m_Object, m_Stack, m_Type, m_Page, m_List );
toSet = null;
shouldSet = false;
shouldSend = false;
break;
}
case 2: // Change by Serial
{
toSet = null;
shouldSet = false;
shouldSend = false;
m_Mobile.SendMessage( "Enter the serial you wish to find:" );
m_Mobile.Prompt = new InternalPrompt( m_Property, m_Mobile, m_Object, m_Stack, m_Type, m_Page, m_List );
break;
}
case 3: // Nullify
{
toSet = null;
shouldSet = true;
break;
}
case 4: // View Properties
{
toSet = null;
shouldSet = false;
object obj = m_Property.GetValue( m_Object, null );
if ( obj == null )
m_Mobile.SendMessage( "The property is null and so you cannot view its properties." );
else if ( !BaseCommand.IsAccessible( m_Mobile, obj ) )
m_Mobile.SendMessage( "You may not view their properties." );
else
viewProps = obj;
break;
}
default:
{
toSet = null;
shouldSet = false;
break;
}
}
if ( shouldSet )
{
try
{
CommandLogging.LogChangeProperty( m_Mobile, m_Object, m_Property.Name, toSet == null ? "(null)" : toSet.ToString() );
m_Property.SetValue( m_Object, toSet, null );
EventPropertiesGump.OnValueChanged( m_Object, m_Property, m_Stack );
}
catch
{
m_Mobile.SendMessage( "An exception was caught. The property may not have changed." );
}
}
if ( shouldSend )
m_Mobile.SendGump( new EventSetObjectGump( m_Property, m_Mobile, m_Object, m_Stack, m_Type, m_Page, m_List ) );
if ( viewProps != null )
m_Mobile.SendGump( new EventPropertiesGump( m_Mobile, viewProps ) );
}
}
}

View File

@@ -0,0 +1,67 @@
using System;
using System.Reflection;
using System.Collections;
using Server;
using Server.Gumps;
using Server.Items;
using Server.Targeting;
using Server.Commands;
namespace Server.EventSystem
{
public class EventSetObjectTarget : Target
{
private PropertyInfo m_Property;
private Mobile m_Mobile;
private object m_Object;
private Stack m_Stack;
private Type m_Type;
private int m_Page;
private ArrayList m_List;
public EventSetObjectTarget( PropertyInfo prop, Mobile mobile, object o, Stack stack, Type type, int page, ArrayList list ) : base( -1, false, TargetFlags.None )
{
m_Property = prop;
m_Mobile = mobile;
m_Object = o;
m_Stack = stack;
m_Type = type;
m_Page = page;
m_List = list;
}
protected override void OnTarget( Mobile from, object targeted )
{
try
{
if ( m_Type == typeof( Type ) )
targeted = targeted.GetType();
else if ( (m_Type == typeof( BaseAddon ) || m_Type.IsAssignableFrom( typeof( BaseAddon ) )) && targeted is AddonComponent )
targeted = ((AddonComponent)targeted).Addon;
if ( m_Type.IsAssignableFrom( targeted.GetType() ) )
{
CommandLogging.LogChangeProperty( m_Mobile, m_Object, m_Property.Name, targeted.ToString() );
m_Property.SetValue( m_Object, targeted, null );
EventPropertiesGump.OnValueChanged( m_Object, m_Property, m_Stack );
}
else
{
m_Mobile.SendMessage( "That cannot be assigned to a property of type : {0}", m_Type.Name );
}
}
catch
{
m_Mobile.SendMessage( "An exception was caught. The property may not have changed." );
}
}
protected override void OnTargetFinish( Mobile from )
{
if ( m_Type == typeof( Type ) )
from.SendGump( new EventPropertiesGump( m_Mobile, m_Object, m_Stack, m_List, m_Page ) );
else
from.SendGump( new EventSetObjectGump( m_Property, m_Mobile, m_Object, m_Stack, m_Type, m_Page, m_List ) );
}
}
}

View File

@@ -0,0 +1,240 @@
using System;
using System.Reflection;
using System.Collections;
using Server;
using Server.Gumps;
using Server.Targeting;
using Server.Network;
using Server.Commands;
namespace Server.EventSystem
{
public class EventSetPoint2DGump : Gump
{
private PropertyInfo m_Property;
private Mobile m_Mobile;
private object m_Object;
private Stack m_Stack;
private int m_Page;
private ArrayList m_List;
public static readonly bool OldStyle = PropsConfig.OldStyle;
public static readonly int GumpOffsetX = PropsConfig.GumpOffsetX;
public static readonly int GumpOffsetY = PropsConfig.GumpOffsetY;
public static readonly int TextHue = PropsConfig.TextHue;
public static readonly int TextOffsetX = PropsConfig.TextOffsetX;
public static readonly int OffsetGumpID = PropsConfig.OffsetGumpID;
public static readonly int HeaderGumpID = PropsConfig.HeaderGumpID;
public static readonly int EntryGumpID = PropsConfig.EntryGumpID;
public static readonly int BackGumpID = PropsConfig.BackGumpID;
public static readonly int SetGumpID = PropsConfig.SetGumpID;
public static readonly int SetWidth = PropsConfig.SetWidth;
public static readonly int SetOffsetX = PropsConfig.SetOffsetX, SetOffsetY = PropsConfig.SetOffsetY;
public static readonly int SetButtonID1 = PropsConfig.SetButtonID1;
public static readonly int SetButtonID2 = PropsConfig.SetButtonID2;
public static readonly int PrevWidth = PropsConfig.PrevWidth;
public static readonly int PrevOffsetX = PropsConfig.PrevOffsetX, PrevOffsetY = PropsConfig.PrevOffsetY;
public static readonly int PrevButtonID1 = PropsConfig.PrevButtonID1;
public static readonly int PrevButtonID2 = PropsConfig.PrevButtonID2;
public static readonly int NextWidth = PropsConfig.NextWidth;
public static readonly int NextOffsetX = PropsConfig.NextOffsetX, NextOffsetY = PropsConfig.NextOffsetY;
public static readonly int NextButtonID1 = PropsConfig.NextButtonID1;
public static readonly int NextButtonID2 = PropsConfig.NextButtonID2;
public static readonly int OffsetSize = PropsConfig.OffsetSize;
public static readonly int EntryHeight = PropsConfig.EntryHeight;
public static readonly int BorderSize = PropsConfig.BorderSize;
private static readonly int CoordWidth = 105;
private static readonly int EntryWidth = CoordWidth + OffsetSize + CoordWidth;
private static readonly int TotalWidth = OffsetSize + EntryWidth + OffsetSize + SetWidth + OffsetSize;
private static readonly int TotalHeight = OffsetSize + ( 4 * ( EntryHeight + OffsetSize ) );
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize;
public EventSetPoint2DGump( PropertyInfo prop, Mobile mobile, object o, Stack stack, int page, ArrayList list )
: base( GumpOffsetX, GumpOffsetY )
{
m_Property = prop;
m_Mobile = mobile;
m_Object = o;
m_Stack = stack;
m_Page = page;
m_List = list;
Point2D p = (Point2D)prop.GetValue( o, null );
AddPage( 0 );
AddBackground( 0, 0, BackWidth, BackHeight, BackGumpID );
AddImageTiled( BorderSize, BorderSize, TotalWidth - ( OldStyle ? SetWidth + OffsetSize : 0 ), TotalHeight, OffsetGumpID );
int x = BorderSize + OffsetSize;
int y = BorderSize + OffsetSize;
AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, prop.Name );
x += EntryWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
x = BorderSize + OffsetSize;
y += EntryHeight + OffsetSize;
AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "Use your location" );
x += EntryWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 1, GumpButtonType.Reply, 0 );
x = BorderSize + OffsetSize;
y += EntryHeight + OffsetSize;
AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "Target a location" );
x += EntryWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 2, GumpButtonType.Reply, 0 );
x = BorderSize + OffsetSize;
y += EntryHeight + OffsetSize;
AddImageTiled( x, y, CoordWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, CoordWidth - TextOffsetX, EntryHeight, TextHue, "X:" );
AddTextEntry( x + 16, y, CoordWidth - 16, EntryHeight, TextHue, 0, p.X.ToString() );
x += CoordWidth + OffsetSize;
AddImageTiled( x, y, CoordWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, CoordWidth - TextOffsetX, EntryHeight, TextHue, "Y:" );
AddTextEntry( x + 16, y, CoordWidth - 16, EntryHeight, TextHue, 1, p.Y.ToString() );
x += CoordWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 3, GumpButtonType.Reply, 0 );
}
private class InternalTarget : Target
{
private PropertyInfo m_Property;
private Mobile m_Mobile;
private object m_Object;
private Stack m_Stack;
private int m_Page;
private ArrayList m_List;
public InternalTarget( PropertyInfo prop, Mobile mobile, object o, Stack stack, int page, ArrayList list )
: base( -1, true, TargetFlags.None )
{
m_Property = prop;
m_Mobile = mobile;
m_Object = o;
m_Stack = stack;
m_Page = page;
m_List = list;
}
protected override void OnTarget( Mobile from, object targeted )
{
IPoint3D p = targeted as IPoint3D;
if ( p != null )
{
try
{
CommandLogging.LogChangeProperty( m_Mobile, m_Object, m_Property.Name, new Point2D( p ).ToString() );
m_Property.SetValue( m_Object, new Point2D( p ), null );
EventPropertiesGump.OnValueChanged( m_Object, m_Property, m_Stack );
}
catch
{
m_Mobile.SendMessage( "An exception was caught. The property may not have changed." );
}
}
}
protected override void OnTargetFinish( Mobile from )
{
m_Mobile.SendGump( new EventPropertiesGump( m_Mobile, m_Object, m_Stack, m_List, m_Page ) );
}
}
public override void OnResponse( NetState sender, RelayInfo info )
{
Point2D toSet;
bool shouldSet, shouldSend;
switch ( info.ButtonID )
{
case 1: // Current location
{
toSet = new Point2D( m_Mobile.Location );
shouldSet = true;
shouldSend = true;
break;
}
case 2: // Pick location
{
m_Mobile.Target = new InternalTarget( m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List );
toSet = Point2D.Zero;
shouldSet = false;
shouldSend = false;
break;
}
case 3: // Use values
{
TextRelay x = info.GetTextEntry( 0 );
TextRelay y = info.GetTextEntry( 1 );
toSet = new Point2D( x == null ? 0 : Utility.ToInt32( x.Text ), y == null ? 0 : Utility.ToInt32( y.Text ) );
shouldSet = true;
shouldSend = true;
break;
}
default:
{
toSet = Point2D.Zero;
shouldSet = false;
shouldSend = true;
break;
}
}
if ( shouldSet )
{
try
{
CommandLogging.LogChangeProperty( m_Mobile, m_Object, m_Property.Name, toSet.ToString() );
m_Property.SetValue( m_Object, toSet, null );
EventPropertiesGump.OnValueChanged( m_Object, m_Property, m_Stack );
}
catch
{
m_Mobile.SendMessage( "An exception was caught. The property may not have changed." );
}
}
if ( shouldSend )
m_Mobile.SendGump( new EventPropertiesGump( m_Mobile, m_Object, m_Stack, m_List, m_Page ) );
}
}
}

View File

@@ -0,0 +1,246 @@
using System;
using System.Reflection;
using System.Collections;
using Server;
using Server.Gumps;
using Server.Targeting;
using Server.Network;
using Server.Commands;
namespace Server.EventSystem
{
public class EventSetPoint3DGump : Gump
{
private PropertyInfo m_Property;
private Mobile m_Mobile;
private object m_Object;
private Stack m_Stack;
private int m_Page;
private ArrayList m_List;
public static readonly bool OldStyle = PropsConfig.OldStyle;
public static readonly int GumpOffsetX = PropsConfig.GumpOffsetX;
public static readonly int GumpOffsetY = PropsConfig.GumpOffsetY;
public static readonly int TextHue = PropsConfig.TextHue;
public static readonly int TextOffsetX = PropsConfig.TextOffsetX;
public static readonly int OffsetGumpID = PropsConfig.OffsetGumpID;
public static readonly int HeaderGumpID = PropsConfig.HeaderGumpID;
public static readonly int EntryGumpID = PropsConfig.EntryGumpID;
public static readonly int BackGumpID = PropsConfig.BackGumpID;
public static readonly int SetGumpID = PropsConfig.SetGumpID;
public static readonly int SetWidth = PropsConfig.SetWidth;
public static readonly int SetOffsetX = PropsConfig.SetOffsetX, SetOffsetY = PropsConfig.SetOffsetY;
public static readonly int SetButtonID1 = PropsConfig.SetButtonID1;
public static readonly int SetButtonID2 = PropsConfig.SetButtonID2;
public static readonly int PrevWidth = PropsConfig.PrevWidth;
public static readonly int PrevOffsetX = PropsConfig.PrevOffsetX, PrevOffsetY = PropsConfig.PrevOffsetY;
public static readonly int PrevButtonID1 = PropsConfig.PrevButtonID1;
public static readonly int PrevButtonID2 = PropsConfig.PrevButtonID2;
public static readonly int NextWidth = PropsConfig.NextWidth;
public static readonly int NextOffsetX = PropsConfig.NextOffsetX, NextOffsetY = PropsConfig.NextOffsetY;
public static readonly int NextButtonID1 = PropsConfig.NextButtonID1;
public static readonly int NextButtonID2 = PropsConfig.NextButtonID2;
public static readonly int OffsetSize = PropsConfig.OffsetSize;
public static readonly int EntryHeight = PropsConfig.EntryHeight;
public static readonly int BorderSize = PropsConfig.BorderSize;
private static readonly int CoordWidth = 70;
private static readonly int EntryWidth = CoordWidth + OffsetSize + CoordWidth + OffsetSize + CoordWidth;
private static readonly int TotalWidth = OffsetSize + EntryWidth + OffsetSize + SetWidth + OffsetSize;
private static readonly int TotalHeight = OffsetSize + ( 4 * ( EntryHeight + OffsetSize ) );
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize;
public EventSetPoint3DGump( PropertyInfo prop, Mobile mobile, object o, Stack stack, int page, ArrayList list )
: base( GumpOffsetX, GumpOffsetY )
{
m_Property = prop;
m_Mobile = mobile;
m_Object = o;
m_Stack = stack;
m_Page = page;
m_List = list;
Point3D p = (Point3D)prop.GetValue( o, null );
AddPage( 0 );
AddBackground( 0, 0, BackWidth, BackHeight, BackGumpID );
AddImageTiled( BorderSize, BorderSize, TotalWidth - ( OldStyle ? SetWidth + OffsetSize : 0 ), TotalHeight, OffsetGumpID );
int x = BorderSize + OffsetSize;
int y = BorderSize + OffsetSize;
AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, prop.Name );
x += EntryWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
x = BorderSize + OffsetSize;
y += EntryHeight + OffsetSize;
AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "Use your location" );
x += EntryWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 1, GumpButtonType.Reply, 0 );
x = BorderSize + OffsetSize;
y += EntryHeight + OffsetSize;
AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "Target a location" );
x += EntryWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 2, GumpButtonType.Reply, 0 );
x = BorderSize + OffsetSize;
y += EntryHeight + OffsetSize;
AddImageTiled( x, y, CoordWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, CoordWidth - TextOffsetX, EntryHeight, TextHue, "X:" );
AddTextEntry( x + 16, y, CoordWidth - 16, EntryHeight, TextHue, 0, p.X.ToString() );
x += CoordWidth + OffsetSize;
AddImageTiled( x, y, CoordWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, CoordWidth - TextOffsetX, EntryHeight, TextHue, "Y:" );
AddTextEntry( x + 16, y, CoordWidth - 16, EntryHeight, TextHue, 1, p.Y.ToString() );
x += CoordWidth + OffsetSize;
AddImageTiled( x, y, CoordWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, CoordWidth - TextOffsetX, EntryHeight, TextHue, "Z:" );
AddTextEntry( x + 16, y, CoordWidth - 16, EntryHeight, TextHue, 2, p.Z.ToString() );
x += CoordWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 3, GumpButtonType.Reply, 0 );
}
private class InternalTarget : Target
{
private PropertyInfo m_Property;
private Mobile m_Mobile;
private object m_Object;
private Stack m_Stack;
private int m_Page;
private ArrayList m_List;
public InternalTarget( PropertyInfo prop, Mobile mobile, object o, Stack stack, int page, ArrayList list )
: base( -1, true, TargetFlags.None )
{
m_Property = prop;
m_Mobile = mobile;
m_Object = o;
m_Stack = stack;
m_Page = page;
m_List = list;
}
protected override void OnTarget( Mobile from, object targeted )
{
IPoint3D p = targeted as IPoint3D;
if ( p != null )
{
try
{
CommandLogging.LogChangeProperty( m_Mobile, m_Object, m_Property.Name, new Point3D( p ).ToString() );
m_Property.SetValue( m_Object, new Point3D( p ), null );
EventPropertiesGump.OnValueChanged( m_Object, m_Property, m_Stack );
}
catch
{
m_Mobile.SendMessage( "An exception was caught. The property may not have changed." );
}
}
}
protected override void OnTargetFinish( Mobile from )
{
m_Mobile.SendGump( new EventPropertiesGump( m_Mobile, m_Object, m_Stack, m_List, m_Page ) );
}
}
public override void OnResponse( NetState sender, RelayInfo info )
{
Point3D toSet;
bool shouldSet, shouldSend;
switch ( info.ButtonID )
{
case 1: // Current location
{
toSet = m_Mobile.Location;
shouldSet = true;
shouldSend = true;
break;
}
case 2: // Pick location
{
m_Mobile.Target = new InternalTarget( m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List );
toSet = Point3D.Zero;
shouldSet = false;
shouldSend = false;
break;
}
case 3: // Use values
{
TextRelay x = info.GetTextEntry( 0 );
TextRelay y = info.GetTextEntry( 1 );
TextRelay z = info.GetTextEntry( 2 );
toSet = new Point3D( x == null ? 0 : Utility.ToInt32( x.Text ), y == null ? 0 : Utility.ToInt32( y.Text ), z == null ? 0 : Utility.ToInt32( z.Text ) );
shouldSet = true;
shouldSend = true;
break;
}
default:
{
toSet = Point3D.Zero;
shouldSet = false;
shouldSend = true;
break;
}
}
if ( shouldSet )
{
try
{
CommandLogging.LogChangeProperty( m_Mobile, m_Object, m_Property.Name, toSet.ToString() );
m_Property.SetValue( m_Object, toSet, null );
EventPropertiesGump.OnValueChanged( m_Object, m_Property, m_Stack );
}
catch
{
m_Mobile.SendMessage( "An exception was caught. The property may not have changed." );
}
}
if ( shouldSend )
m_Mobile.SendGump( new EventPropertiesGump( m_Mobile, m_Object, m_Stack, m_List, m_Page ) );
}
}
}

View File

@@ -0,0 +1,239 @@
using System;
using System.Reflection;
using System.Collections;
using Server;
using Server.Gumps;
using Server.Network;
using Server.Commands;
namespace Server.EventSystem
{
public class EventSetTimeSpanGump : Gump
{
private PropertyInfo m_Property;
private Mobile m_Mobile;
private object m_Object;
private Stack m_Stack;
private int m_Page;
private ArrayList m_List;
public static readonly bool OldStyle = PropsConfig.OldStyle;
public static readonly int GumpOffsetX = PropsConfig.GumpOffsetX;
public static readonly int GumpOffsetY = PropsConfig.GumpOffsetY;
public static readonly int TextHue = PropsConfig.TextHue;
public static readonly int TextOffsetX = PropsConfig.TextOffsetX;
public static readonly int OffsetGumpID = PropsConfig.OffsetGumpID;
public static readonly int HeaderGumpID = PropsConfig.HeaderGumpID;
public static readonly int EntryGumpID = PropsConfig.EntryGumpID;
public static readonly int BackGumpID = PropsConfig.BackGumpID;
public static readonly int SetGumpID = PropsConfig.SetGumpID;
public static readonly int SetWidth = PropsConfig.SetWidth;
public static readonly int SetOffsetX = PropsConfig.SetOffsetX, SetOffsetY = PropsConfig.SetOffsetY;
public static readonly int SetButtonID1 = PropsConfig.SetButtonID1;
public static readonly int SetButtonID2 = PropsConfig.SetButtonID2;
public static readonly int PrevWidth = PropsConfig.PrevWidth;
public static readonly int PrevOffsetX = PropsConfig.PrevOffsetX, PrevOffsetY = PropsConfig.PrevOffsetY;
public static readonly int PrevButtonID1 = PropsConfig.PrevButtonID1;
public static readonly int PrevButtonID2 = PropsConfig.PrevButtonID2;
public static readonly int NextWidth = PropsConfig.NextWidth;
public static readonly int NextOffsetX = PropsConfig.NextOffsetX, NextOffsetY = PropsConfig.NextOffsetY;
public static readonly int NextButtonID1 = PropsConfig.NextButtonID1;
public static readonly int NextButtonID2 = PropsConfig.NextButtonID2;
public static readonly int OffsetSize = PropsConfig.OffsetSize;
public static readonly int EntryHeight = PropsConfig.EntryHeight;
public static readonly int BorderSize = PropsConfig.BorderSize;
private static readonly int EntryWidth = 212;
private static readonly int TotalWidth = OffsetSize + EntryWidth + OffsetSize + SetWidth + OffsetSize;
private static readonly int TotalHeight = OffsetSize + (7 * (EntryHeight + OffsetSize));
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize;
public EventSetTimeSpanGump( PropertyInfo prop, Mobile mobile, object o, Stack stack, int page, ArrayList list ) : base( GumpOffsetX, GumpOffsetY )
{
m_Property = prop;
m_Mobile = mobile;
m_Object = o;
m_Stack = stack;
m_Page = page;
m_List = list;
TimeSpan ts = (TimeSpan)prop.GetValue( o, null );
AddPage( 0 );
AddBackground( 0, 0, BackWidth, BackHeight, BackGumpID );
AddImageTiled( BorderSize, BorderSize, TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0), TotalHeight, OffsetGumpID );
AddRect( 0, prop.Name, 0, -1 );
AddRect( 1, ts.ToString(), 0, -1 );
AddRect( 2, "Zero", 1, -1 );
AddRect( 3, "From H:M:S", 2, -1 );
AddRect( 4, "H:", 3, 0 );
AddRect( 5, "M:", 4, 1 );
AddRect( 6, "S:", 5, 2 );
}
private void AddRect( int index, string str, int button, int text )
{
int x = BorderSize + OffsetSize;
int y = BorderSize + OffsetSize + (index * (EntryHeight + OffsetSize));
AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, str );
if ( text != -1 )
AddTextEntry( x + 16 + TextOffsetX, y, EntryWidth - TextOffsetX - 16, EntryHeight, TextHue, text, "" );
x += EntryWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
if ( button != 0 )
AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, button, GumpButtonType.Reply, 0 );
}
public override void OnResponse( NetState sender, RelayInfo info )
{
TimeSpan toSet;
bool shouldSet, shouldSend;
TextRelay h = info.GetTextEntry( 0 );
TextRelay m = info.GetTextEntry( 1 );
TextRelay s = info.GetTextEntry( 2 );
switch ( info.ButtonID )
{
case 1: // Zero
{
toSet = TimeSpan.Zero;
shouldSet = true;
shouldSend = true;
break;
}
case 2: // From H:M:S
{
bool successfulParse = false;
if( h != null && m != null && s != null )
{
successfulParse = TimeSpan.TryParse( h.Text + ":" + m.Text + ":" + s.Text, out toSet );
}
else
{
toSet = TimeSpan.Zero;
}
shouldSet = shouldSend = successfulParse;
break;
}
case 3: // From H
{
if ( h != null )
{
try
{
toSet = TimeSpan.FromHours( Utility.ToDouble( h.Text ) );
shouldSet = true;
shouldSend = true;
break;
}
catch
{
}
}
toSet = TimeSpan.Zero;
shouldSet = false;
shouldSend = false;
break;
}
case 4: // From M
{
if ( m != null )
{
try
{
toSet = TimeSpan.FromMinutes( Utility.ToDouble( m.Text ) );
shouldSet = true;
shouldSend = true;
break;
}
catch
{
}
}
toSet = TimeSpan.Zero;
shouldSet = false;
shouldSend = false;
break;
}
case 5: // From S
{
if ( s != null )
{
try
{
toSet = TimeSpan.FromSeconds( Utility.ToDouble( s.Text ) );
shouldSet = true;
shouldSend = true;
break;
}
catch
{
}
}
toSet = TimeSpan.Zero;
shouldSet = false;
shouldSend = false;
break;
}
default:
{
toSet = TimeSpan.Zero;
shouldSet = false;
shouldSend = true;
break;
}
}
if ( shouldSet )
{
try
{
CommandLogging.LogChangeProperty( m_Mobile, m_Object, m_Property.Name, toSet.ToString() );
m_Property.SetValue( m_Object, toSet, null );
EventPropertiesGump.OnValueChanged( m_Object, m_Property, m_Stack );
}
catch
{
m_Mobile.SendMessage( "An exception was caught. The property may not have changed." );
}
}
if ( shouldSend )
m_Mobile.SendGump( new EventPropertiesGump( m_Mobile, m_Object, m_Stack, m_List, m_Page ) );
}
}
}

View File

@@ -0,0 +1,43 @@
using System;
using Server.Items;
namespace Server.EventSystem
{
public class EventGate : Moongate
{
private BaseEvent m_Event;
[Constructable]
public EventGate( BaseEvent e )
: base()
{
m_Event = e;
Hue = 1153;
Name = e.EventName + " Gate";
Dispellable = false;
Target = e.StartingLocation;
TargetMap = e.StartingMap;
}
public EventGate( Serial serial )
: base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int)1 ); //version
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
Delete();
}
}
}

View File

@@ -0,0 +1,62 @@
using System;
namespace Server.EventSystem
{
public class EventPersistance : Item
{
private static EventPersistance m_Instance;
public static EventPersistance Instance { get { return m_Instance; } }
public override string DefaultName
{
get { return "EventSystem Persistance - Internal"; }
}
public EventPersistance()
: base( 1 )
{
Movable = false;
if ( m_Instance == null || m_Instance.Deleted )
m_Instance = this;
else
base.Delete();
}
public EventPersistance( Serial serial )
: base( serial )
{
m_Instance = this;
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int)0 ); // version
EventCore.Serialize( writer );
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
switch ( version )
{
case 0:
{
EventCore.Deserialize( reader );
break;
}
}
}
public override void Delete()
{
}
}
}

View File

@@ -0,0 +1,16 @@
using System;
namespace Server.EventSystem
{
public class PlayerStats
{
private Mobile m_Player;
public Mobile Player { get { return m_Player; } }
public PlayerStats( Mobile player )
{
m_Player = player;
}
}
}