Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/Attack.js
Show All 20 Lines | "<element name='RestrictedClasses' a:help='Space delimited list of classes that cannot be attacked by this entity. If target entity has any of these classes, it cannot be attacked'>" + | ||||||||||||||
"<text/>" + | "<text/>" + | ||||||||||||||
"</element>" + | "</element>" + | ||||||||||||||
"</optional>"; | "</optional>"; | ||||||||||||||
Attack.prototype.Schema = | Attack.prototype.Schema = | ||||||||||||||
"<a:help>Controls the attack abilities and strengths of the unit.</a:help>" + | "<a:help>Controls the attack abilities and strengths of the unit.</a:help>" + | ||||||||||||||
"<a:example>" + | "<a:example>" + | ||||||||||||||
"<Melee>" + | "<Melee>" + | ||||||||||||||
"<AttackName>Spear</AttackName>" + | |||||||||||||||
"<Damage>" + | "<Damage>" + | ||||||||||||||
"<Hack>10.0</Hack>" + | "<Hack>10.0</Hack>" + | ||||||||||||||
"<Pierce>0.0</Pierce>" + | "<Pierce>0.0</Pierce>" + | ||||||||||||||
"<Crush>5.0</Crush>" + | "<Crush>5.0</Crush>" + | ||||||||||||||
"</Damage>" + | "</Damage>" + | ||||||||||||||
"<MaxRange>4.0</MaxRange>" + | "<MaxRange>4.0</MaxRange>" + | ||||||||||||||
"<RepeatTime>1000</RepeatTime>" + | "<RepeatTime>1000</RepeatTime>" + | ||||||||||||||
"<Bonuses>" + | "<Bonuses>" + | ||||||||||||||
"<Bonus1>" + | "<Bonus1>" + | ||||||||||||||
"<Civ>pers</Civ>" + | "<Civ>pers</Civ>" + | ||||||||||||||
"<Classes>Infantry</Classes>" + | "<Classes>Infantry</Classes>" + | ||||||||||||||
"<Multiplier>1.5</Multiplier>" + | "<Multiplier>1.5</Multiplier>" + | ||||||||||||||
"</Bonus1>" + | "</Bonus1>" + | ||||||||||||||
"<BonusCavMelee>" + | "<BonusCavMelee>" + | ||||||||||||||
"<Classes>Cavalry Melee</Classes>" + | "<Classes>Cavalry Melee</Classes>" + | ||||||||||||||
"<Multiplier>1.5</Multiplier>" + | "<Multiplier>1.5</Multiplier>" + | ||||||||||||||
"</BonusCavMelee>" + | "</BonusCavMelee>" + | ||||||||||||||
"</Bonuses>" + | "</Bonuses>" + | ||||||||||||||
"<RestrictedClasses datatype=\"tokens\">Champion</RestrictedClasses>" + | "<RestrictedClasses datatype=\"tokens\">Champion</RestrictedClasses>" + | ||||||||||||||
"<PreferredClasses datatype=\"tokens\">Cavalry Infantry</PreferredClasses>" + | "<PreferredClasses datatype=\"tokens\">Cavalry Infantry</PreferredClasses>" + | ||||||||||||||
"</Melee>" + | "</Melee>" + | ||||||||||||||
"<Ranged>" + | "<Ranged>" + | ||||||||||||||
"<AttackName>Bow</AttackName>" + | |||||||||||||||
"<Damage>" + | "<Damage>" + | ||||||||||||||
"<Hack>0.0</Hack>" + | "<Hack>0.0</Hack>" + | ||||||||||||||
"<Pierce>10.0</Pierce>" + | "<Pierce>10.0</Pierce>" + | ||||||||||||||
"<Crush>0.0</Crush>" + | "<Crush>0.0</Crush>" + | ||||||||||||||
"</Damage>" + | "</Damage>" + | ||||||||||||||
"<MaxRange>44.0</MaxRange>" + | "<MaxRange>44.0</MaxRange>" + | ||||||||||||||
"<MinRange>20.0</MinRange>" + | "<MinRange>20.0</MinRange>" + | ||||||||||||||
"<ElevationBonus>15.0</ElevationBonus>" + | "<ElevationBonus>15.0</ElevationBonus>" + | ||||||||||||||
Show All 22 Lines | "<Ranged>" + | ||||||||||||||
"<Damage>" + | "<Damage>" + | ||||||||||||||
"<Hack>0.0</Hack>" + | "<Hack>0.0</Hack>" + | ||||||||||||||
"<Pierce>10.0</Pierce>" + | "<Pierce>10.0</Pierce>" + | ||||||||||||||
"<Crush>0.0</Crush>" + | "<Crush>0.0</Crush>" + | ||||||||||||||
"</Damage>" + | "</Damage>" + | ||||||||||||||
"</Splash>" + | "</Splash>" + | ||||||||||||||
"</Ranged>" + | "</Ranged>" + | ||||||||||||||
"<Slaughter>" + | "<Slaughter>" + | ||||||||||||||
"<AttackName>Slaughter</AttackName>" + | |||||||||||||||
"<Damage>" + | "<Damage>" + | ||||||||||||||
"<Hack>1000.0</Hack>" + | "<Hack>1000.0</Hack>" + | ||||||||||||||
"<Pierce>0.0</Pierce>" + | "<Pierce>0.0</Pierce>" + | ||||||||||||||
"<Crush>0.0</Crush>" + | "<Crush>0.0</Crush>" + | ||||||||||||||
"</Damage>" + | "</Damage>" + | ||||||||||||||
"<MaxRange>4.0</MaxRange>" + | "<MaxRange>4.0</MaxRange>" + | ||||||||||||||
"</Slaughter>" + | "</Slaughter>" + | ||||||||||||||
"</a:example>" + | "</a:example>" + | ||||||||||||||
"<optional>" + | "<optional>" + | ||||||||||||||
"<element name='Melee'>" + | "<element name='Melee'>" + | ||||||||||||||
"<interleave>" + | "<interleave>" + | ||||||||||||||
"<element name='AttackName' a:help='Name of the attack, to be displayed in the GUI. Optionally includes a translate context attribute.'>" + | |||||||||||||||
"<optional>" + | |||||||||||||||
"<attribute name='context'>" + | |||||||||||||||
"<text/>" + | |||||||||||||||
"</attribute>" + | |||||||||||||||
"</optional>" + | |||||||||||||||
"<text/>" + | |||||||||||||||
"</element>" + | |||||||||||||||
Attacking.BuildAttackEffectsSchema() + | Attacking.BuildAttackEffectsSchema() + | ||||||||||||||
"<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='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'>" + // TODO: it shouldn't be stretched | "<element name='RepeatTime' a:help='Time between attacks (in milliseconds). The attack animation will be stretched to match this time'>" + // TODO: it shouldn't be stretched | ||||||||||||||
"<data type='positiveInteger'/>" + | "<data type='positiveInteger'/>" + | ||||||||||||||
"</element>" + | "</element>" + | ||||||||||||||
Attack.prototype.preferredClassesSchema + | Attack.prototype.preferredClassesSchema + | ||||||||||||||
Attack.prototype.restrictedClassesSchema + | Attack.prototype.restrictedClassesSchema + | ||||||||||||||
"</interleave>" + | "</interleave>" + | ||||||||||||||
"</element>" + | "</element>" + | ||||||||||||||
"</optional>" + | "</optional>" + | ||||||||||||||
"<optional>" + | "<optional>" + | ||||||||||||||
"<element name='Ranged'>" + | "<element name='Ranged'>" + | ||||||||||||||
"<interleave>" + | "<interleave>" + | ||||||||||||||
"<element name='AttackName' a:help='Name of the attack, to be displayed in the GUI. Optionally includes a translate context attribute.'>" + | |||||||||||||||
"<optional>" + | |||||||||||||||
"<attribute name='context'>" + | |||||||||||||||
"<text/>" + | |||||||||||||||
"</attribute>" + | |||||||||||||||
"</optional>" + | |||||||||||||||
"<text/>" + | |||||||||||||||
"</element>" + | |||||||||||||||
Attacking.BuildAttackEffectsSchema() + | Attacking.BuildAttackEffectsSchema() + | ||||||||||||||
"<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>" + | "<optional>" + | ||||||||||||||
"<element name='RangeOverlay'>" + | "<element name='RangeOverlay'>" + | ||||||||||||||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | "<element name='Ranged'>" + | ||||||||||||||
Attack.prototype.preferredClassesSchema + | Attack.prototype.preferredClassesSchema + | ||||||||||||||
Attack.prototype.restrictedClassesSchema + | Attack.prototype.restrictedClassesSchema + | ||||||||||||||
"</interleave>" + | "</interleave>" + | ||||||||||||||
"</element>" + | "</element>" + | ||||||||||||||
"</optional>" + | "</optional>" + | ||||||||||||||
"<optional>" + | "<optional>" + | ||||||||||||||
"<element name='Capture'>" + | "<element name='Capture'>" + | ||||||||||||||
"<interleave>" + | "<interleave>" + | ||||||||||||||
"<element name='AttackName' a:help='Name of the attack, to be displayed in the GUI. Optionally includes a translate context attribute.'>" + | |||||||||||||||
"<optional>" + | |||||||||||||||
"<attribute name='context'>" + | |||||||||||||||
"<text/>" + | |||||||||||||||
"</attribute>" + | |||||||||||||||
"</optional>" + | |||||||||||||||
"<text/>" + | |||||||||||||||
"</element>" + | |||||||||||||||
Attacking.BuildAttackEffectsSchema() + | Attacking.BuildAttackEffectsSchema() + | ||||||||||||||
"<element name='MaxRange' a:help='Maximum attack range (in meters)'><ref name='nonNegativeDecimal'/></element>" + | "<element name='MaxRange' a:help='Maximum attack range (in meters)'><ref name='nonNegativeDecimal'/></element>" + | ||||||||||||||
"<element name='RepeatTime' a:help='Time between attacks (in milliseconds). The attack animation will be stretched to match this time'>" + // TODO: it shouldn't be stretched | "<element name='RepeatTime' a:help='Time between attacks (in milliseconds). The attack animation will be stretched to match this time'>" + // TODO: it shouldn't be stretched | ||||||||||||||
"<data type='positiveInteger'/>" + | "<data type='positiveInteger'/>" + | ||||||||||||||
"</element>" + | "</element>" + | ||||||||||||||
Attack.prototype.preferredClassesSchema + | Attack.prototype.preferredClassesSchema + | ||||||||||||||
Attack.prototype.restrictedClassesSchema + | Attack.prototype.restrictedClassesSchema + | ||||||||||||||
"</interleave>" + | "</interleave>" + | ||||||||||||||
"</element>" + | "</element>" + | ||||||||||||||
"</optional>" + | "</optional>" + | ||||||||||||||
"<optional>" + | "<optional>" + | ||||||||||||||
"<element name='Slaughter' a:help='A special attack to kill domestic animals'>" + | "<element name='Slaughter' a:help='A special attack to kill domestic animals'>" + | ||||||||||||||
"<interleave>" + | "<interleave>" + | ||||||||||||||
"<element name='AttackName' a:help='Name of the attack, to be displayed in the GUI. Optionally includes a translate context attribute.'>" + | |||||||||||||||
"<optional>" + | |||||||||||||||
"<attribute name='context'>" + | |||||||||||||||
"<text/>" + | |||||||||||||||
"</attribute>" + | |||||||||||||||
"</optional>" + | |||||||||||||||
"<text/>" + | |||||||||||||||
"</element>" + | |||||||||||||||
Attacking.BuildAttackEffectsSchema() + | Attacking.BuildAttackEffectsSchema() + | ||||||||||||||
"<element name='MaxRange'><ref name='nonNegativeDecimal'/></element>" + // TODO: how do these work? | "<element name='MaxRange'><ref name='nonNegativeDecimal'/></element>" + // TODO: how do these work? | ||||||||||||||
Attack.prototype.preferredClassesSchema + | Attack.prototype.preferredClassesSchema + | ||||||||||||||
Attack.prototype.restrictedClassesSchema + | Attack.prototype.restrictedClassesSchema + | ||||||||||||||
"</interleave>" + | "</interleave>" + | ||||||||||||||
"</element>" + | "</element>" + | ||||||||||||||
"</optional>"; | "</optional>"; | ||||||||||||||
▲ Show 20 Lines • Show All 189 Lines • ▼ Show 20 Lines | Attack.prototype.CompareEntitiesByPreference = function(a, b) | ||||||||||||||
let bPreference = this.GetPreference(b); | let bPreference = this.GetPreference(b); | ||||||||||||||
if (aPreference === null && bPreference === null) return 0; | if (aPreference === null && bPreference === null) return 0; | ||||||||||||||
if (aPreference === null) return 1; | if (aPreference === null) return 1; | ||||||||||||||
if (bPreference === null) return -1; | if (bPreference === null) return -1; | ||||||||||||||
return aPreference - bPreference; | return aPreference - bPreference; | ||||||||||||||
}; | }; | ||||||||||||||
Attack.prototype.GetAttackName = function(type) | |||||||||||||||
{ | |||||||||||||||
return { "name": this.template[type].AttackName._string || this.template[type].AttackName, "context": this.template[type].AttackName["@context"] }; | |||||||||||||||
Freagarach: Why return something when the entity does not have the type? | |||||||||||||||
Done Inline ActionsWell we have to return something, so we can ofc return "", but even type makes more sense that that imho bb: Well we have to return something, so we can ofc return `""`, but even `type` makes more sense… | |||||||||||||||
Not Done Inline Actions
? Freagarach: ? | |||||||||||||||
}; | |||||||||||||||
Attack.prototype.GetRepeatTime = function(type) | Attack.prototype.GetRepeatTime = function(type) | ||||||||||||||
{ | { | ||||||||||||||
let repeatTime = 1000; | let repeatTime = 1000; | ||||||||||||||
if (this.template[type] && this.template[type].RepeatTime) | if (this.template[type] && this.template[type].RepeatTime) | ||||||||||||||
repeatTime = +this.template[type].RepeatTime; | repeatTime = +this.template[type].RepeatTime; | ||||||||||||||
return ApplyValueModificationsToEntity("Attack/" + type + "/RepeatTime", repeatTime, this.entity); | return ApplyValueModificationsToEntity("Attack/" + type + "/RepeatTime", repeatTime, this.entity); | ||||||||||||||
▲ Show 20 Lines • Show All 211 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Why return something when the entity does not have the type?