Changeset View
Standalone View
binaries/data/mods/public/simulation/components/Attack.js
Show First 20 Lines • Show All 121 Lines • ▼ Show 20 Lines | "<element name='Ranged'>" + | ||||
"<element name='Hack' a:help='Hack damage strength'><ref name='nonNegativeDecimal'/></element>" + | "<element name='Hack' a:help='Hack damage strength'><ref name='nonNegativeDecimal'/></element>" + | ||||
"<element name='Pierce' a:help='Pierce damage strength'><ref name='nonNegativeDecimal'/></element>" + | "<element name='Pierce' a:help='Pierce damage strength'><ref name='nonNegativeDecimal'/></element>" + | ||||
"<element name='Crush' a:help='Crush damage strength'><ref name='nonNegativeDecimal'/></element>" + | "<element name='Crush' a:help='Crush damage strength'><ref name='nonNegativeDecimal'/></element>" + | ||||
"<element name='MaxRange' a:help='Maximum attack range (in metres)'><ref name='nonNegativeDecimal'/></element>" + | "<element name='MaxRange' a:help='Maximum attack range (in metres)'><ref name='nonNegativeDecimal'/></element>" + | ||||
"<element name='MinRange' a:help='Minimum attack range (in metres)'><ref name='nonNegativeDecimal'/></element>" + | "<element name='MinRange' a:help='Minimum attack range (in metres)'><ref name='nonNegativeDecimal'/></element>" + | ||||
"<optional>"+ | "<optional>"+ | ||||
"<element name='ElevationBonus' a:help='give an elevation advantage (in meters)'><ref name='nonNegativeDecimal'/></element>" + | "<element name='ElevationBonus' a:help='give an elevation advantage (in meters)'><ref name='nonNegativeDecimal'/></element>" + | ||||
"</optional>" + | "</optional>" + | ||||
"<optional>"+ | |||||
"<element name='ShowRangeOverlay' a:help='If the range overlay will be shown.'><data type='boolean'/></element>" + | |||||
elexis: That's a dependent clause without the main clause. | |||||
Not Done Inline ActionsIf one doesn't want a range visualized, then there should be no RangeOverlay. elexis: If one doesn't want a range visualized, then there should be no `RangeOverlay`.
Disabling… | |||||
"</optional>" + | |||||
"<optional>" + | |||||
"<element name='RangeOverlay'>" + | |||||
"<interleave>" + | |||||
"<element name='LineTexture'><text/></element>" + | |||||
"<element name='LineTextureMask'><text/></element>" + | |||||
"<element name='LineThickness'><ref name='nonNegativeDecimal'/></element>" + | |||||
"</interleave>" + | |||||
"</element>" + | |||||
"</optional>" + | |||||
"<element name='PrepareTime' a:help='Time from the start of the attack command until the attack actually occurs (in milliseconds). This value relative to RepeatTime should closely match the \"event\" point in the actor's attack animation'>" + | "<element name='PrepareTime' a:help='Time from the start of the attack command until the attack actually occurs (in milliseconds). This value relative to RepeatTime should closely match the \"event\" point in the actor's attack animation'>" + | ||||
"<data type='nonNegativeInteger'/>" + | "<data type='nonNegativeInteger'/>" + | ||||
"</element>" + | "</element>" + | ||||
"<element name='RepeatTime' a:help='Time between attacks (in milliseconds). The attack animation will be stretched to match this time'>" + | "<element name='RepeatTime' a:help='Time between attacks (in milliseconds). The attack animation will be stretched to match this time'>" + | ||||
"<data type='positiveInteger'/>" + | "<data type='positiveInteger'/>" + | ||||
"</element>" + | "</element>" + | ||||
"<element name='ProjectileSpeed' a:help='Speed of projectiles (in metres per second)'>" + | "<element name='ProjectileSpeed' a:help='Speed of projectiles (in metres per second)'>" + | ||||
"<ref name='positiveDecimal'/>" + | "<ref name='positiveDecimal'/>" + | ||||
▲ Show 20 Lines • Show All 289 Lines • ▼ Show 20 Lines | Attack.prototype.GetRange = function(type) | ||||
min = ApplyValueModificationsToEntity("Attack/" + type + "/MinRange", min, this.entity); | min = ApplyValueModificationsToEntity("Attack/" + type + "/MinRange", min, this.entity); | ||||
let elevationBonus = +(this.template[type].ElevationBonus || 0); | let elevationBonus = +(this.template[type].ElevationBonus || 0); | ||||
elevationBonus = ApplyValueModificationsToEntity("Attack/" + type + "/ElevationBonus", elevationBonus, this.entity); | elevationBonus = ApplyValueModificationsToEntity("Attack/" + type + "/ElevationBonus", elevationBonus, this.entity); | ||||
return { "max": max, "min": min, "elevationBonus": elevationBonus }; | return { "max": max, "min": min, "elevationBonus": elevationBonus }; | ||||
}; | }; | ||||
Attack.prototype.ShowRangeOverlay = function() | |||||
{ | |||||
return this.template.Ranged && !!this.template.Ranged.ShowRangeOverlay; | |||||
}; | |||||
Attack.prototype.GetLineTexture = function() | |||||
{ | |||||
return this.template.Ranged.RangeOverlay ? this.template.Ranged.RangeOverlay.LineTexture : "outline_border.png"; | |||||
}; | |||||
Attack.prototype.GetLineTextureMask = function() | |||||
{ | |||||
return this.template.Ranged.RangeOverlay ? this.template.Ranged.RangeOverlay.LineTextureMask : "outline_border_mask.png"; | |||||
Not Done Inline ActionsUsing default images and widths in JS components is bad practice. Balancing and art must be removed from the components and specified in the templates. The Aura and Heal component have it wrong too :-/ Those 4 functions can become one just returning the template. In fact the object used in RangeVisualization.UpdateVisualAttackRanges can be constructed here. elexis: Using default images and widths in JS components is bad practice. Balancing and art must be… | |||||
}; | |||||
Attack.prototype.GetLineThickness = function() | |||||
{ | |||||
return this.template.Ranged.RangeOverlay ? +this.template.Ranged.RangeOverlay.LineThickness : 0.175; | |||||
}; | |||||
Not Done Inline ActionsIt were nicer to read if we'd merge those 4 into one, so that we have one function returning the same format in each component, instead of 4 functions in each component. elexis: It were nicer to read if we'd merge those 4 into one, so that we have one function returning… | |||||
Not Done Inline ActionsI guess that becomes self-evident when working with the range overlay code next time. elexis: I guess that becomes self-evident when working with the range overlay code next time. | |||||
// Calculate the attack damage multiplier against a target | // Calculate the attack damage multiplier against a target | ||||
Attack.prototype.GetAttackBonus = function(type, target) | Attack.prototype.GetAttackBonus = function(type, target) | ||||
{ | { | ||||
let attackBonus = 1; | let attackBonus = 1; | ||||
let template = this.template[type]; | let template = this.template[type]; | ||||
if (!template) | if (!template) | ||||
template = this.template[type.split(".")[0]].Splash; | template = this.template[type.split(".")[0]].Splash; | ||||
▲ Show 20 Lines • Show All 186 Lines • Show Last 20 Lines |
That's a dependent clause without the main clause.