RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

how to disable nightsight in a specific dungeon

pooka01

Sorceror
Check what sets the light level in the nightsight spell, when entering the region, do the invert process?
For razor you can just get the razor negociator, it works pretty well.
 

adamg6284

Squire
right but isnt that how the program works? like it gives you an option of either turning off those features or being disconnected? if i turn it off then what's the point of having it?
 

adamg6284

Squire
ok it seems to have worked :) only thing is when you log in with razor and if you're ina dungeon youll still have the nightsight filter but if you leave and re enter itll be dark... so now about making it so that you cant use nightsight in a certain dungeon.. i have a dungeon called "Penumbra" and I want it to be so that you can't use nightsight in it. how would i write that?
 

pooka01

Sorceror
hm, editing scripts and all, but that would be a bit complicated. Try playing with regions.
Or try to edit the razor feature disabler to only work if you are in a certain region -- your dungeon.
 

adamg6284

Squire
im looking at the resurrection spell and how it has it so that if you're in the region named khaldun you can not resurrect. i tried editing the nightsight spell in a similar way but it did nothing.
 

milva

Sorceror
Is this a new region which you set up in region.xml? If not then maybe Custom Regions in a box
would help, since you can disable spells. There is also a program named Region Editor released on here.
I create my own region in region.xml then along with a custom script which goes into
the custom folder, within this script spells can be disabled.
How to create your own region--JamzeMcC explains here how to set up a new region in Region.xml
http://www.runuo.com/community/threads/how-do-i-make-citadel-unmarkable.481354/#post-3724149
 

Djeryv

Sorceror
You can't really "dis-allow" Razor so just try and assume they are gonna use it. Below is my RazorNegotiator.cs (just drop it in your server custom script folder) that blocks the "lightlevel" stuff...

Code:
using System;
using Server;
using System.Collections;
using Server.Network;
using Server.Gumps;
 
namespace Server.Misc
{
    public class RazorFeatureControl
    {
        public const bool Enabled = true; // Is the "Feature Enforced" turned on?
        public const bool KickOnFailure = true; // When true, this will cause anyone who does not negotiate (include those not running Razor at all) to be disconnected from the server.
        public static readonly TimeSpan HandshakeTimeout = TimeSpan.FromSeconds( 30.0 ); // How long to wait for a handshake response before showing warning and disconnecting
        public static readonly TimeSpan DisconnectDelay = TimeSpan.FromSeconds( 15.0 ); // How long to show warning message before they are disconnected
        public const string WarningMessage = "The server was unable to negotiate features with Razor on your system.<BR>You must be running the <A HREF=\"http://razor.runuo.com/download.php\">latest version of Razor</A> to play on this server.<BR>Once you have Razor installed and running, go to the <B>Options</B> tab and check the box in the lower right-hand corner marked <B>Negotiate features with server</B>.  Once you have this box checked, you may log in and play normally.<BR>You will be disconnected shortly.";
 
        public static void Configure()
        {
            DisallowFeature( RazorFeatures.FilterWeather );
            DisallowFeature( RazorFeatures.FilterLight );
        }
 
        [Flags]
        public enum RazorFeatures : ulong
        {
            None = 0,
 
            FilterWeather    = 1 << 0, // Weather Filter
            FilterLight    = 1 << 1, // Light Filter
            SmartTarget    = 1 << 2, // Smart Last Target
            RangedTarget    = 1 << 3, // Range Check Last Target
            AutoOpenDoors    = 1 << 4, // Automatically Open Doors
            DequipOnCast    = 1 << 5, // Unequip Weapon on spell cast
            AutoPotionEquip    = 1 << 6, // Un/Re-equip weapon on potion use
            PoisonedChecks    = 1 << 7, // Block heal If poisoned/Macro IIf Poisoned condition/Heal or Cure self
            LoopedMacros    = 1 << 8, // Disallow Looping macros, For loops, and macros that call other macros
            UseOnceAgent    = 1 << 9, // The use once agent
            RestockAgent    = 1 << 10,// The restock agent
            SellAgent    = 1 << 11,// The sell agent
            BuyAgent    = 1 << 12,// The buy agent
            PotionHotkeys    = 1 << 13,// All potion hotkeys
            RandomTargets    = 1 << 14,// All random target hotkeys (Not target next, last target, target self)
            ClosestTargets    = 1 << 15,// All closest target hotkeys
            OverheadHealth    = 1 << 16,// Health and Mana/Stam messages shown over player's heads
 
            All = 0xFFFFFFFFFFFFFFFF  // Every feature possible
        }
 
        private static RazorFeatures m_DisallowedFeatures = RazorFeatures.None;
 
        public static void DisallowFeature( RazorFeatures feature )
        {
            SetDisallowed( feature, true );
        }
 
        public static void AllowFeature( RazorFeatures feature )
        {
            SetDisallowed( feature, false );
        }
 
        public static void SetDisallowed( RazorFeatures feature, bool value )
        {
            if ( value )
                m_DisallowedFeatures |= feature;
            else
                m_DisallowedFeatures &= ~feature;
        }
 
        public static RazorFeatures DisallowedFeatures { get { return m_DisallowedFeatures; } }
    }
 
    public class RazorFeatureEnforcer
    {
        private static Hashtable m_Table = new Hashtable();
        private static TimerStateCallback OnHandshakeTimeout_Callback = new TimerStateCallback( OnHandshakeTimeout );
        private static TimerStateCallback OnForceDisconnect_Callback = new TimerStateCallback( OnForceDisconnect );
       
