Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/components/Attack.js
Show First 20 Lines • Show All 116 Lines • ▼ Show 20 Lines | "<Slaughter>" + | ||||
"<Pierce>0.0</Pierce>" + | "<Pierce>0.0</Pierce>" + | ||||
"<Crush>0.0</Crush>" + | "<Crush>0.0</Crush>" + | ||||
"<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='Damage'>" + | |||||
DamageTypes.BuildSchema("damage strength") + | DamageTypes.BuildSchema("damage strength") + | ||||
"</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='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.bonusesSchema + | Attack.prototype.bonusesSchema + | ||||
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='Damage'>" + | |||||
DamageTypes.BuildSchema("damage strength") + | DamageTypes.BuildSchema("damage strength") + | ||||
"</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>" + | "<optional>" + | ||||
"<element name='RangeOverlay'>" + | "<element name='RangeOverlay'>" + | ||||
"<interleave>" + | "<interleave>" + | ||||
Show All 11 Lines | "<element name='Ranged'>" + | ||||
"</element>" + | "</element>" + | ||||
"<element name='Delay' a:help='Delay of the damage in milliseconds'><ref name='nonNegativeDecimal'/></element>" + | "<element name='Delay' a:help='Delay of the damage in milliseconds'><ref name='nonNegativeDecimal'/></element>" + | ||||
"<optional>" + | "<optional>" + | ||||
"<element name='Splash'>" + | "<element name='Splash'>" + | ||||
"<interleave>" + | "<interleave>" + | ||||
"<element name='Shape' a:help='Shape of the splash damage, can be circular or linear'><text/></element>" + | "<element name='Shape' a:help='Shape of the splash damage, can be circular or linear'><text/></element>" + | ||||
"<element name='Range' a:help='Size of the area affected by the splash'><ref name='nonNegativeDecimal'/></element>" + | "<element name='Range' a:help='Size of the area affected by the splash'><ref name='nonNegativeDecimal'/></element>" + | ||||
"<element name='FriendlyFire' a:help='Whether the splash damage can hurt non enemy units'><data type='boolean'/></element>" + | "<element name='FriendlyFire' a:help='Whether the splash damage can hurt non enemy units'><data type='boolean'/></element>" + | ||||
"<element name='Damage'>" + | |||||
DamageTypes.BuildSchema("damage strength") + | DamageTypes.BuildSchema("damage strength") + | ||||
"</element>" + | |||||
Attack.prototype.bonusesSchema + | Attack.prototype.bonusesSchema + | ||||
"</interleave>" + | "</interleave>" + | ||||
"</element>" + | "</element>" + | ||||
"</optional>" + | "</optional>" + | ||||
"<element name='Projectile'>" + | "<element name='Projectile'>" + | ||||
"<interleave>" + | "<interleave>" + | ||||
"<element name='Speed' a:help='Speed of projectiles (in meters per second).'>" + | "<element name='Speed' a:help='Speed of projectiles (in meters per second).'>" + | ||||
"<ref name='positiveDecimal'/>" + | "<ref name='positiveDecimal'/>" + | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | "<element name='Capture'>" + | ||||
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='Damage'>" + | |||||
DamageTypes.BuildSchema("damage strength") + | DamageTypes.BuildSchema("damage strength") + | ||||
"</element>" + | |||||
"<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.bonusesSchema + | Attack.prototype.bonusesSchema + | ||||
Attack.prototype.preferredClassesSchema + | Attack.prototype.preferredClassesSchema + | ||||
Attack.prototype.restrictedClassesSchema + | Attack.prototype.restrictedClassesSchema + | ||||
"</interleave>" + | "</interleave>" + | ||||
"</element>" + | "</element>" + | ||||
"</optional>"; | "</optional>"; | ||||
▲ Show 20 Lines • Show All 204 Lines • ▼ Show 20 Lines | Attack.prototype.GetAttackStrengths = function(type) | ||||
let splash = ""; | let splash = ""; | ||||
if (!template) | if (!template) | ||||
{ | { | ||||
template = this.template[type.split(".")[0]].Splash; | template = this.template[type.split(".")[0]].Splash; | ||||
splash = "/Splash"; | splash = "/Splash"; | ||||
} | } | ||||
let applyMods = damageType => | let applyMods = damageType => | ||||
ApplyValueModificationsToEntity("Attack/" + type + splash + "/" + damageType, +(template[damageType] || 0), this.entity); | ApplyValueModificationsToEntity("Attack/" + type + splash + "/Damage/" + damageType, +(template.Damage[damageType] || 0), this.entity); | ||||
if (type == "Capture") | if (type == "Capture") | ||||
return { "value": applyMods("Value") }; | return { "value": ApplyValueModificationsToEntity("Attack/Capture/Value", +(template.Value || 0), this.entity) }; | ||||
let ret = {}; | let ret = {}; | ||||
for (let damageType of DamageTypes.GetTypes()) | for (let damageType of DamageTypes.GetTypes()) | ||||
ret[damageType] = applyMods(damageType); | ret[damageType] = applyMods(damageType); | ||||
return ret; | return ret; | ||||
}; | }; | ||||
Attack.prototype.GetSplashDamage = function(type) | Attack.prototype.GetSplashDamage = function(type) | ||||
{ | { | ||||
if (!this.template[type].Splash) | if (!this.template[type].Splash) | ||||
return false; | return false; | ||||
let splash = this.GetAttackStrengths(type + ".Splash"); | let splash = {}; | ||||
splash.damage = this.GetAttackStrengths(type + ".Splash"); | |||||
splash.friendlyFire = this.template[type].Splash.FriendlyFire != "false"; | splash.friendlyFire = this.template[type].Splash.FriendlyFire != "false"; | ||||
splash.shape = this.template[type].Splash.Shape; | splash.shape = this.template[type].Splash.Shape; | ||||
return splash; | return splash; | ||||
}; | }; | ||||
Attack.prototype.GetRange = function(type) | Attack.prototype.GetRange = function(type) | ||||
{ | { | ||||
let max = +this.template[type].MaxRange; | let max = +this.template[type].MaxRange; | ||||
▲ Show 20 Lines • Show All 236 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator