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:1806
void setDebugMode()
Sets debug mode.
Definition: SavedBattleGame.cpp:916
void loadMapResources(Mod *mod)
Load map resources.
Definition: SavedBattleGame.cpp:343
TileEngine * getTileEngine() const
Gets a pointer to the tileengine.
Definition: SavedBattleGame.cpp:795
A utility class that modifies tile properties on a battlescape map.
Definition: TileEngine.h:38
YAML::Node save() const
Saves a saved battle game to YAML.
Definition: SavedBattleGame.cpp:380
bool addFallingUnit(BattleUnit *unit)
Adds this unit to the vector of falling units.
Definition: SavedBattleGame.cpp:1597
bool getUnitsFalling() const
Checks the status of the switch that says "there are units falling".
Definition: SavedBattleGame.cpp:1638
void endTurn()
Ends the turn.
Definition: SavedBattleGame.cpp:830
void setUnitsFalling(bool fall)
Toggles the switch that says "there are units falling, start the fall state".
Definition: SavedBattleGame.cpp:1629
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:768
std::vector< MapDataSet * > * getMapDataSets()
Gets the game's mapdatafiles.
Definition: SavedBattleGame.cpp:804
void resetUnitHitStates()
Reset all the unit hit state flags.
Definition: SavedBattleGame.cpp:2071
bool isAborted() const
Checks if the mission was aborted.
Definition: SavedBattleGame.cpp:1113
A game state that receives user input and reacts accordingly.
Definition: State.h:44
BattlescapeGame * getBattleGame()
Gets a pointer to the BattlescapeGame.
Definition: SavedBattleGame.cpp:948
void setBattleState(BattlescapeState *bs)
Sets the pointer to the BattlescapeState.
Definition: SavedBattleGame.cpp:957
int getDepth() const
get the depth of the battlescape game.
Definition: SavedBattleGame.cpp:1880
void setPaletteByDepth(State *state)
uses the depth variable to set a palette.
Definition: SavedBattleGame.cpp:1898
void setObjectiveType(int type)
Sets the objective type for this mission.
Definition: SavedBattleGame.cpp:1970
void resetUnitTiles()
Resets tiles units are standing on.
Definition: SavedBattleGame.cpp:965
std::vector< BattleItem * > * getConditionalRecoveredItems()
gets the list of items we MIGHT get.
Definition: SavedBattleGame.cpp:1943
SpecialTileType getObjectiveType() const
Gets the objective type of this mission.
Definition: SavedBattleGame.cpp:1979
int * getCurrentItemId()
Gets the current item ID.
Definition: SavedBattleGame.cpp:1162
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:1755
int getTurn() const
Gets the turn number.
Definition: SavedBattleGame.cpp:822
std::vector< BattleItem * > * getItems()
Gets a pointer to the list of items.
Definition: SavedBattleGame.cpp:777
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:629
int getTurnLimit() const
Gets the turn limit for this mission.
Definition: SavedBattleGame.cpp:2008
void prepareNewTurn()
Carries out new turn preparations.
Definition: SavedBattleGame.cpp:1294
std::vector< BattleItem * > * getGuaranteedRecoveredItems()
gets the list of items we're guaranteed.
Definition: SavedBattleGame.cpp:1934
void removeUnconsciousBodyItem(BattleUnit *bu)
Removes the body item that corresponds to the unit.
Definition: SavedBattleGame.cpp:1491
void resetTiles()
Resets the visibility of all tiles on the map.
Definition: SavedBattleGame.cpp:1766
bool allObjectivesDestroyed() const
Checks if all the objectives are destroyed.
Definition: SavedBattleGame.cpp:1153
UnitFaction getSide() const
Gets the playing side.
Definition: SavedBattleGame.cpp:813
void setDepth(int depth)
set the depth of the battlescape game.
Definition: SavedBattleGame.cpp:1889
void setAmbientVolume(double volume)
sets the ambient sound effect;
Definition: SavedBattleGame.cpp:1990
void randomizeItemLocations(Tile *t)
move all the leftover items to random locations in the storage tiles vector.
Definition: SavedBattleGame.cpp:1013
void setSelectedUnit(BattleUnit *unit)
Sets the currently selected unit.
Definition: SavedBattleGame.cpp:638
void setAborted(bool flag)
Sets whether the mission was aborted.
Definition: SavedBattleGame.cpp:1104
int getMapSizeZ() const
Gets terrain size z.
Definition: SavedBattleGame.cpp:597
int getMapSizeXYZ() const
Gets terrain x*y*z.
Definition: SavedBattleGame.cpp:606
void setMusic(const std::string &track)
Set the name of the music track.
Definition: SavedBattleGame.cpp:1961
std::vector< std::vector< std::pair< int, int > > > & getModuleMap()
get a reference to the baseModules map.
Definition: SavedBattleGame.cpp:1836
SavedGame * getGeoscapeSave()
a shortcut to the geoscape save.
Definition: SavedBattleGame.cpp:1871
Node * getSpawnNode(int nodeRank, BattleUnit *unit)
Gets a spawn node.
Definition: SavedBattleGame.cpp:1173
void removeItem(BattleItem *item)
Removes an item from the game.
Definition: SavedBattleGame.cpp:1036
int getMapSizeY() const
Gets terrain size y.
Definition: SavedBattleGame.cpp:588
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:1670
void setAmbientSound(int sound)
sets the ambient sound effect;
Definition: SavedBattleGame.cpp:1916
void initUtilities(Mod *mod)
Initialises the pathfinding and tileengine.
Definition: SavedBattleGame.cpp:531
void setMissionType(const std::string &missionType)
Sets the mission type.
Definition: SavedBattleGame.cpp:543
Node * getPatrolNode(bool scout, BattleUnit *unit, Node *fromNode)
Gets a patrol node.
Definition: SavedBattleGame.cpp:1218
BattleUnit * selectUnit(Position pos)
Selects the unit with position on map.
Definition: SavedBattleGame.cpp:741
BattleActionType getTUReserved() const
get the reserved fire mode.
Definition: SavedBattleGame.cpp:1797
Represents a single item in the battlescape.
Definition: BattleItem.h:37
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:1512
std::string & getMusic()
Get the name of the music track.
Definition: SavedBattleGame.cpp:1952
bool placeUnitNearPosition(BattleUnit *unit, const Position &entryPoint, bool largeFriend)
Attempts to place a unit on or near entryPoint.
Definition: SavedBattleGame.cpp:1719
void setChronoTrigger(ChronoTrigger trigger)
Sets the action that triggers when the timer runs out.
Definition: SavedBattleGame.cpp:2035
void setObjectiveCount(int counter)
Sets how many objectives need to be destroyed.
Definition: SavedBattleGame.cpp:1121
Pathfinding * getPathfinding() const
Gets the pathfinding object.
Definition: SavedBattleGame.cpp:786
bool isBeforeGame() const
Check whether the battle has actually commenced or not.
Definition: SavedBattleGame.cpp:2049
BattleUnit * getHighestRankedXCom()
Gets the highest ranked, living XCom unit.
Definition: SavedBattleGame.cpp:1647
double getAmbientVolume() const
gets the ambient sound effect;
Definition: SavedBattleGame.cpp:1999
BattleUnit * selectNextPlayerUnit(bool checkReselect=false, bool setReselect=false, bool checkInventory=false)
Selects the next soldier.
Definition: SavedBattleGame.cpp:664
void calculateModuleMap()
calculate the number of map modules remaining
Definition: SavedBattleGame.cpp:1846
int getMapSizeX() const
Gets terrain size x.
Definition: SavedBattleGame.cpp:579
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:759
bool isItemUsable(RuleItem *item) const
Checks if an item is usable on this map.
Definition: SavedBattleGame.cpp:2058
int getAmbientSound() const
gets the ambient sound effect;
Definition: SavedBattleGame.cpp:1925
~SavedBattleGame()
Cleans up the saved game.
Definition: SavedBattleGame.cpp:65
bool getDebugMode() const
Gets debug mode.
Definition: SavedBattleGame.cpp:930
bool isCheating() const
check if the AI has engaged cheat mode.
Definition: SavedBattleGame.cpp:1788
Tile ** getTiles() const
Gets a pointer to the tiles, a tile is the smallest component of battlescape.
Definition: SavedBattleGame.cpp:479
void getTileCoords(int index, int *x, int *y, int *z) const
Converts a tile index to its coordinates.
Definition: SavedBattleGame.cpp:618
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:1004
BattleUnit * selectPreviousPlayerUnit(bool checkReselect=false, bool setReselect=false, bool checkInventory=false)
Selects the previous soldier.
Definition: SavedBattleGame.cpp:651
int getGlobalShade() const
Gets the global shade.
Definition: SavedBattleGame.cpp:570
bool getKneelReserved() const
get whether we are reserving TUs to kneel.
Definition: SavedBattleGame.cpp:1815
void setGlobalShade(int shade)
Sets the global shade.
Definition: SavedBattleGame.cpp:561
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:2017
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:2026
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:1130
void setCheatTurn(int turn)
Sets the turn to start the aliens cheating.
Definition: SavedBattleGame.cpp:2044
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:490
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:552
void setKneelReserved(bool reserved)
set whether we are reserving TUs to kneel.
Definition: SavedBattleGame.cpp:1824
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:939
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:1452
Definition: BaseInfoState.cpp:40
const std::vector< Position > & getTileSearch() const
get an 11x11 grid of positions (-10 to +10) to check.
Definition: SavedBattleGame.cpp:1779
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:1577
std::list< BattleUnit * > * getFallingUnits()
Gets the vector of falling units.
Definition: SavedBattleGame.cpp:1620