Scripts/solo_alt_conditions.js |
"use strict";
this.name = "solos_alt_conditions";
this.author = "Redspear";
this.copyright = "CC-by-nc-sa-3.0";
this.description = "Determines where alt stations will appear";
this.version = "1.2";
"use strict";
this.allowSpawnShip = function(shipKey) {
if (shipKey == "alt-coriolis_station") {
if (system.info.economy =="2" || system.info.economy =="7") {
return true; // Limited to 'poor' economies
} else {
return false; // Otherwise not allowed
}
}
if (shipKey == "alt-dodo_station" || shipKey == "alt-ico_station") {
if (system.info.inhabitants != "Human Colonials") {
return true; // Limited to 'alien' systems
} else {
return false; // Otherwise not allowed
}
}
return true; // Allows other stations to appear
}
this.shipEnteredStationAegis = function(station) {
if (station.isMainStation) {
this.$startTimer();
}
}
this.shipLaunchedFromStation = function(station) {
if (station.isMainStation) {
this.$startTimer();
}
}
this.shipExitedStationAegis = function(station) {
if (station.isMainStation) {
this.$stopTimer();
}
}
this.shipDockedWithStation = function(station) {
if (station.isMainStation) {
this.$stopTimer();
}
}
this.shipDied = function() {
this.$stopTimer();
}
this.$startTimer = function $startTimer () {
this.$stopTimer(); // make sure we stop the timer if it's already running
this._myTimer = new Timer(this, this.$sendMessageTimer, 30, 90); // first timer will fire after 30 sec, but after that will fire every 90 secs
}
this.$stopTimer = function $stopTimer () {
if (this._myTimer && this._myTimer.isRunning) this._myTimer.stop();
}
this.$sendMessageTimer = function $sendMessageTimer () {
var p = player.ship;
var stn = system.mainStation;
var dist = p.position.distanceTo(stn.position);
if (dist < stn.scannerRange) { // only send a message if the player is less than scanner range
if (p.alertCondition != 3) { // only send if the player is not at condition red
this.$sendStationMessage();
}
}
}
this.$sendStationMessage = function $sendStationMessage () {
if(station.shipKey == "alt-dodo_station")
{
system.mainStation.commsMessage("[friendship-messages]");
}
if(station.shipKey == "alt-ico_station")
{
system.mainStation.commsMessage("[wonder-messages]");
}
} |