[Vanilla] Creating new class, Unit upgrades to different class

Joined
Jan 10, 2019
Messages
2,839
1. How to create a new class? In addition to declare 'class' in UNIT.XML and define promotion (how), what else should be done to enable a new unit class?
2. And is it possible to code unit upgrades into different classes. for example i've made a new class 'Infantry' and created two new units; Pike&Shot and Line Infantry. while P&S is Anticav. Line Infantry is in new class and this class combined advantages of Melee and Anticav in one. Is it possible to write an XML code to upgrade Musketman and Pike&Shot into this new unit? if so how.
3. And is it possible to write XML code to nullify Tank weakness to previous Anti cavalry but very vulnerable to Antitank? (also a new class not being a lineage to Anticav and has no bonus against previous 'horse' cavalry) without making a new class out of it?
 
Yep, everything you've suggested here should be possible and fairly straightforward.

1. To create a new unit promotion class you need to add that promotion class to the 'Types' table. For anti-cavalry that looks like this:

<Types>
<Row Type="PROMOTION_CLASS_ANTI_CAVALRY" Kind="KIND_PROMOTION_CLASS"/>
</Types>

You should replace the "PROMOTION_CLASS_ANTI_CAVALRY" with the name of your new promotion class. Next you want to add the ability class to the 'Tags' and 'TypeTags' tables along with any ability you want to apply to the whole units class. Anti-cavalry and their bonus against cavalry looks like this:

<Tags>
<Row Tag="CLASS_ANTI_CAVALRY" Vocabulary="ABILITY_CLASS"/>
</Tags>
<TypeTags>
<Row Tag="CLASS_ANTI_CAVALRY" Type="ABILITY_ANTI_CAVALRY"/>
</TypeTags>

There are a few other things to consider, but for a start, adding in your new promotion class and any abilities like this should create the new unit class. As for creating new promotions for that promotion class, I'd recommend just copying the promotions from another class for starters. But if you know how, you can also add completely new promotions too.


2. To get musketmen and Pike&Shot to upgrade into your new unit, you want to change the 'UnitUpgrades' table.

<UnitUpgrades>
<Update><Where Unit="UNIT_MUSKETMAN"/><Set UpgradeUnit="UNIT_LINE_INFATRY"/></Update>
<Update><Where Unit="UNIT_PIKE_AND_SHOT"/><Set UpgradeUnit="UNIT_LINE_INFATRY"/></Update>
</UnitUpgrades>

Just replace the 'UNIT_LINE_INFATRY' with the technical name of you new unit. It's important to use the "Update" XML syntax to replace the default upgrade with your new unit. Keep in mind that any unit that gets upgraded into a new promotion class keeps all of the promotions from its old promotion class. So a pike and shot might keep the "Thrust" promotion even if line infantry aren't eligible to get that promotion. That could be a bug or a feature depending on how you look at it.


3. To make certain units good against tanks but not horsemen, you would add to or change the 'TypeTags' table again. First you would want to tell the game which units are tanks and which are horsemen:

<Tags>
<Row Tag="CLASS_HORSEMAN" Vocabulary="ABILITY_CLASS"/>
<Row Tag="CLASS_TANK Vocabulary="ABILITY_CLASS"/>
</Tags>
<TypeTags>
<Row Tag="CLASS_HORSEMAN" Type="UNIT_KNIGHT"/>
<Row Tag="CLASS_TANK " Type="UNIT_TANK"/>
</TypeTags>

You want to do that for all units that you think are relevant. Next you would probably want to delete the "ABILITY_ANTI_CAVALRY" and replace it with two new abilities: "ABILITY_ANTI_HORSE" and "ABILITY_ANTI_TANK", for example line infantry could be good against both:

<Tags>
<Row Tag="CLASS_ANTI_HORSEMAN" Vocabulary="ABILITY_CLASS"/>
<Row Tag="CLASS_ANTI_TANK Vocabulary="ABILITY_CLASS"/>
</Tags>
<TypeTags>
<Row Tag="CLASS_ANTI_HORSEMAN" Type="UNIT_LINE_INFANTRY"/>
<Row Tag="CLASS_ANTI_TANK " Type="UNIT_LINE_INFANTRY"/>
</TypeTags>

These tags won't actually do anything yet, for that you have to create the relevant abilities, and that is a bit more complicated.

In general, my advice would be to play around with this website and copy this as closely as you can from the base game. But in general I hope this is enough info to get started. Let me know if you run into any trouble and I'd be happy to help.
 
