|
@@ -2170,26 +2170,26 @@ void VCAI::striveToGoal(const CGoal &ultimateGoal)
|
|
|
|
|
|
void VCAI::striveToQuest (const QuestInfo &q)
|
|
|
{
|
|
|
- if (q.quest && q.quest->progress < CQuest::COMPLETE)
|
|
|
+ if (q.quest.progress < CQuest::COMPLETE)
|
|
|
{
|
|
|
MetaString ms;
|
|
|
- q.quest->getRolloverText(ms, false);
|
|
|
+ q.quest.getRolloverText(ms, false);
|
|
|
BNLOG ("Trying to realize quest: %s", ms.toString());
|
|
|
auto heroes = cb->getHeroesInfo();
|
|
|
|
|
|
- switch (q.quest->missionType)
|
|
|
+ switch (q.quest.missionType)
|
|
|
{
|
|
|
case CQuest::MISSION_ART:
|
|
|
{
|
|
|
BOOST_FOREACH (auto hero, heroes) //TODO: remove duplicated code?
|
|
|
{
|
|
|
- if (q.quest->checkQuest(hero))
|
|
|
+ if (q.quest.checkQuest(hero))
|
|
|
{
|
|
|
striveToGoal (CGoal(GET_OBJ).setobjid(q.obj->id).sethero(hero));
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
- BOOST_FOREACH (auto art, q.quest->m5arts)
|
|
|
+ BOOST_FOREACH (auto art, q.quest.m5arts)
|
|
|
{
|
|
|
striveToGoal (CGoal(GET_ART_TYPE).setaid(art)); //TODO: transport?
|
|
|
}
|
|
@@ -2200,7 +2200,7 @@ void VCAI::striveToQuest (const QuestInfo &q)
|
|
|
//striveToGoal (CGoal(RECRUIT_HERO));
|
|
|
BOOST_FOREACH (auto hero, heroes)
|
|
|
{
|
|
|
- if (q.quest->checkQuest(hero))
|
|
|
+ if (q.quest.checkQuest(hero))
|
|
|
{
|
|
|
striveToGoal (CGoal(GET_OBJ).setobjid(q.obj->id).sethero(hero));
|
|
|
return;
|
|
@@ -2214,13 +2214,13 @@ void VCAI::striveToQuest (const QuestInfo &q)
|
|
|
{
|
|
|
BOOST_FOREACH (auto hero, heroes)
|
|
|
{
|
|
|
- if (q.quest->checkQuest(hero)) //veyr bad info - stacks can be split between multiple heroes :(
|
|
|
+ if (q.quest.checkQuest(hero)) //veyr bad info - stacks can be split between multiple heroes :(
|
|
|
{
|
|
|
striveToGoal (CGoal(GET_OBJ).setobjid(q.obj->id).sethero(hero));
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
- BOOST_FOREACH (auto creature, q.quest->m6creatures)
|
|
|
+ BOOST_FOREACH (auto creature, q.quest.m6creatures)
|
|
|
{
|
|
|
striveToGoal (CGoal(GATHER_TROOPS).setobjid(creature.type->idNumber).setvalue(creature.count));
|
|
|
}
|
|
@@ -2232,16 +2232,16 @@ void VCAI::striveToQuest (const QuestInfo &q)
|
|
|
{
|
|
|
if (heroes.size())
|
|
|
{
|
|
|
- if (q.quest->checkQuest(heroes.front())) //it doesn't matter which hero it is
|
|
|
+ if (q.quest.checkQuest(heroes.front())) //it doesn't matter which hero it is
|
|
|
{
|
|
|
striveToGoal (CGoal(VISIT_TILE).settile(q.tile));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- for (int i = 0; i < q.quest->m7resources.size(); ++i)
|
|
|
+ for (int i = 0; i < q.quest.m7resources.size(); ++i)
|
|
|
{
|
|
|
- if (q.quest->m7resources[i])
|
|
|
- striveToGoal (CGoal(COLLECT_RES).setresID(i).setvalue(q.quest->m7resources[i]));
|
|
|
+ if (q.quest.m7resources[i])
|
|
|
+ striveToGoal (CGoal(COLLECT_RES).setresID(i).setvalue(q.quest.m7resources[i]));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -2252,7 +2252,7 @@ void VCAI::striveToQuest (const QuestInfo &q)
|
|
|
case CQuest::MISSION_KILL_HERO:
|
|
|
case CQuest::MISSION_KILL_CREATURE:
|
|
|
{
|
|
|
- auto obj = cb->getObjByQuestIdentifier(q.quest->m13489val);
|
|
|
+ auto obj = cb->getObjByQuestIdentifier(q.quest.m13489val);
|
|
|
if (obj)
|
|
|
striveToGoal (CGoal(GET_OBJ).setobjid(obj->id));
|
|
|
else
|
|
@@ -2264,13 +2264,13 @@ void VCAI::striveToQuest (const QuestInfo &q)
|
|
|
auto heroes = cb->getHeroesInfo();
|
|
|
BOOST_FOREACH (auto hero, heroes)
|
|
|
{
|
|
|
- if (q.quest->checkQuest(hero))
|
|
|
+ if (q.quest.checkQuest(hero))
|
|
|
{
|
|
|
striveToGoal (CGoal(GET_OBJ).setobjid(q.obj->id).sethero(hero));
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
- for (int i = 0; i < q.quest->m2stats.size(); ++i)
|
|
|
+ for (int i = 0; i < q.quest.m2stats.size(); ++i)
|
|
|
{
|
|
|
BNLOG ("Don't know how to increase primary stat %d\n", i);
|
|
|
}
|
|
@@ -2281,19 +2281,19 @@ void VCAI::striveToQuest (const QuestInfo &q)
|
|
|
auto heroes = cb->getHeroesInfo();
|
|
|
BOOST_FOREACH (auto hero, heroes)
|
|
|
{
|
|
|
- if (q.quest->checkQuest(hero))
|
|
|
+ if (q.quest.checkQuest(hero))
|
|
|
{
|
|
|
striveToGoal (CGoal(VISIT_TILE).settile(q.tile).sethero(hero)); //TODO: causes infinite loop :/
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
- BNLOG ("Don't know how to reach hero level %d\n", q.quest->m13489val);
|
|
|
+ BNLOG ("Don't know how to reach hero level %d\n", q.quest.m13489val);
|
|
|
break;
|
|
|
}
|
|
|
case CQuest::MISSION_PLAYER:
|
|
|
{
|
|
|
- if (playerID != q.quest->m13489val)
|
|
|
- BNLOG ("Can't be player of color %d\n", q.quest->m13489val);
|
|
|
+ if (playerID != q.quest.m13489val)
|
|
|
+ BNLOG ("Can't be player of color %d\n", q.quest.m13489val);
|
|
|
break;
|
|
|
}
|
|
|
case CQuest::MISSION_KEYMASTER:
|
|
@@ -3467,7 +3467,7 @@ bool shouldVisit(HeroPtr h, const CGObjectInstance * obj)
|
|
|
{
|
|
|
if (q.obj == obj)
|
|
|
{
|
|
|
- if (q.quest->checkQuest(*h))
|
|
|
+ if (q.quest.checkQuest(*h))
|
|
|
return true; //we completed the quest
|
|
|
else
|
|
|
return false; //we can't complete this quest
|