Detect when a tile is discovered?


Mar 18, 2023
I'm making a mod where after adopting a social policy, the player will get +1 gold or culture or something whenever they discover a new tile. Detecting when a player discovers a new tile is hard.

Using DLL - VMC there is an event, GameEvents.TileRevealed, which triggers when a unit gains sight over a tile previously hidden by the fog of war (but still a discovered tile). I can use this to detect if the tile was revealed for the first time by any player, but not if it was revealed for the first time by specifically the player who revealed it sadly.

In the base game there is an method Plot.IsVisible which I believe returns true if the a player has discovered the tile (given that there is another method called IsRevealed). But the logic for keeping track of every tile that every unit might have sight of on its next move is a nightmare I do not want to deal with.

I would like to detect when a player reveals a tile for their first time, regardless of whether or not other players have discovered it. Does anyone know a way to do this?
See my "Global - XP For Scouting" mod, it probably does most of what you want.

Note, the CustomMods.h file gives five parameters for the TileRevealed event, there are actually seven
// GameEvents.TileRevealed.Add(function(iPlotX, iPlotY, iTeam, iFromTeam, bFirst, iPlayer, iUnit) end)
Thank you, that mod is very cool and helpful. It does indeed do most of what I want.

In the source code for your DLL, the bFirst parameter passed in reads "(kTeam.isMajorCiv() && iRevealedMajors == 0)"
Which would indicate bFirst is true if any major team has discovered it.

I want to detect whether or not the specific team the player scouting is part of has already discovered it.

Also I do not understand what is passed into eFromTeam, this value seems to always be -1 when I print it out.
If bFirst is true, then Players[iPlayer]:GetTeam() (or something like that) will get you the team of the unit that has just discovered it
eFromTeam is a parameter passed into the method, however it must have been something left over from a previous version of the Civ code base as it is never used
Top Bottom