RPG Class Reference

#include <auto_bazooka.h>

Inheritance diagram for RPG:

Inheritance graph
[legend]
Collaboration diagram for RPG:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 RPG (AutomaticBazookaConfig &cfg, WeaponLauncher *p_launcher)
void Refresh ()
void Shoot (double strength)
void SetTarget (int x, int y)

Protected Member Functions

void SignalOutOfMap ()
void SignalDrowning ()

Protected Attributes

double angle_local
Point2i m_target
bool m_targeted
double m_force
uint m_lastrefresh

Private Attributes

ParticleEngine smoke_engine

Detailed Description

Definition at line 33 of file auto_bazooka.h.


Constructor & Destructor Documentation

RPG::RPG ( AutomaticBazookaConfig cfg,
WeaponLauncher p_launcher 
)

Definition at line 50 of file auto_bazooka.cpp.

00051                                                                       :
00052   WeaponProjectile("rocket", cfg, p_launcher), smoke_engine(20), m_lastrefresh(0)
00053 {
00054   m_targeted = false;
00055   explode_colliding_character = true;
00056 }


Member Function Documentation

void RPG::Refresh (  )  [virtual]

Reimplemented from WeaponProjectile.

Definition at line 64 of file auto_bazooka.cpp.

00065 {
00066   AutomaticBazookaConfig &acfg = dynamic_cast<AutomaticBazookaConfig &>(cfg);
00067   uint time = Time::GetInstance()->Read();
00068   float flying_time = time - begin_time;
00069   uint timestep = time - m_lastrefresh;
00070   m_lastrefresh = time;
00071   if (!m_targeted)
00072   {
00073     // rocket is turning around herself
00074     angle_local += acfg.uncontrolled_turn_speed * timestep / 1000.;
00075     if(angle_local > M_PI) angle_local = -M_PI;
00076 
00077     // TPS_AV_ATTIRANCE msec later being launched, the rocket is homing to the target
00078     if(flying_time>1000 * GetTotalTimeout())
00079     {
00080       m_targeted = true;
00081       SetSpeed(0,0);
00082       angle_local = GetPosition().ComputeAngle( m_target );
00083       m_force = acfg.rocket_force;
00084       SetExternForce(m_force, angle_local);
00085       SetGravityFactor(0);
00086       SetWindFactor(0);
00087     }
00088   }
00089   else
00090   {
00091     SetExternForce(m_force, angle_local+M_PI_2); // reverse the force applyed on the last Refresh()
00092 
00093     if(flying_time - GetTotalTimeout() < acfg.fuel_time*1000.) {
00094       smoke_engine.AddPeriodic(Point2i(GetX() + GetWidth() / 2,
00095                                        GetY() + GetHeight()/ 2), particle_DARK_SMOKE, false, -1, 2.0);
00096       double wish_angle = GetPosition().ComputeAngle( m_target );
00097       double max_rotation = fabs(acfg.max_controlled_turn_speed * timestep / 1000.);
00098       double diff = fmod(wish_angle-angle_local, M_PI*2);
00099       if(diff < -M_PI) diff += M_PI*2;
00100       if(diff > M_PI) diff -= M_PI*2;
00101       //diff should now be between -M_PI and M_PI...
00102       if(diff > max_rotation) {
00103         angle_local += max_rotation;
00104       } else if (diff < -max_rotation) {
00105         angle_local -= max_rotation;
00106       } else {
00107         angle_local = wish_angle;
00108       }
00109       m_force = acfg.rocket_force * ((acfg.fuel_time*1300. - flying_time + GetTotalTimeout())/acfg.fuel_time/1300.);
00110       SetGravityFactor((flying_time - GetTotalTimeout())/acfg.fuel_time/1000.); // slowly increase gravity
00111       SetWindFactor((flying_time - GetTotalTimeout())/acfg.fuel_time/1000.); // slowly increase wind
00112     } else {
00113       SetGravityFactor(1);
00114       m_force = 0; //if there's no fuel left just let it crash into the ground somewhere
00115       if(!IsDrowned()) {
00116         angle_local += acfg.uncontrolled_turn_speed * timestep / 1000.;
00117         if(angle_local > M_PI) angle_local = - M_PI;
00118       } else {
00119         angle_local = M_PI_2;
00120       }
00121     }
00122 
00123     SetExternForce(m_force, angle_local);
00124 
00125   }
00126   image->SetRotation_rad(angle_local);
00127 }

Here is the call graph for this function:

void RPG::SetTarget ( int  x,
int  y 
)

Definition at line 142 of file auto_bazooka.cpp.

00143 {
00144   m_target.x = x;
00145   m_target.y = y;
00146 }

void RPG::Shoot ( double  strength  )  [virtual]

Reimplemented from WeaponProjectile.

Definition at line 58 of file auto_bazooka.cpp.

00059 {
00060   WeaponProjectile::Shoot(strength);
00061   angle_local=ActiveCharacter().GetFiringAngle();
00062 }

Here is the call graph for this function:

void RPG::SignalDrowning (  )  [protected, virtual]

Reimplemented from WeaponProjectile.

Definition at line 129 of file auto_bazooka.cpp.

00130 {
00131   smoke_engine.Stop();
00132   WeaponProjectile::SignalDrowning();
00133 }

Here is the call graph for this function:

void RPG::SignalOutOfMap (  )  [protected, virtual]

Reimplemented from WeaponProjectile.

Definition at line 135 of file auto_bazooka.cpp.

00136 {
00137   GameMessages::GetInstance()->Add (_("The automatic rocket has left the battlefield..."));
00138   WeaponProjectile::SignalOutOfMap();
00139 }

Here is the call graph for this function:


Member Data Documentation

double RPG::angle_local [protected]

Definition at line 37 of file auto_bazooka.h.

double RPG::m_force [protected]

Definition at line 40 of file auto_bazooka.h.

uint RPG::m_lastrefresh [protected]

Definition at line 41 of file auto_bazooka.h.

Point2i RPG::m_target [protected]

Definition at line 38 of file auto_bazooka.h.

bool RPG::m_targeted [protected]

Definition at line 39 of file auto_bazooka.h.

ParticleEngine RPG::smoke_engine [private]

Definition at line 35 of file auto_bazooka.h.


The documentation for this class was generated from the following files:
Generated on Mon Jan 1 14:14:58 2007 for Wormux by  doxygen 1.4.7