Go Back   RunUO - Ultima Online Emulation > RunUO > Custom Script Releases

Custom Script Releases This forum is where you can release your custom scripts for other users to use.

Please note: By releasing your scripts here you are submitting them to the public and as such agree to make them public domain. The RunUO Team has made its software GPL for you to use and enjoy you should do the same for anything based off of RunUO.

Reply
 
Thread Tools Display Modes
Old 08-25-2006, 12:28 PM   #1 (permalink)
Master of the Internet
 
Join Date: Aug 2003
Posts: 5,688
Default [RunUO 2.0 RC1] PlayerRangeSensitiveMod

PlayerRangeSensitiveMod
v2.0
RunUO 2.0 version
updated 8/25/06
ArteGordon


Summary:

AI mod that provides most of the benefits of having PlayerRangeSensitive=false (continuously active AI) with virtually none of the server load.


Recent Updates:

New to version 2.0
updated 8/25/06

- Greatly simplified the overall mod.
- installation instructions updated for RunUO 2.0

Description:

This mod resulted from a great idea by KillerBeez to allow servers to set PlayerRangeSensitive=true but still have mobs to behave as though it were false for some period of time even when players are out of range.
What this mod does is to allow creature AI to remain active for a delay period (set by the DeactivationDelay property, default is 2 minutes) after AI deactivation is triggered (when players go out of range). This essentially allows mob AI to behave as though PlayerRangeSensitive=false when players have been around but then move well beyond the normal range sensitivity (e.g. to other maps, or outside of dungeons), while leaving it true (hence no cpu load) for the vast majority of areas without any recent player activity.

This is particularly effective on shards with low player counts since it provides most of the benefits of PlayerRangeSensitive=false with virtually none of the load.
One thing that I especially like is that with the mod, mobs will no longer collect at dungeon entrances!

I would estimate that shards that are currently running with PlayerRangeSensitive=false, could set it to true, put the delay at something like 10-20 minutes and get behavior that was essentially indistinguishable from PlayerRangeSensitive=false but with 50-90% reduction in overall cpu load. Even at longer delay settings (hours) I would estimate significant reductions in overall cpu load given that significant fractions of each facet are likely to be unvisited over the course of an hour or two and the cpu load reduction will be esentially proportional to this fraction.

Commands:

- the "[setdeactivation [minutes]" command allows an admin to change the default deactivation delay in-game.

Note, setting it to zero will essentially disable the mod returning to the normal PlayerRangeSensitive=true behavior.
Also, changed values in-game will not be restored on server restarts. For permanent change of the deactivation delay, set the DefaultDeactivationDelay static variable in setdeactivation.cs


Installation:

see the installation notes in the PlayerRangeSensitiveMod.txt file for details.
Attached Files
File Type: zip PlayerRangeSensitiveMod-20-v20.zip (2.7 KB, 249 views)
__________________
The first line of the first rule in the forum rules and guidelines "Be respectful of others. "

For questions, information, and support for XmlSpawner and its addons, visit the
XmlSpawner Support Forum

Last edited by ArteGordon; 01-27-2007 at 11:39 AM.
ArteGordon is offline   Reply With Quote
Old 08-25-2006, 12:51 PM   #2 (permalink)
Forum Expert
 
Join Date: May 2005
Age: 29
Posts: 949
Default

Great idea. Simple but elegant...
Irian is offline   Reply With Quote
Old 08-25-2006, 02:04 PM   #3 (permalink)
Master of the Internet
 
Join Date: Aug 2003
Posts: 5,688
Default

- added a mod to OnMapChange that will automatically reactivate AI on creatures that are returning from the internal map, like stabled pets.

The standard behavior is to just let the AI run on internalized mobs. The posted mod turns off AI when internalized and then restarts it when they are restored.
I can't think of any reason why you would want AI running on creatures with internal or null maps, but if someone does think of something, let me know.

Note, that part of the mod isnt required for the enhanced playerrangesensitive behavior, I just added it in because it seemed better, so if you dont want to perform the parts of the mod not explicitly marked with

// begin PlayerRangeSensitiveMod
// end PlayerRangeSensitiveMod

that is ok.
__________________
The first line of the first rule in the forum rules and guidelines "Be respectful of others. "

For questions, information, and support for XmlSpawner and its addons, visit the
XmlSpawner Support Forum
ArteGordon is offline   Reply With Quote
Old 08-25-2006, 02:36 PM   #4 (permalink)
Forum Newbie
 
