• Civilization 7 has been announced. For more info please check the forum here .

Help please on how to Update a Building bestowing extras at the end of an Era?

JA_Lamb

Warlord
Joined
Aug 19, 2009
Messages
253
Location
The changing Dark Continent
For example a Building bestows a FreeSpecialist. End this at end of Medieval Era.
or change Yields at end of Era?

Code:
<Update>
   <Where BuildingType="BUILDING_AGORA" EraType="RENAISSANCE" SpecialistType="SPECIALIST_SCIENTIST />
   <Set Count="0"/>
</Update> 
<Update>
   <Where BuildingType="BUILDING_MONUMENT" EraType="RENAISSANCE" YieldType="YIELD_CULTURE />
   <Set Yield="0"/>
</Update>

Because it didn't work for me. what I got from Database.log is this:

------------------------------
[161509.129] no such table: ContentPackage.LocalizedText
[161511.423] no such table: ContentPackage.LocalizedText
[161514.262] PRIMARY KEY must be unique
[161514.262] PRIMARY KEY must be unique
[161560.095] Validating Foreign Key Constraints...
[161561.249] Passed Validation.
[161561.811]
-- SQLite Memory Statistics --

Any suggestions please?
 
<Building_FreeSpecialistCounts>
and
<Building_YieldChanges>
 
Any suggestions please?
Don't make it up as you go along ;)

Code:
<Update>
   <Where BuildingType="BUILDING_AGORA" EraType="RENAISSANCE" SpecialistType="SPECIALIST_SCIENTIST />
   <Set Count="0"/>
</Update>

Building_FreeSpecialistCounts doesn't have an EraType column
Code:
<Table name="Building_FreeSpecialistCounts">
  <Column name="BuildingType" type="text" reference="Buildings(Type)"/>
  <Column name="SpecialistType" type="text" reference="Specialists(Type)"/>
  <Column name="Count" type="integer"/>
/Table>

Code:
<Update>
   <Where BuildingType="BUILDING_MONUMENT" EraType="RENAISSANCE" YieldType="YIELD_CULTURE />
   <Set Yield="0"/>
</Update>

Neither does Building_YieldChanges

Code:
<Table name="Building_YieldChanges">
  <Column name="BuildingType" type="text" reference="Buildings(Type)"/>
  <Column name="YieldType" type="text" reference="Yields(Type)"/>
  <Column name="Yield" type="integer"/>
</Table>
 
OFCOURSE, mea culpa total inattention to inter-dependacies. But then how do I stop a building either by Era? or by Tech? round about a particular period?
 
But then how do I stop a building either by Era? or by Tech? round about a particular period?

The usual suspect, ie the (Lua) GameEvent.CityCanConstruct() hook
 
Pouakai -

does Building_FreeSpecialistCount allow for different specialists

Yes it does. See below, no crashes yet. ;)

The Update is commented out to remind me that I must do something about it. :lol:
but it works without the update. The Lua I have been advised to use is a bit of a steep hill for me at this stage.

Spoiler :

Code:
<Building_FreeSpecialistCounts>
		<Row>
			<BuildingType>BUILDING_AGORA</BuildingType>
			<SpecialistType>SPECIALIST_SCIENTIST</SpecialistType>
			<Count>1</Count>
		</Row>
		<Row>
			<BuildingType>BUILDING_AGORA</BuildingType>
			<SpecialistType>SPECIALIST_ARTIST</SpecialistType>
			<Count>1</Count>
		</Row>
		<!--
		<Update>
			<Where BuildingType="BUILDING_AGORA" EraType="RENAISSANCE" SpecialistType="SPECIALIST_SCIENTIST />
			<Set Count="0"/>
		</Update><!-- Nerfing UB --
		<Update>
			<Where BuildingType="BUILDING_AGORA" EraType="RENAISSANCE" SpecialistType="SPECIALIST_ARTIST />
			<Set Count="0"/>
		</Update><!-- Nerfing UB -->
	</Building_FreeSpecialistCounts>


Mr. wHoward -

The usual suspect, ie the (Lua) GameEvent.CityCanConstruct() hook

Just as I feared :sad: this will take me some time to assimilate on top of everything else I want to accomplish. Thank you.
 
But then how do I stop a building either by Era? or by Tech? round about a particular period?
When you say "stop", do you make the building unable to be build, or the building no longer having an effect, or both?

