The next example is taken from Starflight beta design doc and explains how combat works in this old game. The purpose of this example is to show that little has realy change in game engine design and that the foundations of game engines are still mostly based on actors and event driven programming (simulation part) with reactive agents (AI part) using a central data model to link all game components.
Also see this link containing a document that describes this kind of architecture in detail:
http://www.jeffplummer.com/Writings/Writings.htmModern games like Morrowind and Oblivion don't add much more complexity to the simulation and AI part. Instead the complexity increase happens in other components that have little effect on gameplay. The graphics engine is much improved. The amount of graphical detail and content available to the player has increased a lot. Game engines use external components like tools to create a face and customize the character in many different ways. There are external components to simulate realistic forest and physics. Games are starting to use more than just reactive AI solutions but are still mostly scripted environments which amounts to reactive AI. There is a search involved in path-finding, following and escorting but nothing that uses advanced AI.
Now to start with the example to the describe the behavior of Starflight ships in an encounter scene.
Actors
------
Scene: Encounter scene in hyperspace (a 2d grid with 2-dim coordinates)
Actors: Player Ship, Alien Ship, Debris
Mute Actors: Missiles, Lasers
Events Sent by Ships to the Game Controller
-------------------------------------------
Fire Missile(s1,s2) - create missile at s1 pos and seek ship s2
Fire Laser(s1,s2) - create laser at s1 position and target s2 (instantaneous)
MoveToXY(x,y) - player ship move to x,y
Move Away(a) - from player ship
Approach(a) - player ship
Move Randomly(a) - around player ship
Evade(a) - maintain distance from player ship
Raise Shields(s) - alien or player ship raises shields
Lower Shield(s) -
Arm Weapons -
Disarm Weapons -
Call More Ships(a) - alien ship calls for more ships to aid him in combat
Scan Ship(s,x,y) - scan location x,y
Pick Cargo(s) - pick all cargo in debris near the ship
Hail(s1,s2,p) - player hails at alien ship or alien ship hails at player in posture p
Note: Aliens do not tell the controler where they want to move, instead they request from the controller a certain movement style and the controller decides to each specific location the alien ship should move. The player ship specificaly issues a move to xy command because the player controls the ship directly.
Note2: Starflight is optimized so that these are actualy direct funtion calls inside the game cycle.
Ship Local Status
-----------------
boolean CanSurrender - if this alien hail for surrender.
pos Position - (x,y)
float Rotation - angle
float MoveRate - how fast the ship can move
int HitPoints - ship hit points
enum Race - race that owns alien ship.
enum LaserStatus = ARMED|DISARMED|DISABLED
enum MissileStatus = ARMED|DISARMED|DISABLED
enum ShieldStatus = ARMED|DISARMED|DISABLED
enum EngineStatus = ENABLED|DISABLED
enum MovementType
Vars Used by Events
-------------------
boolean InComm
InComm is et when the game enters comm mode and cleared when exits comm mode.
Cleared when scene starts.
boolean InCombat
Player has selected the Navigator combat option.
Cleared when scene starts.
boolean Terminated
Game has left comm mode.
Cleared when palyer enters comm mode again.
Cleared when scene starts.
boolean Surrender
Player has requested to surrender.
Cleared when scene starts.
boolean Attacking
Attack is set to true when any alien ship fires a weapon at the player.
Attack is reset when no alien ship has fired a weapon for 2 minutes or when communications was entered.
Cleared when scene starts.
boolean NothingHappening
If there was no communication within 2 minutes.
Cleared when scene starts.
boolean PFiredMissile
Player has fired a missile that hasn't exploded yet.
Cleared when missile explodes or timeouts.
Cleared when scene starts.
boolean AFiredMissile
Alien has fired a missile that hasn't exploded yet.
Cleared when missile explodes or timeouts.
Cleared when scene starts.
boolean Dead
Ship has been destroyed and become debris.
Cleared when scene starts.
float Damage
Set to the number of hit points damaged when ship is attacked.
Cleared when scene starts.
boolean Call
Reinforcements have been called.
Cleared when reinforcements arrive.
Cleared when scene starts.
boolean Arrived
Reinforcements have arrived.
Cleared when scene starts.
enum Range = SHORT|MED|LONG
If player ship is > 20 cell distance from closest alien ship.
If player ship is 7-20 cell distance (missile range) from closest alien ship.
If player ship is < 7 cell distance (laser range) from closest alien ship.
Default depends on initial scene setup.
class ScanData
Scan data of last scanned ship. This gives info about scanned ships like arm and shield status, hit points and movement type. Cleared when a new scan is started.
Cleared when scene starts.
Events Received by Ships or Player
----------------------------------
Note: When a scene is started and event vars get their default values no events are generated.
Theres one event for when each event variable is set or cleared. For example NothingHappeningSet and NothingHappeningClear.
Starflight Logic (beta doc)
---------------------------
Taken from this site:
http://www.starflt.com/starflt.php?ID=SF1Univ1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| (weapons)
FIRE MISSILES <-- ?IN-COMBAT TRUE ?P-HAS-MISSILES TRUE ?P-FIRE-MISS-NOW TRUE ?MISSILES-DEAD FALSE FIRE LASERS <-- ?IN-COMBAT TRUE ?P-HAS-LASERS TRUE ?P-FIRE-MISS-NOW FALSE ?P-FIRE-LASER-NOW TRUE ?LASERS-DEAD FALSE ?RANGE-SHORT TRUE (movement)
APPROACH <-- ?IN-COMBAT TRUE ?RANGE-LONG TRUE ?A-FIRED-MISSILE FALSE ?ENGINES-DEAD FALSE APPROACH <-- ?IN-COMBAT TRUE ?RANGE-MED TRUE ?A-FIRED-MISSILE FALSE ?MOVE-RND-NOW FALSE ?APPROACHING-NOW TRUE ?ENGINES-DEAD FALSE MOVE RANDOMLY <-- ?IN-COMBAT TRUE ?RANGE-LONG FALSE ?A-FIRED-MISSILE FALSE ?MOVE-RND-NOW TRUE ?ENGINES-DEAD FALSE EVASIVE <-- ?IN-COMBAT TRUE ?A-FIRED-MISSILE TRUE ?ENGINES-DEAD FALSE
(if none of these are done then DO NOTHING)
Alien Auxillary Actions
RAISE SHIELDS <-- ?SHIELDS-UP FALSE ?FRIENDLY FALSE ?SURRENDER FALSE LOWER SHIELDS <-- ?SHIELDS-UP TRUE ?FRIENDLY TRUE LOWER SHIELDS <-- ?SHIELDS-UP TRUE ?SURRENDER TRUE ARM WEAPONS <-- ?WEAPONS-ARMED FALSE ?FRIENDLY FALSE ?NEUTRAL FALSE ?SURRENDER FALSE DIS-ARM WEAPONS <-- ?WEAPONS-ARMED TRUE ?HOSTILE FALSE ?OBSEQUIOUS FALSE ?FIGHT FALSE DIS-ARM WEAPONS <-- ?WEAPONS-ARMED TRUE ?SURRENDER TRUE CALL FOR MORE SHIPS <-- ?CALL TRUE ?CALLED FALSE ?RACE TRUE ?<3SHIPS TRUE ?FRIENDLY FALSE ?NEUTRAL FALSE ?SURRENDER FALSE MORE SHIPS ARRIVE <-- ?CALLED TRUE ?ARRIVE TRUE SCAN PLAYER'S SHIP <-- ?RACE TRUE ?SCAN TRUE ?SCANNED FALSE |