2. Interactive functionality
2.1 RTS Functions
2.1.1 Selecting an object
- Performing: Move mouse on top of an object (etc. building or mech) and click left mouse button once.
- Implementation: CDirectInput class tells that left mouse button was pressed and supplies the coordinates, which are used to determine if there is an object underneath to be selected. If there is, 'selected' variable is updated. Selected items action queue, action menu and info screen is asked to update themselves.
2.1.2 Unselecting an object
- Performing: While an object is selected, move mouse cursor to an empty place and click left mouse button once. Also pressing 'esc' on keyboard unselects object.
- Implementation: CDirectInput class tells that left mouse button was pressed and supplies the coordinates, which are used to determine if there is an object underneath to be selected. If there isn't, 'selection' variable is cleared. Same happens if CDirectInput class supplies keyboard input 'esc'. Selected items action queue, action menu and info screen is asked to update themselves.
2.1.3 Binding a selection
- Performing: While an object is selected, hold 'Ctrl' button down and choose a number to bind the object to.
- Implementation: CDirectInput class tells if 'Ctrl' is down and a number is pressed. After that 'selected' variable is checked. If not empty, it's contents are copied to 'bind[number]' variable.
2.1.4 Referring to bound object
- Performing: In any state of the game, if an object is bound to a certain number, pressing this number selects the object immediately.
- Implementation: If CDirectInput class tells that a number was pressed, 'bind[number]' variable is checked, and if not empty it's contents is copied to 'selected' variable. Selected items action queue, action menu and info screen is asked to update themselves.
2.1.5 Building a building
- Performing: Move mouse curson on top of a building you want to build and press left button once or press the quick button on keyboard which refers to the building in question. Then move mouse cursor to the place you want to put the building and press left mouse button once. Then wait for the building to complete.
- Implementation: CDirectInput class tells that left mouse button was pressed and gives the coordinates, which are used to determine if the cursor was on top of a building icon in action menu. If it was, then the mouse cursor is chanced to a appropriate building. A correct keyboard button does the same thing (checked from CDirectInput). When left mouse button is pressed again, the coordinates tell where the building is set to be built. If there was no collisions with other objects or heightmap and the coordinates are inside the 'energisized' region a building object is created to those coordinates. Available resources will be checked, if they're too few, a sound is played with a on-game message shown and building is cancelled. Selected items action queue, action menu and info screen is asked to update themselves.
2.1.6 Cancelling building of a building
- Performing: First select the building you wish to cancel with mouse. Then press the cancel button from action menu or press 'esc' from keyboard.
- Implementation: 'selected' variable points to a game object. When CDirectInput class tells that left mouse button was pressed on top of a cancel button in action menu or 'esc' was pressed on keyboard a 'cancel' command is sent to selected game object. Because the object is being built, the cancel command cancels the building process. Action queue, action menu and info screen is asked to update themselves.
2.1.7 Using action queue to develop technology or build mechs
- Performing: Select a building you want to use to build or develop something. After selection the objects action menu shows all the building/development possibilities. Clicking one of them with left mouse button adds it to the objects action queue to be built/developed. Building/developement of an item can be cancelled by clicking it with left mouse button. Every command has also a shortcut key.
- Implementation: If 'selected' variable points to a building, left mouse button was pressed (CDirectInput) on top of the action menu item and the action queue is not full, the item is added to the queue. If left mouse button is pressed over the item in queue a cancel message is sent to the item. The queue will be popped every time the previous item is completed, the resources are checked just in time. If resources are too few for queued item, it will be set pending, and it will wait until resources are available (fixed interval for checking).
2.1.8 Mech actions
- Performing: You can command the mech by selecting an action from the action menu or using proper shortcut key from keyboard. Some actions are actually action groups, and the action is selected from the submenu. Actions (excluding stop) can be cancelled from the submenu, right clicking on the terrain or pressing esc. Destination for most of the actions has to be given by left clicking on the terrain. With 'shift' pressed down you can combine actions which are then performed in the order they were given. Queued actions can be cancelled by left clicing from the action queue.
- Implementation: CDirectInput and action menu classes are used to detect given orders. Submenu is displayed instead of the main action menu when needed. Every submenu contains Cancel action, which returns to the main action menu. If shift was not pressed, 'do action' message is sent to the selected game object and it's action queue cleared. If shift button is pressed down the actions are added to the action queue in given order and object performs them in FIFO order.
2.1.8.1 Moving actions
- Performing: Mech has three different moving commands -- move, stop and patrol. Destination is required for move and patrol commands. Queuing action after patrol is not possible and results to instant performing.
- Implementation: Command and destination is passed to the selected mech by using message system. Current position has to be stored for patrolling. If path finding technology has been developed, A* algorithm is used for navigation (see 1.5.1). Otherwise direct route is used. If no path is available, action is cancelled. As stop command doesn't require destination and has no subactions, it doesn't have sub action menu and is performed instantly.
2.1.8.2 Building power distribution system
- Performing: Building power distribution system is like building any other building (see 2.1.5). Only requirements are resources and clear terrain. Mech can not be controlled while building. Action can be performed from the fps mode with shortcut key, in which case current mech location is used for building.
- Implementation: First part of the building is simalar to moving command (see 2.1.8.1). If mech fails to get to the location, action is cancelled. Second part is similar to building a normal building (see 2.1.5), but special animation is played for the mech, and a flag is set to indicate the building state. After building is completed (or cancelled), mech returns to the normal state.
2.1.8.3 Changing weapons and modes
- Performing: Different weapons and operating modes can be selected from submenus. Changing the operation mode can be similarly performed from the fps mode with a shortcut key. Changing the weapon from the fps mode is a bit different operation (see 2.2.4).
- Implementation: Submenu is displayed after selecting "Select weapon" or "Change mode" action group. At this point, command can be cancelled. After selecting the real action (weapon or mode), message is sent to the mech and action is performed instantly. Info screen and mech animation is updated according to the change.
2.1.8.4 Attacking actions
- Performing: Attack action depends on the available technology and the selected weapon. EMP shockwave can be launched instantly, byt destination coordinates are required for other weapons. With landmines, mech has to travel to the selected location before burrowing the mine. Othervice mech starts to shoot the target. If autoaim technology is available, moving target can be attacked as long as it is on sight. Without autoaim fixed destination coordinates are used.
- Implementation: Bullet creation (see 2.2.3) and damage model (see 3.2.2) is identical to the fps mode shooting. Attacking will continue until target is destroyed (requires machine vision), or new command is given.
2.1.9 Changing into FPS mode
- Performing: First select a mech you want to control in first person perspective. Then you can press 'enter' or bound key for this mech from keyboard or double click it with left mouse button. Perspective moves to FPS instantaneously.
- Implementation: When CDirectInput class tells that left mouse button is double clicked or 'enter' or number is pressed, the message is sent to the selected object and it proceeds with changing perspective to FPS if everything is in order (selected object is mech etc.).
2.1.10 Exploring the Map
- Performing: A mech can see only to a certain distance, and so can a building. Totally unseen areas are covered in black, and the map needs to be explored with a mech. After a location has been seen once, it will be visible within a fog. Only buildings (as they were at the time they were seen) and the terrain are seen under the fog. There is also a tecnology called Map Scanner that allows the player to see all black areas as fogged (scans the entire terrain).
- Implementation: An array will contain information of visible and seen locations. The values in the array will be updated every round, so that visible or foggy areas become foggy. Then all players objects that have visual capabilities will update information about what they see. Info about seen buildings will be preserved when they're inside the fog, and their state will be updated when they're seen again. If the "Map Scanner"-technology is developed, the seen flag will be set for the whole array.
2.1.11 Upgrading mechs
- Performing: When a mech is in a build platform, the platform is selected and there are upgrades available, the upgrades will be in the action menu. Clicking these will queue the action. The mech may not be moved out of the platform, or the upgrade is cancelled. New technologies will be available to the mechs only thorough upgrades.
- Implementation: When a mech arrives at a build platform, the platform will be sent a message, and it will store a pointer to the mech object. When a platform is selected, it checks, if the pointer is set. Then it polls available upgrades, and upgrades already done, and tells the action menu to display the available options. When a item in the action menu are clicked, the action is added to the action queue. The queue will be popped when the platform is not doing anything. When a action is popped from the queue, it will check and reserve (or wait for) needed resources, and check that the right mech is at the platform. After that a message will be sent to the platform and the mech to set their status and animations. If the mech is moved, the upgrade will be cancelled, and the resources freed. After the action's duration counter finshises, the mech is sent a message and it's animation updated to reflect the upgrade.
2.2 FPS Functions
2.2.1 Moving
- Performing: You can move the mech forward and backwards by pressing 'w' or 's' respectively, and turn left or right by pressing 'a' or 'd'. Moving forward will move the mech to the direction of it's feet (ie, not necessarily the same direction as the camera/upper body is looking at), and backwards to the opposite direction.
- Implementation: CDirectInput class tells that certain of these keys is pressed. The message is sent to the mech game object, and it will alter it's rotation and velocity and set its animation to reflect the movement.
2.2.2 Aiming
- Performing: Mech's upper torso can be controlled independently from the feet by using the mouse. The amount of this rotation is defined by the amount of "Turning upper body"-technology of the movement technology branch (see Concept document, 3.3.3.1).
- Implementation: CDirectInput class tells that mouse was moved and message is sent to the mech game object. The object will then turn the upper body according to the speed of the mouse, but with a maximum speed. The animation will be changed to reflect the new rotation of the upper body. The camera queries it's direction from the mech's upper body, so it will view what the mech sees.
2.2.3 Shooting
- Performing: The primary weapon can be fired using the left mouse button.
- Implementation: CDirectInput class tells that left mouse button was pressed. The mech object will then be queried for the direction and weapon type, and a new bullet object is created with initial velocity as specified by the mech and the weapon. Weapons are inaccurate from the long distances.
2.2.4 Changing a weapon
- Performing: The primary weapon can be changed using the right mouse button. This selects next available weapon from the weapon bar. First weapon from the bar is selected after last one.
- Implementation: CDirectInput class tells that right mouse button was pressed. The mech game object will then be told that it should change weapon. The object will then set it's primary weapon and update it's animation to show the new selected weapon. Weapon bar is updated to show current weapon.
2.2.5 Changing into RTS mode
- Performing: The mode can be changed back to the RTS mode by pressing escape or one of the bound numbers for object in the FPS mode. This may also occurr non-interactively, if the mech in question is destroyed while in use.
- Implementation: CDirectInput tells when the key is pressed. The mech object will be notified, and it will return to the state it was before the FPS mode, and the visible area in the RTS will be centered to the mech or the newly selected object.