Join us at the Oolite Anniversary Party -- London, 7th July 2024, 1pm
More details in this thread.

Scripters cove

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: winston, another_commander

User avatar
Pleb
---- E L I T E ----
---- E L I T E ----
Posts: 908
Joined: Sun Apr 29, 2012 2:23 pm
Location: United Kingdom

Re: Scripters cove

Post by Pleb »

Eric Walch wrote:
Pleb wrote:
For reasons unknown I've managed to get my code to work now. I still can't explain why it wasn't working, but I think it was to do with the time...however it is working now so never mind cheers anyways though.
Looking at the code, there are only two reasons when adding a contract fails:
A: When there is no free passenger cabin.
B: When that passenger is already present.

I assume B can easily happen during testing. At least it should be added to the wiki that there can not be two passengers with the same name. (edit: done)
I'm assuming it might have been A actually. But that leads me to another question, is there any way of checking if there is enough room for a passenger? So that if there wasn't it could warn the player that they cannot accept a passenger contract?
Desktop PC: CPU: Intel i7-4790K Quad Core 4.4GHz (Turbo-Charged) GPU: Nvidia GeForce GTX 1080Ti RAM: 32GB DDR3

Laptop PC: CPU: Intel i5-10300H Quad Core 4.5GHz (Turbo-Charged) GPU: Nvidia GeForce GTX 1650 RAM: 32GB DDR4
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Scripters cove

Post by cim »

Pleb wrote:
I'm assuming it might have been A actually. But that leads me to another question, is there any way of checking if there is enough room for a passenger? So that if there wasn't it could warn the player that they cannot accept a passenger contract?
Yes - passengerCapacity and passengerCount
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Re: Scripters cove

Post by Smivs »

You can count the ship's passengers, then if the number of passengers is less than the number of berths, contracts can be taken, otherwise don't offer them.

<ninja'd>
Commander Smivs, the friendliest Gourd this side of Riedquat.
User avatar
Pleb
---- E L I T E ----
---- E L I T E ----
Posts: 908
Joined: Sun Apr 29, 2012 2:23 pm
Location: United Kingdom

Re: Scripters cove

Post by Pleb »

cim wrote:
Pleb wrote:
I'm assuming it might have been A actually. But that leads me to another question, is there any way of checking if there is enough room for a passenger? So that if there wasn't it could warn the player that they cannot accept a passenger contract?
Yes - passengerCapacity and passengerCount
Ah, that was pretty obvious to find sorry about that but thank you very much! :oops:
Desktop PC: CPU: Intel i7-4790K Quad Core 4.4GHz (Turbo-Charged) GPU: Nvidia GeForce GTX 1080Ti RAM: 32GB DDR3

Laptop PC: CPU: Intel i5-10300H Quad Core 4.5GHz (Turbo-Charged) GPU: Nvidia GeForce GTX 1650 RAM: 32GB DDR4
User avatar
Pleb
---- E L I T E ----
---- E L I T E ----
Posts: 908
Joined: Sun Apr 29, 2012 2:23 pm
Location: United Kingdom

Re: Scripters cove

Post by Pleb »

Sorry I have another question, on a different subject this time. Say, for example, the player is reporting to a marker beacon (essentially a buoy) to investigate something. I need it so that when the player gets within a certain distance of the buoy the player receives a communication telling him/her to get the hell out of there! Is this possible, as when I tried to modify an exisitng AI file (like I have with the Taxi Station or Corporate Trading Outpost) so that when the buoy spots the player it sends a communication, but this communication can't come from the buoy, it needs to be a scipted comm message (so that it is in the comm log but not from the buoy). Is this possible?
Desktop PC: CPU: Intel i7-4790K Quad Core 4.4GHz (Turbo-Charged) GPU: Nvidia GeForce GTX 1080Ti RAM: 32GB DDR3

Laptop PC: CPU: Intel i5-10300H Quad Core 4.5GHz (Turbo-Charged) GPU: Nvidia GeForce GTX 1650 RAM: 32GB DDR4
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Scripters cove

Post by cim »

Pleb wrote:
Sorry I have another question, on a different subject this time. Say, for example, the player is reporting to a marker beacon (essentially a buoy) to investigate something. I need it so that when the player gets within a certain distance of the buoy the player receives a communication telling him/her to get the hell out of there! Is this possible, as when I tried to modify an exisitng AI file (like I have with the Taxi Station or Corporate Trading Outpost) so that when the buoy spots the player it sends a communication, but this communication can't come from the buoy, it needs to be a scipted comm message (so that it is in the comm log but not from the buoy). Is this possible?
Yes - player.commsMessage will send a message from no apparent source.
User avatar
Pleb
---- E L I T E ----
---- E L I T E ----
Posts: 908
Joined: Sun Apr 29, 2012 2:23 pm
Location: United Kingdom

Re: Scripters cove

Post by Pleb »

cim wrote:
Pleb wrote:
Sorry I have another question, on a different subject this time. Say, for example, the player is reporting to a marker beacon (essentially a buoy) to investigate something. I need it so that when the player gets within a certain distance of the buoy the player receives a communication telling him/her to get the hell out of there! Is this possible, as when I tried to modify an exisitng AI file (like I have with the Taxi Station or Corporate Trading Outpost) so that when the buoy spots the player it sends a communication, but this communication can't come from the buoy, it needs to be a scipted comm message (so that it is in the comm log but not from the buoy). Is this possible?
Yes - player.commsMessage will send a message from no apparent source.
Okay but how do I get this script command to launch when the player gets near the buoy? Sorry I didn't explain myself very well! :oops:
Desktop PC: CPU: Intel i7-4790K Quad Core 4.4GHz (Turbo-Charged) GPU: Nvidia GeForce GTX 1080Ti RAM: 32GB DDR3

