Creating dummy buildings

edge363

Chieftain
Joined
Sep 20, 2014
Messages
22
I would really like either direction towards, or some help with creating a dummy building that is added to all cities connected to the capitol. I feel like I have all of the important stuff done(lol no) but I dont know everything that needs to be done for it to work.

I also thought about just adding the building to all cities and then modifying it so that the palace subtracts the bonuses, but then you wouldn't need the trade routes. Modifying the trait using a trait is just completely out of the question(too limited).

I would adore whoever helps me<3 and give them credit with making meh terrible mod. Haha :D
 
Makes a big difference if you want the dummy building to show in the city "list of buildings", and in that case, whether you are creating a mod for BNW or for Vanilla/G&K. Completely hiding a building is pretty easily done in BNW but not so much for Vanilla/G&K.

I thought you had developed lua code for the city-connected-to-capital requirement (?). Or is that not working ?
 
all expansions. Hidden building for a trait. Only applies to the cities connected to the capitol. Does not need to show up in any information, and be completely hidden from the player.
 
all expansions. Hidden building for a trait. Only applies to the cities connected to the capitol. Does not need to show up in any information, and be completely hidden from the player.
"all expansions" is a problem so far as hiding the building is concerned. As mentioned before, easy in BNW, not so easy in G&K/Vanilla. In BNW, all that is really required to completely hide a building are the following four columns stated as shown within <Buildings>:
Code:
<GameData>
	<Buildings>
		<Row>
			......
			<Cost>-1</Cost>
			<FaithCost>-1</FaithCost>
			<PrereqTech>NULL</PrereqTech>
			<GreatWorkCount>-1</GreatWorkCount>
			......
		</Row>
	</Buildings>
</GameData>
You still need a few other column commands (signified by the "......"), but those four lines are the "heart and soul" of hiding buildings for BNW.

(2) Also, you didn't respond as to whether your lua code for adding buildings to cities connected to the capital was working.

(3) What exactly are you wanting the building to do in terms of yields, etc.?


[edit]You can also look here, though I am not sure that is what you are looking for: Hidden Buildings and accompanying template
 
It is not working. I want it to give happiness and culture, but I would think that modifying the building would easily modify the actual trait.

trait: You receive +2 happiness, and +4 culture for every city connected to the capitol. possibly less or more, but I would like a passive that scales with the size of the empire.
 
Code:
GameEvents.PlayerDoTurn.Add(											  -- Make the following code fire at the beginning of a turn:							
function(playerID)												  -- yay, functions
	local pPlayer = Players[playerID]									  -- who is "pPlayer"?
	if (pPlayer:IsAlive()) then										  -- if pPlayer is alive
		if (pPlayer:GetCivilizationType() == GameInfoTypes.CIVILIZATION_EDGE363_CIV) then		  -- if pPlayer is your new civ
			for pCity in pPlayer:Cities() do							  -- For each of pPlayer's cities:
				if not (pCity:IsCapital()) then							  -- if the city isn't the capital
					if (pPlayer:IsCapitalConnectedToCity(pCity)) then			  -- If the city is connected
						if not (pCity:IsHasBuilding(GameInfoTypes.BUILDING_DUMMY)) then   -- If the city doesn't have a dummy already
							pCity:SetNumRealBuilding(GameInfoTypes.BUILDING_DUMMY, 1) -- Give the city the dummy
						else								  -- if it does though
							return						  -- fuhgeddaboutit
						end							  -- done
					else								  -- if not connected though
						pCity:SetNumRealBuilding(GameInfoTypes.BUILDING_DUMMY, 0)	  -- remove the dummy
					end							          -- a bunch of ends following just to wrap it all up
				end
			end
		end
	end
end)
 
It is not working. I want it to give happiness and culture, but I would think that modifying the building would easily modify the actual trait.

trait: You receive +2 happiness, and +4 culture for every city connected to the capitol. possibly less or more, but I would like a passive that scales with the size of the empire.

In this case, just add <Happiness>2</Happiness> to the building itself (in the same place as the other lines of code above), and add the following table after the end of the Buildings table:

Code:
<GameData>
	<Building_YieldChanges>
		<Row>
			<BuildingType>(Building codename goes here)</BuildingType>
			<YieldType>YIELD_CULTURE</YieldType>
			<Yield>4</Yield>
		</Row>
	</Building_YieldChanges>
</GameData>

Note that you only need one GameData table in an XML file, so it would look like this:

Code:
<?xml version="1.0" encoding="utf-8"?>
<GameData>
	<Buildings>
		<Row>
			<Type>(Building codename goes here)</Type>
			<BuildingClass>(Building Class codename goes here)</BuildingClass>
			<Description>TXT_KEY_(Building codename goes here)</Description>
			<Cost>-1</Cost>
			<PrereqTech>NULL</PrereqTech>
			<GreatWorkCount>-1</GreatWorkCount>
			<FaithCost>-1</FaithCost>
			<Happiness>2</Happiness>
		</Row>
	</Buildings>
	<Building_YieldChanges>
		<Row>
			<BuildingType>(Building codename goes here)</BuildingType>
			<YieldType>YIELD_CULTURE</YieldType>
			<Yield>4</Yield>
		</Row>
	</Building_YieldChanges>
