New unit formation

scotchandcake

Chieftain
Joined
Jul 12, 2012
Messages
38
Hello folks!

I'm trying to introduce a new "hero" type unit:
A player can only have 1 of these at any time, it is fairly strong with fancy promotions.

For good looks, I used the "EarlyGreatMerchant" unit formation, which puts the main unit up front, and 2 other units in the back. It looks okay, and it also works for combat.
(See picture below)

The only issue is that my "hero" dies first when attacked, because he's in the front row. I would like him to be the last man standing in the formation...

I had a look at the UnitFormations xml, but I don't really understand all the commands in it. I would like to change the formation, so that it is 2 units in the front and the "hero" unit in the back...

Does anyone know which command does what, and how you could make a new formation that uses the EarlyGreatMerchant, just the other way around - with 2 units up front and 1 in the back?

Here is the EarlyGreatMerchant unit formation from the UnitFormations.xml for reference:

Spoiler :
<Formation>
<Name>EarlyGreatMerchant</Name>
<SpacingX>9</SpacingX>
<SpacingY>5</SpacingY>
<SpacingMultiplier>1.39252</SpacingMultiplier>
<PerRowInc>0</PerRowInc>
<YOffsetInc>10</YOffsetInc>
<YOffsetCurved>1</YOffsetCurved>
<Stagger>0</Stagger>
<UnitRandomness>0</UnitRandomness>
<BlockRandomness>0</BlockRandomness>
<TotalWidth>3</TotalWidth>
<XBlockSize>4</XBlockSize>
<XBlockSpacingCount>0</XBlockSpacingCount>
<YBlockSize>0</YBlockSize>
<YBlockSpacingCount>1</YBlockSpacingCount>
<CenterWidth>0</CenterWidth>
</Formation>


Help would be greatly appreciated :worship:
 

Attachments

  • Neues Bild (10).jpg
    Neues Bild (10).jpg
    55.4 KB · Views: 143
What I know about formation:

Code:
SpacingX : 		space between column
SpacingY : 		space between row
SpacingMultiplier :	coefficient for above values
PerRowInc : 		increment figures on each row by this value x2
YOffsetInc : 		increment Y position on each figure on a row from central position
YOffsetCurved: 		(1=on / 0=off) curve the Y offset
Stagger:		add this number of figures 1 row on 2
UnitRandomness :	position can change a bit based on this value 0 is fixed, 0.5 is high variation
BlockRandomness :	same as above, for blocks
TotalWidth :		number of figures on 1st row (set to 1, the 1st figure is not shown ??)

I don't play much with blocks as I don't really understand the logic behind their placement, but the Samurai is an example of use.

For the great marchand, the formation is one line incurved in a V

What you want is a 2 straight lines formation, maybe something like that:

Code:
	<Formation>
		<Name>ProtectedHero</Name>
		<SpacingX>12</SpacingX>
		<SpacingY>8</SpacingY>
		<SpacingMultiplier>1</SpacingMultiplier>
		<PerRowInc>0</PerRowInc>
		<YOffsetInc>0</YOffsetInc>
		<YOffsetCurved>0</YOffsetCurved>
		<Stagger>1</Stagger>
		<UnitRandomness>0</UnitRandomness>
		<BlockRandomness>0</BlockRandomness>
		<TotalWidth>2</TotalWidth>
		<XBlockSize>0</XBlockSize>
		<XBlockSpacingCount>0</XBlockSpacingCount>
		<YBlockSize>0</YBlockSize>
		<YBlockSpacingCount>0</YBlockSpacingCount>
		<CenterWidth>0</CenterWidth>
	</Formation>

With a 3 figure units you will have the first 2 in front, and the third alone on the second line, and the game engine place single figure on a line in the middle, so it should fit your need.
 
I tried your solution, but got stuck with a small problem:

The formation doesn't get accepted by the game, I receive this error in the Database log:

Spoiler :
[21996.094] Database::XMLSerializer (xml/Units/UnitMisc.xml): 'Row' or 'Delete' expected, got 'Formation'.


Here the new formation in the xml of my mod:

Spoiler :
<Formations>
<Formation>
<Name>ProtectedHero</Name>
<SpacingX>12</SpacingX>
<SpacingY>8</SpacingY>
<SpacingMultiplier>1</SpacingMultiplier>
<PerRowInc>0</PerRowInc>
<YOffsetInc>0</YOffsetInc>
<YOffsetCurved>0</YOffsetCurved>
<Stagger>1</Stagger>
<UnitRandomness>0</UnitRandomness>
<BlockRandomness>0</BlockRandomness>
<TotalWidth>2</TotalWidth>
<XBlockSize>0</XBlockSize>
<XBlockSpacingCount>0</XBlockSpacingCount>
<YBlockSize>0</YBlockSize>
<YBlockSpacingCount>0</YBlockSpacingCount>
<CenterWidth>0</CenterWidth>
</Formation>
</Formations>


The funny thing is that the vanilla formations.xml doesn't use <Row> at all, it also just puts <Formation>.

My theories: Either I need to set VFS to true for this xml, or formations can't be added in xml, just like unit art infos.
Might adding the formation in sql format solve the issue?
 
I tried your solution, but got stuck with a small problem:

The formation doesn't get accepted by the game, I receive this error in the Database log:

Spoiler :
[21996.094] Database::XMLSerializer (xml/Units/UnitMisc.xml): 'Row' or 'Delete' expected, got 'Formation'.


Here the new formation in the xml of my mod:

Spoiler :
<Formations>
<Formation>
<Name>ProtectedHero</Name>
<SpacingX>12</SpacingX>
<SpacingY>8</SpacingY>
<SpacingMultiplier>1</SpacingMultiplier>
<PerRowInc>0</PerRowInc>
<YOffsetInc>0</YOffsetInc>
<YOffsetCurved>0</YOffsetCurved>
<Stagger>1</Stagger>
<UnitRandomness>0</UnitRandomness>
<BlockRandomness>0</BlockRandomness>
<TotalWidth>2</TotalWidth>
<XBlockSize>0</XBlockSize>
<XBlockSpacingCount>0</XBlockSpacingCount>
<YBlockSize>0</YBlockSize>
<YBlockSpacingCount>0</YBlockSpacingCount>
<CenterWidth>0</CenterWidth>
</Formation>
</Formations>


The funny thing is that the vanilla formations.xml doesn't use <Row> at all, it also just puts <Formation>.

My theories: Either I need to set VFS to true for this xml, or formations can't be added in xml, just like unit art infos.
Might adding the formation in sql format solve the issue?

The formation file is one of the few that are not added to the database, but still moddable by completely replacing it. (Yes, put a copy in your mod with VFS property to true and edit it)

Problem is that your mod won't be compatible with other mods modifying the formations (like R.E.D. Modpack)
 
Ah, that's the trick...

Alright, I think I will keep the Merchant formation and just make it 3 units of the same model.
The mod is compatible with everything so far, and I would like to keep it that way - more options for players to combine mods, no conflicts...

Thanks a lot for the info, though!
Always nice to learn something more ;)



Here's the mod if you're interested:

Supernatural Beliefs Mod
 
Top Bottom