22 #include <yaml-cpp/yaml.h> 23 #include "BattleUnit.h" 24 #include "../Mod/AlienDeployment.h" 33 class BattlescapeState;
51 int _mapsize_x, _mapsize_y, _mapsize_z;
52 std::vector<MapDataSet*> _mapDataSets;
55 std::vector<Node*> _nodes;
56 std::vector<BattleUnit*> _units;
57 std::vector<BattleItem*> _items, _deleted;
60 std::string _missionType;
67 int _objectiveType, _objectivesDestroyed, _objectivesNeeded;
68 std::vector<BattleUnit*> _exposedUnits;
69 std::list<BattleUnit*> _fallingUnits;
70 bool _unitsFalling, _cheating;
71 std::vector<Position> _tileSearch, _storageSpace;
72 BattleActionType _tuReserved;
74 std::vector< std::vector<std::pair<int, int> > > _baseModules;
75 int _depth, _ambience;
76 double _ambientVolume;
77 std::vector<BattleItem*> _recoverGuaranteed, _recoverConditional;
79 int _turnLimit, _cheatTurn;
80 ChronoTrigger _chronoTrigger;
83 BattleUnit *selectPlayerUnit(
int dir,
bool checkReselect =
false,
bool setReselect =
false,
bool checkInventory =
false);
92 YAML::Node
save()
const;
94 void initMap(
int mapsize_x,
int mapsize_y,
int mapsize_z,
bool resetTerrain =
true);
112 std::vector<BattleItem*> *
getItems();
114 std::vector<BattleUnit*> *
getUnits();
132 return pos.z * _mapsize_y * _mapsize_x + pos.y * _mapsize_x + pos.x;
147 if (pos.x < 0 || pos.y < 0 || pos.z < 0
148 || pos.x >= _mapsize_x || pos.y >= _mapsize_y || pos.z >= _mapsize_z)
251 std::vector< std::vector<std::pair<int, int> > > &
getModuleMap();
void setTUReserved(BattleActionType reserved)
set the reserved fire mode.
Definition: SavedBattleGame.cpp:1800
void setDebugMode()
Sets debug mode.
Definition: SavedBattleGame.cpp:919
void loadMapResources(Mod *mod)
Load map resources.
Definition: SavedBattleGame.cpp:347
TileEngine * getTileEngine() const
Gets a pointer to the tileengine.
Definition: SavedBattleGame.cpp:798
A utility class that modifies tile properties on a battlescape map.
Definition: TileEngine.h:37
YAML::Node save() const
Saves a saved battle game to YAML.
Definition: SavedBattleGame.cpp:383
bool addFallingUnit(BattleUnit *unit)
Adds this unit to the vector of falling units.
Definition: SavedBattleGame.cpp:1591
bool getUnitsFalling() const
Checks the status of the switch that says "there are units falling".
Definition: SavedBattleGame.cpp:1632
void endTurn()
Ends the turn.
Definition: SavedBattleGame.cpp:833
void setUnitsFalling(bool fall)
Toggles the switch that says "there are units falling, start the fall state".
Definition: SavedBattleGame.cpp:1623
Tile * getTile(Position pos) const
Gets the Tile at a given position on the map.
Definition: SavedBattleGame.h:145
std::vector< BattleUnit * > * getUnits()
Gets a pointer to the list of units.
Definition: SavedBattleGame.cpp:771
std::vector< MapDataSet * > * getMapDataSets()
Gets the game's mapdatafiles.
Definition: SavedBattleGame.cpp:807
void resetUnitHitStates()
Reset all the unit hit state flags.
Definition: SavedBattleGame.cpp:2065
bool isAborted() const
Checks if the mission was aborted.
Definition: SavedBattleGame.cpp:1107
A game state that receives user input and reacts accordingly.
Definition: State.h:43
BattlescapeGame * getBattleGame()
Gets a pointer to the BattlescapeGame.
Definition: SavedBattleGame.cpp:951
void setBattleState(BattlescapeState *bs)
Sets the pointer to the BattlescapeState.
Definition: SavedBattleGame.cpp:960
int getDepth() const
get the depth of the battlescape game.
Definition: SavedBattleGame.cpp:1874
void setPaletteByDepth(State *state)
uses the depth variable to set a palette.
Definition: SavedBattleGame.cpp:1892
void setObjectiveType(int type)
Sets the objective type for this mission.
Definition: SavedBattleGame.cpp:1964
void resetUnitTiles()
Resets tiles units are standing on.
Definition: SavedBattleGame.cpp:968
std::vector< BattleItem * > * getConditionalRecoveredItems()
gets the list of items we MIGHT get.
Definition: SavedBattleGame.cpp:1937
SpecialTileType getObjectiveType() const
Gets the objective type of this mission.
Definition: SavedBattleGame.cpp:1973
int * getCurrentItemId()
Gets the current item ID.
Definition: SavedBattleGame.cpp:1156
The game data that gets written to disk when the game is saved.
Definition: SavedGame.h:99
void resetTurnCounter()
Resets the turn counter.
Definition: SavedBattleGame.cpp:1749
int getTurn() const
Gets the turn number.
Definition: SavedBattleGame.cpp:825
std::vector< BattleItem * > * getItems()
Gets a pointer to the list of items.
Definition: SavedBattleGame.cpp:780
Contains all the game-specific static data that never changes throughout the game, like rulesets and resources.
Definition: Mod.h:87
BattleUnit * getSelectedUnit() const
Gets the currently selected unit.
Definition: SavedBattleGame.cpp:632
int getTurnLimit() const
Gets the turn limit for this mission.
Definition: SavedBattleGame.cpp:2002
void prepareNewTurn()
Carries out new turn preparations.
Definition: SavedBattleGame.cpp:1288
std::vector< BattleItem * > * getGuaranteedRecoveredItems()
gets the list of items we're guaranteed.
Definition: SavedBattleGame.cpp:1928
void removeUnconsciousBodyItem(BattleUnit *bu)
Removes the body item that corresponds to the unit.
Definition: SavedBattleGame.cpp:1485
void resetTiles()
Resets the visibility of all tiles on the map.
Definition: SavedBattleGame.cpp:1760
bool allObjectivesDestroyed() const
Checks if all the objectives are destroyed.
Definition: SavedBattleGame.cpp:1147
UnitFaction getSide() const
Gets the playing side.
Definition: SavedBattleGame.cpp:816
void setDepth(int depth)
set the depth of the battlescape game.
Definition: SavedBattleGame.cpp:1883
void setAmbientVolume(double volume)
sets the ambient sound effect;
Definition: SavedBattleGame.cpp:1984
void randomizeItemLocations(Tile *t)
move all the leftover items to random locations in the storage tiles vector.
Definition: SavedBattleGame.cpp:1016
void setSelectedUnit(BattleUnit *unit)
Sets the currently selected unit.
Definition: SavedBattleGame.cpp:641
void setAborted(bool flag)
Sets whether the mission was aborted.
Definition: SavedBattleGame.cpp:1098
int getMapSizeZ() const
Gets terrain size z.
Definition: SavedBattleGame.cpp:600
int getMapSizeXYZ() const
Gets terrain x*y*z.
Definition: SavedBattleGame.cpp:609
void setMusic(const std::string &track)
Set the name of the music track.
Definition: SavedBattleGame.cpp:1955
std::vector< std::vector< std::pair< int, int > > > & getModuleMap()
get a reference to the baseModules map.
Definition: SavedBattleGame.cpp:1830
SavedGame * getGeoscapeSave()
a shortcut to the geoscape save.
Definition: SavedBattleGame.cpp:1865
Node * getSpawnNode(int nodeRank, BattleUnit *unit)
Gets a spawn node.
Definition: SavedBattleGame.cpp:1167
void removeItem(BattleItem *item)
Removes an item from the game.
Definition: SavedBattleGame.cpp:1039
int getMapSizeY() const
Gets terrain size y.
Definition: SavedBattleGame.cpp:591
Represents a specific type of item.
Definition: RuleItem.h:40
int getMoraleModifier(BattleUnit *unit=0)
Gets the morale modifier for XCom based on the highest ranked, living XCom unit, or the modifier for ...
Definition: SavedBattleGame.cpp:1664
void setAmbientSound(int sound)
sets the ambient sound effect;
Definition: SavedBattleGame.cpp:1910
void initUtilities(Mod *mod)
Initialises the pathfinding and tileengine.
Definition: SavedBattleGame.cpp:534
void setMissionType(const std::string &missionType)
Sets the mission type.
Definition: SavedBattleGame.cpp:546
Node * getPatrolNode(bool scout, BattleUnit *unit, Node *fromNode)
Gets a patrol node.
Definition: SavedBattleGame.cpp:1212
BattleUnit * selectUnit(Position pos)
Selects the unit with position on map.
Definition: SavedBattleGame.cpp:744
BattleActionType getTUReserved() const
get the reserved fire mode.
Definition: SavedBattleGame.cpp:1791
Represents a single item in the battlescape.
Definition: BattleItem.h:36
bool setUnitPosition(BattleUnit *bu, Position position, bool testOnly=false)
Sets or tries to set a unit of a certain size on a certain position of the map.
Definition: SavedBattleGame.cpp:1506
std::string & getMusic()
Get the name of the music track.
Definition: SavedBattleGame.cpp:1946
bool placeUnitNearPosition(BattleUnit *unit, const Position &entryPoint, bool largeFriend)
Attempts to place a unit on or near entryPoint.
Definition: SavedBattleGame.cpp:1713
void setChronoTrigger(ChronoTrigger trigger)
Sets the action that triggers when the timer runs out.
Definition: SavedBattleGame.cpp:2029
void setObjectiveCount(int counter)
Sets how many objectives need to be destroyed.
Definition: SavedBattleGame.cpp:1115
Pathfinding * getPathfinding() const
Gets the pathfinding object.
Definition: SavedBattleGame.cpp:789
bool isBeforeGame() const
Check whether the battle has actually commenced or not.
Definition: SavedBattleGame.cpp:2043
BattleUnit * getHighestRankedXCom()
Gets the highest ranked, living XCom unit.
Definition: SavedBattleGame.cpp:1641
double getAmbientVolume() const
gets the ambient sound effect;
Definition: SavedBattleGame.cpp:1993
BattleUnit * selectNextPlayerUnit(bool checkReselect=false, bool setReselect=false, bool checkInventory=false)
Selects the next soldier.
Definition: SavedBattleGame.cpp:667
void calculateModuleMap()
calculate the number of map modules remaining
Definition: SavedBattleGame.cpp:1840
int getMapSizeX() const
Gets terrain size x.
Definition: SavedBattleGame.cpp:582
void load(const YAML::Node &node, Mod *mod, SavedGame *savedGame)
Loads a saved battle game from YAML.
Definition: SavedBattleGame.cpp:118
std::vector< Node * > * getNodes()
Gets a pointer to the list of nodes.
Definition: SavedBattleGame.cpp:762
bool isItemUsable(RuleItem *item) const
Checks if an item is usable on this map.
Definition: SavedBattleGame.cpp:2052
int getAmbientSound() const
gets the ambient sound effect;
Definition: SavedBattleGame.cpp:1919
~SavedBattleGame()
Cleans up the saved game.
Definition: SavedBattleGame.cpp:65
bool getDebugMode() const
Gets debug mode.
Definition: SavedBattleGame.cpp:933
bool isCheating() const
check if the AI has engaged cheat mode.
Definition: SavedBattleGame.cpp:1782
Tile ** getTiles() const
Gets a pointer to the tiles, a tile is the smallest component of battlescape.
Definition: SavedBattleGame.cpp:482
void getTileCoords(int index, int *x, int *y, int *z) const
Converts a tile index to its coordinates.
Definition: SavedBattleGame.cpp:621
Basic element of which a battle map is build.
Definition: Tile.h:42
std::vector< Position > & getStorageSpace()
give me access to the storage tiles vector.
Definition: SavedBattleGame.cpp:1007
BattleUnit * selectPreviousPlayerUnit(bool checkReselect=false, bool setReselect=false, bool checkInventory=false)
Selects the previous soldier.
Definition: SavedBattleGame.cpp:654
int getGlobalShade() const
Gets the global shade.
Definition: SavedBattleGame.cpp:573
bool getKneelReserved() const
get whether we are reserving TUs to kneel.
Definition: SavedBattleGame.cpp:1809
void setGlobalShade(int shade)
Sets the global shade.
Definition: SavedBattleGame.cpp:564
Battlescape game - the core game engine of the battlescape game.
Definition: BattlescapeGame.h:68
ChronoTrigger getChronoTrigger() const
Gets the action that triggers when the timer runs out.
Definition: SavedBattleGame.cpp:2011
A utility class that calculates the shortest path between two points on the battlescape map...
Definition: Pathfinding.h:35
void setTurnLimit(int limit)
Sets the turn limit for this mission.
Definition: SavedBattleGame.cpp:2020
The battlescape data that gets written to disk when the game is saved.
Definition: SavedBattleGame.h:47
void addDestroyedObjective()
increments the objective counter.
Definition: SavedBattleGame.cpp:1124
void setCheatTurn(int turn)
Sets the turn to start the aliens cheating.
Definition: SavedBattleGame.cpp:2038
void initMap(int mapsize_x, int mapsize_y, int mapsize_z, bool resetTerrain=true)
Sets the dimensions of the map and initializes it.
Definition: SavedBattleGame.cpp:493
Represents a node/spawnpoint in the battlescape, loaded from RMP files.
Definition: Node.h:32
std::string getMissionType() const
Gets the mission type.
Definition: SavedBattleGame.cpp:555
void setKneelReserved(bool reserved)
set whether we are reserving TUs to kneel.
Definition: SavedBattleGame.cpp:1818
Easy handling of X-Y-Z coordinates.
Definition: Position.h:28
MIDI track.
Definition: GMCat.cpp:40
BattlescapeState * getBattleState()
Gets a pointer to the BattlescapeState.
Definition: SavedBattleGame.cpp:942
Battlescape screen which shows the tactical battle.
Definition: BattlescapeState.h:47
int getTileIndex(Position pos) const
Converts coordinates into a unique index.
Definition: SavedBattleGame.h:130
SavedBattleGame()
Creates a new battle save, based on the current generic save.
Definition: SavedBattleGame.cpp:50
Represents a moving unit in the battlescape, player controlled or AI controlled it holds info about i...
Definition: BattleUnit.h:59
void reviveUnconsciousUnits()
Revives unconscious units (healthcheck).
Definition: SavedBattleGame.cpp:1446
Definition: BaseInfoState.cpp:40
const std::vector< Position > & getTileSearch() const
get an 11x11 grid of positions (-10 to +10) to check.
Definition: SavedBattleGame.cpp:1773
bool eyesOnTarget(UnitFaction faction, BattleUnit *unit)
Checks whether a particular faction has eyes on *unit (whether any unit on that faction sees *unit)...
Definition: SavedBattleGame.cpp:1571
std::list< BattleUnit * > * getFallingUnits()
Gets the vector of falling units.
Definition: SavedBattleGame.cpp:1614