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?)Lestradae wrote: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.LittleBear wrote:do = (
"setMissionMusic: none"
Scripting requests
Moderators: winston, another_commander
- Commander McLane
- ---- E L I T E ----
- Posts: 9520
- Joined: Thu Dec 14, 2006 9:08 am
- Location: a Hacker Outpost in a moderately remote area
- Contact:
Re: ....
@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...
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...
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
In playerEntity.m there are three places were it calls
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.
Code: Select all
[UNIVERSE allShipAIsReactToMessage:@"PLAYER WITCHSPACE"];
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.
UPS-Courier & DeepSpacePirates & others at the box and some older versions
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?)
Ideally both available in-flight rather than just when docked (and ditto the in-flight part for removeAllCargo, is that possible too?)
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link
*
this would be nice
javascript acces to
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
same file later in the file, in the function of
static JSBool PlayerShipGetProperty(JSContext *context, JSObject *this, jsval name, jsval *outValue)
and file oolite-global-prefix.js
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)
this would be nice
javascript acces to
Code: Select all
player.ship.galaxyCoords
player.ship.cursorCoords
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
};
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;
Code: Select all
this.defineCompatibilitySubGetter("player", "ship", "galaxyCoords");
this.defineCompatibilitySubGetter("player", "ship", "cursorCoords");
I'm getting correct output
(x,y,0)
Bounty Scanner
Number 935
Number 935
-
- Quite Grand Sub-Admiral
- Posts: 6682
- Joined: Wed Feb 28, 2007 7:54 am
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?
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?
Thanksanother_commander wrote:Good job man!
Frame, can you please check that your name has been spelled correctly in the contributors thread in Announcements?
And yes it is spelled correct.
Bounty Scanner
Number 935
Number 935
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
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:
I needed it to create a random reaction time with AI scripting. e.g. like:
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.
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())];
}
Code: Select all
"INCOMING_MISSILE" = ("messageSelf: FIGHT_MISSILE", "randomPauseAI: 0.5 3.0");
"FIGHT_MISSILE" = (setTargetToPrimaryAggressor, fightOrFleeMissile);
EDIT: Added the above command to the trunk.
UPS-Courier & DeepSpacePirates & others at the box and some older versions
- Commander McLane
- ---- E L I T E ----
- Posts: 9520
- Joined: Thu Dec 14, 2006 9:08 am
- Location: a Hacker Outpost in a moderately remote area
- Contact:
Thanks for taking up a suggestion from back in January!another_commander wrote:Good job man! Will check this in the evening and if all good, this might become revision2221.
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.
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...)
- Lestradae
- ---- E L I T E ----
- Posts: 3095
- Joined: Tue Apr 17, 2007 10:30 pm
- Location: Vienna, Austria
...
I suggest expanding the following command: %Jxxx
... 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.
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.
-
- Quite Grand Sub-Admiral
- Posts: 6682
- Joined: Wed Feb 28, 2007 7:54 am
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.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...)
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
Great job A_C, Witchspace travelling will never be save anymore.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.
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.
UPS-Courier & DeepSpacePirates & others at the box and some older versions
-
- Quite Grand Sub-Admiral
- Posts: 6682
- Joined: Wed Feb 28, 2007 7:54 am
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.
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.
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.
Dream as if you'll live forever
Live as if you'll die tomorrow
Live as if you'll die tomorrow
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.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.
Code: Select all
this.defineCompatibilitySubGetterAndSetter("player", "ship", "scriptedMisjump");
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...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.
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..
Last edited by Frame on Tue Jul 28, 2009 3:19 pm, edited 1 time in total.
Bounty Scanner
Number 935
Number 935