Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/UnitAI.js
Show First 20 Lines • Show All 1,775 Lines • ▼ Show 20 Lines | "COMBAT": { | ||||
// Show weapons rather than carried resources. | // Show weapons rather than carried resources. | ||||
this.SetAnimationVariant("combat"); | this.SetAnimationVariant("combat"); | ||||
this.SelectAnimation("move"); | this.SelectAnimation("move"); | ||||
this.StartTimer(1000, 1000); | this.StartTimer(1000, 1000); | ||||
}, | }, | ||||
"leave": function() { | "leave": function() { | ||||
// Show carried resources when walking. | // Show carried resources when walking. | ||||
Stan: @wraitii's fix ? :D | |||||
Done Inline Actionsit is related only to code I just added Silier: it is related only to code I just added | |||||
Not Done Inline ActionsOh okay. Stan: Oh okay. | |||||
this.SetDefaultAnimationVariant(); | this.SetDefaultAnimationVariant(); | ||||
this.StopTimer(); | this.StopTimer(); | ||||
}, | }, | ||||
"Timer": function(msg) { | "Timer": function(msg) { | ||||
if (this.ShouldAbandonChase(this.order.data.target, this.order.data.force, IID_Attack, this.order.data.attackType)) | if (this.ShouldAbandonChase(this.order.data.target, this.order.data.force, IID_Attack, this.order.data.attackType)) | ||||
{ | { | ||||
this.StopMoving(); | this.StopMoving(); | ||||
this.FinishOrder(); | this.FinishOrder(); | ||||
// Return to our original position | // Return to our original position | ||||
if (this.GetStance().respondHoldGround) | if (this.GetStance().respondHoldGround) | ||||
this.WalkToHeldPosition(); | this.WalkToHeldPosition(); | ||||
} | } | ||||
else | |||||
{ | |||||
// Check if target does not started to run | |||||
let cmpUnitAI = Engine.QueryInterface(this.order.data.target, IID_UnitAI); | |||||
if (cmpUnitAI && cmpUnitAI.IsFleeing()) | |||||
{ | |||||
Not Done Inline ActionsMaybe: let cmpUnitAI = Engine.QueryInterface(this.order.data.target, IID_UnitAI); if (!cmpUnitAI || !cmpUnitAI.IsFleeing()) return; // Run after the fleeing target this.SetMoveSpeedRatio(this.GetRunMultiplier()); Stan: Maybe:
```lang=js
let cmpUnitAI = Engine.QueryInterface(this.order.data.target, IID_UnitAI)… | |||||
// Run after a fleeing target | |||||
this.SetMoveSpeedRatio(this.GetRunMultiplier()); | |||||
} | |||||
} | |||||
}, | }, | ||||
"MoveCompleted": function() { | "MoveCompleted": function() { | ||||
if (this.CheckTargetAttackRange(this.order.data.target, this.order.data.attackType)) | if (this.CheckTargetAttackRange(this.order.data.target, this.order.data.attackType)) | ||||
{ | { | ||||
// If the unit needs to unpack, do so | // If the unit needs to unpack, do so | ||||
if (this.CanUnpack()) | if (this.CanUnpack()) | ||||
▲ Show 20 Lines • Show All 242 Lines • ▼ Show 20 Lines | "COMBAT": { | ||||
{ | { | ||||
this.StopMoving(); | this.StopMoving(); | ||||
this.FinishOrder(); | this.FinishOrder(); | ||||
// Return to our original position | // Return to our original position | ||||
if (this.GetStance().respondHoldGround) | if (this.GetStance().respondHoldGround) | ||||
this.WalkToHeldPosition(); | this.WalkToHeldPosition(); | ||||
} | } | ||||
else | |||||
{ | |||||
// Check if target does not started to run | |||||
Not Done Inline ActionsSince it's both time the same code, maybe make it a function ? Stan: Since it's both time the same code, maybe make it a function ? | |||||
let cmpUnitAI = Engine.QueryInterface(this.order.data.target, IID_UnitAI); | |||||
if (cmpUnitAI && cmpUnitAI.IsFleeing()) | |||||
{ | |||||
// Run after a fleeing target | |||||
this.SetMoveSpeedRatio(this.GetRunMultiplier()); | |||||
} | |||||
} | |||||
}, | }, | ||||
"MoveCompleted": function() { | "MoveCompleted": function() { | ||||
this.SetNextState("ATTACKING"); | this.SetNextState("ATTACKING"); | ||||
}, | }, | ||||
}, | }, | ||||
}, | }, | ||||
▲ Show 20 Lines • Show All 3,903 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
@wraitii's fix ? :D