Laptop PC: CPU: Intel i5-10300H Quad Core 4.5GHz (Turbo-Charged) GPU: Nvidia GeForce GTX 1650 RAM: 32GB DDR4
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Scripters cove

Post by cim »

Pleb wrote:
Okay but how do I get this script command to launch when the player gets near the buoy? Sorry I didn't explain myself very well! :oops:
Ah, right. You need the buoy's AI to start in a state that scans for the player (they're the only ship with primary role "player") - plenty of examples in other OXPs for how to do that. When it finds them, it switches into a different state, the ENTER of which has a sendScriptMessage call.

The buoy then has a ship script attached, from which a function can be called by sendScriptMessage. That function sends the anonymous comms message, and presumably also calls back to your worldscript(s) to trigger the next stage of the investigation.
User avatar
Pleb
---- E L I T E ----
---- E L I T E ----
Posts: 908
Joined: Sun Apr 29, 2012 2:23 pm
Location: United Kingdom

Re: Scripters cove

Post by Pleb »

Ah okay I was on the right track then. I will try this out tonight when I finish work - looking forward to the bank holiday weekend whoooo! Thank you very much cim! :D :D :D
Desktop PC: CPU: Intel i7-4790K Quad Core 4.4GHz (Turbo-Charged) GPU: Nvidia GeForce GTX 1080Ti RAM: 32GB DDR3

Laptop PC: CPU: Intel i5-10300H Quad Core 4.5GHz (Turbo-Charged) GPU: Nvidia GeForce GTX 1650 RAM: 32GB DDR4
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5525
Joined: Thu Jun 12, 2008 6:55 pm

Re: Scripters cove

Post by Thargoid »

Look at Traffic Control OXP or Welcome Mat OXP for examples.
User avatar
Commander McLane
---- E L I T E ----
---- 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: Scripters cove

Post by Commander McLane »

cim wrote:
Pleb wrote:
Okay but how do I get this script command to launch when the player gets near the buoy? Sorry I didn't explain myself very well! :oops:
Ah, right. You need the buoy's AI to start in a state that scans for the player (they're the only ship with primary role "player") - plenty of examples in other OXPs for how to do that. When it finds them, it switches into a different state, the ENTER of which has a sendScriptMessage call.

The buoy then has a ship script attached, from which a function can be called by sendScriptMessage. That function sends the anonymous comms message, and presumably also calls back to your worldscript(s) to trigger the next stage of the investigation.
The important point (which was probably not very clear in cim's answer) is that what you want to do is better done in a ship script, and not with an AI. The best solution is to give your buoy a simple nullAI, and attach a script to it that will do the searching and the message sending. For that you need a timer in the ship script that starts as soon as the buoy is spawned and is stopped as soon as the player ship is detected inside a defined distance from the buoy, at which point the message is sent via the command that cim gave you (which is a JS-script command, not an AI command).
User avatar
Griff
Oolite 2 Art Director
Oolite 2 Art Director
Posts: 2479
Joined: Fri Jul 14, 2006 12:29 pm
Location: Probably hugging his Air Fryer

Re: Scripters cove

Post by Griff »

I was picking through Commander McLane's 3d_asteroids script to see if i had enough brainpower to adapt it into a 'C64 version of Elite Anarchies.oxp' that would spawn pirates in a cloud around you no matter whatever direction you were flying and i ended up on a wiki page that listed a setshaders javascript command and it got me thinking can you test if the player has a certain piece of equipment installed and if so change the shaders that will be used for eg. the cargo pods? I was thinking of a piece of equipment that made cargo pods more visible by using shaders to draw a flashing wireframe box around them (it needen't be yet another piece of equipment it could be a function of the scanner target enhancement or something like that). Has anybody done an oxp that does somethiing like this already (test for player equipment and change shaders/materials on an NPC ship/object?)
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5525
Joined: Thu Jun 12, 2008 6:55 pm

Re: Scripters cove

Post by Thargoid »

It would be fairly easy to do - equipment checking is standard for most scripted equipment (so it only works when you have it installed and it's not damaged) and the other stuff's just a scan and shader application.

If you can do the shader bits I can knock up a script for you.
User avatar
Commander McLane
---- E L I T E ----
---- 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: Scripters cove

Post by Commander McLane »

Griff wrote:
I was picking through Commander McLane's 3d_asteroids script to see if i had enough brainpower to adapt it into a 'C64 version of Elite Anarchies.oxp' that would spawn pirates in a cloud around you no matter whatever direction you were flying
Isn't that basically what Deep Space Pirates OXP is already doing? I think it would at the very least be a better starting point.
User avatar
Griff
Oolite 2 Art Director
Oolite 2 Art Director
Posts: 2479
Joined: Fri Jul 14, 2006 12:29 pm
Location: Probably hugging his Air Fryer

Re: Scripters cove

Post by Griff »

ahh T! i was hoping you'd pop in :) Smashing, i'll try out some ideas for the shaders over the next few days and post them up, if they look OK i'll hassle you for the script bits!
Post Reply