1 /* 2 * This file is part of Dune Legacy. 3 * 4 * Dune Legacy is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * Dune Legacy is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with Dune Legacy. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 #ifndef QuantBot_H 19 #define QuantBot_H 20 21 #include <players/Player.h> 22 #include <units/MCV.h> 23 24 #include <DataTypes.h> 25 26 class QuantBot : public Player 27 { 28 public: 29 enum class Difficulty { 30 Easy = 0, 31 Medium = 1, 32 Hard = 2, 33 Brutal = 3, 34 Defend = 4 35 }; 36 37 enum class GameMode { 38 Custom = 4, 39 Campaign = 5 40 }; 41 42 void init(); 43 ~QuantBot(); 44 virtual void save(OutputStream& stream) const; 45 46 virtual void update(); 47 48 virtual void onIncrementStructures(int itemID); 49 virtual void onDecrementStructures(int itemID, const Coord& location); 50 virtual void onDecrementUnits(int itemID); 51 virtual void onIncrementUnitKills(int itemID); 52 virtual void onDamage(const ObjectBase* pObject, int damage, Uint32 damagerID); 53 create(House * associatedHouse,const std::string & playername,Difficulty difficulty)54 static Player* create(House* associatedHouse, const std::string& playername, Difficulty difficulty) { 55 return new QuantBot(associatedHouse, playername, difficulty); 56 } 57 load(InputStream & stream,House * associatedHouse)58 static Player* load(InputStream& stream, House* associatedHouse) { 59 return new QuantBot(stream, associatedHouse); 60 } 61 62 private: 63 QuantBot(House* associatedHouse, const std::string& playername, Difficulty difficulty); 64 QuantBot(InputStream& stream, House* associatedHouse); 65 66 67 Difficulty difficulty; ///< difficulty level 68 GameMode gameMode; ///< game mode (custom or campaign) 69 Sint32 buildTimer; ///< When to build the next structure/unit 70 Sint32 attackTimer; ///< When to build the next structure/unit 71 Sint32 retreatTimer; ///< When you last retreated> 72 73 int initialItemCount[Num_ItemID]; 74 int initialMilitaryValue = 0; 75 int militaryValueLimit = 0; 76 int harvesterLimit = 4; 77 bool campaignAIAttackFlag = false; 78 Coord squadRallyLocation = Coord::Invalid(); 79 Coord squadRetreatLocation = Coord::Invalid(); 80 81 void scrambleUnitsAndDefend(const ObjectBase* pIntruder, int numUnits = std::numeric_limits<int>::max()); 82 83 84 Coord findMcvPlaceLocation(const MCV* pMCV); 85 Coord findPlaceLocation(Uint32 itemID); 86 Coord findSquadCenter(int houseID); 87 Coord findBaseCentre(int houseID); 88 Coord findSquadRallyLocation(); 89 Coord findSquadRetreatLocation(); 90 91 std::list<Coord> placeLocations; ///< Where to place structures 92 93 void checkAllUnits(); 94 void retreatAllUnits(); 95 void build(int militaryValue); 96 void attack(int militaryValue); 97 98 }; 99 100 #endif //QuantBot_H 101