New Unit Not Appearing

Chris41336

Chieftain
Joined
Oct 19, 2008
Messages
84
Hello All,

I created a new Unit Class (and unit type to go along with it) and I set the Ottomans to start with this unit to test it in game and for some reason I cannot get the Unit to appear in game or be producable early on, despite the fact that I made the prereq tech for the unit Agriculture.

I will paste the code below for anybody to tell me if they can see a problem:

This is my XML file for the new unit (I placed it all in the same XML file for simplicity):

Code:
<GameData>
	<UnitClasses>
		<Row>
			<Type>UNITCLASS_ROYAL_GUARD</Type>
			<Description>TXT_KEY_UNIT_ROYAL_GUARD</Description>
			<DefaultUnit>UNIT_ROYAL_GUARD</DefaultUnit>
		</Row>
	</UnitClasses>
	<Units>
		<Row>
			<Class>UNITCLASS_ROYAL_GUARD</Class>
			<Type>UNIT_ROYAL_GUARD</Type>
			<PrereqTech>TECH_AGRICULTURE</PrereqTech>
			<Combat>20</Combat>
			<Cost>150</Cost>
			<Moves>5</Moves>
			<CombatClass>UNITCOMBAT_MOUNTED</CombatClass>
			<Domain>DOMAIN_LAND</Domain>
			<DefaultUnitAI>UNITAI_ATTACK</DefaultUnitAI>
			<Description>TXT_KEY_UNIT_ROYAL_GUARD</Description>
			<Civilopedia>TXT_KEY_CIVILOPEDIA_UNITS_MEDIEVAL_KNIGHT_TEXT</Civilopedia>
			<Strategy>TXT_KEY_UNIT_KNIGHT_STRATEGY</Strategy>
			<Help>TXT_KEY_UNIT_HELP_ROYAL_GUARD</Help>
			<MilitarySupport>true</MilitarySupport>
			<MilitaryProduction>true</MilitaryProduction>
			<Pillage>true</Pillage>
			<ObsoleteTech>TECH_MILITARY_SCIENCE</ObsoleteTech>
			<GoodyHutUpgradeUnitClass>UNITCLASS_CAVALRY</GoodyHutUpgradeUnitClass>
			<AdvancedStartCost>25</AdvancedStartCost>
			<XPValueAttack>3</XPValueAttack>
			<XPValueDefense>3</XPValueDefense>
			<UnitArtInfo>ART_DEF_UNIT_ROYAL_GUARD</UnitArtInfo>
			<UnitFlagIconOffset>25</UnitFlagIconOffset>
			<IconAtlas>UNIT_ATLAS_1</IconAtlas>
			<PortraitIndex>26</PortraitIndex>
			<MoveRate>QUADRUPED</MoveRate>
		</Row>
	</Units>
	<Unit_FreePromotions>
		<Row>
			<UnitType>UNIT_ROYAL_GUARD</UnitType>
			<PromotionType>PROMOTION_GREAT_GENERAL</PromotionType>
		</Row>
		<Row>
			<UnitType>UNIT_ROYAL_GUARD</UnitType>
			<PromotionType>PROMOTION_BLITZ</PromotionType>
		</Row>
	</Unit_FreePromotions>
	<Unit_AITypes>
		<Row>
			<UnitType>UNIT_ROYAL_GUARD</UnitType>
			<UnitAIType>UNITAI_ATTACK</UnitAIType>
		</Row>
		<Row>
			<UnitType>UNIT_ROYAL_GUARD</UnitType>
			<UnitAIType>UNITAI_DEFENSE</UnitAIType>
		</Row>
		<Row>
			<UnitType>UNIT_ROYAL_GUARD</UnitType>
			<UnitAIType>UNITAI_EXPLORE</UnitAIType>
		</Row>
	</Unit_AITypes>
	<Unit_Flavors>
		<Row>
			<UnitType>UNIT_ROYAL_GUARD</UnitType>
			<FlavorType>FLAVOR_RECON</FlavorType>
			<Flavor>1</Flavor>
		</Row>
		<Row>
			<UnitType>UNIT_ROYAL_GUARD</UnitType>
			<FlavorType>FLAVOR_OFFENSE</FlavorType>
			<Flavor>2</Flavor>
		</Row>
		<Row>
			<UnitType>UNIT_ROYAL_GUARD</UnitType>
			<FlavorType>FLAVOR_DEFENSE</FlavorType>
			<Flavor>2</Flavor>
		</Row>
	</Unit_Flavors>
	<Row Tag="TXT_KEY_UNIT_ROYAL_GUARD">
		<Text>Royal Guard</Text>
	</Row>
	<Row Tag="TXT_KEY_UNIT_HELP_ROYAL_GUARD">
		<Text>This is your King's royal guard, accompanied by your majesty himself. Although a powerful unit, be sure to protect your King!</Text>
	</Row>
</GameData>

And this is for making the Ottomans start with one (added to a copied version of Civ5Civilizations.xml):

