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
missile.h
Go to the documentation of this file.
1 #ifndef MISSILE_H_
2 #define MISSILE_H_
3 
4 #include "missile_generic.h"
5 #include "cmd/unit_util.h"
6 
7 class GameMissile : public GameUnit< Missile >
8 {
9 protected:
11  GameMissile( const char *filename,
12  int faction,
13  const string &modifications,
14  const float damage,
15  float phasedamage,
16  float time,
17  float radialeffect,
18  float radmult,
19  float detonation_radius ) :
20  GameUnit< Missile > ( filename, false, faction, modifications )
21  {
22  this->InitMissile( time, damage, phasedamage, radialeffect, radmult, detonation_radius, false, -1 );
23  static bool missilesparkle = XMLSupport::parse_bool( vs_config->getVariable( "graphics", "missilesparkle", "false" ) );
24  if (missilesparkle)
25  maxhull *= 4;
26  }
27 
28  friend class UnitFactory;
29 
30 public:
31  virtual void Kill( bool erase = true )
32  {
35  }
36  virtual void reactToCollision( Unit *smaller,
37  const QVector &biglocation,
38  const Vector &bignormal,
39  const QVector &smalllocation,
40  const Vector &smallnormal,
41  float dist )
42  {
43  static bool doesmissilebounce = XMLSupport::parse_bool( vs_config->getVariable( "physics", "missile_bounce", "false" ) );
44  if (doesmissilebounce)
45  GameUnit< Missile >::reactToCollision( smaller, biglocation, bignormal, smalllocation, smallnormal, dist );
46  Discharge();
47  if (!killed)
48  DealDamageToHull( smalllocation.Cast(), hull+1 ); //should kill, applying addmissile effect
49  }
50  virtual void UpdatePhysics2( const Transformation &trans,
51  const Transformation &old_physical_state,
52  const Vector &accel,
53  float difficulty,
54  const Matrix &transmat,
55  const Vector &CumulativeVelocity,
56  bool ResolveLast,
57  UnitCollection *uc = NULL )
58  {
59  Unit *targ;
60  if ( ( targ = ( Unit::Target() ) ) )
61  if (rand()/( (float) RAND_MAX ) < ( (float) UnitUtil::getECM(targ) )*SIMULATION_ATOM/32768)
62  Target( NULL );
63  //go wild
64  if (retarget == -1) {
65  if (targ)
66  retarget = 1;
67  else
68  retarget = 0;
69  }
70  if (retarget && targ == NULL)
71  Target( NULL );
73  old_physical_state,
74  accel,
75  difficulty,
76  transmat,
77  CumulativeVelocity,
78  ResolveLast,
79  uc );
80  this->time -= SIMULATION_ATOM;
81  if (NULL != targ) {
82  float checker = targ->querySphere( Position()-( SIMULATION_ATOM*GetVelocity() ), Position(), rSize() );
83  if ( (checker
84  && detonation_radius >= 0)
85  || ( ( Position()-targ->Position() ).Magnitude()-targ->rSize()-rSize() < detonation_radius ) ) {
86  Discharge();
87  time = -1;
88  //}
89  }
90  }
91  if (time < 0)
92  DealDamageToHull( Vector( .1, .1, .1 ), hull+1 );
93  }
94 
95 private:
97  GameMissile();
99  GameMissile( const Missile& );
101  GameMissile& operator=( const Missile& );
102 };
103 
104 #endif
105