Some Questions for my First Mod

PatRoy

Chieftain
Joined
Jul 21, 2014
Messages
30
I am working on an idea for my first mod and I had a couple of questions about if certain things are possible to do. If any of these questions are already been answered, I would appreciate a link to the information.

1.) I want to be able to select a 'unit' for production, that when you click it it produce 1 of 3 possible units at random. For example, "Draft A Soldier" would be an option to select for production, the same as a warrior unit, but instead of generating a unit in the normal fashion, it would produce a random unit from a list of possible options. I'm assuming if it is possible it would be a Lau script. Has anyone tried this/is this possible to do?

2.) I want to essentially scrap the existing units for my mod and create all the units (I think that would work better for what I want my mod to do). Can you create new units that are available to all civilizations, the same as a warrior can be produced by all civilizations. I'm assuming you can, if so, is there anything I need to know - or is it as simple as creating the unit and changing it so the city can produce that new unit?

3.) I just created a basic Civ, just to try to get it to load which was copied from the American's files. I tried to add a third unique unit (for sake of explaining UniqueA, UniqueB, and UniqueC). Two of which - UniqueB and UniqueC - had the same unit class (UNITCLASS_WARRIER), and when you start the game it replaces the starting default warrior with UniqueB. When you settle the city, the warrior is gone and you can select UniqueB (which replaced the warrior unit), but UniqueC does not show up (the other UNITCLASS_WARRIER). Can you only have one unique unit per unit class?

4.) Reading through Kael's guide, he explains how to create the icons for units, etc. If I wanted to have all the icons for a unit the same, except the icon which shows up directly above the unit in game, would you just change the picture in the 32 pixel file (I think this is the one that the unit icon in game uses)? Does this cause any problems if the icons are not all the same?

5.) Can you change the promotion names and icons? I'm assuming this would be done similar to the example in Kaels with the toggle icons for units and would need both an xml file and a lau script?

6.) Can you change the names of the items on the top toolbar - Happiness, gold, science, faith, culture - and can you remove any if you like? They would still all work the same, but would just have a name change.

Thanks in advance.
 
1. Requires some fairly simple Lua. See this thread. [Here he was trying to get different appearances for the same unit; but my solution actually uses different units to achieve the effect.]
2. By default, a new unit class that you add to the game will be buildable by all civs (including city states and barbarians).
3. Yes, only one UU per unit class (without a DLL mod) [though you could use Lua to achieve the effect].
4. You can use whatever icons you like. The only issue is your users being confused.
5. Yes. You don't need to change the interface Lua/XML, you only need to change the database references with XML or SQL.
6. You should be able to change all the US English translations for the yields. I imagine it will be several TXT_KEY entries requiring a change. As for removing them from the top bar, I know some of the top bar stuff is hard-coded, but I think what you're trying to do is do-able.
 
1.) Thank you for the help, I will have a look at the Lua script for the random units. To clarify on the second point: I need to create a new unit class (example: UNITCLASS_NEW instead of UNITCLASS_WARRIER) and that will enable all units to produce it? Do I need to change anything in building settings in order to enable the unit?

2.) If I wanted to tie it in with the random unit, and only wanted players to be able to produce the three random units using that script, would I need to prevent a normally production of the unit (like changing it so the building can't normally produce those units).

3.) For the UU, if I wanted, I could base it on any unit class I wanted and change the settings to reflect what I wanted. For example, I could use a knight as my base, but change all the prereqs, domain, etc. to what I wanted?

5.) So if i wanted to create my own promotions, you could create them based off a template of existing promotions and then ensure that my units are able to receive those promotions?

6.) Do you know what file I would need to update to change the names? I would think it would be in a game master file somewhere? Or would I just do up a new XML file and update the TXT_KEY's?
 
I am working on an idea for my first mod and I had a couple of questions about if certain things are possible to do. If any of these questions are already been answered, I would appreciate a link to the information.

