(Nujel'm) Battle Chess
Summary:
Play chess with NPCs as pieces on the Nujel'm chessboard (or set up your own somewhere else). This script comes with a full chess logic behind it, preventing players from making illegal moves, and manages automatically game ending.
Description:
I had this script in an almost finished state for ages, and I decided to finally give it a final touch. I believe there are other battle chess scripts out there, but I don't recall any of them implementing the chess logic. This script supports the following chess features:
- Knows the moves, and it prevents pieces to make any illegal moves (providing a little feedback to the user as well).
- Analyzes the board, preventing moves that would put the mover's king under check.
- Supports castle and en passant moves
- Supports pawn promotion
- Recognizes check, checkmate and stalemate situations
The script currently does not implemet:
- The 50 moves rule
- The 3 identical moves rule
Also this script doesn't implement single player chess. If you want a computer opponent get yourself a real chess game
If the game ends with a winner (as opposed to stalemate, resigning, disconnection or whatever), the winner will receive a little document which records the game stats and certifies the victory. You can disable this feature in ChessConfig.cs.
The game is piloted through a series of gumps displaying the current game status, the pieces captured by each side and the current score.
There are a number of time outs you can configure in ChessConfig.cs. By default a player can take up to 10 minutes to make a move, then they get a warning and have further 3 minutes to move. If they don't the game ends. A similar behaviour occurs when a player is disconnected, they have 10 minutes to get back in game before reset.
Staff can immediately terminate a chess game by deleting one of the NPCs on the board.
Important: the game will NOT serialize itself. The board, and the stone will, but not the game itself. Therefore if the server is rebooted, any game in progress will be lost.
As always, please report any issues.
Installation:
Unzip to your scripts folder and restart the server. Use:
[Add ChessControl
to add the game control stone.
Once the stone is placed it must be configured.
If you already have a board made (for example in Nujel'm):
Go to the stone props and set the following:
- BoardNorthWestCorner : this a Point2D value and you can set it by clicking the target location which corresponds to the board's north west cornder.
- BoardHeight : this is the location at which the NPCs will be created.
- SquareWidth (default 2): this is the width of each chessboard square.
If you don't have a chessboard ready:
If you wish the stone to create a chessboard for you, double click an unconfigured stone and target the ground. The stone will create the board and automatically configure the stone with the correct parameters.
Note: by default the script creates and uses a board where each square is 2x2 tiles. This however can be changed, from 1x1 upwards.
Updates
1.0.1, June 23: Quick fix to prevent players from playing against themselves (which could ultimately result in a server crash).
1.0.2, June 24: Fixed the problem that caused some pieces to be unable to capture when played on Felucca.
1.0.3, June 25: Fixed the crash that would occur when a pawn promotion resulted in a checkmate. Possibly fixed another crash occurring at game start when the guest would accept the game and the owner would cancel at the same time. Also the name of the parner is displayed correctly (without the serial) on the start game gump.
1.1, June 25:
- Increased NPCs speed
- NPCs reset their correct facing direction after moving
- Knights follow an L path when moving
- Changed default hues for black and white
- Added sounds to the NPCs. Each piece has a different sound for moving, attacking and being captured.
- Added a number of cosmetic properties to the stone. All those properties can be changed at any time and will serialize with the stone:
- WhiteHue and BlackHue, no explanation needed.
- AttackEffect : this is the ID of the effect performed by a NPC when attacking (before moving) another piece.
- CaptureEffect : this is the effect the NPC performs when it captures another NPC
- BoltOnDeath : specifies if a NPC's capture will be accompanied by a lightning strike
- ChessSet: choose from 5 (I think) chess sets. Currently supplied are: Classic, Fantasy, Fantasy Giant, Animal and Undead. Each set produces different NPCs and uses different sounds.
1.2, June 27:
- Added a region to the chessboard for the duration of the game. This ensures that players aren't allowed to cast invisibility on the chess pieces.
- When starting a game, the player will be able to decide whether to allow players on the chessboard or not (not allowed by default). This will avoid board cluttering. (Thanks to XLordX for these very valid suggestions)
- Added a minor hue to both black and white pieces. This will make the pieces look much better rather than using the opponent's hue. (Thanks to jjarmis for this!)
- Added a safe word to be used when for some reason you loose the target and the game gump. By default say 'game' and if the game isn't stopped you'll receive the game gump.
- Added the option to have a different orientation for the board (NS by default, EW through props). The automatic chessboard generation takes into consideration this parameter. Thanks to XxSp1derxX for this one.
- Something else I can't remember right now Possibly a potential crash fix.
1.2.1, June 28:
- AllowSpectators property will now serialize correctly
- AllowSpectators and Orientation properties will now be applied real time if a game is in progress
- If the board must be rebuilt during a game, the action will be delayed until the current move is over
- OverrideMinorHue property: if set to true ignores the minor hue and uses just one hue to color the pieces.
- Double clicking the stone during a game will now reset the gumps/targets if they have been lost.
1.2.2, June 29:
- OverrideMinorHue will now also override hair and skin hue
- Fixed a potential crash when a player logs our after the game ends but before both players close their gumps.
- Staff above Counselor will always have access to the chessboard.
1.2.3 July 1:
- Fixed a crash occurring when double clicking the stone during game setup.
1.2.4 July 4:
- Hopefully finally fixed the crashing issue with players disconnecting.
- Fixed a few appearance issues on the classic chess set (Sp1der will be happy )
1.2.5 Sept. 28:
- Refactored the Chessboard class to BChessboard. This will prevent the crash occuring when using the [Decorate command.
- NPCs will be now ejected from the chessboard
- Fixed crash occuring when staff would delete a pawn in the middle of its promotion
- If the winner has no backpack they will not receive their winning certificate
- You can no longer check mate your enemy and win the game, while being checked yourself.
- Player can choose the preferred chess set when starting a game.
Summary:
Play chess with NPCs as pieces on the Nujel'm chessboard (or set up your own somewhere else). This script comes with a full chess logic behind it, preventing players from making illegal moves, and manages automatically game ending.
Description:
I had this script in an almost finished state for ages, and I decided to finally give it a final touch. I believe there are other battle chess scripts out there, but I don't recall any of them implementing the chess logic. This script supports the following chess features:
- Knows the moves, and it prevents pieces to make any illegal moves (providing a little feedback to the user as well).
- Analyzes the board, preventing moves that would put the mover's king under check.
- Supports castle and en passant moves
- Supports pawn promotion
- Recognizes check, checkmate and stalemate situations
The script currently does not implemet:
- The 50 moves rule
- The 3 identical moves rule
Also this script doesn't implement single player chess. If you want a computer opponent get yourself a real chess game
If the game ends with a winner (as opposed to stalemate, resigning, disconnection or whatever), the winner will receive a little document which records the game stats and certifies the victory. You can disable this feature in ChessConfig.cs.
The game is piloted through a series of gumps displaying the current game status, the pieces captured by each side and the current score.
There are a number of time outs you can configure in ChessConfig.cs. By default a player can take up to 10 minutes to make a move, then they get a warning and have further 3 minutes to move. If they don't the game ends. A similar behaviour occurs when a player is disconnected, they have 10 minutes to get back in game before reset.
Staff can immediately terminate a chess game by deleting one of the NPCs on the board.
Important: the game will NOT serialize itself. The board, and the stone will, but not the game itself. Therefore if the server is rebooted, any game in progress will be lost.
As always, please report any issues.
Installation:
Unzip to your scripts folder and restart the server. Use:
[Add ChessControl
to add the game control stone.
Once the stone is placed it must be configured.
If you already have a board made (for example in Nujel'm):
Go to the stone props and set the following:
- BoardNorthWestCorner : this a Point2D value and you can set it by clicking the target location which corresponds to the board's north west cornder.
- BoardHeight : this is the location at which the NPCs will be created.
- SquareWidth (default 2): this is the width of each chessboard square.
If you don't have a chessboard ready:
If you wish the stone to create a chessboard for you, double click an unconfigured stone and target the ground. The stone will create the board and automatically configure the stone with the correct parameters.
Note: by default the script creates and uses a board where each square is 2x2 tiles. This however can be changed, from 1x1 upwards.
Updates
1.0.1, June 23: Quick fix to prevent players from playing against themselves (which could ultimately result in a server crash).
1.0.2, June 24: Fixed the problem that caused some pieces to be unable to capture when played on Felucca.
1.0.3, June 25: Fixed the crash that would occur when a pawn promotion resulted in a checkmate. Possibly fixed another crash occurring at game start when the guest would accept the game and the owner would cancel at the same time. Also the name of the parner is displayed correctly (without the serial) on the start game gump.
1.1, June 25:
- Increased NPCs speed
- NPCs reset their correct facing direction after moving
- Knights follow an L path when moving
- Changed default hues for black and white
- Added sounds to the NPCs. Each piece has a different sound for moving, attacking and being captured.
- Added a number of cosmetic properties to the stone. All those properties can be changed at any time and will serialize with the stone:
- WhiteHue and BlackHue, no explanation needed.
- AttackEffect : this is the ID of the effect performed by a NPC when attacking (before moving) another piece.
- CaptureEffect : this is the effect the NPC performs when it captures another NPC
- BoltOnDeath : specifies if a NPC's capture will be accompanied by a lightning strike
- ChessSet: choose from 5 (I think) chess sets. Currently supplied are: Classic, Fantasy, Fantasy Giant, Animal and Undead. Each set produces different NPCs and uses different sounds.
1.2, June 27:
- Added a region to the chessboard for the duration of the game. This ensures that players aren't allowed to cast invisibility on the chess pieces.
- When starting a game, the player will be able to decide whether to allow players on the chessboard or not (not allowed by default). This will avoid board cluttering. (Thanks to XLordX for these very valid suggestions)
- Added a minor hue to both black and white pieces. This will make the pieces look much better rather than using the opponent's hue. (Thanks to jjarmis for this!)
- Added a safe word to be used when for some reason you loose the target and the game gump. By default say 'game' and if the game isn't stopped you'll receive the game gump.
- Added the option to have a different orientation for the board (NS by default, EW through props). The automatic chessboard generation takes into consideration this parameter. Thanks to XxSp1derxX for this one.
- Something else I can't remember right now Possibly a potential crash fix.
1.2.1, June 28:
- AllowSpectators property will now serialize correctly
- AllowSpectators and Orientation properties will now be applied real time if a game is in progress
- If the board must be rebuilt during a game, the action will be delayed until the current move is over
- OverrideMinorHue property: if set to true ignores the minor hue and uses just one hue to color the pieces.
- Double clicking the stone during a game will now reset the gumps/targets if they have been lost.
1.2.2, June 29:
- OverrideMinorHue will now also override hair and skin hue
- Fixed a potential crash when a player logs our after the game ends but before both players close their gumps.
- Staff above Counselor will always have access to the chessboard.
1.2.3 July 1:
- Fixed a crash occurring when double clicking the stone during game setup.
1.2.4 July 4:
- Hopefully finally fixed the crashing issue with players disconnecting.
- Fixed a few appearance issues on the classic chess set (Sp1der will be happy )
1.2.5 Sept. 28:
- Refactored the Chessboard class to BChessboard. This will prevent the crash occuring when using the [Decorate command.
- NPCs will be now ejected from the chessboard
- Fixed crash occuring when staff would delete a pawn in the middle of its promotion
- If the winner has no backpack they will not receive their winning certificate
- You can no longer check mate your enemy and win the game, while being checked yourself.
- Player can choose the preferred chess set when starting a game.