1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-04-09 07:13:54 +02:00

Merge pull request #517 from nullkiller/freeze-on-quest-selfkilling

Hero try to execute a quest to kill himself
This commit is contained in:
Alexander Shishkin 2018-11-06 03:12:53 +03:00 committed by GitHub
commit d36f59e1af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2469,7 +2469,6 @@ Goals::TSubgoal VCAI::questToGoal(const QuestInfo & q)
}
return sptr(Goals::FindObj(Obj::PRISON)); //rule of a thumb - quest heroes usually are locked in prisons
//BNLOG ("Don't know how to recruit hero with id %d\n", q.quest->m13489val);
break;
}
case CQuest::MISSION_ARMY:
{
@ -2513,11 +2512,27 @@ Goals::TSubgoal VCAI::questToGoal(const QuestInfo & q)
case CQuest::MISSION_KILL_CREATURE:
{
auto obj = cb->getObjByQuestIdentifier(q.quest->m13489val);
if (obj)
return sptr(Goals::VisitObj(obj->id.getNum()));
else
if(!obj)
return sptr(Goals::VisitObj(q.obj->id.getNum())); //visit seer hut
break;
if(obj->ID == Obj::HERO)
{
auto relations = myCb->getPlayerRelations(playerID, obj->tempOwner);
if(relations == PlayerRelations::SAME_PLAYER)
{
auto heroToProtect = cb->getHero(obj->id);
return sptr(Goals::GatherArmy().sethero(heroToProtect));
}
else if(relations == PlayerRelations::ALLIES)
{
break;
}
}
return sptr(Goals::VisitObj(obj->id.getNum()));
}
case CQuest::MISSION_PRIMARY_STAT:
{