using System;
using System.Collections;
using Server;
using Server.Gumps;
using Server.Items;
using Server.Network;
using Server.Accounting;
namespace Server.Mobiles
{
public class MyPlayerMobile : PlayerMobile
{
private Item m_InternalMount;
private bool m_OrcFriend = false;
private bool m_DrowFriend = false;
private RaceType m_Race = RaceType.None;
public int m_StrCap = 150;
public int m_DexCap = 150;
public int m_IntCap = 150;
public enum RaceType
{
None, Human, Dwarf, Drow, Centaur, Elf, Orc, Deamon, Vampire, Undead
}
public Item InternalMount
{
get{ return m_InternalMount; }
set{ m_InternalMount = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool OrcFriend
{
get{ return m_OrcFriend; }
set{ m_OrcFriend = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool DrowFriend
{
get{ return m_DrowFriend; }
set{ m_DrowFriend = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public RaceType Race
{
get{ return m_Race; }
set{ m_Race = value; InvalidateProperties(); }
}
[CommandProperty( AccessLevel.GameMaster )]
public int StrCap // Maximum value of STR stat
{
get {return m_StrCap;}
set {m_StrCap = value;}
}
[CommandProperty( AccessLevel.GameMaster )]
public int IntCap // Maximum value of INT stat
{
get {return m_IntCap;}
set {m_IntCap = value;}
}
[CommandProperty( AccessLevel.GameMaster )]
public int DexCap // Maximum value of DEX stat
{
get {return m_DexCap;}
set {m_DexCap = value;}
}
new public static void Initialize()
{
EventSink.Login += new LoginEventHandler( OnLogin );
}
private static void OnLogin( LoginEventArgs e )
{
if ( e.Mobile is MyPlayerMobile )
{
MyPlayerMobile m = (MyPlayerMobile)e.Mobile;
MyPlayerMobile.MaxPlayerResistance = 85;
if(m.Race == RaceType.None)
{
m.CloseGump( typeof( RaceGump ) );
m.SendGump( new RaceGump( m, RacePage.Info) );
}
}
}
/*
public override void AddNameProperties( ObjectPropertyList list )
{
if(this.Race != RaceType.None)
list.Add( 1042971, "{0}", m_Race==RaceType.None ? " " : m_Race.ToString() );
base.AddNameProperties( list );
}
*/
public override void OnDeath( Container c )
{
if ( m_InternalMount != null )
{
m_InternalMount.Delete();
m_InternalMount = null;
}
base.OnDeath( c );
}
public override void OnAfterResurrect()
{
RestoreBody();
base.OnAfterResurrect();
}
public void CreateInternalMount()
{
if ( m_InternalMount == null )
{
m_InternalMount = new Item( 0x3EAA );
m_InternalMount.Layer = Layer.Mount;
m_InternalMount.Movable = false;
m_InternalMount.Visible = false;
AddItem( m_InternalMount );
}
}
public void RestoreBody()
{
if(this.Female)
this.BodyValue = 401;// if error change back to BodyMod instead of BodyValue
else
this.BodyValue = 400;// if error change back to BodyMod instead of BodyValue
RaceType race = this.Race;
switch( race )
{
case RaceType.Centaur:
{
this.BodyMod = 101;
CreateInternalMount();
break;
}
//case RaceType.Ogre: this.BodyMod = 1; break;
case RaceType.Orc:
{
this.BodyMod = 7;
CreateInternalMount();
break;
}
case RaceType.Deamon:
{
this.BodyMod = 43;
CreateInternalMount();
break;
}
}
}
/*
public override TimeSpan ComputeMovementSpeed( Direction dir )
{
if ( (dir & Direction.Mask) != (this.Direction & Direction.Mask) )
return TimeSpan.Zero;
bool running = ( (dir & Direction.Running) != 0 );
bool onHorse = ( this.Mount != null );
if ( onHorse )
{
if(this.Race == RaceType.Centaur)
return ( running ? TimeSpan.FromSeconds( 0.1 ) : TimeSpan.FromSeconds( 0.2 ) );
else if(this.Race == RaceType.Deamon)
return ( running ? TimeSpan.FromSeconds( 0.1 ) : TimeSpan.FromSeconds( 0.2 ) );
else if(this.Race == RaceType.Orc)
return ( running ? TimeSpan.FromSeconds( 0.3 ) : TimeSpan.FromSeconds( 0.6 ) );
else
return ( running ? TimeSpan.FromSeconds( 0.2 ) : TimeSpan.FromSeconds( 0.2 ) );
}
else
return ( running ? TimeSpan.FromSeconds( 0.9 ) : TimeSpan.FromSeconds( 1.4 ) ); //changed to assist centaur and orc speeds: turin
//return ( running ? TimeSpan.FromSeconds( 0.15 ) : TimeSpan.FromSeconds( 0.3 ) );
}
*/
//the default constructor called at creation
public MyPlayerMobile()
{
try
{
m_Race = this.Race;
}
catch(Exception e)
{
Console.WriteLine(e);
}
}
//the serial constructor called at world load
public MyPlayerMobile( Serial s ) : base( s )
{
}
//called at every world save
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 3 );
writer.Write( m_InternalMount );
writer.Write( (bool)m_OrcFriend );
writer.Write( (bool)m_DrowFriend );
writer.Write( (int)m_Race );
writer.Write( (int) m_StrCap );
writer.Write( (int) m_DexCap );
writer.Write( (int) m_IntCap );
}
//called by serial constructor at world load
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
switch ( version )
{
case 3:
{
m_InternalMount = reader.ReadItem();
goto case 2;
}
case 2:
{
m_OrcFriend = (bool)reader.ReadBool();
m_DrowFriend = (bool)reader.ReadBool();
goto case 1;
}
case 1:
{
m_Race = (RaceType)reader.ReadInt();
goto case 0;
}
case 0:
{
m_StrCap = reader.ReadInt();
m_DexCap = reader.ReadInt();
m_IntCap = reader.ReadInt();
break;
}
}
RestoreBody();
}
/*
public override void Resurrect()
{
// bool wasAlive = this.Alive;
// Races stuff
RaceType Race = this.Race;
// EO Races stuff
base.Resurrect();
}
*/
}
}