1.) I want to be able to select a 'unit' for production, that when you click it it produce 1 of 3 possible units at random. For example, "Draft A Soldier" would be an option to select for production, the same as a warrior unit, but instead of generating a unit in the normal fashion, it would produce a random unit from a list of possible options. I'm assuming if it is possible it would be a Lau script. Has anyone tried this/is this possible to do?

2.) I want to essentially scrap the existing units for my mod and create all the units (I think that would work better for what I want my mod to do). Can you create new units that are available to all civilizations, the same as a warrior can be produced by all civilizations. I'm assuming you can, if so, is there anything I need to know - or is it as simple as creating the unit and changing it so the city can produce that new unit?

3.) I just created a basic Civ, just to try to get it to load which was copied from the American's files. I tried to add a third unique unit (for sake of explaining UniqueA, UniqueB, and UniqueC). Two of which - UniqueB and UniqueC - had the same unit class (UNITCLASS_WARRIER), and when you start the game it replaces the starting default warrior with UniqueB. When you settle the city, the warrior is gone and you can select UniqueB (which replaced the warrior unit), but UniqueC does not show up (the other UNITCLASS_WARRIER). Can you only have one unique unit per unit class?

4.) Reading through Kael's guide, he explains how to create the icons for units, etc. If I wanted to have all the icons for a unit the same, except the icon which shows up directly above the unit in game, would you just change the picture in the 32 pixel file (I think this is the one that the unit icon in game uses)? Does this cause any problems if the icons are not all the same?

5.) Can you change the promotion names and icons? I'm assuming this would be done similar to the example in Kaels with the toggle icons for units and would need both an xml file and a lau script?

6.) Can you change the names of the items on the top toolbar - Happiness, gold, science, faith, culture - and can you remove any if you like? They would still all work the same, but would just have a name change.

Thanks in advance.

1) No idea, probably hideously difficult to do with some very complicated and verbose lua.
("Lua", not "Lau". ;)

2) Units are by default available to all civilizations and it takes extra effort to contain them to just one civilization, e.g. in the case of a unique unit.

Every unit needs to be assigned to a "unitclass". Unitclasses have default units assigned to them - e.g., UNITCLASS_WARRIOR's default unit is UNIT_WARRIOR. The way unique units are generated is by assigning a unit to a unitclass that does not default to that unit, e.g. Making a new unit called UNIT_ABC and assigning it to UNITCLASS_WARRIOR. No one can make this unit unless specifically forced to instead of making warriors. The workaround, by which means a civilization is forced to make UNIT_ABC in place of UNIT_WARRIOR, is an entry in the table <Civilization_UnitClassOverrides>. This is how UUs are created.

Did that make sense? I don't think I'm very good at explaining things...

3) One unique unit per unitclass per civilization, yes. The workaround is to make an entirely new unitclass specifically for Unique C and not assign a default unit to that unitclass, so that it cannot be built, except by America, who should have an entry for this new unitclass in <Civilization_UnitClassOverrides>.

4) By "icon which shows up above the unit" I assume you mean the "unit flag", as the game files call them. It's totally fine to have several units use the same icon but a different flag, since unit icons are controlled by the columns <IconAtlas> and <PortraitIndex>, and the unit flag is controlled by <UnitFlagAtlas> and <PortraitIndex>. Now, since you're using the same icon for each unit, they will have to have an identical IconAtlas and PortraitIndex. Because they will have the same PortraitIndex, in order to create different unit flags for each unit they'll each need their own UnitFlagAtlas.

5) Lua isn't needed here whatsoever. This is a template for the XML for changing promotion icons:
Code:
<GameData>	
	<UnitPromotions>
		<Update>
			<Where Type="PROMOTION_WHATEVERONEYOUWANTTOCHANGE"/>
			<Set IconAtlas="" PortraitIndex=""/>
		</Update>
	</UnitPromotions>
</GameData>
As it is currently, this code deletes (since the fields are empty) the icon for a nonexistent promotion called PROMOTION_WHATEVERONEYOUWANTTOCHANGE.
What Kael was doing was changing the User Interface - not at all related and generally well beyond the scope of new modders.