You could put your changes in any XML file that the mod loads, the file's name isn't necessarily important. If you're starting from an existing mod, then adding your changes to an existing file called UnitGameplay.XML file should be fine. I wouldn't recommend changing the base game data if that's what you're asking though. I would definitely recommend finding a mod similar to what you're trying to do, and copying from that as much as possible.
 
This is what i've done right now. A new unit class called Crusiers, which this is a class Frigate and Missle Cruiser will be reassigned to (Ships of the Line and Modern Battleship will replace the two respectively)
but before I assign the two to the new class. and before I assign promotions. What are tables that defines what does unit do or which domain does it belongs to? (Land, Sea, Air) and unit strenghts (What they're good against, attacking a specific enemy unit with this one deals more damage than the others) and weakness (if the enemy units of a certain class attacks, this unit takes extra damage), and, in case of cruisers, anti-submarine and superior AA ability (again i've yet to discuss many other forum mebers and do more research about what they actually do IRL) .

This is what I want a Cruiser class to be.
the 'Cruiser' class is a kinda hybrid class, naval ranged with ability to assault (melee attack) and able to detect and destroy enemy submarines, also has the same speed as naval melee, they're, however weak against naval ranged and not particularly good against land targets unless promoted specifically.

Do i have to define these in a set of different tables or these abilities are mainly in <Unit> tables (which defines what EACH indivudual unit does rather than what the entire class do) and no other different tables needed?

Can you check this file please?

Also on the promotion coding. There is a prereq table
Code:
<UnitPromotionPrereqs>
<!--Naval Melee-->
       <Row UnitPromotion="PROMOTION_REINFORCED_HULL" PrereqUnitPromotion="PROMOTION_EMBOLON"/>
       <Row UnitPromotion="PROMOTION_RUTTER" PrereqUnitPromotion="PROMOTION_HELMSMAN"/>
       <Row UnitPromotion="PROMOTION_AUXILIARY_SHIPS" PrereqUnitPromotion="PROMOTION_REINFORCED_HULL"/>
       <Row UnitPromotion="PROMOTION_AUXILIARY_SHIPS" PrereqUnitPromotion="PROMOTION_RUTTER"/>
       <Row UnitPromotion="PROMOTION_CONVOY" PrereqUnitPromotion="PROMOTION_REINFORCED_HULL"/>
       <Row UnitPromotion="PROMOTION_CONVOY" PrereqUnitPromotion="PROMOTION_RUTTER"/>
       <Row UnitPromotion="PROMOTION_CREEPING_ATTACK" PrereqUnitPromotion="PROMOTION_AUXILIARY_SHIPS"/>
       <Row UnitPromotion="PROMOTION_CREEPING_ATTACK" PrereqUnitPromotion="PROMOTION_CONVOY"/>
       <!--Naval Ranged-->
       <Row UnitPromotion="PROMOTION_PREPARATORY_FIRE" PrereqUnitPromotion="PROMOTION_LINE_OF_BATTLE"/>
       <Row UnitPromotion="PROMOTION_ROLLING_BARRAGE" PrereqUnitPromotion="PROMOTION_BOMBARDMENT"/>
       <Row UnitPromotion="PROMOTION_SUPPLY_FLEET" PrereqUnitPromotion="PROMOTION_PREPARATORY_FIRE"/>
       <Row UnitPromotion="PROMOTION_SUPPLY_FLEET" PrereqUnitPromotion="PROMOTION_ROLLING_BARRAGE"/>
       <Row UnitPromotion="PROMOTION_PROXIMITY_FUSES" PrereqUnitPromotion="PROMOTION_PREPARATORY_FIRE"/>
       <Row UnitPromotion="PROMOTION_PROXIMITY_FUSES" PrereqUnitPromotion="PROMOTION_ROLLING_BARRAGE"/>
       <Row UnitPromotion="PROMOTION_COINCIDENCE_RANGEFINDING" PrereqUnitPromotion="PROMOTION_SUPPLY_FLEET"/>
       <Row UnitPromotion="PROMOTION_COINCIDENCE_RANGEFINDING" PrereqUnitPromotion="PROMOTION_PROXIMITY_FUSES"/>
</UnitPromotionPrereqs>

Is it still possible to use the existing promotions rather than writing new ones without incurring errors?
 

Attachments

Last edited:
Back
Top Bottom