StarTrekV3_Linux  Version3
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros Pages
TShip Class Reference

#include <Ship.h>

Inherits TSprite.

Inherited by TEnterprise, TFederation_Ship, TKlingonBC, TKlingonBOP, TRomulanBop, and TStarbase.

Public Member Functions

 TShip ()
 constructor More...
 
virtual ~TShip ()
 virtual destructor More...
 
double WayPoint (double a_dX, double a_dY)
 Calculate angle to reach waypoint. More...
 
double GetX ()
 Get the X position. More...
 
double GetY ()
 Get the Y position. More...
 
double GetSpeed ()
 Get the speed. More...
 
double GetAngle ()
 Get the Angle. More...
 
int GetCloackState ()
 Get the cloak state. More...
 
virtual void DoEngineering ()
 VIRTUAL Do Engineering AI, damage control, energy management etc. Should be called in Do_ai(), inherited from TSprite More...
 
virtual void CalcPhaserDamage (double a_dEnergy, int a_nTarget)
 VIRTUAL Calculates the shield energy reduction and damage done by incoming phaser fire. More...
 
virtual void DoCollision (TSprite *a_pSprite)
 VIRTUAL Handle collision for this ship More...
 
virtual void DoCloak ()
 VIRTUAL Handle Cloaking Called by DoEngineering if m_blCanCloak is true More...
 
virtual void Draw (double a_dCamX, double a_dCamY)
 VIRTUAL Draw the ship and some effects (phaser) relative to camera position More...
 
virtual void Explode ()
 VIRTUAL Destroy this ship with an explosion should be called in Do_AI() when damage is critical More...
 
virtual void Control ()
 VIRTUAL Do the actual steering of the ship should be called in Do_AI() when m_dAngleSeek is calculated More...
 
bool Dock (TShip *a_pBaseTarget)
 Handle Docking procedure. More...
 
bool TryEnterDocking ()
 Try to enter the docking procedure. More...
 
void Release (TShip *a_pBaseTarget)
 Start releasing procedure from Docked. More...
 
void PrecalcFireAngles (int a_nLimit)
 Calculate the best firing angles for photon torpedoes Only works if sensor and computer are in good shape. More...
 
void LooseTarget ()
 Make this ship loose it's target. More...
 
double CalcVolume ()
 Calculate the Volume for events happening on/near this ship. More...
 
void Die ()
 set health of systems to zero so the ship will be destroyed More...
 
- Public Member Functions inherited from TSprite
virtual void Move (double a_dLagCount)
 ** VIRTUAL ** Move the sprite according to its speed. Called by Engine More...
 
virtual void Do_ai ()
 ** VIRTUAL ** Enter AI routine Called by Engine More...
 
void SetPosition (double a_dX, double a_dY, double a_dAngle)
 Sets the position of this sprite. More...
 
void SetPosition (double a_dX, double a_dY)
 Sets the position of this sprite. More...
 
void SetHeight (int a_nHeight)
 Sets the Height Z position ( drawing order) More...
 
void SetSpeed (double a_dSpeed)
 Sets the Speed. More...
 
void SetImage (ALLEGRO_BITMAP *a_pImage)
 Sets the Image of the sprite. More...
 
double GetX ()
 Get the X position. More...
 
double GetY ()
 Get the Y position. More...
 
 TSprite ()
 Basic sprite constructor. More...
 
virtual ~TSprite ()
 

Public Attributes

bool m_blPhaserOn
 Phaser firing. More...
 
bool m_blShieldOn
 Shields up ? More...
 
bool m_blDocked
 Is this ship docked. More...
 
bool m_blDocking
 Has this ship entered a docking procedure. More...
 
bool m_blReleasing
 Has this ship entered a release procedure from a Dock. More...
 
int m_nTask
 Tactical task number AI. More...
 
int m_nMaxShieldEnergy
 Maximum charge of shield. More...
 
int m_nShieldEnergy
 current charge of shield decreases when hit More...
 
