QuestAction.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * QuestAction.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 "QuestAction.h"
  12. #include "../../AIGateway.h"
  13. #include "../../Goals/CompleteQuest.h"
  14. namespace NKAI
  15. {
  16. namespace AIPathfinding
  17. {
  18. bool QuestAction::canAct(const AIPathNode * node) const
  19. {
  20. if(questInfo.obj->ID == Obj::BORDER_GATE || questInfo.obj->ID == Obj::BORDERGUARD)
  21. {
  22. return dynamic_cast<const IQuestObject *>(questInfo.obj)->checkQuest(node->actor->hero);
  23. }
  24. return questInfo.quest->progress == CQuest::NOT_ACTIVE
  25. || questInfo.quest->checkQuest(node->actor->hero);
  26. }
  27. Goals::TSubgoal QuestAction::decompose(const CGHeroInstance * hero) const
  28. {
  29. return Goals::sptr(Goals::CompleteQuest(questInfo));
  30. }
  31. void QuestAction::execute(const CGHeroInstance * hero) const
  32. {
  33. ai->moveHeroToTile(questInfo.obj->visitablePos(), hero);
  34. }
  35. std::string QuestAction::toString() const
  36. {
  37. return "Complete Quest";
  38. }
  39. }
  40. }