Scripts/missile_booster.js |
"use strict";
this.name = "missile_booster";
this.author = "Norby";
this.copyright = "2015 Norby";
this.description= "Give higher initial speed to missiles as a fix of launching problems in some ships like Python.";
this.licence = "CC BY-NC-SA 4.0";
this.shipSpawned = function(ship) {
if( ship && ship.isMissile && ship.owner && ship.owner.isValid && ship.script ) {
// ship.velocity = ship.owner.heading.multiply(5*ship.thrust).add(ship.owner.velocity); - old code
//remove thrust to avoid break at start before the engine ignites
ship.script.$missile_booster_thrust = ship.thrust;
ship.thrust = 0;
//restore thrust after 1s
eval("ship.script.$missile_booster = function() { \
this.ship.thrust = this.$missile_booster_thrust; \
if( this.$missile_booster_timer ) { \
this.$missile_booster_timer.stop(); \
delete this.$missile_booster_timer; \
} \
}");
ship.script.$missile_booster_timer = new Timer(ship.script, ship.script.$missile_booster, 1, 0);
}
} |