Progress

General discussion for players of Oolite.

Moderators: another_commander, winston

User avatar
Ark
---- E L I T E ----
---- E L I T E ----
Posts: 664
Joined: Sun Dec 09, 2007 8:22 am
Location: Athens Greece

Post by Ark »

I have seen it once but I didn’t paid much attention :oops:
Did that also affected the operation of advanced space compass?

Usually I switched as fast as I can from standard to advanced space compass and I believe most of the players do that. If yes that explains why there were no reports for this.
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

It doesn’t seem to have affected the advanced compass, no. I’m not entirely sure why not.
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

New ship script events for planet and station proximity events:
  • shipApproachingPlanetSurface(planet : Planet): corresponds to AI message APPROACHING_SURFACE
  • shipLeavingPlanetSurface(planet : Planet)): corresponds to AI message LEAVING_SURFACE
  • shipEnteredPlanetaryVicinity(planet : Planet): corresponds to AI message AEGIS_CLOSE_TO_PLANET
  • shipEnteredStationAegis(station : Station): corresponds to AI message AEGIS_IN_DOCKING_RANGE
  • shipExitedStationAegis(): corresponds to AI message AEGIS_LEAVING_DOCKING_RANGE
  • shipExitedPlanetaryVicinity(): corresponds to AI message AEGIS_NONE
It is potentially possible to go from near-station aegis state to deep-space aegis state. In 1.70 and earlier, this would simply lead to an AEGIS_NONE AI message. To avoid scripts having to special-case this eventuality, I’ve changed it so that this state will cause shipExitedStationAegis()/AEGIS_LEAVING_DOCKING_RANGE to be sent first, immediately followed by shipExitedPlanetaryVicinity()/AEGIS_NONE.

In all cases, the script message is sent before the AI message.

Currently, these messages are only sent for the main planet and station. Ideally the surface proximity warnings, at least, would be sent for all planets.
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

Implemented JavaScript Vector functions random() and randomDirection(). Documented existing function interpolate().
User avatar
Griff
Oolite 2 Art Director
Oolite 2 Art Director
Posts: 2475
Joined: Fri Jul 14, 2006 12:29 pm
Location: Probably hugging his Air Fryer

Post by Griff »

is this so we can plot flightpaths for the AI around ships or objects? eg, target a point X units along the z axis from a stations docking port and do a performflytotarget to get there?
edit: i mean the interpolate function and not the random direction
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

It’s just a convenience function for a commonish geometric operation. (It’s exactly the same as linear interpolation of real numbers, αx + (1 - α)y, only in more dimensions.) There’s nothing special about it, I gave two JS implementations right there on the page. :-)
User avatar
Griff
Oolite 2 Art Director
Oolite 2 Art Director
Posts: 2475
Joined: Fri Jul 14, 2006 12:29 pm
Location: Probably hugging his Air Fryer

Post by Griff »

Ahruman, you have to understand, i'm an idiot :)
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

*makes note*
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

JavaScript non-constructor global functions which previously had names starting with capital letters have been renamed to conform with JavaScript norms. These are:
  • Log() and LogWithClass() -> log()
  • ExpandDescription() -> expandDescription()
  • RandomName() -> randomName()
  • DisplayNameForCommodity() -> displayNameForCommodity()
  • ConsoleMessage() -> consoleMessage() (This one’s added by the debug console script)
Log() and LogWithClass() have been merged into a single function, log(). If it is passed a single parameter, it will print that parameter with the log message class “script.debug.message”, like Log(). If it is passed multiple parameters, the first will be treated as a log message class, like LogWithClass(). Thus, the following are equivalent:

Code: Select all

log("Test");
log("script.debug.message", "Test");
Compatibility aliases exist and will be kept until 1.72. The various compatibility aliases (these, and ones that used to be hard-coded) are now implemented in JavaScript, which is kinda cool. :-)
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

On testing Vector.random() and Vector.randomDirection() (and finding that they were quite buggy as implemented), I noticed that the behaviour of random() isn’t always what you want. It distributes points evenly in the unit volume, but sometimes what you want is vectors of random length in a random direction (which causes clustering towards the centre). So I added randomDirectionAndLength().

This image illustrates the difference between random() (left) and randomDirectionAndLength() (right):
Image

Also, I’ve slapped together an OXP which implements some 1.71 scripting features for 1.70: Futurevision.oxp. Specifically, it implements:
  • Lowercase global functions (see previous post).
  • The three random vector functions.
  • Sound and SoundSource – although they’re very quiet in this implementation.
