Ykkrosh
c8c10a4871
Add various GUI pieces (exit button, resource counts, unit details). Clean up implementation of button panels. Split some content out of 'common' and into page-specific files. Delete some obsolete content. This was SVN commit r7337.
34 lines
955 B
JavaScript
34 lines
955 B
JavaScript
function Armour() {}
|
|
|
|
Armour.prototype.Init = function()
|
|
{
|
|
};
|
|
|
|
Armour.prototype.TakeDamage = function(hack, pierce, crush)
|
|
{
|
|
// Adjust damage values based on armour
|
|
// (Default armour values to 0 if undefined)
|
|
var adjHack = Math.max(0, hack - (this.template.Hack || 0));
|
|
var adjPierce = Math.max(0, pierce - (this.template.Pierce || 0));
|
|
var adjCrush = Math.max(0, crush - (this.template.Crush || 0));
|
|
|
|
// Total is sum of individual damages, with minimum damage 1
|
|
var total = Math.max(1, adjHack + adjPierce + adjCrush);
|
|
|
|
// Reduce health
|
|
var cmpHealth = Engine.QueryInterface(this.entity, IID_Health);
|
|
cmpHealth.Reduce(total);
|
|
};
|
|
|
|
Armour.prototype.GetArmourStrengths = function()
|
|
{
|
|
// Convert attack values to numbers, default 0 if unspecified
|
|
return {
|
|
hack: +(this.template.Hack || 0),
|
|
pierce: +(this.template.Pierce || 0),
|
|
crush: +(this.template.Crush || 0)
|
|
};
|
|
};
|
|
|
|
Engine.RegisterComponentType(IID_DamageReceiver, "Armour", Armour);
|