Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/Attack.js
Show First 20 Lines • Show All 201 Lines • ▼ Show 20 Lines | "<element name='Ranged'>" + | ||||
"</element>" + | "</element>" + | ||||
"</optional>" + | "</optional>" + | ||||
"</interleave>" + | "</interleave>" + | ||||
"</element>" + | "</element>" + | ||||
Attack.prototype.statusEffectsSchema + | Attack.prototype.statusEffectsSchema + | ||||
Attack.prototype.bonusesSchema + | Attack.prototype.bonusesSchema + | ||||
Attack.prototype.preferredClassesSchema + | Attack.prototype.preferredClassesSchema + | ||||
Attack.prototype.restrictedClassesSchema + | Attack.prototype.restrictedClassesSchema + | ||||
"<optional>"+ | |||||
"<element name='TurretsOnly' a:help='When set to \"true\", will only accept attacks coming from turrets.'><text/></element>" + | |||||
"</optional>" + | |||||
"</interleave>" + | "</interleave>" + | ||||
"</element>" + | "</element>" + | ||||
"</optional>" + | "</optional>" + | ||||
"<optional>" + | "<optional>" + | ||||
"<element name='Capture'>" + | "<element name='Capture'>" + | ||||
"<interleave>" + | "<interleave>" + | ||||
"<element name='Value' a:help='Capture points value'><ref name='nonNegativeDecimal'/></element>" + | "<element name='Value' a:help='Capture points value'><ref name='nonNegativeDecimal'/></element>" + | ||||
"<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>" + | ||||
Show All 15 Lines | "<element name='Slaughter' a:help='A special attack to kill domestic animals'>" + | ||||
Attack.prototype.preferredClassesSchema + | Attack.prototype.preferredClassesSchema + | ||||
Attack.prototype.restrictedClassesSchema + | Attack.prototype.restrictedClassesSchema + | ||||
"</interleave>" + | "</interleave>" + | ||||
"</element>" + | "</element>" + | ||||
"</optional>"; | "</optional>"; | ||||
Attack.prototype.Init = function() | Attack.prototype.Init = function() | ||||
{ | { | ||||
}; | }; | ||||
Stan: Should be removed. | |||||
Attack.prototype.Serialize = null; // we have no dynamic state to save | Attack.prototype.Serialize = null; // we have no dynamic state to save | ||||
Attack.prototype.GetAttackTypes = function(wantedTypes) | Attack.prototype.GetAttackTypes = function(wantedTypes) | ||||
{ | { | ||||
let types = g_AttackTypes.filter(type => !!this.template[type]); | let types = g_AttackTypes.filter(type => !!this.template[type]); | ||||
if (!wantedTypes) | if (!wantedTypes) | ||||
return types; | return types; | ||||
▲ Show 20 Lines • Show All 112 Lines • ▼ Show 20 Lines | |||||
Attack.prototype.GetFullAttackRange = function() | Attack.prototype.GetFullAttackRange = function() | ||||
{ | { | ||||
let ret = { "min": Infinity, "max": 0 }; | let ret = { "min": Infinity, "max": 0 }; | ||||
for (let type of this.GetAttackTypes()) | for (let type of this.GetAttackTypes()) | ||||
{ | { | ||||
let range = this.GetRange(type); | let range = this.GetRange(type); | ||||
ret.min = Math.min(ret.min, range.min); | ret.min = Math.min(ret.min, range.min); | ||||
ret.max = Math.max(ret.max, range.max); | ret.max = Math.max(ret.max, range.max); | ||||
} | } | ||||
Not Done Inline Actionssince elevationBonus affects maximum and minimum range and can go negative, I would suggest to get maximal possible value not minimal if there is no specific case why minimum was choosen Silier: since elevationBonus affects maximum and minimum range and can go negative, I would suggest to… | |||||
Not Done Inline ActionsMy reasoning was: If we have an attack which has the largest range but an elevation bonus of 0 and there is another attack which has a smaller max range but an elevation bonus of 5 the full attack range would be not really an attack range, for the unit would not be in range when these values are used. Freagarach: My reasoning was: If we have an attack which has the largest range but an elevation bonus of… | |||||
Not Done Inline Actionsseems unrelated wraitii: seems unrelated | |||||
return ret; | return ret; | ||||
}; | }; | ||||
Attack.prototype.GetBestAttackAgainst = function(target, allowCapture) | Attack.prototype.GetBestAttackAgainst = function(target, allowCapture) | ||||
{ | { | ||||
let cmpFormation = Engine.QueryInterface(target, IID_Formation); | let cmpFormation = Engine.QueryInterface(target, IID_Formation); | ||||
if (cmpFormation) | if (cmpFormation) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 115 Lines • ▼ Show 20 Lines | Attack.prototype.GetBonusTemplate = function(type) | ||||
return template.Bonuses || null; | return template.Bonuses || null; | ||||
}; | }; | ||||
/** | /** | ||||
* Attack the target entity. This should only be called after a successful range check, | * Attack the target entity. This should only be called after a successful range check, | ||||
* and should only be called after GetTimers().repeat msec has passed since the last | * and should only be called after GetTimers().repeat msec has passed since the last | ||||
* call to PerformAttack. | * call to PerformAttack. | ||||
*/ | */ | ||||
Attack.prototype.PerformAttack = function(type, target) | Attack.prototype.PerformAttack = function(type, target, turretId) | ||||
{ | { | ||||
if (this.template[type].TurretsOnly && this.template[type].TurretsOnly == "true" && !turretId) | |||||
return; | |||||
let attackerOwner = Engine.QueryInterface(this.entity, IID_Ownership).GetOwner(); | let attackerOwner = Engine.QueryInterface(this.entity, IID_Ownership).GetOwner(); | ||||
let cmpDamage = Engine.QueryInterface(SYSTEM_ENTITY, IID_Damage); | let cmpDamage = Engine.QueryInterface(SYSTEM_ENTITY, IID_Damage); | ||||
// If this is a ranged attack, then launch a projectile | // If this is a ranged attack, then launch a projectile | ||||
if (type == "Ranged") | if (type == "Ranged") | ||||
{ | { | ||||
let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); | let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); | ||||
let turnLength = cmpTimer.GetLatestTurnLength()/1000; | let turnLength = cmpTimer.GetLatestTurnLength()/1000; | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | if (type == "Ranged") | ||||
actorName = this.template[type].Projectile.ActorName || ""; | actorName = this.template[type].Projectile.ActorName || ""; | ||||
impactActorName = this.template[type].Projectile.ImpactActorName || ""; | impactActorName = this.template[type].Projectile.ImpactActorName || ""; | ||||
impactAnimationLifetime = this.template[type].Projectile.ImpactAnimationLifetime || 0; | impactAnimationLifetime = this.template[type].Projectile.ImpactAnimationLifetime || 0; | ||||
// TODO: Use unit rotation to implement x/z offsets. | // TODO: Use unit rotation to implement x/z offsets. | ||||
let deltaLaunchPoint = new Vector3D(0, this.template[type].Projectile.LaunchPoint["@y"], 0.0); | let deltaLaunchPoint = new Vector3D(0, this.template[type].Projectile.LaunchPoint["@y"], 0.0); | ||||
let launchPoint = Vector3D.add(selfPosition, deltaLaunchPoint); | let launchPoint = Vector3D.add(selfPosition, deltaLaunchPoint); | ||||
let cmpVisual = Engine.QueryInterface(this.entity, IID_Visual); | let cmpVisual = Engine.QueryInterface(turretId ||this.entity, IID_Visual); | ||||
if (cmpVisual) | if (cmpVisual) | ||||
{ | { | ||||
// if the projectile definition is missing from the template | // if the projectile definition is missing from the template | ||||
// then fallback to the projectile name and launchpoint in the visual actor | // then fallback to the projectile name and launchpoint in the visual actor | ||||
if (!actorName) | if (!actorName) | ||||
actorName = cmpVisual.GetProjectileActor(); | actorName = cmpVisual.GetProjectileActor(); | ||||
let visualActorLaunchPoint = cmpVisual.GetProjectileLaunchPoint(); | let visualActorLaunchPoint = cmpVisual.GetProjectileLaunchPoint(); | ||||
▲ Show 20 Lines • Show All 138 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Should be removed.