| General | Hosted Sites | Civ5 | CivRev | Civ4Col | Civ4 | Civ3 | Civ2 | Civ1 | Misc | Marketplace |
![]() |
|
|
Welcome to Civilization Fanatics' Center. You are currently viewing our site as a guest which gives you limited access to our site features. By joining our free community, you will be able to participate in the discussions, search the forum, send private messages, vote in polls, upload your own screenshots to the gallery, and access many other special features. Registration is fast, simple and absolutely free, so sign up today! If you have any problems with the registration process or your account login, please contact support. |
|
|||||||
![]() |
|
|
Thread Tools |
|
|
#1 |
|
Moderator
![]() Join Date: Oct 2004
Location: France
Posts: 3,762
|
Add a new unit in the game (using SQL)
This tutorial is a step by step to add a new unit in the game, it won't covert the creation of a new unit model, there are other tutorials about that.
It assumes that you know how to create a basic mod, and understand the meaning of "OnModActivated" It applies for Civilization and G+K post patch .674, since that patch you don't have (and in fact can't) to replace Civ5ArtDefines_UnitMembers.xml and Civ5ArtDefines_Units.xml. The only file related to units which is still not loaded to the Database (and so have to be replaced in a mod using the VFS property) is unitformations.xml. But unless you want to change the default formations, you won't need it. Note that previous version of the tutorials made a bad use of double-quote in the SQL code, see here why you shouldn't use them and please refer to the now corrected code. The exception for using double-quote is when a SQL keyword is used as a table of column name, as it is the case with "Index" column in ArtDefine_UnitMemberCombats table (see code in step 4) Pre-required : Right click your mod project in the Solution explorer windows, select "properties", go in the "Mod Info" panel, and check the "Reload Unit System" in the "Systems" section. step 1 : For the tutorial, we're taking the example of the biplan from this danrell's units pack, supposing that we want to add a WW1 era fighter to civ5 vanilla. Here are the files requested by this unit model: EarlyFighter_Generic_gloss.dds EarlyFighter_Generic.gr2 EarlyFighter_Generic.fxsxml EarlyFighter_Generic.dds All this files must be copied in your project and have the VFS property set to "true". I'll suggest you to organize your project using folders and subfolders if you have to put many files in it, the VFS will not care for the relative path. Danrell also provide the blend file and a jpg screenshot, those are not needed in your mod, but the blend is a must for those who want to edit the model itself, go and thanks him again for his work ![]() step 2 : create a new sql file in your project (right click the project name or one of it's subfolder in the Solution Explorer windows, select "Add", "New Item..." and Game Rules (SQL) Rename it, or keep the original Game Rules1.sql. You don't need to set the VFS to true for that file, but you have to add an UpdateDatabase entry for it. step 3 : For that right click your mod project in the Solution explorer windows, select "properties", go in the "Action" panel, click "Add...", select "OnModActivated" as event, "UpdateDatabase" as Action, and point File to your newly created SQL file. As this is a step by step mod, I won't detailed the SQL commands used here, just follow the steps and all will goes well (I hope )An XML tutorial may be more user friendly, but I really found the SQL method more efficient. step 4 : Now open the sql file and add the following code to it : Code:
INSERT INTO ArtDefine_UnitInfos (Type,DamageStates,Formation)
SELECT ('ART_DEF_UNIT_BIPLAN'), DamageStates, Formation
FROM ArtDefine_UnitInfos WHERE (Type = 'ART_DEF_UNIT_FIGHTER');
INSERT INTO ArtDefine_UnitInfoMemberInfos (UnitInfoType,UnitMemberInfoType,NumMembers)
SELECT ('ART_DEF_UNIT_BIPLAN'), ('ART_DEF_UNIT_MEMBER_BIPLAN'), NumMembers
FROM ArtDefine_UnitInfoMemberInfos WHERE (UnitInfoType = 'ART_DEF_UNIT_FIGHTER');
INSERT INTO ArtDefine_UnitMemberCombats (UnitMemberType, EnableActions, DisableActions, MoveRadius, ShortMoveRadius, ChargeRadius, AttackRadius, RangedAttackRadius, MoveRate, ShortMoveRate, TurnRateMin, TurnRateMax, TurnFacingRateMin, TurnFacingRateMax, RollRateMin, RollRateMax, PitchRateMin, PitchRateMax, LOSRadiusScale, TargetRadius, TargetHeight, HasShortRangedAttack, HasLongRangedAttack, HasLeftRightAttack, HasStationaryMelee, HasStationaryRangedAttack, HasRefaceAfterCombat, ReformBeforeCombat, HasIndependentWeaponFacing, HasOpponentTracking, HasCollisionAttack, AttackAltitude, AltitudeDecelerationDistance, OnlyTurnInMovementActions, RushAttackFormation)
SELECT ('ART_DEF_UNIT_MEMBER_BIPLAN'), EnableActions, DisableActions, MoveRadius, ShortMoveRadius, ChargeRadius, AttackRadius, RangedAttackRadius, MoveRate, ShortMoveRate, TurnRateMin, TurnRateMax, TurnFacingRateMin, TurnFacingRateMax, RollRateMin, RollRateMax, PitchRateMin, PitchRateMax, LOSRadiusScale, TargetRadius, TargetHeight, HasShortRangedAttack, HasLongRangedAttack, HasLeftRightAttack, HasStationaryMelee, HasStationaryRangedAttack, HasRefaceAfterCombat, ReformBeforeCombat, HasIndependentWeaponFacing, HasOpponentTracking, HasCollisionAttack, AttackAltitude, AltitudeDecelerationDistance, OnlyTurnInMovementActions, RushAttackFormation
FROM ArtDefine_UnitMemberCombats WHERE (UnitMemberType = 'ART_DEF_UNIT_MEMBER_FIGHTER');
INSERT INTO ArtDefine_UnitMemberCombatWeapons (UnitMemberType, "Index", SubIndex, ID, VisKillStrengthMin, VisKillStrengthMax, ProjectileSpeed, ProjectileTurnRateMin, ProjectileTurnRateMax, HitEffect, HitEffectScale, HitRadius, ProjectileChildEffectScale, AreaDamageDelay, ContinuousFire, WaitForEffectCompletion, TargetGround, IsDropped, WeaponTypeTag, WeaponTypeSoundOverrideTag)
SELECT ('ART_DEF_UNIT_MEMBER_BIPLAN'), "Index", SubIndex, ID, VisKillStrengthMin, VisKillStrengthMax, ProjectileSpeed, ProjectileTurnRateMin, ProjectileTurnRateMax, HitEffect, HitEffectScale, HitRadius, ProjectileChildEffectScale, AreaDamageDelay, ContinuousFire, WaitForEffectCompletion, TargetGround, IsDropped, WeaponTypeTag, WeaponTypeSoundOverrideTag
FROM ArtDefine_UnitMemberCombatWeapons WHERE (UnitMemberType = 'ART_DEF_UNIT_MEMBER_FIGHTER');
INSERT INTO ArtDefine_UnitMemberInfos (Type, Scale, ZOffset, Domain, Model, MaterialTypeTag, MaterialTypeSoundOverrideTag)
SELECT ('ART_DEF_UNIT_MEMBER_BIPLAN'), Scale, ZOffset, Domain, ('EarlyFighter_Generic.fxsxml'), MaterialTypeTag, MaterialTypeSoundOverrideTag
FROM ArtDefine_UnitMemberInfos WHERE (Type = 'ART_DEF_UNIT_MEMBER_FIGHTER');
INSERT INTO ArtDefine_StrategicView (StrategicViewType, TileType, Asset )
SELECT ('ART_DEF_UNIT_BIPLAN'), TileType, Asset
FROM ArtDefine_StrategicView WHERE (Type = 'ART_DEF_UNIT_FIGHTER');
This code define the visual effects for the new unit. I use a "template" unit for reference, so I don't have to manually set each entry, but have the SQL code copy them from the "template" unit (here the normal fighter) and only change those that are needed. Using a template is much faster, but you have to be sure that no other mods will delete the unit you're using as a template. Mods compatibility depend of the loading order and can sometimes be assured using associations, but that's another subject. You can still use SQL to add new entries without duplicating another unit's entry using this syntax: Code:
INSERT INTO table_name (column1, column2, column3,...) VALUES (value1, value2, value3,...); but you may find it easier to use XML in that case, see the second post for an example from whoward69. step 5 : Below is the code for the new unit statistics, add it after in the sql file : Code:
INSERT INTO UnitClasses (Type, Description, MaxGlobalInstances, MaxTeamInstances, MaxPlayerInstances, InstanceCostModifier, DefaultUnit )
SELECT ('UNITCLASS_BIPLAN'), Description, MaxGlobalInstances, MaxTeamInstances, MaxPlayerInstances, InstanceCostModifier, ('UNIT_BIPLAN')
FROM UnitClasses WHERE (Type = 'UNITCLASS_FIGHTER');
INSERT INTO Units (Type, Description, Civilopedia, Strategy, Help, Requirements, Combat, RangedCombat, Cost, Moves, Immobile, Range, BaseSightRange, Class, Special, Capture, CombatClass, Domain, CivilianAttackPriority, DefaultUnitAI, Food, NoBadGoodies, RivalTerritory, MilitarySupport, MilitaryProduction, Pillage, Found, FoundAbroad, CultureBombRadius, GoldenAgeTurns, IgnoreBuildingDefense, PrereqResources, Mechanized, Suicide, CaptureWhileEmbarked, PrereqTech, ObsoleteTech, GoodyHutUpgradeUnitClass, HurryCostModifier, AdvancedStartCost, MinAreaSize, AirUnitCap, NukeDamageLevel, WorkRate, NumFreeTechs, RushBuilding, BaseHurry, HurryMultiplier, BaseGold, NumGoldPerEra, SpreadReligion, CombatLimit, RangeAttackOnlyInDomain, RangeAttackIgnoreLOS, RangedCombatLimit, XPValueAttack, XPValueDefense, SpecialCargo, DomainCargo, Conscription, ExtraMaintenanceCost, NoMaintenance, Unhappiness, UnitArtInfo, UnitArtInfoCulturalVariation, UnitArtInfoEraVariation, ProjectPrereq, SpaceshipProject, LeaderPromotion, LeaderExperience, DontShowYields, ShowInPedia, MoveRate, UnitFlagIconOffset, PortraitIndex, IconAtlas, UnitFlagAtlas)
SELECT ('UNIT_BIPLAN'), ('Biplan'), Civilopedia, Strategy, Help, Requirements,
Combat, (25), (250), Moves, Immobile, (5), BaseSightRange, ('UNITCLASS_BIPLAN'), Special, Capture, CombatClass, Domain, CivilianAttackPriority, DefaultUnitAI, Food, NoBadGoodies, RivalTerritory, MilitarySupport, MilitaryProduction, Pillage, Found, FoundAbroad, CultureBombRadius, GoldenAgeTurns, IgnoreBuildingDefense, PrereqResources, Mechanized, Suicide, CaptureWhileEmbarked, PrereqTech, ObsoleteTech, GoodyHutUpgradeUnitClass, HurryCostModifier, AdvancedStartCost, MinAreaSize, AirUnitCap, NukeDamageLevel, WorkRate, NumFreeTechs, RushBuilding, BaseHurry, HurryMultiplier, BaseGold, NumGoldPerEra, SpreadReligion, CombatLimit, RangeAttackOnlyInDomain, RangeAttackIgnoreLOS, RangedCombatLimit, XPValueAttack, XPValueDefense, SpecialCargo, DomainCargo, Conscription, ExtraMaintenanceCost, NoMaintenance, Unhappiness,
('ART_DEF_UNIT_BIPLAN'), UnitArtInfoCulturalVariation, UnitArtInfoEraVariation, ProjectPrereq, SpaceshipProject, LeaderPromotion, LeaderExperience, DontShowYields, ShowInPedia, MoveRate,
UnitFlagIconOffset, PortraitIndex, IconAtlas, UnitFlagAtlas
FROM Units WHERE (Type = 'UNIT_FIGHTER');
INSERT INTO Unit_AITypes (UnitType, UnitAIType)
SELECT ('UNIT_BIPLAN'), UnitAIType
FROM Unit_AITypes WHERE (UnitType = 'UNIT_FIGHTER');
INSERT INTO Unit_ClassUpgrades (UnitType, UnitClassType)
SELECT ('UNIT_BIPLAN'), UnitClassType
FROM Unit_ClassUpgrades WHERE (UnitType = 'UNIT_FIGHTER');
INSERT INTO Unit_Flavors (UnitType, FlavorType, Flavor)
SELECT ('UNIT_BIPLAN'), FlavorType, Flavor
FROM Unit_Flavors WHERE (UnitType = 'UNIT_FIGHTER');
INSERT INTO Unit_FreePromotions (UnitType, PromotionType)
SELECT ('UNIT_BIPLAN'), PromotionType
FROM Unit_FreePromotions WHERE (UnitType = 'UNIT_FIGHTER');
INSERT INTO Unit_ResourceQuantityRequirements (UnitType, ResourceType, Cost)
SELECT ('UNIT_BIPLAN'), ResourceType, Cost
FROM Unit_ResourceQuantityRequirements WHERE (UnitType = 'UNIT_FIGHTER');
UNIT_BIPLAN is the type of your new unit Biplan is the in game name (25) the ranged attack value (250) the construction cost (5) the range ART_DEF_UNIT_BIPLAN refer to the <Type> of step 4 Fell free to tweak other values, thinking of the requested tech for example... This should be enough for most your new units to work properly, danrell's units may require an extra step extra step : copy the "Common" folder from danrell's pack in your project folder, and set the VFS property to true for all it's files. Needed especially for his tanks and ships. edit : finally converted to post-patch .674 method. Last edited by Gedemon; May 04, 2013 at 09:29 AM. Reason: I forgot something rather important... |
|
|
|
|
|
#2 |
|
Moderator
![]() Join Date: Oct 2004
Location: France
Posts: 3,762
|
XML example
Example of XML file for ArtDefines and unit stats based on whoward69' Units - Galleon (GK) v.2
edit: thanks to him, you can now found XML template for all existing units here. Art defines: Code:
<GameData> <ArtDefine_UnitInfos> <Row> <Type>ART_DEF_UNIT_MOD_GALLEON</Type> <DamageStates>1</DamageStates> <Formation>TwoBigGuns</Formation> </Row> </ArtDefine_UnitInfos> <ArtDefine_UnitInfoMemberInfos> <Row> <UnitInfoType>ART_DEF_UNIT_MOD_GALLEON</UnitInfoType> <UnitMemberInfoType>ART_DEF_UNIT_MEMBER_MOD_GALLEON</UnitMemberInfoType> <NumMembers>1</NumMembers> </Row> </ArtDefine_UnitInfoMemberInfos> <ArtDefine_UnitMemberInfos> <Row> <Type>ART_DEF_UNIT_MEMBER_MOD_GALLEON</Type> <Scale>0.14</Scale> <Domain>Sea</Domain> <Model>Assets/Units/Galleon/Galleon.fxsxml</Model> <MaterialTypeTag>WOOD</MaterialTypeTag> <MaterialTypeSoundOverrideTag>WOODLRG</MaterialTypeSoundOverrideTag> </Row> </ArtDefine_UnitMemberInfos> <ArtDefine_UnitMemberCombats> <Row> <UnitMemberType>ART_DEF_UNIT_MEMBER_MOD_GALLEON</UnitMemberType> <EnableActions>Idle Attack RunCharge AttackCity Bombard Death BombardDefend Run Fortify CombatReady AttackSurfaceToAir</EnableActions> <DisableActions></DisableActions> <HasShortRangedAttack>1</HasShortRangedAttack> <HasLeftRightAttack>1</HasLeftRightAttack> <HasRefaceAfterCombat>0</HasRefaceAfterCombat> <HasIndependentWeaponFacing>1</HasIndependentWeaponFacing> </Row> </ArtDefine_UnitMemberCombats> <ArtDefine_UnitMemberCombatWeapons> <Row> <UnitMemberType>ART_DEF_UNIT_MEMBER_MOD_GALLEON</UnitMemberType> <Index>0</Index> <SubIndex>0</SubIndex> <VisKillStrengthMin>10</VisKillStrengthMin> <VisKillStrengthMax>20</VisKillStrengthMax> <HitEffect>ART_DEF_VEFFECT_CANNON_IMPACT_$(TERRAIN)</HitEffect> <WeaponTypeTag>EXPLOSIVE</WeaponTypeTag> <WeaponTypeSoundOverrideTag>EXPLOSION6POUND</WeaponTypeSoundOverrideTag> </Row> </ArtDefine_UnitMemberCombatWeapons> <ArtDefine_StrategicView> <Row> <StrategicViewType>ART_DEF_UNIT_MOD_GALLEON</StrategicViewType> <TileType>Unit</TileType> <Asset>SV_ModGalleon.dds</Asset> </Row> </ArtDefine_StrategicView> </GameData> Code:
<GameData>
<UnitClasses>
<Row>
<Type>UNITCLASS_GALLEON</Type>
<Description>TXT_KEY_UNIT_GALLEON</Description>
<DefaultUnit>UNIT_GALLEON</DefaultUnit>
</Row>
</UnitClasses>
<Units>
<Row>
<Class>UNITCLASS_GALLEON</Class>
<Type>UNIT_GALLEON</Type>
<PrereqTech>TECH_STEAM_POWER</PrereqTech>
<Combat>40</Combat>
<Cost>250</Cost>
<Moves>4</Moves>
<HurryCostModifier>20</HurryCostModifier>
<CombatClass>UNITCOMBAT_NAVALMELEE</CombatClass>
<Domain>DOMAIN_SEA</Domain>
<DefaultUnitAI>UNITAI_ATTACK_SEA</DefaultUnitAI>
<Description>TXT_KEY_UNIT_GALLEON</Description>
<Civilopedia>TXT_KEY_UNIT_GALLEON_TEXT</Civilopedia>
<Strategy>TXT_KEY_UNIT_GALLEON_STRATEGY</Strategy>
<Help>TXT_KEY_UNIT_GALLEON_HELP</Help>
<MilitarySupport>true</MilitarySupport>
<MilitaryProduction>true</MilitaryProduction>
<Pillage>true</Pillage>
<Mechanized>true</Mechanized>
<ObsoleteTech>TECH_COMBUSTION</ObsoleteTech>
<AdvancedStartCost>50</AdvancedStartCost>
<MinAreaSize>20</MinAreaSize>
<XPValueAttack>3</XPValueAttack>
<XPValueDefense>3</XPValueDefense>
<UnitArtInfo>ART_DEF_UNIT_MOD_GALLEON</UnitArtInfo>
<UnitFlagAtlas>UNITS_GALLEON_FLAG_ATLAS</UnitFlagAtlas>
<UnitFlagIconOffset>0</UnitFlagIconOffset>
<IconAtlas>UNITS_GALLEON_ICON_ATLAS</IconAtlas>
<PortraitIndex>0</PortraitIndex>
<MoveRate>BOAT</MoveRate>
</Row>
</Units>
<Unit_AITypes>
<Row>
<UnitType>UNIT_GALLEON</UnitType>
<UnitAIType>UNITAI_ATTACK_SEA</UnitAIType>
</Row>
<Row>
<UnitType>UNIT_GALLEON</UnitType>
<UnitAIType>UNITAI_RESERVE_SEA</UnitAIType>
</Row>
<Row>
<UnitType>UNIT_GALLEON</UnitType>
<UnitAIType>UNITAI_ESCORT_SEA</UnitAIType>
</Row>
<Row>
<UnitType>UNIT_GALLEON</UnitType>
<UnitAIType>UNITAI_EXPLORE_SEA</UnitAIType>
</Row>
</Unit_AITypes>
<Unit_Flavors>
<Row>
<UnitType>UNIT_GALLEON</UnitType>
<FlavorType>FLAVOR_NAVAL</FlavorType>
<Flavor>5</Flavor>
</Row>
<Row>
<UnitType>UNIT_GALLEON</UnitType>
<FlavorType>FLAVOR_NAVAL_RECON</FlavorType>
<Flavor>6</Flavor>
</Row>
</Unit_Flavors>
<Unit_FreePromotions>
<Row>
<UnitType>UNIT_GALLEON</UnitType>
<PromotionType>PROMOTION_EXTRA_SIGHT_I</PromotionType>
</Row>
</Unit_FreePromotions>
<Unit_ClassUpgrades>
<Row>
<UnitType>UNIT_GALLEON</UnitType>
<UnitClassType>UNITCLASS_DESTROYER</UnitClassType>
</Row>
<Update>
<Where UnitType="UNIT_CARAVEL"/>
<Set UnitClassType="UNITCLASS_GALLEON"/>
</Update>
<Update>
<Where UnitType="UNIT_KOREAN_TURTLE_SHIP"/>
<Set UnitClassType="UNITCLASS_GALLEON"/>
</Update>
</Unit_ClassUpgrades>
<Unit_ResourceQuantityRequirements>
<Row>
<UnitType>UNIT_GALLEON</UnitType>
<ResourceType>RESOURCE_IRON</ResourceType>
</Row>
</Unit_ResourceQuantityRequirements>
<Language_en_US>
<Row Tag="TXT_KEY_UNIT_GALLEON">
<Text>Galleon</Text>
</Row>
<Row Tag="TXT_KEY_UNIT_GALLEON_HELP">
<Text>Fast Renaissance exploration Unit with a large sight radius.</Text>
</Row>
<Row Tag="TXT_KEY_UNIT_GALLEON_STRATEGY">
<Text>The Galleon is a major upgrade to a civilization's naval power. A Ranged unit, it is stronger and faster than a Caravel, and it can enter Deep Ocean hexes. The Galleon has a large sight radius, making it the eyes and ears of the mid-game navy.</Text>
</Row>
<Row Tag="TXT_KEY_UNIT_GALLEON_TEXT">
<Text>The gallen was a mid-size, seagoing vessel used in the 17th century to exploit the world, being an upgrade of the earlier Caravel.</Text>
</Row>
</Language_en_US>
</GameData>
<GameData>
<IconTextureAtlases>
<Row>
<Atlas>UNITS_GALLEON_ICON_ATLAS</Atlas>
<IconSize>256</IconSize>
<Filename>ART/Galleon256.dds</Filename>
<IconsPerRow>8</IconsPerRow>
<IconsPerColumn>6</IconsPerColumn>
</Row>
<Row>
<Atlas>UNITS_GALLEON_ICON_ATLAS</Atlas>
<IconSize>128</IconSize>
<Filename>ART/Galleon128.dds</Filename>
<IconsPerRow>8</IconsPerRow>
<IconsPerColumn>6</IconsPerColumn>
</Row>
<Row>
<Atlas>UNITS_GALLEON_ICON_ATLAS</Atlas>
<IconSize>80</IconSize>
<Filename>ART/Galleon80.dds</Filename>
<IconsPerRow>8</IconsPerRow>
<IconsPerColumn>6</IconsPerColumn>
</Row>
<Row>
<Atlas>UNITS_GALLEON_ICON_ATLAS</Atlas>
<IconSize>64</IconSize>
<Filename>ART/Galleon64.dds</Filename>
<IconsPerRow>8</IconsPerRow>
<IconsPerColumn>6</IconsPerColumn>
</Row>
<Row>
<Atlas>UNITS_GALLEON_ICON_ATLAS</Atlas>
<IconSize>45</IconSize>
<Filename>ART/Galleon45.dds</Filename>
<IconsPerRow>8</IconsPerRow>
<IconsPerColumn>6</IconsPerColumn>
</Row>
<Row>
<Atlas>UNITS_GALLEON_FLAG_ATLAS</Atlas>
<IconSize>32</IconSize>
<Filename>ART/GalleonFlag.dds</Filename>
<IconsPerRow>1</IconsPerRow>
<IconsPerColumn>1</IconsPerColumn>
</Row>
</IconTextureAtlases>
</GameData>
Last edited by Gedemon; Mar 09, 2013 at 04:12 AM. |
|
|
|
|
|
#3 |
|
Proud father and civ-nut!
Join Date: Aug 2003
Location: Eastern Front
Posts: 1,023
|
This should assist more people to get active in modding.
I remember how painful it was to make my first few units work, but with this guide and Kael's combined we have a good source of info.
__________________
“The Pope? How many divisions has he got?” Josef Stalin Current Project: The Great Patriotic War - WWII on the Eastern Front |
|
|
|
|
|
#4 |
|
Emperor
Join Date: Feb 2009
Location: Iowa USA
Posts: 4,266
|
Thanks a million for this Gedemon. This is going to help new modders a great deal. I have some real good ideas, involving a World War One mod.
This is going to be great! I am going to learn this, it will give me something to do while waiting for GnK.
__________________
"All science trembles at the searing logic of your fiery intellect. " Brig. Gen. Lewis A. Armistead Last edited by nokmirt; May 11, 2012 at 12:03 AM. |
|
|
|
|
|
#5 | ||
|
King
Join Date: Mar 2011
Location: Orange County, California, U.S.A.
Posts: 659
|
New Unit Template
Apparently this tutorial wasn't quite enough for some, so I zipped up a small ModBuddy project to use as a template, and have attached it here. [EDIT: Removed because it was no longer valid after the changes from pre-G+K patch and later.]
The template copies the stats of a vanilla unit, and makes a new unique "ethnic" unit with new art for a specific Civ. (Vivastpauli requested a Portuguese knight reskin but then disappeared, so this adds the mostly-finished unit to the game and gives it to Greece to replace their knight.) Note that this template isn't compatible with any other mod that adds units with new art. Remember, the last activated version of the civ5artdefines_* files must include all changes from all such mods. From a recent thread: Quote:
__________________
-n. City States Leaders Randomize City Names Smaller Landmarks for R.E.D. Modpack Swiss Guard Gray/Sharkmouth Gunship Teamcolor Napoleonic musketmen Levy for GEM Misc. Units
Last edited by Nutty; Jul 07, 2012 at 02:42 PM. |
||
|
|
|
|
|
#6 |
|
Emperor
Join Date: Feb 2009
Location: Iowa USA
Posts: 4,266
|
So, how do you mod in units post .674 patch? Let me know I want to learn.
__________________
"All science trembles at the searing logic of your fiery intellect. " Brig. Gen. Lewis A. Armistead |
|
|
|
|
|
#7 |
|
Moderator
![]() Join Date: Oct 2004
Location: France
Posts: 3,762
|
The following is the SQL code that I use to replace step 3 and step 4 now that Civ5ArtDefines_UnitMembers.xml and Civ5ArtDefines_Units.xml are no longer needed to mod in new units (which is a very good thing, but has broken a lot of mods)
You can put that code in the file created in step 5. The rest of the steps are still valid I think. Code:
INSERT INTO ArtDefine_UnitInfos (Type,DamageStates,Formation)
SELECT ('ART_DEF_UNIT_WW1_FIGHTER_GERMANY'), DamageStates, Formation
FROM ArtDefine_UnitInfos WHERE (Type = 'ART_DEF_UNIT_WW1_FIGHTER');
INSERT INTO ArtDefine_UnitInfoMemberInfos (UnitInfoType,UnitMemberInfoType,NumMembers)
SELECT ('ART_DEF_UNIT_WW1_FIGHTER_GERMANY'), ('ART_DEF_UNIT_MEMBER_WW1_FIGHTER_GERMANY'), NumMembers
FROM ArtDefine_UnitInfoMemberInfos WHERE (UnitInfoType = 'ART_DEF_UNIT_WW1_FIGHTER');
INSERT INTO ArtDefine_UnitMemberCombats (UnitMemberType, EnableActions, DisableActions, MoveRadius, ShortMoveRadius, ChargeRadius, AttackRadius, RangedAttackRadius, MoveRate, ShortMoveRate, TurnRateMin, TurnRateMax, TurnFacingRateMin, TurnFacingRateMax, RollRateMin, RollRateMax, PitchRateMin, PitchRateMax, LOSRadiusScale, TargetRadius, TargetHeight, HasShortRangedAttack, HasLongRangedAttack, HasLeftRightAttack, HasStationaryMelee, HasStationaryRangedAttack, HasRefaceAfterCombat, ReformBeforeCombat, HasIndependentWeaponFacing, HasOpponentTracking, HasCollisionAttack, AttackAltitude, AltitudeDecelerationDistance, OnlyTurnInMovementActions, RushAttackFormation)
SELECT ('ART_DEF_UNIT_MEMBER_WW1_FIGHTER_GERMANY'), EnableActions, DisableActions, MoveRadius, ShortMoveRadius, ChargeRadius, AttackRadius, RangedAttackRadius,
MoveRate, ShortMoveRate, TurnRateMin, TurnRateMax, TurnFacingRateMin, TurnFacingRateMax, RollRateMin, RollRateMax, PitchRateMin, PitchRateMax, LOSRadiusScale, TargetRadius, TargetHeight, HasShortRangedAttack, HasLongRangedAttack, HasLeftRightAttack, HasStationaryMelee, HasStationaryRangedAttack, HasRefaceAfterCombat, ReformBeforeCombat, HasIndependentWeaponFacing, HasOpponentTracking, HasCollisionAttack, AttackAltitude, AltitudeDecelerationDistance, OnlyTurnInMovementActions, RushAttackFormation
FROM ArtDefine_UnitMemberCombats WHERE (UnitMemberType = 'ART_DEF_UNIT_MEMBER_WW1_FIGHTER');
INSERT INTO ArtDefine_UnitMemberCombatWeapons (UnitMemberType, "Index", SubIndex, ID, VisKillStrengthMin, VisKillStrengthMax, ProjectileSpeed, ProjectileTurnRateMin, ProjectileTurnRateMax, HitEffect, HitEffectScale, HitRadius, ProjectileChildEffectScale, AreaDamageDelay, ContinuousFire, WaitForEffectCompletion, TargetGround, IsDropped, WeaponTypeTag, WeaponTypeSoundOverrideTag)
SELECT ('ART_DEF_UNIT_MEMBER_WW1_FIGHTER_GERMANY'), "Index", SubIndex, ID, VisKillStrengthMin, VisKillStrengthMax, ProjectileSpeed, ProjectileTurnRateMin, ProjectileTurnRateMax, HitEffect, HitEffectScale, HitRadius, ProjectileChildEffectScale, AreaDamageDelay, ContinuousFire, WaitForEffectCompletion, TargetGround, IsDropped, WeaponTypeTag, WeaponTypeSoundOverrideTag
FROM ArtDefine_UnitMemberCombatWeapons WHERE (UnitMemberType = 'ART_DEF_UNIT_MEMBER_WW1_FIGHTER');
INSERT INTO ArtDefine_UnitMemberInfos (Type, Scale, ZOffset, Domain, Model, MaterialTypeTag, MaterialTypeSoundOverrideTag)
SELECT ('ART_DEF_UNIT_MEMBER_WW1_FIGHTER_GERMANY'), Scale, ZOffset, Domain,
('Fokker_Dr.1.fxsxml'), MaterialTypeTag, MaterialTypeSoundOverrideTag
FROM ArtDefine_UnitMemberInfos WHERE (Type = 'ART_DEF_UNIT_MEMBER_WW1_FIGHTER');
I'll do a clean update of first post when I have the time for it (which may not be *soon*, but I'll try to prioritize it) Last edited by Gedemon; Sep 01, 2012 at 04:09 AM. Reason: get ride of badly used double-quotes |
|
|
|
|
|
#8 |
|
Emperor
Join Date: Feb 2009
Location: Iowa USA
Posts: 4,266
|
Don't worry It will take me some time to learn this. I will be patient and do it step by step. Thank you very much for the update, and for your help.
Ok, I am starting with adding a Nieuport 17 mod. Now... I don't need the Nieuport_17.blend file, or do I? I also changed the no_gloss.dds to Nieuport_17_no_gloss.dds is that the way? Both .dds files need to be used right? So, I do not have to do step 3 or 4? Because the new SQL code takes care of those two steps. I just have to edit the code, correct? Now when this mod is done it will add the Nieuport 17 to the game, and I can make it just be available to France. Just like I tweaked the longboat UU to be available to Sweden as well as the Danes. Code:
<Civilization_UnitClassOverrides>
<Row>
<CivilizationType>CIVILIZATION_SWEDEN</CivilizationType>
<UnitClassType>UNITCLASS_TRIREME</UnitClassType>
<UnitType>UNIT_VIKING_LONGBOAT</UnitType>
</Row>
</Civilization_UnitClassOverrides>
I could also pick apart WHoward's longboat UU mod. I hope he does not mind. Now I can open files in modbuddy properly. I see how he changed the unit stats. I see how the modinfo file is set up. It is a summary. XML is straight forward, just like in CiIV. Let me continue... So, what I am doing is simply adding the Nierport 17 as a UU for France, as a replacement for the triplane. I figured this kind of project is perfect for getting my feet wet as far as modding goes. The plan is to copy what WHoward did, except I am not going to change unit stats. It will have the same stats as the WWI fighter. Just to learn for the moment. Ok, SQL folder is in, and code. Changes just need to be made. I do not have to set VFS file to true. check! Now let's add files to the XML folder. These two I don't need in the mod file. WHoward does not use them and you said they are not needed for modding in a unit. Civ5ArtDefines_UnitMembers.xml and Civ5ArtDefines_Units.xml so bye bye to them. I found everything but this. Code:
<Row Tag="TXT_KEY_UNIT_VIKING_LONGBOAT_TEXT"> <Text>Longboats (or Longships) were sea vessels made and used by the Vikings from the Nordic countries for trade, commerce, exploration, and warfare during the Viking Age.[NEWLINE][NEWLINE]The longship is characterized as a graceful, long, narrow, light, wooden boat with a shallow-draft hull designed for speed. The ship's shallow draft allowed navigation in waters only one metre deep and permitted beach landings. Longships were fitted with oars along almost the entire length of the boat itself. Later versions sported a rectangular sail on a single mast which was used to replace or augment the effort of the rowers.</Text> </Row> Code:
<Row Tag="TXT_KEY_UNIT_NIEUPORT17_TEXT"> <Text>The Nieuport 17 was a French biplane fighter aircraft of World War I, manufactured by the Nieuport company. It had outstanding maneuverability, and an excellent rate of climb. Initially, the Nieuport 17 retained the above wing mounted Lewis gun of the Nieuport 11, but in French service this was soon replaced by a synchronised Vickers gun. The Nieuport 17 became obsolescent in 1917, and was replaced by the SPAD S.VII.</Text> </Row>
__________________
"All science trembles at the searing logic of your fiery intellect. " Brig. Gen. Lewis A. Armistead Last edited by nokmirt; Jul 07, 2012 at 01:54 PM. |
|
|
|
|
|
#9 |
|
Emperor
Join Date: Feb 2009
Location: Iowa USA
Posts: 4,266
|
I cannot find these for triplane. The <IconTextureAtlases> can you send me the path to these. I have to change all of the <Atlas>UNITS_VIKING_LONGBOAT_ICON_ATLAS</Atlas> to NIEUPORT17 correct? So, I have to locate the path to for those dealing with the Triplane <IconTextureAtlases>.
Or will my unit, just by default use the triplane icons? I am about this.I am guessing that because my Nieuport 17 is under UNITCLASS_TRIPLANE, then it should use the triplane icons by default. The unit I am adding does not have it's own unique icons. So, am I right in this assumption?
__________________
"All science trembles at the searing logic of your fiery intellect. " Brig. Gen. Lewis A. Armistead Last edited by nokmirt; Jul 07, 2012 at 02:32 PM. |
|
|
|
|
|
#10 | |
|
King
Join Date: Mar 2011
Location: Orange County, California, U.S.A.
Posts: 659
|
Quote:
No, if you don't use SQL (much easier, IMHO--you can just copy most of the entries, and change the ones you need), then you will need to specify everything. If you still want to use XML, then there's no need to guess about any of this. Just take a look at the pertinent section of the game XML. Everything is there, you just have to piece it together from the various files (or learn to go through the database [Documents\My Games\Sid Meier's Civilization V\cache\Civ5DebugDatabase.db] using SQLite Manager for Firefox, or a similar program). It is a little confusing here because Firaxis has 2 different names they use internally for "Triplanes" or "WWI Fighters." * See Assets\DLC\Expansion\Gameplay\XML\Units\CIV5Units_ Expansion.xml (I've bolded <Icon_Atlas> and <PortraitIndex>, which should be the one you were asking about): Spoiler:
* The Art Defines are in Assets\DLC\Expansion\Units\Civ5ArtDefines_Expansio n_Units.xml [note, though, that they need to be rewritten; tag names are different in the database, so if you have to do it from scratch you'll want to check the database--but I've done this for you below; hopefully I haven't made any mistakes/typos] [EDIT: I apparently made lots, but I've tried to fix them]: Spoiler:
...and Assets\DLC\Expansion\Units\Civ5ArtDefines_Expansio n_UnitMembers.xml [same for this one, needed to be rewritten]: Spoiler:
...and Assets\DLC\Expansion\StrategicView\Civ5ArtDefines_ SV_Expansion_Units.xml [which doesn't need rewriting, thankfully]: Spoiler:
* The text descriptions are in Assets\DLC\Expansion\Gameplay\XML\Text\en_US\CIV5G ameTextInfos2_Expansion.xml: Spoiler:
...and Assets\DLC\Expansion\Gameplay\XML\Text\en_US\CIV5G ameTextInfos_Civilopedia_Expansion.xml: Spoiler:
Now copy all this mess into your mod, and go through and make your changes. One file or multiple, doesn't matter. You can leave stuff out if you're going to use the references to the original (e.g., I might use the original TXT_KEY_UNIT_HELP_TRIPLANE then leave out the <Row Tag="TXT_KEY_UNIT_HELP_TRIPLANE"> entry).
__________________
-n. City States Leaders Randomize City Names Smaller Landmarks for R.E.D. Modpack Swiss Guard Gray/Sharkmouth Gunship Teamcolor Napoleonic musketmen Levy for GEM Misc. Units
Last edited by Nutty; Jul 08, 2012 at 04:18 AM. |
|
|
|
|
|
|
#11 |
|
Emperor
Join Date: Feb 2009
Location: Iowa USA
Posts: 4,266
|
Ok, let's do this one step at a time so I don't get confused. This is my Nieuport17.xml code. Is anything missing in this file that needs to be added? I am basically copying how WHoward did it.
Spoiler:
Nieuport17Art.xml Spoiler:
A couple small xml typos. It's ok it keeps me on my toes. All of this look ok? According to modbuddy there are no xml errors. SV_WWI_Triplane.dds the unit from Danrell does not have a version of this. And most of the animations will be for WW1_FIGHTER is that ok?
__________________
"All science trembles at the searing logic of your fiery intellect. " Brig. Gen. Lewis A. Armistead Last edited by nokmirt; Jul 07, 2012 at 11:36 PM. |
|
|
|
|
|
#12 |
|
Emperor
Join Date: Feb 2009
Location: Iowa USA
Posts: 4,266
|
@Gedemon or Nutty, or anyone else that knows.
I am just going to do the SQL way and see how that goes. This is what my Nieuport17.sql code looks like, in my mod project. Is this ok? I just changed unit stats to match the triplane. Where it says this in the code, WHERE (UnitType = "UNIT_FIGHTER"), shouldn't I change that to WHERE (UnitType = "UNIT_TRIPLANE")? And will this be a UU for France or is there more steps to get that done? Let me know. Spoiler:
__________________
"All science trembles at the searing logic of your fiery intellect. " Brig. Gen. Lewis A. Armistead Last edited by nokmirt; Jul 08, 2012 at 04:00 AM. |
|
|
|
|
|
#13 | ||||
|
King
Join Date: Mar 2011
Location: Orange County, California, U.S.A.
Posts: 659
|
I'm going to respond to the XML question anyway because I botched the job so horribly.
Note, these are SQL rows you're adding with XML, so you're not going to have any nesting within the <Row> tags. Quote:
Quote:
Code:
<Model>Nieuport17.fxsxml</Model> <MaterialTypeTag>METAL</MaterialTypeTag> Quote:
Quote:
What do you mean? You shouldn't need to change the fxsxml or the gr2. Now I'll take a look at the SQL...
__________________
-n. City States Leaders Randomize City Names Smaller Landmarks for R.E.D. Modpack Swiss Guard Gray/Sharkmouth Gunship Teamcolor Napoleonic musketmen Levy for GEM Misc. Units
Last edited by Nutty; Jul 08, 2012 at 04:11 AM. |
||||
|
|
|
|
|
#14 | |
|
King
Join Date: Mar 2011
Location: Orange County, California, U.S.A.
Posts: 659
|
Just glancing at it, it looks fine.
Yes. Quote:
Code:
INSERT INTO "Civilization_UnitClassOverrides" ( 'CivilizationType', 'UnitClassType', 'UnitType' ) VALUES ( 'CIVILIZATION_FRANCE', 'UNITCLASS_TRIPLANE', 'UNIT_NIEUPORT17' ); |
|
|
|
|
|
|
#15 |
|
Emperor
Join Date: Feb 2009
Location: Iowa USA
Posts: 4,266
|
I am doing it the shorter way via SQL. Steps 3 and 4, the xml steps are not needed to add units to a mod anymore.
This is my current SQL code. Nieuport17.sql Spoiler:
Check this and let me know if it is correct. Thanks Nutty
__________________
"All science trembles at the searing logic of your fiery intellect. " Brig. Gen. Lewis A. Armistead |
|
|
|
|
|
#16 | |
|
Emperor
Join Date: Feb 2009
Location: Iowa USA
Posts: 4,266
|
Quote:
Nieuport17.xml Spoiler:
Correct? Finished SQL. Spoiler:
__________________
"All science trembles at the searing logic of your fiery intellect. " Brig. Gen. Lewis A. Armistead Last edited by nokmirt; Jul 08, 2012 at 04:29 AM. |
|
|
|
|
|
|
#17 |
|
King
Join Date: Mar 2011
Location: Orange County, California, U.S.A.
Posts: 659
|
The XML to make it a UU is fine [though why not leave it in SQL?], but looking at your SQL again, I notice you're making a new unit class. You should just be using UNITCLASS_TRIPLANE.
(i.e., delete the inserts to the UnitClasses and Unit_ClassUpgrades tables) EDIT: And you still want to change references to UNIT_FIGHTER to UNIT_TRIPLANE.
__________________
-n. City States Leaders Randomize City Names Smaller Landmarks for R.E.D. Modpack Swiss Guard Gray/Sharkmouth Gunship Teamcolor Napoleonic musketmen Levy for GEM Misc. Units
Last edited by Nutty; Jul 08, 2012 at 04:43 AM. |
|
|
|
|
|
#18 |
|
Emperor
Join Date: Feb 2009
Location: Iowa USA
Posts: 4,266
|
Ok like this
Spoiler:
__________________
"All science trembles at the searing logic of your fiery intellect. " Brig. Gen. Lewis A. Armistead |
|
|
|
|
|
#19 |
|
King
Join Date: Mar 2011
Location: Orange County, California, U.S.A.
Posts: 659
|
Delete the first insert, because you don't want to change that table. (Note that what that would have done is make a duplicate of the UNITCLASS_TRIPLANE row.)
|
|
|
|
|
|
#20 |
|
Emperor
Join Date: Feb 2009
Location: Iowa USA
Posts: 4,266
|
Ok, finally the SQL is done.
Spoiler:
This is the dreaded thread of code. Doing it until I get it right is the only way I'll learn.
__________________
"All science trembles at the searing logic of your fiery intellect. " Brig. Gen. Lewis A. Armistead |
|
|
|
![]() |
| Bookmarks |
|
| Thread Tools | |
|
|