[BNW] Replace unit in a separate mod?

JTitan

Warlord
Joined
Jun 28, 2011
Messages
181
Location
New York
How do you replace a unit in another mod? I made a few custom units for the prehistoric mod and I am planning on creating some for other eras mods (Enlightenment, Future Worlds exc.). At the moment, I am trying to replace the autochthon and caveman for the prehistoric era using mod buddy.
 
It's not too different from replacing a regular unit. Basically, you need to learn 3 things: how to make a unique unit (check), how to update the default Unit Type for a particular Unit Class, and how to add references to a mod.

In other words, the mods you want to update add new unit classes (including the Autochthon and Caveman). The default unit type for these are the Autochthon and Caveman (non-default unit types are unique units). You want to write a mod that 1) adds your replacements, 2) updates the units database so your new units are now the new default unit types for the classes you want to update, and 3) includes the mods you want to update in the References list, so your mod loads after.
 
Thanks for your response Cladoniaceae. I made two SQL files off of a template made by gedemon. One for the Autochthon and another for the Caveman. The gr2, fxzxml and two dds files are set to vfs true. The Prehistoric mod is in the reference list. The units show up as spearman. :confused:

here is the SQL for the Autochthon

Spoiler :

UPDATE Units SET UnitArtInfo = 1 WHERE Type = 'UNIT_AUTOCHTHON';

INSERT INTO ArtDefine_UnitInfos (Type,DamageStates,Formation)
SELECT ('ART_DEF_UNIT_AUTOCHTHON', DamageStates, Formation
FROM ArtDefine_UnitInfos WHERE (Type = 'ART_DEF_UNIT_SCOUT');

INSERT INTO ArtDefine_UnitInfoMemberInfos (UnitInfoType,UnitMemberInfoType,NumMembers)
SELECT ('ART_DEF_UNIT_AUTOCHTHON', ('ART_DEF_UNIT_MEMBER_AUTOCHTHON'), NumMembers
FROM ArtDefine_UnitInfoMemberInfos WHERE (UnitInfoType = 'ART_DEF_UNIT_SCOUT');

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_AUTOCHTHON'), 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_SCOUT');

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_AUTOCHTHON'), "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_SCOUT');

INSERT INTO ArtDefine_UnitMemberInfos (Type, Scale, ZOffset, Domain, Model, MaterialTypeTag, MaterialTypeSoundOverrideTag)
SELECT ('ART_DEF_UNIT_MEMBER_AUTOCHTHON'), Scale, ZOffset, Domain, ('SA_Native.fxsxml'), MaterialTypeTag, MaterialTypeSoundOverrideTag
FROM ArtDefine_UnitMemberInfos WHERE (Type = 'ART_DEF_UNIT_MEMBER_SCOUT');

INSERT INTO ArtDefine_StrategicView (StrategicViewType, TileType, Asset )
SELECT ('ART_DEF_UNIT_AUTOCHTHON'), TileType, Asset
FROM ArtDefine_StrategicView WHERE (StrategicViewType = 'ART_DEF_UNIT_SCOUT');


Other than updating UnitArtInfoCulturalVariation, I have never done any SQL and my XML skills are non-existent. But, I like to learn :).
 
Code:
UPDATE Units SET UnitArtInfo = 1 WHERE Type = 'UNIT_AUTOCHTHON';
You are telling the game to use "1" as the unit's art definition. There is no Type called "1" in table ArtDefine_UnitInfos so you get Spearmen since Spearman's ART_DEF_UNIT_SPEARMAN is the "fallback" as defined for Unit Art Defs in the game's base files.

Also, when using modbuddy to create a mod you need to check the checkbox for "Reload Unit System" found here: Common Novice-Modder Mistakes -- "NOT CHECKING THE REQUIRED MODBUDDY CHECK-BOXES"

If creating the mod manually, you need to add
Code:
    <ReloadUnitSystem>1</ReloadUnitSystem>
to the "<Properties>" section of the modinfo file.

----------------------------------------

Also, if the other mods you are trying to adjust have already added ART_DEF_UNIT_AUTOCHTHON to the game, you cannot attempt to add it again. This violates the game's uiniqueness requirements and causes it to cease reading any farther into your SQL file once it encounters an attempt to add a "Type" designation to a table where that "Type" has already been added.

So, for example, I cannot add BUILDING_WALLS since the game already has one defined. I can make updates to change the definition of BUILDING_WALLS but I cannot attempt to add a second BUILDING_WALLS to the game.

This uniqueness constraint applies to anything added by the base game, by any expansions that are active, by any DLC that are active, and by any mods that are active by the time your mod attempts to load into the game.
 