int m_nEnergy
 Available energy for systems.. Warpcore output. More...
 
int m_nCloakState
 state of cloaking device if any More...
 
ALLEGRO_COLOR m_PhaserColor
 The color of the phaser. More...
 
TShipm_pTarget
 Pointer to target. More...
 
TShipm_pBaseTarget
 Pointer to starbase. More...
 
string m_strName
 Name of a ship. More...
 
vector< int > m_lstHealth
 Health of subsystems. More...
 
int m_nMaxHealth
 Maximum health of any system. More...
 
bool m_blMustBeDestroyed
 if true this ship must be destroyed to complete a task More...
 
bool m_blMustSurvive
 if true this ship must survive to complete a task More...
 
bool m_blMustReachPosition
 if true this ship must reach a certain position (m_dSafePosX, m_dSafePosY) More...
 
bool m_blDock
 True if ship must also dock. More...
 
bool m_blNoRelease
 if true ship will stay docked until false More...
 
- Public Attributes inherited from TSprite
bool m_blDestroyed
 
bool m_blCanCollide
 
bool m_blCanFind
 
MEMBER m_Member
 A sprite can be associated with a certain group (Federation, Klingon etc.) More...
 
ID m_ID
 an ID providig some runtime type information More...
 

Protected Member Functions

void SetSpeed (double a_dSpeed)
 Sets the speed of a ship. More...
 

Protected Attributes

AI m_AI
 AI state. More...
 
ID m_PreferedBase
 The ID of the starbasetype to dock at. (types.h) More...
 
double m_dSteer
 Turning rate. More...
 
double m_dAngleSeek
 Angle turning to (steering direction) More...
 
double m_dTargetDistance
 Distance to target if any. More...
 
double m_dViewDistance
 Maximum distance to detect other ships etc. More...
 
double m_dPhaserX
 start of Phaser line Offset X More...
 
double m_dPhaserY
 start of Phaser line Offset Y More...
 
double m_dSafePosX
 Safe position for Escort missions X. More...
 
double m_dSafePosY
 Safe position for Escort missions Y. More...
 
double m_dMaxSpeed
 Maximum speed. More...
 
double m_dWaypointX
 Waypoint to go to X. More...
 
double m_dWaypointY
 Waypoint to go to Y. More...
 
double m_dPhaserAngle
 Angle of phaser when firing. More...
 
double m_dAimangle
 Angle of bullets ( firing direction) More...
 
int m_nRepairItem
 Item being repaired by crew, if any. More...
 
int m_nCrew
 Number of crewmen. More...
 
int m_nPhaserEnergy
 Energy of the phaser. More...
 
int m_nPreferedTarget
 What target subpart to fire at. More...
 
int m_nPhaserPower
 How powerful is the phaser ( efficiency) More...
 
int m_nTorpedoes
 Number of torpedo weapons. More...
 
int m_nFlyheight
 standard cruise Z value.. used for dock and release procedures More...
 
int m_nEnergyTimer
 Timer for Energy management ( warpcore) More...
 
int m_nRepairTimer
 Timer for repairs. More...
 
int m_nPhaserFireTimer
 Timer for phaser damaging target. More...
 
int m_nPhaserTimer
 Timer for phaser recharge. More...
 
int m_nShieldTimer
 Timer to recharge shield. More...
 
int m_nPhotonTimer
 Timer to reload photon tubes. More...
 
int m_nCloakCounter
 counter for cloaking device if any More...
 
int m_nCloakCharge
 Energy of cloaking device. More...
 
int m_nTranslucency
 Cloaking effect. More...
 
bool m_blCanCloak
 Can this ship Cloak. More...
 
- Protected Attributes inherited from TSprite
TEnginem_pEngine
 Pointer to the engine. More...
 
ALLEGRO_BITMAP * m_pImage
 pointer to a bitmap representing this sprite More...
 
int m_nZ
 Z drawing order ( Depth) More...
 
double m_dAngle
 
double m_dX
 
