The GunClass

Superclasses

VuEntity

FalconEntity

Other Subclasses: CampBaseClass , SimBaseClass,TeamClass

SimBaseClass

Other Subclasses:   SimStaticClass

SimMoverClass

Other Subclasses :, SimVehicleClass, EjectedPilotClass

SimWeaponClass

Subclasses: BombClass,MissileClass,

GunClass


#ifdef USE_SH_POOLS
   public:
      // Overload new/delete to use a SmartHeap fixed size pool
      void *operator new(size_t size) { ShiAssert( size == sizeof(GunClass) ); return MemAllocFS(pool); };
      void operator delete(void *mem) { if (mem) MemFreeFS(mem); };
      static void InitializeStorage()   { pool = MemPoolInitFS( sizeof(GunClass), 200, 0 ); };
      static void ReleaseStorage()      { MemPoolFree( pool ); };
      static MEM_POOL   pool;
#endif

   private:
      float xPos, yPos, zPos;
      float pitch, yaw;
      float dragFactor;
      int fireCount,bursts;
      int initialRounds;
          float fractionalRoundsRemaining;      // Could make numRoundsRemaining a float, but this changed less code...
      DrawableTracer** tracers;
      Drawable2D** bullets;
      DrawableTrail* smokeTrail;
         TracerCollisionMode tracerMode;

          // these variables are used to do the series of muzzle tracers
      DrawableTracer **firstTracer;
         Tpoint *muzzleLoc;
         Tpoint *muzzleEnd;
          float *muzzleAlpha;
          float *muzzleWidth;

      int* trailState;
          int muzzleStart;
          float qTimer;
      void UpdateTracers( int firing );
 

   public:
      void InitTracers(void);
      void CleanupTracers(void);
      GunClass(int type);
      virtual ~GunClass(void);
      enum GunStatus {Ready, Sim, Safe};
      float initBulletVelocity;
      GunStatus status;
      GunTracerType *bullet;
      float roundsPerSecond;
      int numRoundsRemaining;
      int numTracers;
      int numFirstTracers;
      int unlimitedAmmo;
      int numFlying;

      void Init (float muzzleVel, int numRounds);
      void SetPosition (float xOffset, float yOffset, float zOffset, float pitch, float yaw);
      int Exec (int* fire, TransformMatrix dmx, ObjectGeometry *geomData, SimObjectType* objList, BOOL isOwnship );

          void NewBurst (void) { bursts++; };
          int GetCurrentBurst (void) { return bursts; };

      void SetTracerCollisionMode( TracerCollisionMode mode )
      {
        tracerMode = mode;
      };

      // new stuff for to support shells

      // typpedefs and enums
      enum GunType
      {
         GUN_SHELL,
         GUN_TRACER,
         GUN_TRACER_BALL
      };

      virtual int IsGun (void) { return TRUE; };

      // member functions
      BOOL              IsShell( void );
      BOOL              IsTracer( void );
      BOOL              ReadyToFire( void );
      float             GetDamageAssessment( SimBaseClass *target, float range );
      void              FireShell( SimObjectType *target );
      void              UpdateShell( void );
      WeaponDomain GetSMSDomain( void );

      // member variables
      WeaponDomain                              gunDomain;                              // air, land, both
      SimObjectType                     *shellTargetPtr;                // set when shell flying
      GunType                                   typeOfGun;                              // tracer or shell
      VU_TIME                                   shellDetonateTime;              // when it goes cablooey
      float                                             minShellRange;                  // minimum for shell
      float                                             maxShellRange;                  // max for shell
      WeaponClassDataType               *wcPtr;                                 // pointer to weapon class data