Go Back   RunUO - Ultima Online Emulation > RunUO > Core Modifications > Other

Other Cant find a category above, use this one! Core mods not listed above go here!

Reply
 
Thread Tools Display Modes
Old 08-13-2005, 10:26 PM   #1 (permalink)
The noob formerly known as Jakob
 
Serp's Avatar
 
Join Date: Jan 2005
Posts: 316
Default Instances Experiment

Before you do anything, read this whole post (especially the last part). This is not for beginners.

First off, what is an instance?
An instance alone is not different from any place anywhere. However there can be several instances of the same area which adds a lot of possibilities! Multiple people can be in seemingly the same area but without bumping into eachother. This is not only cool but also an upcoming feature of some UO:ML dungeons and I just had to give it a shot.

How it works
Everytime an instance is created is makes a new map. This map is derived from another map and it gets all the properties that the "master map" had as of looks and basic rules. When the instance is removed the entire map with all items and mobiles is removed.
This one of the easiest way to do instancing, but not necessarily the best.

Alrighty, how do I get to instanciating?
  • Download the files here and either overwrite or merge with the existing ones. (Item.cs, Map.cs, Mobile.cs and World.cs go into the core, the rest into your custom scripts folder)
  • Compile your new core and start your server
  • Decorate the "instance blueprint". All instances will look like this area. Keep in mind that if you want mobiles you need to put spawners instead of actual mobiles. And yes, XmlSpawner is supported (if you uncomment some code in Instances.cs.) And don't forget the exit teleporters! They can be any kind of teleporters or gates or whatever. The important thing is that they have a "real" map as target and not an instance.
  • Add an InstanceTeleporter
  • Setup your teleporter (see below for options)
  • Play around with it.
  • Report all bugs here!

InstanceTeleporter options
  • InstanceID: when you have multiple teleporters that have the same target you want to specify the same InstanceID in all of them
  • InstanceType: do you want one instance for every player, every party or every guild?
  • Bounds (X1Y1 and X2Y2): Area from where to copy items to the new instance. When you have multiple teleporters that have the same target you want them all to have the same bounds to avoid weirdness

More about the instances
  • Instances decay 10 minutes after the last player leaves it. If any player comes back it will reset the timer.

Known issues
  • Pets will be deleted if they are in the instance when it decays
  • If players are saved in an instance they will pop up in the "blue print" on next server load
  • Almost no speed or resource optimizations
  • If you enter a party instance you can't re-enter if the party would dissolve for some reason. The same goes for guild instances.
  • A region needs to be added to the newly created instance to prevent people from marking runes, walking outside the bounds etc.

Fix list
13 aug. First release.

Some more info...
I mark everything I modify in the core with // Jakob's instance implementation
The code is not very well commented, but I try to keep it simple enough for most people to follow what's going on.


Special thanks to..
Asayre8 for sharing some thoughts on instancing
Xavier for helping me test the scripts


This system is in no way ready for use on a production shard. It may (read probably will) cause some irregularities on your shard. DO NOT use it for anything other than playing around with as of now. I created this as an experiment and you are more than welcome to help fixing it into something stable, but again, please do not use this on a regular shard right now.
Attached Files
File Type: zip Instances.zip (74.5 KB, 142 views)
Serp is offline   Reply With Quote
Old 08-13-2005, 10:48 PM   #2 (permalink)
Forum Expert
 
Join Date: Dec 2002
Posts: 730
Default

Very interesting script Pity I don't like the idead of instances at all, but it will be nice to give it a shot
Atomic is offline   Reply With Quote
Old 08-13-2005, 11:06 PM   #3 (permalink)
UO Gamers: Divinity Seer
 
Join Date: Oct 2003
Age: 23
Posts: 790
Default

Instances have all sorts of great uses, from "adventure" type Dungeons, where you fight
your way down, to Duel Arenas. (Those "challange system") Where you can have your own
arena with minimal lagg caused by bistanders and no waiting in lines.
Xavier_WER is offline   Reply With Quote
Old 08-15-2005, 09:00 PM   #4 (permalink)
Connection Reset by Peer
 
Join Date: Jan 2003
Posts: 676
Default

I've got a brilliant use for this.
I've been trying to make a good single player RPG from UO for a while, and I needed a way to do multiple copies of Trammel on the fly, but never really attempted coding it. This gives me all the code I need, I just need to rewrite the way it saves
tejster24 is offline   Reply With Quote
Old 08-15-2005, 10:38 PM   #5 (permalink)
Forum Expert
 
Alis's Avatar
 
Join Date: Jun 2005
Location: Probably where people call it heaven
Posts: 1,452
Send a message via AIM to Alis Send a message via MSN to Alis
Default