double m_dY
 
double m_dSpeed
 
int m_nBitmapWidth
 
int m_nBitmapHeight
 
int m_nBitmapMidX
 
int m_nBitmapMidY
 

Friends

class TEngine
 

Detailed Description

TShip is the ancestor class for all ships and starbases. It has a lot of handy AI support functions, like damage control, Engineering, Docking procedures... Everything that is in space and has some "Smartness" in it's AI should derive from here

Constructor & Destructor Documentation

TShip::TShip ( )

constructor

TShip::~TShip ( )
virtual

virtual destructor

Member Function Documentation

void TShip::CalcPhaserDamage ( double  a_dEnergy,
int  a_nTarget 
)
virtual

VIRTUAL Calculates the shield energy reduction and damage done by incoming phaser fire.

Parameters
doublea_dEnergy Ammount of energy hitting target
inta_nTarget What subsystem was fired at
double TShip::CalcVolume ( )

Calculate the Volume for events happening on/near this ship.

Returns
The volume of any sound according to the distance to the camera center
void TShip::Control ( )
virtual

VIRTUAL Do the actual steering of the ship should be called in Do_AI() when m_dAngleSeek is calculated

void TShip::Die ( )

set health of systems to zero so the ship will be destroyed

bool TShip::Dock ( TShip a_pBaseTarget)

Handle Docking procedure.

Parameters
TShip* a_pBaseTarget Where to dock
Returns
true when still in docking procedure, false when unable to dock or when already docked.
void TShip::DoCloak ( )
virtual

VIRTUAL Handle Cloaking Called by DoEngineering if m_blCanCloak is true

void TShip::DoCollision ( TSprite a_pSprite)
virtual

VIRTUAL Handle collision for this ship

Parameters
TSprite* a_pSprite The sprite this ship collided with Called By Detect_collision(TSprite * a_pSprite1, TSprite * a_pSprite2) in TEngine.

Reimplemented from TSprite.

void TShip::DoEngineering ( )
virtual

VIRTUAL Do Engineering AI, damage control, energy management etc. Should be called in Do_ai(), inherited from TSprite

Reimplemented in TEnterprise.

void TShip::Draw ( double  a_dCamX,
double  a_dCamY 
)
virtual

VIRTUAL Draw the ship and some effects (phaser) relative to camera position

Parameters
doublea_dCamX Camera X position
doublea_dCamY Camera Y position Only draws what is within the screen boundaries Called by TEngine::Draw();

Reimplemented from TSprite.

void TShip::Explode ( )
virtual

VIRTUAL Destroy this ship with an explosion should be called in Do_AI() when damage is critical

double TShip::GetAngle ( )

Get the Angle.

int TShip::GetCloackState ( )

Get the cloak state.

double TShip::GetSpeed ( )

Get the speed.

double TShip::GetX ( )

Get the X position.

double TShip::GetY ( )

Get the Y position.

void TShip::LooseTarget ( )

Make this ship loose it's target.

void TShip::PrecalcFireAngles ( int  a_nLimit)

Calculate the best firing angles for photon torpedoes Only works if sensor and computer are in good shape.

Parameters
inta_nLimit Number of iterations, more iterations is more precise sets m_dAimangle
void TShip::Release ( TShip a_pBaseTarget)

Start releasing procedure from Docked.

Parameters
TShip* a_pBaseTarget The object docked at
void TShip::SetSpeed ( double  a_dSpeed)
protected

Sets the speed of a ship.

Parameters
doublea_dSpeed Speed value (0-100..200)
bool TShip::TryEnterDocking ( )

Try to enter the docking procedure.

Returns
true if successful, the ship will switch AI to docking
double TShip::WayPoint ( double  a_dX,
double  a_dY 
)

Calculate angle to reach waypoint.

Parameters
doublea_dX Waypoint X
doublea_dY Waypoint Y
Returns
The angle to turn to, should be passed to m_dAngleSeek

Friends And Related Function Documentation

