Page 44 of 118

Re: Scripters cove

Posted: Wed May 02, 2012 9:32 pm
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?

Re: Scripters cove

Posted: Wed May 02, 2012 9:36 pm
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

Re: Scripters cove

Posted: Wed May 02, 2012 9:38 pm
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>

Re: Scripters cove

Posted: Wed May 02, 2012 9:39 pm
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:

Re: Scripters cove

Posted: Fri May 04, 2012 7:36 am
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?

Re: Scripters cove

Posted: Fri May 04, 2012 8:03 am
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.

Re: Scripters cove

Posted: Fri May 04, 2012 8:09 am
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:

Re: Scripters cove

Posted: Fri May 04, 2012 8:25 am
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.

Re: Scripters cove

Posted: Fri May 04, 2012 8:28 am
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

Re: Scripters cove

Posted: Fri May 04, 2012 8:56 am
by Thargoid
Look at Traffic Control OXP or Welcome Mat OXP for examples.

Re: Scripters cove

Posted: Fri May 04, 2012 9:11 pm
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).

Re: Scripters cove

Posted: Tue May 29, 2012 8:14 pm
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?)

Re: Scripters cove

Posted: Tue May 29, 2012 8:24 pm
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.

Re: Scripters cove

Posted: Tue May 29, 2012 8:29 pm
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.

Re: Scripters cove

Posted: Tue May 29, 2012 8:30 pm
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!