mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
Fix 2160 dismissing a VIP hero
This commit is contained in:
parent
4483c45905
commit
9f3313524e
@ -28,6 +28,7 @@
|
||||
#include "../lib/CHeroHandler.h"
|
||||
#include "../lib/mapObjects/CGHeroInstance.h"
|
||||
#include "../lib/NetPacksBase.h"
|
||||
#include "../mapHandler.h"
|
||||
|
||||
/*
|
||||
* CHeroWindow.cpp, part of VCMI engine
|
||||
@ -275,6 +276,9 @@ void CHeroWindow::update(const CGHeroInstance * hero, bool redrawNeeded /*= fals
|
||||
if(!LOCPLINT->cb->howManyTowns() && LOCPLINT->cb->howManyHeroes() == 1)
|
||||
noDismiss = true;
|
||||
|
||||
if(curHero->isMissionCritical())
|
||||
noDismiss = true;
|
||||
|
||||
dismissButton->block(!!curHero->visitedTown || noDismiss);
|
||||
|
||||
if(curHero->getSecSkillLevel(SecondarySkill::TACTICS) == 0)
|
||||
|
@ -66,6 +66,10 @@ const PlayerState * CGameInfoCallback::getPlayer(PlayerColor color, bool verbose
|
||||
{
|
||||
//funtion written from scratch since it's accessed A LOT by AI
|
||||
|
||||
if(!color.isValidPlayer())
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
auto player = gs->players.find(color);
|
||||
if (player != gs->players.end())
|
||||
{
|
||||
@ -964,4 +968,3 @@ void IGameEventRealizer::setObjProperty(ObjectInstanceID objid, int prop, si64 v
|
||||
sob.val = static_cast<ui32>(val);
|
||||
commitPackage(&sob);
|
||||
}
|
||||
|
||||
|
@ -2268,7 +2268,7 @@ EVictoryLossCheckResult CGameState::checkForVictoryAndLoss(PlayerColor player) c
|
||||
|
||||
for (const TriggeredEvent & event : map->triggeredEvents)
|
||||
{
|
||||
if ((event.trigger.test(evaluateEvent)))
|
||||
if (event.trigger.test(evaluateEvent))
|
||||
{
|
||||
if (event.effect.type == EventEffect::VICTORY)
|
||||
return EVictoryLossCheckResult::victory(event.onFulfill, event.effect.toOtherMessage);
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "../CCreatureHandler.h"
|
||||
#include "../BattleState.h"
|
||||
#include "../CTownHandler.h"
|
||||
#include "../mapping/CMap.h"
|
||||
#include "CGTownInstance.h"
|
||||
|
||||
///helpers
|
||||
@ -1454,3 +1455,27 @@ bool CGHeroInstance::hasVisions(const CGObjectInstance * target, const int subty
|
||||
|
||||
return (distance < visionsRange) && (target->pos.z == pos.z);
|
||||
}
|
||||
|
||||
bool CGHeroInstance::isMissionCritical() const
|
||||
{
|
||||
for(const TriggeredEvent & event : IObjectInterface::cb->getMapHeader()->triggeredEvents)
|
||||
{
|
||||
if(event.trigger.test([&](const EventCondition & condition)
|
||||
{
|
||||
if (condition.condition == EventCondition::CONTROL && condition.object)
|
||||
{
|
||||
auto hero = dynamic_cast<const CGHeroInstance*>(condition.object);
|
||||
return (hero != this);
|
||||
}
|
||||
else if(condition.condition == EventCondition::IS_HUMAN)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
class CHero;
|
||||
class CGBoat;
|
||||
class CGTownInstance;
|
||||
class CMap;
|
||||
struct TerrainTile;
|
||||
struct TurnInfo;
|
||||
|
||||
@ -211,6 +212,8 @@ public:
|
||||
void updateSkill(SecondarySkill which, int val);
|
||||
|
||||
bool hasVisions(const CGObjectInstance * target, const int subtype) const;
|
||||
/// If this hero perishes, the scenario is failed
|
||||
bool isMissionCritical() const;
|
||||
|
||||
CGHeroInstance();
|
||||
virtual ~CGHeroInstance();
|
||||
|
Loading…
Reference in New Issue
Block a user