Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/Attack.js
Show First 20 Lines • Show All 449 Lines • ▼ Show 20 Lines | |||||
Attack.prototype.StartAttacking = function(target, type, callerIID) | Attack.prototype.StartAttacking = function(target, type, callerIID) | ||||
{ | { | ||||
if (this.target) | if (this.target) | ||||
this.StopAttacking(); | this.StopAttacking(); | ||||
if (!this.CanAttack(target)) | if (!this.CanAttack(target)) | ||||
return false; | return false; | ||||
let cmpResistance = Engine.QueryInterface(target, IID_Resistance); | |||||
if (!cmpResistance || !cmpResistance.AddAttacker(this.entity)) | |||||
return false; | |||||
let timings = this.GetTimers(type); | let timings = this.GetTimers(type); | ||||
let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); | let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); | ||||
// If the repeat time since the last attack hasn't elapsed, | // If the repeat time since the last attack hasn't elapsed, | ||||
// delay the action to avoid attacking too fast. | // delay the action to avoid attacking too fast. | ||||
let prepare = timings.prepare; | let prepare = timings.prepare; | ||||
if (this.lastAttacked) | if (this.lastAttacked) | ||||
{ | { | ||||
Show All 25 Lines | |||||
{ | { | ||||
if (!this.target) | if (!this.target) | ||||
return; | return; | ||||
let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); | let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); | ||||
cmpTimer.CancelTimer(this.timer); | cmpTimer.CancelTimer(this.timer); | ||||
delete this.timer; | delete this.timer; | ||||
let cmpResistance = Engine.QueryInterface(this.target, IID_Resistance); | |||||
if (cmpResistance) | |||||
cmpResistance.RemoveAttacker(this.entity) | |||||
Lint: semi: Missing semicolon. | |||||
delete this.target; | delete this.target; | ||||
let cmpVisual = Engine.QueryInterface(this.entity, IID_Visual); | let cmpVisual = Engine.QueryInterface(this.entity, IID_Visual); | ||||
if (cmpVisual) | if (cmpVisual) | ||||
cmpVisual.SelectAnimation("idle", false, 1.0); | cmpVisual.SelectAnimation("idle", false, 1.0); | ||||
// The callerIID component may start again, | // The callerIID component may start again, | ||||
// replacing the callerIID, hence save that. | // replacing the callerIID, hence save that. | ||||
▲ Show 20 Lines • Show All 263 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Missing semicolon.