Monday, August 6, 2012

Creating an Event

This is probably my final post on creating an event within a mission.  Each event can be broken down into two primary parts: a trigger and an action.  Each part has smaller subparts that can further define the trigger.  For example, a timed trigger would have a time associated with it.  The event triggers at the time specified in the subpart.  Actions would have similar subparts.

For the most part, triggers share many similar subparts.  A trigger is usually described by a named trigger with a time and/or distance offset.  This means any system describing a trigger will need a trigger name, time and distance field.  In addition, other triggers could involve damage taken by a ship.  This would require a structure (HP) field. 

Consequently, a trigger data object needs these fields to hold a proper trigger.  In addition, it will have a field to hold a reference value for an action.  This field points to an action object as a unique identifier.  This is the final breakdown for triggers:

+ OID (Unique ID field, aka a primary key in a database)
+ MissionName : string (used to filter out irrelevant data records)
+ TriggerName : string (also used as a reference field)
+ Time : float
+ Distance : float
+ Damage : float (percentage)
+ Action : string (references a field within an action object)
+ ActionType : string (tells the computer where to look for the action parameters).

On the other hand, actions is much more difficult to define.  There are many different actions with different subpart requirements.  For example, creating a cylon fighter requires different information than creating  waypoint and inserting a waypoint into a waypoint manager object.  Playing a sound requires different data than creating an object.  This means that actions have to be broken up into different action objects "controlled" by a trigger object.

To start I will be limiting action categories to existing categories in the first tutorial.  The first action to happen in any mission is the instantiation (creation and placement) of all objects in the game.  This includes obvious game objects like the player's fighter and less obvious game objects like each waypoint and any other area trigger objects.  Both types of objects require a position (x, y and z) and rotation (x, y and z).  Fighter objects require player, vehicle and AI (NPC only) data.  Area triggers, including waypoints, will need a trigger distance. 

To facilitate instantiation of both types, the action object will need a pointer.  This pointer will consist of the name of another object (vehicles or controller) and a reference field.  The reference field will be a searchable primary key.  The fields attached to that primary key will hold the pertinent data to load the object.  Here's the breakdown for the general instantiation:

OID (Unique ID needed for the database)
MissionName : string
ActionName : string (actual primary key pointed to by the Action field of the trigger)
Position (x, y, z) : float (x, y, z)
Rotation (x, y, z) : float (x, y, z)
ObjectType : string (tells which table to load from - vehicle/controller)
Object : string (references a record in the table associated with ObjectType)

For vehicle objects:

OID
Object : string (primary key pointed to by the Object field in the Action table)
MissionName : string
FirstName : string
...
PC : bool

For controllers:

OID
Object : string (primary key pointed to by the Object field in the Action table)
Distance : float (triggering distance)
Manager : string (name of a waypoint manager or other manager object)
ItemNumber : string (mostly a waypoints index number)

These fields are expandable, and I will probably add fields as I need them in future missions.  This just represents the general breakdown of the structure.

In addition to instantiation, voice overs will play throughout the mission.  Voice overs are rather simple.  They should consist of a file name and a source.  The source is not the game engine audio source; it represents the entity speaking dialog.  This is necessary to avoid starting two clips from the same person at the same time.  So the breakdown for the audio table is:

OID
MissionName : string
AudioName : string
Source : string

In order to make things more searchable, all of these tables will need a mission name field.  When the intital data is loaded, only mission data (or default data for those actions that happen across all missions - if they exist) will be loaded into the mission lists.  This will cut down on search times as the event manager sifts through the lists.

This is the basic structure used by the event manager. 

Saturday, August 4, 2012

Triggered Events

Well, I stepped away from BSG for a few weeks.  I needed the rest.  I started working on it again this past week.  I created a new destroyer which should be more visually pleasing than the original one I created a few months ago.  In addition, I created a model for the Scropion fighter that will be used as the "starter" fighter. 

Here are a couple of images of the untextured versions (I don't have a good texturing setup at this time - btw, you can click on an image to enlarge it):

The Battlestar Trident (Destroyer):



Scropion Class Fighter (mk1):




I wanted both of these ships in the first tutorial, even if they aren't textured at this point.  Both ships play a predominant role in the early game.  It just makes sense to create both ships.  In addition, it gave me more practice at the model creation process.  In addition to these ships, I do have plans to build some asteroids (low polygon count, which is difficult to find), a space station and a "starter" Cylon fighter craft. 

As for the tutorial, I have started some work on it.  I have created a means to access the database and a means to retrieve player and vehicle data from it.  I started to create another access module for mission data related to vehicles and objects.  There are some issues that I need to consider before proceeding with this module. 

First, there will be very few static models in a mission.  Models, whether it is an asteroid or fighter, will be instantiated by the resource manager.  The only static objects will be manager objects, even some of these will be instantiated by the resource manager.  This will require a great deal of information to be stored inside the database.  For example, the positions of all fighters in a mission will need to be stored in the database.  When the mission loads, the resource manager gets each fighter along with positional and rotational data and instatiates it into the mission at time index zero. 

Second, triggers need to be incorporated into the manager early in the development cycle.  Triggers can be a time index or the player entering a trigger area.  Each of these triggers need to be recorded into the database.  The resource manager will load this data and track the triggers.  The problem is identifying and implementing the triggers.  Timed triggers are relatively straightforward.  Other triggers can be problematic.  Here are some triggers that I can think of (along with some variables associated with the trigger):

Timed  - requires a time index value - what is the event
Enter - requires a triggering object - triggering distance - what is the event
Enter (delayed) requires a triggering object - triggering distance - time delay value - what is the event
Exit - requires an triggering object - triggering distance - what is the event
Exit (delayed) requires a triggering object - triggering distance - time delay value - what is the event
Destruction - requires a triggering object - what is the event
Health Trigger - requires a triggering object - triggering health value - what is the event

While I covered instantiate events, there are other events: audio execution, destroy object and others. 

Third, the system needs to be flexible enough to implement new trigger events and actions.  While the tutorial will have a timed, enter and delayed enter trigger events that involve executing audio, the systems needs to be able to easily implement code to include other trigger events and actions like instantiating an object.  This also applies to the database.  If the database cannot hold the data, it design of the code won't matter. 

So, what is the solution?  I'm going to think about it some and attempt to plan out the interactions between the code and database.  If anyone has a suggestion, I'd love to hear it...

Thursday, August 2, 2012

Destroyer Vote

I have designed two Colonial destroyers.  The first destroyer is the Battlestar Hermes, and I have posted it before.  The second is the Battlestar Trident.  This is a new destroyer that I created this week.  I was just wondering which one is better. 

Hermes:



Trident:





The Hermes is badly textured, and the Trident is untextured.  Unfortunately, I don't have access to a good texturing program at this time.

Please let me know which one is better...