Applying unique graphics to non UU unit

Craig_Sutter

Deity
Joined
Aug 13, 2002
Messages
2,773
Location
Calgary, Canada
Is there any way to apply alternate graphics to a unit without creating a UU?

For example, I want to apply the Longship graphic from whoward's longship unit to trireme's owned by Denmark, however, I do not want to create a UU to do that as the unit will essentially still be a trireme in all but the cosmetic sense. Therefore, I do not want to create another UU for Denmark (I want to maintain 2 UU Per civ).

Thanks.
 
Yes.

[Edited to include the pertinent post from another thread]

Note that you can have as many unique units as you like (though only the first 2 will be shown), so you could still use the UU method, which is much easier, especially as this is only for one civ. Plus, Denmark already has 2 UU's, so you won't have the cosmetic issue where your new unit is displayed instead of the UB or UI.

The other way is...
...the way R.E.D. and Ethnic Units now does it, by coopting the method that settlers use for regional variation. Taking apart Ethnic Units is probably easier to understand, but R.E.D. makes it really easy to edit all of the unit choices.

For this method, each Civ has to be coded in to change it from regional to Civ-specific. From Ethnic Units, here's America's entry to do so:
Spoiler :
Code:
-- AMERICA
UPDATE Civilizations SET ArtStyleSuffix = "_AMERICA" WHERE Type = 'CIVILIZATION_AMERICA';
INSERT INTO "ArtDefine_UnitInfos" ('Type','DamageStates','Formation')
	SELECT	REPLACE("Type", '_EURO', '_AMERICA'), "DamageStates", "Formation"
	FROM "ArtDefine_UnitInfos" WHERE Type LIKE '%_EURO';
INSERT INTO "ArtDefine_UnitInfoMemberInfos" ('UnitInfoType','UnitMemberInfoType','NumMembers')
	SELECT	REPLACE("UnitInfoType", '_EURO', '_AMERICA'), "UnitMemberInfoType", "NumMembers"
	FROM "ArtDefine_UnitInfoMemberInfos" WHERE UnitInfoType LIKE '%_EURO';

Then you need to set UnitArtInfoCulturalVariation in the Units table to 1 for each unit you want to change from the default unit. Note that UnitArtEraVariation (e.g., used for great people and workers) trumps the cultural, so you can't have both.

You could use this method just for Denmark.

Also see this thread after post 8.
 
Thank-you for the reply. I'm unfamiliar with sql but will try to make it work... if it is a simple substitution of America with Denmark and the relevant units, I should be able to do it.

Another method I thought of is to use lua to kill Denmark purchased/constructed Triremes and replace with a faux nonpurchaseble UU. I would need to hook into a construct/purchase unit event of some sort.

SQL solution is probably best, although I am much more familiar with lua... certainly it would be less memory intensive.

Adding a UU is not preferred for aesthetic reasons... I am getting rid of ski infantry in favour of a UB since my mod is medieval based. Any UU would show up ahead of that one.

Again, thanks... I'll work on it over the next couple of days and see how it comes out. If I figure out a good method, I'll likely do it with other civs where cosmetic changes are preferred.

EDIT:

Here is an SQL file I cobbled together from the threads mentioned. I'm at the office so I cannot test or get all the needed info. I also do not know all of the file names I need... but this is just to check if I am on the right track. For example, I don't have on hand the equivalent of "ART_DEF_UNIT_MEMBER_MUSKETMAN_AMERICA" for the Danish longboat... I will have to look it up when I get home. I'm not even really certain that this part is necessary as the member stuff should be pretty much the same between the two.

One thing... I know nothing about sql, and less about graphics, but are all the variable needed here? I think I may be including a lot of items in sql that are not necessary to be changed as I imagine the difference in actions to be little to none between the longboat and the trireme.

Anyhow:

