Making special units not replace the standard ones.

Johnen

Chieftain
Joined
Jul 27, 2013
Messages
41
I just wanted to know since I'm constantly modding this game - Is there a way to make unique civ units completely separate so that they won't replace the standard ones?

Here's an example - I want to make the Landsknecht from the German civ a completely separate unit that won't replace the Pikeman. Yet at the same time I want it to be unique to the German civ so that no other civ can recruit them. Just in case I want to add that I don't want to delete the unit, just make it completely separate so I can build both Landsknecht and Pikeman as Germany.
 
Yes, just make the Landsknecht a new unitclass, and give the non-unique version of that class a -1 cost to make it unbuildable.
EDIT: I think having a non-unique version is not necessary...
EDIT #2: If you want this to affect all UUs, I think this should work...
EDIT #3: Tested it; Nope, the UUs have been separated (IGE sees them as distinct units), but they cannot be built for some reason...
EDIT #4: Oops, need to actually add the classes to UnitClasses. This should be the one:
Code:
INSERT INTO UnitClasses (Type, Description)
    SELECT 'UNITCLASS_' || SUBSTR(UnitType, 6), 'TXT_KEY_' || UnitType
    FROM Civilization_UnitClassOverrides
    WHERE NOT UnitType IS NULL AND
    NOT CivilizationType = 'CIVILIZATION_BARBARIAN' AND
    NOT CivilizationType = 'CIVILIZATION_MINOR';
UPDATE Civilization_UnitClassOverrides
    SET UnitClassType = 'UNITCLASS_' || SUBSTR(UnitType, 6)
    WHERE NOT UnitType IS NULL AND
    NOT CivilizationType = 'CIVILIZATION_BARBARIAN' AND 
    NOT CivilizationType = 'CIVILIZATION_MINOR';
UPDATE Units SET Class = ('UNITCLASS_' || SUBSTR(Type, 6)) 
    WHERE Type IN
    (SELECT UnitType FROM Civilization_UnitClassOverrides
    WHERE UnitType IS NOT NULL AND
    NOT CivilizationType = 'CIVILIZATION_BARBARIAN' AND
    NOT CivilizationType = 'CIVILIZATION_MINOR');
 
What you could do is make a new unit class and call it "unique". You'll need to have a unit though that's used as a "standard" unit - but it then doesn't matter where or when the unique units deriving from it appear on the tech tree - so all of the unique units could be from the unit class we're calling unique in this example.
 
Updated post #2, assuming you want this to affect all UU's. Default unit is left blank, per Craig_Sutter. Note I haven't tested it... EDIT: It works!

To be clear on what this is doing, it's making new classes based on the name of the unit, e.g., UNITCLASS_GERMAN_LANDSKNECHT, and assigning those classes to the units while keeping the unique civ assignment intact.
 
Do you have an XML version of that code?

So far I wrote:

Code:
<GameData>
	<UnitClasses>
		<Row>
			<Type>UNITCLASS_GERMAN_LANDSKNECHT</Type>
			<Description>TXT_KEY_UNIT_GERMAN_LANDSKNECHT</Description>
			<DefaultUnit></DefaultUnit>
		</Row>
	</UnitClasses>
</GameData>

In a unit classes file.

Then I will need to add a new unit in the Units file I guess. Like:

