1
0
forked from mirrors/0ad

Add sloppyness and separate icon path to formation templates (makes it possible to have multiple formation templates - like different settings for different civs - with only one icon file)

This was SVN commit r15180.
This commit is contained in:
sanderd17
2014-05-20 17:18:40 +00:00
parent 4c9d99ff68
commit 672f5a8b11
17 changed files with 30 additions and 2 deletions
@@ -653,7 +653,7 @@ function setupUnitPanel(guiName, usedPanels, unitEntState, playerState, items, c
});
guiSelection.hidden = !formationSelected;
icon.sprite = "stretched:"+grayscale+"session/icons/"+item+".png";
icon.sprite = "stretched:"+grayscale+"session/icons/"+formationInfo.icon;
}
else if (guiName == STANCE)
@@ -4,6 +4,9 @@ Formation.prototype.Schema =
"<element name='FormationName' a:help='Name of the formation'>" +
"<text/>" +
"</element>" +
"<element name='Icon'>" +
"<text/>" +
"</element>" +
"<element name='RequiredMemberCount' a:help='Minimum number of entities the formation should contain'>" +
"<data type='nonNegativeInteger'/>" +
"</element>" +
@@ -30,6 +33,9 @@ Formation.prototype.Schema =
"<element name='WidthDepthRatio' a:help='Average width/depth, counted in number of units.'>" +
"<ref name='nonNegativeDecimal'/>" +
"</element>" +
"<element name='Sloppyness' a:help='Sloppyness in meters (the max difference between the actual and the perfectly aligned formation position'>" +
"<ref name='nonNegativeDecimal'/>" +
"</element>" +
"<optional>" +
"<element name='MinColumns' a:help='When possible, this number of colums will be created. Overriding the wanted width depth ratio'>" +
"<data type='nonNegativeInteger'/>" +
@@ -77,6 +83,7 @@ Formation.prototype.Init = function()
"width": +this.template.UnitSeparationWidthMultiplier,
"depth": +this.template.UnitSeparationDepthMultiplier
};
this.sloppyness = +this.template.Sloppyness;
this.widthDepthRatio = +this.template.WidthDepthRatio;
this.minColumns = +(this.template.MinColumns || 0);
this.maxColumns = +(this.template.MaxColumns || 0);
@@ -736,7 +743,13 @@ Formation.prototype.ComputeFormationOffsets = function(active, positions)
x += side * centerGap / 2;
}
var column = Math.ceil(n/2) + Math.ceil(c/2) * side;
offsets.push(new Vector2D(x, z));
var r1, r2 = 0;
if (this.sloppyness != 0)
{
r1 = (Math.random() * 2 - 1) * this.sloppyness;
r2 = (Math.random() * 2 - 1) * this.sloppyness;
}
offsets.push(new Vector2D(x + r1, z + r2));
offsets[offsets.length - 1].row = r+1;
offsets[offsets.length - 1].column = column;
left--
@@ -860,6 +860,7 @@ GuiInterface.prototype.GetFormationInfoFromTemplate = function(player, data)
return r;
r.name = template.Formation.FormationName;
r.tooltip = template.Formation.DisabledTooltip || "";
r.icon = template.Formation.Icon;
return r;
};
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity parent="template_formation">
<Formation>
<Icon>formations/battle_line.png</Icon>
<FormationName>Battle Line</FormationName>
<SortingClasses>Cavalry Melee Ranged</SortingClasses>
<SortingOrder>fillFromTheSides</SortingOrder>
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity parent="template_formation">
<Formation>
<Icon>formations/box.png</Icon>
<RequiredMemberCount>4</RequiredMemberCount>
<DisabledTooltip>4 units required</DisabledTooltip>
<FormationName>Box</FormationName>
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity parent="template_formation">
<Formation>
<Icon>formations/column_closed.png</Icon>
<FormationName>Column Closed</FormationName>
<MinColumns>3</MinColumns>
<MaxColumns>3</MaxColumns>
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity parent="template_formation">
<Formation>
<Icon>formations/column_open.png</Icon>
<FormationName>Column Open</FormationName>
<ShiftRows>true</ShiftRows>
<UnitSeparationWidthMultiplier>2</UnitSeparationWidthMultiplier>
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity parent="template_formation">
<Formation>
<Icon>formations/flank.png</Icon>
<RequiredMemberCount>8</RequiredMemberCount>
<DisabledTooltip>8 units required</DisabledTooltip>
<FormationName>Flank</FormationName>
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity parent="template_formation">
<Formation>
<Icon>formations/line_closed.png</Icon>
<FormationName>Line Closed</FormationName>
<MinColumns>3</MinColumns>
<WidthDepthRatio>4</WidthDepthRatio>
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity parent="template_formation">
<Formation>
<Icon>formations/line_open.png</Icon>
<FormationName>Line Open</FormationName>
<ShiftRows>true</ShiftRows>
<UnitSeparationWidthMultiplier>2</UnitSeparationWidthMultiplier>
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity parent="template_formation">
<Formation>
<Icon>formations/phalanx.png</Icon>
<RequiredMemberCount>10</RequiredMemberCount>
<DisabledTooltip>10 melee infantry units required</DisabledTooltip>
<FormationName>Phalanx</FormationName>
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity parent="template_formation">
<Formation>
<Icon>formations/scatter.png</Icon>
<FormationName>Scatter</FormationName>
<FormationShape>special</FormationShape>
</Formation>
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity parent="template_formation">
<Formation>
<Icon>formations/skirmish.png</Icon>
<DisabledTooltip>Only ranged units allowed</DisabledTooltip>
<FormationName>Skirmish</FormationName>
<ShiftRows>true</ShiftRows>
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity parent="template_formation">
<Formation>
<Icon>formations/syntagma.png</Icon>
<RequiredMemberCount>9</RequiredMemberCount>
<DisabledTooltip>9 pike infantry units required</DisabledTooltip>
<FormationName>Syntagma</FormationName>
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity parent="template_formation">
<Formation>
<Icon>formations/testudo.png</Icon>
<RequiredMemberCount>9</RequiredMemberCount>
<DisabledTooltip>9 melee infantry units required</DisabledTooltip>
<FormationName>Testudo</FormationName>
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Entity parent="template_formation">
<Formation>
<Icon>formations/wedge.png</Icon>
<RequiredMemberCount>3</RequiredMemberCount>
<DisabledTooltip>3 cavalry units required</DisabledTooltip>
<FormationName>Wedge</FormationName>
@@ -15,6 +15,7 @@
<UnitSeparationWidthMultiplier>1</UnitSeparationWidthMultiplier>
<UnitSeparationDepthMultiplier>1</UnitSeparationDepthMultiplier>
<WidthDepthRatio>1</WidthDepthRatio>
<Sloppyness>0</Sloppyness>
<Animations/>
</Formation>
<FormationAttack>