2
0

DigAtTile.cpp 999 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * DigAtTile.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 "DigAtTile.h"
  12. #include "VisitTile.h"
  13. #include "../VCAI.h"
  14. #include "../AIUtility.h"
  15. extern boost::thread_specific_ptr<CCallback> cb;
  16. extern boost::thread_specific_ptr<VCAI> ai;
  17. extern FuzzyHelper * fh;
  18. using namespace Goals;
  19. bool DigAtTile::operator==(const DigAtTile & other) const
  20. {
  21. return other.hero.h == hero.h && other.tile == tile;
  22. }
  23. TSubgoal DigAtTile::whatToDoToAchieve()
  24. {
  25. const CGObjectInstance * firstObj = vstd::frontOrNull(cb->getVisitableObjs(tile));
  26. if(firstObj && firstObj->ID == Obj::HERO && firstObj->tempOwner == ai->playerID) //we have hero at dest
  27. {
  28. const CGHeroInstance * h = dynamic_cast<const CGHeroInstance *>(firstObj);
  29. sethero(h).setisElementar(true);
  30. return sptr(*this);
  31. }
  32. return sptr(VisitTile(tile));
  33. }