diff --git a/binaries/data/mods/official/entities/template_entity.xml b/binaries/data/mods/official/entities/template_entity.xml
index d4d813b7d2..1e287a47eb 100755
--- a/binaries/data/mods/official/entities/template_entity.xml
+++ b/binaries/data/mods/official/entities/template_entity.xml
@@ -39,6 +39,7 @@
bar.dds
+ 0.0
-1.0
20
2.0
@@ -72,6 +73,14 @@
7
.1
+
+
+
+ false
+ bar.dds
+ 0.2
+
+
false
diff --git a/binaries/data/mods/official/entities/template_structure.xml b/binaries/data/mods/official/entities/template_structure.xml
index 16f5cc620b..f4f1049157 100644
--- a/binaries/data/mods/official/entities/template_structure.xml
+++ b/binaries/data/mods/official/entities/template_structure.xml
@@ -34,6 +34,15 @@
9
+
+
+
+ true
+ 12.0
+ 6.0
+ 0.6
+
+
diff --git a/binaries/data/mods/official/entities/template_unit.xml b/binaries/data/mods/official/entities/template_unit.xml
index bd38849594..25ed38b44e 100644
--- a/binaries/data/mods/official/entities/template_unit.xml
+++ b/binaries/data/mods/official/entities/template_unit.xml
@@ -71,6 +71,14 @@
6
+
+
+ true
+ 5.0
+ 2.0
+ 0.6
+
+
diff --git a/binaries/data/mods/official/scripts/entity_functions.js b/binaries/data/mods/official/scripts/entity_functions.js
index 5ad5772656..dc3fc85983 100644
--- a/binaries/data/mods/official/scripts/entity_functions.js
+++ b/binaries/data/mods/official/scripts/entity_functions.js
@@ -144,57 +144,16 @@ function entityInit()
if (!this.traits.promotion)
this.traits.promotion = new Object();
+ this.setupRank = setupRank;
+
// If entity becomes another entity after it gains enough experience points, set up secondary attributes.
if (this.traits.promotion.req)
{
- // Get the name of the entity.
- entityName = this.tag.toString();
-
- // Determine whether current is basic, advanced or elite, and set rank to suit.
- switch (entityName.substring (entityName.length-2, entityName.length))
- {
- case "_b":
- // Basic. Upgrades to Advanced.
- this.traits.promotion.rank = "1";
- nextSuffix = "_a";
- // Set rank image to put over entity's head.
- this.traits.rank.name = "";
- break;
- case "_a":
- // Advanced. Upgrades to Elite.
- this.traits.promotion.rank = "2";
- nextSuffix = "_e";
- // Set rank image to put over entity's head.
- this.traits.rank.name = "advanced.dds";
- break;
- case "_e":
- // Elite. Maximum rank.
- this.traits.promotion.rank = "3";
- nextSuffix = "";
- // Set rank image to put over entity's head.
- this.traits.rank.name = "elite.dds";
- break;
- default:
- // Does not gain promotions.
- this.traits.promotion.rank = "0"
- nextSuffix = ""
- break;
- }
-
+ this.setupRank();
+
// Give the entity an initial value of 0 earned XP at startup if a default value is not specified.
if (!this.traits.promotion.curr)
- this.traits.promotion.curr = 0
-
- // The entity it should become (unless specified otherwise) is the base entity plus promotion suffix.
- if (!this.traits.promotion.newentity && nextSuffix != "" && this.traits.promotion.rank != "0")
- this.traits.promotion.newentity = entityName.substring (0, entityName.length-2) + nextSuffix
-
- // If entity is an additional rank and the correct actor has not been specified
- // (it's just inherited the Basic), point it to the correct suffix. (Saves us specifying it each time.)
- actorStr = this.actor.toString();
- if (this.traits.promotion.rank > "1"
- && actorStr.substring (actorStr.length-5, actorStr.length) != nextSuffix + ".xml")
- this.actor = actorStr.substring (1,actorStr.length-5) + nextSuffix + ".xml";
+ this.traits.promotion.curr = 0;
}
else
{
@@ -440,6 +399,57 @@ function entityInitQuasi()
// ====================================================================
+// Setup entity's next rank
+function setupRank()
+{
+ // Get the name of the entity.
+ entityName = this.tag.toString();
+
+ // Determine whether current is basic, advanced or elite, and set rank to suit.
+ switch (entityName.substring (entityName.length-2, entityName.length))
+ {
+ case "_b":
+ // Basic. Upgrades to Advanced.
+ this.traits.promotion.rank = "1";
+ nextSuffix = "_a";
+ // Set rank image to put over entity's head.
+ this.traits.rank.name = "";
+ break;
+ case "_a":
+ // Advanced. Upgrades to Elite.
+ this.traits.promotion.rank = "2";
+ nextSuffix = "_e";
+ // Set rank image to put over entity's head.
+ this.traits.rank.name = "advanced.dds";
+ break;
+ case "_e":
+ // Elite. Maximum rank.
+ this.traits.promotion.rank = "3";
+ nextSuffix = "";
+ // Set rank image to put over entity's head.
+ this.traits.rank.name = "elite.dds";
+ break;
+ default:
+ // Does not gain promotions.
+ this.traits.promotion.rank = "0"
+ nextSuffix = ""
+ break;
+ }
+
+ // If entity is an additional rank and the correct actor has not been specified
+ // (it's just inherited the Basic), point it to the correct suffix. (Saves us specifying it each time.)
+ actorStr = this.actor.toString();
+ if (this.traits.promotion.rank > "1"
+ && actorStr.substring (actorStr.length-5, actorStr.length) != nextSuffix + ".xml")
+ this.actor = actorStr.substring (1,actorStr.length-5) + nextSuffix + ".xml";
+
+ // The entity it should become (unless specified otherwise) is the base entity plus promotion suffix.
+ if (!this.traits.promotion.newentity && nextSuffix != "" && this.traits.promotion.rank != "0")
+ this.traits.promotion.newentity = entityName.substring (0, entityName.length-2) + nextSuffix;
+}
+
+// ====================================================================
+
// Attach any auras the entity is entitled to. This was moved to a separate function so that buildings can have their auras
// attached to them only when they finish construction.
function attachAuras()
@@ -891,6 +901,8 @@ function damage( dmg, inflictor )
// Transmogrify him into his next rank.
inflictor.template = getEntityTemplate( inflictor.traits.promotion.newentity, inflictor.player );
+
+ inflictor.setupRank();
}
}
break;