hmmz me shall test every inch of the posted subject project thanks lets look what you have done
Alis is offline   Reply With Quote
Old 08-20-2005, 05:02 PM   #6 (permalink)
Forum Expert
 
Join Date: Sep 2002
Age: 23
Posts: 1,472
Default

I did something similar before, although with a different approach. My method was an Array of "InstanceMap", that were basically Item/Mobile lists. When sending new Mobile/Effect/Item data, I checked wether the emitting object was in the same InstanceMap as the destination object.
Ravatar is offline   Reply With Quote
Old 08-20-2005, 05:23 PM   #7 (permalink)
The noob formerly known as Jakob
 
Serp's Avatar
 
Join Date: Jan 2005
Posts: 316
Default

Quote:
Originally Posted by Ravatar
I did something similar before, although with a different approach. My method was an Array of "InstanceMap", that were basically Item/Mobile lists. When sending new Mobile/Effect/Item data, I checked wether the emitting object was in the same InstanceMap as the destination object.
That approach break just about every script that "scans" the map for mobiles or items, for example housing, movement, ai and area effect spells as well as scripts that make items or mobiles to appear (for instance at creation).
It's just too much modification (imo) for a script that isn't even a part of the official release.
Serp is offline   Reply With Quote
Old 08-22-2005, 05:04 PM   #8 (permalink)
Forum Expert
 
Join Date: Sep 2002
Age: 23
Posts: 1,472
Default

But only a handful of methods do the bulk of that work.

My only concern is the performance hit related to creating new maps so frequently.
Ravatar is offline   Reply With Quote
Old 08-23-2005, 03:36 AM   #9 (permalink)
Forum Expert
 
Join Date: Dec 2003
Location: Sitting in a chair fulfilling my life's goal
Age: 22
Posts: 2,650
Send a message via AIM to Killamus Send a message via MSN to Killamus
Default

So, what happens? I'm gonna run a few senarieo's by ya, I want to know what would happen.

Player a runs in, player b runs in afterwards.
player a leaves, player b leaves
player b comes back in, player a comes back in

In order, would player b then see player a's instance? Or is it seralized per player?

Next:
Player a runs into instance a, player c runs into instance c
player b leaves, player a leaves, player a runs back in, does he still see player b's instance?

last:
Player a is in party with player c. Player a runs into instance a, player c runs into instance b. player c runs into (a) instance a or (b) instance c. Which is it?


This reminds me of guildwars...
__________________
Procrastinators unite!
Tomorrow.
Saying that Java is nice because it works on all OS's is like saying that anal sex is nice because it works on all genders.
Killamus is offline   Reply With Quote
Old 08-23-2005, 09:27 AM   #10 (permalink)
The noob formerly known as Jakob
 
Serp's Avatar
 
Join Date: Jan 2005
Posts: 316
Default

Quote:
Originally Posted by Ravatar
But only a handful of methods do the bulk of that work.

My only concern is the performance hit related to creating new maps so frequently.
Creating a map is really not a big deal. I could see a performance hit with copying all the items though.
This can be solved by giving the instance a Reset() method that deletes all corpses and reset all spawners (providing all items are decoration only).
Serp is offline   Reply With Quote
Old 08-23-2005, 09:31 AM   #11 (permalink)
The noob formerly known as Jakob
 
Serp's Avatar
 
Join Date: Jan 2005
Posts: 316
Default

Quote:
Originally Posted by Killamus
So, what happens? I'm gonna run a few senarieo's by ya, I want to know what would happen.
You can set it to identify per player, party or guild.

If you set it per player:
Quote:
Originally Posted by Killamus
Player a runs in, player b runs in afterwards.
player a leaves, player b leaves
player b comes back in, player a comes back in
Player b will go back to his instance and player a will go back to his instance.

Quote:
Originally Posted by Killamus
Player a runs into instance a, player c runs into instance c
player b leaves, player a leaves, player a runs back in, does he still see player b's instance
Player a will go back to his instance.


Quote:
Originally Posted by killamus
Player a is in party with player c. Player a runs into instance a, player c runs into instance b. player c runs into (a) instance a or (b) instance c. Which is it?
If it's set to identify instances per player they will go to different instances, otherwise they will share. You can set this in the InstanceTeleporter.
Serp is offline   Reply With Quote
Old 08-23-2005, 09:32 PM   #12 (permalink)
Forum Expert
 
Join Date: Dec 2003
Location: Sitting in a chair fulfilling my life's goal
Age: 22
Posts: 2,650
Send a message via AIM to Killamus Send a message via MSN to Killamus
Default

Also, the instance would work off of frozen items as well, correct? Once again, pretty neat script.
__________________
Procrastinators unite!
Tomorrow.
Saying that Java is nice because it works on all OS's is like saying that anal sex is nice because it works on all genders.
Killamus is offline   Reply With Quote
Old 12-03-2005, 06:58 AM   #13 (permalink)
 
