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!

(Nujel'm) Battle Chess

Kamron

Knight
I fixed the direction issue. Use this in the same file (and remove the previous Direction statement).


Code:
BAD CODE[CODE]

You may want to change the whole OnLocationChange method to use OnMovement, and just do the base beforehand (which takes care of direction and the other shit).
 

Kamron

Knight
The fix seems to not be working anymore. And I am hesitant to take out the if statement as it would make jerky movement (yet always work). Maybe someone can think of something.
 

Kamron

Knight
Working on it, I have found something in which works - behold

Code:
		public override void OnMovement( Mobile m, Point3D oldLocation)
		{
			base.OnMovement(m, oldLocation);

			if ( m_NextMove == Point3D.Zero )
				Direction = m_Piece.Facing;
		}
 

Arya

Wanderer
Thanks! I'm going to try it now. It's probably a good idea to add a check for what's moving, if I recall correctly OnMovement gets fired by any mobile moving in the NPC's range.
 

Kamron

Knight
Yeah, that would be a great idea. That method isn't the best to use, but its the only thing that comes after OnLocationChange. A simple if (m == this) will do perfectly.

Code:
if ( m == this && m_NextMove == Point3D.Zero )
 

Arya

Wanderer
The problem is that OnMovement gets fired for all mobiles except 'this', so it will respond only to other movement (and your solution will only work if something else is moving around it). :\
 

Arya

Wanderer
Well I solved it with a delayed call in the OnLocationChanged method:

Code:
Server.Timer.DelayCall( TimeSpan.FromMilliseconds( 500 ), TimeSpan.FromMilliseconds( 500 ), 1, new TimerStateCallback ( OnFacingTimer ), null );

And:

Code:
private void OnFacingTimer( object state )
{
	if ( ! Deleted && m_Piece != null )
	{
		Direction = m_Piece.Facing;
	}
}

Not as clean and nice as I'd like it, but it gets the job done.
 

Arya

Wanderer
Why are they unreliable? I personally never used the Timer.DelayCall() function so should I be expecting something unpredictable or weird?
 

Kamron

Knight
Timers are based on the computer's system, and I have found that by using timers, you cannot expect it to be exact each time, and maybe rarely (if the system is bad or slow), it will not work. Even worse if its a timer based on a client, but thats a different issue.
 

Arya

Wanderer
Well the timer I'm using here isn't mission critical (even if it performs just fine on my heavily overloaded PC - VS debugging RunUO + 2 UO clients + tons of other stuff i have running in background), so if it comes a bit too late now and then it won't really matter.

Also I find it strange that a timer completely fails to fire. There's lots of code relying on timers around, in RunUO too. Perhaps you're using the DelayCall function with a long delay, and don't store the timer object returned by the function which can result in object loss due to GC (just throwing an idea here - I suspect the DelayTimer function doesn't store the timer anywhere).
 

Arya

Wanderer
I posted an update, including most of the suggestions mentioned in the thread. I added a few chess sets, sounds, and colors/effects configurable through the stone properties. (All properties take effect real time so try them out!). Keep in mind that while the classic chess set looks good with the default colors (which have been modified by the way), you'll probably want to change those for the other sets.

I couldn't find a way of effectively removing the target (I tried pretty much everything, from Target.Cancel to simulating targeting... with no results). Anyway I added a check before the target callback invokation to ensure the game is in a state that can handle the target correctly, so the chances of abuse or malfunctionings should be zero.

Enjoy!
 
Having a strange issue with the end game routine.. Whenever anyone gets to the point where they either have no pieces left but the king, or if the King gets check mated, instead of announcing a winner and awarding the prize, the game ends with a "Game Stalled" message.

I am using the Nu'Jelhom Chessboard in Felucca, and everything works great right up the end. It has happened in every game so far, and under multiple circumstances. The players get a "The game is over", "The game is stalled" message and are forced to click End Game.

Do I have something set up wrong? I looked through the script and I can't see why it would do this. It seems to get to eht endgame function fine, it just doesn't pick a winner, therefore ending with a stall. Any ideas?
 

Arya

Wanderer
Is the king being attacked directly when that happens? A stalemate is a situation where your king is not under attack and it's your turn to move. However whatever move you could make, it would put your king under check. Therfore the game is stalled, and there is no winner according to the chess rules.

I have just tried playing a simple test and I succesfully won a game, the loosing king emoted the checkmate message and the winner received the reward. And of course the end game gump displayed the name of the winner. So my guess is that you're really in a stalemate situation when that happens...
 

Khaz

Knight
Wow...

beautiful. Simply amazing. This is much better than the stupid chess boards previously in-game. Thank you very much for this contribution, Arya.
 
Yep you got it. Stalemate. That's exactly what it is, I was just expecting a player to be declared winner if they force the other player into a no move left option. I had no idea that this is considered a stalemate. The "Game is Stalled" message made me and my players think something was wrong. I am not familiar enough with the rules of ches apparently. Sorry for questioning it.

This is yet another amazing system, Arya. Thanks.
 

Kamron

Knight
I was at the graphics studio longer than expected today (meeting for Halo2 demo wrap up and plans to go see it when it airs before spider-man 2). So I haven't had time to make the 1-hit kill effect. If anyone has an ideas on cool effects or fight things to do for each of the players to make it interesting or other stuff, please private message me or email me at [email protected], and Ill add it in with what I am currently planning on making. Just wanna help ya out Arya, and as always beautiful shit, I love it.
 

Fineous

Wanderer
The king and queen are on wrong sides queen should get the color. If I get a chance Ill post a fix.

*edit*

here is the fix simple in chess board change

Code:
// Queens
AddPiece( new Queen( this, ChessColor.Black, new Point2D( 4,0 ) ) );

AddPiece( new Queen( this, ChessColor.White, new Point2D( 4,7 ) ) );

// Kings
AddPiece( new King( this, ChessColor.Black, new Point2D( 3,0 ) ) );
			
AddPiece( new King( this, ChessColor.White, new Point2D( 3,7 ) ) );
 

Arya

Wanderer
Fineous, as far as I know kings are placed on the right side of the board. I know they land on the wrong colors (black on white and viceversa), however this is probably because the Nujel'm chessboard has been designed to be used along the W-E direction rather than N-S. I honestly didn't notice this when I started writing the script, and when I did I already had a good deal of code that relied on directions and honestly didn't want to redo it.

I'm going to fix the auto-generated chessboard of course, thanks for pointing it out :)
 
Top