Trouble with Trumbles in windows trunk 1.75.04324
Moderators: winston, another_commander, Getafix
- Okti
- ---- E L I T E ----
- Posts: 700
- Joined: Sun Sep 26, 2010 1:51 pm
- Location: A GH shop, near witchpoint to Oresrati in Galaxy 8
Trouble with Trumbles in windows trunk 1.75.04324
I just downloaded nighty build of the trunk. And started to play assassins.OXP. You know there is a long series of mission screens in rebel outpost. Before I can finalize the mission screen trouble with trumbles begins, and when I say no series of the mission screens interrupts and I can not proceed to the next stage.
Okti
Okti
- JensAyton
- Grand Admiral Emeritus
- Posts: 6657
- Joined: Sat Apr 02, 2005 2:43 pm
- Location: Sweden
- Contact:
Re: Trouble with Trumbles in windows trunk 1.75.04324
Mission scripts in legacy scripts (such as used by Assassins) are highly problematic. Merely ensuring that only one mission screen is shown at a time, instead of bits of different ones, was a problem. Eric solved this with his “mission offering protocol”, but I’m not sure whether that dealt with chained mission screens. Eric?
(For reference, this is fixed in the JavaScript mission screen system introduced in 1.74.)
That said, the particular case of the trumble mission should be fixable by deciding whether to offer trumbles once on docking, instead of every mission screen opportunity.
(For reference, this is fixed in the JavaScript mission screen system introduced in 1.74.)
That said, the particular case of the trumble mission should be fixable by deciding whether to offer trumbles once on docking, instead of every mission screen opportunity.
E-mail: [email protected]
- Okti
- ---- E L I T E ----
- Posts: 700
- Joined: Sun Sep 26, 2010 1:51 pm
- Location: A GH shop, near witchpoint to Oresrati in Galaxy 8
Re: Trouble with Trumbles in windows trunk 1.75.04324
I think it might be an idea to make the offer only in main stations.
Okti
Okti
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
Re: Trouble with Trumbles in windows trunk 1.75.04324
The method should work for chained ones. I even had a private version of assassains.oxp were this was dealt with. But as fas as I remember did little bear only checks for existing missionscreens by other oxps at the main station in the assumption that no oxp would create mission screens at custom stations.Ahruman wrote:Mission scripts in legacy scripts (such as used by Assassins) are highly problematic. Merely ensuring that only one mission screen is shown at a time, instead of bits of different ones, was a problem. Eric solved this with his “mission offering protocol”, but I’m not sure whether that dealt with chained mission screens. Eric?
UPS-Courier & DeepSpacePirates & others at the box and some older versions
- JensAyton
- Grand Admiral Emeritus
- Posts: 6657
- Joined: Sat Apr 02, 2005 2:43 pm
- Location: Sweden
- Contact:
Re: Trouble with Trumbles in windows trunk 1.75.04324
The trumbles mission already only offers in main stations.Okti wrote:I think it might be an idea to make the offer only in main stations.
E-mail: [email protected]
- Okti
- ---- E L I T E ----
- Posts: 700
- Joined: Sun Sep 26, 2010 1:51 pm
- Location: A GH shop, near witchpoint to Oresrati in Galaxy 8
Re: Trouble with Trumbles in windows trunk 1.75.04324
Code: Select all
this.missionScreenOpportunity = function ()
{
/* In the pre-JavaScript implementation, the mission variable was set to
OFFER_MADE while the mission screen was shown. If the player lanched
in that state, the offer would never be made again -- unless some
other script used the mission choice keys "YES" or "NO". This
implementation uses unique choice keys and doesn't change the mission
variable, which should be more reliable in all cases.
*/
if (missionVariables.trumbles === "OFFER_MADE")
{
missionVariables.trumbles = "BUY_ME";
}
if (player.ship.dockedStation.isMainStation &&
!missionVariables.trumbles &&
!missionVariables.novacount && // So the offers eventually stop for long-time players who keep refusing.
player.credits > 6553.5)
{
missionVariables.trumbles = "BUY_ME";
}
[color=#80FF40] if (missionVariables.trumbles === "BUY_ME" &&[/color] player.trumbleCount === 0 &&
Math.random() < 0.2) // 20% chance of trumble being offered.
{
// Show the mission screen.
mission.runScreen({
titleKey: "oolite_trumble_title",
messageKey: "oolite_trumble_offer",
background: "trumblebox.png",
choicesKey: "oolite_trumble_offer_yesno"
},
function (choice)
{
if (choice === "OOLITE_TRUMBLE_YES")
{
missionVariables.trumbles = "TRUMBLE_BOUGHT";
player.credits -= 30;
player.ship.awardEquipment("EQ_TRUMBLE");
}
else
{
missionVariables.trumbles = "NOT_NOW";
}
});
}
};
this.shipWillExitWitchspace = function ()
{
// If player has rejected a trumble offer, reset trumble mission with 2% probability per jump.
if (missionVariables.trumbles === "NOT_NOW" && Math.random() < 0.02)
{
missionVariables.trumbles = "BUY_ME";
}
};
Okti
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
Re: Trouble with Trumbles in windows trunk 1.75.04324
Not quit so. It is only thevery first "BUY_ME" that is set at main stations when no mission_trumbles was defined. After that the variable is set exiting Witchspace and can trigger at any station. Re-looking at the code i see thatAhruman wrote:The trumbles mission already only offers in main stations.Okti wrote:I think it might be an idea to make the offer only in main stations.
Code: Select all
!missionVariables.novacount && // So the offers eventually stop for long-time players who keep refusing.
EDIT ninja.
UPS-Courier & DeepSpacePirates & others at the box and some older versions
- JensAyton
- Grand Admiral Emeritus
- Posts: 6657
- Joined: Sat Apr 02, 2005 2:43 pm
- Location: Sweden
- Contact:
Re: Trouble with Trumbles in windows trunk 1.75.04324
Proposed new script. This one only offers once per station, and only in main stations (double-checked, even).
Code: Select all
/*
oolite-trumbles-mission.js
Script for random offers of trumbles.
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.
*/
/*jslint white: true, undef: true, eqeqeq: true, bitwise: true, regexp: true, newcap: true, immed: true */
/*global guiScreen, mission, missionVariables, player*/
"use strict";
this.name = "oolite-trumbles";
this.author = "Jens Ayton";
this.copyright = "© 2008-2011 the Oolite team.";
this.description = "Random offers of trumbles.";
this.version = "1.75";
(function () {
var pendingOffer = false;
this.startUp = function startUp()
{
/* In the pre-JavaScript implementation, the mission variable was set to
OFFER_MADE while the mission screen was shown. If the player lanched
in that state, the offer would never be made again -- unless some
other script used the mission choice keys "YES" or "NO". This
implementation uses unique choice keys and doesn't change the mission
variable, which should be more reliable in all cases.
*/
if (missionVariables.trumbles === "OFFER_MADE")
{
missionVariables.trumbles = "BUY_ME";
}
delete this.startUp;
}
this.shipDockedWithStation = function shipDockedWithStation(station)
{
pendingOffer = false;
if (station.isMainStation)
{
if (!missionVariables.trumbles &&
!missionVariables.novacount && // So the offers eventually stop for long-time players who keep refusing.
player.credits > 6553.5)
{
missionVariables.trumbles = "BUY_ME";
}
if (missionVariables.trumbles === "BUY_ME" &&
player.trumbleCount === 0 &&
Math.random() < 0.2) // 20% chance of trumble being offered.
{
pendingOffer = true;
}
}
}
this.missionScreenOpportunity = function missionScreenOpportunity()
{
if (pendingOffer && player.ship.dockedStation.isMainStation)
{
pendingOffer = false;
// Show the mission screen.
mission.runScreen({
titleKey: "oolite_trumble_title",
messageKey: "oolite_trumble_offer",
background: "trumblebox.png",
choicesKey: "oolite_trumble_offer_yesno"
},
function (choice)
{
if (choice === "OOLITE_TRUMBLE_YES")
{
missionVariables.trumbles = "TRUMBLE_BOUGHT";
player.credits -= 30;
player.ship.awardEquipment("EQ_TRUMBLE");
}
else
{
missionVariables.trumbles = "NOT_NOW";
}
});
}
};
this.shipWillExitWitchspace = function shipWillExitWitchspace()
{
// If player has rejected a trumble offer, reset trumble mission with 2% probability per jump.
if (missionVariables.trumbles === "NOT_NOW" && Math.random() < 0.02)
{
missionVariables.trumbles = "BUY_ME";
}
};
}).call(this);
E-mail: [email protected]
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
Re: Trouble with Trumbles in windows trunk 1.75.04324
Looks good. And while we are changing, I would add cleanup code to delete itself
Also the part:
Needs an additional
EDIT: after rereading I think we also need an additional check for
if (missionVariables.trumbles == "TRUMBLE_BOUGHT");
. No need for further checks after this condition.Also the part:
Code: Select all
this.shipWillExitWitchspace = function shipWillExitWitchspace()
{
// If player has rejected a trumble offer, reset trumble mission with 2% probability per jump.
if (missionVariables.trumbles === "NOT_NOW" && Math.random() < 0.02 && !missionVariables.novacount)
{
missionVariables.trumbles = "BUY_ME";
}
};
!missionVariables.novacount
check as above or the mission will still offer itself after G3EDIT: after rereading I think we also need an additional check for
player.credits > 30
before the actual missionscreen is shown as the player could already have spend his credits at this point.UPS-Courier & DeepSpacePirates & others at the box and some older versions
- JensAyton
- Grand Admiral Emeritus
- Posts: 6657
- Joined: Sat Apr 02, 2005 2:43 pm
- Location: Sweden
- Contact:
Re: Trouble with Trumbles in windows trunk 1.75.04324
On that basis, we may as well move the credits check intoEric Walch wrote:EDIT: after rereading I think we also need an additional check forplayer.credits > 30
before the actual missionscreen is shown as the player could already have spend his credits at this point.
missionScreenOpportunity
. There’s no real need to do it more than once.The additional
!missionVariables.novacount
check isn’t really needed. As it stands, the trumble will be offered at most once after the nova counter starts; the goal of eventually stopping is still achieved, but in a less obviously deterministic way.E-mail: [email protected]