Changeset View
Standalone View
binaries/data/mods/public/simulation/components/Attack.js
Show First 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | "<Ranged>" + | ||||
"<Spread>2.5</Spread>" + | "<Spread>2.5</Spread>" + | ||||
"<Delay>1000</Delay>" + | "<Delay>1000</Delay>" + | ||||
"<Bonuses>" + | "<Bonuses>" + | ||||
"<Bonus1>" + | "<Bonus1>" + | ||||
"<Classes>Cavalry</Classes>" + | "<Classes>Cavalry</Classes>" + | ||||
"<Multiplier>2</Multiplier>" + | "<Multiplier>2</Multiplier>" + | ||||
"</Bonus1>" + | "</Bonus1>" + | ||||
"</Bonuses>" + | "</Bonuses>" + | ||||
"<Projectile>" + | |||||
"<Actor>props/units/weapons/rock_flaming.xml</Actor>" + | |||||
"<HitActor>props/units/weapons/rock_explosion.xml</HitActor>" + | |||||
"<HitAnimationTime>0.1</HitAnimationTime>" + | |||||
"</Projectile>" + | |||||
"<RestrictedClasses datatype=\"tokens\">Champion</RestrictedClasses>" + | "<RestrictedClasses datatype=\"tokens\">Champion</RestrictedClasses>" + | ||||
"<Splash>" + | "<Splash>" + | ||||
"<Shape>Circular</Shape>" + | "<Shape>Circular</Shape>" + | ||||
"<Range>20</Range>" + | "<Range>20</Range>" + | ||||
"<FriendlyFire>false</FriendlyFire>" + | "<FriendlyFire>false</FriendlyFire>" + | ||||
"<Hack>0.0</Hack>" + | "<Hack>0.0</Hack>" + | ||||
"<Pierce>10.0</Pierce>" + | "<Pierce>10.0</Pierce>" + | ||||
"<Crush>0.0</Crush>" + | "<Crush>0.0</Crush>" + | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | "<element name='Ranged'>" + | ||||
"<ref name='nonNegativeDecimal'/>" + | "<ref name='nonNegativeDecimal'/>" + | ||||
"</element>" + | "</element>" + | ||||
"<element name='Spread' a:help='Standard deviation of the bivariate normal distribution of hits at 100 meters. A disk at 100 meters from the attacker with this radius (2x this radius, 3x this radius) is expected to include the landing points of 39.3% (86.5%, 98.9%) of the rounds.'><ref name='nonNegativeDecimal'/></element>" + | "<element name='Spread' a:help='Standard deviation of the bivariate normal distribution of hits at 100 meters. A disk at 100 meters from the attacker with this radius (2x this radius, 3x this radius) is expected to include the landing points of 39.3% (86.5%, 98.9%) of the rounds.'><ref name='nonNegativeDecimal'/></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>" + | ||||
Attack.prototype.bonusesSchema + | Attack.prototype.bonusesSchema + | ||||
Attack.prototype.preferredClassesSchema + | Attack.prototype.preferredClassesSchema + | ||||
Attack.prototype.restrictedClassesSchema + | Attack.prototype.restrictedClassesSchema + | ||||
"<optional>" + | "<optional>" + | ||||
"<element name='Projectile'>" + | |||||
"<interleave>" + | |||||
"<optional>" + | |||||
wraitii: I don't think this one should be optional, or alternatively you should make "either or" with… | |||||
Done Inline ActionsThink this lets you have several actorName, I'm not sure whether that works or not... But the proper definition is probably a fair bit annoying. wraitii: Think this lets you have several actorName, I'm not sure whether that works or not... But the… | |||||
Not Done Inline ActionsI could add maxExclusive="2" which does not help against having 2 actorNames but at least there cannot be more. Mate-86: I could add maxExclusive="2" which does not help against having 2 actorNames but at least there… | |||||
"<element name='Actor' a:help='actor of the projectile animation'>" + | |||||
"<text/>" + | |||||
"</element>" + | |||||
"</optional>" + | |||||
"<optional>" + | |||||
"<element name='HitActor' a:help='actor of the projectile hit animation'>" + | |||||
"<text/>" + | |||||
"</element>" + | |||||
"</optional>" + | |||||
"<optional>" + | |||||
"<element name='HitAnimationTime' a:help='length of the projectile hit animation'>" + | |||||
"<ref name='positiveDecimal'/>" + | |||||
"</element>" + | |||||
"</optional>" + | |||||
"</interleave>" + | |||||
"</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>" + | ||||
DamageTypes.BuildSchema("damage strength") + | DamageTypes.BuildSchema("damage strength") + | ||||
Attack.prototype.bonusesSchema + | Attack.prototype.bonusesSchema + | ||||
"</interleave>" + | "</interleave>" + | ||||
▲ Show 20 Lines • Show All 336 Lines • ▼ Show 20 Lines | if (type == "Ranged") | ||||
// Recalculate when the missile will hit the target position. | // Recalculate when the missile will hit the target position. | ||||
let realHorizDistance = realTargetPosition.horizDistanceTo(selfPosition); | let realHorizDistance = realTargetPosition.horizDistanceTo(selfPosition); | ||||
timeToTarget = realHorizDistance / horizSpeed; | timeToTarget = realHorizDistance / horizSpeed; | ||||
let missileDirection = Vector3D.sub(realTargetPosition, selfPosition).div(realHorizDistance); | let missileDirection = Vector3D.sub(realTargetPosition, selfPosition).div(realHorizDistance); | ||||
// Launch the graphical projectile. | // Launch the graphical projectile. | ||||
let cmpProjectileManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_ProjectileManager); | let cmpProjectileManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_ProjectileManager); | ||||
let id = cmpProjectileManager.LaunchProjectileAtPoint(this.entity, realTargetPosition, horizSpeed, gravity); | |||||
let actorName = ""; | |||||
let hitActorName = ""; | |||||
let hitAnimationTime = 0; | |||||
if (this.template.Ranged.Projectile) { | |||||
Done Inline Actions{ on the next line wraitii: { on the next line | |||||
actorName = this.template.Ranged.Projectile.Actor || ""; | |||||
hitActorName = this.template.Ranged.Projectile.HitActor || ""; | |||||
hitAnimationTime = this.template.Ranged.Projectile.HitAnimationTime || 0; | |||||
} | |||||
let id = cmpProjectileManager.LaunchProjectileAtPoint(this.entity, realTargetPosition, horizSpeed, gravity, | |||||
wraitiiUnsubmitted Not Done Inline ActionsThis this would be better one one line imo, screens are wide and there's not a very logical way to split it. wraitii: This this would be better one one line imo, screens are wide and there's not a very logical way… | |||||
Not Done Inline Actions@elexis I think we don't use this but some kind of custom deep copy? wraitii: @elexis I think we don't use this but some kind of custom deep copy? | |||||
actorName, hitActorName, hitAnimationTime); | |||||
Not Done Inline ActionsI think it's great that this magic number is no longer in the C++, but now you could even make it part of the template definition of the projectile. wraitii: I think it's //great// that this magic number is no longer in the C++, but now you could even… | |||||
Not Done Inline ActionsDo you mean adding this offset to the unit templates which means I have to add the projectile property to the templates to all existing ranged units? Mate-86: Do you mean adding this offset to the unit templates which means I have to add the projectile… | |||||
Not Done Inline ActionsAdd it as optional inside your "Projectile" bit. We should then move the gravity and projectile speed bits of Attack.js inside of this, but we'll do that in a separate patch. wraitii: Add it as optional inside your "Projectile" bit.
We should then move the gravity and… | |||||
Not Done Inline ActionsThere is a half ready change about LaunchProjectile attribute where I defined the coordinates as elements but probably would be better as attributes. instead of <LaunchPoint> <X>0</X> <Y>3</Y> <Z>0</Z> </LaunchPoint> use Mate-86: There is a half ready change about `LaunchProjectile` attribute where I defined the coordinates… | |||||
let attackImpactSound = ""; | let attackImpactSound = ""; | ||||
Done Inline Actions{ on the next line wraitii: { on the next line | |||||
let cmpSound = Engine.QueryInterface(this.entity, IID_Sound); | let cmpSound = Engine.QueryInterface(this.entity, IID_Sound); | ||||
Done Inline ActionsThis could use a comment saying we fallback to the old method or something. wraitii: This could use a comment saying we fallback to the old method or something. | |||||
if (cmpSound) | if (cmpSound) | ||||
attackImpactSound = cmpSound.GetSoundGroup("attack_impact_" + type.toLowerCase()); | attackImpactSound = cmpSound.GetSoundGroup("attack_impact_" + type.toLowerCase()); | ||||
let data = { | let data = { | ||||
"type": type, | "type": type, | ||||
"attacker": this.entity, | "attacker": this.entity, | ||||
"target": target, | "target": target, | ||||
"strengths": this.GetAttackStrengths(type), | "strengths": this.GetAttackStrengths(type), | ||||
▲ Show 20 Lines • Show All 103 Lines • Show Last 20 Lines |
I don't think this one should be optional, or alternatively you should make "either or" with the impact actor.