Plot discovery

How can I detect when a plot is discovered by a player?

Try Plot:IsRevealed
which unfortunately only works with a teamID as its argument, not playerID

It gets used alot in the vanilla lua files, so you can do a search for it to see how it works.
 
I need to detect when a plot is discovered, not if a plot has been discovered. My goal was to fix Spain's trait so it scales to era. I found an event NaturalWonderRevealed, but it appears to only work for the active player. I could do the bonus at the end of the turn... though that wouldn't be quite as nice as immediately upon discovery. I figured there might be some sort of generic 'plot discovered' event since the UI has to know that to hide/show things like unit flags... but it appears that might all be called from the c++. :think:
 
In the API there are those 2 events listed : HexFOWStateChanged and VisibilityUpdated

with this example in the game tutorial lua for the first :

Spoiler :
Code:
function OnHexFogEvent( hexPos, fowType, bWholeMap )

	local BlackFog = 0; -- invisible
	local GreyFog  = 1; -- once seen
	local WhiteFog = 2; -- eyes on

	if (fowType == WhiteFog) then
		local gridPosX, gridPosY = ToGridFromHex( hexPos.x, hexPos.y );
		local pPlot = Map.GetPlot( gridPosX, gridPosY );	
		if (pPlot ~= nil) then
			if (pPlot:GetFeatureType() == FeatureTypes.FEATURE_FOREST) then
				pForestRevealedPlot = pPlot;
			elseif (pPlot:GetFeatureType() == FeatureTypes.FEATURE_MARSH) then
				pMarshRevealedPlot = pPlot;
			elseif (pPlot:GetFeatureType() == FeatureTypes.FEATURE_JUNGLE) then
				pJungleRevealedPlot = pPlot;
			end
				
			if (pPlot:IsHills()) then
				pHillRevealedPlot = pPlot;
			elseif (pPlot:IsMountain()) then
				pMountainRevealedPlot = pPlot;
			end
			
			if (pPlot:IsRiver()) then
				pRiverRevealedPlot = pPlot;
			end
		end
	end
end
Events.HexFOWStateChanged.Add( OnHexFogEvent );

But I don't know if this is called only for the human player... (and you'll have to keep tracks of plots visibility...)

I'm marking this thread anyway, as I'll have to use something like this soon :)
 
I tested that one and it also appears to work only for the active player. VisibilityUpdated isn't used anywhere... once I get access to the game again I'll try printing out its arg table to figure out what parameters it has.
 
just tested, seems to be only for the active player too, returning a box of tiles visible on screen (x1, y1 , x2, y2) and 4 others values I have not tested.
 
I suppose you might infer a plot has been discovered by tracking plots a player has entered with a unit... then iterating the plots with line of sight around that unit and recording them in a "discovered plot" table. I'm not certain if the api gives all the information needed to do this, but it otherwise might be doable.

BTW not a lua expert, just speculating on a possible work around.
 
If you're using mine or the CPP DLL

Code:
    <!-- Event sent when a plot is revealed (v58) -->
    <!--   GameEvents.TileRevealed.Add(function(iPlotX, iPlotY, iTeam, iFromTeam, bFirst) end) -->
    <Row Class="3" Name="EVENTS_TILE_REVEALED" Value="0"/>

    <!-- Event sent when the team discovers a new Natural Wonder (v19) -->
    <!--   GameEvents.NaturalWonderDiscovered.Add(function(iTeam, iFeature, iX, iY, bFirst) end) -->
    <Row Class="3" Name="EVENTS_NW_DISCOVERY" Value="0"/>
 
Back
Top Bottom