Code:
-- DENMARK
UPDATE Civilizations SET ArtStyleSuffix = "_DENMARK" WHERE Type = 'CIVILIZATION_DENMARK';
INSERT INTO "ArtDefine_UnitInfos" ('Type','DamageStates','Formation')
	SELECT	REPLACE("Type", '_EURO', '_DENMARK), "DamageStates", "Formation"
	FROM "ArtDefine_UnitInfos" WHERE Type LIKE '%_EURO';
INSERT INTO "ArtDefine_UnitInfoMemberInfos" ('UnitInfoType','UnitMemberInfoType','NumMembers')
	SELECT	REPLACE("UnitInfoType", '_EURO', '_DENMARK'), "UnitMemberInfoType", "NumMembers"
	FROM "ArtDefine_UnitInfoMemberInfos" WHERE UnitInfoType LIKE '%_EURO';

-- DANISH LONGBOAT
INSERT INTO "ArtDefine_UnitInfos" ('Type','DamageStates','Formation')
	SELECT	("ART_DEF_UNIT_U_DANISH_LONGBOAT"), "DamageStates", "Formation"
	FROM "ArtDefine_UnitInfos" WHERE (Type = "ART_DEF_UNIT_TRIREME");
INSERT INTO "ArtDefine_UnitInfoMemberInfos" ('UnitInfoType','UnitMemberInfoType','NumMembers')
	SELECT	("ART_DEF_UNIT_U_DANISH_LONGBOAT"), ("ART_DEF_UNIT_MEMBER_MUSKETMAN_AMERICA"), "NumMembers"
	FROM "ArtDefine_UnitInfoMemberInfos" WHERE (UnitInfoType = "ART_DEF_UNIT_TRIREME");
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_MUSKETMAN_AMERICA"), "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_MUSKETMAN");
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_MUSKETMAN_AMERICA"), "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_MUSKETMAN");
INSERT INTO "ArtDefine_UnitMemberInfos" ("Type", "Scale", "ZOffset", "Domain", "Model", "MaterialTypeTag", "MaterialTypeSoundOverrideTag")
	SELECT	("ART_DEF_UNIT_MEMBER_MUSKETMAN_AMERICA"), "Scale", "ZOffset", "Domain", 
			("continental_inf.fxsxml"), "MaterialTypeTag", "MaterialTypeSoundOverrideTag"
	FROM "ArtDefine_UnitMemberInfos" WHERE (Type = "ART_DEF_UNIT_MEMBER_MUSKETMAN");

I also am unsure, but believe I need to change the art era info in the Trireme xml file to "1", as I understand from my reading.

Sorry that I don't know what I'm doing, but at the office and a sql neophyte.

Thanks.
 
BTW, in case you weren't aware, the Longboat model that whoward69 used for his mod is just a scaled up version of Denmark's embarked unit graphic.

Anyway, it's a bit easier, since you don't have any other units to worry about for the time being, so you can just update Denmark's suffix and skip the 2 INSERTS in the --DENMARK section of your code. There's some issues with your SQL, but I think you've got the gist [and yes, you need to create all of the art define entries even though it's mostly a straight copy of the Trireme].

