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/CHeroHandler.h"
|
||||||
#include "../lib/mapObjects/CGHeroInstance.h"
|
#include "../lib/mapObjects/CGHeroInstance.h"
|
||||||
#include "../lib/NetPacksBase.h"
|
#include "../lib/NetPacksBase.h"
|
||||||
|
#include "../mapHandler.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CHeroWindow.cpp, part of VCMI engine
|
* 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)
|
if(!LOCPLINT->cb->howManyTowns() && LOCPLINT->cb->howManyHeroes() == 1)
|
||||||
noDismiss = true;
|
noDismiss = true;
|
||||||
|
|
||||||
|
if(curHero->isMissionCritical())
|
||||||
|
noDismiss = true;
|
||||||
|
|
||||||
dismissButton->block(!!curHero->visitedTown || noDismiss);
|
dismissButton->block(!!curHero->visitedTown || noDismiss);
|
||||||
|
|
||||||
if(curHero->getSecSkillLevel(SecondarySkill::TACTICS) == 0)
|
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
|
//funtion written from scratch since it's accessed A LOT by AI
|
||||||
|
|
||||||
|
if(!color.isValidPlayer())
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
auto player = gs->players.find(color);
|
auto player = gs->players.find(color);
|
||||||
if (player != gs->players.end())
|
if (player != gs->players.end())
|
||||||
{
|
{
|
||||||
@ -964,4 +968,3 @@ void IGameEventRealizer::setObjProperty(ObjectInstanceID objid, int prop, si64 v
|
|||||||
sob.val = static_cast<ui32>(val);
|
sob.val = static_cast<ui32>(val);
|
||||||
commitPackage(&sob);
|
commitPackage(&sob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2268,7 +2268,7 @@ EVictoryLossCheckResult CGameState::checkForVictoryAndLoss(PlayerColor player) c
|
|||||||
|
|
||||||
for (const TriggeredEvent & event : map->triggeredEvents)
|
for (const TriggeredEvent & event : map->triggeredEvents)
|
||||||
{
|
{
|
||||||
if ((event.trigger.test(evaluateEvent)))
|
if (event.trigger.test(evaluateEvent))
|
||||||
{
|
{
|
||||||
if (event.effect.type == EventEffect::VICTORY)
|
if (event.effect.type == EventEffect::VICTORY)
|
||||||
return EVictoryLossCheckResult::victory(event.onFulfill, event.effect.toOtherMessage);
|
return EVictoryLossCheckResult::victory(event.onFulfill, event.effect.toOtherMessage);
|
||||||
@ -2285,7 +2285,7 @@ EVictoryLossCheckResult CGameState::checkForVictoryAndLoss(PlayerColor player) c
|
|||||||
return EVictoryLossCheckResult();
|
return EVictoryLossCheckResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CGameState::checkForVictory( PlayerColor player, const EventCondition & condition ) const
|
bool CGameState::checkForVictory(PlayerColor player, const EventCondition & condition) const
|
||||||
{
|
{
|
||||||
const PlayerState *p = CGameInfoCallback::getPlayer(player);
|
const PlayerState *p = CGameInfoCallback::getPlayer(player);
|
||||||
switch (condition.condition)
|
switch (condition.condition)
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "../CCreatureHandler.h"
|
#include "../CCreatureHandler.h"
|
||||||
#include "../BattleState.h"
|
#include "../BattleState.h"
|
||||||
#include "../CTownHandler.h"
|
#include "../CTownHandler.h"
|
||||||
|
#include "../mapping/CMap.h"
|
||||||
#include "CGTownInstance.h"
|
#include "CGTownInstance.h"
|
||||||
|
|
||||||
///helpers
|
///helpers
|
||||||
@ -1454,3 +1455,27 @@ bool CGHeroInstance::hasVisions(const CGObjectInstance * target, const int subty
|
|||||||
|
|
||||||
return (distance < visionsRange) && (target->pos.z == pos.z);
|
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 CHero;
|
||||||
class CGBoat;
|
class CGBoat;
|
||||||
class CGTownInstance;
|
class CGTownInstance;
|
||||||
|
class CMap;
|
||||||
struct TerrainTile;
|
struct TerrainTile;
|
||||||
struct TurnInfo;
|
struct TurnInfo;
|
||||||
|
|
||||||
@ -211,6 +212,8 @@ public:
|
|||||||
void updateSkill(SecondarySkill which, int val);
|
void updateSkill(SecondarySkill which, int val);
|
||||||
|
|
||||||
bool hasVisions(const CGObjectInstance * target, const int subtype) const;
|
bool hasVisions(const CGObjectInstance * target, const int subtype) const;
|
||||||
|
/// If this hero perishes, the scenario is failed
|
||||||
|
bool isMissionCritical() const;
|
||||||
|
|
||||||
CGHeroInstance();
|
CGHeroInstance();
|
||||||
virtual ~CGHeroInstance();
|
virtual ~CGHeroInstance();
|
||||||
|
Loading…
Reference in New Issue
Block a user