Join Date: Mar 2003
Posts: 85
Default

thnx ArteGordon
Vertigo is offline   Reply With Quote
Old 08-25-2006, 03:43 PM   #5 (permalink)
Forum Novice
 
madphatboy2's Avatar
 
Join Date: Oct 2003
Posts: 222
Default

Dude, you are a total stud. I was recently having issues with something along this line, and then *POOF* here is your mod. +++Karma
madphatboy2 is offline   Reply With Quote
Old 08-26-2006, 02:40 AM   #6 (permalink)
Forum Novice
 
Cheetah2003's Avatar
 
Join Date: Jun 2006
Location: Laramie, Wyoming
Age: 37
Posts: 360
Send a message via ICQ to Cheetah2003 Send a message via AIM to Cheetah2003 Send a message via MSN to Cheetah2003 Send a message via Yahoo to Cheetah2003
Default

Quote:
Originally Posted by ArteGordon
- added a mod to OnMapChange that will automatically reactivate AI on creatures that are returning from the internal map, like stabled pets.

The standard behavior is to just let the AI run on internalized mobs. The posted mod turns off AI when internalized and then restarts it when they are restored.
I can't think of any reason why you would want AI running on creatures with internal or null maps, but if someone does think of something, let me know.

Note, that part of the mod isnt required for the enhanced playerrangesensitive behavior, I just added it in because it seemed better, so if you dont want to perform the parts of the mod not explicitly marked with

// begin PlayerRangeSensitiveMod
// end PlayerRangeSensitiveMod

that is ok.
Ah cool. I was having an issue with this since installing this mod yesterday. Mounted pets are placed on internal map, so when I dismounted and told my pet to do something it'd just stand there looking dumb. I had just finished a fix in BaseMount.cs, but yours is much more elegant and covers every instance of pets returning from Map.Internal. Thanks!!
Cheetah2003 is offline   Reply With Quote
Old 03-13-2008, 11:43 AM   #7 (permalink)
atf
Lurker
 
Join Date: Jul 2004
Age: 28
Posts: 8
Lightbulb

Great idea, excellent work.
I wonder, does it work on RC2?
atf is offline   Reply With Quote
Old 03-13-2008, 04:47 PM   #8 (permalink)
Master of the Internet
 
Join Date: Aug 2003
Posts: 5,688
Default

Quote:
Originally Posted by atf View Post
Great idea, excellent work.
I wonder, does it work on RC2?
yes, works fine with RC2 and all SVNs so far.
__________________
The first line of the first rule in the forum rules and guidelines "Be respectful of others. "

For questions, information, and support for XmlSpawner and its addons, visit the
XmlSpawner Support Forum
ArteGordon is offline   Reply With Quote
Old 04-23-2008, 11:50 AM   #9 (permalink)
Forum Expert
 
nadious's Avatar
 
Join Date: Jan 2003
Location: (Near) Atlanta, GA
Posts: 369
Default

Arte,

I was trying to install this mod and had a question:

In the docs, is says:

Quote:
and around line 3050 add the OnMapChange method

Code:
        // ARTEGORDONMOD
        // begin reactivate AI on map change
        protected override void OnMapChange(Map oldMap)
        {
            Map map = this.Map;

            if (m_AI != null && map != null && map.GetSector(this.Location).Active)
                m_AI.Activate();

            base.OnMapChange(oldMap);
        }
        // end reactivate AI on map change

        protected override void OnLocationChange(Point3D oldLocation)
        {
            Map map = this.Map;

            if (PlayerRangeSensitive && m_AI != null && map != null && map.GetSector(this.Location).Active)
                m_AI.Activate();

            base.OnLocationChange(oldLocation);
        }
There is no 'OnMapChange' method, but a 'OnLocationChange', instead, around 3050. Should the 'OnMapChange' portions of the script be changed to 'OnLocationChange' or should I leave it like it is?

I'm running SVN 295.
__________________
Play HeroScape? Check out our map site here: http://heroscape.catalystradio.com
nadious is offline   Reply With Quote
Old 04-23-2008, 12:46 PM   #10 (permalink)
Master of the Internet
 
Join Date: Aug 2003
Posts: 5,688
Default

you need to add the OnMapChange method as it is shown. As you mentioned, there isnt one there in the default basecreature.cs script.

Quote:

and around line 3050 add the OnMapChange method

