22 #include <yaml-cpp/yaml.h> 23 #include "BattleUnit.h" 24 #include "../Mod/AlienDeployment.h" 33 class BattlescapeState;
50 int _mapsize_x, _mapsize_y, _mapsize_z;
51 std::vector<MapDataSet*> _mapDataSets;
54 std::vector<Node*> _nodes;
55 std::vector<BattleUnit*> _units;
56 std::vector<BattleItem*> _items, _deleted;
59 std::string _missionType;
66 int _objectiveType, _objectivesDestroyed, _objectivesNeeded;
67 std::vector<BattleUnit*> _exposedUnits;
68 std::list<BattleUnit*> _fallingUnits;
69 bool _unitsFalling, _cheating;
70 std::vector<Position> _tileSearch, _storageSpace;
71 BattleActionType _tuReserved;
73 std::vector< std::vector<std::pair<int, int> > > _baseModules;
74 int _depth, _ambience;
75 double _ambientVolume;
76 std::vector<BattleItem*> _recoverGuaranteed, _recoverConditional;
78 int _turnLimit, _cheatTurn;
79 ChronoTrigger _chronoTrigger;
82 BattleUnit *selectPlayerUnit(
int dir,
bool checkReselect =
false,
bool setReselect =
false,
bool checkInventory =
false);
91 YAML::Node
save()
const;
93 void initMap(
int mapsize_x,
int mapsize_y,
int mapsize_z);
111 std::vector<BattleItem*> *
getItems();
113 std::vector<BattleUnit*> *
getUnits();
131 return pos.z * _mapsize_y * _mapsize_x + pos.y * _mapsize_x + pos.x;
146 if (pos.x < 0 || pos.y < 0 || pos.z < 0
147 || pos.x >= _mapsize_x || pos.y >= _mapsize_y || pos.z >= _mapsize_z)
250 std::vector< std::vector<std::pair<int, int> > > &
getModuleMap();
291 bool isBeforeGame()
const;
void setTUReserved(BattleActionType reserved)
set the reserved fire mode.
Definition: SavedBattleGame.cpp:1799
void setDebugMode()
Sets debug mode.
Definition: SavedBattleGame.cpp:914
void loadMapResources(Mod *mod)
Load map resources.
Definition: SavedBattleGame.cpp:346
TileEngine * getTileEngine() const
Gets a pointer to the tileengine.
Definition: SavedBattleGame.cpp:793
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:382
bool addFallingUnit(BattleUnit *unit)
Adds this unit to the vector of falling units.
Definition: SavedBattleGame.cpp:1590
bool getUnitsFalling() const
Checks the status of the switch that says "there are units falling".
Definition: SavedBattleGame.cpp:1631
void endTurn()
Ends the turn.
Definition: SavedBattleGame.cpp:828
void setUnitsFalling(bool fall)
Toggles the switch that says "there are units falling, start the fall state".
Definition: SavedBattleGame.cpp:1622
Tile * getTile(Position pos) const
Gets the Tile at a given position on the map.
Definition: SavedBattleGame.h:144
std::vector< BattleUnit * > * getUnits()
Gets a pointer to the list of units.
Definition: SavedBattleGame.cpp:766
std::vector< MapDataSet * > * getMapDataSets()
Gets the game's mapdatafiles.
Definition: SavedBattleGame.cpp:802
void initMap(int mapsize_x, int mapsize_y, int mapsize_z)
Sets the dimensions of the map and initializes it.
Definition: SavedBattleGame.cpp:492
bool isAborted() const
Checks if the mission was aborted.
Definition: SavedBattleGame.cpp:1102
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:946
void setBattleState(BattlescapeState *bs)
Sets the pointer to the BattlescapeState.
Definition: SavedBattleGame.cpp:955
int getDepth() const
get the depth of the battlescape game.
Definition: SavedBattleGame.cpp:1873
void setPaletteByDepth(State *state)
uses the depth variable to set a palette.
Definition: SavedBattleGame.cpp:1891
void setObjectiveType(int type)
Sets the objective type for this mission.
Definition: SavedBattleGame.cpp:1963
void resetUnitTiles()
Resets tiles units are standing on.
Definition: SavedBattleGame.cpp:963
std::vector< BattleItem * > * getConditionalRecoveredItems()
gets the list of items we MIGHT get.
Definition: SavedBattleGame.cpp:1936
SpecialTileType getObjectiveType() const
Gets the objective type of this mission.
Definition: SavedBattleGame.cpp:1972
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:1748
int getTurn() const
Gets the turn number.
Definition: SavedBattleGame.cpp:820
std::vector< BattleItem * > * getItems()
Gets a pointer to the list of items.
Definition: SavedBattleGame.cpp:775
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:627
int getTurnLimit() const
Gets the turn limit for this mission.
Definition: SavedBattleGame.cpp:2001
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:1927
void removeUnconsciousBodyItem(BattleUnit *bu)
Removes the body item that corresponds to the unit.
Definition: SavedBattleGame.cpp:1484
void resetTiles()
Resets the visibility of all tiles on the map.
Definition: SavedBattleGame.cpp:1759
bool allObjectivesDestroyed() const
Checks if all the objectives are destroyed.
Definition: SavedBattleGame.cpp:1147
UnitFaction getSide() const
Gets the playing side.
Definition: SavedBattleGame.cpp:811
void setDepth(int depth)
set the depth of the battlescape game.
Definition: SavedBattleGame.cpp:1882
void setAmbientVolume(double volume)
sets the ambient sound effect;
Definition: SavedBattleGame.cpp:1983
void randomizeItemLocations(Tile *t)
move all the leftover items to random locations in the storage tiles vector.
Definition: SavedBattleGame.cpp:1011
void setSelectedUnit(BattleUnit *unit)
Sets the currently selected unit.
Definition: SavedBattleGame.cpp:636
void setAborted(bool flag)
Sets whether the mission was aborted.
Definition: SavedBattleGame.cpp:1093
int getMapSizeZ() const
Gets terrain size z.
Definition: SavedBattleGame.cpp:595
int getMapSizeXYZ() const
Gets terrain x*y*z.
Definition: SavedBattleGame.cpp:604
void setMusic(const std::string &track)
Set the name of the music track.
Definition: SavedBattleGame.cpp:1954
std::vector< std::vector< std::pair< int, int > > > & getModuleMap()
get a reference to the baseModules map.
Definition: SavedBattleGame.cpp:1829
SavedGame * getGeoscapeSave()
a shortcut to the geoscape save.
Definition: SavedBattleGame.cpp:1864
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:1034
int getMapSizeY() const
Gets terrain size y.
Definition: SavedBattleGame.cpp:586
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:1663
void setAmbientSound(int sound)
sets the ambient sound effect;
Definition: SavedBattleGame.cpp:1909
void initUtilities(Mod *mod)
Initialises the pathfinding and tileengine.
Definition: SavedBattleGame.cpp:529
void setMissionType(const std::string &missionType)
Sets the mission type.
Definition: SavedBattleGame.cpp:541
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:739
BattleActionType getTUReserved() const
get the reserved fire mode.
Definition: SavedBattleGame.cpp:1790
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:1505
std::string & getMusic()
Get the name of the music track.
Definition: SavedBattleGame.cpp:1945
bool placeUnitNearPosition(BattleUnit *unit, const Position &entryPoint, bool largeFriend)
Attempts to place a unit on or near entryPoint.
Definition: SavedBattleGame.cpp:1712
void setChronoTrigger(ChronoTrigger trigger)
Sets the action that triggers when the timer runs out.
Definition: SavedBattleGame.cpp:2028
void setObjectiveCount(int counter)
Sets how many objectives need to be destroyed.
Definition: SavedBattleGame.cpp:1110
Pathfinding * getPathfinding() const
Gets the pathfinding object.
Definition: SavedBattleGame.cpp:784
BattleUnit * getHighestRankedXCom()
Gets the highest ranked, living XCom unit.
Definition: SavedBattleGame.cpp:1640
double getAmbientVolume() const
gets the ambient sound effect;
Definition: SavedBattleGame.cpp:1992
BattleUnit * selectNextPlayerUnit(bool checkReselect=false, bool setReselect=false, bool checkInventory=false)
Selects the next soldier.
Definition: SavedBattleGame.cpp:662
void calculateModuleMap()
calculate the number of map modules remaining
Definition: SavedBattleGame.cpp:1839
int getMapSizeX() const
Gets terrain size x.
Definition: SavedBattleGame.cpp:577
void load(const YAML::Node &node, Mod *mod, SavedGame *savedGame)
Loads a saved battle game from YAML.
Definition: SavedBattleGame.cpp:117
std::vector< Node * > * getNodes()
Gets a pointer to the list of nodes.
Definition: SavedBattleGame.cpp:757
int getAmbientSound() const
gets the ambient sound effect;
Definition: SavedBattleGame.cpp:1918
~SavedBattleGame()
Cleans up the saved game.
Definition: SavedBattleGame.cpp:64
bool getDebugMode() const
Gets debug mode.
Definition: SavedBattleGame.cpp:928
bool isCheating() const
check if the AI has engaged cheat mode.
Definition: SavedBattleGame.cpp:1781
Tile ** getTiles() const
Gets a pointer to the tiles, a tile is the smallest component of battlescape.
Definition: SavedBattleGame.cpp:481
void getTileCoords(int index, int *x, int *y, int *z) const
Converts a tile index to its coordinates.
Definition: SavedBattleGame.cpp:616
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:1002
BattleUnit * selectPreviousPlayerUnit(bool checkReselect=false, bool setReselect=false, bool checkInventory=false)
Selects the previous soldier.
Definition: SavedBattleGame.cpp:649
int getGlobalShade() const
Gets the global shade.
Definition: SavedBattleGame.cpp:568
bool getKneelReserved() const
get whether we are reserving TUs to kneel.
Definition: SavedBattleGame.cpp:1808
void setGlobalShade(int shade)
Sets the global shade.
Definition: SavedBattleGame.cpp:559
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:2010
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:2019
The battlescape data that gets written to disk when the game is saved.
Definition: SavedBattleGame.h:46
void addDestroyedObjective()
increments the objective counter.
Definition: SavedBattleGame.cpp:1119
void setCheatTurn(int turn)
Sets the turn to start the aliens cheating.
Definition: SavedBattleGame.cpp:2037
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:550
void setKneelReserved(bool reserved)
set whether we are reserving TUs to kneel.
Definition: SavedBattleGame.cpp:1817
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:937
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:129
SavedBattleGame()
Creates a new battle save, based on the current generic save.
Definition: SavedBattleGame.cpp:49
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:1445
Definition: BaseInfoState.cpp:40
const std::vector< Position > & getTileSearch() const
get an 11x11 grid of positions (-10 to +10) to check.
Definition: SavedBattleGame.cpp:1772
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:1570
std::list< BattleUnit * > * getFallingUnits()
Gets the vector of falling units.
Definition: SavedBattleGame.cpp:1613