mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-19 02:33:15 +00:00
Data changes for new entity bar rendering code. (All the bar info is now in one attribute, rather than having separate info for health bars, stamina bars and ranks).
This was SVN commit r4121.
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
<Border_Name>bar.dds</Border_Name>
|
||||
</Health>
|
||||
<Stamina>
|
||||
<Max>0.0</Max>
|
||||
<Bar_Height>-1.0</Bar_Height>
|
||||
<Bar_Size>20</Bar_Size>
|
||||
<Bar_Width>2.0</Bar_Width>
|
||||
@@ -72,6 +73,14 @@
|
||||
<Sectors>7</Sectors>
|
||||
<Value>.1</Value>
|
||||
</Pitch>
|
||||
|
||||
<Display>
|
||||
<Bars>
|
||||
<Enabled>false</Enabled>
|
||||
<Border>bar.dds</Border>
|
||||
<Border_Size>0.2</Border_Size>
|
||||
</Bars>
|
||||
</Display>
|
||||
|
||||
<Is_Territory_Centre>false</Is_Territory_Centre>
|
||||
|
||||
|
||||
@@ -34,6 +34,15 @@
|
||||
<Vision>
|
||||
<LOS>9</LOS>
|
||||
</Vision>
|
||||
|
||||
<Display>
|
||||
<Bars>
|
||||
<Enabled>true</Enabled>
|
||||
<Offset>12.0</Offset>
|
||||
<Width>6.0</Width>
|
||||
<Height>0.6</Height>
|
||||
</Bars>
|
||||
</Display>
|
||||
</Traits>
|
||||
|
||||
<Script File="scripts/entity_functions.js" />
|
||||
|
||||
@@ -71,6 +71,14 @@
|
||||
<LOS>6</LOS>
|
||||
</Vision>
|
||||
|
||||
<Display>
|
||||
<Bars>
|
||||
<Enabled>true</Enabled>
|
||||
<Offset>5.0</Offset>
|
||||
<Width>2.0</Width>
|
||||
<Height>0.6</Height>
|
||||
</Bars>
|
||||
</Display>
|
||||
</Traits>
|
||||
|
||||
<Actions>
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user