6) Requires user interface modding. Possible but difficult, exceptionally so for new modders.

EDIT: Be'ninja'd by Nutty!
 
1.) Thank you for the help, I will have a look at the Lua script for the random units. To clarify on the second point: I need to create a new unit class (example: UNITCLASS_NEW instead of UNITCLASS_WARRIER) and that will enable all units to produce it? Do I need to change anything in building settings in order to enable the unit?

2.) If I wanted to tie it in with the random unit, and only wanted players to be able to produce the three random units using that script, would I need to prevent a normally production of the unit (like changing it so the building can't normally produce those units).

3.) For the UU, if I wanted, I could base it on any unit class I wanted and change the settings to reflect what I wanted. For example, I could use a knight as my base, but change all the prereqs, domain, etc. to what I wanted?

5.) So if i wanted to create my own promotions, you could create them based off a template of existing promotions and then ensure that my units are able to receive those promotions?

6.) Do you know what file I would need to update to change the names? I would think it would be in a game master file somewhere? Or would I just do up a new XML file and update the TXT_KEY's?

1) Again, units that are assigned to a unitclass whose default unit is that unit (kinda recursive, really) are buildable by anyone. You don't need to change anything; you only have to worry about people not being able to build a unit if you're making it a unique unit.

Now, if a unit is assigned to a unitclass that has no default unit, then no one can build it.

2) Set the unit's <Cost> to -1. Done.

3) ...I'm not sure what you're saying here. You want to make a UU whose attributes don't match its unitclass'? That should work, I think...
The point of a UU is to tell the game "Hey, make so that this civilization, instead of making Unit A, the default unit of Unitclass A, has to make Unit B, which is also in Unitclass A."

5) "Ensure that your units receive this promotion"... do you mean make so that unit receives that promotion free?

6) Depends on whether you want to make a mod or just edit existing files.
 
1) Again, units that are assigned to a unitclass whose default unit is that unit (kinda recursive, really) are buildable by anyone. You don't need to change anything; you only have to worry about people not being able to build a unit if you're making it a unique unit.

Now, if a unit is assigned to a unitclass that has no default unit, then no one can build it.

2) Set the unit's <Cost> to -1. Done.

3) ...I'm not sure what you're saying here. You want to make a UU whose attributes don't match its unitclass'? That should work, I think...
The point of a UU is to tell the game "Hey, make so that this civilization, instead of making Unit A, the default unit of Unitclass A, has to make Unit B, which is also in Unitclass A."

5) "Ensure that your units receive this promotion"... do you mean make so that unit receives that promotion free?

6) Depends on whether you want to make a mod or just edit existing files.

1.) So if I wanted to create a unit that all Civilizations could produce, in an XML file I could create a unit (Ex: UNIT_MY_NEW_UNIT) with a new unit class (Ex: UNITCLASS_MY_NEW) and then model the unit settings after an existing unit (like make it similar to a warrior, or scout, etc)?

3.) What I'm trying to get at is every Civ will have more than 2 unique units that I want a player to be able to produce immediately (no prereq), and I'm just trying to figure out the best way to do that. If I am able to create my own unit class and then make each Civ have a unique unit for that unit class, that would work for what I'm trying to do.

5.) What I meant is, if I wanted to have a new promotion, you had said that I could update an existing promotion. If I did that, is there anywhere in the unit file where you need to have something like "EligiblePromotions" updated?

6.) And I would only want to change the names for the specific mod I'm doing. Not sure if I'm explaining that well enough.
 
1.) So if I wanted to create a unit that all Civilizations could produce, in an XML file I could create a unit (Ex: UNIT_MY_NEW_UNIT) with a new unit class (Ex: UNITCLASS_MY_NEW) and then model the unit settings after an existing unit (like make it similar to a warrior, or scout, etc)?

3.) What I'm trying to get at is every Civ will have more than 2 unique units that I want a player to be able to produce immediately (no prereq), and I'm just trying to figure out the best way to do that. If I am able to create my own unit class and then make each Civ have a unique unit for that unit class, that would work for what I'm trying to do.

