Help creating a new unit!

Gazebo

Lord of the Community Patch
Supporter
Joined
Sep 26, 2010
Messages
18,399
Location
Little Rock
Here's the deal- im trying to make a new unit, however for some reason its graphic always defaults to a spearmen. Here's the code:

Code:
<?xml version="1.0" encoding="utf-8"?>
<!-- Created by ModBuddy on 10/9/2010 10:46:17 PM -->
<UnitArtInfos>
	<UnitArtInfo>
		<Type>ART_DEF_UNIT_MESSENGER</Type>
		<Formation>LooseCivilian</Formation>
		<DamageStates>1</DamageStates>
		<UnitMemberArt>
			<MemberType>ART_DEF_UNIT_MEMBER_EUROMALE20</MemberType>
			<MemberCount>1</MemberCount>
		</UnitMemberArt>
	</UnitArtInfo>
</UnitArtInfos>
 
Seriously, I am about to go insane. There is NO reason why my unit should show up as a spearman and yet it ALWAYS does. Any ideas??

Code:
<Class>UNITCLASS_MESSENGER</Class>
			<Type>UNIT_MESSENGER</Type>
			<Cost>100</Cost>
			<Moves>3</Moves>
			<CombatClass>UNITCOMBAT_RECON</CombatClass>
			<Domain>DOMAIN_LAND</Domain>
			<DefaultUnitAI>UNITAI_MERCHANT</DefaultUnitAI>
			<Description>TXT_KEY_UNIT_MESSENGER</Description>
			<Civilopedia>TXT_KEY_CIV5_ANTIQUITY_MESSENGER_TEXT</Civilopedia>
			<Strategy>TXT_KEY_UNIT_DIPLOMAT_STRATEGY</Strategy>
			<Help>TXT_KEY_UNIT_HELP_DIPLOMAT</Help>
			<AdvancedStartCost>30</AdvancedStartCost>
			<PrereqTech>TECH_WRITING</PrereqTech>
			<ObsoleteTech>TECH_PRINTING_PRESS</ObsoleteTech>
			<WorkRate>1</WorkRate>
			<CombatLimit>0</CombatLimit>
			<BaseGold>5</BaseGold>
			<UnitArtInfo>ART_DEF_UNIT_MESSENGER</UnitArtInfo>
			<UnitFlagIconOffset>0</UnitFlagIconOffset>
			<IconAtlas>DIPLOMAT_ATLAS</IconAtlas>
			<UnitFlagAtlas>DIPLOMAT_ATLAS</UnitFlagAtlas>
			<PortraitIndex>0</PortraitIndex>

Code:
<UnitArtInfos>
	<UnitArtInfo>
		<Type>ART_DEF_UNIT_MESSENGER</Type>
		<Formation>DefaultCavalry</Formation>
		<DamageStates>1</DamageStates>
		<UnitMemberArt>
			<MemberType>ART_DEF_UNIT_MEMBER_HORSEMAN</MemberType>
			<MemberCount>1</MemberCount>
		</UnitMemberArt>
	</UnitArtInfo>
</UnitArtInfos>
 
Did you copy and paste the whole unmodded files called , Civ5ArtDefines_SV_Units.xml , Civ5ArtDefines_UnitMembers.xml , Civ5ArtDefines_Units.xml. I think you need every entry in there even if you dont change them, I could be wrong but thats what I did and it works. I was just going by the Queen of Iceni mod.

The first thing I would do is check to see if my unit is right .. by picking something that is unmodified. Try changing the art to an unchanged archer unit. It should change ... if not something is wrong. It will show up as a spearman unit if there are problems somewhere in one of the files.

EDIT
Looks like you did pick an unmodified unit ... if you did copy and paste the whole files and not just the info you needed for your unit (I would do the whole file I think , they are very small and I dont think it would hurt anything) Then did you make a new entry into the third file like this ..

Spoiler :

you remember my semaphore from the changing icons little write up I did. I added this code in the CivArtDefines_SV_Units.xml