Join Date: Dec 2004
Location: Sweden
Posts: 117
Default

Ok, i dont know if you still support this script, but il ask a question anyways.


The core, would you like to me more exact? i do not got a Item.cs (do you mean BaseItem.cs?) and neither one of those other Core scripts. would be cool if some one told me how to replace these files and replace with what..

realy nice idea btw
Tobbe371 is offline   Reply With Quote
Old 12-03-2005, 12:12 PM   #14 (permalink)
 
Join Date: Oct 2002
Age: 23
Posts: 4,689
Default

if you downloaded the RunUO source coded, then you do have those files.

This script is not supported, and was only put together in a few hours as an example of the idea.
XxSP1DERxX is offline   Reply With Quote
Old 12-03-2005, 12:22 PM   #15 (permalink)
The noob formerly known as Jakob
 
Serp's Avatar
 
Join Date: Jan 2005
Posts: 316
Default

The core is the Server.exe executable you click when starting RunUO. You need to get the source code for that to be able to do this thing, and it doesn't seem like yuo can download that atm.

And like XxSP1DERxX said, it was just a quick example of the idea that works, but it's not very pretty at all, and it's not really supported.
Serp is offline   Reply With Quote
Old 12-03-2005, 04:50 PM   #16 (permalink)
 
Join Date: Dec 2004
Location: Sweden
Posts: 117
Default

ok, just wondering. cuz this could be realy helpfull for allot of shards i think. maby hard with uo, thats not as organized as wow, maby could work on a serious shard. with large guilds and such..
Tobbe371 is offline   Reply With Quote
Old 12-22-2005, 08:09 PM   #17 (permalink)
Forum Expert
 
IHaveRegistered's Avatar
 
Join Date: Jun 2003
Location: Ontario
Age: 20
Posts: 4,522
Send a message via MSN to IHaveRegistered
Default

Quote:
Originally Posted by Jakob
Creating a map is really not a big deal. I could see a performance hit with copying all the items though.
This can be solved by giving the instance a Reset() method that deletes all corpses and reset all spawners (providing all items are decoration only).
Dunno if you've ran over this already... Butttttttttt...

Why don't you make it so you can choose to only copy a specified area?

(i'm loving my scenarios today...)

Say you got your map (splats map down on table)...
It has towns, cities, and stuff...
Copying all that makes massive lag...
Copying a SPECIFIED area creates less lag...

Copy I dunno... (0, 0) to (500, 500)... Not all of (0, 0) to (6112, 4096)...

We see what i'm getting at? (I hope... if you don't I dunno how to explain it more... :P)

-Aiden
__________________
IHaveRegistered is offline   Reply With Quote
Old 04-29-2006, 07:12 AM   #18 (permalink)
Forum Expert
 
Join Date: Jan 2004
Location: England
Age: 20
Posts: 442
Default

I know this is an old thread so sorry if a Mod feels that I am digging it up.
However I've just started to play around with this, it looks exactly what I need for the project that I want to undertake.
So first a big thanks to Jakob from me for his hard work in creating this.

Instead of copying the core files and replacing my old Core files I wanted to merge Jakob's changes with my current Core files. His instructions and commenting was great to help me find all his core changes, however there was only one bit that was missed out so this post is to correct this and help any others if they encounter the same problem.
I encountered this compile error:
'Server.Map' does not contain a definition for 'Index'
To fix this:
In Map.cs you will need to find these two methods:
Code:
public static Map[] GetMapValues()
{
    CheckNamesAndValues();
    return m_MapValues;
}
and

Code:
public static Map Parse( string value )
{
    CheckNamesAndValues();
    for ( int i = 0; i < m_MapNames.Length; ++i )
    {
         if ( Insensitive.Equals( m_MapNames[i], value ) )
              return m_MapValues[i];
    }
    try
    {
         int index = int.Parse( value );
         if ( index >= 0 && index < m_Maps.Length && m_Maps[index] != null )
              return m_Maps[index];
    }
    catch
    {
    }
    throw new Exception( "Invalid map name" );
}
In between these new methods place this code:
Code:
// Jakob's instances
public int Index
{
    get
    {
         for (int i = 0; i < m_Maps.Length; ++i)
              if (m_Maps[i] == this)
                   return i;
         return -1;
    }
}
// end instances
Your code should now look like this:

Code:
public static Map[] GetMapValues()
{
    CheckNamesAndValues();
    return m_MapValues;
}
 
// Jakob's instances
public int Index
{
    get
    {
         for (int i = 0; i < m_Maps.Length; ++i)
              if (m_Maps[i] == this)
                   return i;
         return -1;
    }
}
// end instances
 
public static Map Parse( string value )
{
    CheckNamesAndValues();
    for ( int i = 0; i < m_MapNames.Length; ++i )
    {
         if ( Insensitive.Equals( m_MapNames[i], value ) )
              return m_MapValues[i];
    }
    try
    {
         int index = int.Parse( value );
         if ( index >= 0 && index < m_Maps.Length && m_Maps[index] != null )
              return m_Maps[index];
    }
    catch
    {
    }
    throw new Exception( "Invalid map name" );
}
You are now ready to compile your new core.
tobyjug is offline   Reply With Quote
Old 04-29-2006, 08:09 AM   #19 (permalink)
Forum Expert
 
Join Date: Jan 2004
Location: England
Age: 20
Posts: 442
Default

After some more playing with this I noticed that when the world saved it crashed during Serialization of Mobiles.
So I did some error checking using Console.WriteLine and narrowed it down to m_LogoutMap being null during Serialization. This caused crashes because it checks m_LogoutMap.IsInstance, during Serialization and because m_LogoutMap was null it couldnt check the IsInstance and caused a null object reference crash.

The fix for this is to find the following code in the Serialize method of Mobile.cs:

Code:
//writer.Write( m_LogoutMap );
if (m_LogoutMap.IsInstance && m_Player) // Jakob's instance implementation
    writer.Write(m_LogoutMap.Parent); // TODO: Better "kick" method that prevent break-ins and such (move to last location?)
else
    writer.Write(m_LogoutMap);
Change this code to:

Code:
//writer.Write( m_LogoutMap );
if (m_LogoutMap != null && m_LogoutMap.IsInstance && m_Player) // Jakob's instance implementation
    writer.Write(m_LogoutMap.Parent); // TODO: Better "kick" method that prevent break-ins and such (move to last location?)
else
    writer.Write(m_LogoutMap);
tobyjug is offline   Reply With Quote
Old 07-18-2007, 04:28 AM   #20 (permalink)
Forum Expert
 
Join Date: Oct 2002
Age: 45
Posts: 4,369
Default

Has anyone (or can anyone) take a stab at updating this to work with the latest SVN?
__________________
HellRazor is online now   Reply With Quote
Old 07-20-2007, 02:13 PM   #21 (permalink)
Newbie
 
Join Date: Jun 2006
Posts: 94
Default

Yes.. I have a working, current version of it. I haven't added any useful examples of it, but it serializes/deserializes fine..
Kamron is offline   Reply With Quote
Old 07-23-2007, 04:33 PM   #22 (permalink)
Newbie
 
Join Date: Jun 2006
Posts: 94
Default

HellRazor, have you looked at the code I sent you?
__________________
Record for the sentence that makes the least sense - Go HERE
Kamron is offline   Reply With Quote
Old 07-24-2007, 02:56 AM   #23 (permalink)
Forum Expert
 
Join Date: Oct 2002
Age: 45
Posts: 4,369
Default

Not yet, I still need to merge it in and compile it. Will do that this week and try to create some instances to mess around in.
__________________
HellRazor is online now   Reply With Quote
Old 08-26-2007, 03:52 PM   #24 (permalink)
Forum Novice
 
AodhanW's Avatar
 
Join Date: Aug 2007
Age: 31
Posts: 120
Default

I don't know if this project has been considered a failure, a success, or if it merely hasn't seen a post in a month because its under heavy testing. But I had one rather important question to ask.

Can you create an instance of an area, and *save* that instance so it can be returned to at a later date?

The specific application I'd like to turn this to:
Creating patches of 'land' that players can get to place homes, or that owners of cities can 'purchase' to add on to their towns as instanced neighborhoods. I know that since the current set-up only allows for players, partys, or groups to go in that it won't quite work the way I imagine. But is it possible to set it up so only certain people can get in? Kind of a 'friends list' set by the players?

In the instance of neighborhoods, a publicly accessible neighborhood, so basically you click on the teleporter, and select a particular 'neighborhood' to go into?

Just a couple of thoughts.

I know that this would require something in place that doesn't delete pets and the like. Which is why I was curious if it was possible to save the 'state of the instance'.
AodhanW is offline   Reply With Quote
Old 08-27-2007, 02:51 AM   #25 (permalink)
Newbie
 
Join Date: Jan 2004
Posts: 98
Default

Quote:
Originally Posted by AodhanW View Post
Creating patches of 'land' that players can get to place homes, or that owners of cities can 'purchase' to add on to their towns as instanced neighborhoods.
The typical reason for doing instance in MMO is so that there is less conflict in competing for the dungeon resources on a shard with a lot of players. Creating copies of the same dungeon for different players/groups makes sense. Why would you want to create patches of land as instance just so people can place homes? For that purpose, there are plenty of space on the regular maps, why not just do it on a regular map? It is much easier that way.
Rocko Wang is offline   Reply With Quote
Reply

Bookmarks