Cannisters

An area for discussing new ideas and additions to Oolite.

Moderators: winston, another_commander

Post Reply
User avatar
Killer Wolf
---- E L I T E ----
---- E L I T E ----
Posts: 2280
Joined: Tue Jan 02, 2007 12:38 pm

Cannisters

Post by Killer Wolf »

Would like a reworking of their ejection maths, it's ridiculous when some get dumped or you nail a ship after a fight and the cargo goes zipping off at .87LM.
User avatar
tsoj
Deadly
Deadly
Posts: 199
Joined: Wed May 18, 2016 8:19 pm
Location: Berlin
Contact:

Re: Cannisters

Post by tsoj »

The GalCop Missions OXP has an equipment called "Ejection Damper" which stops cargo from moving. You could look at the code and it should probably be possible to adjust it, such that you don't need to buy/activate equipment for this to work, and to maybe just give an upper bound to the velocity of cargo cannisters instead of reducing the velocity to 0.
I think this is the relevant code bit:

Code: Select all

//-------------------------------------------------------------------------------------------------------------
this.shipDumpedCargo = function (cargo) {
    if (this._unitOn === true) {
        player.consoleMessage("Ejection dampening applied.", 2);
        cargo.maxThrust = 1;
        cargo.thrust = 1;
        this._usesLeft -= 1;
        this._cargoList.push(cargo);
        if (this._resetTimer == null || this._resetTimer.isRunning === false) {
            this._resetTimer = new Timer(this, this.$resetCargo, 2, 2);
        }
        if (this._usesLeft <= 0) {
            this._usesLeft = 0;
            this._unitOn = false;
            this.$playSound("off");
            player.ship.removeEquipment("EQ_GCM_EJECTION_DAMPER");
            player.consoleMessage("Ejection damper expended and removed.", 5);
        }
    }
}

//-------------------------------------------------------------------------------------------------------------
this.$resetCargo = function $resetCargo() {
    if (this._cargoList.length === 0) {
        this._resetTimer.stop();
        this._resetTimer = null;
        return;
    }
    for (var i = this._cargoList.length - 1; i >= 0; i--) {
        var cargo = this._cargoList[i];
        if (!cargo.velocity || cargo.velocity.magnitude() === 0) {
            if (cargo.isValid && cargo.isInSpace) {
                cargo.maxThrust = 0;
                cargo.thrust = 0;
            }
            this._cargoList.splice(i, 1);
        }
    }
}
The Oolite core code that calculates the velocity for dumped cargo is probably this, if you want to tinker around with it. (It also handles ejection of escape pods.)
Post Reply