All scripts now JavaScript -- adopted somewhat twiddled versions of Eric's scripts, with the cleanup stuff removed (premature optimization is the root of all evil; I'll put it back in if anyone has profiling information indicating it's actually a win). Moved the mission screen function into global-prefix as a generally-available utility function. Wrote JS scripts for the two remaining ships using death_actions. Added Ship.explode(), which kills any ShipEntity through energy damage including the main station. Once again made blowing up the main station with blowUpMainStation (or explode()) work.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1473 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
parent
016ce3e69e
commit
197119ccc8
62
Resources/AIs/oolite-constrictor-AI.plist
Normal file
62
Resources/AIs/oolite-constrictor-AI.plist
Normal file
@ -0,0 +1,62 @@
|
||||
{
|
||||
GLOBAL =
|
||||
{
|
||||
ENTER = ("setStateTo: TRAVEL_TO_LURK_AREA");
|
||||
EXIT = ();
|
||||
UPDATE = ();
|
||||
};
|
||||
"ATTACK_SHIP" =
|
||||
{
|
||||
ATTACKED = (setTargetToPrimaryAggressor, "setStateTo: ATTACK_SHIP");
|
||||
"ENERGY_LOW" = ("setStateTo: FLEE");
|
||||
ENTER = (performAttack);
|
||||
EXIT = ();
|
||||
"INCOMING_MISSILE" = (fightOrFleeMissile, "setStateTo: FLEE");
|
||||
"TARGET_DESTROYED" = ("setStateTo: LURK");
|
||||
"TARGET_LOST" = ("setStateTo: LURK");
|
||||
"ENTER WORMHOLE" = ("setStateTo: ENTER_WORMHOLE");
|
||||
UPDATE = ("sendScriptMessage: checkDistance", "pauseAI: 5.0");
|
||||
};
|
||||
FLEE =
|
||||
{
|
||||
ENTER = ("setDesiredRangeTo: 25600", performFlee);
|
||||
"ENERGY_FULL" = (performIdle, "setStateTo: LURK");
|
||||
"TARGET_LOST" = (performIdle, "setStateTo: LURK");
|
||||
"DESIRED_RANGE_ACHIEVED" = (performIdle, "setStateTo: LURK");
|
||||
"INCOMING_MISSILE" = (fightOrFleeMissile, "setStateTo: FLEE");
|
||||
"REACHED_SAFETY" = ("setSpeedTo: 0.0", performIdle, "pauseAI: 10.0");
|
||||
ATTACKED = (setTargetToPrimaryAggressor, "setStateTo: FLEE");
|
||||
UPDATE = ("sendScriptMessage: checkDistance", "pauseAI: 5.0");
|
||||
EXIT = ();
|
||||
};
|
||||
"TRAVEL_TO_LURK_AREA" =
|
||||
{
|
||||
ATTACKED = (setTargetToPrimaryAggressor, "setStateTo: ATTACK_SHIP");
|
||||
"DESIRED_RANGE_ACHIEVED" = ("setStateTo: LURK");
|
||||
ENTER = (setDestinationToCurrentLocation, "setDesiredRangeTo: 1500.0", performFlyToRangeFromDestination);
|
||||
EXIT = ();
|
||||
"GROUP_ATTACK_TARGET" = (setTargetToFoundTarget, "setStateTo: ATTACK_SHIP");
|
||||
"INCOMING_MISSILE" = (fightOrFleeMissile, "setStateTo: FLEE");
|
||||
"EXITED WITCHSPACE" = ("setStateTo: LURK");
|
||||
UPDATE = ("sendScriptMessage: checkDistance", "pauseAI: 1.0");
|
||||
};
|
||||
LURK =
|
||||
{
|
||||
ENTER = ("setSpeedTo: 0.0", performIdle);
|
||||
ATTACKED = (setTargetToPrimaryAggressor, "setStateTo: ATTACK_SHIP");
|
||||
EXIT = ();
|
||||
"INCOMING_MISSILE" = (fightOrFleeMissile, "setStateTo: FLEE");
|
||||
"TARGET_FOUND" = (setTargetToFoundTarget, checkGroupOddsVersusTarget);
|
||||
"ODDS_GOOD" = (groupAttackTarget);
|
||||
"ODDS_LEVEL" = (groupAttackTarget);
|
||||
"GROUP_ATTACK_TARGET" = (setTargetToFoundTarget, "setStateTo: ATTACK_SHIP");
|
||||
UPDATE = ("sendScriptMessage: checkDistance", "scanForNearestShipWithPrimaryRole: player", "pauseAI: 5.0");
|
||||
};
|
||||
"ENTER_WORMHOLE" =
|
||||
{
|
||||
ENTER = (setDestinationToTarget, "setDesiredRangeTo: 1.0", "setSpeedFactorTo: 1.0", performFlyToRangeFromDestination);
|
||||
"PLAYER WITCHSPACE" = (enterTargetWormhole);
|
||||
UPDATE = ();
|
||||
EXIT = ();
|
||||
};
|
||||
}
|
@ -24,8 +24,21 @@
|
||||
</array>
|
||||
<key>do</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>conditions</key>
|
||||
<array>
|
||||
<string>gui_screen_string notequal GUI_SCREEN_MISSION</string>
|
||||
</array>
|
||||
<key>do</key>
|
||||
<array>
|
||||
<string>setMissionMusic: none</string>
|
||||
<string>setMissionImage: none</string>
|
||||
<string>showShipModel: none</string>
|
||||
<string>setGuiToMissionScreen</string>
|
||||
</array>
|
||||
</dict>
|
||||
<string>awardCredits: 1000</string>
|
||||
<string>addMissionText: conhunt-thief-captured</string><!-- missiontext key -->
|
||||
<string>addMissionText: conhunt-thief-captured</string>
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
|
@ -962,10 +962,10 @@
|
||||
"human-colonial-description-plural" = "Human Colonials";
|
||||
"clock-format" = "%07d:%02d:%02d:%02d";
|
||||
"clock-format-adjusting" = "%07d:%02d:%02d:%02d (adjusting)";
|
||||
"danger-fuel-leak" = "Danger! Fuel leak!";
|
||||
"legal-desc-alien" = "Alien";
|
||||
"danger-fuel-leak" = "Danger! Fuel leak!";
|
||||
"legal-desc-alien" = "Alien";
|
||||
"legal-desc-system-vessel" = "System Vessel";
|
||||
"legal-desc-military-vessel" = "Military Vessel";
|
||||
"legal-desc-military-vessel" = "Military Vessel";
|
||||
"planetname-derivative-suffix" = "ian"; // This is the suffix used with %I (producing 'Laveian' for example)
|
||||
|
||||
|
||||
@ -1014,5 +1014,8 @@
|
||||
|
||||
//autosave filename
|
||||
"autosave-commander-name" = "autosave";
|
||||
|
||||
|
||||
// Nova mission strings
|
||||
"oolite-nova-coward" = "Coward! You chose not to help the refugees!";
|
||||
"oolite-nova-refugees" = "A hold full of %I refugees.";
|
||||
}
|
||||
|
@ -312,7 +312,6 @@
|
||||
ai_type = "pirateAI.plist";
|
||||
bounty = 150;
|
||||
cargo_type = "CARGO_NOT_CARGO";
|
||||
death_actions = ("spawn: cloaking-device 1", "set: mission_cloak COMPLETE");
|
||||
energy_recharge_rate = 4;
|
||||
exhaust = ("0.0 0.0 -35.0 8.0 6.0 8.0");
|
||||
forward_weapon_type = "WEAPON_BEAM_LASER";
|
||||
@ -328,6 +327,7 @@
|
||||
model = "asp_redux.dat";
|
||||
name = "Asp Mark II";
|
||||
roles = "asp-cloaked oolite-asp-cloaked";
|
||||
script = "oolite-cloaking-device-target-ship.js";
|
||||
thrust = 50;
|
||||
weapon_position_aft = "0.0 -5.0 -35.0";
|
||||
weapon_position_forward = "0.0 0.0 22.5";
|
||||
@ -431,7 +431,7 @@
|
||||
energy_recharge_rate = 0;
|
||||
forward_weapon_type = "WEAPON_NONE";
|
||||
has_ecm = no;
|
||||
has_escape_pod = 0;
|
||||
has_escape_pod = no;
|
||||
has_scoop = no;
|
||||
max_energy = 100;
|
||||
max_flight_pitch = 0.1;
|
||||
@ -527,7 +527,7 @@
|
||||
forward_weapon_type = "WEAPON_BEAM_LASER";
|
||||
fuel = 70;
|
||||
has_ecm = 0.95;
|
||||
has_escape_pod = 1;
|
||||
has_escape_pod = yes;
|
||||
has_scoop = yes;
|
||||
likely_cargo = 15;
|
||||
max_cargo = 175;
|
||||
@ -738,7 +738,7 @@
|
||||
energy_recharge_rate = 0;
|
||||
forward_weapon_type = "WEAPON_NONE";
|
||||
has_ecm = no;
|
||||
has_escape_pod = 0;
|
||||
has_escape_pod = no;
|
||||
has_scoop = no;
|
||||
max_energy = 25;
|
||||
max_flight_pitch = 0.5;
|
||||
@ -1212,16 +1212,15 @@
|
||||
"constrictor" =
|
||||
{
|
||||
aft_eject_position = "0.0 5.5 -19.0";
|
||||
ai_type = "pirateAI.plist";
|
||||
ai_type = "oolite-constrictor-AI.plist";
|
||||
bounty = 250;
|
||||
cargo_type = "CARGO_NOT_CARGO";
|
||||
death_actions = ("set: mission_conhunt CONSTRICTOR_DESTROYED");
|
||||
energy_recharge_rate = 5;
|
||||
exhaust = ("0.0 0.0 -30.0 18.0 12.0 12.0");
|
||||
forward_weapon_type = "WEAPON_MILITARY_LASER";
|
||||
fuel = 70;
|
||||
has_ecm = yes;
|
||||
has_escape_pod = 1;
|
||||
has_escape_pod = yes;
|
||||
has_fuel_injection = yes;
|
||||
likely_cargo = 3;
|
||||
max_cargo = 15;
|
||||
@ -1235,6 +1234,7 @@
|
||||
name = "Constrictor";
|
||||
pilot = "constrictor-mission-thief"; // key to entry in characters.plist
|
||||
roles = "constrictor oolite-constrictor";
|
||||
script = "oolite-constrictor.js";
|
||||
thrust = 50;
|
||||
weapon_position_aft = "0.0 -4.5 -30.0";
|
||||
weapon_position_forward = "0.0 0.0 27.5";
|
||||
@ -1249,7 +1249,7 @@
|
||||
forward_weapon_type = "WEAPON_NONE";
|
||||
frangible = 0;
|
||||
has_ecm = yes;
|
||||
has_escape_pod = 0;
|
||||
has_escape_pod = no;
|
||||
has_scoop = no;
|
||||
max_energy = 25000;
|
||||
max_flight_pitch = 8;
|
||||
@ -1308,7 +1308,7 @@
|
||||
forward_weapon_type = "WEAPON_NONE";
|
||||
frangible = 0;
|
||||
has_ecm = yes;
|
||||
has_escape_pod = 0;
|
||||
has_escape_pod = no;
|
||||
has_scoop = no;
|
||||
max_energy = 25000;
|
||||
max_flight_pitch = 8;
|
||||
@ -1570,7 +1570,7 @@
|
||||
forward_weapon_type = "WEAPON_NONE";
|
||||
frangible = 0;
|
||||
has_ecm = yes;
|
||||
has_escape_pod = 0;
|
||||
has_escape_pod = no;
|
||||
has_scoop = no;
|
||||
max_energy = 25000;
|
||||
max_flight_pitch = 8;
|
||||
@ -2130,7 +2130,7 @@
|
||||
exhaust = ("0.0 0.0 -64.5 12.0 12.0 13.0");
|
||||
forward_weapon_type = "WEAPON_BEAM_LASER";
|
||||
fuel = 70;
|
||||
has_escape_pod = 1;
|
||||
has_escape_pod = yes;
|
||||
has_scoop = yes;
|
||||
likely_cargo = 10;
|
||||
max_cargo = 100;
|
||||
@ -2172,7 +2172,7 @@
|
||||
forward_weapon_type = "WEAPON_NONE";
|
||||
frangible = 0;
|
||||
has_ecm = yes;
|
||||
has_escape_pod = 0;
|
||||
has_escape_pod = no;
|
||||
has_scoop = no;
|
||||
"max_defense_ships" = 2;
|
||||
max_energy = 1000;
|
||||
@ -2314,7 +2314,7 @@
|
||||
energy_recharge_rate = 0;
|
||||
forward_weapon_type = "WEAPON_NONE";
|
||||
has_ecm = no;
|
||||
has_escape_pod = 0;
|
||||
has_escape_pod = no;
|
||||
has_scoop = no;
|
||||
max_energy = 5;
|
||||
max_flight_pitch = 1;
|
||||
@ -2384,7 +2384,6 @@
|
||||
ai_type = "thargoidAI.plist";
|
||||
bounty = 100;
|
||||
cargo_type = "CARGO_NOT_CARGO";
|
||||
death_actions = ("commsMessage: [thargoid_curses]");
|
||||
energy_recharge_rate = 4;
|
||||
forward_weapon_type = "WEAPON_THARGOID_LASER";
|
||||
fuel = 150;
|
||||
@ -2402,6 +2401,7 @@
|
||||
roles = "thargoid oolite-thargoid thargoid-mothership";
|
||||
scanClass = "CLASS_THARGOID";
|
||||
scanner_range = 60000;
|
||||
script = "oolite-thargoid-warship.js";
|
||||
thrust = 50;
|
||||
};
|
||||
"transporter" =
|
||||
|
@ -1,5 +1,7 @@
|
||||
(
|
||||
"oolite-legacy-script.plist",
|
||||
"oolite-constrictor-hunt-mission.js",
|
||||
"oolite-cloaking-device-mission.js",
|
||||
"oolite-nova-mission.js",
|
||||
"oolite-thargoid-plans-mission.js",
|
||||
"oolite-trumbles-mission.js"
|
||||
)
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
|
||||
oolite-cloaking-device.js
|
||||
oolite-cloaking-device-mission.js
|
||||
|
||||
Script for cloaking device mission.
|
||||
|
||||
|
@ -6,7 +6,7 @@ Ship script for cloaking device cargo pod.
|
||||
|
||||
|
||||
Oolite
|
||||
Copyright © 2007 Giles C Williams and contributors
|
||||
Copyright © 2008 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
|
||||
|
39
Resources/Scripts/oolite-cloaking-device-target-ship.js
Normal file
39
Resources/Scripts/oolite-cloaking-device-target-ship.js
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
|
||||
oolite-cloaking-device-target-ship.js
|
||||
|
||||
Ship script for cloaking mission target ship.
|
||||
|
||||
|
||||
Oolite
|
||||
Copyright © 2008 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.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
this.name = "oolite-cloaking-device-target-ship";
|
||||
this.author = "Jens Ayton";
|
||||
this.copyright = "© 2008 the Oolite team.";
|
||||
this.version = "1.71";
|
||||
|
||||
|
||||
this.shipDied = function ()
|
||||
{
|
||||
this.spawn("cloaking-device");
|
||||
missionVariables.cloak = "COMPLETE";
|
||||
}
|
166
Resources/Scripts/oolite-constrictor-hunt-mission.js
Normal file
166
Resources/Scripts/oolite-constrictor-hunt-mission.js
Normal file
@ -0,0 +1,166 @@
|
||||
/*
|
||||
|
||||
oolite-constrictor-hunt-mission.js
|
||||
|
||||
Script for Constrictor hunt mission.
|
||||
|
||||
|
||||
Oolite
|
||||
Copyright © 2004-2008 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.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
this.name = "oolite-constrictor-hunt";
|
||||
this.author = "eric walch";
|
||||
this.copyright = "© 2008 the Oolite team.";
|
||||
this.version = "1.71";
|
||||
|
||||
|
||||
this.addToScreen = function ()
|
||||
{
|
||||
if (guiScreen == "GUI_SCREEN_SYSTEM_DATA")
|
||||
{
|
||||
if (galaxyNumber == 0)
|
||||
{
|
||||
switch (system.ID)
|
||||
{
|
||||
case 28:
|
||||
mission.addMessageTextKey("constrictor_hunt_0_28");
|
||||
break;
|
||||
|
||||
case 36:
|
||||
mission.addMessageTextKey("constrictor_hunt_0_36");
|
||||
break;
|
||||
|
||||
case 150:
|
||||
mission.addMessageTextKey("constrictor_hunt_0_150");
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (galaxyNumber == 1)
|
||||
{
|
||||
switch (system.ID)
|
||||
{
|
||||
case 3:
|
||||
case 5:
|
||||
case 16:
|
||||
case 26:
|
||||
case 32:
|
||||
case 68:
|
||||
case 106:
|
||||
case 107:
|
||||
case 162:
|
||||
case 164:
|
||||
case 184:
|
||||
case 192:
|
||||
case 220:
|
||||
mission.addMessageTextKey("constrictor_hunt_1_A");
|
||||
break;
|
||||
|
||||
case 253:
|
||||
mission.addMessageTextKey("constrictor_hunt_1_253");
|
||||
break;
|
||||
|
||||
case 79:
|
||||
mission.addMessageTextKey("constrictor_hunt_1_79");
|
||||
break;
|
||||
|
||||
case 53:
|
||||
mission.addMessageTextKey("constrictor_hunt_1_53");
|
||||
break;
|
||||
|
||||
case 118:
|
||||
mission.addMessageTextKey("constrictor_hunt_1_118");
|
||||
break;
|
||||
case 193:
|
||||
mission.addMessageTextKey("constrictor_hunt_1_193");
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.missionOffers = function ()
|
||||
{
|
||||
if (guiScreen == "GUI_SCREEN_MISSION" || (mission.choice && mission.choice != "")) return;
|
||||
|
||||
// there will be a "missionScreenEnded" or a "missionChoiceWasReset" in future to react to.
|
||||
if (player.dockedStation.isMainStation)
|
||||
{
|
||||
if (galaxyNumber < 2 && !missionVariables.conhunt && player.score > 255)
|
||||
{
|
||||
mission.runMissionScreen("constrictor_hunt_brief1", null, null, "constrictor");
|
||||
if (galaxyNumber == 0) mission.addMessageTextKey("constrictor_hunt_brief1a"); // galaxy = 0
|
||||
else mission.addMessageTextKey("constrictor_hunt_brief1b"); // galaxy = 1
|
||||
missionVariables.conhunt = "STAGE_1";
|
||||
mission.setInstructionsKey("conhunt_short_desc1");
|
||||
}
|
||||
if (missionVariables.conhunt == "CONSTRICTOR_DESTROYED") // Variable is set by the ship-script
|
||||
{
|
||||
mission.runMissionScreen("constrictor_hunt_debrief", null, null, "constrictor");
|
||||
player.credits += 5000;
|
||||
player.bounty = 0; // legal status
|
||||
player.score += 256; // ship kills
|
||||
mission.addMessageTextKey(); // reset the missionbriefing
|
||||
missionVariables.conhunt = "MISSION_COMPLETE";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.setUpShips = function ()
|
||||
{
|
||||
if (galaxyNumber == 1 &&
|
||||
system.ID == 193 &&
|
||||
missionVariables.conhunt == "STAGE_1" &&
|
||||
system.countShipsWithRole("constrictor") == 0)
|
||||
{
|
||||
system.legacy_addShips("constrictor", 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**** Event handlers ****/
|
||||
|
||||
this.guiScreenChanged = function ()
|
||||
{
|
||||
if (galaxyNumber < 2 && missionVariables.conhunt == "STAGE_1") this.addToScreen();
|
||||
}
|
||||
|
||||
this.shipDockedWithStation = function ()
|
||||
{
|
||||
this.missionOffers();
|
||||
}
|
||||
|
||||
this.missionScreenEnded = this.missionChoiceWasReset = function ()
|
||||
{
|
||||
if (!player.docked) return;
|
||||
this.missionOffers();
|
||||
}
|
||||
|
||||
this.shipExitedWitchspace = this.shipLaunchedFromStation = function ()
|
||||
{
|
||||
this.setUpShips();
|
||||
}
|
68
Resources/Scripts/oolite-constrictor.js
Normal file
68
Resources/Scripts/oolite-constrictor.js
Normal file
@ -0,0 +1,68 @@
|
||||
/*
|
||||
|
||||
oolite-constrictor-hunt-mission.js
|
||||
|
||||
Script for Constrictor hunt mission.
|
||||
|
||||
|
||||
Oolite
|
||||
Copyright © 2004-2008 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.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
this.name = "oolite-constrictor";
|
||||
this.author = "eric walch";
|
||||
this.copyright = "© 2008 the Oolite team.";
|
||||
this.version = "1.01";
|
||||
|
||||
|
||||
this.legalPoints = 0;
|
||||
|
||||
this.shipSpawned = function ()
|
||||
{
|
||||
this.legalPoints = this.ship.bounty;
|
||||
this.ship.bounty = 0;
|
||||
}
|
||||
|
||||
|
||||
this.shipDied = function (killer)
|
||||
{
|
||||
if(killer == player) missionVariables.conhunt = "CONSTRICTOR_DESTROYED";
|
||||
}
|
||||
|
||||
|
||||
this.checkDistance = function ()
|
||||
{
|
||||
if (player.position.distanceTo(this.ship) < 50000)
|
||||
{
|
||||
if(this.legalPoints > 0)
|
||||
{
|
||||
this.ship.bounty = this.legalPoints;
|
||||
this.legalPoints = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(this.legalPoints == 0)
|
||||
{
|
||||
this.legalPoints = this.ship.bounty;
|
||||
this.ship.bounty = 0;
|
||||
}
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@ Standard ship script; handles legacy foo_actions.
|
||||
|
||||
|
||||
Oolite
|
||||
Copyright © 2007 Giles C Williams and contributors
|
||||
Copyright © 2008 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
|
||||
|
@ -45,6 +45,31 @@ this.version = "1.71";
|
||||
this.global = (function () { return this; } ).call();
|
||||
|
||||
|
||||
/**** Utilities, not intended to be retired ****/
|
||||
|
||||
// Ship.spawnOne(): like spawn(role, 1), but returns the ship rather than an array.
|
||||
Ship.__proto__.spawnOne = function (role)
|
||||
{
|
||||
let result = this.spawn(role, 1);
|
||||
if (result) return result[0];
|
||||
else return null;
|
||||
}
|
||||
|
||||
|
||||
// mission.runMissionScreen(): one-shot mission screen, until we get a proper MissionScreen class.
|
||||
mission.runMissionScreen = function (messageKey, backgroundImage, choiceKey, shipKey, musicKey)
|
||||
{
|
||||
mission.showShipModel(shipKey);
|
||||
mission.setMusic(musicKey);
|
||||
mission.setBackgroundImage(backgroundImage);
|
||||
mission.showMissionScreen();
|
||||
mission.addMessageTextKey(messageKey);
|
||||
if (choiceKey) mission.setChoicesKey(choiceKey);
|
||||
mission.setBackgroundImage();
|
||||
mission.setMusic();
|
||||
}
|
||||
|
||||
|
||||
/**** Backwards-compatibility functions. These will be removed before next stable. ****/
|
||||
|
||||
// Define a function that is an alias for another function.
|
||||
@ -118,6 +143,12 @@ mission.resetMissionChoice = function()
|
||||
}
|
||||
|
||||
|
||||
system.legacy_spawn = function()
|
||||
{
|
||||
special.jsWarning("system.legacy_spawn() is deprecated (and never worked), use Ship.spawn() instead.");
|
||||
}
|
||||
|
||||
|
||||
// To be removed after 1.71
|
||||
Entity.__proto__.valid = function ()
|
||||
{
|
||||
|
@ -1,345 +0,0 @@
|
||||
{
|
||||
"!metadata!" = {
|
||||
// NOTE: metadata tagging syntax is not backwards compatible with versions of Oolite prior to 1.68.
|
||||
version = "1.71";
|
||||
description = "Oolite built-in world scripts.";
|
||||
};
|
||||
|
||||
"oolite-thargoid-plans" = (
|
||||
{
|
||||
conditions = (
|
||||
"dockedAtMainStation_bool equal YES",
|
||||
"galaxy_number equal 2",
|
||||
"mission_conhunt equal MISSION_COMPLETE",
|
||||
"mission_thargplans undefined",
|
||||
"score_number greaterthan 1280"
|
||||
);
|
||||
do = (
|
||||
setGuiToMissionScreen,
|
||||
"addMissionText: thargoid_plans_intro_brief",
|
||||
"set: mission_thargplans PRELUDE",
|
||||
"setMissionDescription: thargplans_short_desc1"
|
||||
);
|
||||
},
|
||||
{
|
||||
conditions = (
|
||||
"status_string equal STATUS_DOCKED",
|
||||
"galaxy_number equal 2",
|
||||
"mission_thargplans equal PRELUDE",
|
||||
"planet_number equal 83"
|
||||
);
|
||||
do = (
|
||||
setGuiToMissionScreen,
|
||||
"showShipModel: thargoid",
|
||||
"addMissionText: thargoid_plans_main_brief",
|
||||
"set: mission_thargplans RUNNING",
|
||||
"setMissionDescription: thargplans_short_desc2"
|
||||
);
|
||||
},
|
||||
{
|
||||
conditions = (
|
||||
"mission_thargplans equal RUNNING",
|
||||
"status_string equal STATUS_IN_FLIGHT",
|
||||
"scriptTimer_number lessthan 60"
|
||||
);
|
||||
do = (
|
||||
"checkForShips: thargoid",
|
||||
{
|
||||
conditions = ("shipsFound_number lessthan 2");
|
||||
do = (
|
||||
"addSystemShips: thargoid 1 0.66",
|
||||
"addSystemShips: thargoid 1 0.33"
|
||||
);
|
||||
},
|
||||
{
|
||||
conditions = (
|
||||
"shipsFound_number lessthan 5",
|
||||
"d100_number lessthan 50"
|
||||
);
|
||||
do = ("addShips: thargoid 1");
|
||||
}
|
||||
);
|
||||
},
|
||||
{
|
||||
conditions = (
|
||||
"dockedAtMainStation_bool equal YES",
|
||||
"galaxy_number equal 2",
|
||||
"mission_thargplans equal RUNNING",
|
||||
"planet_number equal 36"
|
||||
);
|
||||
do = (
|
||||
setGuiToMissionScreen,
|
||||
"showShipModel: thargoid",
|
||||
"addMissionText: thargoid_plans_debrief",
|
||||
"set: mission_thargplans MISSION_COMPLETE",
|
||||
"awardShipKills: 256",
|
||||
"awardEquipment: EQ_NAVAL_ENERGY_UNIT",
|
||||
clearMissionDescription
|
||||
);
|
||||
},
|
||||
{
|
||||
conditions = (
|
||||
"mission_thargplans equal MISSION_COMPLETE",
|
||||
"mission_TL_FOR_EQ_NAVAL_ENERGY_UNIT undefined"
|
||||
);
|
||||
do = ("set: mission_TL_FOR_EQ_NAVAL_ENERGY_UNIT 13");
|
||||
}
|
||||
);
|
||||
"oolite-constrictor-hunt" = (
|
||||
{
|
||||
conditions = (
|
||||
"dockedAtMainStation_bool equal YES",
|
||||
"galaxy_number lessthan 2",
|
||||
"mission_conhunt undefined",
|
||||
"score_number greaterthan 255"
|
||||
);
|
||||
do = (
|
||||
setGuiToMissionScreen,
|
||||
"showShipModel: constrictor",
|
||||
"addMissionText: constrictor_hunt_brief1",
|
||||
{
|
||||
conditions = ("galaxy_number equal 0");
|
||||
do = ("addMissionText: constrictor_hunt_brief1a");
|
||||
},
|
||||
{
|
||||
conditions = ("galaxy_number equal 1");
|
||||
do = ("addMissionText: constrictor_hunt_brief1b");
|
||||
},
|
||||
"set: mission_conhunt STAGE_1",
|
||||
"setMissionDescription: conhunt_short_desc1"
|
||||
);
|
||||
},
|
||||
{
|
||||
conditions = (
|
||||
"mission_conhunt equal STAGE_1",
|
||||
"gui_screen_string equal GUI_SCREEN_SYSTEM_DATA"
|
||||
);
|
||||
do = (
|
||||
{
|
||||
conditions = ("galaxy_number equal 0");
|
||||
do = (
|
||||
{
|
||||
conditions = ("planet_number equal 150");
|
||||
do = ("addMissionText: constrictor_hunt_0_150");
|
||||
},
|
||||
{
|
||||
conditions = ("planet_number equal 36");
|
||||
do = ("addMissionText: constrictor_hunt_0_36");
|
||||
},
|
||||
{
|
||||
conditions = ("planet_number equal 28");
|
||||
do = ("addMissionText: constrictor_hunt_0_28");
|
||||
}
|
||||
);
|
||||
},
|
||||
{
|
||||
conditions = ("galaxy_number equal 1");
|
||||
do = (
|
||||
{
|
||||
conditions = ("planet_number equal 3");
|
||||
do = ("addMissionText: constrictor_hunt_1_A");
|
||||
},
|
||||
{
|
||||
conditions = ("planet_number equal 5");
|
||||
do = ("addMissionText: constrictor_hunt_1_A");
|
||||
},
|
||||
{
|
||||
conditions = ("planet_number equal 16");
|
||||
do = ("addMissionText: constrictor_hunt_1_A");
|
||||
},
|
||||
{
|
||||
conditions = ("planet_number equal 26");
|
||||
do = ("addMissionText: constrictor_hunt_1_A");
|
||||
},
|
||||
{
|
||||
conditions = ("planet_number equal 32");
|
||||
do = ("addMissionText: constrictor_hunt_1_A");
|
||||
},
|
||||
{
|
||||
conditions = ("planet_number equal 68");
|
||||
do = ("addMissionText: constrictor_hunt_1_A");
|
||||
},
|
||||
{
|
||||
conditions = ("planet_number equal 106");
|
||||
do = ("addMissionText: constrictor_hunt_1_A");
|
||||
},
|
||||
{
|
||||
conditions = ("planet_number equal 107");
|
||||
do = ("addMissionText: constrictor_hunt_1_A");
|
||||
},
|
||||
{
|
||||
conditions = ("planet_number equal 162");
|
||||
do = ("addMissionText: constrictor_hunt_1_A");
|
||||
},
|
||||
{
|
||||
conditions = ("planet_number equal 164");
|
||||
do = ("addMissionText: constrictor_hunt_1_A");
|
||||
},
|
||||
{
|
||||
conditions = ("planet_number equal 184");
|
||||
do = ("addMissionText: constrictor_hunt_1_A");
|
||||
},
|
||||
{
|
||||
conditions = ("planet_number equal 192");
|
||||
do = ("addMissionText: constrictor_hunt_1_A");
|
||||
},
|
||||
{
|
||||
conditions = ("planet_number equal 220");
|
||||
do = ("addMissionText: constrictor_hunt_1_A");
|
||||
},
|
||||
{
|
||||
conditions = ("planet_number equal 253");
|
||||
do = ("addMissionText: constrictor_hunt_1_253");
|
||||
},
|
||||
{
|
||||
conditions = ("planet_number equal 79");
|
||||
do = ("addMissionText: constrictor_hunt_1_79");
|
||||
},
|
||||
{
|
||||
conditions = ("planet_number equal 53");
|
||||
do = ("addMissionText: constrictor_hunt_1_53");
|
||||
},
|
||||
{
|
||||
conditions = ("planet_number equal 118");
|
||||
do = ("addMissionText: constrictor_hunt_1_118");
|
||||
},
|
||||
{
|
||||
conditions = ("planet_number equal 193");
|
||||
do = ("addMissionText: constrictor_hunt_1_193");
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
},
|
||||
{
|
||||
conditions = (
|
||||
"mission_conhunt equal STAGE_1",
|
||||
"status_string equal STATUS_IN_FLIGHT",
|
||||
"galaxy_number equal 1",
|
||||
"planet_number equal 193"
|
||||
);
|
||||
do = (
|
||||
"checkForShips: constrictor",
|
||||
{
|
||||
conditions = ("shipsFound_number equal 0");
|
||||
do = ("addShips: constrictor 1");
|
||||
}
|
||||
);
|
||||
},
|
||||
{
|
||||
conditions = (
|
||||
"dockedAtMainStation_bool equal YES",
|
||||
"mission_conhunt equal CONSTRICTOR_DESTROYED"
|
||||
);
|
||||
do = (
|
||||
setGuiToMissionScreen,
|
||||
"showShipModel: constrictor",
|
||||
"awardCredits: 5000",
|
||||
"setLegalStatus: 0",
|
||||
"awardShipKills: 256",
|
||||
"addMissionText: constrictor_hunt_debrief",
|
||||
"set: mission_conhunt MISSION_COMPLETE",
|
||||
clearMissionDescription
|
||||
);
|
||||
}
|
||||
);
|
||||
"oolite-nova" = (
|
||||
{
|
||||
conditions = ("status_string equal STATUS_IN_FLIGHT", "sunGoneNova_bool equal YES");
|
||||
do = (sendAllShipsAway);
|
||||
},
|
||||
{
|
||||
conditions = ("status_string equal STATUS_IN_FLIGHT", "sunWillGoNova_bool equal YES");
|
||||
do = (sendAllShipsAway);
|
||||
},
|
||||
{
|
||||
conditions = ("galaxy_number equal 3", "mission_novacount undefined", "mission_nova undefined");
|
||||
do = ("set: mission_novacount 0");
|
||||
},
|
||||
{
|
||||
conditions = ("galaxy_number equal 3", "status_string equal STATUS_EXITING_WITCHSPACE");
|
||||
do = (
|
||||
"increment: mission_novacount",
|
||||
"testForEquipment: EQ_GAL_DRIVE",
|
||||
{
|
||||
conditions = (
|
||||
"foundEquipment_bool equal YES",
|
||||
"mission_novacount greaterthan 3",
|
||||
"mission_nova undefined"
|
||||
);
|
||||
do = (
|
||||
"set: mission_nova 2HRS_TO_ZERO",
|
||||
"setFuelLeak: 25",
|
||||
"setSunNovaIn: 7200",
|
||||
"setPlanetinfo: market = none",
|
||||
"setPlanetinfo: sun_gone_nova = YES"
|
||||
);
|
||||
}
|
||||
);
|
||||
},
|
||||
{
|
||||
conditions = ("mission_nova equal 2HRS_TO_ZERO", "status_string equal STATUS_IN_FLIGHT", "sunWillGoNova_bool equal NO");
|
||||
do = (sendAllShipsAway);
|
||||
},
|
||||
{
|
||||
conditions = (
|
||||
"mission_nova equal 2HRS_TO_ZERO",
|
||||
"dockedAtMainStation_bool equal YES",
|
||||
"missionChoice_string undefined"
|
||||
);
|
||||
do = (
|
||||
"setMissionImage: solar.png",
|
||||
setGuiToMissionScreen,
|
||||
"addMissionText: nova_1",
|
||||
"setMissionChoices: nova_yesno"
|
||||
);
|
||||
},
|
||||
{
|
||||
conditions = (
|
||||
"mission_nova equal 2HRS_TO_ZERO",
|
||||
"dockedAtMainStation_bool equal YES",
|
||||
"missionChoice_string equal YES"
|
||||
);
|
||||
do = (
|
||||
"useSpecialCargo: A hold full of %I refugees.",
|
||||
"setMissionDescription: nova_missiondesc",
|
||||
launchFromStation,
|
||||
blowUpStation,
|
||||
"set: mission_nova NOVA_ESCAPE_HERO",
|
||||
"setSunNovaIn: 30",
|
||||
"reset: mission_nova_count"
|
||||
);
|
||||
},
|
||||
{
|
||||
conditions = (
|
||||
"mission_nova equal 2HRS_TO_ZERO",
|
||||
"dockedAtMainStation_bool equal YES",
|
||||
"missionChoice_string equal NO"
|
||||
);
|
||||
do = (
|
||||
launchFromStation,
|
||||
blowUpStation,
|
||||
"set: mission_nova NOVA_ESCAPE_COWARD",
|
||||
"commsMessage: Coward! You chose not to help the refugees!",
|
||||
"setSunNovaIn: 3",
|
||||
"reset: mission_nova_count"
|
||||
);
|
||||
},
|
||||
{
|
||||
conditions = ("mission_nova equal NOVA_ESCAPE_HERO", "status_string equal STATUS_EXITING_WITCHSPACE");
|
||||
do = ("set: mission_nova NOVA_ESCAPED_SYSTEM");
|
||||
},
|
||||
{
|
||||
conditions = ("mission_nova equal NOVA_ESCAPED_SYSTEM", "dockedAtMainStation_bool equal YES");
|
||||
do = (
|
||||
removeAllCargo,
|
||||
"awardCargo: 100 Gem-Stones",
|
||||
"setMissionImage: solar.png",
|
||||
setGuiToMissionScreen,
|
||||
"addMissionText: nova_hero",
|
||||
"set: mission_nova NOVA_HERO",
|
||||
clearMissionDescription
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
189
Resources/Scripts/oolite-nova-mission.js
Normal file
189
Resources/Scripts/oolite-nova-mission.js
Normal file
@ -0,0 +1,189 @@
|
||||
/*
|
||||
|
||||
oolite-nova-mission.js
|
||||
|
||||
Script for nova mission.
|
||||
|
||||
|
||||
Oolite
|
||||
Copyright © 2004-2008 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.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
this.name = "oolite-nova";
|
||||
this.author = "eric walch";
|
||||
this.copyright = "© 2008 the Oolite team.";
|
||||
this.version = "1.71";
|
||||
|
||||
|
||||
this.missionOffers = function ()
|
||||
{
|
||||
if (guiScreen == "GUI_SCREEN_MISSION" || (mission.choice && mission.choice != "")) return;
|
||||
|
||||
// there will be a "missionScreenEnded" or a "missionChoiceWasReset" in future to react to.
|
||||
if (player.dockedStation.isMainStation)
|
||||
{
|
||||
if (galaxyNumber == 3)
|
||||
{
|
||||
if (!missionVariables.nova && !missionVariables.novacount) missionVariables.novacount = 0;
|
||||
if (missionVariables.nova == "TWO_HRS_TO_ZERO")
|
||||
{
|
||||
mission.runMissionScreen("nova_1", "solar.png", "nova_yesno");
|
||||
this.novaOffer = "NOVA_CHOICE"; // use a temporary variable for the offering.
|
||||
this.novaMissionTimer.stop();
|
||||
}
|
||||
}
|
||||
if (galaxyNumber == 3 || galaxyNumber == 4)
|
||||
{
|
||||
if (missionVariables.nova == "NOVA_ESCAPED_SYSTEM")
|
||||
{
|
||||
player.removeAllCargo();
|
||||
player.awardCargo("Gem-Stones", 100);
|
||||
mission.runMissionScreen("nova_hero", "solar.png");
|
||||
missionVariables.nova = "NOVA_HERO";
|
||||
mission.setInstructionsKey();
|
||||
}
|
||||
if (missionVariables.nova == "NOVA_ESCAPE_POD")
|
||||
{
|
||||
player.removeAllCargo(); // can only be done while docked.
|
||||
missionVariables.nova = "NOVA_HERO"; // not a real hero but other scripts expect this missionend string.
|
||||
mission.setInstructionsKey();
|
||||
}
|
||||
if (missionVariables.nova == "NOVA_ESCAPE_COWARD")
|
||||
{
|
||||
missionVariables.nova = "NOVA_HERO"; // not a real hero but other scripts expect this missionend string.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.choiceEvaluation = function()
|
||||
{
|
||||
if (!this.novaOffer) return;
|
||||
|
||||
if (this.novaOffer == "NOVA_CHOICE")
|
||||
{
|
||||
if (mission.choice == "YES")
|
||||
{
|
||||
mission.choice = null;
|
||||
this.novaOffer = null;
|
||||
player.useSpecialCargo(expandDescription("[oolite-nova-refugees]"));
|
||||
mission.setInstructionsKey("nova_missiondesc");
|
||||
missionVariables.nova = "NOVA_ESCAPE_HERO";
|
||||
player.launch();
|
||||
system.mainStation.explode();
|
||||
system.setSunNova(30);
|
||||
missionVariables.novacount = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
// mission.choice = "NO", or null when player launched without a choice.
|
||||
mission.choice = null;
|
||||
this.novaOffer = null;
|
||||
missionVariables.nova = "NOVA_ESCAPE_COWARD";
|
||||
player.commsMessage(expandDescription("[oolite-nova-coward]"), 4.5);
|
||||
system.setSunNova(3);
|
||||
missionVariables.novacount = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// general, used when player enters nova system after mission.
|
||||
this.sendShipsAway = function()
|
||||
{
|
||||
if (!system.goneNova)
|
||||
{
|
||||
this.novaTimer.stop();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
system.sendAllShipsAway();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// special, used when player enters nova system during mission.
|
||||
this.sendShipsAwayForMission = function()
|
||||
{
|
||||
if (missionVariables.nova != "TWO_HRS_TO_ZERO")
|
||||
{
|
||||
this.novaMissionTimer.stop();
|
||||
}
|
||||
else
|
||||
{
|
||||
system.sendAllShipsAway();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**** Event handlers ****/
|
||||
|
||||
this.shipLaunchedEscapePod = function ()
|
||||
{
|
||||
if (missionVariables.nova == "NOVA_ESCAPED_SYSTEM")
|
||||
{
|
||||
missionVariables.nova = "NOVA_ESCAPE_POD";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.shipDockedWithStation = function ()
|
||||
{
|
||||
this.missionOffers();
|
||||
}
|
||||
|
||||
|
||||
this.missionScreenEnded = this.missionChoiceWasReset = function ()
|
||||
{
|
||||
this.choiceEvaluation();
|
||||
if (player.docked) this.missionOffers();
|
||||
}
|
||||
|
||||
this.shipWillExitWitchspace = function () // call this as soon as possible so other scripts can see it will go nova.
|
||||
{
|
||||
if (galaxyNumber == 3)
|
||||
{
|
||||
if (missionVariables.novacount) missionVariables.novacount++;
|
||||
if (player.hasEquipment("EQ_GAL_DRIVE") && missionVariables.novacount > 3 && !missionVariables.nova)
|
||||
{
|
||||
missionVariables.nova = "TWO_HRS_TO_ZERO";
|
||||
player.fuelLeakRate = 25;
|
||||
system.setSunNova(7200);
|
||||
player.consoleMessage(expandDescription("[danger-fuel-leak]"), 4.5);
|
||||
player.call("setPlanetinfo:", "market = none");
|
||||
player.call("setPlanetinfo:", "sun_gone_nova = YES");
|
||||
|
||||
if (this.novaMissionTimer) this.novaMissionTimer.start();
|
||||
else this.novaMissionTimer = new Timer(this, this.sendShipsAwayForMission, 60, 30);
|
||||
}
|
||||
}
|
||||
if (missionVariables.nova == "NOVA_ESCAPE_HERO") missionVariables.nova = "NOVA_ESCAPED_SYSTEM";
|
||||
}
|
||||
|
||||
|
||||
this.shipExitedWitchspace = function()
|
||||
{
|
||||
if (system.goneNova)
|
||||
{
|
||||
if (this.novaTimer) this.novaTimer.start();
|
||||
else this.novaTimer = new Timer(this, this.sendShipsAway, 1, 60);
|
||||
}
|
||||
}
|
138
Resources/Scripts/oolite-thargoid-plans-mission.js
Normal file
138
Resources/Scripts/oolite-thargoid-plans-mission.js
Normal file
@ -0,0 +1,138 @@
|
||||
/*
|
||||
|
||||
oolite-thargoid-plans-mission.js
|
||||
|
||||
Script for Thargoid plans mission.
|
||||
|
||||
|
||||
Oolite
|
||||
Copyright © 2004-2008 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.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
this.name = "oolite-thargoid-plans";
|
||||
this.author = "eric walch";
|
||||
this.copyright = "© 2008 the Oolite team.";
|
||||
this.version = "1.71";
|
||||
|
||||
|
||||
this.missionOffers = function ()
|
||||
{
|
||||
if (guiScreen == "GUI_SCREEN_MISSION" || (mission.choice && mission.choice != "")) return;
|
||||
// there will be a "missionScreenEnded" or a "missionChoiceWasReset" in future to react to.
|
||||
if (player.dockedStation.isMainStation)
|
||||
{
|
||||
if (galaxyNumber == 2)
|
||||
{
|
||||
if (!missionVariables.thargplans &&
|
||||
missionVariables.conhunt == "MISSION_COMPLETE" &&
|
||||
player.score > 1280 &&
|
||||
system.ID != 83)
|
||||
{
|
||||
mission.runMissionScreen("thargoid_plans_intro_brief");
|
||||
missionVariables.thargplans = "PRELUDE";
|
||||
mission.setInstructionsKey("thargplans_short_desc1");
|
||||
mission.markSystem(83);
|
||||
}
|
||||
else if (missionVariables.thargplans == "PRELUDE" &&
|
||||
system.ID == 83)
|
||||
{
|
||||
mission.unmarkSystem(83);
|
||||
mission.runMissionScreen("thargoid_plans_main_brief", null, null, "thargoid");
|
||||
missionVariables.thargplans = "RUNNING";
|
||||
mission.setInstructionsKey("thargplans_short_desc2");
|
||||
mission.markSystem(36);
|
||||
}
|
||||
else if (missionVariables.thargplans == "RUNNING" &&
|
||||
system.ID == 36)
|
||||
{
|
||||
mission.runMissionScreen("thargoid_plans_debrief", null, null, "thargoid");
|
||||
player.score += 256; // ship kills
|
||||
mission.setInstructionsKey(); // reset the missionbriefing
|
||||
missionVariables.thargplans = "MISSION_COMPLETE";
|
||||
player.awardEquipment("EQ_NAVAL_ENERGY_UNIT");
|
||||
missionVariables.TL_FOR_EQ_NAVAL_ENERGY_UNIT = 13;
|
||||
mission.unmarkSystem(36);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.addTargoids = function ()
|
||||
{
|
||||
this.loopcount++; // 5 loops of adding in the legacy script with a script timer.
|
||||
if (this.loopcount > 5)
|
||||
{
|
||||
this.targoidTimer.stop;
|
||||
return;
|
||||
}
|
||||
if (system.countShipsWithRole("thargoid") < 2)
|
||||
{
|
||||
system.legacy_addSystemShips("thargoid", 1, 0.33);
|
||||
system.legacy_addSystemShips("thargoid", 1, 0.66);
|
||||
}
|
||||
if (system.countShipsWithRole("thargoid") < 5 && Math.random() < 0.5)
|
||||
{
|
||||
system.legacy_addShips("thargoid", 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.setUpShips = function ()
|
||||
{
|
||||
if (missionVariables.thargplans == "RUNNING" && galaxyNumber == 2)
|
||||
{
|
||||
if (this.targoidTimer) this.targoidTimer.start();
|
||||
else this.targoidTimer = new Timer(this, this.addTargoids, 10, 10);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**** Event handlers ****/
|
||||
this.startUp = this.reset = function ()
|
||||
{
|
||||
this.loopcount = 0; // should be zero on the first launch after a reset.
|
||||
}
|
||||
|
||||
|
||||
this.shipDockedWithStation = function ()
|
||||
{
|
||||
this.missionOffers();
|
||||
}
|
||||
|
||||
|
||||
this.missionScreenEnded = this.missionChoiceWasReset = function ()
|
||||
{
|
||||
if (!player.docked) return;
|
||||
this.missionOffers();
|
||||
}
|
||||
|
||||
|
||||
this.shipLaunchedFromStation = function ()
|
||||
{
|
||||
this.setUpShips();
|
||||
}
|
||||
|
||||
|
||||
this.shipExitedWitchspace = function ()
|
||||
{
|
||||
this.loopcount = 0;
|
||||
this.setUpShips();
|
||||
}
|
38
Resources/Scripts/oolite-thargoid-warship.js
Normal file
38
Resources/Scripts/oolite-thargoid-warship.js
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
|
||||
oolite-thargoid-warship.js
|
||||
|
||||
Ship script for thargoid warship.
|
||||
|
||||
|
||||
Oolite
|
||||
Copyright © 2008 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.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
this.name = "oolite-thargoid-warship";
|
||||
this.author = "Jens Ayton";
|
||||
this.copyright = "© 2008 the Oolite team.";
|
||||
this.version = "1.71";
|
||||
|
||||
|
||||
this.shipDied = function ()
|
||||
{
|
||||
player.commsMessage(expandDescription("[thargoid_curses]"));
|
||||
}
|
@ -73,11 +73,7 @@ this.shipDockedWithStation = function ()
|
||||
&& Math.random() < 0.2)
|
||||
{
|
||||
// Show the mission screen.
|
||||
mission.clearMissionScreen();
|
||||
mission.setBackgroundImage("trumblebox.png");
|
||||
mission.showMissionScreen();
|
||||
mission.addMessageTextKey("oolite_trumble_offer");
|
||||
mission.setChoicesKey("oolite_trumble_offer_yesno");
|
||||
mission.runMissionScreen("oolite_trumble_offer", "trumblebox.png", "oolite_trumble_offer_yesno");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -91,7 +87,7 @@ this.missionScreenEnded = function ()
|
||||
if (mission.choice == "OOLITE_TRUMBLE_YES")
|
||||
{
|
||||
// Trumble bought.
|
||||
mission.clearMissionScreen();
|
||||
mission.choice = null;
|
||||
missionVariables.trumbles = "TRUMBLE_BOUGHT";
|
||||
player.credits -= 30;
|
||||
player.awardEquipment("EQ_TRUMBLE");
|
||||
@ -99,7 +95,7 @@ this.missionScreenEnded = function ()
|
||||
else if (mission.choice == "OOLITE_TRUMBLE_NO")
|
||||
{
|
||||
// Trumble bought.
|
||||
mission.clearMissionScreen();
|
||||
mission.choice = null;
|
||||
missionVariables.trumbles = "NOT_NOW";
|
||||
}
|
||||
// else it was someone else's mission screen, so we do nothing.
|
||||
|
@ -3174,7 +3174,7 @@ double scoopSoundPlayTime = 0.0;
|
||||
}
|
||||
|
||||
|
||||
- (int)launchEscapeCapsule
|
||||
- (OOUniversalID)launchEscapeCapsule
|
||||
{
|
||||
ShipEntity *doppelganger = nil;
|
||||
ShipEntity *escapePod = nil;
|
||||
|
@ -2083,7 +2083,6 @@ static int scriptRandomSeed = -1; // ensure proper random function
|
||||
missionBackgroundTexture = [OOTexture textureWithName:value inFolder:@"Images"];
|
||||
[missionBackgroundTexture retain];
|
||||
}
|
||||
[[UNIVERSE gui] setBackgroundTexture:missionBackgroundTexture];
|
||||
}
|
||||
|
||||
|
||||
|
@ -7268,25 +7268,27 @@ static BOOL AuthorityPredicate(Entity *entity, void *parameter)
|
||||
|
||||
- (void) spawn:(NSString *)roles_number
|
||||
{
|
||||
NSArray* tokens = ScanTokensFromString(roles_number);
|
||||
NSString* roleString = nil;
|
||||
NSString* numberString = nil;
|
||||
|
||||
NSArray *tokens = ScanTokensFromString(roles_number);
|
||||
NSString *roleString = nil;
|
||||
NSString *numberString = nil;
|
||||
|
||||
if ([tokens count] != 2)
|
||||
{
|
||||
OOLog(kOOLogSyntaxAddShips, @"***** Could not spawn: '%@' (must be two tokens, role and number)",roles_number);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
roleString = [tokens stringAtIndex:0];
|
||||
numberString = [tokens stringAtIndex:1];
|
||||
|
||||
|
||||
int number = [numberString intValue];
|
||||
|
||||
|
||||
OOLog(kOOLogNoteAddShips, @"Spawning %d x '%@' near %@ %d", number, roleString, name, universalID);
|
||||
|
||||
while (number--)
|
||||
|
||||
do
|
||||
{
|
||||
[UNIVERSE spawnShipWithRole:roleString near:self];
|
||||
} while (--number);
|
||||
}
|
||||
|
||||
|
||||
|
@ -185,8 +185,8 @@ static NSString *GetGLSLInfoLog(GLhandleARB shaderObject);
|
||||
BOOL OK = YES;
|
||||
const GLcharARB *sourceString = NULL;
|
||||
GLint compileStatus;
|
||||
GLhandleARB vertexShader;
|
||||
GLhandleARB fragmentShader;
|
||||
GLhandleARB vertexShader = NULL_SHADER;
|
||||
GLhandleARB fragmentShader = NULL_SHADER;
|
||||
|
||||
OO_ENTER_OPENGL();
|
||||
|
||||
|
@ -162,7 +162,7 @@ This code is hereby placed in the public domain.
|
||||
- (id)weakRetain
|
||||
{
|
||||
if (weakSelf == nil) weakSelf = [OOWeakReference weakRefWithObject:self];
|
||||
return [weakSelf retain];
|
||||
return [weakSelf retain]; // Each caller releases this, as -weakRetain must be balanced with -release.
|
||||
}
|
||||
|
||||
|
||||
|
@ -53,6 +53,8 @@ static JSBool ShipHasRole(JSContext *context, JSObject *this, uintN argc, jsval
|
||||
static JSBool ShipEjectItem(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult);
|
||||
static JSBool ShipEjectSpecificItem(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult);
|
||||
static JSBool ShipDumpCargo(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult);
|
||||
static JSBool ShipSpawn(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult);
|
||||
static JSBool ShipExplode(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult);
|
||||
static JSBool ShipRunLegacyScriptActions(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult);
|
||||
|
||||
|
||||
@ -187,6 +189,8 @@ static JSFunctionSpec sShipMethods[] =
|
||||
{ "ejectSpecificItem", ShipEjectSpecificItem, 1 },
|
||||
{ "dumpCargo", ShipDumpCargo, 0 },
|
||||
{ "runLegacyScriptActions", ShipRunLegacyScriptActions, 2 },
|
||||
{ "spawn", ShipSpawn, 1 },
|
||||
{ "explode", ShipExplode, 0 },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
@ -767,6 +771,71 @@ static JSBool ShipDumpCargo(JSContext *context, JSObject *this, uintN argc, jsva
|
||||
}
|
||||
|
||||
|
||||
// spawn(role : String [, number : count]) : Array
|
||||
static JSBool ShipSpawn(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult)
|
||||
{
|
||||
ShipEntity *thisEnt = nil;
|
||||
NSString *role = nil;
|
||||
int32 count;
|
||||
NSMutableArray *result = nil;
|
||||
ShipEntity *ship = nil;
|
||||
|
||||
if (!JSShipGetShipEntity(context, this, &thisEnt)) return YES; // stale reference, no-op.
|
||||
role = [NSString stringWithJavaScriptValue:*argv inContext:context];
|
||||
if (role == nil)
|
||||
{
|
||||
OOReportJavaScriptError(context, @"Expected role (string), got \"%@\".", JSValToNSString(context, argv[0]));
|
||||
return YES;
|
||||
}
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
if (!JS_ValueToInt32(context, argv[1], &count) || count < 1)
|
||||
{
|
||||
OOReportJavaScriptError(context, @"Expected spawn count (positive integer), got \"%@\".", JSValToNSString(context, argv[1]));
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
else count = 1;
|
||||
|
||||
assert(count > 0);
|
||||
|
||||
result = [NSMutableArray arrayWithCapacity:count];
|
||||
|
||||
do
|
||||
{
|
||||
ship = [UNIVERSE spawnShipWithRole:role near:thisEnt];
|
||||
if (ship != nil)
|
||||
{
|
||||
[result addObject:ship];
|
||||
}
|
||||
} while (--count);
|
||||
|
||||
*outResult = [result javaScriptValueInContext:context];
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
// explode()
|
||||
static JSBool ShipExplode(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult)
|
||||
{
|
||||
ShipEntity *thisEnt = nil;
|
||||
|
||||
if (!JSShipGetShipEntity(context, this, &thisEnt)) return YES; // stale reference, no-op.
|
||||
|
||||
if (thisEnt == (ShipEntity *)[UNIVERSE station])
|
||||
{
|
||||
// Allow exploding of main station (e.g. nova mission)
|
||||
[UNIVERSE unMagicMainStation];
|
||||
}
|
||||
|
||||
[thisEnt setEnergy:1];
|
||||
[thisEnt takeEnergyDamage:500000000.0 from:nil becauseOf:nil];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
// scriptTarget.runLegacyShipActions(target : Ship, actions : Array)
|
||||
static JSBool ShipRunLegacyScriptActions(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult)
|
||||
{
|
||||
|
@ -78,7 +78,6 @@ static JSBool SystemLegacyAddSystemShips(JSContext *context, JSObject *this, uin
|
||||
static JSBool SystemLegacyAddShipsAt(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult);
|
||||
static JSBool SystemLegacyAddShipsAtPrecisely(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult);
|
||||
static JSBool SystemLegacyAddShipsWithinRadius(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult);
|
||||
static JSBool SystemLegacySpawn(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult);
|
||||
static JSBool SystemLegacySpawnShip(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult);
|
||||
|
||||
static JSBool SystemStaticSystemNameForID(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult);
|
||||
@ -175,7 +174,6 @@ static JSFunctionSpec sSystemMethods[] =
|
||||
{ "legacy_addShipsAt", SystemLegacyAddShipsAt, 6 },
|
||||
{ "legacy_addShipsAtPrecisely", SystemLegacyAddShipsAtPrecisely, 6 },
|
||||
{ "legacy_addShipsWithinRadius", SystemLegacyAddShipsWithinRadius, 7 },
|
||||
{ "legacy_spawn", SystemLegacySpawn, 2 },
|
||||
{ "legacy_spawnShip", SystemLegacySpawnShip, 1 },
|
||||
{ 0 }
|
||||
};
|
||||
@ -764,27 +762,6 @@ static JSBool SystemLegacyAddShipsWithinRadius(JSContext *context, JSObject *thi
|
||||
}
|
||||
|
||||
|
||||
static JSBool SystemLegacySpawn(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult)
|
||||
{
|
||||
PlayerEntity *player = OOPlayerForScripting();
|
||||
NSString *role = nil;
|
||||
int32 count;
|
||||
NSString *arg = nil;
|
||||
|
||||
role = JSValToNSString(context, argv[0]);
|
||||
if (!JS_ValueToInt32(context, argv[1], &count) || count < 1 || 64 < count)
|
||||
{
|
||||
OOReportJavaScriptError(context, @"System.%@(): expected positive count, got %@.", @"legacy_spawn", JSValToNSString(context, argv[1]));
|
||||
return YES;
|
||||
}
|
||||
|
||||
arg = [NSString stringWithFormat:@"%@ %d", role, count];
|
||||
[player spawn:arg];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
static JSBool SystemLegacySpawnShip(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult)
|
||||
{
|
||||
PlayerEntity *player = OOPlayerForScripting();
|
||||
|
@ -290,7 +290,7 @@ enum
|
||||
- (BOOL) addShips:(int) howMany withRole:(NSString *) desc intoBoundingBox:(BoundingBox) bbox;
|
||||
- (BOOL) spawnShip:(NSString *) shipdesc;
|
||||
- (void) witchspaceShipWithPrimaryRole:(NSString *)role;
|
||||
- (void) spawnShipWithRole:(NSString *) desc near:(Entity *) entity;
|
||||
- (ShipEntity *) spawnShipWithRole:(NSString *) desc near:(Entity *) entity;
|
||||
|
||||
- (BOOL) roleIsPirateVictim:(NSString *)role;
|
||||
|
||||
|
@ -2457,46 +2457,51 @@ GLfloat docked_light_specular[4] = { (GLfloat) 1.0, (GLfloat) 1.0, (GLfloat) 0.5
|
||||
}
|
||||
|
||||
|
||||
- (void) spawnShipWithRole:(NSString *) desc near:(Entity *) entity
|
||||
// adds a ship within the collision radius of the other entity
|
||||
- (ShipEntity *) spawnShipWithRole:(NSString *) desc near:(Entity *) entity
|
||||
{
|
||||
// adds a ship within the collision radius of the other entity
|
||||
if (!entity)
|
||||
return;
|
||||
ShipEntity *ship;
|
||||
Vector spawn_pos = entity->position;
|
||||
Quaternion spawn_q; quaternion_set_random(&spawn_q);
|
||||
Vector vf = vector_forward_from_quaternion(spawn_q);
|
||||
if (entity == nil) return nil;
|
||||
|
||||
ShipEntity *ship = nil;
|
||||
Vector spawn_pos;
|
||||
Quaternion spawn_q;
|
||||
GLfloat offset = (randf() + randf()) * entity->collision_radius;
|
||||
spawn_pos.x += offset * vf.x; spawn_pos.y += offset * vf.y; spawn_pos.z += offset * vf.z;
|
||||
|
||||
quaternion_set_random(&spawn_q);
|
||||
spawn_pos = vector_add([entity position], vector_multiply_scalar(vector_forward_from_quaternion(spawn_q), offset));
|
||||
|
||||
ship = [self newShipWithRole:desc]; // retain count = 1
|
||||
|
||||
// Deal with scripted cargopods and ensure they are filled with something.
|
||||
if (ship && [ship hasPrimaryRole:@"cargopod"])
|
||||
if ([ship hasPrimaryRole:@"cargopod"])
|
||||
{
|
||||
NSArray *theCargopod = [self getContainersOfGoods:1 scarce:NO];
|
||||
[ship release]; // We are about to pass to cargopod an already generated object.
|
||||
ship = [theCargopod objectAtIndex:0];
|
||||
ship = [[theCargopod objectAtIndex:0] retain];
|
||||
}
|
||||
|
||||
if (ship)
|
||||
if (ship != nil)
|
||||
{
|
||||
if (![ship crew] && !(ship->scanClass == CLASS_CARGO || ship->scanClass == CLASS_ROCK))
|
||||
{
|
||||
[ship setCrew:[NSArray arrayWithObject:
|
||||
[OOCharacter randomCharacterWithRole: desc
|
||||
andOriginalSystem: systems[Ranrot() & 255]]]];
|
||||
}
|
||||
|
||||
if (ship->scanClass <= CLASS_NO_DRAW)
|
||||
{
|
||||
[ship setScanClass: CLASS_NEUTRAL];
|
||||
}
|
||||
[ship setPosition:spawn_pos];
|
||||
[ship setOrientation:spawn_q];
|
||||
[self addEntity:ship];
|
||||
[[ship getAI] setState:@"GLOBAL"]; // must happen after adding to the universe!
|
||||
[ship setStatus:STATUS_IN_FLIGHT];
|
||||
if (![ship hasPrimaryRole:@"cargopod"]) // cargopod does not require release due to the way it is created.
|
||||
{
|
||||
[ship release];
|
||||
}
|
||||
[ship autorelease];
|
||||
}
|
||||
|
||||
return ship;
|
||||
}
|
||||
|
||||
|
||||
@ -2525,7 +2530,7 @@ GLfloat docked_light_specular[4] = { (GLfloat) 1.0, (GLfloat) 1.0, (GLfloat) 0.5
|
||||
[ring setVelocity:v];
|
||||
[ring setLifetime:i*50.0];
|
||||
[ring setScanClass: CLASS_NO_DRAW];
|
||||
[self addEntity:ring]; // [entities addObject:ring];
|
||||
[self addEntity:ring];
|
||||
breakPatternCounter++;
|
||||
[ring release];
|
||||
}
|
||||
@ -2667,12 +2672,18 @@ GLfloat docked_light_specular[4] = { (GLfloat) 1.0, (GLfloat) 1.0, (GLfloat) 0.5
|
||||
}
|
||||
|
||||
|
||||
static BOOL IsCandidateMainStationPredicate(Entity *entity, void *parameter)
|
||||
{
|
||||
return [entity isStation] && !entity->isExplicitlyNotMainStation;
|
||||
}
|
||||
|
||||
|
||||
- (StationEntity *) station
|
||||
{
|
||||
if (cachedStation == nil)
|
||||
{
|
||||
cachedStation = [self findOneEntityMatchingPredicate:HasScanClassPredicate
|
||||
parameter:[NSNumber numberWithInt:CLASS_STATION]];
|
||||
cachedStation = [self findOneEntityMatchingPredicate:IsCandidateMainStationPredicate
|
||||
parameter:nil];
|
||||
}
|
||||
return cachedStation;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user