Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/UnitAI.js
Show First 20 Lines • Show All 5,779 Lines • ▼ Show 20 Lines | UnitAI.prototype.MoveRandomly = function(distance) | ||||
let halfDelta = randFloat(this.roamAngle / 4, this.roamAngle * 3 / 4); | let halfDelta = randFloat(this.roamAngle / 4, this.roamAngle * 3 / 4); | ||||
// First half rotation to decrease the impression of immediate rotation | // First half rotation to decrease the impression of immediate rotation | ||||
ang += halfDelta; | ang += halfDelta; | ||||
cmpUnitMotion.FaceTowardsPoint(pos.x + 0.5 * Math.sin(ang), pos.z + 0.5 * Math.cos(ang)); | cmpUnitMotion.FaceTowardsPoint(pos.x + 0.5 * Math.sin(ang), pos.z + 0.5 * Math.cos(ang)); | ||||
// Then second half of the rotation | // Then second half of the rotation | ||||
ang += halfDelta; | ang += halfDelta; | ||||
let dist = randFloat(0.5, 1.5) * distance; | let dist = randFloat(0.5, 1.5) * distance; | ||||
cmpUnitMotion.MoveToPointRange(pos.x - 0.5 * Math.sin(ang), pos.z - 0.5 * Math.cos(ang), dist, dist); | cmpUnitMotion.MoveToPointRange(pos.x - 0.5 * Math.sin(ang), pos.z - 0.5 * Math.cos(ang), dist, -1); | ||||
}; | }; | ||||
UnitAI.prototype.SetFacePointAfterMove = function(val) | UnitAI.prototype.SetFacePointAfterMove = function(val) | ||||
{ | { | ||||
var cmpMotion = Engine.QueryInterface(this.entity, IID_UnitMotion); | var cmpMotion = Engine.QueryInterface(this.entity, IID_UnitMotion); | ||||
if (cmpMotion) | if (cmpMotion) | ||||
cmpMotion.SetFacePointAfterMove(val); | cmpMotion.SetFacePointAfterMove(val); | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 82 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator