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!

"We all march togeather" NPC fix

DeepFreez

Wanderer
"We all march togeather" NPC fix

Ever noticed that all the NPCs on the shard ten to walk in lock step? This is especially noticable with vendors that were all spawned at the same time and are not respawned on a regular basis. There is a simple little fix for this that I think should make it into the next release.

in BaseAI.cs the line
[code:1]
public AITimer( BaseAI owner ) : base( TimeSpan.FromSeconds( Utility.RandomDouble()), TimeSpan.FromSeconds( Math.Max( 0.0, owner.m_Mobile.CurrentSpeed ) ) )
[/code:1]
should be changed to
[code:1]
public AITimer( BaseAI owner ) : base( TimeSpan.FromSeconds( Utility.RandomDouble()*owner.m_Mobile.CurrentSpeed ), TimeSpan.FromSeconds( Math.Max( 0.0, owner.m_Mobile.CurrentSpeed ) ) )
[/code:1]
This causes the NPC startups to be spread out over a much longer period, making the lockstep behavior almost dissapear.
 

krrios

Administrator
Re: "We all march togeather" NPC fix

Yes, but even after this change, what happens when you [save ? ;)
 
Re: "We all march togeather" NPC fix

krrios said:
Yes, but even after this change, what happens when you [save ? ;)
It doesn't serialize the offset, but doesn't that just mean that it should start up with a different offset each time you restart the server?

Cheers,
Ignacio
 

DeepFreez

Wanderer
Re: "We all march togeather" NPC fix

krrios said:
Yes, but even after this change, what happens when you [save ? ;)
[save does not restart any timers as far as I know....?

When the server is restarted, every NPC will get a new random offset. What this offset is, is irrelevant except in as far as it spreads out the marching effect. Before restart A moves and 2s later B moves. After the restart B moves then A moves 1.8s later. This will not impact the game itself and makes things much prettier :)
 

krrios

Administrator
Saving pauses the server. Any timers with an interval less than the time it takes to save will be queued and processed directly after the save. So, while NPCs wouldn't move in lockstep at startup, they would after the first save.
 

DeepFreez

Wanderer
krrios said:
Any timers with an interval less than the time it takes to save will be queued and processed directly after the save.
Doh... Didnt know that and since my test shard saves in no time flat I didnt pick this up.
Maybe a OnSaveComplete is then the thing to have?
 

Kamron

Knight
So will this be fixed by asynchronizing those particular timers at the end of a worldsave? Or are just saying fuck it to this one?

It is rather annoying by the way, lived with it ever since I started RunUO.
 
It would require some changes in order to allow the offset to be reinitialized from outside the class, but it should be doable.

Another thing to look at might be to have a small variation in BaseVendor with regards to the speed, so that when a speed of 2.0 is given it actually varies by +-5%, and could reset itself every so often.
 

Kamron

Knight
Yeah, that would reduce the lockstep to probably 5-10 minute intervals, or less if you wanted to adjust it. Great ideas. I await the great krrios' response of what will be actually used.
 
Top