I am not sure if you need to do this code or not ... I think I had to because I made some other changes.
Code:
             <ArtInfo>
		<Type>ART_DEF_UNIT_SEMAPHORE</Type>
		<Asset>SV_Scout.dds</Asset>
	</ArtInfo>


Spoiler :

I also created s file I called Civ5UnitClasses.xml

This seemed to help unbreak some things for my custom unit.

Code:
<GameData>
	<UnitClasses>
		<Row>
			<Type>UNITCLASS_SEMAPHORE</Type>
			<Description>TXT_KEY_UNIT_SCOUT</Description>
			<DefaultUnit>UNIT_SCOUT</DefaultUnit>
		</Row>
	</UnitClasses> 
</GameData>

 
Did you copy and paste the whole unmodded files called , Civ5ArtDefines_SV_Units.xml , Civ5ArtDefines_UnitMembers.xml , Civ5ArtDefines_Units.xml. I think you need every entry in there even if you dont change them, I could be wrong but thats what I did and it works. I was just going by the Queen of Iceni mod.

The first thing I would do is check to see if my unit is right .. by picking something that is unmodified. Try changing the art to an unchanged archer unit. It should change ... if not something is wrong. It will show up as a spearman unit if there are problems somewhere in one of the files.


I'll try adding all of the parts of those .xml files– right now I just have the parts I changed, which might be the problem. I've tried using preexisting models (like the scout) and it works fine– its just when I try to use my own models.
 
check my post again , did you do the second spoiler ?

I did some reeditting and I think you looked before I was done
 
Still not working. I'll post all the code I've added so you can see if there are any errors. It won't have the top <> b/c I am copying and pasting:

Code:
<UnitArtInfo>
		<Type>ART_DEF_UNIT_MESSENGER</Type>
		<DamageStates>1</DamageStates>
		<UnitMemberArt>
			<MemberType>ART_DEF_UNIT_MEMBER_SCOUT</MemberType>
			<MemberCount>1</MemberCount>
		</UnitMemberArt>
	</UnitArtInfo>
</UnitArtInfos>

Code:
<UnitClasses>
		<Row>
			<Type>UNITCLASS_DIPLOMAT</Type>
			<Description>TXT_KEY_UNIT_DIPLOMAT</Description>
			<DefaultUnit>UNIT_DIPLOMAT</DefaultUnit>
		</Row>

Code:
<ArtInfo>
		<Type>ART_DEF_UNIT_MESSENGER</Type>
		<Asset>SV_Scout.dds</Asset>
	</ArtInfo>
</SVUnitArtInfos>

Code:
<Units>
		<Row>
			<Class>UNITCLASS_MESSENGER</Class>
			<Type>UNIT_MESSENGER</Type>
			<Cost>100</Cost>
			<Moves>3</Moves>
			<CombatClass>UNITCOMBAT_RECON</CombatClass>
			<Domain>DOMAIN_LAND</Domain>
			<DefaultUnitAI>UNITAI_MERCHANT</DefaultUnitAI>
			<Description>TXT_KEY_UNIT_MESSENGER</Description>
			<Civilopedia>TXT_KEY_CIV5_ANTIQUITY_MESSENGER_TEXT</Civilopedia>
			<Strategy>TXT_KEY_UNIT_DIPLOMAT_STRATEGY</Strategy>
			<Help>TXT_KEY_UNIT_HELP_DIPLOMAT</Help>
			<AdvancedStartCost>30</AdvancedStartCost>
			<PrereqTech>TECH_WRITING</PrereqTech>
			<ObsoleteTech>TECH_PRINTING_PRESS</ObsoleteTech>
			<WorkRate>1</WorkRate>
			<CombatLimit>0</CombatLimit>
			<BaseGold>5</BaseGold>
			<UnitArtInfo>ART_DEF_UNIT_MESSENGER</UnitArtInfo>
			<UnitFlagIconOffset>0</UnitFlagIconOffset>
			<IconAtlas>DIPLOMAT_ATLAS</IconAtlas>
			<UnitFlagAtlas>DIPLOMAT_ATLAS</UnitFlagAtlas>
			<PortraitIndex>0</PortraitIndex>
		</Row>
 
