Re: Scripters cove
Posted: Sun Mar 01, 2015 11:11 am
Thanks! I'll see what I can cobble together.
For information and discussion about Oolite.
https://bb.oolite.space/
Context - why would you care?phkb wrote:Is there a way using JS to tell if a new game has just been started?
Not strictly, no - the routine to load a saved game and the routine to start a new scenario differ only in which directory they get thephkb wrote:Is there a way using JS to tell if a new game has just been started?
oolite-save
file from.Then you can spam them with market research surveys, customer satisfaction questionaires and offers linked to the purchase. And they'll probably need reminding to leave Feedback!phkb wrote:I'd like to send an email to the player telling about their purchase of their ship.
Given that scenarios may not even allow the email OXP to load in the first place, and even if they do might have their own ideas for what initial emails the player should get - "Congratulations on your recent theft of this Boa Freighter" - that's probably more a feature than a bug if the OXP has to have specific checks for each separate scenario.Wildeblood wrote:Clock won't be reliable if scenarios catch on with OXPers. Folk won't always start with a new Jameson to create their oolite-save files. More likely the'll use an old one and just delete the mission variables; it wouldn't occur to me to reset the clock, and if it did why should all scenarios start at the same time?
spara wrote:Is there a way to set a station to disallowedDockingCollides so that all ships without docking permission would collide? A shipdata property disallowed_docking_collides would be nice .
allowsDocking
false is really intended for situations like "this is a launch-only dock with some sort of high-speed launch catapult, and you're not getting your ship back in there" or "you could dock here, but not while the bay doors are closed"acceptDockingRequestFrom
would have disallowedDockingCollides
apply in that case, but that would need re-testing every frame. (That's probably acceptable as the method shouldn't be particularly intensive)A game mechanic change of crashing the player when docking without permission instead of fining would be an interesting one .cim wrote:spara wrote:Is there a way to set a station to disallowedDockingCollides so that all ships without docking permission would collide? A shipdata property disallowed_docking_collides would be nice .allowsDocking
false is really intended for situations like "this is a launch-only dock with some sort of high-speed launch catapult, and you're not getting your ship back in there" or "you could dock here, but not while the bay doors are closed"
I could set it up so that per-ship rejection on the dock through a method parallel toacceptDockingRequestFrom
would havedisallowedDockingCollides
apply in that case, but that would need re-testing every frame. (That's probably acceptable as the method shouldn't be particularly intensive)
Code: Select all
// if the ship targets the player, potentially untarget them
this.shipTargetAcquired = function(target) {
if (this._debug) log(this.name, "target acquired");
var w = worldScripts.RenameShipTweak;
if (target == player.ship && w._confusionActive == true && this._disable == false) {
if (this._debug) log(this.name, "player ship targetted");
if (Math.random() < (1 / w._chanceOfSuccess)) {
this._retarget = true;
this.ship.target = null;
if (w._confusedMessageSent == false) {
log(this.name, "sending confused message");
this.ship.commsMessage(expandDescription("[confused-message]", {shipname:w._storedShipName}), player.ship);
w._confusedMessageSent = true;
}
}
}
}
Code: Select all
13:53:41.072 [script.javaScript.exception.unexpectedType]: ***** JavaScript exception (Oolite Assassin AI 1.80): TypeError: this.ship.target is null
13:53:41.072 [script.javaScript.exception.unexpectedType]: Resources/Scripts/oolite-priorityai.js, line 2767.
Code: Select all
this.ship.target = nearbySuitableTarget;
// later...
if (this.ship.target.property == something) {
conditionScannerContainsCourier
in the ship AIs. Currently it's this:
Code: Select all
PriorityAIController.prototype.conditionScannerContainsCourier = function()
{
return (this.checkScannerWithPredicate(function(s) {
return (this.shipInRoleCategory(s,"oolite-courier")) || (s.isPlayer && this.shipHasRiskyContracts(s));
}));
}
Code: Select all
ship.AIScript.oolite_priorityai.conditionScannerContainsCourier = function() {
return (this.checkScannerWithPredicate(function(s) {
if (s.isPlayer) {
// do the "recently renamed" checks here, return false if is ignoring the player
// this also means that the assassins will go after another courier instead if one happens to be about
}
return (this.shipInRoleCategory(s,"oolite-courier")) || (s.isPlayer && this.shipHasRiskyContracts(s));
}));
}
w._chanceOfSuccess
is even slightly greater than 1, this will mean that within seconds they realise their mistake.conditionScannerContainsCourier
- I created a JS file with my code in it, put it in the Scripts folder, then for each assassin at the witchpoint I tried ship.setScript("assassin-confused.js");
. I get this error:Code: Select all
17:28:51.434 [script.javaScript.load.failed]: ***** Error loading JavaScript script ../AddOns/RenameShipTweak.oxp/Scripts/assassin-confused.js -- could not run script
17:28:51.561 [script.javaScript.exception.unexpectedType]: ***** JavaScript exception (RenameShipTweak 1.0.0): TypeError: ship.AIScript.oolite_priorityai is undefined
ship.AIScript.oolite_priorityai.conditionScannerContainsCourier = function()
trying to get it to work, including (but not limited to):
Code: Select all
this.ship.AIScript.oolite_priorityai.conditionScannerContainsCourier
this.AIScript.oolite_libpriorityai.conditionScannerContainsCourier (for this one, the error was "this.AIScript is undefined")
ship.AIScript.PriorityAIController.conditionScannerContainsCourier
ship.AIScript["oolite-libPriorityAI"].conditionScannerContainsCourier
ship.AIScript.oolite_priorityAI.conditionScannerContainsCourier
ship.AIScript["Oolite Assassin AI"].conditionScannerContainsCourier
setAI
method! So I moved my script file to the AIs folder, and tried again.Code: Select all
19:16:43.227 [script.javaScript.exception.unexpectedType]: ***** JavaScript exception (RenameShipTweak 1.0.0): TypeError: ship.AIScript.oolite_priorityai is undefined
setAI
or setScript
method on the assassin ships? (2) Does my script need anything other than my overridden function in it? For instance, do I need a this.aiStarted = function()
if I load it via setAI
? (3) Have I missed anything obvious? (Actually, I think that's a given - feel free to answer that one or not!).