| Config/script.js |
"use strict";
this.name = "derelicts_dont_count";
this.author = "Milo";
this.copyright = "2021";
this.description = "Negates +1 Elite score awarded by the core game when player destroys a derelict ship or a dead Tharglet.";
this.version = "1.2";
this.shipKilledOther = function(whom, damageType) {
if (whom.isDerelict || ((whom.hasRole("tharglet") || whom.hasRole("thargon")) && whom.scanClass == "CLASS_CARGO")) player.score--;
}
this.shipSpawned = function(ship) {
if (ship.isPlayer) return;
// safely monkey-patch all the event functions on the ship
// when an event is not pre-existing, apply an empty function to our replacement function
// so we can save time when doing all the calls later
if (ship.script.shipLaunchedEscapePod) {
ship.script._ddc_shipLaunchedEscapePod = ship.script.shipLaunchedEscapePod;
} else {
ship.script._ddc_shipLaunchedEscapePod = function(escapePod, passengers) {};
}
if (ship.script.shipBeingAttacked) {
ship.script._ddc_shipBeingAttacked = ship.script.shipBeingAttacked;
} else {
ship.script._ddc_shipBeingAttacked = function(whom) {};
}
if (ship.script.shipBeingAttackedByCloaked) {
ship.script._ddc_shipBeingAttackedByCloaked = ship.script.shipBeingAttackedByCloaked;
} else {
ship.script._ddc_shipBeingAttackedByCloaked = function() {};
}
if (ship.script.shipAttackedWithMissile) {
ship.script._ddc_shipAttackedWithMissile = ship.script.shipAttackedWithMissile;
} else {
ship.script._ddc_shipAttackedWithMissile = function(missile, whom) {};
}
// award the kill when the player forces the pilot to eject
ship.script.shipLaunchedEscapePod = function(escapePod, passengers) {
this.ship.script._ddc_shipLaunchedEscapePod(escapePod, passengers);
if (this.ship.script._lastAttacker && this.ship.script._lastAttacker.isPlayer) player.score++;
}
// record who was the last entity to attack this ship
ship.script.shipBeingAttacked = function(whom) {
this.ship.script._ddc_shipBeingAttacked(whom);
this.ship.script._lastAttacker = whom;
}
ship.script.shipBeingAttackedByCloaked = function() {
this.ship.script._ddc_shipBeingAttacked();
// because this event doesn't get a "whom" parameter, we need to check who the player is targetting
// if it's this ship, we know our "whom".
if (player.ship.target == this.ship) this.ship.script._lastAttacker = player.ship;
}
ship.script.shipAttackedWithMissile = function(missile, whom) {
this.ship.script._ddc_shipAttackedWithMissile(missile, whom);
this.ship.script._lastAttacker = whom;
}
} |