Kael lists an XML-tag in his modder's guide:
Code:
<MaxStartEra>ERA_ANCIENT</MaxStartEra>
I haven't tested this tag, but according to his description, this will make it so that the building can only be build in Ancient era (my logic would have said that it ment that you can only build it in games starting in Ancient era, but I haven't tested it, and this is what he writes: "...and can't be built in any era except the Ancient Era").

If you want a building to go obsolete with time, you can tie this up to a particular Tech through XML, here taken from Great Wall:
Code:
<ObsoleteTech>TECH_DYNAMITE</ObsoleteTech>

You can also change the yields of a building with time through XML, you'll have to add to the building entry a definition of what Tech changes the building:
Code:
	<Buildings>
		<Update>
			<Where Type="BUILDING_SHRINE"/>
			<Set>
				<EnhancedYieldTech>TECH_ARCHEOLOGY</EnhancedYieldTech>
			</Set>
		</Update>
	</Buildings>

And then you need to define how the yield changes:
Code:
	<Building_TechEnhancedYieldChanges>
		<Row>
			<BuildingType>BUILDING_SHRINE</BuildingType>
			<YieldType>YIELD_CULTURE</YieldType>
			<Yield>1</Yield>
		</Row>
	</Building_TechEnhancedYieldChanges>

I reckon you can put in a negative yield if you want to decrease the original yield of the building, I know for fact that other places of the game accept negative yields, but I haven't tested this one.

I don't know if this will help you in what you wish to accomplish.
 
Kaspergm thank you. Must be having mental blocks these days.

I already use the <EnhancedYieldTech> tag while the building is still operable. What I didn't think of doing is to Update the previous Update. Thanks.

BTW the <ObsoleteTech> Tag kills everything of the building, while I only want to decouple part of it's operations. But your Update of an Update is perfect. I'll try and let you know. Thanks. :goodjob:
 
Nope, these Tags are static and load @ beginning of Game. They'll just step over each other in trully Civ fashion and the last one will remain to play with.

wHoward is right what I need is dynamic in the middle of the game to change what worked halfway through. Although it was sooo close, I may give it some time to see if I can do something else.
 
OK it did take me about an hours worth of more thinking until I finally got what was your problem (yeah, not too fast here on a sunday evening) but yes, too bad we can't add two consecutive Enhance techs.

About the obsolete tag killing everything, will that mean if I try to add an EnhanceTechYield to Great Wall to give it some culture after Dynamites, that will be overruled by the obsolete tag? If so, too bad.
 
Yes, this is vintage Firaxis/Civ. the last file/entry upload oversteps the previous. Main reason of Mod incompatibility in Civ4. They really tried to address this issue in Civ5, but the tools they gave us are so... dissatisfacory and require so much learning input that it takes a lot of the fun away from modding unless one is a professional. Anyway enough bi**g forward Ho!

I think that if your Enhance TechYield takes place after the obsolete Tech kicks in it will work.

My experience was with the old Colossus who used to stop giving the Gold and GreatMerchant points when obsolete, but continued to give some 1 Culture throughout.
 
Will this work?

AGORA exchanged for normal MARKET @ end of Middle Ages


Code:
local bAGORA = GameInfoTypes.BUILDING_AGORA
local bMARKET = GameInfoTypes.BUILDING_MARKET
local bERA = GameInfoTypes.ERA_RENAISSANCE

GameEvents.CityCanConstruct.Add(function(iPlayer, iCity, iBuilding) 
	local pPlayer = Players[iPlayer];
	local pCity = pPlayer:GetCityByID(iCity);
	local cPlot = pCity:Plot()
	local iCurrentEra = pPlayer:GetCurrentEra();				-- 1ST check Player is @ Era=Renaissance

		if (iCurrentEra <= bERA ) then return; end				-- If CurrentEra less than Renaissance END IT here.
		
			if (pCity:IsHasBuilding(bAGORA)) then				-- If City has AGORA
				pCity:SetNumRealBuilding(bMARKET, 1);			-- Add MARKET
				pCity:SetNumRealBuilding(bAGORA, -1);			-- Remove AGORA and all Philosophy boosts.
			end
		end
	end
end	)

Trying to follow wHowards advise.

The usual suspect, ie the (Lua) GameEvent.CityCanConstruct() hook
Very shaky on above code. How do I end it for the GameEvent. to work?
 
No Agora should be <MaxStartEra>MEDIEVAL in XML. Here it's supposed to be replaced by a normal MARKET in Renaissance and later ERAS.
 
Top Bottom