Progress
Moderators: winston, another_commander
- JensAyton
- Grand Admiral Emeritus
- Posts: 6657
- Joined: Sat Apr 02, 2005 2:43 pm
- Location: Sweden
- Contact:
It doesn’t seem to have affected the advanced compass, no. I’m not entirely sure why not.
E-mail: [email protected]
- JensAyton
- Grand Admiral Emeritus
- Posts: 6657
- Joined: Sat Apr 02, 2005 2:43 pm
- Location: Sweden
- Contact:
New ship script events for planet and station proximity events:
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.
- 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
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.
E-mail: [email protected]
- JensAyton
- Grand Admiral Emeritus
- Posts: 6657
- Joined: Sat Apr 02, 2005 2:43 pm
- Location: Sweden
- Contact:
Implemented JavaScript Vector functions random() and randomDirection(). Documented existing function interpolate().
E-mail: [email protected]
- JensAyton
- Grand Admiral Emeritus
- Posts: 6657
- Joined: Sat Apr 02, 2005 2:43 pm
- Location: Sweden
- Contact:
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. :-)
E-mail: [email protected]
- JensAyton
- Grand Admiral Emeritus
- Posts: 6657
- Joined: Sat Apr 02, 2005 2:43 pm
- Location: Sweden
- Contact:
JavaScript non-constructor global functions which previously had names starting with capital letters have been renamed to conform with JavaScript norms. These are:
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. :-)
- Log() and LogWithClass() -> log()
- ExpandDescription() -> expandDescription()
- RandomName() -> randomName()
- DisplayNameForCommodity() -> displayNameForCommodity()
- ConsoleMessage() -> consoleMessage() (This one’s added by the debug console script)
Code: Select all
log("Test");
log("script.debug.message", "Test");
E-mail: [email protected]
- JensAyton
- Grand Admiral Emeritus
- Posts: 6657
- Joined: Sat Apr 02, 2005 2:43 pm
- Location: Sweden
- Contact:
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):
Also, I’ve slapped together an OXP which implements some 1.71 scripting features for 1.70: Futurevision.oxp. Specifically, it implements:
Edit 2: added image.
This image illustrates the difference between random() (left) and randomDirectionAndLength() (right):
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 2: added image.
E-mail: [email protected]
- JensAyton
- Grand Admiral Emeritus
- Posts: 6657
- Joined: Sat Apr 02, 2005 2:43 pm
- Location: Sweden
- Contact:
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.
E-mail: [email protected]
- JensAyton
- Grand Admiral Emeritus
- Posts: 6657
- Joined: Sat Apr 02, 2005 2:43 pm
- Location: Sweden
- Contact:
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?
E-mail: [email protected]
-
- Quite Grand Sub-Admiral
- Posts: 6682
- Joined: Wed Feb 28, 2007 7:54 am
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.
- JensAyton
- Grand Admiral Emeritus
- Posts: 6657
- Joined: Sat Apr 02, 2005 2:43 pm
- Location: Sweden
- Contact:
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.
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.
E-mail: [email protected]
- JensAyton
- Grand Admiral Emeritus
- Posts: 6657
- Joined: Sat Apr 02, 2005 2:43 pm
- Location: Sweden
- Contact:
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.
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.
E-mail: [email protected]