change this and see what happens ... first thing that caught my eye .. I am still looking

Code:
<UnitClasses>
		<Row>
			[color=red]<Type>UNITCLASS_MESSENGER</Type>[/color]
			<Description>TXT_KEY_UNIT_DIPLOMAT</Description>
			<DefaultUnit>UNIT_DIPLOMAT</DefaultUnit>
		</Row>
</UnitClasses>
 
Yea the strategic icons are not right for me either ... I have no idea how to fix that. Whats really odd is the strategic icon for my initial settler before I turn him into my first city has an icon of a warrior in strategic view ... and my game almost crashed when I clicked on them.

as for the other unit class thing .. I dont know ... the way you have it set up is different from the way I did it ... my unit was broken until I made the change and then it started to work normally ... so I could see it on the research timeline thing and the production queue.
 
I think I know how to do it... try resizing the icon file you made for the flag and making a new entry in the iconatlastexture.xml, I would start with the "unit" sizes in the below table. We already created the "UnitFlag" one for 32.

If I had to guess I think it is probably "unit" 64 maybe 80...

You may not have to resize the flag .. it might stretch to fit .... try that before making a new resized dds file.

I will try in a bit , I am in the middle of something else right now. Let me know if you get it working.


Each icon atlas is partitioned by the individual size of the icon itself.
Various icon types have their own unique set of atlases and sizes that they use.

Here are some example sizes:

Promotions 256, 64, 45, 32
Buildings 256, 128, 64, 45
Citizens 256, 128, 64, 45, 32
Civ Symbols 256, 128, 80, 64, 45, 32
Difficulties 128, 64, 32
GameSpeeds 128, 64, 32
Leaders 256, 128, 64
Natural Wonders 256, 128, 80, 64, 45
Policies 256, 64
Resources 256, 80, 64, 45
Technologies 256, 214, 128, 80, 64, 45
Terrain 256, 64
Unit Actions 64, 45
Units 256, 128, 80, 64, 45
Unit Flags 32
World Sizes 128, 64, 32
World Types 128, 64, 32
 
I dunno. I've messed with it for awhile and it just seems to break the other icons in the game- i.e. settlers become archers (icon), barbarians become missiles, etc. all the icons break.

Perhaps we would have to replace the games atlas file for flags (it has one- called UnitFlagWhite.dds)

Or just use flags from that file. Other than that, my mod works!!
 
DDS files are handled automatically and added to some sort of background magic DDS database that doesn't need paths (so I guess the filenames need to not collide with builtin ones). They don't need actions associated with them.
 
DDS files are handled automatically and added to some sort of background magic DDS database that doesn't need paths (so I guess the filenames need to not collide with builtin ones). They don't need actions associated with them.


Not sure what you mean...are you saying we don't need to use the <IconFlagAtlas> command in the Civ5Unit.xml file? As it stands now, the game doesn't use my 32px icon for my units in the normal view unless I set the command <IconFlagAtlas>DIPLOMAT_FLAG_ATLAS</IconFlagAtlas>. Doing this, however, breaks all other 'civilian' flags like settlers, etc (in the strategic view) and my icon still doesn't work in strategic view. Meh.
 
Not sure what you mean...are you saying we don't need to use the <IconFlagAtlas> command in the Civ5Unit.xml file? As it stands now, the game doesn't use my 32px icon for my units in the normal view unless I set the command <IconFlagAtlas>DIPLOMAT_FLAG_ATLAS</IconFlagAtlas>. Doing this, however, breaks all other 'civilian' flags like settlers, etc (in the strategic view) and my icon still doesn't work in strategic view. Meh.
No, I mean they don't need any OnLoadMod actions... as to the rest, that sounds perplexing and I have no idea. It makes very little sense at all, to be honest... I'll be looking into it in the nearish future, but I want to sort out modular resources and work on some other elements of my recent modern/near future expanding mod suite (largely in planning stage due to delay of fixing resources).
 
Back
Top Bottom