Introduction
Tank hockey is a game that can be played by teams of people driving tanks or similar vehicles, pushing a large, puck-like physical object onto goals to score points. The game also has a combat element - if the puck is destroyed by gunfire, it subdivides into two smaller pucks up to a limit of three generations.
Components
The tank hockey system comprises the following scripted objects:
A server object
A puck (stored in, and rezzed by, the server object)
Two goal objects
One or more standard scoreboards.
Tanks (or other vehicles). These have no special requirements to work, other than a vehicle gun.
Operation
The whole system is designed to be created from the RezMela control board, which should rez a server, the goals, the vehicles and any ancillary objects such as perimeter fencing.
On being rezzed, the server creates a puck and positions it in the centre of the playing field.
One player on each side clicks their own goal to claim it for themselves. The goal displays their name when this is done.
The game is then ready to be played. The players push the puck around by driving the vehicles to collide with it, the object being to push the puck(s) into the opponent's goal.
If the original puck is "hit" by a vehicle gun, it deletes itself and the server spawns two smaller replacement pucks. The effect is as if the puck had been split into two pieces. These smaller pucks also subdivide when hit, but the subsequent, third generation will only disappear when hit and will not spawn any more pucks.
If any puck makes physical contact with a goal, the goal will flash and play sound, and gameplay stops. The goal may then be clicked, which stops the flashing, deletes any pucks and creates a new, first-generation puck in the centre of the pitch.
Technically, there is no limit to the length of the game except the availability of vehicles.
Construction
The server may be any object. The contents of the root prim should be the puck script, the RezMela WorldObjectRoot script, a sound to be played when the puck is put into play, the config file (see below) and a copy of the puck.
The puck is made up of an invisible (via texture) flat cylinder base (root prim) containing the script and support files, with a larger, visible main cylinder linked to it. There is also a linked, invisible (via texture) box prim roughly the same size as the cylinder. This prim is used for collision detection (currently cylinders perform poorly at this). Only the root prim has any contents. The entire puck should ideally be set to invisible (via 100% transparency) when placed in the server so that it's not seen when initially rezzed, although the puck will set itself to invisible as the script loads.
The goal is a linkset comprising a root prim and a number of unscripted child prims. Any prim named "Post" will light up when a goal is scored. A prim named "Name" acts as the display for the player name and resizes itself on the Y axis to accommodate the length of the name. The root prim should contain the goal script, a sound to be played when a goal is scored (the name is immaterial) and the RezMela WorldObjectRoot script.
It is advisable to surround the playing area with a wall to contain the puck.
Configuration
There are two configuration files. These are the usual INI-type notecards, with "//" comments and blank lines allowed. They are:
Puck configuration
Named "Puck config" and stored in the puck object, this has the following parameters:
DustTexture
FlameTexture
SmokeTexture
The name of a texture in the object contents, used for the dust created by the puck in motion
Likewise, the texture used for an explosion when the puck is hit
Likewise, the texture used for smoke when the puck is hit
The puck also should contain the textures named, although overlap is possible (eg the smoke and dust textures may be the same)
Server configuration
Named "Tank hockey config", this notecard resides in the server object and has the following parameters:
Centring the puck
To work around situations whereby the puck rests against the perimeter wall and is difficult to push back out into play, there is a centring feature. If the puck travels into a margin defined by the "Margin" parameter of the server configuration notecard, a force defined by the "CenterPush" parameter will be applied to the puck in the direction of the pitch centre. These values can be tuned such that it's not obvious that the puck is affected by unnatural forces.
Naming goals
The name associated with a goal is stored as the object description. On being clicked by a player, if the description is blank, the goal script will store the player's name in the description and use that as the name of the team associated with that goal. The description may also be set by hand or by an external script if necessary.
Communications
The communications between the various objects can be described as follows:
The server is always listening to channel -3920100
Goals
Each goal broadcasts "G<team name>" periodically on the server channel; the server reads this data to identify goals and teams
When a goal is scored, the goal script broadcasts "S<team name>"; the server uses that to update the scores
When the goal object is reset after a goal is scored, the goal script broadcasts "R", and the server uses that to initiate a game reset
Pucks
When a puck is first rezzed, the server periodically sends via osMessageObject() "G" followed by a CSV string of all the data the puck needs to know
On receipt of that data, the puck replies with "G" alone via the same method; the server then stops sending the data
The puck receives "D" messages (via dataserver()) from vehicle guns to detect hits by shells.
On being hit, the puck sends "DP<current position>" to the server, "explodes" and dies.
On receiving "DP", the server rezzes two new pucks (unless MaxGenerations is reached) near the given position
In addition, on being deleted by the RezMela control board, the server sends "X" to all pucks, when die silently on receipt
Scoreboards
The standard scoreboard communications are used by the server