missionScreen RFC part III

* yet more RFC bugfixes, there were quite a few not-quite-right bits, I _think_ I got all of them now...
* added titleKey as a mission.runScreen parameter, for use with missiontext.plist
* updated all internal missions to use the new mission API, some mission keys normalisation.
* fully tested & fixed both nova & trumbles missions.
* proper fix: no save when the sun is going nova!

git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@2759 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
Marc 2009-11-18 21:58:32 +00:00
parent f7affbc01a
commit 116d83f955
13 changed files with 189 additions and 198 deletions

View File

@ -31,7 +31,7 @@
);
},
"awardCredits: 1000",
"addMissionText: conhunt-thief-captured"
"addMissionText: constrictor_hunt_thief_captured"
);
}
);

View File

@ -1,6 +1,7 @@
{
// Constrictor Hunt mission (oolite-constrictor-hunt-mission.js)
"constrictor_hunt_title" = "Space Navy Mission";
"constrictor_hunt_0_150" = "“The constrictor was last seen at %J036, Commander.”";
"constrictor_hunt_0_28" = "“Yep, an unusual new ship had a galactic hyperdrive fitted here, used it too.”";
"constrictor_hunt_0_36" = "“A strange looking ship left here a while back. Looked bound for %J028.”";
@ -12,28 +13,29 @@
"constrictor_hunt_1_A" = "“I hear a weird looking ship was seen at %J253.”";
"constrictor_hunt_brief1" = "---INCOMING MESSAGE\n\nGreetings Commander,\n\nI am Captain Curruthers of Her Imperial Majestys Space Navy and I beg a moment of your valuable time. We would like you to do a little job for us.\nThe ship you see here is a new model, the Constrictor, equipped with a top secret new shield generator.\n\nUnfortunately its been stolen.\n";
"conhunt_short_desc1" = "Hunt for the Constrictor stolen from %J150.";
"conhunt_short_desc1b" = "Hunt for the Constrictor stolen from Xeer Shipyards.";
"constrictor_hunt_brief1a" = "It went missing from our ship yard on %J150 five months ago and was last seen at %J036. Your mission should you decide to accept it, is to seek and destroy this ship. You are cautioned that only Military Lasers will get through the new shields and that the Constrictor is fitted with an E.C.M. System.\n\nGood Luck, Commander.\n\n---MESSAGE ENDS.";
"constrictor_hunt_brief1b" = "It went missing from Xeer Shipyards five months ago and is believed to have jumped to this galaxy. Your mission should you decide to accept it, is to seek and destroy this ship. You are cautioned that only Military Lasers will get through the new shields and that the Constrictor is fitted with an E.C.M. System.\n\nGood Luck, Commander.\n\n---MESSAGE ENDS.";
"constrictor_hunt_info1a" = "Hunt for the Constrictor stolen from %J150.";
"constrictor_hunt_info1b" = "Hunt for the Constrictor stolen from Xeer Shipyards.";
"constrictor_hunt_debrief" = "---INCOMING MESSAGE\n\nCongratulations Commander!\n\nThere will always be a place for you in Her Imperial Majestys Space Navy.\n\nAnd maybe sooner than you think...\n\n---MESSAGE ENDS.";
"conhunt-thief-captured" = "You captured the thief who stole the constrictor! Her Imperial Navy awards you a bonus of 1000 credits!\n";
"constrictor_hunt_thief_captured" = "You captured the thief who stole the constrictor! Her Imperial Navy awards you a bonus of 1000 credits!\n";
// Thargoid Plans mission (oolite-thargoid-plans-mission.js)
"thargoid_plans_debrief" = "---INCOMING MESSAGE\n\nYou have served us well and we shall remember.\n\nWe did not expect the Thargoids to find out about you.\n\nFor the moment please accept this Navy Extra Energy Unit as payment.\n\n---MESSAGE ENDS.";
"thargoid_plans_intro_brief" = "---INCOMING MESSAGE\n\nAttention Commander, I am Captain Fortesque of Her Imperial Majestys Space Navy.\n\nWe have need of your services again.\n\nIf you would be so good as to go to %J083 you will be briefed.\n\nIf successful, you will be rewarded.\n\n---MESSAGE ENDS.";
"thargoid_plans_main_brief" = "---INCOMING MESSAGE\n\nGood Day Commander.\n\nI am Agent Blake of Naval Intelligence.\nAs you know, the Navy have been keeping the Thargoids off your ass out in deep space for many years now.\nWell the situation has changed. Our boys are ready for a push right to the home system of those murderers.\n\nI have obtained the defence plans for their Hive Worlds. The beetles know weve got something but not what. If I transmit the plans to our base on %J036 theyll intercept the transmission. I need a ship to make the run. Youre elected.\n\nThe plans are unipulse coded within this transmission. You will be paid.\n\nGood luck Commander.\n\n---MESSAGE ENDS.";
"thargplans_short_desc1" = "Go to %J083 for a briefing.";
"thargplans_short_desc2" = "Convey the secret plans to %J036.";
"thargoid_plans_title" = "Space Navy Mission";
"thargoid_plans_brief1" = "---INCOMING MESSAGE\n\nAttention Commander, I am Captain Fortesque of Her Imperial Majestys Space Navy.\n\nWe have need of your services again.\n\nIf you would be so good as to go to %J083 you will be briefed.\n\nIf successful, you will be rewarded.\n\n---MESSAGE ENDS.";
"thargoid_plans_brief2" = "---INCOMING MESSAGE\n\nGood Day Commander.\n\nI am Agent Blake of Naval Intelligence.\nAs you know, the Navy have been keeping the Thargoids off your ass out in deep space for many years now.\nWell the situation has changed. Our boys are ready for a push right to the home system of those murderers.\n\nI have obtained the defence plans for their Hive Worlds. The beetles know weve got something but not what. If I transmit the plans to our base on %J036 theyll intercept the transmission. I need a ship to make the run. Youre elected.\n\nThe plans are unipulse coded within this transmission. You will be paid.\n\nGood luck Commander.\n\n---MESSAGE ENDS.";
"thargoid_plans_info1" = "Go to %J083 for a briefing.";
"thargoid_plans_info2" = "Convey the secret plans to %J036.";
"thargoid_plans_debrief" = "---INCOMING MESSAGE\n\nYou have served us well and we shall remember.\n\nWe did not expect the Thargoids to find out about you.\n\nFor the moment please accept this Navy Extra Energy Unit as payment.\n\n---MESSAGE ENDS.";
// Nova mission (oolite-nova-mission.js)
"oolite_nova" = "Youve arrived at an unfortunate time, Commander.\n\nOur sun has become unstable and is due to go nova at any moment. All our ships are evacuating the system, the last few refugees have come here to find a ship to take them to safety.\n\nPlease, please help us to escape!";
"oolite_nova_title" = "Rescue Mission";
"oolite_nova_brief" = "Youve arrived at an unfortunate time, Commander.\n\nOur sun has become unstable and is due to go nova at any moment. All our ships are evacuating the system, the last few refugees have come here to find a ship to take them to safety.\n\nPlease, please help us to escape!";
"oolite_nova_info" = "Get the refugees to safety.";
"oolite_nova_hero" = "Commander, we thank you.\n\nYouve brought us all to safety but we have no money with which we can reward you\n- our last credits were taken by those who took us to the space station.\n\nInstead we offer you undying gratitude... and what few valuable possessions we can spare.\n\nYou are our hero!";
"oolite_nova_short_desc" = "Get the refugees to safety.";
"oolite_nova_disappointed" = "Commander, you should be ashamed.\nThose people you left behind had laid their hopes on you and you just left them to their fate.\n\nYour behaviour has been that of a coward.";
"oolite_nova_ignored" = "Commander,\n you were the last hope for survivival for the remaining refugees. If you hadnt\nignored the emergency, they could have escaped the nova explosion.\n\nHow could you abandon them to their fate...";
"oolite_nova_yesno" =
@ -45,6 +47,7 @@
// Trumbles mission (oolite-trumbles-mission.js)
"oolite_trumble_title" = "Special Offer";
"oolite_trumble_offer" = "Commander [commander_name],\n\nYou look like someone who could use a Trumble on your [commander_shipdisplayname]!\n\nThis is yours for only 30 credits.";
"oolite_trumble_offer_yesno" =
{

View File

@ -36,6 +36,16 @@ this.copyright = "© 20082009 the Oolite team.";
this.version = "1.74";
this.cleanUp = function ()
{
// Remove event handlers.
delete this.guiScreenChanged;
delete this.missionScreenOpportunity;
delete this.shipExitedWitchspace;
delete this.shipLaunchedFromStation;
};
this.addToScreen = function ()
{
if (guiScreen === "GUI_SCREEN_SYSTEM_DATA")
@ -91,36 +101,36 @@ this.addToScreen = function ()
this.missionOffers = function ()
{
if (guiScreen === "GUI_SCREEN_MISSION" || guiScreen === "GUI_SCREEN_REPORT" || (mission.choice && mission.choice !== "") || !player.ship.docked) { return; }
{
if (!player.ship.docked) { return; }
// Choices are handled inside the missionScreenEnded and missionChoiceWasReset events.
if (player.ship.dockedStation.isMainStation)
{
if (galaxyNumber < 2 && !missionVariables.conhunt && player.score > 255)
{
mission.runMissionScreen("constrictor_hunt_brief1", null, null, "constrictor");
// there are no options to deal with, we don't need a callback function.
mission.runScreen({titleKey:"constrictor_hunt_title", messageKey:"constrictor_hunt_brief1", model: "constrictor"}, null);
if (galaxyNumber === 0)
{
mission.addMessageTextKey("constrictor_hunt_brief1a"); // galaxy = 0
mission.setInstructionsKey("conhunt_short_desc1");
mission.setInstructionsKey("constrictor_hunt_info1a");
}
else
{
mission.addMessageTextKey("constrictor_hunt_brief1b"); // galaxy = 1
mission.setInstructionsKey("conhunt_short_desc1b");
mission.setInstructionsKey("constrictor_hunt_info1b");
}
missionVariables.conhunt = "STAGE_1";
// mission.setInstructionsKey("conhunt_short_desc1");
}
if (missionVariables.conhunt === "CONSTRICTOR_DESTROYED") // Variable is set by the ship-script
if (missionVariables.conhunt === "CONSTRICTOR_DESTROYED") // Variable is set by the ship script
{
mission.runMissionScreen("constrictor_hunt_debrief", null, null, "constrictor");
mission.runScreen({titleKey:"constrictor_hunt_title", messageKey:"constrictor_hunt_debrief", model: "constrictor"}, null);
player.credits += 5000;
player.bounty = 0; // legal status
player.score += 256; // ship kills
mission.setInstructionsKey(null); // reset the missionbriefing
mission.setInstructionsKey(null); // reset the mission briefing
missionVariables.conhunt = "MISSION_COMPLETE";
this.cleanUp();
}
}
};
@ -140,6 +150,14 @@ this.setUpShips = function ()
/**** Event handlers ****/
this.startUp = function ()
{
// Remove event handlers once the mission is over.
if (missionVariables.conhunt === "MISSION_COMPLETE") { this.cleanUp(); }
};
this.guiScreenChanged = function ()
{
if (galaxyNumber < 2 && missionVariables.conhunt === "STAGE_1")
@ -149,19 +167,13 @@ this.guiScreenChanged = function ()
};
this.shipDockedWithStation = function ()
// this function is potentially called multiple times
this.missionScreenOpportunity = function ()
{
this.missionOffers();
};
this.missionScreenEnded = this.reportScreenEnded = this.missionChoiceWasReset = function ()
{
if (!player.ship.docked) { return; }
this.missionOffers();
};
this.shipExitedWitchspace = this.shipLaunchedFromStation = function ()
{
this.setUpShips();

View File

@ -61,9 +61,9 @@ Ship.__proto__.spawnOne = function (role)
// mission.setInstructionsKey(): load mission text from mission.plist and use it as mission instructions.
mission.setInstructionsKey = function(textKey)
mission.setInstructionsKey = function(textKey, missionKey)
{
mission.setInstructions(expandMissionText(textKey));
mission.setInstructions(expandMissionText(textKey), missionKey);
}
@ -254,6 +254,6 @@ mission.runMissionScreen = function (_messageKey, _backgroundImage, _choiceKey,
{
special.jsWarning("Mission.runMissionScreen() is deprecated, use Mission.runScreen() instead.");
// pre-1.74 mission.setBackgroundImage did set the foreground (foremost background image (!)
mission.runScreen({music:_musicKey, showModel:_shipKey, choicesKey:_choiceKey, foreground:_backgroundImage, messageKey:_messageKey}, null);
mission.runScreen({music:_musicKey, model:_shipKey, choicesKey:_choiceKey, foreground:_backgroundImage, messageKey:_messageKey}, null);
};

View File

@ -36,17 +36,11 @@ this.copyright = "© 2009 the Oolite team.";
this.version = "1.74";
this.startUp = function ()
{
if (missionVariables.nova && missionVariables.nova === "NOVA_HERO") this.cleanUp();
}
this.missionOffers = function ()
{
if (guiScreen === "GUI_SCREEN_MISSION" || guiScreen === "GUI_SCREEN_REPORT" || (mission.choice && mission.choice !== "") || !player.ship.docked) { return; }
if (!player.ship.docked) { return; }
// Choices are handled inside the missionScreenEnded and missionChoiceWasReset events.
// Choices are handled inside this.choiceEvaluation.
if (player.ship.dockedStation.isMainStation)
{
if (galaxyNumber === 3)
@ -54,8 +48,7 @@ this.missionOffers = function ()
if (!missionVariables.nova && !missionVariables.novacount) { missionVariables.novacount = 0; }
if (missionVariables.nova === "TWO_HRS_TO_ZERO")
{
mission.runMissionScreen("oolite_nova", "solar.png", "oolite_nova_yesno");
this.novaOffer = "NOVA_CHOICE"; // use a temporary variable for the offering.
mission.runScreen({titleKey:"oolite_nova_title", messageKey:"oolite_nova_brief", background:"solar.png", choicesKey:"oolite_nova_yesno"}, this.choiceEvaluation);
this.novaMissionTimer.stop();
}
}
@ -64,26 +57,26 @@ this.missionOffers = function ()
if (missionVariables.nova === "NOVA_ESCAPED_SYSTEM")
{
player.ship.removeAllCargo();
player.ship.awardCargo("Gem-Stones", 100);
mission.runMissionScreen("oolite_nova_hero", "solar.png");
mission.runScreen({titleKey:"oolite_nova_title", messageKey:"oolite_nova_hero", background:"solar.png"}, null);
player.ship.manifest["Gem-Stones"] += 100;
this.endTheMission();
}
else if (missionVariables.nova === "NOVA_ESCAPE_POD")
{
player.ship.removeAllCargo(); // can only be done while docked.
mission.runMissionScreen("oolite_nova_disappointed", "solar.png");
mission.runScreen({titleKey:"oolite_nova_title", messageKey:"oolite_nova_disappointed", background:"solar.png"}, null);
this.endTheMission();
}
else if (missionVariables.nova === "NOVA_ESCAPE_OTHER")
{
mission.runMissionScreen("oolite_nova_ignored", "solar.png");
mission.runScreen({titleKey:"oolite_nova_title", messageKey:"oolite_nova_ignored", background:"solar.png"}, null);
this.endTheMission();
}
else if (missionVariables.nova === "NOVA_ESCAPE_COWARD" && !system.sun.isGoingNova && !system.sun.hasGoneNova)
{
player.decreaseContractReputation();
player.decreasePassengerReputation();
mission.runMissionScreen("oolite_nova_disappointed", "solar.png");
mission.runScreen({titleKey:"oolite_nova_title", messageKey:"oolite_nova_disappointed", background:"solar.png"}, null);
this.endTheMission();
}
}
@ -99,7 +92,7 @@ this.missionOffers = function ()
this.endTheMission = function()
{
missionVariables.nova = "NOVA_HERO"; // even if not a hero, scripts expect this string at mission end.
missionVariables.nova = "NOVA_HERO"; // even if not a hero, other scripts expect this string at mission end.
mission.setInstructionsKey(null);
this.cleanUp();
}
@ -111,56 +104,34 @@ this.cleanUp = function()
// this.shipExitedWitchspace is still needed after the nova mission.
delete this.shipWillEnterWitchspace;
delete this.shipWillExitWitchspace;
delete this.shipDockedWithStation;
delete this.missionScreenEnded;
delete this.reportScreenEnded;
delete this.missionChoiceWasReset;
delete this.missionScreenOpportunity;
delete this.shipLaunchedEscapePod;
// after the mission is over, we don't need the following functions.
delete this.missionOffers;
delete this.choiceEvaluation;
delete this.sendShipsAwayForMission;
delete this.shipLaunchedFromStation;
}
this.choiceEvaluation = function()
this.choiceEvaluation = function(choice)
{
if (this.novaOffer && this.novaOffer === "NOVA_CHOICE")
if (choice === "YES")
{
if (mission.choice === "YES")
{
player.ship.useSpecialCargo(expandDescription("[oolite-nova-refugees]"));
mission.setInstructionsKey("oolite_nova_short_desc");
missionVariables.nova = "NOVA_ESCAPE_HERO";
player.ship.launch();
this.blowUpAllStations();
system.sun.goNova(30);
missionVariables.novacount = null;
}
else
{
// mission.choice == "NO", or null when player launched without a choice.
missionVariables.nova = "NOVA_ESCAPE_COWARD";
player.commsMessage(expandDescription("[oolite-nova-coward]"), 4.5);
system.sun.goNova(10);
missionVariables.novacount = null;
}
/* IMPORTANT
The line "mission.choice = null" causes a missionChoiceWasReset()
event to occur. Our missionChoiceWasReset() handler calls back into
choiceEvaluation(). It is therefore imperative that this.novaOffer
is cleared _before_ mission.choice, or we end up in the else branch
above.
*/
delete this.novaOffer;
mission.choice = null;
player.ship.useSpecialCargo(expandDescription("[oolite-nova-refugees]"));
mission.setInstructionsKey("oolite_nova_info");
missionVariables.nova = "NOVA_ESCAPE_HERO";
player.ship.launch();
this.blowUpAllStations();
system.sun.goNova(30);
}
else
{
// mission.choice == "NO", or null when player launched without making a choice.
missionVariables.nova = "NOVA_ESCAPE_COWARD";
player.commsMessage(expandDescription("[oolite-nova-coward]"), 4.5);
system.sun.goNova(10);
}
missionVariables.novacount = null;
};
// used when player enters nova system during nova mission.
this.sendShipsAwayForMission = function()
{
@ -242,8 +213,17 @@ this.flareChange = function(toValue,callFunc,callDelay,pass)
}
}
/**** Event handlers ****/
this.startUp = function ()
{
// Remove all event handlers once the mission is over.
if (missionVariables.nova === "NOVA_HERO") { this.cleanUp(); }
}
this.shipLaunchedEscapePod = function ()
{
if (missionVariables.nova === "NOVA_ESCAPED_SYSTEM")
@ -253,22 +233,12 @@ this.shipLaunchedEscapePod = function ()
};
this.shipDockedWithStation = function ()
this.missionScreenOpportunity = function ()
{
this.missionOffers();
};
this.missionScreenEnded = this.reportScreenEnded = this.missionChoiceWasReset = function ()
{
this.choiceEvaluation();
if (player.ship.docked)
{
this.missionOffers();
}
};
this.shipWillEnterWitchspace = function ()
{
if (this.willGoNova)
@ -312,6 +282,13 @@ this.shipWillExitWitchspace = function () // call this as soon as possible so o
}
};
this.shipLaunchedFromStation = function()
{
if ((system.sun.isGoingNova || system.sun.hasGoneNova) && missionVariables.nova === "NOVA_ESCAPE_COWARD")
{
this.blowUpAllStations();
}
}
this.shipExitedWitchspace = function()
{

View File

@ -38,8 +38,8 @@ this.version = "1.74";
this.missionOffers = function ()
{
if (guiScreen === "GUI_SCREEN_MISSION" || guiScreen === "GUI_SCREEN_REPORT" || (mission.choice && mission.choice !== "") || !player.ship.docked) { return; }
// there will be a "missionScreenEnded" or a "missionChoiceWasReset" in future to react to.
if (!player.ship.docked) { return; }
if (player.ship.dockedStation.isMainStation)
{
if (galaxyNumber === 2)
@ -49,38 +49,37 @@ this.missionOffers = function ()
player.score > 1280 &&
system.ID !== 83)
{
mission.runMissionScreen("thargoid_plans_intro_brief");
mission.runScreen({titleKey:"thargoid_plans_title", messageKey:"thargoid_plans_brief1"}, null);
missionVariables.thargplans = "PRELUDE";
mission.setInstructionsKey("thargplans_short_desc1");
mission.setInstructionsKey("thargoid_plans_info1");
mission.markSystem(83);
}
else if (missionVariables.thargplans === "PRELUDE" &&
system.ID === 83)
{
mission.unmarkSystem(83);
mission.runMissionScreen("thargoid_plans_main_brief", null, null, "thargoid");
mission.runScreen({titleKey:"thargoid_plans_title", messageKey:"thargoid_plans_brief2", model: "thargoid"}, null);
missionVariables.thargplans = "RUNNING";
mission.setInstructionsKey("thargplans_short_desc2");
mission.setInstructionsKey("thargoid_plans_info2");
mission.markSystem(36);
}
else if (missionVariables.thargplans === "RUNNING" &&
system.ID === 36)
{
mission.runMissionScreen("thargoid_plans_debrief", null, null, "thargoid");
mission.runScreen({titleKey:"thargoid_plans_title", messageKey:"thargoid_plans_debrief", model: "thargoid"}, null);
player.score += 256; // ship kills
mission.setInstructionsKey(null); // reset the missionbriefing
missionVariables.thargplans = "MISSION_COMPLETE";
if (player.ship.hasEquipment("EQ_ENERGY_UNIT"))
// for backward compatibility, hasEquipment doesn't check the damaged version.
if (player.ship.hasEquipment("EQ_ENERGY_UNIT") || player.ship.hasEquipment("EQ_ENERGY_UNIT_DAMAGED"))
{
// remove the specified equipment, either working or damaged version.
player.ship.removeEquipment("EQ_ENERGY_UNIT");
}
else if (player.ship.hasEquipment("EQ_ENERGY_UNIT_DAMAGED"))
{
player.ship.removeEquipment("EQ_ENERGY_UNIT_DAMAGED");
}
player.ship.awardEquipment("EQ_NAVAL_ENERGY_UNIT");
EquipmentInfo.infoForKey("EQ_NAVAL_ENERGY_UNIT").effectiveTechLevel = 13;
mission.unmarkSystem(36);
this.cleanUp();
}
}
}
@ -123,26 +122,31 @@ this.setUpShips = function ()
};
this.cleanUp = function()
{
// Remove event handlers.
delete this.missionScreenOpportunity;
delete this.shipLaunchedFromStation;
delete this.shipExitedWitchspace;
}
/**** Event handlers ****/
this.startUp = this.reset = function ()
this.startUp = function ()
{
this.loopcount = 0; // should be zero on the first launch after a reset.
if (missionVariables.thargplans === "MISSION_COMPLETE") { this.cleanUp(); }
};
this.shipDockedWithStation = function ()
this.missionScreenOpportunity = function ()
{
this.missionOffers();
};
this.missionScreenEnded = this.reportScreenEnded = this.missionChoiceWasReset = function ()
{
if (!player.ship.docked) { return; }
this.missionOffers();
};
this.shipLaunchedFromStation = function ()
{
this.setUpShips();

View File

@ -37,7 +37,7 @@ this.description = "Random offers of trumbles.";
this.version = "1.74";
this.startUp = this.reset = function ()
this.startUp = function ()
{
/* For simplicity, ensure that missionVariables.trumbles is never
undefined when running the rest of the script. If it could be
@ -52,7 +52,7 @@ this.startUp = this.reset = function ()
};
this.shipDockedWithStation = function ()
this.missionScreenOpportunity = function ()
{
if (!player.ship.docked) { return; } // Player might have been forcibly undocked by another script.
@ -76,41 +76,28 @@ this.shipDockedWithStation = function ()
missionVariables.trumbles = "BUY_ME";
}
if (missionVariables.trumbles === "BUY_ME" && player.trumbleCount === 0)
if (missionVariables.trumbles === "BUY_ME" && player.trumbleCount === 0 &&
Math.random() < 0.2) // 20% chance of trumble being offered.
{
// 20% chance of trumble being offered, if no other script got this dock session first.
if (guiScreen === "GUI_SCREEN_STATUS" &&
Math.random() < 0.2)
{
// Show the mission screen.
mission.runMissionScreen("oolite_trumble_offer", "trumblebox.png", "oolite_trumble_offer_yesno");
}
// Show the mission screen
mission.runScreen({titleKey:"oolite_trumble_title", messageKey:"oolite_trumble_offer", background:"trumblebox.png", choicesKey:"oolite_trumble_offer_yesno"}, this.trumbleOffered);
}
};
this.missionScreenEnded = function ()
this.trumbleOffered = function(choice)
{
if (missionVariables.trumbles === "BUY_ME")
if (choice == "OOLITE_TRUMBLE_YES")
{
// Could have been trumble mission screen.
if (mission.choice === "OOLITE_TRUMBLE_YES")
{
// Trumble bought.
missionVariables.trumbles = "TRUMBLE_BOUGHT";
mission.choice = null;
player.credits -= 30;
player.ship.awardEquipment("EQ_TRUMBLE");
}
else if (mission.choice === "OOLITE_TRUMBLE_NO")
{
// Trumble bought.
missionVariables.trumbles = "NOT_NOW";
mission.choice = null;
}
// else it was someone else's mission screen, so we do nothing.
missionVariables.trumbles = "TRUMBLE_BOUGHT";
player.credits -= 30;
player.ship.awardEquipment("EQ_TRUMBLE");
}
};
else
{
missionVariables.trumbles = "NOT_NOW";
}
}
this.shipWillExitWitchspace = function ()

View File

@ -3994,24 +3994,21 @@ static PlayerEntity *sSharedPlayer = nil;
[self doScriptEvent:@"shipDockedWithStation" withArgument:dockedStation];
// If the player is fined, it shows the fine on screen. If a mission
// screen is started, the on-screen message is removed immediately.
// fines need to be applied before mission screens.
if (gui_screen != GUI_SCREEN_MISSION && [dockingReport length] == 0)
{
if (being_fined) [self getFined];
[self doWorldEventUntilMissionScreen:@"missionScreenOpportunity"];
}
// if we've not switched to the mission screen yet then proceed normally..
if (gui_screen != GUI_SCREEN_MISSION)
{
// apply any pending fines, if not done above.
if (being_fined && [dockingReport length] != 0) [self getFined];
if (being_fined) [self getFined];
[self setGuiToStatusScreen]; // also displays docking reports if needed.
}
[[OOCacheManager sharedCache] flush];
// If we're showing the report screen, we don't want to do anything now.
if (gui_screen != GUI_SCREEN_REPORT)
{
// When a mission screen is started, any on-screen message is removed immediately.
[self doWorldEventUntilMissionScreen:@"missionScreenOpportunity"];
}
}
@ -5123,7 +5120,7 @@ static PlayerEntity *sSharedPlayer = nil;
{
if (dockedStation == nil)
dockedStation = [UNIVERSE station];
canLoadOrSave = (dockedStation == [UNIVERSE station] && ![[UNIVERSE sun] goneNova]);
canLoadOrSave = (dockedStation == [UNIVERSE station] && !([[UNIVERSE sun] goneNova] || [[UNIVERSE sun] willGoNova]));
}
BOOL canQuickSave = (canLoadOrSave && ([[gameView gameController] playerFileToLoad] != nil));

View File

@ -33,6 +33,7 @@ MA 02110-1301, USA.
#import "ShipEntityAI.h"
#import "StationEntity.h"
#import "Universe.h"
#import "PlanetEntity.h"
#import "GameController.h"
#import "AI.h"
#import "MyOpenGLView.h"
@ -2989,7 +2990,7 @@ static BOOL toggling_music;
if (!dockedStation) dockedStation = [UNIVERSE station];
station = dockedStation; // leaveDock will clear dockedStation.
if (station == [UNIVERSE station] && [UNIVERSE autoSaveNow] && ![[UNIVERSE generateSystemData:system_seed] oo_boolForKey:@"sun_gone_nova"]) [self autosavePlayer];
if (station == [UNIVERSE station] && [UNIVERSE autoSaveNow] && !([[UNIVERSE sun] goneNova] || [[UNIVERSE sun] willGoNova])) [self autosavePlayer];
// autosave at the second launch after load / restart
if ([UNIVERSE autoSave]) [UNIVERSE setAutoSaveNow:YES];
[self leaveDock:dockedStation];
@ -3083,11 +3084,12 @@ static BOOL toggling_music;
[UNIVERSE removeDemoShips];
[gui clearBackground];
[[OOMusicController sharedController] stopMissionMusic];
[self setGuiToStatusScreen]; // some js actions require this to be set first.
if (_missionWithCallback)
{
[self doMissionCallback];
}
[self setGuiToStatusScreen];
[self setGuiToStatusScreen]; // we need to provide feedback when something changes inside the callback.
[self endMissionScreenAndNoteOpportunity];
}
spacePressed = YES;
@ -3140,11 +3142,12 @@ static BOOL toggling_music;
[gui clearBackground];
[[OOMusicController sharedController] stopMissionMusic];
[self playDismissedMissionScreen];
[self setGuiToStatusScreen]; // enable some js commands
if (_missionWithCallback)
{
[self doMissionCallback];
}
[self setGuiToStatusScreen];
[self setGuiToStatusScreen]; // enable feedback
[self endMissionScreenAndNoteOpportunity];
[self checkScript];
}

View File

@ -2131,7 +2131,7 @@ static int scriptRandomSeed = -1; // ensure proper random function
- (void) launchFromStation
{
// ensure autosave is ready
// ensure autosave is ready for the next unscripted launch
if ([UNIVERSE autoSave]) [UNIVERSE setAutoSaveNow:YES];
[self leaveDock:dockedStation];
}

View File

@ -995,8 +995,13 @@ OOINLINE BOOL RowInRange(OOGUIRow row, NSRange range)
glEnd();
}
// show foremost background image...
// show background images...
//
// dim background image fix
if (![[PlayerEntity sharedPlayer] showDemoShips] && backgroundSprite!=nil)
{
[backgroundSprite blitCentredToX:x + 0.5f * size_in_pixels.width Y:y + 0.5f * size_in_pixels.height Z:z alpha:alpha];
}
if (foregroundSprite!=nil)
{

View File

@ -29,6 +29,8 @@ MA 02110-1301, USA.
#import "OOJSPlayer.h"
#import "PlayerEntityScriptMethods.h"
#import "OOStringParsing.h"
#import "OOCollectionExtractors.h"
static JSBool MissionGetProperty(JSContext *context, JSObject *this, jsval name, jsval *outValue);
@ -48,7 +50,6 @@ static JSBool MissionRunScreen(JSContext *context, JSObject *this, uintN argc, j
// Mission screen callback varibables
static jsval callbackFunction;
static JSObject *callbackThis;
static OOJSScript *callbackScript;
static JSClass sMissionClass =
@ -74,7 +75,7 @@ enum
kMission_title, // title of mission screen, string.
kMission_foreground, // missionforeground image, string.
kMission_background, // mission background image, string.
kMission_showModel, // mission 'ship' model role, string.
kMission_3DModel, // mission 3D model: role, string.
};
@ -82,10 +83,6 @@ static JSPropertySpec sMissionProperties[] =
{
// JS name ID flags
{ "choice", kMission_choice, JSPROP_PERMANENT | JSPROP_ENUMERATE },
//{ "title", kMission_title, JSPROP_PERMANENT | JSPROP_ENUMERATE },
//{ "foregroundImage", kMission_foreground, JSPROP_PERMANENT | JSPROP_ENUMERATE },
//{ "backgroundImage", kMission_background, JSPROP_PERMANENT | JSPROP_ENUMERATE },
//{ "shipModel", kMission_shipModel, JSPROP_PERMANENT | JSPROP_ENUMERATE },
{ 0 }
};
@ -118,7 +115,7 @@ void MissionRunCallback()
{
jsval argval = JSVAL_VOID;
jsval rval = JSVAL_VOID;
JSContext *context = [[OOJavaScriptEngine sharedEngine] acquireContext];
jsval function = callbackFunction;
// don't do anything if we don't have a function, or script.
if(JSVAL_IS_NULL(callbackFunction) || [callbackScript weakRefUnderlyingObject] == nil)
@ -126,17 +123,18 @@ void MissionRunCallback()
return;
}
callbackFunction = JSVAL_NULL;
JSContext *context = [[OOJavaScriptEngine sharedEngine] acquireContext];
argval = [[OOPlayerForScripting() missionChoice_string] javaScriptValueInContext:context];
[OOJSScript pushScript:callbackScript];
[[OOJavaScriptEngine sharedEngine] callJSFunction:callbackFunction
forObject:callbackThis
[[OOJavaScriptEngine sharedEngine] callJSFunction:function
forObject:JSVAL_TO_OBJECT([callbackScript javaScriptValueInContext:context])
argc:1
argv:&argval
result:&rval];
[OOJSScript popScript:callbackScript];
[[OOJavaScriptEngine sharedEngine] releaseContext:context];
callbackFunction = JSVAL_NULL;
}
@ -157,13 +155,6 @@ static JSBool MissionGetProperty(JSContext *context, JSObject *this, jsval name,
if (result == nil) result = [NSNull null];
break;
case kMission_title:
case kMission_foreground:
case kMission_background:
case kMission_showModel:
result = [NSNull null];
break;
default:
OOReportJSBadPropertySelector(context, @"Mission", JSVAL_TO_INT(name));
return NO;
@ -198,15 +189,15 @@ static JSBool MissionSetProperty(JSContext *context, JSObject *this, jsval name,
[player setMissionImage:JSValToNSString(context,*value)];
break;
case kMission_3DModel:
// If value can't be converted to a string this will clear the entity (ship) model.
[player showShipModel:JSValToNSString(context, *value)];
break;
case kMission_background:
// If value can't be converted to a string this will clear the background image.
[player setMissionBackground:JSValToNSString(context,*value)];
break;
case kMission_showModel:
// If value can't be converted to a string this will clear the entity (ship) model.
[player showShipModel:JSValToNSString(context, *value)];
break;
default:
OOReportJSBadPropertySelector(context, @"Mission", JSVAL_TO_INT(name));
@ -368,6 +359,7 @@ static JSBool MissionClearMissionScreen(JSContext *context, JSObject *this, uint
{
PlayerEntity *player = OOPlayerForScripting();
OOReportJSWarning(context, @"Mission.%@ is deprecated and will be removed in a future version of Oolite.", @"clearMissionScreen");
[player clearMissionScreen];
return YES;
}
@ -403,8 +395,19 @@ static JSBool MissionRunScreen(JSContext *context, JSObject *this, uintN argc, j
}
str=@"title";
if (JS_GetProperty(context, params, [str UTF8String], &value))
if (JS_GetProperty(context, params, [str UTF8String], &value)&& !JSVAL_IS_NULL(value) && !JSVAL_IS_VOID(value))
MissionSetProperty(context, this, INT_TO_JSVAL(kMission_title), &value);
else
{
str=@"titleKey";
if (JS_GetProperty(context, params, [str UTF8String], &value))
{
str = [[UNIVERSE missiontext] oo_stringForKey:JSValToNSString(context, value)];
str = ExpandDescriptionForCurrentSystem(str);
str = [player replaceVariablesInString:str];
[player setMissionTitle:str];
}
}
str=@"music";
if (JS_GetProperty(context, params, [str UTF8String], &value))
@ -414,9 +417,9 @@ static JSBool MissionRunScreen(JSContext *context, JSObject *this, uintN argc, j
if (JS_GetProperty(context, params, [str UTF8String], &value) && !JSVAL_IS_NULL(value) && !JSVAL_IS_VOID(value))
MissionSetProperty(context, this, INT_TO_JSVAL(kMission_foreground), &value);
str=@"showModel";
str=@"model";
if (JS_GetProperty(context, params, [str UTF8String], &value))
MissionSetProperty(context, this, INT_TO_JSVAL(kMission_showModel), &value);
MissionSetProperty(context, this, INT_TO_JSVAL(kMission_3DModel), &value);
str=@"background";
if (JS_GetProperty(context, params, [str UTF8String], &value))
@ -426,13 +429,8 @@ static JSBool MissionRunScreen(JSContext *context, JSObject *this, uintN argc, j
[player setGuiToMissionScreenWithCallback:!JSVAL_IS_NULL(function)];
if (!JSVAL_IS_NULL(function))
{
callbackThis = this;
callbackScript = [[OOJSScript currentlyRunningScript] weakRetain];
}
str=@"choicesKey";
if (JS_GetProperty(context, params, [str UTF8String], &value))
MissionSetChoicesKey(context, this, 1, &value, &noWarning);
str=@"message";
if (JS_GetProperty(context, params, [str UTF8String], &value) && !JSVAL_IS_NULL(value) && !JSVAL_IS_VOID(value))
@ -444,6 +442,10 @@ static JSBool MissionRunScreen(JSContext *context, JSObject *this, uintN argc, j
[player addMissionText: JSValToNSString(context, value)];
}
str=@"choicesKey";
if (JS_GetProperty(context, params, [str UTF8String], &value))
MissionSetChoicesKey(context, this, 1, &value, &noWarning);
// now clean up!
value = JSVAL_NULL;
MissionSetProperty(context, this, INT_TO_JSVAL(kMission_foreground), &value);

View File

@ -3584,7 +3584,8 @@ static const OOMatrix starboard_matrix =
OOGL(gluLookAt(view_dir.x, view_dir.y, view_dir.z, 0.0, 0.0, 0.0, view_up.x, view_up.y, view_up.z));
// needs to be here, otherwise it's drawn over the demo ship(s)
if (displayGUI) [gui drawGUIBackground];
// dim background image fix
if (displayGUI && inGUIMode) [gui drawGUIBackground];
if (!displayGUI || inGUIMode)
{