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_damage.h File Reference
#include <string>
#include <vector>
#include "unit.h"
#include "unit_factory.h"
#include "ai/order.h"
#include "gfx/animation.h"
#include "gfx/mesh.h"
#include "gfx/halo.h"
#include "vegastrike.h"
#include "unit_collide.h"
#include <float.h>
#include "audiolib.h"
#include "images.h"
#include "beam.h"
#include "config_xml.h"
#include "vs_globals.h"
#include "xml_support.h"
#include "savegame.h"
#include "gfx/cockpit.h"
#include "cmd/script/mission.h"
#include "missile.h"
#include "cmd/ai/communication.h"
#include "cmd/script/flightgroup.h"
#include "music.h"
#include "faction_generic.h"
#include "universe_util.h"
#include "csv.h"
#include "unit_csv.h"
#include "base.h"

Go to the source code of this file.

Functions

unsigned int apply_float_to_unsigned_int (float tmp)
 
vector< Mesh * > MakeMesh (unsigned int mysize)
 
float rand01 ()
 
AnimationGetVolatileAni (unsigned int)
 
unsigned int AddAnimation (const QVector &, const float, bool, const string &, float percentgrow)
 
AnimationgetRandomCachedAni ()
 
string getRandomCachedAniString ()
 
void disableSubUnits (Unit *un)
 

Function Documentation

unsigned int AddAnimation ( const QVector ,
const float  ,
bool  ,
const string &  ,
float  percentgrow 
)
unsigned int apply_float_to_unsigned_int ( float  tmp)

Definition at line 649 of file unit_generic.cpp.

Referenced by Unit::DealDamageToHullReturnArmor().

650 {
651  static unsigned long int seed = 2531011;
652  seed += 214013;
653  seed %= 4294967295u;
654  unsigned int ans = (unsigned int) tmp;
655  tmp -= ans; //now we have decimal;
656  if ( seed < (unsigned long int) (4294967295u*tmp) )
657  ans += 1;
658  return ans;
659 }
void disableSubUnits ( Unit un)

Definition at line 1824 of file unit_generic.cpp.

References DestroyMount(), disableSubUnits(), Unit::getSubUnits(), j, and Unit::mounts.

Referenced by disableSubUnits(), and GameUnit< UnitType >::Explode().

1825 {
1826  Unit *un;
1827  for (un_iter i = uhn->getSubUnits(); (un = *i) != NULL; ++i)
1828  disableSubUnits( un );
1829  for (unsigned int j = 0; j < uhn->mounts.size(); ++j)
1830  DestroyMount( &uhn->mounts[j] );
1831 }
Animation* getRandomCachedAni ( )

Definition at line 71 of file unit_functions.cpp.

References cached_ani, i, and j.

72 {
73  if ( cached_ani.size() ) {
74  unsigned int rn = rand()%cached_ani.size();
75  vsUMap< std::string, Animation* >::iterator j = cached_ani.begin();
76  for (unsigned int i = 0; i < rn; i++)
77  j++;
78  return (*j).second;
79  } else {
80  return NULL;
81  }
82 }
string getRandomCachedAniString ( )

Definition at line 59 of file unit_functions.cpp.

References cached_ani, i, and j.

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

60 {
61  if ( cached_ani.size() ) {
62  unsigned int rn = rand()%cached_ani.size();
63  vsUMap< std::string, Animation* >::iterator j = cached_ani.begin();
64  for (unsigned int i = 0; i < rn; i++)
65  j++;
66  return (*j).first;
67  } else {
68  return "";
69  }
70 }
Animation* GetVolatileAni ( unsigned  int)

Definition at line 45 of file star_system_jump.cpp.

References a, and VolatileJumpAnimations.

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

46 {
47  if ( which < VolatileJumpAnimations.size() )
48  return VolatileJumpAnimations[which].a;
49  return NULL;
50 }
vector< Mesh* > MakeMesh ( unsigned int  mysize)

Definition at line 445 of file unit_xml.cpp.

References i.

446 {
447  std::vector< Mesh* >temp;
448  for (unsigned int i = 0; i < mysize; i++)
449  temp.push_back( NULL );
450  return temp;
451 }
float rand01 ( )

Definition at line 641 of file unit_generic.cpp.

Referenced by Unit::DamageRandSys(), Unit::DealDamageToHullReturnArmor(), DestroyPlayerSystem(), DestroySystem(), GameCockpit::Draw(), and GameUniverse::StartDraw().

642 {
643  return (float) rand()/(float) RAND_MAX;
644 }