1 /***************************************************************************** 2 * $LastChangedDate: 2011-04-09 21:58:06 -0400 (Sat, 09 Apr 2011) $ 3 * @file 4 * @author Jim E. Brooks http://www.palomino3d.org 5 * @brief Missiles. 6 *//* 7 * LEGAL: COPYRIGHT (C) 2008 JIM E. BROOKS 8 * THIS SOURCE CODE IS RELEASED UNDER THE TERMS 9 * OF THE GNU GENERAL PUBLIC LICENSE VERSION 2 (GPL 2). 10 *****************************************************************************/ 11 12 #ifndef GAME_MISSILE_HH 13 #define GAME_MISSILE_HH 1 14 15 #include "game/projectile.hh" 16 17 namespace game { 18 19 //////////////////////////////////////////////////////////////////////////////// 20 /// @brief Missiles. 21 /// 22 /// Lua: 23 /// ---- 24 /// (See also projectile.hh). 25 /// Lua determines which Actor is the target. 26 /// Lua interfaces with this C++ class in terms of the Dyna class. 27 /// 28 /// C++: 29 /// ---- 30 /// (See also projectile.hh). 31 /// Every tick, Guide() rotates the Dyna's matrix 32 /// to guide the missile towards the target. 33 /// If the target is hit, movement stops. 34 /// If the target is destroyed by another action, 35 /// missile will fly straight until it flies past max distance. 36 /// 37 class Missile : public Projectile 38 { 39 PREVENT_COPYING(Missile) 40 public: 41 Missile( shptr<Object> target, 42 Object& launcher, 43 const Speed launcherSpeed, 44 const Meter particleRadiusGeo, 45 const bool malfunction ); 46 virtual ~Missile(); GetName(void)47 virtual const string GetName( void ) { return string("Missile"); } 48 49 private: 50 shptr<Graph> MakeGraph( void ); 51 CLASS_METHOD Speed ComputeInitialSpeed( const Speed launcherSpeed ); 52 virtual WorldVertex Guide( const fp step1 ); 53 virtual void Explode( void ); 54 void Maneuver( Matrix& matrix, /*IN/OUT*/ 55 const uint rotationAxis, 56 const uint nextRotationAxis, 57 Radian maneuverAngle, 58 const WorldVertex targetPos ); 59 60 private: 61 shptr<Object> mTarget; ///< what missile is guided towards 62 uint mRotationAxis; ///< AXIS_ROLL or AXIS_PITCH 63 Radian mManeuverAngleRoll; 64 Radian mManeuverAnglePitch; 65 fp mPredictedManeuverAngleSign; ///< try rotating in same direction as previously 66 const fp mHitDistance; ///< scalar in world space 67 const bool mMalfunction; ///< missiles don't always work 68 public: 69 DECLARE_TYPESIG(TYPESIG_MISSILE) 70 }; 71 72 } // namespace game 73 74 #endif // GAME_MISSILE_HH 75