How to check an entity's altitude?

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: another_commander, winston

Posts: 170
Joined: Mon May 25, 2015 5:23 pm
Location: Russia

Re: How to check an entity's altitude?

Post by Rustem »

View this functions from Stealth Raiders OXP(deep_stealth_raiders.js):

Code: Select all

this.$configurationSetDestinationToLeaveSun = function() {...}
this.$configurationSetDestinationToSafeSun = function() {...}
this.$configurationSetDestinationToAwaySun = function() {...}

this.$behaviourFleeHeat = function() {...}
this.$behaviourFleeOverHeat = function() {...}
this.$behaviourFleeHeatInCombat = function() {...}
also in the sunSkimExitAI.plist from oolite folder Resources/AIs

Code: Select all

"LEAVE_SUN" = {...}
Its like templates and examples for development.

Final code for setTargetToCelestialObject and setPerpendicularlyCoordinatesToCelestialObject not developed, because:
- part above examples for priority JS AI. Its should be edited from sun to common celestial object.
- i not know how long and speed need for the escorts flee perpendicularly away from the celestial object?

Oops, the celestial object not can set as ship target. Then need edit first simple version and renamed from setTargetToCelestialObject to fleeFromCelestialObject.

So, based on above examples, may be suggested this ships script function, as example solution.

Code: Select all

this.fleeFromCelestialObject = function() { = null;
	var range = this.ship.scannerRange; // this range is correctly ?
	var body = this.$calcAltitudeForShip();
	this.ship.destination = body;
	this.ship.desiredRange = body.radius + body.altitude + range;
	this.ship.desiredSpeed = this.ship.maxSpeed * 7; // 7 is optimal ?
Part "setStateTo: FLEE" was deleted, because its exist into ship script function.

So, for AI.plist is simple solution:

Code: Select all

FLEEING = ("sendScriptMessage: fleeFromCelestialObject");
@ UK_Eliter: If this code not worked, report me.
---- E L I T E ----
---- E L I T E ----
Posts: 1142
Joined: Sat Sep 12, 2009 11:58 pm
Location: Essex (mainly industrial and occasionally anarchic)

Re: How to check an entity's altitude?

Post by UK_Eliter »

Thanks very much Rustem. I'm seeing what I can get working . .
Post Reply