How do you assign a certain building to a unit

Riker13

King
Joined
Nov 9, 2001
Messages
859
Location
UK
I want to make in my mod that the only way you can make knights is if you have a castle.

I have used both the tables below but neither work, any help would be great.

<Table name="Unit_Buildings">
<Column name="UnitType" type="text" reference="Units(Type)"/>
<Column name="BuildingType" type="text" reference="Buildings(Type)"/>
</Table>
<Table name="Unit_BuildingClassRequireds">
<Column name="UnitType" type="text" reference="Units(Type)"/>
<Column name="BuildingClassType" type="text" reference="BuildingClasses(Type)"/>

Regards
Riker13 :crazyeye:

*Edit, I did use the above tables correctly and not as tables, above is just an example of which ones I have used without success. ;)
 
Im pretty sure the problem is that you have to write the code in LUA using those tables. The tables alone do not give any function, they simply store all the variables and information that LUA uses. Sorry cant help you with the coding part since Im still trying to learn it myself.
 
Im pretty sure the problem is that you have to write the code in LUA using those tables. The tables alone do not give any function, they simply store all the variables and information that LUA uses. Sorry cant help you with the coding part since Im still trying to learn it myself.
That would make sense if there were hooks for them. The binary code of the game (DLL) makes extensive use of the tables in the DB, but some fields as mysteriously in the schema but not implemented in code. Of course, there also might be a typo or something in the file that the OP is using to try to make it work as well...
 
The problem is that according to the code you have in your first post, you're trying to define a new table.

But you don't have to. The Unit_BuildingClassRequireds table already exists.

So your code would be:
Code:
<GameInfo>
     <Unit_BuildingClassRequireds>
          <Row>
               <UnitType>UNIT_KNIGHT</UnitType>
               <BuildingClassType>BUILDINGCLASS_CASTLE</BuildingClassType>
          </Row>
     </Unit_BuildingClassRequireds>
</GameInfo>

Hope that helps.

EDIT: Note that because it refers to a building class instead of a building, the Knight unit will be able to be built at all Unique Buildings that are of the Castle class (if any exist), as well as the actual Castle building.
 
The problem is that according to the code you have in your first post, you're trying to define a new table.

But you don't have to. The Unit_BuildingClassRequireds table already exists.

So your code would be:
Code:
<GameInfo>
     <Unit_BuildingClassRequireds>
          <Row>
               <UnitType>UNIT_KNIGHT</UnitType>
               <BuildingClassType>BUILDINGCLASS_CASTLE</BuildingClassType>
          </Row>
     </Unit_BuildingClassRequireds>
</GameInfo>

Hope that helps.

EDIT: Note that because it refers to a building class instead of a building, the Knight unit will be able to be built at all Unique Buildings that are of the Castle class (if any exist), as well as the actual Castle building.

Goddambigcar,

Yes I did try that but it dont work either?

Do you think there is a Lua connection?

Regards

Riker13 :crazyeye:
 
Because you asked, and because I didn't know for sure, I input this code into my own mod, just for testing purposes:
Code:
<Unit_BuildingClassRequireds>
		<Row>
			<UnitType>UNIT_WORKER</UnitType>
			<BuildingClassType>BUILDINGCLASS_MONUMENT</BuildingClassType>
		</Row>
	</Unit_BuildingClassRequireds>

All within the <GameInfo> tags, of course.

And yes, it works. If you don't have the building, when you hover over the unit you want to build, there's red text at the bottom that says "You must have _building_ in this city in order to build this unit."

So I'd say that there's something not right on your end. It worked for me.
 
Hay Bigcar,

Strange, and this is within the Units.xml yes?

I will try it again maybe there was something silly like a spelling mistake or something, would`nt put it past me ;)

Many thanks for your help though.

Regards

Riker13 :crazyeye:
 
Doesn't matter what filename.xml you put it in.

The table schema that you pointed out in your first post was within the Civ5Buildings.xml.

Myself, I put it in my new units.xml, after the <Units></Units> elements (because it's not in the units table, it's in the unit_buildingclassrequireds table.

So I guess I'm not sure what you're asking.

But I really do hope you get it working, and I thank you for asking the question, because before that I didn't know that there was a define for it, and it's something that I think I'm going to use.
 
Hi Bigcar,

Thanks again for your help as soon as I have finished my current game I will try it out and will let you know the results, im sure it will work this time must have made an error somewhere and will tell you what I done wrong.

And your welcome for the suggestion ;) I had it in my custom civ IV game but they changed some things in V. I will get it back to IV standard soon.

All the best.

Riker13 :crazyeye:
 
Bigcar,

Many thanks, tested out now, I did actualy solve it myself but instead of when testing building a city and looking on production and seeing the red text as you said I went streight to the civipedia to see if the unit needed a castle for it to be built which it did not show.

So that part must be elsewhere maybe in Text but thanks for the help anyway allways good to have another pair of eyes on the problem.

All the best.

Riker13 :crazyeye:
 
Is there a way when doing this:

<GameInfo>
<Unit_BuildingClassRequireds>
<Row>
<UnitType>UNIT_KNIGHT</UnitType>
<BuildingClassType>BUILDINGCLASS_CASTLE</BuildingClassType>
</Row>
</Unit_BuildingClassRequireds>
</GameInfo>

That it will show in the Civilopedia that you need the Barracks to make the Knight?

Regards
 
Back
Top Bottom