Starshatter_Open
Open source Starshatter engine
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Shot.h
Go to the documentation of this file.
1 /* Project Starshatter 4.5
2  Destroyer Studios LLC
3  Copyright © 1997-2004. All Rights Reserved.
4 
5  SUBSYSTEM: Stars.exe
6  FILE: Shot.h
7  AUTHOR: John DiCamillo
8 
9 
10  OVERVIEW
11  ========
12  Laser and Missile class
13 */
14 
15 #ifndef Shot_h
16 #define Shot_h
17 
18 #include "Types.h"
19 #include "Geometry.h"
20 #include "SimObject.h"
21 #include "Color.h"
22 
23 // +--------------------------------------------------------------------+
24 
25 class Camera;
26 class Ship;
27 class Trail;
28 class System;
29 class WeaponDesign;
30 class Sprite;
31 class Sound;
32 
33 // +--------------------------------------------------------------------+
34 
35 class Shot : public SimObject,
36 public SimObserver
37 {
38 public:
39  static const char* TYPENAME() { return "Shot"; }
40 
41  Shot(const Point& pos, const Camera& cam, WeaponDesign* design, const Ship* ship=0);
42  virtual ~Shot();
43 
44  virtual void SeekTarget(SimObject* target, System* sub=0);
45  virtual void ExecFrame(double factor);
46  static void Initialize();
47  static void Close();
48 
49  virtual void Activate(Scene& scene);
50  virtual void Deactivate(Scene& scene);
51 
52  const Ship* Owner() const { return owner; }
53  double Damage() const;
54  int ShotType() const { return type; }
55  virtual SimObject* GetTarget() const;
56 
57  virtual bool IsPrimary() const { return primary; }
58  virtual bool IsDrone() const { return false; }
59  virtual bool IsDecoy() const { return false; }
60  virtual bool IsProbe() const { return false; }
61  virtual bool IsMissile() const { return !primary; }
62  virtual bool IsArmed() const { return armed; }
63  virtual bool IsBeam() const { return beam; }
64  virtual bool IsFlak() const;
65  virtual bool IsHostileTo(const SimObject* o) const;
66 
67  bool HitTarget() const { return hit_target; }
68  void SetHitTarget(bool h) { hit_target = h; }
69 
70  virtual bool IsTracking(Ship* tgt) const;
71  virtual double PCS() const { return 0; }
72  virtual double ACS() const { return 0; }
73  virtual int GetIFF() const;
74  virtual Color MarkerColor() const;
75 
76  const Point& Origin() const { return origin; }
77  float Charge() const { return charge; }
78  void SetCharge(float c);
79  double Length() const;
80  Graphic* GetTrail() const { return (Graphic*) trail; }
81  void SetFuse(double seconds);
82 
83  void SetBeamPoints(const Point& from, const Point& to);
84  virtual void Disarm();
85  virtual void Destroy();
86 
87  const WeaponDesign* Design() const { return design; }
88  const char* DesignName() const;
89  int GetEta() const { return eta; }
90  void SetEta(int t) { eta = t; }
91 
92  double AltitudeMSL() const;
93  double AltitudeAGL() const;
94 
95  // SimObserver interface:
96  virtual bool Update(SimObject* obj);
97  virtual const char* GetObserverName() const;
98 
99  int operator == (const Shot& s) const { return id == s.id; }
100 
101 protected:
102  const Ship* owner;
103 
104  int type;
105  float base_damage;
106  float charge;
107  float offset;
109  short eta;
110  BYTE iff_code;
112  bool primary;
113  bool beam;
114  bool armed;
116 
117  Sprite* flash; // muzzle flash
118  Sprite* flare; // drive flare
119  Trail* trail; // exhaust trail
120 
123 
124  // for beam weapons:
126 };
127 
128 #endif Shot_h
129