Page MenuHomeWildfire Games

Allow Flying objects to be stationary
Needs ReviewPublic

Authored by Stan on Dec 6 2019, 3:38 PM.

Details

Reviewers
Angen
Summary

Open questions:

  • Should the template define an oscillation range where the object goes up and down when stationary?
Test Plan
  • Test that if you disable the option the plane continues to turn around
  • Test that if the option is enabled it stops moving as soon as it reaches the target.

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
Vulcan added a comment.Dec 6 2019, 3:39 PM

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/691/display/redirect

Vulcan added a comment.Dec 6 2019, 3:45 PM

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Source...
Executing section JS...
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 106| 106| 				this.pitch = 0;
| 107| 107| 				// We've stopped.
| 108| 108| 				if (cmpGarrisonHolder)
| 109|    |-					cmpGarrisonHolder.AllowGarrisoning(true,"UnitMotionFlying");
|    | 109|+					cmpGarrisonHolder.AllowGarrisoning(true, "UnitMotionFlying");
| 110| 110| 				canTurn = false;
| 111| 111| 				this.hasTarget = false;
| 112| 112| 				this.landing = false;
|    | [NORMAL] ESLintBear (space-unary-ops):
|    | Unexpected space after unary operator '-'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 143| 143| 			var targetHeight = ground;
| 144| 144| 			// Steep, then gradual descent.
| 145| 145| 			if ((pos.y - targetHeight) / this.template.FlyingHeight > 1 / SHORT_FINAL)
| 146|    |-				this.pitch = - Math.PI / 18;
|    | 146|+				this.pitch = -Math.PI / 18;
| 147| 147| 			else
| 148| 148| 				this.pitch = Math.PI / 18;
| 149| 149| 			var descentRate = ((pos.y - targetHeight) / this.template.FlyingHeight * this.template.ClimbRate + SHORT_FINAL) * SHORT_FINAL;
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 171| 171| 		if (this.speed < this.template.TakeoffSpeed && this.onGround)
| 172| 172| 		{
| 173| 173| 			if (cmpGarrisonHolder)
| 174|    |-				cmpGarrisonHolder.AllowGarrisoning(false,"UnitMotionFlying");
|    | 174|+				cmpGarrisonHolder.AllowGarrisoning(false, "UnitMotionFlying");
| 175| 175| 			this.pitch = 0;
| 176| 176| 			// Accelerate forwards
| 177| 177| 			this.speed = Math.min(this.template.MaxSpeed, this.speed + turnLength * this.template.AccelRate);
|    | [NORMAL] ESLintBear (space-unary-ops):
|    | Unexpected space after unary operator '-'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 238| 238| 		if (newangle - angle > Math.PI / 18)
| 239| 239| 			this.roll = Math.PI / 9;
| 240| 240| 		else if (newangle - angle < -Math.PI / 18)
| 241|    |-			this.roll = - Math.PI / 9;
|    | 241|+			this.roll = -Math.PI / 9;
| 242| 242| 		else
| 243| 243| 			this.roll = newangle - angle;
| 244| 244| 	}
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 331| 331| 
| 332| 332| UnitMotionFlying.prototype.StopMoving = function()
| 333| 333| {
| 334|    |-	//Invert
|    | 334|+	// Invert
| 335| 335| 	if (!this.waterDeath)
| 336| 336| 		this.landing = !this.landing;
| 337| 337| 

binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 190| »   »   »   var·targetHeight·=·ground·+·(+this.template.FlyingHeight);
|    | [NORMAL] JSHintBear:
|    | 'targetHeight' is already defined.
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/1207/display/redirect

Angen added inline comments.Dec 9 2019, 9:17 AM
binaries/data/mods/public/simulation/components/UnitMotionFlying.js
14

I would say by the name it is boolean value no range value

167

what if someone wants range 0?

Stan added inline comments.Dec 9 2019, 9:26 AM
binaries/data/mods/public/simulation/components/UnitMotionFlying.js
14

Yeah at first I wanted it to be a lone flag any idea for the name?

167

Well try range 0 it doesn't work...

Angen added inline comments.Dec 9 2019, 9:42 AM
binaries/data/mods/public/simulation/components/UnitMotionFlying.js
14

maybe stationaryRange, stationaryDistance

167

then there should be something like positive decimal in template

Stan updated this revision to Diff 10541.Dec 9 2019, 11:13 AM
Stan marked 4 inline comments as done.
Stan edited the summary of this revision. (Show Details)
Stan edited the test plan for this revision. (Show Details)
  • CanBeStationary → StationaryDistance
  • nonNegativeDecimal → positiveDecimal

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/721/display/redirect

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Source...
Executing section JS...
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 106| 106| 				this.pitch = 0;
| 107| 107| 				// We've stopped.
| 108| 108| 				if (cmpGarrisonHolder)
| 109|    |-					cmpGarrisonHolder.AllowGarrisoning(true,"UnitMotionFlying");
|    | 109|+					cmpGarrisonHolder.AllowGarrisoning(true, "UnitMotionFlying");
| 110| 110| 				canTurn = false;
| 111| 111| 				this.hasTarget = false;
| 112| 112| 				this.landing = false;
|    | [NORMAL] ESLintBear (space-unary-ops):
|    | Unexpected space after unary operator '-'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 143| 143| 			var targetHeight = ground;
| 144| 144| 			// Steep, then gradual descent.
| 145| 145| 			if ((pos.y - targetHeight) / this.template.FlyingHeight > 1 / SHORT_FINAL)
| 146|    |-				this.pitch = - Math.PI / 18;
|    | 146|+				this.pitch = -Math.PI / 18;
| 147| 147| 			else
| 148| 148| 				this.pitch = Math.PI / 18;
| 149| 149| 			var descentRate = ((pos.y - targetHeight) / this.template.FlyingHeight * this.template.ClimbRate + SHORT_FINAL) * SHORT_FINAL;
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 171| 171| 		if (this.speed < this.template.TakeoffSpeed && this.onGround)
| 172| 172| 		{
| 173| 173| 			if (cmpGarrisonHolder)
| 174|    |-				cmpGarrisonHolder.AllowGarrisoning(false,"UnitMotionFlying");
|    | 174|+				cmpGarrisonHolder.AllowGarrisoning(false, "UnitMotionFlying");
| 175| 175| 			this.pitch = 0;
| 176| 176| 			// Accelerate forwards
| 177| 177| 			this.speed = Math.min(this.template.MaxSpeed, this.speed + turnLength * this.template.AccelRate);
|    | [NORMAL] ESLintBear (space-unary-ops):
|    | Unexpected space after unary operator '-'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 238| 238| 		if (newangle - angle > Math.PI / 18)
| 239| 239| 			this.roll = Math.PI / 9;
| 240| 240| 		else if (newangle - angle < -Math.PI / 18)
| 241|    |-			this.roll = - Math.PI / 9;
|    | 241|+			this.roll = -Math.PI / 9;
| 242| 242| 		else
| 243| 243| 			this.roll = newangle - angle;
| 244| 244| 	}
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 336| 336| 
| 337| 337| UnitMotionFlying.prototype.StopMoving = function()
| 338| 338| {
| 339|    |-	//Invert
|    | 339|+	// Invert
| 340| 340| 	if (!this.waterDeath)
| 341| 341| 		this.landing = !this.landing;
| 342| 342| 

binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 190| »   »   »   var·targetHeight·=·ground·+·(+this.template.FlyingHeight);
|    | [NORMAL] JSHintBear:
|    | 'targetHeight' is already defined.
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/1237/display/redirect

Angen added a comment.EditedJan 5 2020, 1:51 PM

Feature itselft works good, cannot tell that about whole unitmotionflying attacking functionality.
Just one thing which i noticed, when it stops to attack, it should reset horizontal rotation to 0, sometimes it stops at strange angle.

Angen requested changes to this revision.Jan 13 2020, 8:21 AM

+ rotation of entity needs to be fixed as pointed above

binaries/data/mods/public/simulation/components/UnitMotionFlying.js
167

could you please compare squared distance as elexis pointed on ircs instead root distance ? thnx

This revision now requires changes to proceed.Jan 13 2020, 8:21 AM
Stan updated this revision to Diff 10997.Jan 13 2020, 10:00 AM

Reset rotation. Use squared distance for comparison instead.

Angen added inline comments.Jan 13 2020, 10:06 AM
binaries/data/mods/public/simulation/components/UnitMotionFlying.js
170

maybe cmpPosition.TurnTo(cmpPosition.GetPosition2D().angleTo(targetPosition));

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/macos-differential/119/display/redirect

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Source...
Executing section JS...
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 106| 106| 				this.pitch = 0;
| 107| 107| 				// We've stopped.
| 108| 108| 				if (cmpGarrisonHolder)
| 109|    |-					cmpGarrisonHolder.AllowGarrisoning(true,"UnitMotionFlying");
|    | 109|+					cmpGarrisonHolder.AllowGarrisoning(true, "UnitMotionFlying");
| 110| 110| 				canTurn = false;
| 111| 111| 				this.hasTarget = false;
| 112| 112| 				this.landing = false;
|    | [NORMAL] ESLintBear (space-unary-ops):
|    | Unexpected space after unary operator '-'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 143| 143| 			var targetHeight = ground;
| 144| 144| 			// Steep, then gradual descent.
| 145| 145| 			if ((pos.y - targetHeight) / this.template.FlyingHeight > 1 / SHORT_FINAL)
| 146|    |-				this.pitch = - Math.PI / 18;
|    | 146|+				this.pitch = -Math.PI / 18;
| 147| 147| 			else
| 148| 148| 				this.pitch = Math.PI / 18;
| 149| 149| 			var descentRate = ((pos.y - targetHeight) / this.template.FlyingHeight * this.template.ClimbRate + SHORT_FINAL) * SHORT_FINAL;
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 175| 175| 		if (this.speed < this.template.TakeoffSpeed && this.onGround)
| 176| 176| 		{
| 177| 177| 			if (cmpGarrisonHolder)
| 178|    |-				cmpGarrisonHolder.AllowGarrisoning(false,"UnitMotionFlying");
|    | 178|+				cmpGarrisonHolder.AllowGarrisoning(false, "UnitMotionFlying");
| 179| 179| 			this.pitch = 0;
| 180| 180| 			// Accelerate forwards
| 181| 181| 			this.speed = Math.min(this.template.MaxSpeed, this.speed + turnLength * this.template.AccelRate);
|    | [NORMAL] ESLintBear (space-unary-ops):
|    | Unexpected space after unary operator '-'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 242| 242| 		if (newangle - angle > Math.PI / 18)
| 243| 243| 			this.roll = Math.PI / 9;
| 244| 244| 		else if (newangle - angle < -Math.PI / 18)
| 245|    |-			this.roll = - Math.PI / 9;
|    | 245|+			this.roll = -Math.PI / 9;
| 246| 246| 		else
| 247| 247| 			this.roll = newangle - angle;
| 248| 248| 	}
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 340| 340| 
| 341| 341| UnitMotionFlying.prototype.StopMoving = function()
| 342| 342| {
| 343|    |-	//Invert
|    | 343|+	// Invert
| 344| 344| 	if (!this.waterDeath)
| 345| 345| 		this.landing = !this.landing;
| 346| 346| 

binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 194| »   »   »   var·targetHeight·=·ground·+·(+this.template.FlyingHeight);
|    | [NORMAL] JSHintBear:
|    | 'targetHeight' is already defined.
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/1541/display/redirect

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/1023/display/redirect

Stan marked 2 inline comments as done.Jan 13 2020, 10:09 AM
Stan added inline comments.
binaries/data/mods/public/simulation/components/UnitMotionFlying.js
170

I don't have access to to targetPos only X, Y.

Angen added inline comments.Jan 16 2020, 1:41 PM
binaries/data/mods/public/simulation/components/UnitMotionFlying.js
138

but would need recompute distance here, but this is only when unit landed currently

219–220

nuke this ? move squared version before if else and use that one here?
As this is going to be computed always when StationaryDistance does not exist, or in case StationaryDistance is defined this will be computing distance second time in case entity does not stop movement in StationaryDistance check.

Stan marked 3 inline comments as done.Jan 16 2020, 2:28 PM
Stan added inline comments.
binaries/data/mods/public/simulation/components/UnitMotionFlying.js
138

What does this refer to?

219–220

euclidDistance2DSquared != euclidDistance2D?
So I either have to sqrt it, or square the rest?

Angen added inline comments.Jan 17 2020, 9:21 AM
binaries/data/mods/public/simulation/components/UnitMotionFlying.js
138

this = if/else branch, so it would be recomputed less frequently as now

219–220

distFromTarget is used in two ifs below, they can be easily changed to use squared version

Stan updated this revision to Diff 11315.Sun, Feb 9, 11:29 PM
Stan marked 4 inline comments as done.

Use square distance instead.

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/1741/display/redirect

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/1222/display/redirect

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/macos-differential/318/display/redirect

Stan updated this revision to Diff 11317.Mon, Feb 10, 8:25 AM

Fix typo.

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Source...
Executing section JS...
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 107| 107| 				this.pitch = 0;
| 108| 108| 				// We've stopped.
| 109| 109| 				if (cmpGarrisonHolder)
| 110|    |-					cmpGarrisonHolder.AllowGarrisoning(true,"UnitMotionFlying");
|    | 110|+					cmpGarrisonHolder.AllowGarrisoning(true, "UnitMotionFlying");
| 111| 111| 				canTurn = false;
| 112| 112| 				this.hasTarget = false;
| 113| 113| 				this.landing = false;
|    | [NORMAL] ESLintBear (space-unary-ops):
|    | Unexpected space after unary operator '-'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 144| 144| 			var targetHeight = ground;
| 145| 145| 			// Steep, then gradual descent.
| 146| 146| 			if ((pos.y - targetHeight) / this.template.FlyingHeight > 1 / SHORT_FINAL)
| 147|    |-				this.pitch = - Math.PI / 18;
|    | 147|+				this.pitch = -Math.PI / 18;
| 148| 148| 			else
| 149| 149| 				this.pitch = Math.PI / 18;
| 150| 150| 			var descentRate = ((pos.y - targetHeight) / this.template.FlyingHeight * this.template.ClimbRate + SHORT_FINAL) * SHORT_FINAL;
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 176| 176| 		if (this.speed < this.template.TakeoffSpeed && this.onGround)
| 177| 177| 		{
| 178| 178| 			if (cmpGarrisonHolder)
| 179|    |-				cmpGarrisonHolder.AllowGarrisoning(false,"UnitMotionFlying");
|    | 179|+				cmpGarrisonHolder.AllowGarrisoning(false, "UnitMotionFlying");
| 180| 180| 			this.pitch = 0;
| 181| 181| 			// Accelerate forwards
| 182| 182| 			this.speed = Math.min(this.template.MaxSpeed, this.speed + turnLength * this.template.AccelRate);
|    | [NORMAL] ESLintBear (space-unary-ops):
|    | Unexpected space after unary operator '-'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 242| 242| 		if (newangle - angle > Math.PI / 18)
| 243| 243| 			this.roll = Math.PI / 9;
| 244| 244| 		else if (newangle - angle < -Math.PI / 18)
| 245|    |-			this.roll = - Math.PI / 9;
|    | 245|+			this.roll = -Math.PI / 9;
| 246| 246| 		else
| 247| 247| 			this.roll = newangle - angle;
| 248| 248| 	}
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 340| 340| 
| 341| 341| UnitMotionFlying.prototype.StopMoving = function()
| 342| 342| {
| 343|    |-	//Invert
|    | 343|+	// Invert
| 344| 344| 	if (!this.waterDeath)
| 345| 345| 		this.landing = !this.landing;
| 346| 346| 

binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 195| »   »   »   var·targetHeight·=·ground·+·(+this.template.FlyingHeight);
|    | [NORMAL] JSHintBear:
|    | 'targetHeight' is already defined.
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/1743/display/redirect

Stan updated this revision to Diff 11350.Thu, Feb 13, 9:51 PM

var → let

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Source...
Executing section JS...
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 107| 107| 				this.pitch = 0;
| 108| 108| 				// We've stopped.
| 109| 109| 				if (cmpGarrisonHolder)
| 110|    |-					cmpGarrisonHolder.AllowGarrisoning(true,"UnitMotionFlying");
|    | 110|+					cmpGarrisonHolder.AllowGarrisoning(true, "UnitMotionFlying");
| 111| 111| 				canTurn = false;
| 112| 112| 				this.hasTarget = false;
| 113| 113| 				this.landing = false;
|    | [NORMAL] ESLintBear (space-unary-ops):
|    | Unexpected space after unary operator '-'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 144| 144| 			var targetHeight = ground;
| 145| 145| 			// Steep, then gradual descent.
| 146| 146| 			if ((pos.y - targetHeight) / this.template.FlyingHeight > 1 / SHORT_FINAL)
| 147|    |-				this.pitch = - Math.PI / 18;
|    | 147|+				this.pitch = -Math.PI / 18;
| 148| 148| 			else
| 149| 149| 				this.pitch = Math.PI / 18;
| 150| 150| 			var descentRate = ((pos.y - targetHeight) / this.template.FlyingHeight * this.template.ClimbRate + SHORT_FINAL) * SHORT_FINAL;
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 176| 176| 		if (this.speed < this.template.TakeoffSpeed && this.onGround)
| 177| 177| 		{
| 178| 178| 			if (cmpGarrisonHolder)
| 179|    |-				cmpGarrisonHolder.AllowGarrisoning(false,"UnitMotionFlying");
|    | 179|+				cmpGarrisonHolder.AllowGarrisoning(false, "UnitMotionFlying");
| 180| 180| 			this.pitch = 0;
| 181| 181| 			// Accelerate forwards
| 182| 182| 			this.speed = Math.min(this.template.MaxSpeed, this.speed + turnLength * this.template.AccelRate);
|    | [NORMAL] ESLintBear (space-unary-ops):
|    | Unexpected space after unary operator '-'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 242| 242| 		if (newangle - angle > Math.PI / 18)
| 243| 243| 			this.roll = Math.PI / 9;
| 244| 244| 		else if (newangle - angle < -Math.PI / 18)
| 245|    |-			this.roll = - Math.PI / 9;
|    | 245|+			this.roll = -Math.PI / 9;
| 246| 246| 		else
| 247| 247| 			this.roll = newangle - angle;
| 248| 248| 	}
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 340| 340| 
| 341| 341| UnitMotionFlying.prototype.StopMoving = function()
| 342| 342| {
| 343|    |-	//Invert
|    | 343|+	// Invert
| 344| 344| 	if (!this.waterDeath)
| 345| 345| 		this.landing = !this.landing;
| 346| 346| 

binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 195| »   »   »   var·targetHeight·=·ground·+·(+this.template.FlyingHeight);
|    | [NORMAL] JSHintBear:
|    | 'targetHeight' is already defined.
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/1758/display/redirect

Stan updated this revision to Diff 11355.Fri, Feb 14, 10:27 PM

Remove template changes.

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Source...
Executing section JS...
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 107| 107| 				this.pitch = 0;
| 108| 108| 				// We've stopped.
| 109| 109| 				if (cmpGarrisonHolder)
| 110|    |-					cmpGarrisonHolder.AllowGarrisoning(true,"UnitMotionFlying");
|    | 110|+					cmpGarrisonHolder.AllowGarrisoning(true, "UnitMotionFlying");
| 111| 111| 				canTurn = false;
| 112| 112| 				this.hasTarget = false;
| 113| 113| 				this.landing = false;
|    | [NORMAL] ESLintBear (space-unary-ops):
|    | Unexpected space after unary operator '-'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 144| 144| 			var targetHeight = ground;
| 145| 145| 			// Steep, then gradual descent.
| 146| 146| 			if ((pos.y - targetHeight) / this.template.FlyingHeight > 1 / SHORT_FINAL)
| 147|    |-				this.pitch = - Math.PI / 18;
|    | 147|+				this.pitch = -Math.PI / 18;
| 148| 148| 			else
| 149| 149| 				this.pitch = Math.PI / 18;
| 150| 150| 			var descentRate = ((pos.y - targetHeight) / this.template.FlyingHeight * this.template.ClimbRate + SHORT_FINAL) * SHORT_FINAL;
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 176| 176| 		if (this.speed < this.template.TakeoffSpeed && this.onGround)
| 177| 177| 		{
| 178| 178| 			if (cmpGarrisonHolder)
| 179|    |-				cmpGarrisonHolder.AllowGarrisoning(false,"UnitMotionFlying");
|    | 179|+				cmpGarrisonHolder.AllowGarrisoning(false, "UnitMotionFlying");
| 180| 180| 			this.pitch = 0;
| 181| 181| 			// Accelerate forwards
| 182| 182| 			this.speed = Math.min(this.template.MaxSpeed, this.speed + turnLength * this.template.AccelRate);
|    | [NORMAL] ESLintBear (space-unary-ops):
|    | Unexpected space after unary operator '-'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 242| 242| 		if (newangle - angle > Math.PI / 18)
| 243| 243| 			this.roll = Math.PI / 9;
| 244| 244| 		else if (newangle - angle < -Math.PI / 18)
| 245|    |-			this.roll = - Math.PI / 9;
|    | 245|+			this.roll = -Math.PI / 9;
| 246| 246| 		else
| 247| 247| 			this.roll = newangle - angle;
| 248| 248| 	}
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 340| 340| 
| 341| 341| UnitMotionFlying.prototype.StopMoving = function()
| 342| 342| {
| 343|    |-	//Invert
|    | 343|+	// Invert
| 344| 344| 	if (!this.waterDeath)
| 345| 345| 		this.landing = !this.landing;
| 346| 346| 

binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 195| »   »   »   var·targetHeight·=·ground·+·(+this.template.FlyingHeight);
|    | [NORMAL] JSHintBear:
|    | 'targetHeight' is already defined.
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/1762/display/redirect

Nescio added a subscriber: Nescio.Sat, Feb 15, 10:23 AM
Nescio added inline comments.
binaries/data/mods/public/simulation/components/UnitMotionFlying.js
14

In English “stationary” has a single n. Also don't forget to end sentences with a full stop.

Nescio removed a subscriber: Nescio.Sat, Feb 15, 10:24 AM
elexis retitled this revision from Allow Flying objects to be stationnary to Allow Flying objects to be stationary.Sat, Feb 15, 10:26 AM
Stan updated this revision to Diff 11357.Sat, Feb 15, 10:31 AM
Stan marked an inline comment as done.
Stan added a subscriber: Nescio.

Fix typo reported by @Nescio.

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Source...
Executing section JS...
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 107| 107| 				this.pitch = 0;
| 108| 108| 				// We've stopped.
| 109| 109| 				if (cmpGarrisonHolder)
| 110|    |-					cmpGarrisonHolder.AllowGarrisoning(true,"UnitMotionFlying");
|    | 110|+					cmpGarrisonHolder.AllowGarrisoning(true, "UnitMotionFlying");
| 111| 111| 				canTurn = false;
| 112| 112| 				this.hasTarget = false;
| 113| 113| 				this.landing = false;
|    | [NORMAL] ESLintBear (space-unary-ops):
|    | Unexpected space after unary operator '-'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 144| 144| 			var targetHeight = ground;
| 145| 145| 			// Steep, then gradual descent.
| 146| 146| 			if ((pos.y - targetHeight) / this.template.FlyingHeight > 1 / SHORT_FINAL)
| 147|    |-				this.pitch = - Math.PI / 18;
|    | 147|+				this.pitch = -Math.PI / 18;
| 148| 148| 			else
| 149| 149| 				this.pitch = Math.PI / 18;
| 150| 150| 			var descentRate = ((pos.y - targetHeight) / this.template.FlyingHeight * this.template.ClimbRate + SHORT_FINAL) * SHORT_FINAL;
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 176| 176| 		if (this.speed < this.template.TakeoffSpeed && this.onGround)
| 177| 177| 		{
| 178| 178| 			if (cmpGarrisonHolder)
| 179|    |-				cmpGarrisonHolder.AllowGarrisoning(false,"UnitMotionFlying");
|    | 179|+				cmpGarrisonHolder.AllowGarrisoning(false, "UnitMotionFlying");
| 180| 180| 			this.pitch = 0;
| 181| 181| 			// Accelerate forwards
| 182| 182| 			this.speed = Math.min(this.template.MaxSpeed, this.speed + turnLength * this.template.AccelRate);
|    | [NORMAL] ESLintBear (space-unary-ops):
|    | Unexpected space after unary operator '-'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 242| 242| 		if (newangle - angle > Math.PI / 18)
| 243| 243| 			this.roll = Math.PI / 9;
| 244| 244| 		else if (newangle - angle < -Math.PI / 18)
| 245|    |-			this.roll = - Math.PI / 9;
|    | 245|+			this.roll = -Math.PI / 9;
| 246| 246| 		else
| 247| 247| 			this.roll = newangle - angle;
| 248| 248| 	}
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 340| 340| 
| 341| 341| UnitMotionFlying.prototype.StopMoving = function()
| 342| 342| {
| 343|    |-	//Invert
|    | 343|+	// Invert
| 344| 344| 	if (!this.waterDeath)
| 345| 345| 		this.landing = !this.landing;
| 346| 346| 

binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 195| »   »   »   var·targetHeight·=·ground·+·(+this.template.FlyingHeight);
|    | [NORMAL] JSHintBear:
|    | 'targetHeight' is already defined.
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/1764/display/redirect

Nescio removed a subscriber: Nescio.Sat, Feb 15, 10:52 AM
Angen added inline comments.Wed, Feb 19, 6:18 PM
binaries/data/mods/public/simulation/components/UnitMotionFlying.js
127–128

recompute distanceToTargetSquared here

135–136

recompute distanceToTargetSquared here

137

recompute distanceToTargetSquared here

Angen added inline comments.Wed, Feb 19, 6:19 PM
binaries/data/mods/public/simulation/components/UnitMotionFlying.js
137

(ignore pls this one, i forgot to delete)

Angen requested changes to this revision.Wed, Feb 19, 8:28 PM
This revision now requires changes to proceed.Wed, Feb 19, 8:28 PM
Stan updated this revision to Diff 11396.Wed, Feb 19, 8:48 PM
Stan marked 3 inline comments as done.

Recompute distance when changing directions.

Stan marked an inline comment as done.Wed, Feb 19, 8:49 PM

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Source...
Executing section JS...
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 107| 107| 				this.pitch = 0;
| 108| 108| 				// We've stopped.
| 109| 109| 				if (cmpGarrisonHolder)
| 110|    |-					cmpGarrisonHolder.AllowGarrisoning(true,"UnitMotionFlying");
|    | 110|+					cmpGarrisonHolder.AllowGarrisoning(true, "UnitMotionFlying");
| 111| 111| 				canTurn = false;
| 112| 112| 				this.hasTarget = false;
| 113| 113| 				this.landing = false;
|    | [NORMAL] ESLintBear (space-unary-ops):
|    | Unexpected space after unary operator '-'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 146| 146| 			var targetHeight = ground;
| 147| 147| 			// Steep, then gradual descent.
| 148| 148| 			if ((pos.y - targetHeight) / this.template.FlyingHeight > 1 / SHORT_FINAL)
| 149|    |-				this.pitch = - Math.PI / 18;
|    | 149|+				this.pitch = -Math.PI / 18;
| 150| 150| 			else
| 151| 151| 				this.pitch = Math.PI / 18;
| 152| 152| 			var descentRate = ((pos.y - targetHeight) / this.template.FlyingHeight * this.template.ClimbRate + SHORT_FINAL) * SHORT_FINAL;
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 178| 178| 		if (this.speed < this.template.TakeoffSpeed && this.onGround)
| 179| 179| 		{
| 180| 180| 			if (cmpGarrisonHolder)
| 181|    |-				cmpGarrisonHolder.AllowGarrisoning(false,"UnitMotionFlying");
|    | 181|+				cmpGarrisonHolder.AllowGarrisoning(false, "UnitMotionFlying");
| 182| 182| 			this.pitch = 0;
| 183| 183| 			// Accelerate forwards
| 184| 184| 			this.speed = Math.min(this.template.MaxSpeed, this.speed + turnLength * this.template.AccelRate);
|    | [NORMAL] ESLintBear (space-unary-ops):
|    | Unexpected space after unary operator '-'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 244| 244| 		if (newangle - angle > Math.PI / 18)
| 245| 245| 			this.roll = Math.PI / 9;
| 246| 246| 		else if (newangle - angle < -Math.PI / 18)
| 247|    |-			this.roll = - Math.PI / 9;
|    | 247|+			this.roll = -Math.PI / 9;
| 248| 248| 		else
| 249| 249| 			this.roll = newangle - angle;
| 250| 250| 	}
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 342| 342| 
| 343| 343| UnitMotionFlying.prototype.StopMoving = function()
| 344| 344| {
| 345|    |-	//Invert
|    | 345|+	// Invert
| 346| 346| 	if (!this.waterDeath)
| 347| 347| 		this.landing = !this.landing;
| 348| 348| 

binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 197| »   »   »   var·targetHeight·=·ground·+·(+this.template.FlyingHeight);
|    | [NORMAL] JSHintBear:
|    | 'targetHeight' is already defined.
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/1792/display/redirect

Angen requested changes to this revision.Thu, Feb 20, 7:49 PM
Angen added inline comments.
binaries/data/mods/public/simulation/components/UnitMotionFlying.js
171

this return is wrong, if already reached new target because in range of stationary distance, event is never sent

This revision now requires changes to proceed.Thu, Feb 20, 7:49 PM

you can move this.reachedtarget section to function and pass it computed distance

binaries/data/mods/public/simulation/components/UnitMotionFlying.js
169

btw, you need to reset this.pitch and this.roll

Stan added inline comments.Thu, Feb 20, 11:13 PM
binaries/data/mods/public/simulation/components/UnitMotionFlying.js
171

So... should I send event before returning?

Stan updated this revision to Diff 11437.Wed, Feb 26, 8:52 PM
Stan marked 2 inline comments as done.

Reset roll and pitch, send message.

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/1821/display/redirect