friend class TEngine
friend

Member Data Documentation

AI TShip::m_AI
protected

AI state.

bool TShip::m_blCanCloak
protected

Can this ship Cloak.

bool TShip::m_blDock

True if ship must also dock.

bool TShip::m_blDocked

Is this ship docked.

bool TShip::m_blDocking

Has this ship entered a docking procedure.

bool TShip::m_blMustBeDestroyed

if true this ship must be destroyed to complete a task

bool TShip::m_blMustReachPosition

if true this ship must reach a certain position (m_dSafePosX, m_dSafePosY)

bool TShip::m_blMustSurvive

if true this ship must survive to complete a task

bool TShip::m_blNoRelease

if true ship will stay docked until false

bool TShip::m_blPhaserOn

Phaser firing.

bool TShip::m_blReleasing

Has this ship entered a release procedure from a Dock.

bool TShip::m_blShieldOn

Shields up ?

double TShip::m_dAimangle
protected

Angle of bullets ( firing direction)

double TShip::m_dAngleSeek
protected

Angle turning to (steering direction)

double TShip::m_dMaxSpeed
protected

Maximum speed.

double TShip::m_dPhaserAngle
protected

Angle of phaser when firing.

double TShip::m_dPhaserX
protected

start of Phaser line Offset X

double TShip::m_dPhaserY
protected

start of Phaser line Offset Y

double TShip::m_dSafePosX
protected

Safe position for Escort missions X.

double TShip::m_dSafePosY
protected

Safe position for Escort missions Y.

double TShip::m_dSteer
protected

Turning rate.

double TShip::m_dTargetDistance
protected

Distance to target if any.

double TShip::m_dViewDistance
protected

Maximum distance to detect other ships etc.

double TShip::m_dWaypointX
protected

Waypoint to go to X.

double TShip::m_dWaypointY
protected

Waypoint to go to Y.

vector<int> TShip::m_lstHealth

Health of subsystems.

int TShip::m_nCloakCharge
protected

Energy of cloaking device.

int TShip::m_nCloakCounter
protected

counter for cloaking device if any

int TShip::m_nCloakState

state of cloaking device if any

int TShip::m_nCrew
protected

Number of crewmen.

int TShip::m_nEnergy

Available energy for systems.. Warpcore output.

int TShip::m_nEnergyTimer
protected

Timer for Energy management ( warpcore)

int TShip::m_nFlyheight
protected

standard cruise Z value.. used for dock and release procedures

int TShip::m_nMaxHealth

Maximum health of any system.

int TShip::m_nMaxShieldEnergy

Maximum charge of shield.

int TShip::m_nPhaserEnergy
protected

Energy of the phaser.

int TShip::m_nPhaserFireTimer
protected

Timer for phaser damaging target.

int TShip::m_nPhaserPower
protected

How powerful is the phaser ( efficiency)

int TShip::m_nPhaserTimer
protected

Timer for phaser recharge.

int TShip::m_nPhotonTimer
protected

Timer to reload photon tubes.

int TShip::m_nPreferedTarget
protected

What target subpart to fire at.

int TShip::m_nRepairItem
protected

Item being repaired by crew, if any.

int TShip::m_nRepairTimer
protected

Timer for repairs.

int TShip::m_nShieldEnergy

current charge of shield decreases when hit

int TShip::m_nShieldTimer
protected

Timer to recharge shield.

int TShip::m_nTask

Tactical task number AI.

int TShip::m_nTorpedoes
protected

Number of torpedo weapons.

int TShip::m_nTranslucency
protected

Cloaking effect.

TShip* TShip::m_pBaseTarget

Pointer to starbase.

ALLEGRO_COLOR TShip::m_PhaserColor

The color of the phaser.

ID TShip::m_PreferedBase
protected

The ID of the starbasetype to dock at. (types.h)

TShip* TShip::m_pTarget

Pointer to target.

string TShip::m_strName

Name of a ship.


The documentation for this class was generated from the following files: