Can you create a new <CombatClass>

crashburn274

Chieftain
Joined
Nov 13, 2011
Messages
10
I'd like create a new unit (an airship) with a different promotion tree than existing units. I believe that means defining a new <CombatClass> for the unit. I found the existing combat classes, but don't how to create a new one, and haven't been able to find a template for it. Can anyone point me in the right direction?


This is what I have so far (flyer coded elsewhere, it's presently copy-paseted from Smoky Skies):
Spoiler :
<?xml version="1.0" encoding="utf-8"?>
<!-- Created by ModBuddy on 11/8/2014 2:18:27 AM -->
<!-- created by Crash, with stolen sources from Street, RJ815 and BlouBlou -->
<!-- Alpha Version. Adds an airship, which has good LOS, can spot submarines, and is capable of carrying an aircraft, but is weak in combat.-->
<!-- The airship should be able to bombard cities and gain the siege promotion tree, like the bomber, but also have a promotion tree -->
<!-- which improves speed, like the helicopter it's based on. For balance, the airship will be limited to carrying the Flyer, which-->
<!-- is a no-resources-required, cheap to build triplane, with reduced range and combat strength. -->
<GameData>
<UnitClasses>
<Row>
<Type>UNITCLASS_AIRSHIP</Type>
<Description>TXT_KEY_UNIT_AIRSHIP_CUS</Description>
<DefaultUnit>UNIT_AIRSHIP</DefaultUnit>
</Row>
</UnitClasses>


<Units>
<Row>
<Class>UNITCLASS_AIRSHIP</Class>
<Type>UNIT_AIRSHIP</Type>
<PrereqTech>TECH_STEAM_POWER</PrereqTech>
<Combat>30</Combat>
<Cost>250</Cost>
<Moves>4</Moves>
<CombatClass>UNITCOMBAT_HELICOPTER</CombatClass>
<Domain>DOMAIN_AIR</Domain>
<!-- DOMAIN_HOVER -->
<DefaultUnitAI>UNITAI_FAST_ATTACK</DefaultUnitAI>
<Description>TXT_KEY_UNIT_AIRSHIP_CUS</Description>
<Strategy>TXT_KEY_UNIT_AIRSHIP_CUS_STRATEGY</Strategy>
<Help>TXT_KEY_UNIT_HELP_AIRSHIP_CUS</Help>
<MilitarySupport>true</MilitarySupport>
<MilitaryProduction>true</MilitaryProduction>
<Pillage>true</Pillage>
<IgnoreBuildingDefense>true</IgnoreBuildingDefense>
<ObsoleteTech>TECH_COMPUTERS</ObsoleteTech>
<!-- <GoodyHutUpgradeUnitClass>UNITCLASS_ANTI_TANK_GUN</GoodyHutUpgradeUnitClass> -->
<AdvancedStartCost>30</AdvancedStartCost>
<XPValueAttack>3</XPValueAttack>
<XPValueDefense>3</XPValueDefense>
<SpecialCargo>SPECIALUNIT_FIGHTER</SpecialCargo>
<UnitArtInfo>ART_DEF_UNIT_SMOKEY_STEAM_AIRSHIP_LEVEL_1</UnitArtInfo>
<UnitFlagIconOffset>7</UnitFlagIconOffset>
<UnitFlagAtlas>EXPANSION_SCEN_UNIT_FLAG_ATLAS</UnitFlagAtlas>
<IconAtlas>EXPANSION_SCEN_UNIT_ATLAS</IconAtlas>
<PortraitIndex>7</PortraitIndex>
<MoveRate>WHEELED</MoveRate>
</Row>
</Units>

<Unit_AITypes>
<Row>
<UnitType>UNIT_AIRSHIP</UnitType>
<UnitAIType>UNITAI_FAST_ATTACK</UnitAIType>
</Row>
<Row>
<UnitType>UNIT_AIRSHIP</UnitType>
<UnitAIType>UNITAI_EXPLORE_SEA</UnitAIType>
</Row>
<Row>
<UnitType>UNIT_AIRSHIP</UnitType>
<UnitAIType>UNITAI_ESCORT_SEA</UnitAIType>
</Row>
<Row>
<UnitType>UNIT_AIRSHIP</UnitType>
<UnitAIType>UNITAI_CARRIER_SEA</UnitAIType>
</Row>
</Unit_AITypes>

<UnitPromotions>
<Row>
<Type>PROMOTION_MOVE_ALL_TERRAIN</Type>
<Description>TXT_KEY_PROMOTION_MOVE_ALL_TERRAIN</Description>
<Help>TXT_KEY_PROMOTION_MOVE_ALL_TERRAIN_HELP</Help>
<Sound>AS2D_IF_LEVELUP</Sound>
<IconAtlas>ABILITY_ATLAS</IconAtlas>
<PediaType>PEDIA_ATTRIBUTES</PediaType>
<PortraitIndex>58</PortraitIndex>
<PediaEntry>TXT_KEY_PROMOTION_MOVE_ALL_TERRAIN</PediaEntry>
<CanMoveAllTerrain>true</CanMoveAllTerrain>
<LostWithUpgrade>1</LostWithUpgrade>
</Row>
<!-- <Row>
<Type>PROMOTION_FLAT_MOVEMENT_COST_A</Type>
<Description>TXT_KEY_PROMOTION_FLAT_MOVEMENT_COST</Description>
<Help>TXT_KEY_PROMOTION_FLAT_MOVEMENT_COST</Help>
<Sound>AS2D_IF_LEVELUP</Sound>
<FlatMovementCost>true</FlatMovementCost>
<LostWithUpgrade>true</LostWithUpgrade>
<PortraitIndex>58</PortraitIndex>
<IconAtlas>ABILITY_ATLAS</IconAtlas>
<PediaType>PEDIA_ATTRIBUTES</PediaType>
<PediaEntry>TXT_KEY_PEDIA_PROMOTION_FLAT_MOVEMENT_COST</PediaEntry>
</Row>
<Row>
<Type>PROMOTION_HOVERING_UNIT_A</Type>
<Description>TXT_KEY_PROMOTION_HOVERING_UNIT</Description>
<Help>TXT_KEY_PROMOTION_HOVERING_UNIT_HELP</Help>
<Sound>AS2D_IF_LEVELUP</Sound>
<CanMoveImpassable>true</CanMoveImpassable>
<LostWithUpgrade>true</LostWithUpgrade>
<HoveringUnit>true</HoveringUnit>
<PortraitIndex>58</PortraitIndex>
<IconAtlas>ABILITY_ATLAS</IconAtlas>
<PediaType>PEDIA_ATTRIBUTES</PediaType>
<PediaEntry>TXT_KEY_PEDIA_PROMOTION_HOVERING_UNIT</PediaEntry>
</Row> -->

<Row>
<Type>PROMOTION_NO_CAPTURE_A</Type>
<Description>TXT_KEY_PROMOTION_NO_CAPTURE</Description>
<Help>TXT_KEY_PROMOTION_NO_CAPTURE</Help>
<Sound>AS2D_IF_LEVELUP</Sound>
<NoCapture>true</NoCapture>
<LostWithUpgrade>true</LostWithUpgrade>
<PortraitIndex>57</PortraitIndex>
<IconAtlas>ABILITY_ATLAS</IconAtlas>
<PediaType>PEDIA_ATTRIBUTES</PediaType>
<PediaEntry>TXT_KEY_PEDIA_PROMOTION_NO_CAPTURE</PediaEntry>
</Row>
</UnitPromotions>

<UnitPromotions_UnitCombats>
<Delete UnitCombatType="UNITCOMBAT_HELICOPTER" PromotionType="PROMOTION_EMBARKATION"/>
<Delete UnitCombatType="UNITCOMBAT_HELICOPTER" PromotionType="PROMOTION_DEFENSIVE_EMBARKATION"/>
<Delete UnitCombatType="UNITCOMBAT_HELICOPTER" PromotionType="PROMOTION_ALLWATER_EMBARKATION"/>
</UnitPromotions_UnitCombats>


<Unit_FreePromotions>
<Row>
<UnitType>UNIT_AIRSHIP</UnitType>
<PromotionType>PROMOTION_FLAT_MOVEMENT_COST</PromotionType>
</Row>
<Row>
<UnitType>UNIT_AIRSHIP</UnitType>
<PromotionType>PROMOTION_HOVERING_UNIT</PromotionType>
</Row>
<Row>
<UnitType>UNIT_AIRSHIP</UnitType>
<PromotionType>PROMOTION_SEE_INVISIBLE_SUBMARINE</PromotionType>
</Row>
<Row>
<UnitType>UNIT_AIRSHIP</UnitType>
<PromotionType>PROMOTION_NO_DEFENSIVE_BONUSES</PromotionType>
</Row>
<Row>
<UnitType>UNIT_AIRSHIP</UnitType>
<PromotionType>PROMOTION_NO_CAPTURE_A</PromotionType>
</Row>
<Row>
<UnitType>UNIT_AIRSHIP</UnitType>
<PromotionType>PROMOTION_EXTRA_SIGHT_II</PromotionType>
</Row>
<Row>
<UnitType>UNIT_AIRSHIP</UnitType>
<PromotionType>PROMOTION_CARGO_I</PromotionType>
</Row>
<Row>
<UnitType>UNIT_AIRSHIP</UnitType>
<PromotionType>PROMOTION_MOVE_ALL_TERRAIN</PromotionType>
</Row>
<Row>
<UnitType>UNIT_AIRSHIP</UnitType>
<PromotionType>PROMOTION_CAN_MOVE_IMPASSABLE</PromotionType>
</Row>
</Unit_FreePromotions>


<Unit_ClassUpgrades>

</Unit_ClassUpgrades>

<Unit_Flavors>
<Row>
<UnitType>UNIT_AIRSHIP</UnitType>
<FlavorType>FLAVOR_OFFENSE</FlavorType>
<Flavor>9</Flavor>
</Row>
<Row>
<UnitType>UNIT_AIRSHIP</UnitType>
<FlavorType>FLAVOR_DEFENSE</FlavorType>
<Flavor>7</Flavor>
</Row>
<Row>
<UnitType>UNIT_AIRSHIP</UnitType>
<FlavorType>FLAVOR_MOBILE</FlavorType>
<Flavor>12</Flavor>
</Row>
</Unit_Flavors>

<Unit_ResourceQuantityRequirements>

</Unit_ResourceQuantityRequirements>

<UnitGameplay2DScripts>
<Row UnitType="UNIT_AIRSHIP">
<SelectionSound>AS2D_SELECT_BOMBER</SelectionSound>
<FirstSelectionSound>AS2D_BIRTH_BOMBER</FirstSelectionSound>
</Row>
</UnitGameplay2DScripts>

</GameData>


Moderator Action: Moved to the main C&C forums as that is where questions should be posted.
 
You can create a new combat class using XML code like this:

Code:
	<UnitCombatInfos>
		<Row>
			<Type>UNITCOMBAT_MYCLASS</Type>
			<Description>TXT_KEY_UNITCOMBAT_MYCLASS</Description>
		</Row>
	</UnitCombatInfos>

(Of course this should be within the <GameData> tags.)

But the last time I tried to do it, the combat animations of units belonging to the new combat class weren't played. There is a small chance that this was changed in the latest expansions and patches, so you can test it yourself.

Edit: My research suggests that you might be able to get the new combat class working if you name it UNITCOMBAT_NAVAL. It doesn't have to be really naval units, just use this name. I haven't checked if it works, but there is a good chance it does. (I assume you use BNW.)
 
Top Bottom