Saturday, December 7, 2013

Damage Control

The more I jot down notes for this script, the more I realize that this script will undergo some huge changes.  In previous versions, Damage Control was a relatively small script with a specific objective that really didn't need to exist outside of Flight Control.  Now, it might just get to be a key script with a lot of code.

Basically, it will have access to the Flight Control script and will be able to update the current structure of the parent ship.  Right now, this is its only true interaction with Flight Control.  In addition, it will need a list of interchangeable parts.  This is where Damage Control will start to get complicated.

The list of interchangeable parts will actually be a list of a programmer defined type.  This type will contain a collider, a component, a replacement component and a damage threshold.  Basically, this script will get the collider hit by an attack.  It will find the collider, if the collider is in the list, and compare the amount of damage dealt to the damage threshold.  If the damage dealt exceeds the damage threshold, the script will "turn off" the original component and "turn on" the damage component.  This will allow space craft to be visually damaged in the game. 

In addition to these visual effects, damaging a craft should have an actual effect on the effectiveness of the craft.  Consequently, this script will need a series of subsystems.  When a collider is "hit", this script will also check for a keyword.  For example, the "left engine" collider has the keyword "engine".  These keywords will funnel hits on specific parts of the ship in a certain direction.

With a keyword system in place, the script will damage various subsystems.  An "engine" hit can affect "thrust", "fuel consumption rate" or other set subsystems.  Hits to other keywords can affect an entirely different set of subsystems. 

So, what are subsystems?  A subsystem is simply a float value representing a percentage.  Hitting the sensor subsystem would decrease the maximum sensor range by a certain percentage.  Hitting the maneuverability subsystem would have a similar effect on the ship's ability to turn.  Other systems would see an increase.  For example, damaging the fuel lines would increase the fuel consumption rate by a certain percentage.

Each of these subsystems would be accessible by other scripts.  The HUD Control would look up the sensor subsystem and incorporate that number into what is displayed to the player.  Flight Control would look up other relevant subsystems, like the fuel consumption, maneuverability and thrusting subsystems as part of its calculations. 

The plan is to eventually make Damage Control into a database compliant object.  This will allow me to use Damage Control to customize various ships using a single model or model set.  Actually, it may be two different database tables: one for cosmetics and another for subsystems.  However, this particular feature will be further down the road.  I will develop this script with a preload routine.  A "testing" script, will be attached to each object and will load the default values for a ship for the time being.  I want to see the new script in action before developing the database portion.

No comments:

Post a Comment