Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mount.cpp File Reference
#include "unit_generic.h"
#include "missile_generic.h"
#include "beam.h"
#include "bolt.h"
#include "weapon_xml.h"
#include "audiolib.h"
#include "unit_factory.h"
#include "ai/order.h"
#include "ai/fireall.h"
#include "ai/script.h"
#include "ai/navigation.h"
#include "ai/flybywire.h"
#include "configxml.h"
#include "gfx/cockpit_generic.h"
#include "force_feedback.h"
#include "networking/netclient.h"
#include "ai/aggressive.h"
#include "lin_time.h"
#include "vsfilesystem.h"

Go to the source code of this file.

Functions

bool isMissile (const weapon_info *)
 
void DestroyMount (Mount *mount)
 
bool AdjustMatrix (Matrix &mat, const Vector &velocity, Unit *target, float speed, bool lead, float cone)
 
void AdjustMatrixToTrackTarget (Matrix &mat, const Vector &velocity, Unit *target, float speed, bool lead, float cone)
 
void GetMadAt (Unit *un, Unit *parent, int numhits=0)
 

Variables

char SERVER
 
double interpolation_blend_factor
 

Function Documentation

bool AdjustMatrix ( Matrix mat,
const Vector velocity,
Unit target,
float  speed,
bool  lead,
float  cone 
)

Definition at line 214 of file unit_functions_generic.cpp.

References Matrix::getQ(), Matrix::getR(), Matrix::p, Unit::Position(), Unit::PositionITTS(), QVector, R, Vector, and VectorAndPositionToMatrix().

215 {
216  if (target) {
217  QVector pos( mat.p );
218  Vector R( mat.getR() );
219  QVector targpos( lead ? target->PositionITTS( pos, vel, speed, false ) : target->Position() );
220 
221  Vector dir = (targpos-pos).Cast();
222  dir.Normalize();
223  if (dir.Dot( R ) >= cone) {
224  Vector Q( mat.getQ() );
225  Vector P;
226  ScaledCrossProduct( Q, dir, P );
227  ScaledCrossProduct( dir, P, Q );
228  VectorAndPositionToMatrix( mat, P, Q, dir, pos );
229  } else {
230  return false;
231  }
232  return true;
233  }
234  return false;
235 }
void AdjustMatrixToTrackTarget ( Matrix mat,
const Vector velocity,
Unit target,
float  speed,
bool  lead,
float  cone 
)

Definition at line 107 of file mount.cpp.

References AdjustMatrix().

Referenced by Beam::Draw().

108 {
109  AdjustMatrix( mat, velocity, target, speed, lead, cone );
110 }
void DestroyMount ( Mount mount)

Definition at line 44 of file mount.cpp.

References AUDStopPlaying(), Mount::DESTROYED, Mount::sound, Mount::status, and Mount::UnFire().

Referenced by Unit::ClearMounts(), Unit::DamageRandSys(), Unit::Destroy(), and disableSubUnits().

45 {
46  mount->UnFire();
47  AUDStopPlaying( mount->sound );
48  mount->status = Mount::DESTROYED;
49 }
void GetMadAt ( Unit un,
Unit parent,
int  numhits = 0 
)

Definition at line 86 of file comm_ai.cpp.

References Order::Communicate(), CommunicationMessage::fsm, Unit::getAIState(), FSM::GetHitNode(), VegaConfig::getVariable(), i, XMLSupport::parse_int(), CommunicationMessage::SetCurrentState(), and vs_config.

Referenced by AllUnitsCloseAndEngage(), and Mount::PhysicsAlignedFire().

87 {
88  if (numhits == 0) {
89  static int snumhits = XMLSupport::parse_int( vs_config->getVariable( "AI", "ContrabandMadness", "5" ) );
90  numhits = snumhits;
91  }
92  CommunicationMessage hit( un, parent, NULL, 0 );
93  hit.SetCurrentState( hit.fsm->GetHitNode(), NULL, 0 );
94  for (int i = 0; i < numhits; i++)
95  parent->getAIState()->Communicate( hit );
96 }
bool isMissile ( const weapon_info )

Definition at line 306 of file unit_generic.cpp.

References VegaConfig::getVariable(), weapon_info::LIGHTMISSILE, XMLSupport::parse_bool(), weapon_info::PROJECTILE, weapon_info::size, weapon_info::type, and vs_config.

Referenced by Mount::Activate(), Unit::ActivateGuns(), WeaponComparator< FORWARD >::checkmount(), Mount::DeActive(), Mount::Fire(), Unit::Fire(), Unit::LockMissile(), Mount::PhysicsAlignedFire(), and Unit::setAverageGunSpeed().

307 {
308  static bool useProjectile =
309  XMLSupport::parse_bool( vs_config->getVariable( "graphics", "hud", "projectile_means_missile", "false" ) );
310  if (useProjectile && weap->type == weapon_info::PROJECTILE)
311  return true;
312  if (useProjectile == false && weap->size >= weapon_info::LIGHTMISSILE)
313  return true;
314  return false;
315 }

Variable Documentation

double interpolation_blend_factor

Definition at line 20 of file unit_functions_generic.cpp.

char SERVER

Definition at line 43 of file accountserver.cpp.