Path |
Config/script.js |
/*
interstellar_help.js
Adds a ship that asks for your help in interstellar space.
Oolite
Copyright © 2004-2011 Giles C Williams and contributors
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
interstellar_help.oxp
Copyright © 2008-2011 "Commander McLane"
This work is licensed under the Creative Commons
Attribution-Noncommercial-Share Alike 3.0 Unported License.
To view a copy of this license, visit
http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter
to Creative Commons, 171 Second Street, Suite 300, San Francisco,
California, 94105, USA.
*/
"use strict";
this.name = "interstellar_help";
this.author = "Commander McLane";
this.copyright = "© 2011 Commander McLane";
this.license = "CC-by-nc-sa 3.0";
this.shipWillEnterWitchspace = function(cause)
{
if(system.isInterstellarSpace && this.interstellarHelp)
{
this.fuelUsed = system.info.distanceToSystem(System.infoForSystem(galaxyNumber, player.ship.targetSystem));
missionVariables.interstellar_help_pay = (Math.round(this.fuelUsed * 2) * 10) + 50;
}
// next line is part of the substitution for playerJumpFailed
if(system.isInterstellarSpace && this.playerCanJumpTimer.isRunning)
this.playerCanJumpTimer.stop();
}
this.shipWillExitWitchspace = function()
{
if(system.isInterstellarSpace && !this.interstellarHelp && Math.random() < 0.3) system.addShips("interstellar_help_trader", 1, [0, 0, 0], 15000);
}
this.playerJumpFailed = function(reason)
{
if(system.isInterstellarSpace && reason == "insufficient fuel" && Math.random > 0.75 && system.countShipsWithRole("interstellar_helper") == 0)
{
system.addShips("interstellar_helper", 1, player.ship.position.add(Vector3D.randomDirection(27000)));
}
}
/* the code below here is only a substitute as long as 'playerJumpFailed' doesn't work */
this.shipExitedWitchspace = function()
{
if(system.isInterstellarSpace)
{
if(!this.playerCanJumpTimer) this.playerCanJumpTimer = new Timer(this, this.$checkPlayerFuel, 45, 45);
else this.playerCanJumpTimer.start();
}
}
this.$checkPlayerFuel = function()
{
if(player.ship.fuel < 1 && system.countShipsWithRole("interstellar_helper") == 0)
system.addShips("interstellar_helper", 1, player.ship.position.add(Vector3D.randomDirection(27000)));
}
|
Scripts/interstellar-electronic-thumb.js |
/*
interstellar-electronic-thumb.js
Enables the player to call for help if left without fuel in interstellar space.
Oolite
Copyright © 2004-2011 Giles C Williams and contributors
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
interstellar_help.oxp
Copyright © 2008-2011 "Commander McLane"
This work is licensed under the Creative Commons
Attribution-Noncommercial-Share Alike 3.0 Unported License.
To view a copy of this license, visit
http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter
to Creative Commons, 171 Second Street, Suite 300, San Francisco,
California, 94105, USA.
*/
"use strict";
this.name = "interstellar-electronic-thumb";
this.author = "Commander McLane";
this.copyright = "© 2011 Commander McLane";
this.license = "CC-by-nc-sa 3.0";
this.activated = function()
{
if(!system.isInterstellarSpace)
{
player.consoleMessage("Please don't press this button again.");
player.consoleMessage("The Electronic Thumb doesn't work inside a system.");
return;
}
if(player.ship.isCloaked)
{
player.consoleMessage("Electronic Thumb off-line.");
player.consoleMessage("Reason: Ship is cloaked. Please decloak first.");
}
else
{
player.consoleMessage("Electronic Thumb activated.");
player.consoleMessage("Let's see if you could flag down a ship to your rescue.");
if(system.countShipsWithPrimaryRole("interstellar_helper") == 0)
system.addShips("interstellar_helper", 1, player.ship.position.add(Vector3D.randomDirection(27000)));
}
}
|
Scripts/interstellar-help-ship.js |
/*
interstellar-help-ship.js
Script for the ship that asks for your help in interstellar space.
Oolite
Copyright © 2004-2011 Giles C Williams and contributors
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
interstellar_help.oxp
Copyright © 2008-2011 "Commander McLane"
This work is licensed under the Creative Commons
Attribution-Noncommercial-Share Alike 3.0 Unported License.
To view a copy of this license, visit
http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter
to Creative Commons, 171 Second Street, Suite 300, San Francisco,
California, 94105, USA.
*/
"use strict";
this.name = "interstellar-help-ship";
this.author = "Commander McLane";
this.copyright = "© 2011 Commander McLane";
this.license = "CC-by-nc-sa 3.0";
this.shipSpawned = function()
{
if(system.isInterstellarSpace)
{
this.ship.AIState = "WAIT_A_LITTLE";
}
else
{
this.ship.primaryRole = "trader";
this.ship.switchAI("route1traderAI.plist");
}
}
this.shipExitedWormhole = function()
{
if(system.isInterstellarSpace)
{
delete worldScripts.interstellar_help.interstellarHelp;
delete worldScripts.interstellar_help.fuelUsed;
delete missionVariables.interstellar_help_pay;
this.ship.AIState = "COMPLAIN";
return;
}
else
{
this.ship.primaryRole = "trader";
this.ship.AIState = "DESTINATION_REACHED";
return;
}
}
this.$waitForPlayer = function()
{
if (!player.ship || !player.ship.isValid) return;
if(this.ship.position.distanceTo(player.ship.position) < 1000 && !player.ship.isCloaked)
{
this.ship.target = player.ship;
this.ship.reactToAIMessage("TARGET_FOUND");
}
}
this.$checkJumpCapability = function()
{
if(this.ship.hasHyperspaceMotor)
this.ship.reactToAIMessage("BUYING");
else
this.ship.reactToAIMessage("ROLL_1");
}
this.$checkDistanceToPlayer = function()
{
if(this.ship.position.distanceTo(player.ship) < 250 && player.ship.heading.angleTo(this.ship.position.subtract(player.ship.position).direction()) < 0.15)
{
this.ship.AIState = "REFUELING";
this.fuelTransferred = 0;
this.payment = 0;
if(!this.refuelTimer)
this.refuelTimer = new Timer(this, this.$refuelFromPlayerShip, 1, 1);
else
this.refuelTimer.start();
}
}
this.$refuelFromPlayerShip = function()
{
if(player.ship.heading.angleTo(this.ship.position.subtract(player.ship.position).direction()) < 0.15)
{
player.ship.fuel -= 0.2;
this.ship.fuel += 0.2;
player.credits += 4;
this.fuelTransferred += 0.2;
this.payment += 4;
player.consoleMessage("Fuel transferred: " + Math.round(this.fuelTransferred * 10) / 10 + " LY. Payment: " + this.payment + expandDescription("[interstellar_help_cr]"), 1);
if(player.ship.fuel < 0.2)
{
this.refuelTimer.stop();
this.ship.reactToAIMessage("NO_MORE_FUEL");
}
if(this.ship.fuel >= 7)
{
this.refuelTimer.stop();
this.ship.reactToAIMessage("FULL");
}
}
else
{
this.refuelTimer.stop();
this.ship.reactToAIMessage("TRANSACTION_COMPLETE");
}
}
this.$startWormholing = function()
{
worldScripts.interstellar_help.interstellarHelp = "FOLLOWING";
}
this.$payReward = function()
{
player.credits += missionVariables.interstellar_help_pay;
delete worldScripts.interstellar_help.interstellarHelp;
delete worldScripts.interstellar_help.fuelUsed;
delete missionVariables.interstellar_help_pay;
this.ship.primaryRole = "trader";
}
this.shipTargetCloaked = function()
{
if(!this.ship.target.isPlayer) return;
var currentAIState = this.ship.AIState;
switch(currentAIState)
{
case "BUYING":
this.ship.commsMessage("Hey, friend, why have you disappeared?");
this.ship.target = null;
this.ship.AIState = "WAIT_A_LITTLE";
break;
case "WAIT_FOR_APPROACH":
this.ship.commsMessage("Hey, friend, why have you disappeared?");
this.ship.target = null;
this.ship.AIState = "WAIT_A_LITTLE";
break;
case "REFUELING":
this.refuelTimer.stop();
this.ship.commsMessage("Hey, friend, why have you disappeared? We weren't finished yet.");
this.ship.target = null;
this.ship.AIState = "PREPARE_JUMP";
}
}
this.shipDied = function()
{
if(worldScripts.interstellar_help.interstellarHelp)
{
delete worldScripts.interstellar_help.interstellarHelp;
delete missionVariables.interstellar_help_pay;
}
}
|
Scripts/interstellar-helper.js |
/*
interstellar-helper.js
Script for the ship that asks for your help in interstellar space.
Oolite
Copyright © 2004-2011 Giles C Williams and contributors
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
interstellar_help.oxp
Copyright © 2008-2011 "Commander McLane"
This work is licensed under the Creative Commons
Attribution-Noncommercial-Share Alike 3.0 Unported License.
To view a copy of this license, visit
http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter
to Creative Commons, 171 Second Street, Suite 300, San Francisco,
California, 94105, USA.
*/
"use strict";
this.name = "interstellar-helper";
this.author = "Commander McLane";
this.copyright = "© 2011 Commander McLane";
this.license = "CC-by-nc-sa 3.0";
this.$playerInScannerRange = function () {
if (this.ship.position.distanceTo(player.ship) < 24000) {
this.ship.reactToAIMessage("APPROACHING_PLAYER");
}
}
this.$checkPlayerApproached = function () {
if (this.ship.position.distanceTo(player.ship) < 7000) {
this.ship.reactToAIMessage("PLAYER_APPROACHED");
}
}
this.$checkForFuelScoops = function () {
if (player.ship.equipmentStatus("EQ_FUEL_SCOOPS") != "EQUIPMENT_OK") {
this.ship.AIState = "WORMHOLE";
}
}
this.$startWaiting = function () {
this.waitTimer = new Timer(this, this.$stopWaiting, 30);
}
this.$stopWaiting = function () {
this.ship.commsMessage("Sorry commander, I ain't got time forever. Have to continue my journey. So long!");
this.ship.AIState = "GOOD_BYE";
this.ship.primaryRole = "trader";
delete this.waitTimer;
}
this.$checkDistanceToPlayer = function () {
if (this.ship.position.distanceTo(player.ship) < 250 && player.ship.heading.angleTo(this.ship.position.subtract(player.ship.position).direction()) < 0.15) {
this.waitTimer.stop();
delete this.waitTimer;
this.ship.AIState = "REFUELING";
this.fuelTransferred = 0;
this.payment = 0;
if (!this.refuelTimer)
this.refuelTimer = new Timer(this, this.$refuelPlayerShip, 1, 1);
else
this.refuelTimer.start();
}
}
this.$refuelPlayerShip = function () {
if (player.ship.heading.angleTo(this.ship.position.subtract(player.ship.position).direction()) < 0.15) {
player.ship.fuel += 0.2;
this.ship.fuel -= 0.2;
player.credits -= 4;
this.fuelTransferred += 0.2;
this.payment += 4;
player.consoleMessage("Fuel transferred: " + Math.round(this.fuelTransferred * 10) / 10 + " LY. Price: " + this.payment + expandDescription("[interstellar_help_cr]"), 1);
if (this.ship.fuel < 3.4) {
this.refuelTimer.stop();
this.ship.reactToAIMessage("NO_MORE_FUEL");
this.ship.primaryRole = "trader";
}
if (player.ship.fuel >= 7) {
this.refuelTimer.stop();
this.ship.reactToAIMessage("FULL");
this.ship.primaryRole = "trader";
}
if (player.credits < 4) {
this.refuelTimer.stop();
this.ship.reactToAIMessage("NO_MORE_MONEY");
this.ship.primaryRole = "trader";
}
} else {
this.refuelTimer.stop();
this.ship.reactToAIMessage("TRANSACTION_COMPLETE");
this.ship.primaryRole = "trader";
}
}
this.shipSpawned = this.$setTargetToPlayer = function () {
this.ship.target = player.ship;
}
this.shipDied = function () {
this.ship.fuel = 0;
} |