1
0
forked from 0ad/0ad

Show the number of attacks per second to show users some attack speed, without showing the actual timers, or calcualtion of the number of arrows. Fixes #2352

This was SVN commit r14555.
This commit is contained in:
sanderd17 2014-01-10 09:17:40 +00:00
parent 72c2853563
commit 3d23f81696
2 changed files with 32 additions and 4 deletions

View File

@ -225,15 +225,29 @@ function displaySingle(entState, template)
Math.round(range/4);
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) + ")";
} // don't show when it's 0
}
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";
}
Engine.GetGUIObjectByName("attackAndArmorStats").tooltip = attack + "\n[font=\"serif-bold-13\"]Armor:[/font] " + armorTypeDetails(entState.armour);

View File

@ -322,6 +322,9 @@ GuiInterface.prototype.GetExtendedEntityState = function(player, ent)
ret.attack.type = type;
ret.attack.minRange = range.min;
ret.attack.maxRange = range.max;
var timers = cmpAttack.GetTimers(type);
ret.attack.prepareTime = timers.prepare;
ret.attack.repeatTime = timers.repeat;
if (type == "Ranged")
{
ret.attack.elevationBonus = range.elevationBonus;
@ -359,6 +362,17 @@ GuiInterface.prototype.GetExtendedEntityState = function(player, ent)
ret.armour = cmpArmour.GetArmourStrengths();
}
var cmpBuildingAI = Engine.QueryInterface(ent, IID_BuildingAI);
if (cmpBuildingAI)
{
ret.buildingAI = {
"defaultArrowCount": cmpBuildingAI.GetDefaultArrowCount(),
"garrisonArrowMultiplier": cmpBuildingAI.GetGarrisonArrowMultiplier(),
"garrisonArrowClasses": cmpBuildingAI.GetGarrisonArrowClasses(),
"arrowCount": cmpBuildingAI.GetArrowCount()
};
}
var cmpObstruction = Engine.QueryInterface(ent, IID_Obstruction);
if (cmpObstruction)
{