Note that the art define MUST be called ART_DEF_UNIT_TRIREME_DENMARK (since that's what the game will look for with UnitArtInfoCulturalVariation enabled and the suffix changed to _DENMARK).

Anyway, if you really prefer XML, since you don't need to do anything fancy, you're welcome to use that instead:
Code:
<GameData>
  <Civilizations>
    <Update>
      <Where Type="CIVILIZATION_DENMARK" />
      <Set ArtStyleSuffix="_DENMARK" />
    </Update>
  </Civilizations>
  <Units>
    <Update>
      <Where Type="UNIT_TRIREME" />
      <Set UnitArtInfoCulturalVariation="1" />
    </Update>
  </Units>
  <ArtDefine_UnitInfos>
    <Row>
      <Type>ART_DEF_UNIT_TRIREME_DENMARK</Type>
      <DamageStates>3</DamageStates>
    </Row>
  </ArtDefine_UnitInfos>
  <ArtDefine_UnitInfoMemberInfos>
    <Row>
      <UnitInfoType>ART_DEF_UNIT_TRIREME_DENMARK</UnitInfoType>
      <UnitMemberInfoType>ART_DEF_UNIT_MEMBER_TRIREME_DENMARK</UnitMemberInfoType>
      <NumMembers>1</NumMembers>
    </Row>
  </ArtDefine_UnitInfoMemberInfos>
  <ArtDefine_UnitMemberInfos>
    <Row>
      <Type>ART_DEF_UNIT_MEMBER_TRIREME_DENMARK</Type>
      <Scale>0.10</Scale>
      <Domain>Sea</Domain>
      <Model>U_Denmark_Longboat.fxsxml</Model>
      <MaterialTypeTag>WOOD</MaterialTypeTag>
      <MaterialTypeSoundOverrideTag>WOODLRG</MaterialTypeSoundOverrideTag>
    </Row>
  </ArtDefine_UnitMemberInfos>
  <ArtDefine_UnitMemberCombats>
    <Row>
      <UnitMemberType>ART_DEF_UNIT_MEMBER_TRIREME_DENMARK</UnitMemberType>
      <EnableActions>Idle Attack RunCharge AttackCity Bombard Death BombardDefend Run Fortify CombatReady AttackSurfaceToAir</EnableActions>
      <HasShortRangedAttack>1</HasShortRangedAttack>
      <HasLongRangedAttack>1</HasLongRangedAttack>
      <HasLeftRightAttack>1</HasLeftRightAttack>
      <HasRefaceAfterCombat>0</HasRefaceAfterCombat>
      <HasIndependentWeaponFacing>1</HasIndependentWeaponFacing>
    </Row>
  </ArtDefine_UnitMemberCombats>
  <ArtDefine_UnitMemberCombatWeapons>
    <Row>
      <UnitMemberType>ART_DEF_UNIT_MEMBER_TRIREME_DENMARK</UnitMemberType>
      <Index>0</Index>
      <SubIndex>0</SubIndex>
      <VisKillStrengthMin>0.0</VisKillStrengthMin>
      <VisKillStrengthMax>0.0</VisKillStrengthMax>
      <WeaponTypeTag>ARROW</WeaponTypeTag>
      <WeaponTypeSoundOverrideTag>ARROW</WeaponTypeSoundOverrideTag>
      <MissTargetSlopRadius>10.0</MissTargetSlopRadius>
    </Row>
  </ArtDefine_UnitMemberCombatWeapons>
  <ArtDefine_StrategicView>
    <Row>
      <StrategicViewType>ART_DEF_UNIT_TRIREME_DENMARK</StrategicViewType>
      <TileType>Unit</TileType>
      <Asset>SV_Trireme.dds</Asset>
    </Row>
  </ArtDefine_StrategicView>
</GameData>

EDIT: Why not do the same for Polynesia? Make ART_DEF_UNIT_TRIREME_POLYNESIA, and just change the <Scale> to 0.7, and the <Model> to U_Polynesian_War_Canoe.fxsxml.
EDIT #2: ...and ART_DEF_UNIT_FRIGATE_SPAIN using U_Spanish_Galleon.fxsxml and ART_DEF_UNIT_IRONCLAD_AMERICA with Union_Ironclad.fxsxml...
 
It looks a bit tricky at first, Craig, but as soon as you get the hang of it, it's a doddle ;).
 
Thank-you. I can't wait to get home and try it.

I really need to get into sql sometimes, but for some reason it is more intimidating for me than lua and certainly /sql/ I mean xml.

I know what you mean. Once you start copying it though, it's easy to reproduce. I probably wouldn't be able to do any original SQL programming, but reading the code carefully, it's reasonably straightforward to understand, especially if you already know XML.
 
It worked perfectly... I have 4 viking civs in my mod that are looking really good now.

I even managed to use whoward's strategic view icon that he had made for the longship unit he created.

I'm wondering about the other art whoward created for his unit and possibilities for it... I suppose only the art defines are affected. Too bad, as it would be nice to use the unit flag icon, but that is likely impossible. I was lucky enough to be able to use the strategic view icon as it is.

Thank-you for all the help.

PS I wonder, as well as the galleon and polynesian units, if the cargo ship graphic might be used for a Netherlands Kogge (for the galleas).
 
Back
Top Bottom