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!

Courageous' Random Encounter Engine

kaiovas

Sorceror
uhm.. failed to initialize, no errors, no messages, only "random encounters... failed to initialize" uhm.. what can i do?:D
i have done everything you wrote:)
thanks:D
 

Courageous

Wanderer
kaiovas said:
uhm.. failed to initialize, no errors, no messages, only "random encounters... failed to initialize" uhm.. what can i do?:D
i have done everything you wrote:)
thanks:D

I'm not at home to check, but I believe you will see this error when it catches an exception directly relating to parsing XML. If I didn't dump the exception after catching it, my bad. Check the loadXml() routine and look around for a catch. This should be sent to Console.WriteLine().

As a guess, you have some miss matching XML somewhere.

Perhaps I'll have write a DTD or schema for this to make error conditions like this more clear...

If you're still having problems monday night, I gladly diagnose your XML file against my installation for you then... I am currently in Las Vegas. :)

C//
 

RavonTUS

Sorceror
Greetings,

I think I have figured out why some items do not decay. In your XML example, the ITEM is a treasure chest. By default, in the RunUO scripts, the property movable is set to false, so it will not decay.

If you could change the prop movable to true, just before you place the item, it will then decay correctly.

-Ravon
 

Courageous

Wanderer
Ahhhhhhhhhh.

Thank you for that, Ravon. I'll do it.

"Omigod, I'm surrounded by chests and I cannot escape."

LAUGH.

C//

p.s., alas, humor aside, I believe people using this system should note that this is a very significant problem. Each undecayed chest is an admin-intervention event to fix. You want to turn off item spawning in any shard you have until the fix is posted or you have fixed it yourself.
 

cefyl

Wanderer
i'm unable to win against that :

Code:
RandomEncounters: Exception encountered attempting to load file: ./Scripts/Custom/RandomEncounters/RandomEncounters.xml
System.FormatException: Input string was not in a correct format.
   at System.Number.ParseSingle(String s, NumberStyles style, NumberFormatInfo i
nfo)
   at System.Single.Parse(String s, NumberStyles style, IFormatProvider provider
)
   at Server.Misc.RandomEncounterEngine.LoadXml()
   at Server.Misc.RandomEncounterEngine.MaybeLoadXml()
RandomEncounters: failed initialization!
I'm using your xml file without editing it.

please, save me !
 

Courageous

Wanderer
cefyl said:
i'm unable to win against that :

Code:
RandomEncounters: Exception encountered attempting to load file: ./Scripts/Custom/RandomEncounters/RandomEncounters.xml
System.FormatException: Input string was not in a correct format.
   at System.Number.ParseSingle(String s, NumberStyles style, NumberFormatInfo i
nfo)
   at System.Single.Parse(String s, NumberStyles style, IFormatProvider provider
)
   at Server.Misc.RandomEncounterEngine.LoadXml()
   at Server.Misc.RandomEncounterEngine.MaybeLoadXml()
RandomEncounters: failed initialization!
I'm using your xml file without editing it.

please, save me !


The problem is, your computer is designated as having a foreign numeric format for floating point. A comma instead of a point before the zero perhaaps?

The fix has been mentioned previously in the thread, but hasn't been posted yet. What you want to do is add a CultureInfo() call to the Single.Parse() call. Search for CultureInfo previously in the file. The call should look like that.

C//
 

cefyl

Wanderer
in fact, i tried that one with no succes :'(

arul said:
I've found a bug in your script.
Code:
29.11.-19:20:15 System.FormatException: Input string was not in a correct format
.
   at System.Number.ParseSingle(String s, NumberStyles style, NumberFormatInfo i
nfo)
   at System.Single.Parse(String s, NumberStyles style, IFormatProvider provider
)
   at Server.Misc.RandomEncounterEngine.LoadXml()
   at Server.Misc.RandomEncounterEngine.MaybeLoadXml()
29.11.-19:20:15 RandomEncounters: failed initialization!

This will need a little fix for non-US people.
Open the RandomEncounters.cs, then put at the above of the script this
Code:
using System.Globalization;
then search through the file for this ( it's there four times )
Code:
float.Parse( [I]something[/I] );
and replace it with
Code:
float.Parse([I]something[/I],  new CultureInfo("en-US"));
also there is Single.Parse() method in use at the line +/- 150 so find it and replace with this
Code:
Single.Parse(probability, new CultureInfo("en-US"));

and.... it works now, although it would be better to make the cultureinfo static in the configuration class and refer to it instead of creating the new instance every time it's needed.

However, great idea and well coded, good job Courageous.
 

Courageous

Wanderer
cefyl said:
in fact, i tried that one with no succes :'(

Strange. Which country are you in?

I'm sorry about this. Globalization issues can be a headache.

I'm not going to be able to do much about this for a few days, as I am out of town. If the problem persists, I can see if there's a way to fool the .net runtime into thinking that I am in your country and then parsing the file that way to duplicate the error. If you do happen to figure out what the problem is, please post, and I will make the repair as soon as possible.

C//
 

Courageous

Wanderer
cefyl said:
seems that changing only this one is working :

Yes that wasw the change I was referring to. It's already been done in my current development tree, but I haven't zipped up a new copy yet.

C//
 

Courageous

Wanderer
random encounters... failed to initialize

The source code seems to say that this error can only happen with as little information as this if it cannot find your RandomEncounters.xml file at the expected place. I was an idiot and returned false from load if the file cannot be found without printining any diagnostics. I'll print out an error message in the next release, but you should look for m_EncountersFile and make sure the location matches where you put the file.

C//
 

IdahoLynxx

Wanderer
Great script! first one i have messed with adding in a long time to my server! but i have a question. So I understand how to add regions to the XML file in the script, my question is what file is it refrencing that i need to work on to add small new regions. Like i want to set up a small region around that small island connected to trinsic?

Thanks!
 

Courageous

Wanderer
IdahoLynxx said:
Great script! first one i have messed with adding in a long time to my server! but i have a question. So I understand how to add regions to the XML file in the script, my question is what file is it refrencing that i need to work on to add small new regions. Like i want to set up a small region around that small island connected to trinsic?

Thanks!

Idaho Lynx:

For the Random Encounter Engine to recognize your new region, if you add it, all you need to do is add a region, and name it. The connection of a facet, to a type of region, to a name of region (e.g., facet felluca, region wilderness, 'covetous entrance') uniquely identifies the region to the engine.

At any given time a player is targeted for an encounter, the engine pulls the region the player is in, determines the facet, finds the type, and checks the name. It then compares that to entries in the .xml file.

Does this answer your question?

C//

p.s., thinking about this, are you familiar with Region Editor?
 

Courageous

Wanderer
kaiovas said:
nothing to do... failed initialization:/

Kaiovas:

I am still in testing for some bugfixes and changes to the engine; however, I believe if you modify your MaybeLoadXml function so that the beginning looks like the snippet below, the system will diagnose your problem for you. If I am wrong about that, after you have tested it, PM me and I will diagnose your .xml file in my own installation, personally.

private static bool MaybeLoadXml()
{
if (!System.IO.File.Exists( m_EncountersFile ))
{
Console.WriteLine( "RandomEncounters: Could not find config file: " + m_EncountersFile );
return false;
}

Best wishes,

C//
 

RavonTUS

Sorceror
Greetings Courageous,

Your script is coming along nicely. One thing you may consider, or at least in my plans for your script, is that I want a player to randomly encounter decorum items as well - lamp post, fire, rocks, debris.

So, I took a look at your code and made this change...

Original Code...
Code:
                //--------------------------------------------------------------
                // some core items won't decay, but we need them to:
                // the code is in the core, and we don't want to modify that,
                // so we will do it here instead
                //--------------------------------------------------------------

                if ( created is Container && !item.Movable )
                {
                    cleanupList.Add(created);
                }

and simply removed the if statement...

Code:
                //--------------------------------------------------------------
                // some core items won't decay, but we need them to:
                // the code is in the core, and we don't want to modify that,
                // so we will do it here instead
                //--------------------------------------------------------------

                //This only deletes Container, I need it to delete all items.
                //if ( created is Container && !item.Movable )
                {
                    cleanupList.Add(created);
                }

It now seems to delete all items and working the way I want it too, although I will continue to test it.

Thank you again,
-Ravon
 

RavonTUS

Sorceror
Greetings,

Oh, one other thing for anyone else using this fabulous script. You can use Arya's Region Editor to create regions, however you will still need to manually add the region name to the scripts in the \Scripts\Regions folder.

For Example....
Code:
using System;
using Server;

namespace Server.Regions
{
	public class MalasDungeon : DungeonRegion
	{
		public static void Initialize()
		{
			Region.AddRegion( new MalasDungeon( "Doom" ) ); 
			Region.AddRegion( new MalasDungeon( "Doom Gauntlet" ) );
[COLOR="Blue"]            //added Regions...
            Region.AddRegion(new MalasDungeon("DoomEntrance"));
            Region.AddRegion(new MalasDungeon("DoomExit"));
            Region.AddRegion(new MalasDungeon("DoomC"));
            Region.AddRegion(new MalasDungeon("DoomD"));
            Region.AddRegion(new MalasDungeon("DoomE"));
            Region.AddRegion(new MalasDungeon("DoomF"));
            Region.AddRegion(new MalasDungeon("DoomG"));
            Region.AddRegion(new MalasDungeon("DoomH"));
            Region.AddRegion(new MalasDungeon("DoomI"));

[/COLOR]		}

		public MalasDungeon( string name ) : base( name, Map.Malas )
		{
		}
	}
}
-Ravon
 

Courageous

Wanderer
//This only deletes Container, I need it to delete all items.
//if ( created is Container && !item.Movable )
{
cleanupList.Add(created);
}

Ravon,

Won't this now delete items in the players backpack? I'll experiment with that; an option there is to look at the item as the cleanup timer fires, and see if there are things about it that would make it not want to be deleted. I already had to do the same thing for tamed creatures, so there's an obvious place for it.

When I was implementing this, what I really wanted to do was set a Decays property on the item to "false"; alas, the base item doesn't support that. It probably should, but toying around with the core isn't on my list right now, except for major functionality that the core team mike really, really like. :)

Anyway, I'm so glad to hear that you are combining new regions with the editor with the encounter engine. This is a functionality that I'd hope someone would try! As you get detailed with it, please say some words about your results. One option posted in my logs would be for me to run some regions on different timers... that would require some significant rewickering of the way that things are organized internally, I think, but might be worth it in some cases (e.g., especially for dungeons).

C//
 
Top