OpenXcom  1.0
Open-source clone of the original X-Com
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
AlienBAIState.h
1 /*
2  * Copyright 2010-2014 OpenXcom Developers.
3  *
4  * This file is part of OpenXcom.
5  *
6  * OpenXcom is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * OpenXcom is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with OpenXcom. If not, see <http://www.gnu.org/licenses/>.
18  */
19 #ifndef OPENXCOM_ALIENBAISTATE_H
20 #define OPENXCOM_ALIENBAISTATE_H
21 
22 #include "BattleAIState.h"
23 #include "Position.h"
24 #include <vector>
25 
26 namespace OpenXcom
27 {
28 
29 class SavedBattleGame;
30 class BattleUnit;
31 class BattlescapeState;
32 class Node;
33 
38 {
39 protected:
40  BattleUnit *_aggroTarget;
41  int _knownEnemies, _visibleEnemies, _spottingEnemies;
42  int _escapeTUs, _ambushTUs, _reserveTUs;
43  BattleAction *_escapeAction, *_ambushAction, *_attackAction, *_patrolAction, *_psiAction;
44  bool _rifle, _melee, _blaster;
45  bool _traceAI, _wasHit, _didPsi;
46  int _AIMode, _intelligence, _closestDist;
47  Node *_fromNode, *_toNode;
48  std::vector<int> _reachable, _reachableWithAttack;
49 public:
55  void load(const YAML::Node& node);
57  YAML::Node save() const;
59  void enter();
61  void exit();
63  void think(BattleAction *action);
65  void setWasHit();
67  bool getWasHit() const;
69  void setupPatrol();
71  void setupAmbush();
73  void setupAttack();
75  void setupEscape();
77  int countKnownTargets() const;
79  int getSpottingUnits(Position pos) const;
81  int selectNearestTarget();
85  bool selectRandomTarget();
87  bool selectPointNearTarget(BattleUnit *target, int maxTUs) const;
89  void evaluateAIMode();
91  bool findFirePoint();
93  bool explosiveEfficacy(Position targetPos, BattleUnit *attackingUnit, int radius, int diff, bool grenade = false) const;
95  void meleeAction();
97  void wayPointAction();
99  void projectileAction();
101  void selectFireMethod();
103  void grenadeAction();
105  bool psiAction();
107  void meleeAttack();
108  bool validTarget(BattleUnit* unit, bool assessDanger, bool includeCivs) const;
109 };
110 
111 }
112 
113 #endif
Definition: BattlescapeGame.h:45
YAML::Node save() const
Saves the AI state to YAML.
Definition: AlienBAIState.cpp:104
bool selectRandomTarget()
Selects a random known target.
Definition: AlienBAIState.cpp:1086
void meleeAction()
Attempts to take a melee attack/charge an enemy we can see.
Definition: AlienBAIState.cpp:1562
int countKnownTargets() const
count how many xcom/civilian units are known to this unit.
Definition: AlienBAIState.cpp:956
void setupPatrol()
setup a patrol objective.
Definition: AlienBAIState.cpp:413
void setupAttack()
setup a combat objective.
Definition: AlienBAIState.cpp:682
void wayPointAction()
Attempts to fire a waypoint projectile at an enemy we, or one of our teammates sees.
Definition: AlienBAIState.cpp:1611
int getSpottingUnits(Position pos) const
count how many known XCom units are able to see this unit.
Definition: AlienBAIState.cpp:974
This class is used by the BattleUnit AI.
Definition: BattleAIState.h:35
bool psiAction()
Performs a psionic attack.
Definition: AlienBAIState.cpp:1803
void setWasHit()
Sets the "unit was hit" flag true.
Definition: AlienBAIState.cpp:395
bool getWasHit() const
Gets whether the unit was hit.
Definition: AlienBAIState.cpp:404
void grenadeAction()
Attempts to throw a grenade at an enemy (or group of enemies) we can see.
Definition: AlienBAIState.cpp:1762
void think(BattleAction *action)
Runs state functionality every AI cycle.
Definition: AlienBAIState.cpp:142
bool selectPointNearTarget(BattleUnit *target, int maxTUs) const
Selects the nearest reachable point relative to a target.
Definition: AlienBAIState.cpp:1112
void selectFireMethod()
Selects a fire method.
Definition: AlienBAIState.cpp:1698
void meleeAttack()
Performs a melee attack action.
Definition: AlienBAIState.cpp:1906
bool explosiveEfficacy(Position targetPos, BattleUnit *attackingUnit, int radius, int diff, bool grenade=false) const
Decides if we should throw a grenade/launch a missile to this position.
Definition: AlienBAIState.cpp:1473
void evaluateAIMode()
re-evaluate our situation, and make a decision from our available options.
Definition: AlienBAIState.cpp:1154
~AlienBAIState()
Cleans up the AlienBAIState.
Definition: AlienBAIState.cpp:70
AlienBAIState(SavedBattleGame *save, BattleUnit *unit, Node *node)
Creates a new AlienBAIState linked to the game and a certain unit.
Definition: AlienBAIState.cpp:53
bool findFirePoint()
Selects a suitable position from which to attack.
Definition: AlienBAIState.cpp:1397
This class is used by the BattleUnit AI.
Definition: AlienBAIState.h:37
void setupAmbush()
setup an ambush objective.
Definition: AlienBAIState.cpp:567
The battlescape data that gets written to disk when the game is saved.
Definition: SavedBattleGame.h:50
Represents a node/spawnpoint in the battlescape, loaded from RMP files.
Definition: Node.h:34
void enter()
Enters the state.
Definition: AlienBAIState.cpp:123
void projectileAction()
Attempts to fire at an enemy we can see.
Definition: AlienBAIState.cpp:1685
Easy handling of X-Y-Z coordinates.
Definition: Position.h:30
void load(const YAML::Node &node)
Loads the AI state from YAML.
Definition: AlienBAIState.cpp:83
void setupEscape()
setup an escape objective.
Definition: AlienBAIState.cpp:757
Represents a moving unit in the battlescape, player controlled or AI controlled it holds info about i...
Definition: BattleUnit.h:58
void exit()
Exits the state.
Definition: AlienBAIState.cpp:133
int selectNearestTarget()
Selects the nearest target we can see, and return the number of viable targets.
Definition: AlienBAIState.cpp:1012
bool selectClosestKnownEnemy()
Selects the closest known xcom unit for ambushing.
Definition: AlienBAIState.cpp:1063