5.) What I meant is, if I wanted to have a new promotion, you had said that I could update an existing promotion. If I did that, is there anywhere in the unit file where you need to have something like "EligiblePromotions" updated?

6.) And I would only want to change the names for the specific mod I'm doing. Not sure if I'm explaining that well enough.

1) Exactly!

3) All you have to do to not have a prereq tech for a unit is not give it prereq tech, i.e. There is a column in the Units table called PrereqTech. Don't add it in and the unit has no prereq tech. This should cause no conflict as unitclasses themselves don't have prereq techs.

Now balance-wise, the only military unit that wouldn't be game-breaking to not have a prereq tech is one replacing the Warrior. But there is nothing to stop you from making a prereq-less Infantry replacement.

5) Be aware that updating an existing promotion will cause the original one to be lost.

If you want to give a specific unit a specific promotion for free, use the table <Unit_FreePromotions>.
AFAIK You can't just make so only one unit can receive a certain promotion - you have to make so that every unit of a certain unitcombat (e.g. Melee, Gunpowder, Mounted, etc.) can receive that promotion. This is accomplished using the table <UnitPromotions_UnitCombats>. If the promotion does not have any entries in this table, it cannot be given to a unit except manually with lua or using <Unit_FreePromotions>.

6)
Code:
<GameData>
	<Language_en_US>

	<!-- Language_en_US is the name of the table you would use
     	     if this text is supposed to be English. The table name
     	     should vary by language:

     	     en_US = English
     	     de_DE = German
     	     fr_FR = French

    	     etc. etc. -->

		<Update>
			<Where Tag="TXT_KEY_PROMOTION_THEPROMOTIONWHOSETEXTYOUWANTTOCHANGE"/>
			<Set Text="New Description"/>
		</Update>
	</Language_en_US>
</GameData>

This template would go in a new XML file in a mod.
 
Ok, so I have tried to create a new unit class, which would be available to all Civs. I added that unit as a free unit at the start of the game to ensure it is loading the unit properly, but it doesn't show up. If anyone could have a look and let me know what I've done wrong it would be appreciated.

Also, while I have uploaded the file, anyone who is good with icons that could tell me what I've done wrong where my icon for my Civ doesn't load would also be appreciated.
 

Attachments

  • National Hockey League Mod (v 1).zip
    144.5 KB · Views: 40
Congrats on your first mod! The error on the unit I notice is that you need to define the UNITCLASS in the <UnitClasses> table:

Code:
<UnitClasses>
    <Row>
        <Type>UNITCLASS_PRO_SCOUT</Type>
        <Description>TXT_KEY_UNIT_PRO_SCOUT</Description>
        <DefaultUnit>UNIT_PRO_SCOUT</DefaultUnit>
    </Row>
</UnitClasses>

You should also enable logging to catch any other errors: http://forums.civfanatics.com/showthread.php?t=487482.

You should also review this for tips on artwork. Once you put together an atlas to the right proportions, in the <Civilizations> table, in your CanadiensCiv file, change

Code:
<PortraitIndex>0</PortraitIndex>
<IconAtlas>CIV_COLOR_ATLAS</IconAtlas>
<AlphaIconAtlas>CIV_ALPHA_ATLAS</AlphaIconAtlas>

to match your your atlas. As you have it built now, you would change CIV_COLOR_ATLAS in the code above to CIV_COLOR_ATLAS_NHL to match your Civ5IcontextureAtlases file.

Also, the file for the B17/Minuteman is not necessary - the game already has those units, just add them to your Civ via <Civilization_UnitClassOverrides>
 
Thanks for the help. I realize that I changed the atlas back after it stopped working. It was loading at one point and then I tried adding a leader icon and it caused one of my civ I on files to not load.

For the unit class, can I include that in my main file for the units or is it best to keep this as a separate XML file?

And the B17 and minuteman I left to just have two uniques while trying to figure out how to create a new unit class.

Again, thanks for the help!
 
Top Bottom