Code:
        // ARTEGORDONMOD
        // begin reactivate AI on map change
        protected override void OnMapChange(Map oldMap)
        {
            Map map = this.Map;

            if (m_AI != null && map != null && map.GetSector(this.Location).Active)
                m_AI.Activate();

            base.OnMapChange(oldMap);
        }
        // end reactivate AI on map change
The OnLocationChange method shown is just there to give you a suggestion as to where to put it in the script. You dont need to modify that at all.
__________________
The first line of the first rule in the forum rules and guidelines "Be respectful of others. "

For questions, information, and support for XmlSpawner and its addons, visit the
XmlSpawner Support Forum
ArteGordon is offline   Reply With Quote
Old 04-23-2008, 01:41 PM   #11 (permalink)
Forum Expert
 
nadious's Avatar
 
Join Date: Jan 2003
Location: (Near) Atlanta, GA
Posts: 369
Default

10-4. Appreciate it. You can tell I'm still wet behind the ears when it comes to this scripting stuff.
__________________
Play HeroScape? Check out our map site here: http://heroscape.catalystradio.com
nadious is offline   Reply With Quote
Old 04-23-2008, 02:20 PM   #12 (permalink)
Newbie
 
Join Date: Apr 2005
Age: 28
Posts: 26
Default

This is a fantastic script, Arte. You have my thanks for releasing this and all your other awesome stuff.
Wardka is offline   Reply With Quote
Old 04-25-2008, 04:33 PM   #13 (permalink)
Forum Novice
 
Hanse_T_Insane's Avatar
 
Join Date: Jan 2007
Location: Mount Morris New York
Age: 47
Posts: 215
Send a message via Skype™ to Hanse_T_Insane
Default

i put it in and now this

Code:
RunUO - [www.runuo.com] Version 2.0, Build 2959.20979
Core: Running on .NET Framework Version 2.0.50727
Core: Optimizing for 2 processors
Scripts: Compiling C# scripts...failed (1 errors, 0 warnings)
Errors:
 + Engines/AI/Creature/BaseCreature.cs:
    CS1513: Line 3050: } expected
Scripts: One or more scripts failed to compile or no script files were found.
 - Press return to exit, or R to try again.
here is what i did