</GameData>
 
local traitBuilding = GameInfoTypes.BUILDING_TRAIT

GameEvents.PlayerDoTurn.Add(
function(iPlayer)
local pPlayer = Players[iPlayer];
if (pPlayer:IsAlive()) then
if (pPlayer:GetCivilizationType() == GameInfoTypes.CIVILIZATION_JEANZ) then
for pCity in pPlayer:Cities() do
if (pCity:GetNumBuilding(traitBuilding) > 0) then
pCity:SetNumRealBuilding(traitBuilding, 0);
end
if (not pCity:IsCapital() and pPlayer:IsCapitalConnectedToCity(pCity) and not pCity:IsBlockaded()) then
pCity:SetNumRealBuilding(traitBuilding, 1);
end
end
end
end
end)

So this is what I already made. The only problem is getting the mod to recognize and use it. I think... From what I can see it is very similar tot he help I received, and I beleive it is not wrong. I am asking in mod buddy, how do I make this file active? do i import it into the virtual file system? link it to the dummy building some how? I do not know. And the guides covering Lua options do not seemingly address this issue directly(or I am to dumb to understand it:crazyeye:)

edit: I also have the building file(which I also think is correct, mayyyyybeeee) SO here is the mod as a whole.
 

Attachments

  • BlueJeanz (v 1).zip
    1.3 MB · Views: 27
To get a Lua file to activate, you generally need to go to the mod's properties in ModBuddy (through the Project tab), then click on Content. Add the Lua file as an InGameUIAddin, and hopefully it should show up properly.

Let me know if my instructions aren't clear, I'll try to make it a bit better if that's the case
 
Ah. You need the lua file to be set in ModBUddy as a "InGameUIAddin". See here for how to do that: whoward69's what ModBuddy setting for what file types tutorial

Sorry I didn't get back to you earlier. RL required me to be away from my computer for a while today. It is getting a little late for me...but if you are still needing a little help, I will be around tomorrow morning USA time.

Whatever progress you have on your mod, even if it doesn't work, attach to a post if you are still having troubles, as shown how here: whoward69's zip your mods and attach tutorial. Much easier to help you by looking at the actual condition of the mod as you've built it, even if it does have errors and mistakes often made by new modders.
 
Edge, correct me if I'm wrong, but I don't think the code you posted will work correctly, because of these two lines:
Code:
local traitBuilding = GameInfoTypes.BUILDING_TRAIT

GameEvents.PlayerDoTurn.Add(
function(iPlayer)
	local pPlayer = Players[iPlayer];
	if (pPlayer:IsAlive()) then
		if (pPlayer:GetCivilizationType() == GameInfoTypes.CIVILIZATION_JEANZ) then
			for pCity in pPlayer:Cities() do
[B][COLOR="Blue"]				if (pCity:GetNumBuilding(traitBuilding) > 0) then
					pCity:SetNumRealBuilding(traitBuilding, 0);[/COLOR][/B]
				end
				if (not pCity:IsCapital() and pPlayer:IsCapitalConnectedToCity(pCity) and not pCity:IsBlockaded()) then
					pCity:SetNumRealBuilding(traitBuilding, 1);
				end
			end
		end
	end
end)
That's syntactically correct and everything, but IINM that will check to see if the city does have a building (greater than 0 of the building type in the city), and if so, it will remove it. I think.
 
Yup. But then the next if chunk should replace it back into the city if the conditions are correct. Also assuming there aren't any syntax errors. Which based on the way the line is structured I'm not entirely sure the leading "not" right after the "if" won't be applied to the entire set of conditions. But I could be very wrong about that...I always have trouble parsing out those combined commands.
 
Ah. You need the lua file to be set in ModBUddy as a "InGameUIAddin". See here for how to do that: whoward69's what ModBuddy setting for what file types tutorial

Sorry I didn't get back to you earlier. RL required me to be away from my computer for a while today. It is getting a little late for me...but if you are still needing a little help, I will be around tomorrow morning USA time.

Whatever progress you have on your mod, even if it doesn't work, attach to a post if you are still having troubles, as shown how here: whoward69's zip your mods and attach tutorial. Much easier to help you by looking at the actual condition of the mod as you've built it, even if it does have errors and mistakes often made by new modders.

I thought I had already uploaded it....hmmmm. I will uploaded it again on this post! But I might be able ot get it to work with all of the great help I have already received.
 

Attachments

  • New Jeanz (v 1).zip
    1.4 MB · Views: 31
LOL. It works, except it gives a free floating gardens(aztecs special water mill building) to a city after it is connected. haha!

Can anybody tell me why?
 