Edit: I also added an optional scale parameter to Vector.randomDirection(), similar to maxLength for the other two.
Edit 2: added image.
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

A few more JS script events:
  • alertConditionChanged(newCondition : Number, oldCondition : Number) is now sent for stations as well as the player. Station conditions range from 1 (green) to 3 (red), no 0 (docked) for stations. The current status is accessible through a new alertCondition property. Oh yeah, those newCondition and oldCondition parameters are new for the player as well.
  • guiScreenChanged(newScreenName : String, oldScreenName : String) for player/world scripts.
  • shipLostTarget(), equivalent to AI TARGET_LOST.
  • shipDestroyedTarget(), similar to AI TARGET_DESTROYED, except that the script event is immediate while the AI message is queued.
  • shipEnergyBecameFull(), equivalent to AI ENERGY_FULL.
  • shipEnergyIsLow(), equivalent to AI ENERGY_LOW (25% warning). Note that this is sent each time a ship is hit and its resultant energy is under 25%, rather than once when transitioning to 25%. It is currently not sent when energy levels are manipulated by a script.
  • shipEnergyBecameFull(), equivalent to AI ENERGY_FULL. This is currently not sent when energy levels are manipulated by a script.
  • shipReachedNavPoint(), equivalent to AI NAVPOINT_REACHED (racing AI).
  • shipReachedEndPoint(), equivalent to AI ENDPOINT_REACHED (racing AI).
  • shipAttackedWithMissile(missile : Ship, sender : Ship), equivalent to AI INCOMING_MISSILE.
  • shipCollided(other : Ship), equivalent to AI COLLISION.
  • offenceCommittedNearby(aggressor : Ship, victim : Ship), equivalent to AI OFFENCE_COMMITTED (sent, when a clean ship is attacked, to the main station if in aegis and any police vessels in scanner range).
  • Close contact handlers: shipCloseContact(other : Ship), shipTraversePositiveX(other : Ship), shipTraverseNegativeX(other : Ship), shipTraversePositiveY(other : Ship), shipTraverseNegativeY(other : Ship), shipTraversePositiveZ(other : Ship), shipTraverseNegativeZ(other : Ship), equivalent to AI CLOSE CONTACT and {POSITIVE|NEGATIVE} {X|Y|Z} TRAVERSE messages. In addition, the collision tracking flag (track_contacts in shipdata.plist) can now be set at runtime with the trackCloseContacts property.
And one more thing… the game no longer checks for internal damage immediately after the player dies, so hopefully no more “You exploded; fuel scoops damaged” messages.
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

I forgot one: shipHitByECM(), equivalent to AI ECM. Currently this is sent multiple times per ECM blast. It would be easy to limit this to once for the script event; thoughts?
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6547
Joined: Wed Feb 28, 2007 7:54 am

Post by another_commander »

How many times per blast are we talking about? I was thinking that a missile could be launched after the ECM blast event has been sent and the missile would not be affected, while the player would think that the ECM is still active, therefore the script would react. If it is not causing delays or something like that, I would prefer having ECM events being broadcasted while the blast lasts.
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

It’s 4 times, at 0.5 second intervals. (ParticleEntity.m:898)

What I’ll do is add a “pulses remaining” parameter. If this is 0, you’re seeing the end of the blast. Unless the ECM is tweaked, shipHitByECM() will be called with values of 3, 2, 1 and 0.

Edit: the point of the four blasts is that each blast has a larger radius than the previous one, so a ship far from the source of the ECM won’t see the earliest ones. This has the effect that ECM takes time to reach distant objects, and is more effective against hardheads at close range.
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

All built-in world scripts and ship actions are now implemented in JavaScript. (Thanks, Eric; I changed them a bit.) Eric’s mission screen function is now available globally as mission.runMissionScreen().

Added new method Ship.explode(). For a change of pace, I’ll let you guess what it does. (Interestingly, it does it to the main station, too – it’s used in the new Nova script.)

I’ve done some other stuff over the last few days too, although as usual not the things I said I’d be doing. Actually done things include hunting for leaks (unsuccessfully) and cleaning up sound handling to be more consistent across platforms while also doing more stuff through customsounds.plist (which I note doesn’t have a wiki page). Also, JS sound stuff now uses customsounds.plist for sounds whose names are enclosed in brackets; for instance, Sound.load("[mycustomsound]") will look up “[mycustomsound]” in customsounds.plist, while Sound.load("mysound.ogg") will treat “mysound.ogg” as a file name.

another_commander and Kaks have been hitting bugs with sticks, too.
Post Reply