        public static void Initialize()
        {
            if ( RazorFeatureControl.Enabled )
            {
                EventSink.Login += new LoginEventHandler( EventSink_Login );
 
                ProtocolExtensions.Register( 0xFF, true, new OnPacketReceive( OnHandshakeResponse ) );
            }
        }
 
        private static void EventSink_Login( LoginEventArgs e )
        {
            Mobile m = e.Mobile;
            if ( m != null && m.NetState != null && m.NetState.Running )
            {
                Timer t;
 
                m.Send( new BeginRazorHandshake() );
 
                m.CheckLightLevels( true );
               
                if ( m_Table.ContainsKey( m ) )
                {
                    t = m_Table[m] as Timer;
                    if ( t != null && t.Running )
                        t.Stop();
                }
 
                m_Table[m] = t = Timer.DelayCall( RazorFeatureControl.HandshakeTimeout, OnHandshakeTimeout_Callback, m );
                t.Start();
            }
        }
       
        private static void OnHandshakeResponse( NetState state, PacketReader pvSrc )
        {
            pvSrc.Trace( state );
 
            if ( state == null || state.Mobile == null || !state.Running )
                return;
 
            Mobile m = state.Mobile;
            Timer t = null;
            if ( m_Table.Contains( m ) )
            {
                t = m_Table[m] as Timer;
 
                if ( t != null )
                    t.Stop();
 
                m_Table.Remove( m );
            }
        }
 
        private static void OnHandshakeTimeout( object state )
        {
            Timer t = null;
            Mobile m = state as Mobile;
            if ( m == null )
                return;
 
            m_Table.Remove( m );
 
            if ( !RazorFeatureControl.KickOnFailure )
            {
                Console.WriteLine( "Player '{0}' failed to negotiate Razor features.", m );
            }
            else if ( m.NetState != null && m.NetState.Running )
            {
                m.SendGump( new Gumps.WarningGump( 1060635, 30720, RazorFeatureControl.WarningMessage, 0xFFC000, 420, 250, null, null ) );
 
                m_Table[m] = t = Timer.DelayCall( RazorFeatureControl.DisconnectDelay, OnForceDisconnect_Callback, m );
                t.Start();
            }
        }
 
        private static void OnForceDisconnect( object state )
        {
            if ( state is Mobile )
            {
                Mobile m = (Mobile)state;
 
                if ( m.NetState != null && m.NetState.Running )
                    m.NetState.Dispose();
                m_Table.Remove( m );
 
                Console.WriteLine( "Player {0} kicked (Failed Razor handshake)", m );
            }
        }
 
        private sealed class BeginRazorHandshake : ProtocolExtension
        {
            public BeginRazorHandshake() : base( 0xFE, 8 )
            {
                m_Stream.Write( (uint)((ulong)RazorFeatureControl.DisallowedFeatures >> 32) );
                m_Stream.Write( (uint)((ulong)RazorFeatureControl.DisallowedFeatures & 0xFFFFFFFF) );
            }
        }
    }
}

Now here is a simple DarkRegion.cs (or whatever name you want to give it I guess) and then you can just put a region in Regions.xml with a type="DarkRegion" in it. This only stops the spell from being cast while in the area.

Code:
using System;
using System.Xml;
using Server;
using Server.Mobiles;
using Server.Gumps;
using Server.Spells;
using Server.Spells.Seventh;
using Server.Spells.Fourth;
using Server.Spells.Sixth;
using Server.Spells.Chivalry;
 
namespace Server.Regions
{
    public class DarkRegion : BaseRegion
    {
        public DarkRegion( XmlElement xml, Map map, Region parent ) : base( xml, map, parent )
        {
        }
 
        public override bool AllowHousing( Mobile from, Point3D p )
        {
            return false;
        }
 
        public override bool OnBeginSpellCast( Mobile m, ISpell s )
        {
            if ( s is NightSightSpell )
            {
                m.SendMessage( "That spell does not seem to work in this place." );
                return false;
            }
            else
            {
                return base.OnBeginSpellCast( m, s );
            }
        }
    }
}

Although this is all the limits to my knowledge on the subject, there are a bunch more variables to consider. What about potions? What about items with Night Sight attributes? You would almost need a way to set the light level when one enters the region, but nothing stops them from drinking another potion or removing (and then re-adding) a piece of Night Sight equipment.

Now this is from my PlayerMobile.cs script. What I did here is basically I have no elves on my server, humans only. What I did not like is that a piece of Night Sight gear was brighter than the potions were. I wanted a little bit of ambiance from the light sources in the world. So I made sure that my Night Sight gear was as good as the Night Sight potions.

Code:
        public override void ComputeBaseLightLevels( out int global, out int personal )
        {
            global = LightCycle.ComputeLevelFor( this );
 
            bool racialNightSight = (Core.ML && this.Race == Race.Elf);
 
            if ( this.LightLevel < 26 && racialNightSight )
                personal = 26;
 
            else if ( this.LightLevel < 13 && AosAttributes.GetValue( this, AosAttribute.NightSight ) > 0 ) // ADDED FOR NIGHT SIGHT ITEMS TO BE LIKE POTIONS
                personal = 13;
 
            else
                personal = this.LightLevel;
        }

That's all I know!
 
Top