Code:
			<Row>
		<Class>UNITCLASS_GERMAN_LANDSKNECHT</Class>
		<Type>UNIT_GERMAN_LANDSKNECHT</Type>
		<PrereqTech>TECH_CIVIL_SERVICE</PrereqTech>
		<Combat>10</Combat>
		<Cost>45</Cost>
		<Moves>2</Moves>
		<CombatClass>UNITCOMBAT_MELEE</CombatClass>
		<Domain>DOMAIN_LAND</Domain>
		<DefaultUnitAI>UNITAI_COUNTER</DefaultUnitAI>
		<Description>TXT_KEY_UNIT_GERMAN_LANDSKNECHT</Description>
		<Civilopedia>TXT_KEY_CIVILOPEDIA_UNITS_MEDIEVAL_LANDSKNECHT_TEXT</Civilopedia>
		<Strategy>TXT_KEY_UNIT_GERMAN_LANDSKNECHT_STRATEGY</Strategy>
		<Help>TXT_KEY_UNIT_HELP_LANDSKNECHT</Help>
		<MilitarySupport>true</MilitarySupport>
		<MilitaryProduction>true</MilitaryProduction>
		<Pillage>true</Pillage>
		<ObsoleteTech>TECH_RIFLING</ObsoleteTech>
		<GoodyHutUpgradeUnitClass>UNITCLASS_RIFLEMAN</GoodyHutUpgradeUnitClass>
		<AdvancedStartCost>20</AdvancedStartCost>
		<XPValueAttack>3</XPValueAttack>
		<XPValueDefense>3</XPValueDefense>
		<Conscription>3</Conscription>
		<UnitArtInfo>ART_DEF_UNIT_U_GERMAN_LANDSKNECHT</UnitArtInfo>
		<UnitFlagIconOffset>33</UnitFlagIconOffset>
		<IconAtlas>UNIT_ATLAS_1</IconAtlas>
		<PortraitIndex>34</PortraitIndex>
	</Row>

Right?

But how do I delete the old landsknecht?

With something like:

Code:
<Delete UnitType="UNIT_GERMAN_LANDSKNECHT" />

Or did I get this part wrong?

Gonna finish it in a few hour work has kept me too busy to finish this. I even got some new fitting music, but I was only able to implement it after deleting the old files. Anyway should have this ready enough to upload soon for anyone who wants to look at it. Although this mod is far from finished. I need a lot of new units and buildings.
 
Make certain that the unit class default unit is >< so there is not base unit buildable.

For example:

Code:
<UnitClasses>
		<Row>
			<Type>UNITCLASS_STELLINGA</Type>
			<Description>Stellinga</Description>
			[COLOR="Red"]<DefaultUnit></DefaultUnit>[/COLOR]
		</Row>
	</UnitClasses>

I didn't realise you could do that. Is it the same for building classes? I take it that <DefaultUnit/> would also suffice?
 
Johnen: You can't do all the cool stuff you can do with SQL in XML, but if you just want to do it one-off style, I'd still use updates where you can (it's easier, less potential for mistakes, and probably deals with future patches better). The UnitClasses part is fine, though you do not need to include the blank DefaultUnit if you're adding a new row (it defaults to an empty string).
Code:
<GameData>
    <UnitClasses>
        <Row>
            <Type>UNITCLASS_GERMAN_LANDSKNECHT</Type>
            <Description>TXT_KEY_UNIT_GERMAN_LANDSKNECHT</Description>
        </Row>
    </UnitClasses>
    <Civilization_UnitClassOverrides>
        <Update>
            <Where UnitType="UNIT_GERMAN_LANDSKNECHT">
            <Set UnitClassType="UNITCLASS_GERMAN_LANDSKNECHT">
        </Update>
    </Civilization_UnitClassOverrides>
    <Units>
        <Update>
            <Where Type="UNIT_GERMAN_LANDSKNECHT">
            <Set Class="UNITCLASS_GERMAN_LANDSKNECHT">
        </Update>
    </Units>
</GameData>
EDIT: If you did want to do an add and a delete, you were close:
<Units><Delete Type="UNIT_GERMAN_LANDSKNECHT" /></Units>

This cheat sheet is a very helpful CiV XML/SQL syntax reference.



Rob: Yes, <DefaultUnit /> suffices, though as I mentioned above, it's not even necessary in this case.

EDIT: I don't know whether a default is required for buildings; unlike units (where the barbarian galley's default isn't blank; it's set to the string 'NONE'), all of the existing buildings do have one set. You might assume that the system would work similarly, but those assumptions are often incorrect with CiV.
 
I have fixed all the issues, but it took a lot more work then that. Just last night I've managed to finish adding the Landsknecht as a separate unit.

