1
0
forked from 0ad/0ad

Fix function that decides which units can have which formations, and remove formations for animals and the maurian worker elephant

This was SVN commit r13726.
This commit is contained in:
sanderd17 2013-08-21 09:53:59 +00:00
parent 52d6a8036d
commit 605852fccf
6 changed files with 19 additions and 21 deletions

View File

@ -1249,38 +1249,31 @@ function GetFormationRequirements(formationName)
function CanMoveEntsIntoFormation(ents, formationName)
{
var count = ents.length;
// TODO: should check the player's civ is allowed to use this formation
// See simulation/components/Player.js GetFormations() for a list of all allowed formations
var requirements = GetFormationRequirements(formationName);
if (!requirements)
return false;
if (count < requirements.count)
return false;
var scatterOnlyUnits = true;
formationName = formationName.replace(/\s+/g,"");
var count = 0;
var reqClasses = requirements.classesRequired || [];
for each (var ent in ents)
{
var cmpIdentity = Engine.QueryInterface(ent, IID_Identity);
if (cmpIdentity)
{
var classes = cmpIdentity.GetClassesList();
if (scatterOnlyUnits && (classes.indexOf("Worker") == -1 || classes.indexOf("Support") == -1))
scatterOnlyUnits = false;
for each (var classRequired in requirements.classesRequired)
{
if (classes.indexOf(classRequired) == -1)
{
return false;
}
}
}
if (!cmpIdentity || !cmpIdentity.CanUseFormation(formationName))
continue;
var classes = cmpIdentity.GetClassesList();
if (reqClasses.some(function(c){return classes.indexOf(c) == -1;}))
return false;
count++;
}
if (scatterOnlyUnits)
if (count < requirements.count)
return false;
return true;

View File

@ -20,6 +20,7 @@
<Identity>
<GenericName>Island Settlement</GenericName>
<Civ>brit</Civ>
<Classes datatype="tokens">Naval</Classes>
<Tooltip>Increase population limit and defend waterways</Tooltip>
<SpecificName>Crannog</SpecificName>
<History>A crannog (or crannoge) is the name given in Scotland and Ireland to an artificial island or natural island, used for a settlement. The name can also be used to refer to wooden platforms erected on shallow loch floors, although understandably few remains of this sort have been found. The choice of an island as a home is thought to have been for defence as well as the availability of food in the form of fish nearby.</History>

View File

@ -11,6 +11,7 @@
<GenericName>Fauna</GenericName>
<Classes datatype="tokens">Animal Organic -ConquestCritical</Classes>
<Icon>gaia/fauna_generic.png</Icon>
<Formations disable=""/>
</Identity>
<Loot>
<xp>10</xp>

View File

@ -11,6 +11,9 @@
<Identity>
<GenericName>Support</GenericName>
<Classes datatype="tokens">Support Organic</Classes>
<Formations datatype="tokens" replace="">
Box
</Formations>
</Identity>
<Loot>
<xp>10</xp>

View File

@ -53,7 +53,6 @@
<History>Women in the ancient world took on a variety of roles - from leadership (Celts) to servant (Greeks). Women are hard workers, the economic backbone of any civilisation. In history, it was typical when all the males (capable of fighting) were killed for the females, children, and elderly to be sold as slaves.</History>
<Tooltip>Gather resources, build civic structures, and inspire nearby males to work faster. Bonused at foraging and farming.</Tooltip>
<Classes datatype="tokens">Worker Female Citizen</Classes>
<Formations disable=""/>
</Identity>
<ResourceGatherer>
<MaxDistance>2.0</MaxDistance>

View File

@ -30,6 +30,7 @@
<Icon>units/maur_support_elephant.png</Icon>
<History>Support Elephant.</History>
<Tooltip>Mobile dropsite. Can also assist in constructing buildings.</Tooltip>
<Formations disable=""/>
</Identity>
<Loot>
<xp>50</xp>