The following is a showcase of in-game scripting that I have done on various games.
Buzz-Bomb was built as a prof of concept to see if real-world robotic control techniques could be utilized inside a game environment. Buzz-bomb uses a variety of scripts to help him navigate, follow the player, self-correct, and path-follow.
Buzz-Bomb doesn't actually float by fake means, he works using the game physics engine. Rather then hard set his elevation, Buzz-Bomb actually shoots out a virtual laser range finder below him to detect how far away he is away from an object. Then using three virtual thrusters: physics force is applied to lift his mass off the ground. Once his elevation is above the desired number, his thrusters cut-off letting him drop. This repeats over and over causing him to naturally bob up and down just as a real thruster driven robot would. This natural use of the physics engine means he can self-correct if turned up-side-down and interact with the player, explosions or other objects in the game world.
Buzz-Bomb has an virtual eye. Using a "follow the carrot" technique, he is told to start tracking a way-point, or other object such as the player. Then using a forward thruster that pulls in the direction he is looking, he can move toward any point in the game world. This allows him to follow the player, or a pre-determined path. His speed is controlled based on the distance to his target object, so the faster the player runs, the faster he tries to follow.
He also has some basic path-finding ability in order to detect if there is an obstruction in front of him, such as a wall, that pushes him toward the door opening.
Castaway, player detecting spot-light:
As part of my Castaway map, I had a prison camp with automated defenses. A high-power spot-light would aim and move randomly around the camp, looking for anything out of place. If the player was caught in the beam of the spot-light the spotlight color would turn red, an alarm would sound, and the defense towers would come online. The player could either evade the spot light, hiding in a shadow, or engage his cloak.
This was all achieved using a complicated flow-graph scripting system. It uses various math and trigger elements built into CryEngine2. The flowgraph first randomly rotates and pitches the spotlight within a given tolerance. It then calculates the angle of between where the spot light is aimed, and where the player is located relative to the spotlight origin. If this falls with-in a certain enough range, and the player is not in a shadow area, the spot light changes color, and starts to actually track the player. The player has only seconds to take cover or cloak in order to avoid being shot.
Darkwater, free fall though the air, with full player control:
This was a fun and challenging scene I planned out for my game. The end result really gives the player a sense that they have control of their path in the air just like a real skydiver.
The scene: The player is being hazed as the new guy in the squad. As such the squad leader jumps out of the airplane with the player's parachute in-tow. The challenge: Make a cutscene were the player must jump out of the plane, has control of his flight, all while free falling though the air. The player has to be able to find and catch-up with the other character before hitting the ground.
In order to make this scene work a variety of flow-graph scripts were made to both give the player control, and also nudge the player into the correct position for the scene to work. The hard part is that by giving the player full control while falling, they could easily get lost, not find the other character falling below them, or even fly right past the other character while trying to get close. The free fall of the other character lasts for only one minute, the player must jump from the plane within thirty seconds in order to catch-up with the other character and re-claim his parachute…or die when they hit the ground.
Normally in the CryEngine a player can do a free-fall. In fact the Crysis starts out with a free fall in the beginning of the game. However they gave the player only control over the direction they can face, but no actual movement is allowed in the air. Using a flow-graph that detects the keyboard keys, I was able to give the players control over their movement in all directions. This was achieved using the game physics engine, actually nudging the character in the direction they were facing. However finding another character falling a hundred feet below you can be challenging even if the other character is giving off a smoke trail.
So as part of the flow-graph, the game physics engine detect how far away you are from the other character, and constantly nudges you toward a spot next to that character, again all while both the player and character are free falling. The further the player is from the other character, the stronger the force pushing you towards their position. This automatically compensates for lost time between the character and player jump, and also dampens the players controls such that they can't move too far away from the other character, preventing a player from just zooming though the air in the opposite direction.
Finally the script also controls the other character, who automatically faces the player once the player is close enough, says a line of dialog, and gives the player the parachute, often within seconds of hitting the ground.
The end result is a thrilling free fall cut-scene that doesn't break the reality or control the player feels in the game.
Left 4 Dead 2 – Working Skeeball and bowling mini-games.
While not nearly as advanced as what was possible in Crysis, getting working Skeeball and Bowling inside Left 4 Dead 2 was quite a feat.
The bowling uses a series of in-game triggers to detect the player, ball release point, foul line, gutter ball, strikes and spares. The game physics engine handles the tossing of the ball, randomness in the path path, and the pins getting knocked down.
The game plays two frames before resetting. The bowling alley is build exactly to real-world specs.
An authentic to-scale skeeball machine was modeled from scratch. The player presses a button to release a skeeball towards the target on a randomized path. The game engine and a detailed physics model handle the ball movement. A series of trigger and counters keeps score and tracks how many balls the player has left.