Page 16 of 56
Re: ....
Posted: Fri Feb 20, 2009 11:33 am
by Commander McLane
Lestradae wrote:LittleBear wrote:do = (
"setMissionMusic: none"
That one's interesting. Is there a XML command for the planetinfo.plist that lets a piece of music or a sound file be played when the player enters a system? I could use something like that for my special systems.
Who is speaking of entering a system? Mission Music can be played
when a mission screen opens. Which is exactly what LittleBear's code snippet is about. (You haven't read the
conditions-part of it, have you?)
Posted: Fri Feb 20, 2009 12:48 pm
by Kaks
@Lestradae: have I ever mentioned Javascript? You can play any music you like depending on any condition, at any time!
You could easily (I don't know with how many lines yet!

) have a sound equivalent to system redux/famous planets: specific music when entering specific systems, or a more generic one playing music based on type of government, different sound effects when entering the aegis depending on the system technology, or even different 'warning' sound messages when being attacked, depending on the main role of the ship attacking you...
Posted: Mon Mar 09, 2009 4:58 pm
by Eric Walch
In playerEntity.m there are three places were it calls
Code: Select all
[UNIVERSE allShipAIsReactToMessage:@"PLAYER WITCHSPACE"];
Probably it should also send a JS message to all scripts.
Currently I noticed Oolite has a bug that repeating timers in a ship script keep running when the player leaves the system. I have one mission ship that uses these timers. I now use the "PLAYER WITCHSPACE" AI message to send a script event to stop and delete the timers. But an added problem is that this ship ends its journey with an dockingAI. At the moment it switches to that AI I see no way to call that script function to stop the timers when the player leaves at that moment.
This is a temporary problem until the timer bug is fixed, but I can imagine other situations were it is easier to let the ship itself detect that the player left the system instead of doing it in a player worldScript.
Posted: Tue Mar 31, 2009 4:02 pm
by Thargoid
We can award specific cargo types to the player, but would it be do-able to add the ability to check for the amount of a specific cargo type that is in the hold, and also where present to selectively remove it (basically the opposite of awardCargo)?
Ideally both available in-flight rather than just when docked (and ditto the in-flight part for removeAllCargo, is that possible too?)
Posted: Fri Jul 03, 2009 7:21 am
by Frame
*
this would be nice
javascript acces to
Code: Select all
player.ship.galaxyCoords
player.ship.cursorCoords
Both Read Only
It would be nice to know where in witchspace you are, since we do not have system ID for witchspace, when writing an OXP
Cursor coords is just added bonus.. but should be included In my opinion as it can also serve in getting coordinates fast, for this and that system.. instead of having to go look it up on the wiki thus saving wiki bandwidth & traffic...
player.ship because it is selected by the player on the hyperspace computer on the ship...
I tested it, like this... and serve it on a silver plate
file:
OOJSPlayerShip.m
Code: Select all
enum
{
// Property IDs,
// other stuff removed for ease of reading in this post
kPlayerShip_galaxy_coords, //galaxy coordinates, vector read only
kPlayerShip_cursor_coords, //cursor coordinates, vector read only
};
static JSPropertySpec sPlayerShipProperties[] =
{
// JS name ID flags
// other stuff removed for ease of reading
{ "galaxyCoords", kPlayerShip_galaxy_coords, JSPROP_PERMANENT | JSPROP_ENUMERATE | JSPROP_READONLY },
{ "cursorCoords", kPlayerShip_cursor_coords, JSPROP_PERMANENT | JSPROP_ENUMERATE | JSPROP_READONLY },
{ 0 }
// other stuff removed for ease of reading
};
same file later in the file, in the function of
static JSBool PlayerShipGetProperty(JSContext *context, JSObject *this, jsval name, jsval *outValue)
Code: Select all
case kPlayerShip_galaxy_coords:
OK = NSPointToVectorJSValue(context, [player galaxy_coordinates], outValue);
break;
case kPlayerShip_cursor_coords:
OK = NSPointToVectorJSValue(context, [player cursor_coordinates], outValue);
break;
and file
oolite-global-prefix.js
Code: Select all
this.defineCompatibilitySubGetter("player", "ship", "galaxyCoords");
this.defineCompatibilitySubGetter("player", "ship", "cursorCoords");
in a test build of revision 2220, (latest right now), this has checked out ok... using the debug console
I'm getting correct output
(x,y,0)
Posted: Fri Jul 03, 2009 8:45 am
by another_commander
Good job man! Will check this in the evening and if all good, this might become revision
2221.
Edit: It actually became revision 2223, Ahruman fixed a couple of things in the trunk before I managed to get there. Oh, and the names of the methods are
player.ship.galaxyCoordinates and
player.ship.cursorCoordinates.
Frame, can you please check that your name has been spelled correctly in the contributors thread in Announcements?

Posted: Sat Jul 04, 2009 12:14 pm
by Frame
another_commander wrote:Good job man!
Frame, can you please check that your name has been spelled correctly in the contributors thread in Announcements?

