This commit is contained in:
mark 2009-06-28 03:36:42 +00:00
parent c63a5f13fa
commit 2204d5fb86
86 changed files with 1077 additions and 257 deletions

View file

@ -105,7 +105,22 @@ namespace Server.Mobiles
private int m_GuildMessageHue, m_AllianceMessageHue;
private List<Mobile> m_AutoStabled;
private List<Mobile> m_AllFollowers;
#region Getters & Setters
public List<Mobile> AutoStabled { get { return m_AutoStabled; } }
public List<Mobile> AllFollowers
{
get
{
if( m_AllFollowers == null )
m_AllFollowers = new List<Mobile>();;
return m_AllFollowers;
}
}
public Server.Guilds.RankDefinition GuildRank
{
get
@ -516,7 +531,11 @@ namespace Server.Mobiles
}
from.SendGump( new NoticeGump( 1060637, 30720, notice, 0xFFC000, 300, 140, null, null ) );
return;
}
if( from is PlayerMobile )
((PlayerMobile)from).ClaimAutoStabledPets();
}
private bool m_NoDeltaRecursion;
@ -768,6 +787,8 @@ namespace Server.Mobiles
private static void OnLogout( LogoutEventArgs e )
{
if( e.Mobile is PlayerMobile )
((PlayerMobile)e.Mobile).AutoStablePets();
}
private static void EventSink_Connected( ConnectedEventArgs e )
@ -989,6 +1010,9 @@ namespace Server.Mobiles
strBase = this.Str; //this.Str already includes GetStatOffset/str
strOffs = AosAttributes.GetValue( this, AosAttribute.BonusHits );
if ( Core.ML && strOffs > 25 )
strOffs = 25;
if ( AnimalForm.UnderTransformation( this, typeof( BakeKitsune ) ) || AnimalForm.UnderTransformation( this, typeof( GreyWolf ) ) )
strOffs += 20;
}
@ -1998,6 +2022,7 @@ namespace Server.Mobiles
private TimeSpan m_LongTermElapse;
private DateTime m_SessionStart;
private DateTime m_LastEscortTime;
private DateTime m_LastPetBallTime;
private DateTime m_NextSmithBulkOrder;
private DateTime m_NextTailorBulkOrder;
private DateTime m_SavagePaintExpiration;
@ -2072,8 +2097,17 @@ namespace Server.Mobiles
set{ m_LastEscortTime = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public DateTime LastPetBallTime
{
get{ return m_LastPetBallTime; }
set{ m_LastPetBallTime = value; }
}
public PlayerMobile()
{
m_AutoStabled = new List<Mobile>();
m_VisList = new List<Mobile>();
m_PermaFlags = new List<Mobile>();
m_AntiMacroTable = new Hashtable();
@ -2260,6 +2294,9 @@ namespace Server.Mobiles
if ( target is BaseCreature && ((BaseCreature)target).InitialInnocent && !((BaseCreature)target).Controlled )
return false;
if ( Core.ML && target is BaseCreature && ((BaseCreature)target).Controlled && this == ((BaseCreature)target).ControlMaster )
return false;
return base.IsHarmfulCriminal( target );
}
@ -2319,6 +2356,11 @@ namespace Server.Mobiles
switch ( version )
{
case 26:
{
m_AutoStabled = reader.ReadStrongMobileList();
goto case 25;
}
case 25:
{
int recipeCount = reader.ReadInt();
@ -2520,6 +2562,8 @@ namespace Server.Mobiles
}
case 0:
{
if( version < 26 )
m_AutoStabled = new List<Mobile>();
break;
}
}
@ -2598,7 +2642,9 @@ namespace Server.Mobiles
base.Serialize( writer );
writer.Write( (int) 25 ); // version
writer.Write( (int) 26 ); // version
writer.Write( m_AutoStabled, true );
if( m_AcquiredRecipes == null )
{
@ -3855,5 +3901,99 @@ namespace Server.Mobiles
m_BuffTable = null;
}
#endregion
public void AutoStablePets()
{
if ( Core.SE && AllFollowers.Count > 0 )
{
for ( int i = 0; i < m_AllFollowers.Count; ++i )
{
BaseCreature pet = AllFollowers[i] as BaseCreature;
if ( pet == null || pet.ControlMaster == null || ( pet.Summoned && !Core.ML ) )
continue;
if ( pet is IMount && ((IMount)pet).Rider != null )
continue;
if ( (pet is PackLlama || pet is PackHorse || pet is Beetle || pet is HordeMinionFamiliar) && (pet.Backpack != null && pet.Backpack.Items.Count > 0) )
continue;
if ( !pet.Summoned && !pet.IsBonded )
continue;
pet.ControlTarget = null;
pet.ControlOrder = OrderType.Stay;
pet.Internalize();
pet.SetControlMaster( null );
pet.SummonMaster = null;
pet.IsStabled = true;
pet.Loyalty = BaseCreature.MaxLoyalty; // Wonderfully happy
Stabled.Add( pet );
m_AutoStabled.Add( pet );
--i;
}
}
}
public void ClaimAutoStabledPets()
{
if( !Core.SE || m_AutoStabled.Count <= 0 )
return;
if( !Alive )
{
SendLocalizedMessage( 1076251 ); // Your pet was unable to join you while you are a ghost. Please re-login once you have ressurected to claim your pets.
return;
}
for ( int i = 0; i < m_AutoStabled.Count; ++i )
{
BaseCreature pet = m_AutoStabled[i] as BaseCreature;
if ( pet == null || pet.Deleted )
{
pet.IsStabled = false;
m_AutoStabled.RemoveAt( i );
if( Stabled.Contains( pet ) )
Stabled.Remove( pet );
--i;
continue;
}
if ( (Followers + pet.ControlSlots) <= FollowersMax )
{
m_AutoStabled.RemoveAt( i );
--i;
pet.SetControlMaster( this );
if ( pet.Summoned )
pet.SummonMaster = this;
pet.ControlTarget = this;
pet.ControlOrder = OrderType.Follow;
pet.MoveToWorld( Location, Map );
pet.IsStabled = false;
pet.Loyalty = BaseCreature.MaxLoyalty; // Wonderfully Happy
if( Stabled.Contains( pet ) )
Stabled.Remove( pet );
}
else
{
SendMessage( 1049612, pet.Name ); // ~1_NAME~ remained in the stables because you have too many followers.
}
}
m_AutoStabled.Clear();
}
}
}