Config/script.js |
"use strict";
this.name = "Shaky Drive";
this.version = "1.0.0"; // Astrobe. Based on Bullet Drive by Wildblood, May 16th, 2013
/* ====================================================================================
MAINTAIN LOCKED HEADING AT HIGH SPEED
======================================================================================= */
this.$maintainHeading = function()
{
var self = player.ship;
if (self.status !== "STATUS_IN_FLIGHT" && self.status !== "STATUS_WITCHSPACE_COUNTDOWN")
{
removeFrameCallback(this.$monitor);
delete this.$monitor;
delete this.$heading;
return;
}
if (self.speed > 8*self.maxSpeed)
{
// the strength of the "shaking" depends on speed.
// This works by rotating a bit the ship on all of its axis, by a random angle.
// The randomness has two components: one that is picked for every new frame, and one that is picked at launch time.
// This way, the ships has a tendency to "deviate" in a certain way.
var k= (self.speed/(32*self.maxSpeed))/100;
if (this.$heading) self.orientation = self.orientation.rotate(Vector3D.randomDirectionAndLength(0.4).add(this.$heading), k);
else this.$heading = Vector3D.randomDirectionAndLength(0.4);
}
}
/* ====================================================================================
STARTING $maintainHeading
======================================================================================= */
this.shipLaunchedFromStation = function(station)
{
if (!this.$monitor)
{
this.$monitor = addFrameCallback(this.$maintainHeading.bind(this));
}
}
this.shipExitedWitchspace = function()
{
if (player.alertCondition == 1 && !this.$monitor)
{
this.$monitor = addFrameCallback(this.$maintainHeading.bind(this));
}
}
// CHANGELOG
// 1.0.0 2016-10-28 Release
// 0.0.3 2016-08-26 alertConditionChanged does not seem to take place on launching; replaced with willLaunchFromStation.
// 0.0.2 2016-04-12 No shaking at max witchdrive speed, reduced shaking.
// 0.0.1 2016-04-09 Beta version.
|