mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Fix cursor & add way to access danger info for HotA-like DD cursor
This commit is contained in:
parent
f51e1a0ba6
commit
3f94d316cb
@ -650,7 +650,19 @@ void AdventureMapInterface::onTileHovered(const int3 &targetPosition)
|
||||
return;
|
||||
case SpellID::DIMENSION_DOOR:
|
||||
if(isValidAdventureSpellTarget(targetPosition, objAtTile, SpellID::DIMENSION_DOOR))
|
||||
{
|
||||
if(VLC->settings()->getBoolean(EGameSettings::DIMENSION_DOOR_TRIGGERS_GUARDS))
|
||||
{
|
||||
auto isGuarded = LOCPLINT->cb->isTileGuardedAfterDimensionDoorUse(targetPosition, LOCPLINT->localState->getCurrentHero());
|
||||
if(isGuarded)
|
||||
{
|
||||
CCS->curh->set(Cursor::Map::T1_ATTACK);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
CCS->curh->set(Cursor::Map::TELEPORT);
|
||||
}
|
||||
else
|
||||
CCS->curh->set(Cursor::Map::POINTER);
|
||||
return;
|
||||
|
@ -287,6 +287,24 @@ std::vector<const CGObjectInstance*> CGameInfoCallback::getGuardingCreatures (in
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool CGameInfoCallback::isTileGuardedAfterDimensionDoorUse(int3 tile, const CGHeroInstance * castingHero) const
|
||||
{
|
||||
//for known tiles this is just potential convenience info, for tiles behind fog of war this info matches HotA but not H3 so make it accessible only with proper setting on
|
||||
bool canAccessInfo = false;
|
||||
|
||||
if(isVisible(tile))
|
||||
canAccessInfo = true;
|
||||
else if(VLC->settings()->getBoolean(EGameSettings::DIMENSION_DOOR_TRIGGERS_GUARDS) //TODO: check if available casts > 0
|
||||
&& isInScreenRange(castingHero->getSightCenter(), tile)
|
||||
&& castingHero->canCastThisSpell(static_cast<SpellID>(SpellID::DIMENSION_DOOR).toSpell()))
|
||||
canAccessInfo = true;
|
||||
|
||||
if(canAccessInfo)
|
||||
return !gs->guardingCreatures(tile).empty();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CGameInfoCallback::getHeroInfo(const CGObjectInstance * hero, InfoAboutHero & dest, const CGObjectInstance * selectedObject) const
|
||||
{
|
||||
const auto * h = dynamic_cast<const CGHeroInstance *>(hero);
|
||||
|
@ -193,6 +193,7 @@ public:
|
||||
//map
|
||||
virtual int3 guardingCreaturePosition (int3 pos) const;
|
||||
virtual std::vector<const CGObjectInstance*> getGuardingCreatures (int3 pos) const;
|
||||
virtual bool isTileGuardedAfterDimensionDoorUse(int3 tile, const CGHeroInstance * castingHero) const;
|
||||
virtual const CMapHeader * getMapHeader()const;
|
||||
virtual int3 getMapSize() const; //returns size of map - z is 1 for one - level map and 2 for two level map
|
||||
virtual const TerrainTile * getTile(int3 tile, bool verbose = true) const;
|
||||
|
@ -1196,7 +1196,7 @@ bool CGameHandler::moveHero(ObjectInstanceID hid, int3 dst, ui8 teleporting, boo
|
||||
sendAndApply(&tmh);
|
||||
|
||||
if (visitDest == VISIT_DEST && objectToVisit && objectToVisit->id == h->id)
|
||||
{ // Hero should be always able to visit any object he staying on even if there guards around
|
||||
{ // Hero should be always able to visit any object he is staying on even if there are guards around
|
||||
visitObjectOnTile(t, h);
|
||||
}
|
||||
else if (lookForGuards == CHECK_FOR_GUARDS && isInTheMap(guardPos))
|
||||
@ -1351,7 +1351,7 @@ void CGameHandler::setOwner(const CGObjectInstance * obj, const PlayerColor owne
|
||||
|
||||
if (oldOwner.isValidPlayer()) //old owner is real player
|
||||
{
|
||||
if (getPlayerState(oldOwner)->towns.empty() && getPlayerState(oldOwner)->status != EPlayerStatus::LOSER) //previous player lost last last town
|
||||
if (getPlayerState(oldOwner)->towns.empty() && getPlayerState(oldOwner)->status != EPlayerStatus::LOSER) //previous player lost last town
|
||||
{
|
||||
InfoWindow iw;
|
||||
iw.player = oldOwner;
|
||||
|
Loading…
Reference in New Issue
Block a user