where you have these lines here:
Code:
		</Language_en_US>
	[COLOR="Red"]<?xml version="1.0" encoding="utf-8"?>
	<!-- Created by ModBuddy on 2/24/2013 5:11:29 PM -->
	<GameData>[/COLOR]
		<BuildingClasses>
			<Row>
				<Type>BUILDINGCLASS_TRAIT</Type>
				<DefaultBuilding>BUILDING_TRAIT</DefaultBuilding>
				<Description>TXT_KEY_BUILDING_TRAIT</Description>
			</Row>
		</BuildingClasses>
		<Civilization_BuildingClassOverrides>
			<Row>
				<CivilizationType>CIVILIZATION_BARBARIAN</CivilizationType>
				<BuildingClassType>BUILDINGCLASS_TRAIT_BUILDING</BuildingClassType>
				<BuildingType/>
			</Row>
			<Row>
				<CivilizationType>CIVILIZATION_MINOR</CivilizationType>
				<BuildingClassType>BUILDINGCLASS_TRAIT</BuildingClassType>
				<BuildingType/>
			</Row>
		</Civilization_BuildingClassOverrides>
	[COLOR="red"]</GameData>[/COLOR]
</GameData>
there is already an open <GameData> prior to those lines, so you are going to get failure of the traitBuilding.xml file from syntax errors. The two <GameData> -- </GameData> lines as shown absolutely must be eliminated. You should also get rid of the <?xml version="1.0" encoding="utf-8"?> line since that is never included within <GameData> wraps. I would eliminate these lines:
Code:
<Civilopedia>TXT_KEY_CIV5_BUILDINGS_TRAIT_TEXT</Civilopedia>
<Strategy>TXT_KEY_BUILDING_TRAIT_STRATEGY</Strategy>
<Help>TXT_KEY_BUILDING_TRAIT_HELP</Help>
Since they tend to conflict with hiding the building. As well as these lines here:
Code:
<Row Tag="TXT_KEY_CIV5_BUILDINGS_TRAIT_TEXT">
	<Text>
		<!-- Add Civilopedia text here -->
	</Text>
</Row>
<Row Tag="TXT_KEY_BUILDING_TRAIT_STRATEGY">
	<Text>The Trait Building can only be constructed in a city with an improved source of [ICON_RES_HORSE] Horses or [ICON_RES_IVORY] Ivory nearby. The Trait Building increases a civilization's [ICON_HAPPINESS_1] Happiness.</Text>
</Row>
<Row Tag="TXT_KEY_BUILDING_TRAIT_HELP">
	<Text>City must have an improved source of [ICON_RES_HORSE] Horses or [ICON_RES_IVORY] Ivory nearby.</Text>
</Row>

All you should really need in that file is this:
Code:
<GameData>
	<Buildings>
		<Row>
			<Type>BUILDING_TRAIT</Type>
			<Description>TXT_KEY_BUILDING_TRAIT</Description>
			<Cost>-1</Cost>
			<PrereqTech>NULL</PrereqTech>
			<GreatWorkCount>-1</GreatWorkCount>
			<FaithCost>-1</FaithCost>
			<NeverCapture>true</NeverCapture>
			<MinAreaSize>-1</MinAreaSize>
			<Happiness>2</Happiness>
			<BuildingClass>BUILDINGCLASS_TRAIT</BuildingClass>
			<ArtDefineTag>NONE</ArtDefineTag>
			<PortraitIndex>44</PortraitIndex>
			<IconAtlas>BW_ATLAS_1</IconAtlas>
		</Row>
	</Buildings>
	<Building_YieldChanges>
		<Row>
			<BuildingType>BUILDING_TRAIT</BuildingType>
			<YieldType>YIELD_CULTURE</YieldType>
			<Yield>4</Yield>
		</Row>
	</Building_YieldChanges>

	<Language_en_US>
		<Row Tag="TXT_KEY_BUILDING_TRAIT">
			<Text>Trait Building</Text>
		</Row>
	</Language_en_US>

	<BuildingClasses>
		<Row>
			<Type>BUILDINGCLASS_TRAIT</Type>
			<DefaultBuilding>BUILDING_TRAIT</DefaultBuilding>
			<Description>TXT_KEY_BUILDING_TRAIT</Description>
		</Row>
	</BuildingClasses>
</GameData>

Plus you had some other errors related to wrong building designation in <Building_YieldChanges> and you had some repeats of column commands within the <Buildings> table, each of which would cause the entire file to fail until you root them out.

Plus, for dummy/hidden buildings it is always better to include no more commands than the minimum necessary to (a) get the game to accept the building as valid, and (b), get the effects you want so far as yields and the like go.

Having just made the previous statement, note that I always include a <IconAtlas> and <PortraitIndex> command even though the building is intended to be hidden: I'm not sure if I can get by without them so far as the game accepting the building as valid, though they have no effect on the building showing anywhere.
 
LOL. It works, except it gives a free floating gardens(aztecs special water mill building) to a city after it is connected. haha!

Can anybody tell me why?
See my previous post as to why your BUILDING_TRAIT fails to load into the game. What is happening is that the lua line local traitBuilding = GameInfoTypes.BUILDING_TRAIT is failing to find anything called BUILDING_TRAIT and is defaulting within your PlayerDoTurn function to the building with "0" as its building ID#, which happens to be the Floating Garden.
 
Thank you. I changed it and now it works! Really happy about the mod working.
 
Top Bottom