ScummVM API documentation
ai_targetacquisition.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef SCUMM_HE_MOONBASE_AI_TARGETACQUISITION_H
23 #define SCUMM_HE_MOONBASE_AI_TARGETACQUISITION_H
24 
25 #include "scumm/he/moonbase/ai_defenseunit.h"
26 #include "scumm/he/moonbase/ai_node.h"
27 #include "scumm/he/moonbase/ai_tree.h"
28 
29 namespace Scumm {
30 
31 const int NUM_IMPT_UNITS = 3;
32 const int NUM_SHOT_POSITIONS = 1;
33 const int NUM_WEAPONS = 3;
34 
35 class Sortie : public IContainedObject {
36 private:
37  static int _sSourceX;
38  static int _sSourceY;
39 
40  static int _sTargetX;
41  static int _sTargetY;
42 
43  int _unitType;
44  int _shotPosX, _shotPosY;
45  Common::Array<DefenseUnit *> _enemyDefenses;
46  AI *_ai;
47 
48 public:
49  Sortie(AI *ai) { _ai = ai; _unitType = 0; _shotPosX = _shotPosY = 0; }
50  ~Sortie() override;
51 
52  static void setSourcePos(int x, int y) {
53  _sSourceX = x;
54  _sSourceY = y;
55  }
56  static void setTargetPos(int x, int y) {
57  _sTargetX = x;
58  _sTargetY = y;
59  }
60 
61  void setUnitType(int unitType) { _unitType = unitType; }
62 
63  void setShotPosX(int shotPosX) { _shotPosX = shotPosX; }
64  void setShotPosY(int shotPosY) { _shotPosY = shotPosY; }
65  void setShotPos(int shotPosX, int shotPosY) {
66  _shotPosX = shotPosX;
67  _shotPosY = shotPosY;
68  }
69 
70  void setEnemyDefenses(Common::Array<DefenseUnit *> enemyDefenses) {
71  _enemyDefenses = enemyDefenses;
72  }
73  void setEnemyDefenses(int enemyDefensesScummArray, int defendX, int defendY);
74 
75  void printEnemyDefenses();
76 
77  static int getSourcePosX() { return _sSourceX; }
78  static int getSourcePosY() { return _sSourceY; }
79  static int getTargetPosX() { return _sTargetX; }
80  static int getTargetPosY() { return _sTargetY; }
81 
82  int getUnitType() const { return _unitType; }
83 
84  int getShotPosX() const { return _shotPosX; }
85  int getShotPosY() const { return _shotPosY; }
86  int *getShotPos() const;
87 
88  Common::Array<DefenseUnit *> getEnemyDefenses() const { return _enemyDefenses; }
89 
90  IContainedObject *duplicate() override;
91 
92  int numChildrenToGen() override;
93  IContainedObject *createChildObj(int, int &completionFlag) override;
94 
95 
96  float calcH() override;
97  int checkSuccess() override;
98  float calcT() override;
99 };
100 
101 class Defender {
102 private:
103  int _sourceX;
104  int _sourceY;
105  int _targetX;
106  int _targetY;
107  int _sourceUnit;
108  int _power;
109  int _angle;
110  int _unit;
111  AI *_ai;
112 
113 public:
114  Defender(AI *ai);
115  void setSourceX(int sourceX) { _sourceX = sourceX; }
116  void setSourceY(int sourceY) { _sourceY = sourceY; }
117  void setTargetX(int targetX) { _targetX = targetX; }
118  void setTargetY(int targetY) { _targetY = targetY; }
119  void setSourceUnit(int sourceUnit) { _sourceUnit = sourceUnit; }
120  void setPower(int power) { _power = power; }
121  void setAngle(int angle) { _angle = angle; }
122  void setUnit(int unit) { _unit = unit; }
123 
124  int getSourceX() const { return _sourceX; }
125  int getSourceY() const { return _sourceY; }
126  int getTargetX() const { return _targetX; }
127  int getTargetY() const { return _targetY; }
128  int getSourceUnit() const { return _sourceUnit; }
129  int getPower() const { return _power; }
130  int getAngle() const { return _angle; }
131  int getUnit() const { return _unit; }
132 
133  int calculateDefenseUnitPosition(int targetX, int targetY, int index);
134 };
135 
137 public:
138  bool operator()(DefenseUnit *x, DefenseUnit *y) {
139  //disabled units go at the end
140  if (x->getState() == DUS_OFF) {
141  debugC(DEBUG_MOONBASE_AI, "OFF");
142  return 0;
143  }
144 
145  return x->getDistanceTo() < y->getDistanceTo();
146  }
147 };
148 
149 } // End of namespace Scumm
150 
151 #endif
Definition: ai_targetacquisition.h:136
Definition: ai_targetacquisition.h:101
Definition: array.h:52
Definition: ai_main.h:85
Definition: ai_targetacquisition.h:35
Definition: ai_defenseunit.h:47
void void void void void debugC(int level, uint32 debugChannels, MSVC_PRINTF const char *s,...) GCC_PRINTF(3
Definition: ai_node.h:32
Definition: actor.h:30