Code:
{
			if ( Combatant != null )
				return false; // in combat.. not idling

			if ( m_IdleReleaseTime > DateTime.MinValue )
			{
				// idling...

				if ( DateTime.Now >= m_IdleReleaseTime )
				{
					m_IdleReleaseTime = DateTime.MinValue;
					return false; // idle is over
				}

				return true; // still idling
			}

			if ( 95 > Utility.Random( 100 ) )
				return false; // not idling, but don't want to enter idle state

			m_IdleReleaseTime = DateTime.Now + TimeSpan.FromSeconds( Utility.RandomMinMax( 15, 25 ) );
			
        // ARTEGORDONMOD
        // begin reactivate AI on map change
        protected override void OnMapChange(Map oldMap)
        {
            Map map = this.Map;

            if (m_AI != null && map != null && map.GetSector(this.Location).Active)
                m_AI.Activate();

            base.OnMapChange(oldMap);
        }
        // end reactivate AI on map change

        protected override void OnLocationChange(Point3D oldLocation)
        {
            Map map = this.Map;

            if (PlayerRangeSensitive && m_AI != null && map != null && map.GetSector(this.Location).Active)
                m_AI.Activate();

            base.OnLocationChange(oldLocation);
        			

			if ( Body.IsHuman )
			{
				switch ( Utility.Random( 2 ) )
				{
					case 0: Animate( 5, 5, 1, true,  true, 1 ); break;
					case 1: Animate( 6, 5, 1, true, false, 1 ); break;
				}	
			}
			else if ( Body.IsAnimal )
			{
				switch ( Utility.Random( 3 ) )
				{
					case 0: Animate(  3, 3, 1, true, false, 1 ); break;
					case 1: Animate(  9, 5, 1, true, false, 1 ); break;
					case 2: Animate( 10, 5, 1, true, false, 1 ); break;
				}
			}
			else if ( Body.IsMonster )
			{
				switch ( Utility.Random( 2 ) )
				{
					case 0: Animate( 17, 5, 1, true, false, 1 ); break;
					case 1: Animate( 18, 5, 1, true, false, 1 ); break;
				}
			}

			PlaySound( GetIdleSound() );
			return true; // entered idle state
suggestions pls?
Hanse_T_Insane is offline   Reply With Quote
Old 04-25-2008, 04:59 PM   #14 (permalink)
Forum Expert
 
Greystar's Avatar
 
Join Date: Mar 2004
Location: NorthCentral IL, USA
Age: 35
Posts: 3,848
Default

Quote:
Originally Posted by Hanse_T_Insane View Post
i put it in and now this

Code:
RunUO - [www.runuo.com] Version 2.0, Build 2959.20979
Core: Running on .NET Framework Version 2.0.50727
Core: Optimizing for 2 processors
Scripts: Compiling C# scripts...failed (1 errors, 0 warnings)
Errors:
 + Engines/AI/Creature/BaseCreature.cs:
    CS1513: Line 3050: } expected
Scripts: One or more scripts failed to compile or no script files were found.
 - Press return to exit, or R to try again.
here is what i did

Code:
{
			if ( Combatant != null )
				return false; // in combat.. not idling

			if ( m_IdleReleaseTime > DateTime.MinValue )
			{
				// idling...

				if ( DateTime.Now >= m_IdleReleaseTime )
				{
					m_IdleReleaseTime = DateTime.MinValue;
					return false; // idle is over
				}

				return true; // still idling
			}

			if ( 95 > Utility.Random( 100 ) )
				return false; // not idling, but don't want to enter idle state

			m_IdleReleaseTime = DateTime.Now + TimeSpan.FromSeconds( Utility.RandomMinMax( 15, 25 ) );
			
        // ARTEGORDONMOD
        // begin reactivate AI on map change
        protected override void OnMapChange(Map oldMap)
        {
            Map map = this.Map;

            if (m_AI != null && map != null && map.GetSector(this.Location).Active)
                m_AI.Activate();

            base.OnMapChange(oldMap);
        }
        // end reactivate AI on map change

        protected override void OnLocationChange(Point3D oldLocation)
        {
            Map map = this.Map;

            if (PlayerRangeSensitive && m_AI != null && map != null && map.GetSector(this.Location).Active)
                m_AI.Activate();

            base.OnLocationChange(oldLocation);
        			

			if ( Body.IsHuman )
			{
				switch ( Utility.Random( 2 ) )
				{
					case 0: Animate( 5, 5, 1, true,  true, 1 ); break;
					case 1: Animate( 6, 5, 1, true, false, 1 ); break;
				}	
			}
			else if ( Body.IsAnimal )
			{
				switch ( Utility.Random( 3 ) )
				{
					case 0: Animate(  3, 3, 1, true, false, 1 ); break;
					case 1: Animate(  9, 5, 1, true, false, 1 ); break;
					case 2: Animate( 10, 5, 1, true, false, 1 ); break;
				}
			}
			else if ( Body.IsMonster )
			{
				switch ( Utility.Random( 2 ) )
				{
					case 0: Animate( 17, 5, 1, true, false, 1 ); break;
					case 1: Animate( 18, 5, 1, true, false, 1 ); break;
				}
			}

			PlaySound( GetIdleSound() );
			return true; // entered idle state
suggestions pls?
Right before
// ARTEGORDONMOD
add }
__________________
Quote:
(\__/)
(='.'=)This is Bunny. Copy and paste bunny into your
(")_(")signature to help him gain world domination.
Killable Guards (GS Version)
Just a Simple Staff Tool
You can leave me messages.
Ernest Gary Gygax - Quote "I would like the world to remember me as the guy who really enjoyed playing games and sharing his knowledge and his fun pastimes with everybody else."
Greystar is offline   Reply With Quote
Old 04-25-2008, 06:50 PM   #15 (permalink)
Forum Novice
 
Hanse_T_Insane's Avatar
 
Join Date: Jan 2007
Location: Mount Morris New York
Age: 47
Posts: 215
Send a message via Skype™ to Hanse_T_Insane
Default

Thank you very much
Hanse_T_Insane is offline   Reply With Quote
Old 05-07-2008, 07:19 PM   #16 (permalink)
Forum Novice
 
Hanse_T_Insane's Avatar
 
Join Date: Jan 2007
Location: Mount Morris New York
Age: 47
Posts: 215
Send a message via Skype™ to Hanse_T_Insane
Default

If the time is set to low, will this cause the spawn to cease all movement shortly after spawning?
Hanse_T_Insane is offline   Reply With Quote
Old 09-21-2008, 02:14 PM   #17 (permalink)
Newbie
 
Join Date: Jan 2004
Posts: 98
Default

The file for download seems corrupted, anybody has a working copy they can share with me? Thanks.

Edit: Never mind, I got it.

Last edited by Rocko Wang; 09-21-2008 at 02:21 PM.
Rocko Wang is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5