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
unit_jump.h File Reference
#include "unit.h"
#include "audiolib.h"
#include "star_system_generic.h"
#include "cmd/images.h"

Go to the source code of this file.

Functions

bool CompareDest (Unit *un, StarSystem *origin)
 
std::vector< Unit * > ComparePrimaries (Unit *primary, StarSystem *origin)
 
void DealPossibleJumpDamage (Unit *un)
 
void ActivateAnimation (Unit *)
 
void WarpPursuit (Unit *un, StarSystem *sourcess, std::string destination)
 

Variables

Hashtable< std::string,
StarSystem, 127 > 
star_system_table
 
std::vector< unorigdest * > pendingjump
 

Function Documentation

void ActivateAnimation ( Unit )

Definition at line 893 of file star_system_generic.cpp.

References ActivateAnimation(), Unit::graphic_options::Animating, Unit::getSubUnits(), Unit::graphicOptions, and i.

894 {
895  jumppoint->graphicOptions.Animating = 1;
896  Unit *un;
897  for (un_iter i = jumppoint->getSubUnits(); NULL != (un = *i); ++i)
898  ActivateAnimation( un );
899 }
bool CompareDest ( Unit un,
StarSystem origin 
)
inline

Definition at line 13 of file unit_jump.h.

References Unit::GetDestinations(), StarSystem::getFileName(), and i.

Referenced by ComparePrimaries().

14 {
15  for (unsigned int i = 0; i < un->GetDestinations().size(); i++)
16  if ( std::string( origin->getFileName() ) == std::string( un->GetDestinations()[i] ) )
17  return true;
18  return false;
19 }
std::vector< Unit* > ComparePrimaries ( Unit primary,
StarSystem origin 
)
inline

Definition at line 21 of file unit_jump.h.

References CompareDest().

Referenced by GameUnit< UnitType >::TransferUnitToSystem().

22 {
23  std::vector< Unit* >myvec;
24  if ( CompareDest( primary, origin ) )
25  myvec.push_back( primary );
26  return myvec;
27 }
void DealPossibleJumpDamage ( Unit un)

Definition at line 297 of file unit_functions_generic.cpp.

References Unit::ApplyDamage(), Unit::UnitJump::damage, float, Unit::GetJumpStatus(), VegaConfig::getVariable(), Unit::GetVelocity(), XMLSupport::parse_float(), Unit::Position(), speed, and vs_config.

Referenced by GameUnit< UnitType >::TransferUnitToSystem().

298 {
299  float speed = un->GetVelocity().Magnitude();
300  float damage = un->GetJumpStatus().damage+(rand()%100 < 1) ? (rand()%20) : 0;
301  static float muld = XMLSupport::parse_float( vs_config->getVariable( "physics", "jump_damage_multiplier", ".1" ) );
302  static float maxd = XMLSupport::parse_float( vs_config->getVariable( "physics", "max_jump_damage", "100" ) );
303  float dam = speed*(damage*muld);
304  if (dam > maxd) dam = maxd;
305  if (dam > 1) {
306  un->ApplyDamage( ( un->Position()+un->GetVelocity().Cast() ).Cast(),
307  un->GetVelocity(),
308  dam,
309  un,
310  GFXColor( ( (float) (rand()%100) )/100,
311  ( (float) (rand()%100) )/100,
312  ( (float) (rand()%100) )/100 ), NULL );
313  un->SetCurPosition( un->LocalPosition()+( ( (float) rand() )/RAND_MAX )*dam*un->GetVelocity().Cast() );
314  }
315 }
void WarpPursuit ( Unit un,
StarSystem sourcess,
std::string  destination 
)

Definition at line 5260 of file unit_generic.cpp.

References Unit::UnitJump::delay, float_to_int(), StarSystem::getFileName(), VegaConfig::getVariable(), Unit::jump, StarSystem::JumpTo(), Magnitude(), XMLSupport::parse_bool(), XMLSupport::parse_float(), SystemLocation(), and vs_config.

Referenced by Unit::Target(), and GameUnit< UnitType >::TransferUnitToSystem().

5261 {
5262  static bool AINotUseJump = XMLSupport::parse_bool( vs_config->getVariable( "physics", "no_ai_jump_points", "false" ) );
5263  if (AINotUseJump) {
5264  static float seconds_per_parsec =
5265  XMLSupport::parse_float( vs_config->getVariable( "physics", "seconds_per_parsec", "10" ) );
5266  float ttime =
5267  ( SystemLocation( sourcess->getFileName() )-SystemLocation( destination ) ).Magnitude()*seconds_per_parsec;
5268  un->jump.delay += float_to_int( ttime );
5269  sourcess->JumpTo( un, NULL, destination, true, true );
5270  un->jump.delay -= float_to_int( ttime );
5271  }
5272 }

Variable Documentation

Hashtable< std::string, StarSystem, 127 > star_system_table

Definition at line 773 of file star_system_generic.cpp.