Random Encounters?

Finaltwist

Rookie
Sep 7, 2019
88
10
8
Good afternoon all,

Does anyone know of any scripts that add random encounters? Like in OSI where you have random bandit or prisoner camps as you explore the world... looks like this feature isn't present?
 

Falkor

Squire
Apr 11, 2018
252
88
28
wpshard.com
Shard Name
Whispering Pines
There is the Courageous Random Encounter System (that's not an adjective; it's named after the scripter Courageous). I can't find it for download by itself but it is part of some of the "whole shard" downloads here.

I could try to create a usable distribution out of files I have on hand but I'll need to edit them to remove shard-specific things first. It was created for RunUO RC1 so I have no idea how compatible it is with current ServUO.
 

Falkor

Squire
Apr 11, 2018
252
88
28
wpshard.com
Shard Name
Whispering Pines
Here is the system. It may or may not run in ServUO but I've used it for a long time with RunUO 2.0 final without any stability issues. Carefully follow the ReadMe file!

I renamed the file extensions inside the ArteGordon folder to .off because my server didn't like them but they're included here for the sake of completeness.
 

Attachments

Finaltwist

Rookie
Sep 7, 2019
88
10
8
Here is the system. It may or may not run in ServUO but I've used it for a long time with RunUO 2.0 final without any stability issues. Carefully follow the ReadMe file!

I renamed the file extensions inside the ArteGordon folder to .off because my server didn't like them but they're included here for the sake of completeness.
Hi Falkor, thanks for your help here... I"m installing this script in uo odyssey (runuo) and getting the following error

C#:
Errors:
 + Custom/RandomEncounters/XmlDateCount.cs:
    CS0246: Line 7: The type or namespace name 'XmlDate' could not be found (are you missing a using directive or an assembly reference?)
    CS0246: Line 14: The type or namespace name 'ASerial' could not be found (are you missing a using directive or an assembly reference?)
    CS0246: Line 18: The type or namespace name 'Attachable' could not be found (are you missing a using directive or an assembly reference?)
    CS0246: Line 18: The type or namespace name 'AttachableAttribute' could not be found (are you missing a using directive or an assembly reference?)
Looks like the package you provided has a file called xmldate.cs.off which isn't loading. adding that file adds a bunch of other errors.
Could i impose and ask for some guidance?
Post automatically merged:

edit: to make it easier for you... here is the content of the xmldatecount.cs file
C#:
//------------------------------------------------------------------------------
using System;
using Server;
//------------------------------------------------------------------------------
namespace Server.Engines.XmlSpawner2
{
    public class XmlDateCount : XmlDate
    {
        private int m_Count = 0;

        [CommandProperty( AccessLevel.GameMaster )]
        public int Count { get{ return m_Count; } set { m_Count = value; } }

        public XmlDateCount( ASerial serial ) : base( serial )
        {
        }

        [Attachable]
        public XmlDateCount( string name ) : base ( name )
        {
            m_Count = 0;
        }

        public override void Serialize( GenericWriter writer )
        {
            base.Serialize(writer);

            writer.Write( (int) 0 );
            writer.Write( m_Count );

        }

        public override void Deserialize( GenericReader reader )
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();
            m_Count = reader.ReadInt();
        }
    }
}
 

Falkor

Squire
Apr 11, 2018
252
88
28
wpshard.com
Shard Name
Whispering Pines
It worked for me out of the box so I've never really had to troubleshoot it.

Do you have XMLSpawner2 installed? It's not in older RunUO versions by default.
 

Finaltwist

Rookie
Sep 7, 2019
88
10
8
It worked for me out of the box so I've never really had to troubleshoot it.

Do you have XMLSpawner2 installed? It's not in older RunUO versions by default.
No i don't believe uo odyssey has that installed... i did a search in scripts for "xmlspawner" and didn't get a hit. I"ll see about installing that!
 

Falkor

Squire
Apr 11, 2018
252
88
28
wpshard.com
Shard Name
Whispering Pines
Since that package may be hard to find these days, I've zipped it up for you. You should be able to just drop it into its own folder within your Customs folder with no other modifications anywhere. Everything else it does is optional and probably beyond what you want to tinker with for now.
 

Attachments

Finaltwist

Rookie
Sep 7, 2019
88
10
8
I'm getting quite a few errors on the XMLspawner - looks like UO odyssey took out quite a few systems (escortables for example) which would take too much time to re-incorporate. So i've opted to use the slimmed down xmlspawner files located in the Artegordon directory of the randomencounter file that was posted earlier. so far so good but i am getting an error (below). It looks like i'm missing a reference somewhere

C#:
 + Custom/RandomEncounters/Helpers.cs:
    CS0246: Line 73: The type or namespace name 'Tile' could not be found (are you missing a using directive or an assembly reference?)
probably a missing reference to a server - trying to figure out which one
 

Milva

Admin
Moderator
Mar 3, 2013
4,426
547
113
Donate
Donate money to this user
Tile was changed quite some time ago try Static Tile first-if error try the next , LandTile, GetStaticTile & GetLandTile.
 
  • Like
Reactions: Finaltwist

Finaltwist

Rookie
Sep 7, 2019
88
10
8
You guys are great, much appreciate. I'll try Milva's suggestion
Post automatically merged:

Could someone give a hint as to this error?

C#:
 + Custom/RandomEncounters/ArteGordon/XmlAttach.cs:
    CS1501: Line 49: No overload for method 'IsConstructable' takes 1 arguments
and here is the offending part of the script
C#:
                if ( !(requireconstructable && Add.IsConstructable( ctor )) && !(requireattachable && XmlAttach.IsAttachable( ctor )))
                    continue;

                // check the parameter list of the constructor
                ParameterInfo[] paramList = ctor.GetParameters();
Post automatically merged:

With regards to Milva's suggestion, I changed

Tile LandTile = map.Tiles.GetLandTile( xLoc, yLoc );

to

Static Tile LandTile = map.Tiles.GetLandTile( xLoc, yLoc );

and get

CS1002: Line 60: ; expected

error....
Post automatically merged:

here is the offending section of the script giving a Tile error...
C#:
        public static void Octant( CommandEventArgs e )
        {
            Tour tour = delegate( Map map, int x, int y )
            {
                int         xLoc = e.Mobile.Location.X + x;
                int         yLoc = e.Mobile.Location.Y + y;

                StaticTile        LandTile  = map.Tiles.GetLandTile( xLoc, yLoc );

                Effects.SendLocationParticles(
                    EffectItem.Create( new Point3D( xLoc, yLoc, landTile.Z), map, EffectItem.DefaultDuration ),
                    0x37CC, 1, 40, 96, 3, 9917, 0
                    );

                if( Math.Abs( x ) > 12 ) return true; // stop searching
                if( Math.Abs( y ) > 12 ) return true; // stop searching

                return false;
            };
 
Last edited:
  • Like
Reactions: Ozzer2016

Finaltwist

Rookie
Sep 7, 2019
88
10
8
Hi Milva, I'm no programmer and VS likely won't help me at all (i downloaded it and it asked for what modules i wanted and I was lost!).
I just want to add a few scripts here and there for the uo server... once in a while.

I don't understand your reply "Shows your missing online 60 ; "

I changed line 60:

Tile LandTile = map.Tiles.GetLandTile( xLoc, yLoc );

to

Static Tile LandTile = map.Tiles.GetLandTile( xLoc, yLoc );

and get

CS1002: Line 60: ; expected

There is a ; at the end of line 60. I just added Static and i guess it expects a ; in the line.
 

Tukaram

Squire
Jan 4, 2015
314
43
28
56
In the OP it sounds like you are asking about the Prisoner Camps. That is in there. I just put PrisonerCamp on a spawner and it spawns a camp. It randomly makes lizard, bandit, rat...
 
  • Like
Reactions: Finaltwist

Finaltwist

Rookie
Sep 7, 2019
88
10
8
In the OP it sounds like you are asking about the Prisoner Camps. That is in there. I just put PrisonerCamp on a spawner and it spawns a camp. It randomly makes lizard, bandit, rat...
Yes, however that requires manual placing of spawners. random encounters allows you to have random encounters spawn randomly as the player is exploring, based on location. its a neat feature. I fixed the Tile error - and for any googling their way here with the same issue, i had to change " Tile" to "LandTile".

it loads without any red errors, but i still get this white error specific to XMLspawner
C#:
RandomEncounters: Exception caught attempting to load file: ./Data/RandomEncounters.xml
System.Xml.XmlException: There are multiple root elements. Line 138, position 2.
   at System.Xml.XmlTextReaderImpl.Throw(Exception e)
   at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
   at System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace)
   at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc)
   at System.Xml.XmlDocument.Load(XmlReader reader)
   at Server.Misc.RandomEncounterEngine.LoadXml()
##### RandomEncounters: ***FAILED INITIALIZATION***!
this is likely from me having to edit the regions and tiles in that file. Thanks all.
Post automatically merged:

RandomEncounters: **WE'RE LIVE, BABY***...

:D:D:D:D:D
 
Last edited:
  • Like
Reactions: Ozzer2016

Ozzer2016

Rookie
Jul 2, 2016
82
15
8
45
Yes, however that requires manual placing of spawners. random encounters allows you to have random encounters spawn randomly as the player is exploring, based on location. its a neat feature. I fixed the Tile error - and for any googling their way here with the same issue, i had to change " Tile" to "LandTile".

it loads without any red errors, but i still get this white error specific to XMLspawner
C#:
RandomEncounters: Exception caught attempting to load file: ./Data/RandomEncounters.xml
System.Xml.XmlException: There are multiple root elements. Line 138, position 2.
   at System.Xml.XmlTextReaderImpl.Throw(Exception e)
   at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
   at System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace)
   at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc)
   at System.Xml.XmlDocument.Load(XmlReader reader)
   at Server.Misc.RandomEncounterEngine.LoadXml()
##### RandomEncounters: ***FAILED INITIALIZATION***!
this is likely from me having to edit the regions and tiles in that file. Thanks all.
Post automatically merged:

RandomEncounters: **WE'RE LIVE, BABY***...

:D:D:D:D:D
Awsome :)
 

Finaltwist

Rookie
Sep 7, 2019
88
10
8
Had a crash related to this script today - would someone help by indicating what i should look for?

C#:
System.InvalidOperationException: Failed to compare two elements in the array. ---> System.InvalidCastException: Specified cast is not valid.
   at Server.Misc.SpawnFinder.TileComparer.Compare(Object o1, Object o2)
   at System.Array.SorterObjectArray.SwapIfGreaterWithItems(Int32 a, Int32 b)
   at System.Array.SorterObjectArray.DepthLimitedQuickSort(Int32 left, Int32 right, Int32 depthLimit)
   --- End of inner exception stack trace ---
   at System.Array.SorterObjectArray.DepthLimitedQuickSort(Int32 left, Int32 right, Int32 depthLimit)
   at System.Array.Sort(Array keys, Array items, Int32 index, Int32 length, IComparer comparer)
   at System.Collections.ArrayList.Sort(Int32 index, Int32 count, IComparer comparer)
   at Server.Misc.SpawnFinder.FindSpawnTileInternal(PlayerMobile pm, Point3D centerPoint, Point2D currentPoint, Point3D& spawnPoint, LandType landType, EffectType effectType, Int32 effectHue)
   at Server.Misc.SpawnFinder.<>c__DisplayClass4.<FindSpiral>b__3(Map map, Int32 x, Int32 y)
   at Server.Searches.SpiralSearch.SearchSpiral(Map map, Int32 start, SearchDirection direction, Boolean randomStart, Tour tour)
   at Server.Misc.SpawnFinder.FindSpiral(PlayerMobile pm, Point3D centerPoint, Point3D& spawnPoint, LandType landType, Int32 distance, Boolean inwards, EffectType effectType, Int32 effectHue)
   at Server.Misc.RandomEncounterEngine.GenerateEncounter(PlayerMobile playerMobile, RandomEncounter encounterTemplate, ArrayList cleanupList)
   at Server.Misc.RandomEncounterEngine.GenerateEncounters(String timerType)
   at Server.Timer.Slice()
   at Server.Core.Main(String[] args)
I was in a dungeon at the time and I don't have many randomspawns in dungeons yet - having not yet populated the xml file. Not sure what it means by specified cast is invalid
 

unblest

Citizen
May 20, 2016
27
5
3
40
My guess is that Tile type is either StaticTile or LandTile and these kinda stuffs got screwed and mixed up