CIV5Units.xml:
Code:
<GameData>
	<Units>
		<Delete Type="UNIT_GERMAN_LANDSKNECHT" />
		<Row>
			<Class>UNITCLASS_LAND_KNIGHT</Class>
			<Type>UNIT_LAND_KNIGHT</Type>
			<PrereqTech>TECH_CHIVALRY</PrereqTech>
			<Combat>21</Combat>
			<Cost>45</Cost>
			<Moves>2</Moves>
			<CombatClass>UNITCOMBAT_MELEE</CombatClass>
			<Domain>DOMAIN_LAND</Domain>
			<DefaultUnitAI>UNITAI_ATTACK</DefaultUnitAI>
			<Description>TXT_KEY_UNIT_GERMAN_LANDSKNECHT</Description>
			<Civilopedia>TXT_KEY_CIVILOPEDIA_UNITS_MEDIEVAL_LANDSKNECHT_TEXT</Civilopedia>
			<Strategy>TXT_KEY_UNIT_GERMAN_LANDSKNECHT_STRATEGY</Strategy>
			<Help>TXT_KEY_UNIT_HELP_LANDSKNECHT</Help>
			<MilitarySupport>true</MilitarySupport>
			<MilitaryProduction>true</MilitaryProduction>
			<Pillage>true</Pillage>
			<ObsoleteTech>TECH_RIFLING</ObsoleteTech>
			<GoodyHutUpgradeUnitClass>UNITCLASS_RIFLEMAN</GoodyHutUpgradeUnitClass>
			<AdvancedStartCost>25</AdvancedStartCost>
			<XPValueAttack>3</XPValueAttack>
			<XPValueDefense>3</XPValueDefense>
			<Conscription>3</Conscription>
			<UnitArtInfo>ART_DEF_UNIT_U_GERMAN_LANDSKNECHT</UnitArtInfo>
			<UnitFlagIconOffset>33</UnitFlagIconOffset>
			<IconAtlas>UNIT_ATLAS_1</IconAtlas>
			<PortraitIndex>34</PortraitIndex>
		</Row>
	</Units>
</GameData>

CIV5UnitClasses.xml:
Code:
<GameData>
	<UnitClasses>
		<Row>
			<Type>UNITCLASS_LAND_KNIGHT</Type>
			<Description></Description>
			<DefaultUnit></DefaultUnit>
		</Row>
	</UnitClasses>
</GameData>

CIV5Civilizations.xml:
Code:
<GameData>
	<Civilization_UnitClassOverrides>
		<Delete CivilizationType="CIVILIZATION_GERMANY" UnitClassType="UNITCLASS_PIKEMAN" UnitType="UNIT_GERMAN_LANDSKNECHT" />
		<Row>
			<CivilizationType>CIVILIZATION_GERMANY</CivilizationType>
			<UnitClassType>UNITCLASS_LAND_KNIGHT</UnitClassType>
			<UnitType>UNIT_LAND_KNIGHT</UnitType>
		</Row>	
	</Civilization_UnitClassOverrides>
</GameData>

All I gotta do now is just put in a proper description and adjust the costs and everything else for balance. Then I'm gonna take care of the other units.

I still would need someone to make some brand new custom units. Know anyone who could help?
 
Using your method, you need to re-add the Panzer also. [Sorry, was looking at it w/ my phone, didn't see the full line...]

By brand new custom units, what are you asking for? Adding the art and art defines for one or more of the units in the Units subforum? See the sticky re: XML art defines in the Units subforum, or the Add a new unit using SQL tutorial (though XML is covered too).
 
The panzers are working fine without any changes thus far. I need a Panzerkampfwagen IV and Panther model - both fully animated, driving side by side in a formation of at least 3 tanks to replace the Russian T-34 tanks. The German Panzer will get a proper names as the Heavy Panzer Battalion and the ones made up of lighter tanks will be a Panzer Battalion.

Actually I'm talking about brand new 3D models. Like pikemen using an early Medieval cannon just before going to the Renaissance cannon model. I want a lot more modern military models in general. For example tanks like: Anders, Abrams, Merkava, T90 Tagil and many, many more. I also want modern looking military and special forces to replace XCOM.
 
Top Bottom