Last edited:
Thank you LeeS for your explanation. I understand a little more what the commands mean now.

I have everything checked in the custom properties section, and changed 1 to ART_DEF_UNIT_AUTOCHTHON_EDU. Do I need to create a new SQL for the new UnitArtInfo?

Actually, the only part of the units I want to change are the fxsxml files. Is there a easy way to just replace the fxsml for the default units? The stats and everything is staying the same. I just want to change the model.
 
I got the the Autochthon unit replaced but I am having trouble with the Caveman. The Caveman uses the vanilla barbarian warrior. I am not sure what SQL code would work. Any suggestions?

Here is the code I used to get the Autochthon model replaced
Spoiler :
UPDATE ArtDefine_UnitMemberInfos SET Model = 'SA_Native.fxsxml' WHERE Type = 'ART_DEF_UNIT_MEMBER_AUTOCHTHON';


Here is a pic with the successful Autochthon next to the unsuccessful Caveman

New_Autochthon.jpg
 
You would either need to update to the existing Barbarian Warrior ART_DEF_UNIT_BARBARIAN_EURO or you would have to create a new definition by borrowing (ie, SELECT FROM) the existing ART_DEF_UNIT_BARBARIAN_EURO and its members and changing the fxsxml as needed in the appropriate
place(s).
 
You would either need to update to the existing Barbarian Warrior ART_DEF_UNIT_BARBARIAN_EURO or you would have to create a new definition by borrowing (ie, SELECT FROM) the existing ART_DEF_UNIT_BARBARIAN_EURO and its members and changing the fxsxml as needed in the appropriate
place(s).

I do not want to replace the the barbarian unit, so the second option is what I want. I made a new SQL for the Caveman unit but it is not working. The unit continues to show the barbarian unit in game.

Here is the SQL I used.

Spoiler :

INSERT INTO "ArtDefine_UnitInfos" ('Type','DamageStates','Formation')
SELECT ("ART_DEF_UNIT_CAVEMAN"), "DamageStates", "Barbarian"
FROM "ArtDefine_UnitInfos" WHERE (Type = "ART_DEF_UNIT_BARBARIAN_EURO");
INSERT INTO "ArtDefine_UnitInfoMemberInfos" ('UnitInfoType','UnitMemberInfoType','NumMembers')
VALUES ("ART_DEF_UNIT_CAVEMAN", "ART_DEF_UNIT_MEMBER_CAVEMAN", 3);
INSERT INTO "ArtDefine_UnitInfoMemberInfos" ('UnitInfoType','UnitMemberInfoType','NumMembers')
VALUES ("ART_DEF_UNIT_CAVEMAN", "ART_DEF_UNIT_MEMBER_CAVEMAN", 3);
INSERT INTO "ArtDefine_UnitInfoMemberInfos" ('UnitInfoType','UnitMemberInfoType','NumMembers')
VALUES ("ART_DEF_UNIT_CAVEMAN", "ART_DEF_UNIT_MEMBER_CAVEMAN", 3);
INSERT INTO "ArtDefine_UnitInfoMemberInfos" ('UnitInfoType','UnitMemberInfoType','NumMembers')
VALUES ("ART_DEF_UNIT_CAVEMAN", "ART_DEF_UNIT_MEMBER_CAVEMAN", 3);
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_CAVEMAN"), "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_BARBARIAN_EURO_ALPHA");
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_CAVEMAN"), "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_BARBARIAN_EURO_ALPHA");
INSERT INTO "ArtDefine_UnitMemberInfos" ("Type", "Scale", "ZOffset", "Domain", "Model", "MaterialTypeTag", "MaterialTypeSoundOverrideTag")
SELECT ("ART_DEF_UNIT_MEMBER_CAVEMAN"), "Scale", "ZOffset", "Domain",
("SA_Caveman.fxsxml"), "MaterialTypeTag", "MaterialTypeSoundOverrideTag"
FROM "ArtDefine_UnitMemberInfos" WHERE (Type = "ART_DEF_UNIT_MEMBER_BARBARIAN_EURO_ALPHA");


Not sure what to do. Could someone look at this SQL and tell me my mistake(s)? I appreciate the help.
 
Ok, I got it now. The SQL is correct, just forgot to put the command in.

Spoiler :
UPDATE Units SET UnitArtInfo = 'ART_DEF_UNIT_CAVEMAN' WHERE Type = 'UNIT_CAVEMAN';


Thank you Cladoniaceae and LeeS for your help. :thanx:

Here are the two units
Prehistoric_units.jpg
 
Top Bottom