I've been looking through the SDK trying to figure out how tile visibility/revealedness works, and how to change it. I've found CvPlot::isRevealed() and CvCity::isRevealed(), as well as CvPlot::isVisible() and CvCity::isVisible(). The problem is, I'm not sure I'm using them properly.
The idea is to share vision with a friendly civ, something like in Starcraft or whatnot. So in CvPlot::isVisible() I put:
and in CvPlot::isRevealed() & CvCity::isRevealed():
This has the interesting effect of showing friends' units as they explore the map, but not actually 'revealing' the map, meaning units wander about over black tiles. When mousing over, the terrain info is revealed, but the map itself isn't (see the pic). Also, once the 'friendship' is broken (isFriendOf() no longer returns true for the player), all the benefits are lost: any territory previously visible only to the friend vanishes from the player's map.
Changing isRevealed() and isVisible() is a poor solution to this problem. Ideally, whenever a friend moves a unit, expands culture, etc.--anything that reveals/makes visible a map square--I'd like to also update the *player's* actual map. But I can't figure out how to do this, in Python or the SDK. Any suggestions?
The idea is to share vision with a friendly civ, something like in Starcraft or whatnot. So in CvPlot::isVisible() I put:
Code:
for (int iI = 0; iI < MAX_PLAYERS; iI++)
{
if (GET_PLAYER(GET_TEAM(eTeam).getLeaderID()).isFriendOf((PlayerTypes)iI))
{
if ((getVisibilityCount(GET_PLAYER((PlayerTypes)iI).getTeam()) > 0) || (getStolenVisibilityCount(GET_PLAYER((PlayerTypes)iI).getTeam()) > 0))
return true;
}
}
and in CvPlot::isRevealed() & CvCity::isRevealed():
Code:
for (int iI = 0; iI < MAX_PLAYERS; iI++)
{
if (GET_PLAYER(GET_TEAM(eIndex).getLeaderID()).isFriendOf((PlayerTypes)iI))
{
if (m_abRevealed[GET_PLAYER((PlayerTypes)iI).getTeam()])
return true;
}
}
This has the interesting effect of showing friends' units as they explore the map, but not actually 'revealing' the map, meaning units wander about over black tiles. When mousing over, the terrain info is revealed, but the map itself isn't (see the pic). Also, once the 'friendship' is broken (isFriendOf() no longer returns true for the player), all the benefits are lost: any territory previously visible only to the friend vanishes from the player's map.
Changing isRevealed() and isVisible() is a poor solution to this problem. Ideally, whenever a friend moves a unit, expands culture, etc.--anything that reveals/makes visible a map square--I'd like to also update the *player's* actual map. But I can't figure out how to do this, in Python or the SDK. Any suggestions?