20 #include <yaml-cpp/yaml.h> 21 #include "BattlescapeGame.h" 23 #include "../Savegame/BattleUnit.h" 30 class SavedBattleGame;
33 class BattlescapeState;
36 enum AIMode { AI_PATROL, AI_AMBUSH, AI_COMBAT, AI_ESCAPE };
46 int _knownEnemies, _visibleEnemies, _spottingEnemies;
47 int _escapeTUs, _ambushTUs;
48 BattleAction *_escapeAction, *_ambushAction, *_attackAction, *_patrolAction, *_psiAction;
49 bool _rifle, _melee, _blaster;
50 bool _traceAI, _didPsi;
51 int _AIMode, _intelligence, _closestDist;
52 Node *_fromNode, *_toNode;
53 std::vector<int> _reachable, _reachableWithAttack, _wasHitBy;
54 BattleActionType _reserve;
55 UnitFaction _targetFaction;
62 void load(
const YAML::Node& node);
64 YAML::Node
save()
const;
bool getWasHitBy(int attacker) const
Gets whether the unit was hit.
Definition: AIModule.cpp:396
bool selectPointNearTarget(BattleUnit *target, int maxTUs) const
Selects the nearest reachable point relative to a target.
Definition: AIModule.cpp:1131
Definition: BattlescapeGame.h:43
void evaluateAIMode()
re-evaluate our situation, and make a decision from our available options.
Definition: AIModule.cpp:1173
void setupAmbush()
setup an ambush objective.
Definition: AIModule.cpp:569
int selectNearestTarget()
Selects the nearest target we can see, and return the number of viable targets.
Definition: AIModule.cpp:1028
bool psiAction()
Performs a psionic attack.
Definition: AIModule.cpp:1860
void wayPointAction()
Attempts to fire a waypoint projectile at an enemy we, or one of our teammates sees.
Definition: AIModule.cpp:1650
bool selectClosestKnownEnemy()
Selects the closest known xcom unit for ambushing.
Definition: AIModule.cpp:1082
bool findFirePoint()
Selects a suitable position from which to attack.
Definition: AIModule.cpp:1422
int countKnownTargets() const
count how many xcom/civilian units are known to this unit.
Definition: AIModule.cpp:968
AIModule(SavedBattleGame *save, BattleUnit *unit, Node *node)
Creates a new AIModule linked to the game and a certain unit.
Definition: AIModule.cpp:49
void setWasHitBy(BattleUnit *attacker)
Sets the "unit was hit" flag true.
Definition: AIModule.cpp:386
YAML::Node save() const
Saves the AI Module to YAML.
Definition: AIModule.cpp:107
void setupEscape()
setup an escape objective.
Definition: AIModule.cpp:769
void load(const YAML::Node &node)
Loads the AI Module from YAML.
Definition: AIModule.cpp:85
bool validTarget(BattleUnit *unit, bool assessDanger, bool includeCivs) const
Checks to make sure a target is valid, given the parameters.
Definition: AIModule.cpp:1988
This class is used by the BattleUnit AI.
Definition: AIModule.h:40
~AIModule()
Cleans up the AIModule.
Definition: AIModule.cpp:72
void think(BattleAction *action)
Runs Module functionality every AI cycle.
Definition: AIModule.cpp:127
bool selectRandomTarget()
Selects a random known target.
Definition: AIModule.cpp:1105
void meleeAttack()
Performs a melee attack action.
Definition: AIModule.cpp:1970
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: AIModule.cpp:1498
void selectMeleeOrRanged()
Assuming we have both a ranged and a melee weapon, we have to select one.
Definition: AIModule.cpp:2023
bool getNodeOfBestEfficacy(BattleAction *action)
Checks nearby nodes to see if they'd make good grenade targets.
Definition: AIModule.cpp:2084
void setupPatrol()
setup a patrol objective.
Definition: AIModule.cpp:405
void selectFireMethod()
Selects a fire method.
Definition: AIModule.cpp:1751
The battlescape data that gets written to disk when the game is saved.
Definition: SavedBattleGame.h:47
BattleActionType getReserveMode()
Checks the alien's TU reservation setting.
Definition: AIModule.cpp:2014
Represents a node/spawnpoint in the battlescape, loaded from RMP files.
Definition: Node.h:32
void grenadeAction()
Attempts to throw a grenade at an enemy (or group of enemies) we can see.
Definition: AIModule.cpp:1815
Easy handling of X-Y-Z coordinates.
Definition: Position.h:28
void setupAttack()
setup a combat objective.
Definition: AIModule.cpp:688
void meleeAction()
Attempts to take a melee attack/charge an enemy we can see.
Definition: AIModule.cpp:1596
int getSpottingUnits(const Position &pos) const
count how many known XCom units are able to see this unit.
Definition: AIModule.cpp:990
void projectileAction()
Attempts to fire at an enemy we can see.
Definition: AIModule.cpp:1738
Represents a moving unit in the battlescape, player controlled or AI controlled it holds info about i...
Definition: BattleUnit.h:59
BattleUnit * getTarget()
Gets the current targetted unit.
Definition: AIModule.cpp:2137
Definition: BaseInfoState.cpp:40