Code:
<Row>
			<CivilizationType>CIVILIZATION_OTTOMAN</CivilizationType>
			<UnitClassType>UNITCLASS_SETTLER</UnitClassType>
			<Count>1</Count>
			<UnitAIType>UNITAI_SETTLE</UnitAIType>
		</Row>
		<Row>
			<CivilizationType>CIVILIZATION_OTTOMAN</CivilizationType>
			<UnitClassType>UNITCLASS_ROYAL_GUARD</UnitClassType>
			<Count>1</Count>
			<UnitAIType>UNITAI_DEFENSE</UnitAIType>
		</Row>

And here is the ArtDefine:

Code:
<UnitArtInfos>
		<UnitArtInfo>
			<Type>ART_DEF_UNIT_ROYAL_GUARD</Type>
			<Formation>DefaultCavalry</Formation>
			<DamageStates>1</DamageStates>
			<UnitMemberArt>
				<MemberType>ART_DEF_UNIT_MEMBER_ROYAL_GUARD_KING</MemberType>
				<MemberCount>1</MemberCount>
			</UnitMemberArt>
			<UnitMemberArt>
				<MemberType>ART_DEF_UNIT_MEMBER_ROYAL_GUARD</MemberType>
				<MemberCount>4</MemberCount>
			</UnitMemberArt>
		</UnitArtInfo>
	</UnitArtInfos>

(all of the ART_DEF are also uploaded to the mod, the .dds files and fxsxml and gr2 files. They are basically just Knight graphics with a color scheme change.)

I also ensured that I sed OnModActivated to UpdateDatabase with all of the new XML files I have in my mod. Just another question: do any XML files that I am adding to need to contain all of the info from the original Civ 5 stuff, or can I just create an entirely new XML document with new code and the game will understand to implement that code where necessary? Thanks in advance guys.
 
1. Missing the <Language_en_US> around;
<Row Tag="TXT_KEY_UNIT_ROYAL_GUARD">
<Text>Royal Guard</Text>
</Row>
<Row Tag="TXT_KEY_UNIT_HELP_ROYAL_GUARD">
<Text>This is your King's royal guard, accompanied by your majesty himself. Although a powerful unit, be sure to protect your King!</Text>


Add that, try again, should work from the looks of it.
 
Any update to the art defines file has to contain the whole art defines file, it will also be overwritten by any later loaded mod that has it's own artdefines file. So if you set your unit to use a new animation instead of one of the defaults and the artdefines file doesn't contain the ART_DEF_UNIT_ROYAL_GUARD either (as in this case) because you haven't supplied the whole file, or because someone else overwrote your file, then the unit won't show. I'm willing to bet if you switch ART_DEF_UNIT_ROYAL_GUARD too ART_DEF_UNIT_KNIGHT, and fix the <Language_en_US> as stated already, that your unit will show up.

Honestly at the moment unless your mod is focused on new unit animations (like R.E.D. is) then at this time it's not worth adding them, since any mod that IS focused on that will most likely be desired over yours and thus yours will break and not work. It's the reason I'm not using any new animations in my two current mods but the total conversion I'm working on WILL because if they are playing a total conversion then most likely they aren't using other random mods.
 
Thank you for the quixk replies guys! I will attempt this when I get back from work:

Elistor, I don't have any custom animations. I just took the Knight and reskinned it. I wanted it to look and act just like a Knight with a slightly different color scheme. Shouldn't that allow it to work, since the animations for the Knight are already fully loaded into the game? (NOTE: I used GrannyMaterialHacker in Nexus to accomplish this, if that helps at all.)
 
Unfortunately not. When I say new animation I don't mean from scratch new but "I did something with a <UnitArtInfos> tag in it" new. At one point for my two mods I'd planed on doing what Kael did with his Gaelic warrior, IE grab an existing animation and apply it differently with XML, but I quickly realized that if I did I'd be overwriting anyone else <UnitArtInfos> tags because I have to provide the whole file and thus wouldn't have there changes. I wish it where as modular as the rest of the XML but this is the one area where the modablity of the game falls flat on it's face. :sad:
 
Hm. That's pretty lame. I hope that is something they are planning on fixing, because that's pretty limiting. My Royal Guard Unit is going to be pretty lame looking just like a knight. I'll just see if there is a glow effect like the great people have and use that around the unit. Thanks alot you guys!
 
Bad news, I changed both things (added the Language tags and also changed the ART_DEF to knight in the Unit's XML, but the Unit still does not show. I'm thinking it might have something to do with the fact that I created a new Unit Class instead of just making this a UU in an already existing class. Besides just adding the "class" tag at the beginning of my XML, are there any other steps I have to take?
 
Some progress: I edited the warrior art defines to make them my royal guard units, and it worked, which means the mod is successfully recognizing my new meshes. However, translating them into the game is not working, so it is the actual coding itself that is the problem at some point. I will look into this some more and see what I ca come up with. Does anyone have any insight onto making an entire new unit class?
 
Is this an Ottoman unique unit? You didn't set that at all.
 
Putmalk: it's not the Ottoman Unique Unit. I just set it to start when the ottomans start because I normally play as them and I just wanted to see them in the game moving around. However, I figured it out. I was missing the line of code which deals with the UnitIcon =P. Such a silly line kept my unit from entering the game.

Now I just need the codes which control the starting units for the civs =/.
 
Back
Top Bottom