Starshatter_Open
Open source Starshatter engine
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
CombatAction.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: CombatAction.h
7  AUTHOR: John DiCamillo
8 
9 
10  OVERVIEW
11  ========
12  A planned action (mission/story/strategy) in a dynamic campaign.
13 */
14 
15 #ifndef CombatAction_h
16 #define CombatAction_h
17 
18 #include "Types.h"
19 #include "Geometry.h"
20 #include "Text.h"
21 #include "List.h"
22 
23 // +--------------------------------------------------------------------+
24 
25 class Combatant;
26 class CombatAction;
27 class CombatActionReq;
28 
29 // +--------------------------------------------------------------------+
30 
32 {
33 public:
34  static const char* TYPENAME() { return "CombatAction"; }
35 
36  enum TYPE
37  {
47  };
48 
49  enum STATUS
50  {
56  };
57 
58  CombatAction(int id, int type, int subtype, int team);
59  ~CombatAction();
60 
61  int operator == (const CombatAction& a) const { return id == a.id; }
62 
63  bool IsAvailable() const;
64  void FireAction();
65  void FailAction();
66  void AddRequirement(int action, int stat, bool not = false);
67  void AddRequirement(Combatant* c1, Combatant* c2, int comp, int score);
68  void AddRequirement(Combatant* c1, int group_type, int group_id, int comp, int score, int intel=0);
69  static int TypeFromName(const char* n);
70  static int StatusFromName(const char* n);
71 
72  // accessors/mutators:
73  int Identity() const { return id; }
74  int Type() const { return type; }
75  int Subtype() const { return subtype; }
76  int OpposingType() const { return opp_type; }
77  int GetIFF() const { return team; }
78  int Status() const { return status; }
79  int Source() const { return source; }
80  Point Location() const { return loc; }
81  const char* System() const { return system; }
82  const char* Region() const { return region; }
83  const char* Filename() const { return text_file; }
84  const char* ImageFile() const { return image_file; }
85  const char* SceneFile() const { return scene_file; }
86  int Count() const { return count; }
87  int ExecTime() const { return time; }
88  int StartBefore() const { return start_before; }
89  int StartAfter() const { return start_after; }
90  int MinRank() const { return min_rank; }
91  int MaxRank() const { return max_rank; }
92  int Delay() const { return delay; }
93  int Probability() const { return probability; }
94  int AssetType() const { return asset_type; }
95  int AssetId() const { return asset_id; }
96  List<Text>& AssetKills() { return asset_kills; }
97  int TargetType() const { return target_type; }
98  int TargetId() const { return target_id; }
99  int TargetIFF() const { return target_iff; }
100  List<Text>& TargetKills() { return target_kills; }
101  const char* GetText() const { return text; }
102 
103  void SetType(int t) { type = (char) t; }
104  void SetSubtype(int s) { subtype = (char) s; }
105  void SetOpposingType(int t){ opp_type = (char) t; }
106  void SetIFF(int t) { team = (char) t; }
107  void SetStatus(int s) { status = (char) s; }
108  void SetSource(int s) { source = s; }
109  void SetLocation(const Point& p) { loc = p; }
110  void SetSystem(Text sys) { system = sys; }
111  void SetRegion(Text rgn) { region = rgn; }
112  void SetFilename(Text f) { text_file = f; }
113  void SetImageFile(Text f) { image_file = f; }
114  void SetSceneFile(Text f) { scene_file = f; }
115  void SetCount(int n) { count = (char) n; }
116  void SetExecTime(int t) { time = t; }
117  void SetStartBefore(int s) { start_before = s; }
118  void SetStartAfter(int s) { start_after = s; }
119  void SetMinRank(int n) { min_rank = (char) n; }
120  void SetMaxRank(int n) { max_rank = (char) n; }
121  void SetDelay(int d) { delay = d; }
122  void SetProbability(int n) { probability = n; }
123  void SetAssetType(int t) { asset_type = t; }
124  void SetAssetId(int n) { asset_id = n; }
125  void SetTargetType(int t) { target_type = t; }
126  void SetTargetId(int n) { target_id = n; }
127  void SetTargetIFF(int n) { target_iff = n; }
128  void SetText(Text t) { text = t; }
129 
130 
131 private:
132  int id;
133  char type;
134  char subtype;
135  char opp_type;
136  char team;
137  char status;
138  char min_rank;
139  char max_rank;
140  int source;
141  Point loc;
142  Text system;
143  Text region;
144  Text text_file;
145  Text image_file;
146  Text scene_file;
147  char count;
148  int start_before;
149  int start_after;
150  int delay;
151  int probability;
152  int rval;
153  int time;
154 
155  Text text;
156  int asset_type;
157  int asset_id;
158  List<Text> asset_kills;
159  int target_type;
160  int target_id;
161  int target_iff;
162  List<Text> target_kills;
163 
164  List<CombatActionReq> requirements;
165 };
166 
167 // +--------------------------------------------------------------------+
168 
170 public:
171  static const char* TYPENAME() { return "CombatActionReq"; }
172 
174  LT, LE, GT, GE, EQ, // absolute score comparison
175  RLT, RLE, RGT, RGE, REQ // delta score comparison
176  };
177 
178  CombatActionReq(int a, int s, bool n = false)
179  : action(a), stat(s), not(n), c1(0), c2(0), comp(0), score(0), intel(0) { }
180 
181  CombatActionReq(Combatant* a1, Combatant* a2, int comparison, int value)
182  : action(0), stat(0), not(0), c1(a1), c2(a2), group_type(0), group_id(0),
183  comp(comparison), score(value), intel(0) { }
184 
185  CombatActionReq(Combatant* a1, int gtype, int gid, int comparison, int value, int intel_level=0)
186  : action(0), stat(0), not(0), c1(a1), c2(0), group_type(gtype), group_id(gid),
187  comp(comparison), score(value), intel(intel_level) { }
188 
189  static int CompFromName(const char* sym);
190 
191  int action;
192  int stat;
193  bool not;
194 
197  int comp;
198  int score;
199  int intel;
201  int group_id;
202 };
203 
204 #endif CombatAction_h
205