Adjust the attack tooltips. Make the formatting for attack rate more consistent and use meters instead of tiles for range.

This was SVN commit r14609.
This commit is contained in:
alpha123
2014-01-18 18:59:51 +00:00
parent 046c5ef74c
commit ea526eedd1
2 changed files with 32 additions and 25 deletions
@@ -15,7 +15,7 @@ function displaySingle(entState, template)
{
// Get general unit and player data
var specificName = template.name.specific;
var genericName = template.name.generic != template.name.specific? template.name.generic : "";
var genericName = template.name.generic != template.name.specific ? template.name.generic : "";
// If packed, add that to the generic name (reduces template clutter)
if (genericName && template.pack && template.pack.state == "packed")
genericName += " -- Packed";
@@ -221,33 +221,16 @@ function displaySingle(entState, template)
{
var realRange = entState.attack.elevationAdaptedRange;
var range = entState.attack.maxRange;
attack += ", [font=\"serif-bold-13\"]Range:[/font] " +
Math.round(range/4);
attack += ", [font=\"serif-bold-13\"]Range:[/font] " + range +
"[font=\"sans-10\"][color=\"orange\"] meters[/color][/font]";
if (Math.round((realRange - range)/4) > 0)
attack += " (+" + Math.round((realRange - range)/4) + ")";
else if (Math.round((realRange - range)/4) < 0)
attack += " (" + Math.round((realRange - range)/4) + ")";
if (Math.round(realRange - range) > 0)
attack += " (+" + Math.round(realRange - range) + ")";
else if (Math.round(realRange - range) < 0)
attack += " (" + Math.round(realRange - range) + ")";
}
attack += "\n[font=\"serif-bold-13\"]Rate:[/font] ";
var hits = 0;
if (entState.unitAI)
hits++;
if (entState.buildingAI)
hits += entState.buildingAI.arrowCount;
if (hits == 1)
attack += hits + " attack per ";
else
attack += hits + " attacks per ";
var time = entState.attack.repeatTime/1000;
if (time == 1)
attack += "second";
else
attack += time + " seconds";
attack += ", [font=\"serif-bold-13\"]Rate:[/font] " + attackRateDetails(entState);
}
Engine.GetGUIObjectByName("attackAndArmorStats").tooltip = attack + "\n[font=\"serif-bold-13\"]Armor:[/font] " + armorTypeDetails(entState.armour);
@@ -32,6 +32,17 @@ function toTitleCase(word)
return word;
}
function pluralize(word, count, pluralWord)
{
if (count == 1 && pluralWord != null)
return pluralWord;
var plural = "s";
if (word[word.length - 1] == "s")
plural = "es";
return word + (count == 1 ? "" : plural);
}
// Get the basic player data
function getPlayerData(playerAssignments)
{
@@ -166,6 +177,19 @@ function damageTypeDetails(dmg)
}
}
function attackRateDetails(entState) {
if (entState.buildingAI)
var arrows = entState.buildingAI.arrowCount;
var time = entState.attack.repeatTime / 1000;
if (entState.buildingAI) {
return arrows + "[font=\"sans-10\"][color=\"orange\"] " + pluralize("arrow", arrows) + "[/color][/font]" +
" / " + (time == 1 ? "" : time) + " [font=\"sans-10\"][color=\"orange\"]" + pluralize("second", time) +
"[/color][/font]";
}
return time + "[font=\"sans-10\"][color=\"orange\"] " + pluralize("second", time) + "[/color][/font]";
}
// Converts an armor level into the actual reduction percentage
function armorLevelToPercentage(level)
{