Thanks
And yes it is spelled correct.
Posted: Tue Jul 07, 2009 6:45 pm
by Eric Walch
I like to add a new pause command to the AI vocabulary: randomPauseAI. I already coded it and tested it on my test environment and it acts as I planned:
Code: Select all
- (void) randomPauseAI:(NSString *)intervalString
{
NSArray* tokens = ScanTokensFromString(intervalString);
double start, end;
if ([tokens count] != 2)
{
OOLog(@"ai.syntax.randomPauseAI", @"***** ERROR: cannot read min and max value for pause, needs 2 values: '%@'.", intervalString);
return;
}
start = [(NSString *)[tokens objectAtIndex:0] doubleValue];
end = [(NSString *)[tokens objectAtIndex:1] doubleValue];
[shipAI setNextThinkTime:[UNIVERSE getTime] + (start + (end - start)*randf())];
}
I needed it to create a random reaction time with AI scripting. e.g. like:
Code: Select all
"INCOMING_MISSILE" = ("messageSelf: FIGHT_MISSILE", "randomPauseAI: 0.5 3.0");
"FIGHT_MISSILE" = (setTargetToPrimaryAggressor, fightOrFleeMissile);
No instant reaction on incoming missiles but sending itself an instruction to react between a minimum and maximum time interval.
EDIT: Added the above command to the trunk.
Posted: Fri Jul 10, 2009 9:12 am
by Commander McLane
another_commander wrote:Good job man! Will check this in the evening and if all good, this might become revision 2221.
Edit: It actually became revision 2223, Ahruman fixed a couple of things in the trunk before I managed to get there. Oh, and the names of the methods are player.ship.galaxyCoordinates and player.ship.cursorCoordinates.
Thanks for taking up a suggestion from
back in January!
Now what about my other suggestions about the whole witchjumping business? Like
this one. Oh, and of course making misjumps scriptable (if you're at it, you know...)

...
Posted: Mon Jul 27, 2009 9:04 pm
by Lestradae
I suggest expanding the following command:
%Jxxx
Will display the system name of system with ID number "xxx". xxx must be a 3 digit number or no replacement takes place. e.g. %J007 is Lave (in Galaxy 1, that is)
... to a four-digit number
%Jyxxx in which the y (0-7) stands for the galaxy or sector the system is in.
That way, trans-galactic missions can be displayed correctly by using the above command and use the new "1.73" trunk feature of also depicting oxp-altered planet/system names.
Posted: Mon Jul 27, 2009 11:41 pm
by another_commander
Commander McLane wrote:
Now what about my other suggestions about the whole witchjumping business? Like
this one. Oh, and of course making misjumps scriptable (if you're at it, you know...)

As of SVN2267, we have scriptable misjumps. The new read/write JavaScript boolean property
player.ship.scriptedMisjump has been added. As long as this is set to true the player ship will be executing misjumps, so handle with care and make sure to reset it after having finished with it.
Posted: Tue Jul 28, 2009 10:49 am
by Eric Walch
another_commander wrote:As of SVN2267, we have scriptable misjumps. The new read/write JavaScript boolean property player.ship.scriptedMisjump has been added. As long as this is set to true the player ship will be executing misjumps, so handle with care and make sure to reset it after having finished with it.
Great job A_C, Witchspace travelling will never be save anymore.
Just one suggestion: Don't let an oxp reset that property buy let the code reset it after every jump. That way an oxp can only set it for the next jump.
When oxp'ers must reset that themselves it will lead to conflicts when two of them use this feature. When not needed an oxp is likely to clear the property always to be sure and not check if he was the one that had set it or that an other oxp has set it. By making it auto clearing on jumping you avoid these problems.
Posted: Tue Jul 28, 2009 11:52 am
by another_commander
You are right Eric. SVN2268 makes the scripted misjumps have a lifespan of one jump only, then they are autoreset. This should make things simpler for OXPers, as they only have to worry about setting the property before the actual scripted jump, then they can forget about it. The scripted_misjump flag will remain set to true during the shipWillExitWitchspace handler, but will be back to false at the end of the shipExitedWitchspace handler.
Posted: Tue Jul 28, 2009 3:00 pm
by Nemoricus
Hmm....it occurs to me that if an OXP has a scripted misjump in it, they may not want things that usually show up in Witchspace to show up.
While I can't think of an example off-hand, I do know that the presence of Thargoids and Navy vessels from other OXPs may complicate the misjumping OXP's plans.
OXP makers should therefore add a check to see if the misjump flag has been set so that they don't interfere with the scripted events.
Posted: Tue Jul 28, 2009 3:08 pm
by Frame
another_commander wrote:
As of SVN2267, we have scriptable misjumps. The new read/write JavaScript boolean property player.ship.scriptedMisjump has been added. As long as this is set to true the player ship will be executing misjumps, so handle with care and make sure to reset it after having finished with it.
I do not see it in resources/
oolite-global-prefix.js, but then again, i'm not even sure if it is needed in there... I'm not double checking, I'm just writing a new feature to suggest... and thereby fell over it. as I suspected it being last and to look something like.
Code: Select all
this.defineCompatibilitySubGetterAndSetter("player", "ship", "scriptedMisjump");
Nemoricus wrote:Hmm....it occurs to me that if an OXP has a scripted misjump in it, they may not want things that usually show up in Witchspace to show up.
While I can't think of an example off-hand, I do know that the presence of Thargoids and Navy vessels from other OXPs may complicate the misjumping OXP's plans.
OXP makers should therefore add a check to see if the misjump flag has been set so that they don't interfere with the scripted events.
I always felt that Thargoids being auto present was a bit cheesy , especially since we can force mis-jumps by rolling the ship now. But they are there, and so is the galactic navy & behemots and so on...
OXP makers should deal with it like this, in case they want neither...
1 At Player entering interstellar space move player to a location far away.
preferbly at WillExitWitchSpace
2 remove all Not wanted ships before spawning yours
system.allShips contains all ships to be removed.
3 move player back to position at which he jumped in..