RecruitHero.cpp 980 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * RecruitHero.cpp, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #include "StdInc.h"
  11. #include "Goals.h"
  12. #include "../VCAI.h"
  13. #include "../AIUtility.h"
  14. #include "../AIhelper.h"
  15. #include "../FuzzyHelper.h"
  16. #include "../ResourceManager.h"
  17. #include "../BuildingManager.h"
  18. #include "../../../lib/CPathfinder.h"
  19. #include "../../../lib/StringConstants.h"
  20. extern boost::thread_specific_ptr<CCallback> cb;
  21. extern boost::thread_specific_ptr<VCAI> ai;
  22. extern FuzzyHelper * fh;
  23. using namespace Goals;
  24. TSubgoal RecruitHero::whatToDoToAchieve()
  25. {
  26. const CGTownInstance * t = ai->findTownWithTavern();
  27. if(!t)
  28. return sptr(BuildThis(BuildingID::TAVERN).setpriority(2));
  29. TResources res;
  30. res[EGameResID::GOLD] = GameConstants::HERO_GOLD_COST;
  31. return ai->ah->whatToDo(res, iAmElementar()); //either buy immediately, or collect res
  32. }