D4rkh0bb1T

Member
Good evening, i'm having issue with the decay level of houses. Not sure what should be done in scripts to make my house decay over few months for exemple. Right now, houses decay very rapidly in a matter of days, not good at all!

Grandfathered decay's level does not fit what's written in my DynamicDecay.cs,
and i'm not sure if I should remove the ! check in the BaseHouse.cs -
I also notice that Core.ML is bool enabled in top DynamicDecay script, shouldnt be Core.AOS?

What are your tips on that?

DynamicDecay:
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.FromDays( 30 ),        TimeSpan.FromDays( 30 )        );
            Register( DecayLevel.Slightly,        TimeSpan.FromDays( 30 ),        TimeSpan.FromDays( 30 )        );
            Register( DecayLevel.Somewhat,        TimeSpan.FromDays( 30 ),        TimeSpan.FromDays( 30 )        );
            Register( DecayLevel.Fairly,        TimeSpan.FromDays( 30 ),        TimeSpan.FromDays( 30 )        );
            Register( DecayLevel.Greatly,        TimeSpan.FromDays( 30 ),        TimeSpan.FromDays( 30 )        );
            Register( DecayLevel.IDOC,            TimeSpan.FromHours( 24 ),    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;
        }
    }
}
BaseHouse:
if ( !Core.AOS )
    return DecayType.ManualRefresh;

if ( acct.Inactive )
    return DecayType.Condemned;
 
in BaseHouse.cs search to
"public const bool DecayEnabled = true;"
set true to "false" and your house never decay
 
Thanks for replying. I want my houses to decay, but they totally decayed after few days instead of months. I have set the return Core.ML to Core.AOS, it seems to have fix my issue since it was looking for another expansion. (AoS here)
 
Thanks for replying. I want my houses to decay, but they totally decayed after few days instead of months. I have set the return Core.ML to Core.AOS, it seems to have fix my issue since it was looking for another expansion. (AoS here)
In publish 57 > Basehouse.CS > I solve this around line 51. I commented out and added,

//NextDecayStage = DateTime.UtcNow + DynamicDecay.GetRandomDuration(level);
NextDecayStage = DateTime.UtcNow.AddDays(180);

I also did not want players first houses to be auto renewed (never decay). To solve this I navigated towards line 100 and made the following adjustment,

//if (!Core.AOS)
if (Core.AOS)

Based off my testing and past research, house decays go through 6 stages. The AddDays(##); adjustment then will go into effect 6 times. So roughly this will cause houses to decay when inactive for roughly 1,080 days or roughly 3 years. For a virgin server I'm not to worried about land just yet and I can see adjusting this variable down works just as easily (Granted server needs to be restarted between code changes).

This is my first crack at this and I'm sure there is a more elegant code adjustment out there. I'm tempted to try to get the random duration to work again but to help call out a smaller day range when the house is in its final stage (sheesh can you imagen waiting 180 days for a house to randomly drop >:) )
 
Last edited:

Active Shards

Donations

Total amount
$80.00
Goal
$1,000.00
Back