1
0
forked from 0ad/0ad

generalise kill vs eject garrisoned entities on death of garrisonHolder

This was SVN commit r13676.
This commit is contained in:
sanderd17 2013-08-17 09:26:17 +00:00
parent d37d3be5d0
commit b5888f4e45
20 changed files with 35 additions and 9 deletions

View File

@ -12,7 +12,10 @@ GarrisonHolder.prototype.Schema =
"</element>" +
"<element name='EjectHealth' a:help='Percentage of maximum health below which this holder no longer allows garrisoning'>" +
"<ref name='nonNegativeDecimal'/>" +
"</element>" +
"</element>" +
"<element name='EjectEntitiesOnDestroy' a:help='Whether the entity should eject or kill all garrisoned entities on destroy'>" +
"<data type='boolean'/>" +
"</element>" +
"<element name='BuffHeal' a:help='Number of hit points that will be restored to this holder&apos;s garrisoned units each second'>" +
"<ref name='nonNegativeDecimal'/>" +
"</element>" +
@ -74,6 +77,13 @@ GarrisonHolder.prototype.GetHealRate = function()
return ApplyTechModificationsToEntity("GarrisonHolder/BuffHeal", +this.template.BuffHeal, this.entity);
};
GarrisonHolder.prototype.EjectEntitiesOnDestroy = function()
{
if (this.template.EjectEntitiesOnDestroy == "true")
return true;
return false;
}
/**
* Get number of garrisoned units capable of shooting arrows
* Not necessarily archers
@ -337,15 +347,12 @@ GarrisonHolder.prototype.OnHealthChanged = function(msg)
{
if (!this.HasEnoughHealth())
{
// We have to be careful of our passability
// ships: not land passable, so assume units have drowned in a shipwreck
// building: land passable, so units can be ejected freely
var classes = (Engine.QueryInterface(this.entity, IID_Identity)).GetClassesList();
var cmpPosition = Engine.QueryInterface(this.entity, IID_Position);
// Destroy the garrisoned units if the holder is a ship or is not in the
// world (generally means this holder is inside a ship which has sunk).
if (classes.indexOf("Ship") != -1 || !cmpPosition.IsInWorld())
// Destroy the garrisoned units if the holder kill his entities on destroy or
// is not in the world (generally means this holder is inside
// a holder which kills its entities which has sunk).
if (!this.EjectEntitiesOnDestroy() || !cmpPosition.IsInWorld())
{
for each (var entity in this.entities)
{

View File

@ -7,6 +7,7 @@
<GarrisonHolder>
<Max>30</Max>
<EjectHealth>0.1</EjectHealth>
<EjectEntitiesOnDestroy>true</EjectEntitiesOnDestroy>
<List datatype="tokens">Support Infantry Cavalry</List>
<BuffHeal>3</BuffHeal>
<LoadingRange>2</LoadingRange>

View File

@ -16,6 +16,7 @@
<GarrisonHolder>
<Max>5</Max>
<EjectHealth>0.1</EjectHealth>
<EjectEntitiesOnDestroy>true</EjectEntitiesOnDestroy>
<List datatype="tokens">Support Infantry</List>
<BuffHeal>0</BuffHeal>
<LoadingRange>2</LoadingRange>

View File

@ -7,6 +7,7 @@
<GarrisonHolder>
<Max>30</Max>
<EjectHealth>0.1</EjectHealth>
<EjectEntitiesOnDestroy>true</EjectEntitiesOnDestroy>
<List datatype="tokens">Support Infantry Cavalry</List>
<BuffHeal>3</BuffHeal>
<LoadingRange>2</LoadingRange>

View File

@ -42,6 +42,7 @@
<GarrisonHolder>
<Max>20</Max>
<EjectHealth>0.1</EjectHealth>
<EjectEntitiesOnDestroy>true</EjectEntitiesOnDestroy>
<List datatype="tokens">Support Infantry Cavalry</List>
<BuffHeal>1</BuffHeal>
<LoadingRange>2</LoadingRange>

View File

@ -23,6 +23,7 @@
<GarrisonHolder>
<Max>20</Max>
<EjectHealth>0.1</EjectHealth>
<EjectEntitiesOnDestroy>true</EjectEntitiesOnDestroy>
<List datatype="tokens">Support Infantry Cavalry</List>
<BuffHeal>3</BuffHeal>
<LoadingRange>2</LoadingRange>

View File

@ -34,7 +34,8 @@
</Footprint>
<GarrisonHolder>
<Max>5</Max>
<EjectHealth>0.1</EjectHealth>
<EjectHealth>0.1</EjectHealth>
<EjectEntitiesOnDestroy>true</EjectEntitiesOnDestroy>
<List datatype="tokens">Support Infantry</List>
<BuffHeal>0</BuffHeal>
<LoadingRange>2</LoadingRange>

View File

@ -44,6 +44,7 @@
<GarrisonHolder>
<Max>1</Max>
<EjectHealth>0.1</EjectHealth>
<EjectEntitiesOnDestroy>true</EjectEntitiesOnDestroy>
<List datatype="tokens">Support Infantry</List>
<BuffHeal>0</BuffHeal>
<LoadingRange>2</LoadingRange>

View File

@ -34,6 +34,7 @@
<GarrisonHolder>
<Max>5</Max>
<EjectHealth>0.1</EjectHealth>
<EjectEntitiesOnDestroy>true</EjectEntitiesOnDestroy>
<List datatype="tokens">Support Infantry</List>
<BuffHeal>0</BuffHeal>
<LoadingRange>2</LoadingRange>

View File

@ -16,6 +16,7 @@
<GarrisonHolder>
<Max>10</Max>
<EjectHealth>0.1</EjectHealth>
<EjectEntitiesOnDestroy>true</EjectEntitiesOnDestroy>
<List datatype="tokens">Infantry Cavalry</List>
<BuffHeal>0</BuffHeal>
<LoadingRange>2</LoadingRange>

View File

@ -35,6 +35,7 @@
<GarrisonHolder>
<Max>20</Max>
<EjectHealth>0.075</EjectHealth>
<EjectEntitiesOnDestroy>true</EjectEntitiesOnDestroy>
<List datatype="tokens">Support Infantry Cavalry Siege</List>
<BuffHeal>0</BuffHeal>
<LoadingRange>6</LoadingRange>

View File

@ -13,6 +13,7 @@
<GarrisonHolder>
<Max>10</Max>
<EjectHealth>0.1</EjectHealth>
<EjectEntitiesOnDestroy>true</EjectEntitiesOnDestroy>
<List datatype="tokens">Animal</List>
<BuffHeal>1</BuffHeal>
<LoadingRange>2</LoadingRange>

View File

@ -29,6 +29,7 @@
<GarrisonHolder>
<Max>5</Max>
<EjectHealth>0.1</EjectHealth>
<EjectEntitiesOnDestroy>true</EjectEntitiesOnDestroy>
<List datatype="tokens">Support Infantry Cavalry</List>
<BuffHeal>1</BuffHeal>
<LoadingRange>2</LoadingRange>

View File

@ -33,6 +33,7 @@
<GarrisonHolder>
<Max>20</Max>
<EjectHealth>0</EjectHealth>
<EjectEntitiesOnDestroy>false</EjectEntitiesOnDestroy>
<List datatype="tokens">Support Infantry Cavalry</List>
<BuffHeal>1</BuffHeal>
<LoadingRange>10</LoadingRange>

View File

@ -22,6 +22,7 @@
<GarrisonHolder>
<Max>1</Max>
<EjectHealth>0</EjectHealth>
<EjectEntitiesOnDestroy>false</EjectEntitiesOnDestroy>
<List datatype="tokens">Support Infantry</List>
<BuffHeal>1</BuffHeal>
<LoadingRange>10</LoadingRange>

View File

@ -14,6 +14,7 @@
<GarrisonHolder>
<Max>15</Max>
<EjectHealth>0</EjectHealth>
<EjectEntitiesOnDestroy>false</EjectEntitiesOnDestroy>
<List datatype="tokens">Support Infantry Cavalry</List>
<BuffHeal>1</BuffHeal>
<LoadingRange>10</LoadingRange>

View File

@ -33,6 +33,7 @@
<GarrisonHolder>
<Max>50</Max>
<EjectHealth>0</EjectHealth>
<EjectEntitiesOnDestroy>false</EjectEntitiesOnDestroy>
<List datatype="tokens">Support Infantry Cavalry Siege</List>
<BuffHeal>1</BuffHeal>
<LoadingRange>10</LoadingRange>

View File

@ -33,6 +33,7 @@
<GarrisonHolder>
<Max>30</Max>
<EjectHealth>0</EjectHealth>
<EjectEntitiesOnDestroy>false</EjectEntitiesOnDestroy>
<List datatype="tokens">Support Infantry Cavalry Siege</List>
<BuffHeal>1</BuffHeal>
<LoadingRange>10</LoadingRange>

View File

@ -56,6 +56,7 @@
<GarrisonHolder>
<Max>5</Max>
<EjectHealth>0.1</EjectHealth>
<EjectEntitiesOnDestroy>true</EjectEntitiesOnDestroy>
<List datatype="tokens">Support Infantry</List>
<BuffHeal>1</BuffHeal>
<LoadingRange>2</LoadingRange>

View File

@ -38,6 +38,7 @@
<GarrisonHolder>
<Max>20</Max>
<EjectHealth>0.1</EjectHealth>
<EjectEntitiesOnDestroy>true</EjectEntitiesOnDestroy>
<List datatype="tokens">Support Infantry</List>
<BuffHeal>1</BuffHeal>
<LoadingRange>2</LoadingRange>