Config/script.js |
this.name = "alien_systems";
this.author = "Redspear";
this.copyright = "2022 Redspear";
this.licence = "CC BY-NC-SA 4.0";
this.description = "System variance by inhabitant type";
this.version = "0.2";
"use strict";
this.shipWillEnterWitchspace = function() {
Sound.stopMusic();
}
this.shipExitedWitchspace = function() {
var birds = /bird/i;
var felines = /feline/i;
var frogs = /frog/i;
var humanoids = /humanoid/i;
var insects = /insect/i;
var lizards = /lizard/i;
var lobsters = /lobster/i;
var rodents = /rodent/i;
var colonials = /colonial/i;
if(system.isInterstellarSpace)
{
Sound.playMusic("Reorte_Theme.ogg");
}
if(system.info.inhabitants.match(birds))
{
Sound.playMusic("Isinor_Theme.ogg");
player.commsMessage("[bird-beacon-messsages]", 6);
}
if(system.info.inhabitants.match(felines))
{
Sound.playMusic("Tianve_Theme.ogg");
player.commsMessage("[feline-beacon-messsages]", 6);
}
if(system.info.inhabitants.match(frogs))
{
Sound.playMusic("Lerelace_Theme.ogg");
player.commsMessage("[frog-beacon-messsages]", 6);
}
if(system.info.inhabitants.match(humanoids))
{
Sound.playMusic("Leesti_Theme.ogg");
player.commsMessage("[humanoid-beacon-messsages]", 6);
}
if(system.info.inhabitants.match(insects))
{
Sound.playMusic("Diso_Theme.ogg");
player.commsMessage("[insect-beacon-messsages]", 6);
}
if(system.info.inhabitants.match(lizards))
{
Sound.playMusic("Tionisle_Theme.ogg");
player.commsMessage("[lizard-beacon-messsages]", 6);
}
if(system.info.inhabitants.match(lobsters))
{
Sound.playMusic("Zaonce_Theme.ogg");
player.commsMessage("[lobster-beacon-messsages]", 6);
}
if(system.info.inhabitants.match(rodents))
{
Sound.playMusic("Teraed_Theme.ogg");
player.commsMessage("[rodent-beacon-messsages]", 6);
}
}
this.shipEnteredPlanetaryVicinity = function(entity) {
if(entity.isSun) {
Sound.playMusic("Lave_Theme.ogg");
}
}
this.shipEnteredStationAegis = function(station) {
if (station.isMainStation) {
Sound.stopMusic();
this.$startTimer();
var birds = /bird/i;
var felines = /feline/i;
var frogs = /frog/i;
var humanoids = /humanoid/i;
var insects = /insect/i;
var lizards = /lizard/i;
var lobsters = /lobster/i;
var rodents = /rodent/i;
var colonials = /colonial/i;
if(system.info.inhabitants.match(birds))
{
Sound.playMusic("Isinor_Theme.ogg");
}
if(system.info.inhabitants.match(felines))
{
Sound.playMusic("Tianve_Theme.ogg");
}
if(system.info.inhabitants.match(frogs))
{
Sound.playMusic("Lave_Theme.ogg");
}
if(system.info.inhabitants.match(humanoids))
{
Sound.playMusic("Leesti_Theme.ogg");
}
if(system.info.inhabitants.match(insects))
{
Sound.playMusic("Diso_Theme.ogg");
}
if(system.info.inhabitants.match(lizards))
{
Sound.playMusic("Tionisle_Theme.ogg");
}
if(system.info.inhabitants.match(lobsters))
{
Sound.playMusic("Zaonce_Theme.ogg");
}
if(system.info.inhabitants.match(rodents))
{
Sound.playMusic("Teread_Theme.ogg");
}
}
}
this.shipLaunchedFromStation = function(station) {
if (station.isMainStation) {
this.$startTimer();
var birds = /bird/i;
var felines = /feline/i;
var frogs = /frog/i;
var humanoids = /humanoid/i;
var insects = /insect/i;
var lizards = /lizard/i;
var lobsters = /lobster/i;
var rodents = /rodent/i;
var colonials = /colonial/i;
if(system.info.inhabitants.match(birds))
{
Sound.playMusic("Isinor_Theme.ogg");
}
if(system.info.inhabitants.match(felines))
{
Sound.playMusic("Tianve_Theme.ogg");
}
if(system.info.inhabitants.match(frogs))
{
Sound.playMusic("Lave_Theme.ogg");
}
if(system.info.inhabitants.match(humanoids))
{
Sound.playMusic("Leesti_Theme.ogg");
}
if(system.info.inhabitants.match(insects))
{
Sound.playMusic("Diso_Theme.ogg");
}
if(system.info.inhabitants.match(lizards))
{
Sound.playMusic("Tionisle_Theme.ogg");
}
if(system.info.inhabitants.match(lobsters))
{
Sound.playMusic("Zaonce_Theme.ogg");
}
if(system.info.inhabitants.match(rodents))
{
Sound.playMusic("Teread_Theme.ogg");
}
}
}
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(); // safety check
this._myTimer = new Timer(this, this.$sendMessageTimer, 60, 120); // first and subsequent
}
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 within scanner range
if (p.alertCondition != 3) { // only send if the player is not at condition red
this.$sendStationMessage();
}
}
}
this.$sendStationMessage = function $sendStationMessage () {
var birds = /bird/i;
var felines = /feline/i;
var frogs = /frog/i;
var humanoids = /humanoid/i;
var insects = /insect/i;
var lizards = /lizard/i;
var lobsters = /lobster/i;
var rodents = /rodent/i;
var colonials = /colonial/i;
if(system.info.inhabitants.match(birds) && system.techLevel < 12)
{
system.mainStation.commsMessage("[bird-messages]", 6);
}
if(system.info.inhabitants.match(felines) && system.techLevel < 12)
{
system.mainStation.commsMessage("[feline-messages]", 6);
}
if(system.info.inhabitants.match(frogs) && system.techLevel < 12)
{
system.mainStation.commsMessage("[frog-messages]", 6);
}
if(system.info.inhabitants.match(humanoids) && system.techLevel < 12)
{
system.mainStation.commsMessage("[humanoid-messages]", 6);
}
if(system.info.inhabitants.match(insects) && system.techLevel < 12)
{
system.mainStation.commsMessage("[insect-messages]", 6);
}
if(system.info.inhabitants.match(lizards) && system.techLevel < 12)
{
system.mainStation.commsMessage("[lizard-messages]", 6);
}
if(system.info.inhabitants.match(lobsters) && system.techLevel < 12)
{
system.mainStation.commsMessage("[lobster-messages]", 6);
}
if(system.info.inhabitants.match(rodents) && system.techLevel < 12)
{
system.mainStation.commsMessage("[rodent-messages]", 6);
}
} |