2 improvements in one tile?

dartmor

Chieftain
Joined
Oct 23, 2010
Messages
55
Location
Russia
For some tricky modification, i need Worker to be able to
1. to have Improvement button, available only when basic improvement on tile is done, than can be clicked - i need only button
2. Be animated for few turns as if he is making improvement - i need only the animation


So the easiest way i guess is to:
1. Create new Improvement, than will be grayed out until basic improvement is done - this way i get the button
2. This new Improvement can be built on basic Improvement without destroying it, but i can destroy this new Improvement through lua - without touching normal basic improvement - this way i have my animation

So, is it possible and how to do that?
 
I've not tested this myself, but you can try to look at the following Improvements table:
Code:
<Improvement_ValidImprovements>
	<Row>
		<ImprovementType>IMPROVEMENT_LANDMARK</ImprovementType>
		<PrereqImprovement>IMPROVEMENT_ARCHAEOLOGICAL_DIG</PrereqImprovement>
	</Row>
</Improvement_ValidImprovements>

It may or may not work as you want it to, but it's about the only example I can see within the base game of an improvement "requiring" another one.
 
It may or may not work as you want it to, but it's about the only example I can see within the base game of an improvement "requiring" another one.

- There can only be 1 (completed) improvement on any given plot on the map.... meaning you can never have 2 improvements on the same tile at once.

- The aforementioned table (Improvement_ValidImprovements) refers to improvements that may be built by a unit if the pre-requisite improvement is present on a tile. The (old) improvement will be removed and replaced by the (new) improvement once the build is complete.

- As a side note: roads/Railroads are not treated as "improvements" by the game engine (actually something entirely different), even though various bits and pieces of the UI text seem to lump them in with the rest of the "real" improvements.

That being said, couldn't you just make an improvement (that does nothing, and takes something stupid like 10,000 turns to build) and just assign your worker to build that instead? No need to use lua for it.
 
I haven't delved into the DLL (don't have the energy to do so, so I'll have to take the word of others who enjoy diving into that mess) but it sounds like what he wants.

You can simply make a secondary improvement "require" the old one, but have exactly the same model. It sounds like it will automatically handle the build action being available or unavailable to the Workers.

As far as roads and railroads go, yeah, they are "Routes" to the game, I suppose.
 
One problem with the "improvement requires another improvement" code the Landmark uses is that once you start building the new improvement, the old one is removed. This isn't an issue for the Landmark, or any other improvement that can be built instantly, because they appear in the same turn as construction starts. But for any improvement that takes multiple turns to build, construction will stop in the next turn, because the required improvement no longer exists...
 
What's wrong?

Code:
<GameData>
	<Routes>
		<Row>
			<Type>ROUTE_NEW_ROAD</Type>
			<Description>TXT_KEY_ROUTE_ROAD</Description>
			<Value>1</Value>
			<AdvancedStartCost>12</AdvancedStartCost>
			<Civilopedia>TXT_KEY_CIV5_IMPROVEMENTS_ROAD_TEXT</Civilopedia>
			<PortraitIndex>40</PortraitIndex>
			<IconAtlas>TERRAIN_ATLAS</IconAtlas>
		</Row>
	</Routes>
</GameData>

Code:
<GameData>
	<Builds>
		<Row>
			<Type>BUILD_NEW_ROAD</Type>
			<Time>400</Time>
			<RouteType>ROUTE_NEW_ROAD</RouteType>
			<Description>TXT_KEY_BUILD_ROAD</Description>
			<Help>TXT_KEY_BUILD_ROAD_HELP</Help>
			<Recommendation>TXT_KEY_BUILD_ROAD_REC</Recommendation>
			<EntityEvent>ENTITY_EVENT_SHOVEL</EntityEvent>
			<HotKey>KB_R</HotKey>
			<CtrlDownAlt>1</CtrlDownAlt>
			<OrderPriority>95</OrderPriority>
			<IconIndex>24</IconIndex>
			<IconAtlas>UNIT_ACTION_ATLAS</IconAtlas>
		</Row>
	</Builds>
</GameData>

Code:
<GameData>
	<Unit_Builds>
		<Row>
			<UnitType>UNIT_WORKER</UnitType>
			<BuildType>BUILD_NEW_ROAD</BuildType>
		</Row>
	</Unit_Builds>
</GameData>
 
Ok, problem solved. Instead of
<RouteType>ROUTE_NEW_ROAD</RouteType>
i should use
<RouteType>ROUTE_ROAD</RouteType>
because it's not possible to create new route type as far as i can tell.

So i did this:
Code:
<GameData>
	<Unit_Builds>
		<Row>
			<UnitType>UNIT_WORKER</UnitType>
			<BuildType>BUILD_ROAD</BuildType>
		</Row>
		<Row>
			<UnitType>UNIT_WORKER</UnitType>
			<BuildType>BUILD_NEW_ROAD</BuildType>
		</Row>
	</Unit_Builds>
</GameData>
Code:
<GameData>
	<Builds>
		<Row>
			<Type>BUILD_NEW_ROAD</Type>
			<Time>400</Time>
			<RouteType>ROUTE_ROAD</RouteType>
			<Description>TXT_KEY_BUILD_ROAD</Description>
			<Help>TXT_KEY_BUILD_ROAD_HELP</Help>
			<Recommendation>TXT_KEY_BUILD_ROAD_REC</Recommendation>
			<HotKey>KB_R</HotKey>
			<CtrlDownAlt>1</CtrlDownAlt>
			<OrderPriority>95</OrderPriority>
			<IconIndex>24</IconIndex>
			<IconAtlas>UNIT_ACTION_ATLAS</IconAtlas>
		</Row>
	</Builds>
</GameData>

And now Worker has 2 buttons for road.

But now i have to invent a way to define when Worker build a simple road or my special "road", because basically it's the same Route type. My pseudo-code:
Code:
Events.SerialEventRoadCreated (hexX, hexY, player, routeType, unit, road?
local player = Players[Game.GetActivePlayer()]
local unit = Units[Game.GetActiveUnit()] < ??? not sure how to
local road = new road?

if road = new road
then unit:get'promotion
	end

destroy this road

end)

I want worker to receive special promotion, when it builds new "road". The main question is how to define when worker builds exactly new "road", not a standard one? creating new route type ( as seen in a post above ) - doesn't work

is it's not possible, then i need to somehow create new route type, or do the same thing with improvement instead of road
by the way, because it's the same route type - i can't build it twice? so my new "road" won't be available to build if there is already a normal road

so maybe i should think about using one of improvements to do this

oooooooooor i can simply give special promotion every time when unit builds needed improvement, and later player just replace that improvement with the same one - to get special promotion again

then my very pseudo -code would be
Code:
Events.SerialEventImprovementCreated(hexX, hexY, continent1,continent2, player, createImprovementType, ImprovementType createImprovementRRType, createImprovementEra,createImprovementState, unknown ImprovementEra = nil)
local player = Players[Game.GetActivePlayer()]
local unit = Units[Game.GetActiveUnit()]
local impType = Farm
local resourceType = Wheat

if unit:farm on wheat
then unit:get promotion
	end
end)
 
Back
Top Bottom