Plant gump issues

http://jira.runuo.com/browse/RUNUO-12

House decay stages should pass at random intervals
http://jira.runuo.com/browse/RUNUO-113

Nature's Fury cast issues
http://jira.runuo.com/browse/RUNUO-114

Animal Form inaccuracies and issue with Talisman of the Fey
http://jira.runuo.com/browse/RUNUO-115

BaseWaterContainer fill messages and behavior
http://jira.runuo.com/browse/RUNUO-116

AdminGump filter for accounts owning houses
http://jira.runuo.com/browse/RUNUO-118

Seeds should be stackable
http://jira.runuo.com/browse/RUNUO-119

Typo in case of a jailbreak
http://jira.runuo.com/browse/RUNUO-120

Prevent creation of invalid account names
http://jira.runuo.com/browse/RUNUO-121
This commit is contained in:
eos 2012-01-01 03:34:02 +00:00
parent d2f79e93ea
commit 4cba2c8d56
18 changed files with 440 additions and 137 deletions

View file

@ -24,6 +24,34 @@ namespace Server.Multis
public static int MaxFriends { get { return !Core.AOS ? 50 : 140; } }
public static int MaxBans { get { return !Core.AOS ? 50 : 140; } }
#region Dynamic decay system
private DecayLevel m_CurrentStage;
private DateTime m_NextDecayStage;
[CommandProperty( AccessLevel.GameMaster )]
public DateTime NextDecayStage
{
get { return m_NextDecayStage; }
set { m_NextDecayStage = value; }
}
public void ResetDynamicDecay()
{
m_CurrentStage = DecayLevel.Ageless;
m_NextDecayStage = DateTime.MinValue;
}
public void SetDynamicDecay( DecayLevel level )
{
m_CurrentStage = level;
if ( DynamicDecay.Decays( level ) )
m_NextDecayStage = DateTime.Now + DynamicDecay.GetRandomDuration( level );
else
m_NextDecayStage = DateTime.MinValue;
}
#endregion
public const bool DecayEnabled = true;
public static void Decay_OnTick()
@ -128,37 +156,73 @@ namespace Server.Multis
}
}
private DecayLevel m_LastDecayLevel;
[CommandProperty( AccessLevel.GameMaster )]
public virtual DecayLevel DecayLevel
{
get
{
DecayLevel result;
if ( !CanDecay )
{
if ( DynamicDecay.Enabled )
ResetDynamicDecay();
m_LastRefreshed = DateTime.Now;
return DecayLevel.Ageless;
result = DecayLevel.Ageless;
}
else if ( DynamicDecay.Enabled )
{
DecayLevel stage = m_CurrentStage;
if ( stage == DecayLevel.Ageless || ( DynamicDecay.Decays( stage ) && m_NextDecayStage <= DateTime.Now ) )
SetDynamicDecay( ++stage );
if ( stage == DecayLevel.Collapsed && ( HasRentedVendors || VendorInventories.Count > 0 ) )
result = DecayLevel.DemolitionPending;
else
result = stage;
}
else
{
result = GetOldDecayLevel();
}
TimeSpan timeAfterRefresh = DateTime.Now - m_LastRefreshed;
int percent = (int) ((timeAfterRefresh.Ticks * 1000) / DecayPeriod.Ticks);
if ( result != m_LastDecayLevel )
{
m_LastDecayLevel = result;
if ( percent >= 1000 ) // 100.0%
return ( HasRentedVendors || VendorInventories.Count > 0 ) ? DecayLevel.DemolitionPending : DecayLevel.Collapsed;
else if ( percent >= 950 ) // 95.0% - 99.9%
return DecayLevel.IDOC;
else if ( percent >= 750 ) // 75.0% - 94.9%
return DecayLevel.Greatly;
else if ( percent >= 500 ) // 50.0% - 74.9%
return DecayLevel.Fairly;
else if ( percent >= 250 ) // 25.0% - 49.9%
return DecayLevel.Somewhat;
else if ( percent >= 005 ) // 00.5% - 24.9%
return DecayLevel.Slightly;
if ( m_Sign != null && !m_Sign.GettingProperties )
m_Sign.InvalidateProperties();
}
return DecayLevel.LikeNew;
return result;
}
}
public DecayLevel GetOldDecayLevel()
{
TimeSpan timeAfterRefresh = DateTime.Now - m_LastRefreshed;
int percent = (int) ((timeAfterRefresh.Ticks * 1000) / DecayPeriod.Ticks);
if ( percent >= 1000 ) // 100.0%
return ( HasRentedVendors || VendorInventories.Count > 0 ) ? DecayLevel.DemolitionPending : DecayLevel.Collapsed;
else if ( percent >= 950 ) // 95.0% - 99.9%
return DecayLevel.IDOC;
else if ( percent >= 750 ) // 75.0% - 94.9%
return DecayLevel.Greatly;
else if ( percent >= 500 ) // 50.0% - 74.9%
return DecayLevel.Fairly;
else if ( percent >= 250 ) // 25.0% - 49.9%
return DecayLevel.Somewhat;
else if ( percent >= 005 ) // 00.5% - 24.9%
return DecayLevel.Slightly;
return DecayLevel.LikeNew;
}
public virtual bool RefreshDecay()
{
if ( DecayType == DecayType.Condemned )
@ -168,6 +232,12 @@ namespace Server.Multis
m_LastRefreshed = DateTime.Now;
if ( DynamicDecay.Enabled )
ResetDynamicDecay();
if ( m_Sign != null )
m_Sign.InvalidateProperties();
return ( oldLevel > DecayLevel.LikeNew );
}
@ -2336,7 +2406,17 @@ namespace Server.Multis
{
base.Serialize( writer );
writer.Write( (int) 14 ); // version
writer.Write( (int) 15 ); // version
if ( !DynamicDecay.Enabled )
{
writer.Write( (int) -1 );
}
else
{
writer.Write( (int) m_CurrentStage );
writer.Write( m_NextDecayStage );
}
writer.Write( (Point3D) m_RelativeBanLocation );
@ -2434,9 +2514,23 @@ namespace Server.Multis
int version = reader.ReadInt();
int count;
bool loadedDynamicDecay = false;
switch ( version )
{
case 15:
{
int stage = reader.ReadInt();
if ( stage != -1 )
{
m_CurrentStage = (DecayLevel)stage;
m_NextDecayStage = reader.ReadDateTime();
loadedDynamicDecay = true;
}
goto case 14;
}
case 14:
{
m_RelativeBanLocation = reader.ReadPoint3D();
@ -2631,6 +2725,16 @@ namespace Server.Multis
if ( version < 11 )
m_LastRefreshed = DateTime.Now + TimeSpan.FromHours( 24 * Utility.RandomDouble() );
if ( DynamicDecay.Enabled && !loadedDynamicDecay )
{
DecayLevel old = GetOldDecayLevel();
if ( old == DecayLevel.DemolitionPending )
old = DecayLevel.Collapsed;
SetDynamicDecay( old );
}
if ( !CheckDecay() )
{
if ( RelocatedEntities.Count > 0 )
@ -2788,7 +2892,11 @@ namespace Server.Multis
{
get
{
return m_Region.GoLocation;
if ( m_Region != null )
return m_Region.GoLocation;
Point3D rel = m_RelativeBanLocation;
return new Point3D( this.X + rel.X, this.Y + rel.Y, this.Z + rel.Z );
}
set
{
@ -2806,7 +2914,9 @@ namespace Server.Multis
set
{
m_RelativeBanLocation = value;
m_Region.GoLocation = new Point3D( this.X + value.X, this.Y + value.Y, this.Z + value.Z );
if ( m_Region != null )
m_Region.GoLocation = new Point3D( this.X + value.X, this.Y + value.Y, this.Z + value.Z );
}
}

View file

@ -0,0 +1,74 @@
using System;
using System.Collections.Generic;
using Server;
namespace Server.Multis
{
public class DynamicDecay
{
public static bool Enabled { get { return Core.ML; } }
private static Dictionary<DecayLevel, DecayStageInfo> m_Stages;
static DynamicDecay()
{
m_Stages = new Dictionary<DecayLevel, DecayStageInfo>();
Register( DecayLevel.LikeNew, TimeSpan.FromHours( 1 ), TimeSpan.FromHours( 1 ) );
Register( DecayLevel.Slightly, TimeSpan.FromDays( 1 ), TimeSpan.FromDays( 2 ) );
Register( DecayLevel.Somewhat, TimeSpan.FromDays( 1 ), TimeSpan.FromDays( 2 ) );
Register( DecayLevel.Fairly, TimeSpan.FromDays( 1 ), TimeSpan.FromDays( 2 ) );
Register( DecayLevel.Greatly, TimeSpan.FromDays( 1 ), TimeSpan.FromDays( 2 ) );
Register( DecayLevel.IDOC, TimeSpan.FromHours( 12 ), TimeSpan.FromHours( 24 ) );
}
public static void Register( DecayLevel level, TimeSpan min, TimeSpan max )
{
DecayStageInfo info = new DecayStageInfo( min, max );
if ( m_Stages.ContainsKey( level ) )
m_Stages[level] = info;
else
m_Stages.Add( level, info );
}
public static bool Decays( DecayLevel level )
{
return m_Stages.ContainsKey( level );
}
public static TimeSpan GetRandomDuration( DecayLevel level )
{
if ( !m_Stages.ContainsKey( level ) )
return TimeSpan.Zero;
DecayStageInfo info = m_Stages[level];
long min = info.MinDuration.Ticks;
long max = info.MaxDuration.Ticks;
return TimeSpan.FromTicks( min + (long)( Utility.RandomDouble() * ( max - min ) ) );
}
}
public class DecayStageInfo
{
private TimeSpan m_MinDuration;
private TimeSpan m_MaxDuration;
public TimeSpan MinDuration
{
get { return m_MinDuration; }
}
public TimeSpan MaxDuration
{
get { return m_MaxDuration; }
}
public DecayStageInfo( TimeSpan min, TimeSpan max )
{
m_MinDuration = min;
m_MaxDuration = max;
}
}
}

View file

@ -71,6 +71,13 @@ namespace Server.Multis
public override bool ForceShowProperties{ get{ return ObjectPropertyList.Enabled; } }
private bool m_GettingProperties;
public bool GettingProperties
{
get { return m_GettingProperties; }
}
public override void GetProperties( ObjectPropertyList list )
{
base.GetProperties( list );
@ -82,7 +89,9 @@ namespace Server.Multis
{
list.Add( m_Owner.Public ? 1061641 : 1061642 ); // This House is Open to the Public : This is a Private Home
m_GettingProperties = true;
DecayLevel level = m_Owner.DecayLevel;
m_GettingProperties = false;
if ( level == DecayLevel.DemolitionPending )
{