1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Need help with making a mod to add one unit

Discussion in 'Civ5 - Creation & Customization' started by The Tollan, Jun 9, 2014.

  1. The Tollan

    The Tollan Prince

    Joined:
    Oct 29, 2005
    Messages:
    418
    I need help on making this mod that creates a new unit (Artic Infantry). This unit is essentially envisioned to be a modified Mechanized Infantry unit with bonuses in Tundra and Ice terrain and different unit members (two Mechanized Infantry and four Paratroopers). All art assets will come from pre-existing game files. I have made some progress on this, but I have never specifically created any mods to add units to the game, only mods that retexture and reskin existing units (and add formations). So I am starting to get stuck. I know the basics about the SQL tables and the XML files, but mainly from retexturing existing units. For testing purposes I tried copying and pasting lines from some of the tutorial posts into the SQL file.

    I have attached a copy of the mod and files to this thread to show the stuff I have compiled so far. The mod is not really functional at the moment and I may have included more files than are necessary. Any help or advice is appreciated greatly.

    On the SQL file the following lines about ART_DEF_UNIT_MEMBER_MECHANIZEDINFANTRY2 are there for purposes of making it easier to set the unit members in the correct positions in the formation. Basically, when making other mods that reskinned an existing unit, I was only able to get the different unit members to appear in the right order by adding this part.


    Spoiler :
    INSERT INTO "ArtDefine_UnitMemberInfos" VALUES ("ART_DEF_UNIT_MEMBER_MECHANIZEDINFANTRY2","0.10000000149011612",null,"","Assets/Units/MechanizedInfantry/MechanizedInfantry.fxsxml","CLOTH","METALSM");

    INSERT INTO "ArtDefine_UnitMemberCombats" VALUES ("ART_DEF_UNIT_MEMBER_MECHANIZEDINFANTRY2","Idle Attack RunCharge AttackCity Bombard Death BombardDefend Run Fortify CombatReady","",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"1",null,null,"1",null,"1","1",null,null,null,null,null,null,"",null);

    INSERT INTO "ArtDefine_UnitMemberCombatWeapons" VALUES ("ART_DEF_UNIT_MEMBER_MECHANIZEDINFANTRY2","0","0","",null,null,null,null,null,"",null,null,null,null,null,null,null,null,"BULLETHC","BULLETHC",null);
     

    Attached Files:

  2. LeeS

    LeeS Imperator Supporter

    Joined:
    Jul 23, 2013
    Messages:
    6,909
    Location:
    Illinois, USA
    You don't actually want these as part of your mod since as near as I can tell they're repeats of what already exists in the base game. Direct repeats of what already exists in the base game will generally cause an entire file to fail during mod load. In your case I think this will be OK since none of your original stuff is in either of these files anyway. It's just extra clutter and extra work to include these two files since doing so isn't really gaining you anything.
    Code:
          <UpdateDatabase>Civ5Unitclasses.xml</UpdateDatabase>
          <UpdateDatabase>Civ5Units.xml</UpdateDatabase>
    I'm not sure about
    Code:
          <UpdateDatabase>UnitFormations.xml</UpdateDatabase>
    but I'm wondering if it isn't the same sort of deal.

    Additional Note: you don't need existing base-game stuff. When the mod loads, any reference in your mod to existing base-game stuff will still be found just fine by your mod, even though you haven't included a repeat of that base-game stuff anywhere in your mod.

    edit: by 'reference' I mean any command in XML such as an <Update> with a <Where something="something" />.
    Or in SQL when you have an
    Code:
    FROM "Units" WHERE (Type = "UNIT_MECHANIZED_INFANTRY")
    or something similar.
     
  3. Nutty

    Nutty Deity

    Joined:
    Mar 9, 2011
    Messages:
    3,175
    Gender:
    Male
    Location:
    Orange County, California, U.S.A.
    I haven't actually tried this ingame yet (maybe I'll check it out after I get home), but here's some observations just from looking at your files [besides the observations from LeeS above]:

    First, the word is "Arctic."

    Note that "1" [or '1'] is a string, which is different from 1 [no quotes], an integer, or 0.1, a floating-point number. Either way, you typically don't want to use double-quotes (" ") with SQLite; you want single quotes (' '). You don't quote a keyword like NULL, and you don't quote the name of a column that you're copying with a SELECT statement.
    For example, based on one of the lines you quote:
    Code:
    INSERT INTO ArtDefine_UnitMemberInfos VALUES ('ART_DEF_UNIT_MEMBER_MECHANIZEDINFANTRY2', 0.1, NULL, NULL, 'MechanizedInfantry.fxsxml', 'CLOTH', 'METALSM');
    or based on one of your SELECT's from the mod:
    Code:
    INSERT INTO ArtDefine_UnitInfoMemberInfos (UnitInfoType, UnitMemberInfoType, NumMembers)
    	SELECT 'ART_DEF_UNIT_ARCTIC_INFANTRY', 'ART_DEF_UNIT_MEMBER_ARCTIC_INFANTRY', NumMembers
    	FROM ArtDefine_UnitInfoMemberInfos WHERE UnitInfoType = 'ART_DEF_UNIT_MECHANIZED_INFANTRY';
    Note that your use of a UnitFormations.xml file will cause incompatibility with any other mod that replaces it (e.g., R.E.D. Modpack), since there can unfortunately only be one UnitFormations.xml file.

    You also aren't using VFS=true properly. The only file that should be VFS=true is UnitFormations.xml (and it should NOT be set to UpdateDatabase). The rest should be set to UpdateDatabase with VFS=false).

    I'm not sure why you think it's more difficult to organize units by re-using the existing ART_DEF_UNIT_MEMBER's; it's just a matter of the order you place them in the ArtDefine_UnitInfoMemberInfos table, and it makes your job somewhat easier.

    Note you forgot the ArtDefine_StrategicView icon.

    See above.
     
  4. The Tollan

    The Tollan Prince

    Joined:
    Oct 29, 2005
    Messages:
    418
    I have worked on the mod and have attempted to implement the advice posted on this thread. However, I am still having issues with getting the mod to actually successfully the new unit in the game. I eliminated the unnecessary Civ5Units.xml and Civ5Unitclasses.xml files and fixed the VFS status as per Nutty's recommendation.

    The .sql file almost certainly has some remaining issues. I tried fixing some specific things, but am not sure exactly about how to address potential remaining problems with the INSERT INTO and SELECT portions, specifically the use of parenthesis and apostrophes.

    Once I get the mod to successfully add the unit then I will do some minor tweaking on the characteristics, such as terrain bonuses, but right now I am only focused on getting a new buildable unit in the game.
     

    Attached Files:

  5. Nutty

    Nutty Deity

    Joined:
    Mar 9, 2011
    Messages:
    3,175
    Gender:
    Male
    Location:
    Orange County, California, U.S.A.
    You're missing the 2 after MECHANIZEDINFANTRY and you have an extra apostrophe in this line (and I'd use an underscore to keep consistency):
    Code:
    INSERT INTO ArtDefine_UnitMemberCombats VALUES ('ART_DEF_UNIT_MEMBER_MECHANIZED[COLOR="RED"][B]_[/B][/COLOR]INFANTRY[COLOR="RED"][B]2[/B][/COLOR]'[COLOR="RED"][B]'[/B][/COLOR], ...
    And I know I said you typically don't use double-quotes, but you will need them around the word "Index" (because INDEX is a SQL keyword; Firaxis should never have used it as a column name...), i.e.:
    Code:
    INSERT INTO ArtDefine_UnitMemberCombatWeapons (UnitMemberType, [COLOR="RED"][B]"[/B][/COLOR]Index[COLOR="RED"][B]"[/B][/COLOR], SubIndex, ID, VisKillStrengthMin, VisKillStrengthMax, ProjectileSpeed, ProjectileTurnRateMin, ProjectileTurnRateMax, HitEffect, HitEffectScale, HitRadius, ProjectileChildEffectScale, AreaDamageDelay, ContinuousFire, WaitForEffectCompletion, TargetGround, IsDropped, WeaponTypeTag, WeaponTypeSoundOverrideTag)
    	SELECT 'ART_DEF_UNIT_MEMBER_ARCTIC_INFANTRY', [COLOR="RED"][B]"[/B][/COLOR]Index[COLOR="RED"][B]"[/B][/COLOR], 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_MECHANIZED_INFANTRY';
     
  6. The Tollan

    The Tollan Prince

    Joined:
    Oct 29, 2005
    Messages:
    418
    I fixed the errors in the SQL file pointed out on this thread, and some others, but the mod still does not seem to be working.

    I have not yet been able to get the new unit to appear in game in any form. Nothing in the build menus or Civilopedia during any tests yet.

    Modbuddy is displaying syntax error on (specifically appears in the second line):

    Code:
    INSERT INTO ArtDefine_UnitInfos (Type, DamageStates, Formation)
    	SELECT 'ART_DEF_UNIT_ARCTIC_INFANTRY', DamageStates, Formation
    	FROM 'ArtDefine_UnitInfos' WHERE (Type = 'ART_DEF_UNIT_MECHANIZED_INFANTRY');

    Also, I provisionally removed the Mechanized_Infantry2 data inserts from the SQL file to reduce clutter. If I can get the mod working then I will set the specific placing of the Paratrooper and Mechanized Infantry unit members without using any of this.
     

    Attached Files:

  7. Nutty

    Nutty Deity

    Joined:
    Mar 9, 2011
    Messages:
    3,175
    Gender:
    Male
    Location:
    Orange County, California, U.S.A.
    You're missing the ' ' around 'Arctic Infantry' for the Units table insert (Description column).

    ModBuddy's syntax error underlining doesn't do SQL very well.
     
  8. The Tollan

    The Tollan Prince

    Joined:
    Oct 29, 2005
    Messages:
    418
    The new unit is now displaying properly in the Civilopedia, but I cannot actually build it in game. For some reason it will not appear in the build menu.

    Is there an overlap between the new "Arctic Infantry" and the default Mechanized Infantry unit that prevents me from building the new unit or is there something missing from the SQL file? My goal is to keep the standard Mechanized Infantry unit without any changes while adding a new, separate unit that is mostly based on it (will make the other changes to the unit to once it is buildable and useable in game).

    The SQL file as of now:

    Code:
    INSERT INTO ArtDefine_UnitInfos (Type, DamageStates, Formation)
    	SELECT 'ART_DEF_UNIT_ARCTIC_INFANTRY', DamageStates, Formation
    	FROM ArtDefine_UnitInfos WHERE Type = 'ART_DEF_UNIT_MECHANIZED_INFANTRY';
    
    INSERT INTO ArtDefine_UnitInfoMemberInfos (UnitInfoType, UnitMemberInfoType, NumMembers)
    	SELECT 'ART_DEF_UNIT_ARCTIC_INFANTRY', UnitMemberInfoType, NumMembers
    	FROM ArtDefine_UnitInfoMemberInfos WHERE UnitInfoType = 'ART_DEF_UNIT_MECHANIZED_INFANTRY';
    
    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_ARCTIC_INFANTRY', 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_MECHANIZED_INFANTRY';
    
    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_ARCTIC_INFANTRY', "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_MECHANIZED_INFANTRY';
    
    INSERT INTO ArtDefine_UnitMemberInfos (Type, Scale, ZOffset, Domain, Model, MaterialTypeTag, MaterialTypeSoundOverrideTag)
    	SELECT 'ART_DEF_UNIT_MEMBER_ARCTIC_INFANTRY', Scale, ZOffset, Domain, Model, MaterialTypeTag, MaterialTypeSoundOverrideTag
    	FROM ArtDefine_UnitMemberInfos WHERE Type = 'ART_DEF_UNIT_MEMBER_MECHANIZED_INFANTRY';
    
    INSERT INTO ArtDefine_StrategicView (StrategicViewType, TileType, Asset)
    	SELECT 'ART_DEF_UNIT_ARCTIC_INFANTRY', TileType, Asset
    	FROM ArtDefine_StrategicView WHERE StrategicViewType = 'ART_DEF_UNIT_MECHANIZED_INFANTRY';
    
    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_ARCTIC_INFANTRY', 'Arctic Infantry', 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
    	FROM Units WHERE Type = 'UNIT_MECHANIZED_INFANTRY';
    
    INSERT INTO Unit_AITypes (UnitType, UnitAIType)
    	SELECT 'UNIT_ARCTIC_INFANTRY', UnitAIType
    	FROM Unit_AITypes WHERE UnitType = 'UNIT_MECHANIZED_INFANTRY';
    
    INSERT INTO Unit_ClassUpgrades (UnitType, UnitClassType)
    	SELECT 'UNIT_ARCTIC_INFANTRY', UnitClassType
    	FROM Unit_ClassUpgrades WHERE UnitType = 'UNIT_MECHANIZED_INFANTRY';
    
    INSERT INTO Unit_Flavors (UnitType, FlavorType, Flavor)
    	SELECT 'UNIT_ARCTIC_INFANTRY', FlavorType, Flavor
    	FROM Unit_Flavors WHERE UnitType = 'UNIT_MECHANIZED_INFANTRY';
    
    INSERT INTO Unit_FreePromotions (UnitType, PromotionType)
    	SELECT 'UNIT_ARCTIC_INFANTRY', PromotionType
    	FROM Unit_FreePromotions WHERE UnitType = 'UNIT_MECHANIZED_INFANTRY';
    
    INSERT INTO Unit_ResourceQuantityRequirements (UnitType, ResourceType, Cost)
    	SELECT 'UNIT_ARCTIC_INFANTRY', ResourceType, Cost
    	FROM Unit_ResourceQuantityRequirements WHERE UnitType = 'UNIT_MECHANIZED_INFANTRY';
     
  9. Nutty

    Nutty Deity

    Joined:
    Mar 9, 2011
    Messages:
    3,175
    Gender:
    Male
    Location:
    Orange County, California, U.S.A.
    Right now, you've basically got your unit set up as a unique mechanized infantry, but haven't given the unique to anybody. You need to make a new class.

    Change the Units insert to this:
    Code:
    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_ARCTIC_INFANTRY', 'Arctic Infantry', Civilopedia, Strategy, Help, Requirements, Combat, RangedCombat, Cost, Moves, Immobile, Range, BaseSightRange, 'UNITCLASS_ARCTIC_INFANTRY', 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
    	FROM Units WHERE Type = 'UNIT_MECHANIZED_INFANTRY';
    And add this:
    Code:
    INSERT INTO UnitClasses (Type, Description, MaxGlobalInstances, MaxTeamInstances, MaxPlayerInstances, InstanceCostModifier, DefaultUnit)
    	SELECT 'UNITCLASS_ARCTIC_INFANTRY', 'Arctic Infantry', MaxGlobalInstances, MaxTeamInstances, MaxPlayerInstances, InstanceCostModifier, 'UNIT_ARCTIC_INFANTRY'
    	FROM UnitClasses WHERE Type = 'UNITCLASS_MECHANIZED_INFANTRY';
    EDIT: It looks like you also missed:
    Code:
    INSERT INTO UnitGameplay2DScripts (UnitType, SelectionSound, FirstSelectionSound)
    	SELECT 'UNIT_ARCTIC_INFANTRY', SelectionSound, FirstSelectionSound
    	FROM UnitGameplay2DScripts WHERE UnitType = 'UNIT_MECHANIZED_INFANTRY';
     
  10. The Tollan

    The Tollan Prince

    Joined:
    Oct 29, 2005
    Messages:
    418
    The unit is now buildable in game. Now I can focus on tweaking stats, the formation, and unit members.

    Thanks for the help Nutty.
     
  11. The Tollan

    The Tollan Prince

    Joined:
    Oct 29, 2005
    Messages:
    418
    There are still a few issues that I am attempting to resolve with this mod.

    The first question I have is: Are the inserts for ArtDefine_UnitMemberCombats, ArtDefine_UnitMemberCombatWeapons, ArtDefine_UnitMemberInfos needed at all for this mod? I am not trying to add any new types of unit members. The new unit will only use existing Paratrooper and Mechanized Infantry unit members. I provisionally removed these inserts.

    Next, two observations:

    I noticed that the location of the Units insert seems to affect whether or not the Arctic Infantry unit buildable. If certain other inserts come before the Unit one then the mod unit is not buildable. The unit does still appear in the Civilopedia, but with a build cost listed as &#8220;free.&#8221; Also, the unit, even when buildable, is not purchasable with faith points for some reason even while many other units, including Mechanized Infantry, can be purchased with them (not a major issue, but perhaps this indicates that something is amiss).

    Also, the selection sound does not seem to be working properly on the Arctic Infantry unit. Most of the sound effects are perfectly fine on the unit, but when selected the Mechanized Infantry selection sound does not play. There is just a generic type selection sound. I have the code set like this:

    Code:
    INSERT INTO UnitGameplay2DScripts (UnitType, SelectionSound, FirstSelectionSound)
    	SELECT 'UNIT_ARCTIC_INFANTRY', SelectionSound, FirstSelectionSound
    	FROM UnitGameplay2DScripts WHERE Type = 'UNIT_MECHANIZED_INFANTRY';
    
    Other issues:

    How do you set the unit members for a unit in SQL? I have changed unit members using XML, but not SQL.

    I am trying to set the unit members for Arctic Infantry to appear in this order: 1 Mechanized Infantry, 2 Paratroopers, 1 Mechanized Infantry, 2 Paratroopers.

    I tried using INSERT INTO and VALUES (both with and without spacing between VALUES and the opening parenthesis) but nothing changed in the mod.

    This is one sample of the code I tested:

    Code:
    INSERT INTO ArtDefine_UnitInfoMemberInfos (UnitInfoType, UnitMemberInfoType, NumMembers)
    	VALUES ('ART_DEF_UNIT_ARCTIC_INFANTRY', 'ART_DEF_UNIT_MEMBER_MECHANIZEDINFANTRY', 1);
    
    INSERT INTO ArtDefine_UnitInfoMemberInfos (UnitInfoType, UnitMemberInfoType, NumMembers)
    	VALUES ('ART_DEF_UNIT_ARCTIC_INFANTRY', 'ART_DEF_UNIT_MEMBER_PARATROOPER', 2);
    
    INSERT INTO ArtDefine_UnitInfoMemberInfos (UnitInfoType, UnitMemberInfoType, NumMembers)
    	VALUES ('ART_DEF_UNIT_ARCTIC_INFANTRY', 'ART_DEF_UNIT_MEMBER_MECHANIZEDINFANTRY', 1);
    
    INSERT INTO ArtDefine_UnitInfoMemberInfos (UnitInfoType, UnitMemberInfoType, NumMembers)
    	VALUES ('ART_DEF_UNIT_ARCTIC_INFANTRY', 'ART_DEF_UNIT_MEMBER_PARATROOPER', 2);

    The next problem is the formation. I tried (unsuccessfully) this code (based on the custom formation name in the UnitFormations.XML):

    Code:
    INSERT INTO ArtDefine_UnitInfos (Type, DamageStates, Formation)
    	SELECT 'ART_DEF_UNIT_ARCTIC_INFANTRY', DamageStates, ArcticInfantry
    	FROM ArtDefine_UnitInfos WHERE Type = 'ART_DEF_UNIT_MECHANIZED_INFANTRY';
    I also tried using &#8216;ArcticInfantry&#8217; with single quotation marks.

    I also tested adding this to the end of the SQL file:

    Code:
    UPDATE ArtDefine_UnitInfos SET Formation = 'ArcticInfantry' WHERE Type = 'ART_DEF_UNIT_ARCTIC_INFANTRY';
    I am trying to use the custom formation ArcticInfantry from the UnitFormations file. The reason I am trying to use this is that, IMO, mixing Paratrooper, or other foot soldier, unit members with vehicle unit members tends to lead to problematic spacing issues without making a custom formation.
     
  12. The Tollan

    The Tollan Prince

    Joined:
    Oct 29, 2005
    Messages:
    418
    This is the code for the whole SQL file as of now (the syntax error is still appearing at the top of the mod):

    Code:
    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_ARCTIC_INFANTRY', 'Arctic Infantry', Civilopedia, Strategy, Help, Requirements, Combat, RangedCombat, Cost, Moves, Immobile, Range, BaseSightRange, 'UNITCLASS_ARCTIC_INFANTRY', 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
    	FROM Units WHERE Type = 'UNIT_MECHANIZED_INFANTRY';
    
    INSERT INTO UnitClasses (Type, Description, MaxGlobalInstances, MaxTeamInstances, MaxPlayerInstances, InstanceCostModifier, DefaultUnit)
    	SELECT 'UNITCLASS_ARCTIC_INFANTRY', 'Arctic Infantry', MaxGlobalInstances, MaxTeamInstances, MaxPlayerInstances, InstanceCostModifier, 'UNIT_ARCTIC_INFANTRY'
    	FROM UnitClasses WHERE Type = 'UNITCLASS_MECHANIZED_INFANTRY';
    	
    INSERT INTO UnitGameplay2DScripts (UnitType, SelectionSound, FirstSelectionSound)
    	SELECT 'UNIT_ARCTIC_INFANTRY', SelectionSound, FirstSelectionSound
    	FROM UnitGameplay2DScripts WHERE Type = 'UNIT_MECHANIZED_INFANTRY';
    
    INSERT INTO ArtDefine_UnitInfos (Type, DamageStates, Formation)
    	SELECT 'ART_DEF_UNIT_ARCTIC_INFANTRY', DamageStates, Formation
    	FROM ArtDefine_UnitInfos WHERE Type = 'ART_DEF_UNIT_MECHANIZED_INFANTRY';
    
    INSERT INTO ArtDefine_UnitInfoMemberInfos (UnitInfoType, UnitMemberInfoType, NumMembers)
    	SELECT 'ART_DEF_UNIT_ARCTIC_INFANTRY', UnitMemberInfoType, NumMembers
    	FROM ArtDefine_UnitInfoMemberInfos WHERE UnitInfoType = 'ART_DEF_UNIT_MECHANIZED_INFANTRY';
    
    INSERT INTO ArtDefine_StrategicView (StrategicViewType, TileType, Asset)
    	SELECT 'ART_DEF_UNIT_ARCTIC_INFANTRY', TileType, Asset
    	FROM ArtDefine_StrategicView WHERE StrategicViewType = 'ART_DEF_UNIT_MECHANIZED_INFANTRY';
    
    INSERT INTO Unit_AITypes (UnitType, UnitAIType)
    	SELECT 'UNIT_ARCTIC_INFANTRY', UnitAIType
    	FROM Unit_AITypes WHERE UnitType = 'UNIT_MECHANIZED_INFANTRY';
    
    INSERT INTO Unit_ClassUpgrades (UnitType, UnitClassType)
    	SELECT 'UNIT_ARCTIC_INFANTRY', UnitClassType
    	FROM Unit_ClassUpgrades WHERE UnitType = 'UNIT_MECHANIZED_INFANTRY';
    
    INSERT INTO Unit_Flavors (UnitType, FlavorType, Flavor)
    	SELECT 'UNIT_ARCTIC_INFANTRY', FlavorType, Flavor
    	FROM Unit_Flavors WHERE UnitType = 'UNIT_MECHANIZED_INFANTRY';
    
    INSERT INTO Unit_FreePromotions (UnitType, PromotionType)
    	SELECT 'UNIT_ARCTIC_INFANTRY', PromotionType
    	FROM Unit_FreePromotions WHERE UnitType = 'UNIT_MECHANIZED_INFANTRY';
    
    INSERT INTO Unit_ResourceQuantityRequirements (UnitType, ResourceType, Cost)
    	SELECT 'UNIT_ARCTIC_INFANTRY', ResourceType, Cost
    	FROM Unit_ResourceQuantityRequirements WHERE UnitType = 'UNIT_MECHANIZED_INFANTRY';
     
  13. Nutty

    Nutty Deity

    Joined:
    Mar 9, 2011
    Messages:
    3,175
    Gender:
    Male
    Location:
    Orange County, California, U.S.A.
    You need to start checking your log files. The reason you have different behavior based on where you put an entry is because as soon as an error is found the rest of the file is discarded. I had a typo in the UnitGameplay2DScripts entry I gave you. It should be:
    Code:
    INSERT INTO UnitGameplay2DScripts (UnitType, SelectionSound, FirstSelectionSound)
    	SELECT 'UNIT_ARCTIC_INFANTRY', SelectionSound, FirstSelectionSound
    	FROM UnitGameplay2DScripts WHERE [COLOR="RED"][B]Unit[/B][/COLOR]Type = 'UNIT_MECHANIZED_INFANTRY';
    No, you don't need to add new ART_DEF_UNIT_MEMBER* entries if you're not going to change anything. The art defines code looks correct.

    You do want the single quotes around the 'ArcticInfantry' formation entry.
     
  14. The Tollan

    The Tollan Prince

    Joined:
    Oct 29, 2005
    Messages:
    418
    Ok, everything in the mod is essentially working now except for the free unit promotion I attempted to add. This is basically the last significant hurdle.

    I checked the SQL database with SQLite manger and the XML files to try figure out how to add a free promotion that gives a combat bonus in the Tundra terrain. Basically I am trying to get something like the Desert Warrior promotion, but with a Tundra bonus instead.

    The database log showed this on my most recent test:

    From what I have read the StrategicView part is irrelevant and not an issue. As for the rest:

    The "column: true" refers to the last part of the code below. In my previous tests, this error always has displayed on the first text value in the unit promotion table inserts that does not have single quotation marks placed around it. So the error normally appears as no such column: TERRAIN_TUNDRA. I am not sure whether this error is actually causing the promotion to not display in game or not. I have tried placing single quotation marks around all of the areas that show errors, but that does not solve the problem.

    The code that I am working for the unit promotion looks like this (could probably switch to using just VALUES for the first part):

    Code:
    INSERT INTO Unit_FreePromotions (UnitType, PromotionType)
    	SELECT 'UNIT_ARCTIC_INFANTRY', 'PROMOTION_TUNDRABONUS'
    	FROM Unit_FreePromotions WHERE UnitType = 'UNIT_PARATROOPER';
    
    INSERT INTO UnitPromotions_Terrains (PromotionType, TerrainType, Attack, Defense) 
    	VALUES ('PROMOTION_TUNDRABONUS', TERRAIN_TUNDRA, 15, 15);
    
    INSERT INTO UnitPromotions (Type, Description, PortraitIndex, IconAtlas, PediaEntry, CannotBeChosen)
    	VALUES ('PROMOTION_TUNDRABONUS', 'Tundra Operations Proficiency', 44, PROMOTION_ATLAS, PEDIA_ATTRIBUTES, true);

    From reference purposes this is the XML code for Desert Warrior promotion from the UnitsPromotion_Expansion2.XML file:


    Code:
    <UnitPromotions>
    <!-- Regular promotions -->
    
    <Type>PROMOTION_DESERT_WARRIOR</Type>
    <Description>TXT_KEY_PROMOTION_DESERT_WARRIOR</Description>
    <Help>TXT_KEY_PROMOTION_DESERT_WARRIOR_HELP</Help>
    <Sound>AS2D_IF_LEVELUP</Sound>
    <PortraitIndex>1</PortraitIndex>
    <IconAtlas>EXPANSION2_PROMOTION_ATLAS</IconAtlas>
    <PediaType>PEDIA_ATTRIBUTES</PediaType>
    <PediaEntry>TXT_KEY_PROMOTION_DESERT_WARRIOR</PediaEntry>
    <CannotBeChosen>true</CannotBeChosen>
    </Row>
    </UnitPromotions>
    
    -<UnitPromotions_Terrains>
    -<Row>
    <PromotionType>PROMOTION_DESERT_WARRIOR</PromotionType>
    <TerrainType>TERRAIN_DESERT</TerrainType>
    <Attack>50</Attack>
    <Defense>50</Defense>
    </Row>
    </UnitPromotions_Terrains>
    Edit: I noticed that the description part of my UnitsPromotion table did not match with the Desert Warrior's format, but even with removing that description column the promotion does not appear during tests.
     
  15. Nutty

    Nutty Deity

    Joined:
    Mar 9, 2011
    Messages:
    3,175
    Gender:
    Male
    Location:
    Orange County, California, U.S.A.
    The "columns StrategicViewType, TileType..." error is due to Firaxis sloppiness; you'll get that with no mods loaded.

    There's no boolean (true/false) in SQLite. Use 1 instead (no quotes).
     
  16. The Tollan

    The Tollan Prince

    Joined:
    Oct 29, 2005
    Messages:
    418
    The XML file I posted is not in my mod. I just used that promotion in the quote as my point of reference.
     
  17. Nutty

    Nutty Deity

    Joined:
    Mar 9, 2011
    Messages:
    3,175
    Gender:
    Male
    Location:
    Orange County, California, U.S.A.
  18. The Tollan

    The Tollan Prince

    Joined:
    Oct 29, 2005
    Messages:
    418
    The CannotBeChosen column in the UnitPromotions table is the only column that I see with the Boolean issue. Most of the other columns are text based according to the database.

    I tried this setup with no promotion appearing in the game:

    Code:
    INSERT INTO Unit_FreePromotions (UnitType, PromotionType)
    	SELECT 'UNIT_ARCTIC_INFANTRY', 'PROMOTION_TUNDRABONUS'
    	FROM Unit_FreePromotions WHERE UnitType = 'UNIT_PARATROOPER';
    
    INSERT INTO UnitPromotions_Terrains (PromotionType, TerrainType, Attack, Defense) 
    	VALUES ('PROMOTION_TUNDRABONUS', TERRAIN_TUNDRA, 15, 15);
    
    INSERT INTO UnitPromotions (Type, Description, PortraitIndex, IconAtlas, PediaEntry, CannotBeChosen)
    	VALUES ('PROMOTION_TUNDRABONUS', 'Arctic Operation Proficiency', 44, PROMOTION_ATLAS, PEDIA_ATTRIBUTES, 1);
    The database log showed this result:

    Is the "no such column: TERRAIN_TUNDRA" a problem or is irrelevant?

    I used the same string ('TUNDRABONUS') for the UnitPromotions_Terrains as UnitPromotions based on what I saw with the Woodsman Promotion (which appears in the UnitPromotions_Features and in UnitPromotions with the same string).
     
  19. PawelS

    PawelS Ancient Druid

    Joined:
    Dec 11, 2003
    Messages:
    2,803
    Location:
    Poland
    It's a problem caused by the fact that you wrote TERRAIN_TUNDRA instead of 'TERRAIN_TUNDRA', so SQL treats it as a column name instead of text.
     
  20. The Tollan

    The Tollan Prince

    Joined:
    Oct 29, 2005
    Messages:
    418
    Just got it working.

    I placed single quotation marks around the text portions of the code.

    I had done that before and it didn't work, but that was because of the Boolean issue that you pointed out Nutty.

    I think that all major issues are resolved. Thanks a ton for the all the help Nutty. If I publish this on steam I will put your user name in the special thanks section.

    Edit: Ninja'ed. :)

    PawelS also pointed the answer out.
     

Share This Page