oxp Testing

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

Moderators: winston, another_commander

User avatar
mandoman
---- E L I T E ----
---- E L I T E ----
Posts: 1375
Joined: Thu Apr 28, 2011 3:17 pm

oxp Testing

Post by mandoman »

I have an oxp put together for a ship I dubbed simply "UFOship". It is suppose to be a, until now, unknown enemy of the Thargoids, and their main objective is killing Thargoid vessels. It will NOT attack any other kind of ship, UNLESS a ship other than a Thargoid ship attacks the UFO ship first. In other words, it will retaliate against any ship that attacks it first. It is NOT a player ship.

Here's the problem. though the game says it has loaded this oxp, and the Latest.log does NOT show any ERRORs, the UFOship is not appearing in the conditions I set for it to appear. Would someone be willing to look at the oxp, and see what I need to correct. I know I'm not a genius at this stuff, and I HAVE gone and studied tutorials on both HTML, and JAVA script, I still don't seem to be able to make the ship appear in the game. I tried to follow the guides for writing out JAVA script in Oolite, and have made a whole Script folder containing .js files that define what each entity is suppose to accomplish, or how to act. Maybe I went too far, or didn't define the right things, I'm not sure. If I am not totally persona non grata in this forum, I could sure use the help. Thanks.

Here's the link to the oxp:

http://www.box.net/shared/h5x70n4yuag1kr8o8aos
Mandotech Industries Wiki Page.

http://wiki.alioth.net/index.php/User:Mandoman
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Re: oxp Testing

Post by Smivs »

Hi Mandoman,
I haven't got time to have a look I'm afraid, but have you considered doing this in stages.
Make sure the UFOship works. Make a simple OXP for it - just shipdata and a script to spawn it in the Config folder, the model in the Models folder, and the texture in the Textures folder.
Just make it spawn a sensible distance away from the station when you launch. You can have a look at it, but more importantly, if it's there you know all those elements work.
From there, move on to your scripting and check it's appearing as and where it should.
After that, develop the scripting more as needed and work on any AI it might need.
One small step at a time, making sure each works before moving on.
Commander Smivs, the friendliest Gourd this side of Riedquat.
User avatar
mandoman
---- E L I T E ----
---- E L I T E ----
Posts: 1375
Joined: Thu Apr 28, 2011 3:17 pm

Re: oxp Testing

Post by mandoman »

Smivs wrote:
Hi Mandoman,
I haven't got time to have a look I'm afraid, but have you considered doing this in stages.
Make sure the UFOship works. Make a simple OXP for it - just shipdata and a script to spawn it in the Config folder, the model in the Models folder, and the texture in the Textures folder.
Just make it spawn a sensible distance away from the station when you launch. You can have a look at it, but more importantly, if it's there you know all those elements work.
From there, move on to your scripting and check it's appearing as and where it should.
After that, develop the scripting more as needed and work on any AI it might need.
One small step at a time, making sure each works before moving on.
OK, that's sound advice. I've not been able to make that work with other ships, but I'll give it a try. Thanks. :)
Mandotech Industries Wiki Page.

http://wiki.alioth.net/index.php/User:Mandoman
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Re: oxp Testing

Post by Thargoid »

Ok, let's break this down into a few pieces:

Shipdata.plist

The roles key currently has "roles" = "hunt and attack thargoids"; . That literally means if a script tries to spawn a ship with role "hunt", "and", "attack" or "thargoids" then probably one of your ships would appear (or at least it would try to).

The trunk code has a built-in populator, which tries to populate the game system with ships based on a number of specific roles (pirate, trader, police etc). If your ship does not use one of those roles, then the trunk populator won't spawn your ship. In that case you need to use your own populator script to do the job (and have a corresponding role in shipdata.plist set up to link with it, for example "mandoman_UFOShip" or something like that).

There are a few more minor points in the shipdata.plist (NPCs don't have port and starboard weapons, and your port weapon is misdefined anyway, and you don't give any co-ordinates for the weapon positions for examples) but the roles one is the main issue there.

AI

You've got some non-standard keys in there (for example "INCOMING_AGGRESSOR-MISSILE"). That is not necessary wrong as JS scripts can send messages to AIs corresponding to any key, but it's not what your OXP is doing here. Basically nothing is ever going to send your AIs that message, so it's not going to be acted upon.

A good list of the messages that the trunk engine can send to the ships AI is [EliteWiki] here on the wiki.

Scripts

Each NPC ship type (ie each entry in shipdata.plist) can have one script corresponding to it, linked via the shipdata.plist key "script" (e.g. "script" = "mandoman_UFOShip.js"; for example). That script can contain specific functions, as detailed here on the wiki. The trunk engine will send those events to the ship script whenever the corresponding event happens. For example if you fire a missile at the NPC ship, it's script is sent the event shipAttackedWithMissile and any code in the script under this.shipAttackedWithMissile(missile, whom) function header will be run, with the parameters of missile and whom passed to it (what missile was fired and by whom respectively in this particular example).

It is possible to define your own functions in the script, and call them either from other script functions (such as the pre-existing ones) or from the AI (although that's advanced usage). If the script has custom functions (such as your this.UFOshipWillNotExitFromWitchspace = function() for example) then that code will never fire as it will never be called.

But in this case, as none of your scripts are actually linked to your ship (via shipdata.plist as noted above) then the scripts themselves are never actually loaded by the game anyway.

There is a second type of script (the worldscript) but that relates to the player, and I'll keep things simpler here by ignoring that for the moment.

My suggestion to you would be to look at the Thargoid and Thargon entries in the trunk shipdata.plist, and see how they link to their AIs and also the script in the case of the Thargoid ship. Then look at that script and see how it generates the odd messages (the Thargoid curses about poets and suchlike) that come up when one of the ships is destroyed.

I would also use the existing game code (trunk and OXP) as your template rather than web resources. They tend to be related to javascript for web programming, which is a little different. Use those web resources instead to tell you what javascript functions are available to go into your scripts, but the overall template and structure is better taken from closer to home.

But fair play to you for trying to get your head around it - I can appreciate it's not easy until you get the hang of how everything links together and how it all interacts. Stick at it! :twisted: Oh and apologies for the essay ;)
User avatar
mandoman
---- E L I T E ----
---- E L I T E ----
Posts: 1375
Joined: Thu Apr 28, 2011 3:17 pm

Re: oxp Testing

Post by mandoman »

Thargoid, thank you. You have given me guidelines that I can understand (I think). As for using other existing scripts as templates, allow me to quote another_commander:
mandoman, the JS scripts you have presented so far have no chance of working. They are completely non-JS. You will need to take some time to look at the documentation in the wiki referring to scripts and the JavaScript handlers for Oolite. Before even that, I would recommend reading online tutorials about JavaScript, so that you at least get the syntax part right. Blindly copy pasting code does not help, you need to know how things get put together. It will then be much easier for us to help you, too.
That is to whom I refer as considering me persona non grata. When it came right down to it, the only thing I learned from those tutorials is that they are not quite unlike the code used in Oolite. :)

Perhaps he is right, but i'm stubborn enough not to back down now, especially after reading your advice. I think I'll make a .txt of that post to refer as I go along with this. I didn't expect this ship to turn out right the first, or even the tenth time, but like you said, I'm just trying to get my head around it. I like the idea of the BIG ships, and would therefore like to know how to go about scripting them. Modeling them isn't a problem, it's translating the model into script that works in the game engine. I've been unsuccessfully trying to spawn the UFOship the way Smivs suggested, but enough said, I am off to follow your advice. Oh, and I'm still going to try spawning it as Smivs recommended. Thanks very much guys. :D
Mandotech Industries Wiki Page.

http://wiki.alioth.net/index.php/User:Mandoman
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Re: oxp Testing

Post by Smivs »

You'll get there!
I think you should start by making sure your ship can actually appear and work in the game. If it can't, all the scripts and AIs in the Ooniverse can't do anything with it.
So make a bare-bones OXP with just the bare minimum. Shipdata.plist and a spawning script in Config, The model in Models and the texture in Textures. Spawn it and make sure it really does appear as a ship in the game. See it. Then you can start doing more exciting things with it.
The spawning script will be something like this...

Code: Select all

// Standard attributes 
this.name           = "DemoScript.js"; 
this.author         = "Smivs"; 
this.copyright      = "This script is hereby placed in the public domain."; 
this.version        = "1.0"; 
this.description    = "Script to add an object near player on launching from station." 



this.shipLaunchedFromStation = function() 
{
         
   system.addShips("your-ship's-role", 1, player.ship.position, 10000);
    
};
copy and paste this into a text editor and call it script.js. In the above "your-ship's-role" is the unique role you'll give your ship. Thargoid suggested "mandoman_UFOShip" and that seems very sensible. So in your shipdata have roles = "mandoman_UFOShip"; and replace "your-ship's-role" in the script above with "mandoman_UFOShip"
Good luck!
Commander Smivs, the friendliest Gourd this side of Riedquat.
User avatar
mandoman
---- E L I T E ----
---- E L I T E ----
Posts: 1375
Joined: Thu Apr 28, 2011 3:17 pm

Re: oxp Testing

Post by mandoman »

Smivs wrote:
You'll get there!
I think you should start by making sure your ship can actually appear and work in the game. If it can't, all the scripts and AIs in the Ooniverse can't do anything with it.
So make a bare-bones OXP with just the bare minimum. Shipdata.plist and a spawning script in Config, The model in Models and the texture in Textures. Spawn it and make sure it really does appear as a ship in the game. See it. Then you can start doing more exciting things with it.
The spawning script will be something like this...

Code: Select all

// Standard attributes 
this.name           = "DemoScript.js"; 
this.author         = "Smivs"; 
this.copyright      = "This script is hereby placed in the public domain."; 
this.version        = "1.0"; 
this.description    = "Script to add an object near player on launching from station." 



this.shipLaunchedFromStation = function() 
{
         
   system.addShips("your-ship's-role", 1, player.ship.position, 10000);
    
};
copy and paste this into a text editor and call it script.js. In the above "your-ship's-role" is the unique role you'll give your ship. Thargoid suggested "mandoman_UFOShip" and that seems very sensible. So in your shipdata have roles = "mandoman_UFOShip"; and replace "your-ship's-role" in the script above with "mandoman_UFOShip"
Good luck!
Very cool. Thanks a lot, Smivs. I'll get right on that. My spawn script didn't define things that well. Man, I have got to take notes. :D

By the way, can I get away with an entry like this in shipdata.plist to refer to entities (yes, plural)?

"ufoship_aggressor" {
"like_ship" = "any oolite ship";
"name" = "ufo_aggressor"
"roles" = "hunter trader pirate police systemship galcop navyship behemoth";
"scan_class" = "CLASS_POWERED_CRAFT, CLASS_POLICE";
"script" = "ufo_aggressor.js";

Later Addittion:

I have run into a snag. I want the weapons on the UFOship to be ball turrets, but I'm confused on how to go about the quaternion equations. Do I need to do them? The Oolite oxp making guide seems to suggest that the Java script in Oolite can figure them for me, but I may not be understanding that correctly.
Mandotech Industries Wiki Page.

http://wiki.alioth.net/index.php/User:Mandoman
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Re: oxp Testing

Post by Thargoid »

The name, roles and scan_class in the above are wrong.

name - this is what the ship will be called in the game. For example if you target it with a missile or ID lock, it's the name that appears. You probably don't want that as "ufo_aggressor" I think?

roles - systemship, galcop and navyship are not built in roles, so unless you want to use them via a populator script such as the one Smivs posted, they'll never be used. For more details on the trunk system populator and the roles it uses, see [EliteWiki] here on the wiki.

scan_class - similarly there are a very specific set of scan classes available for use - see here for details of what is available.

Indeed I would strongly urge you to keep that shipdata.plist screen from the wiki open and use it as reference when compiling your shipdata.plist file. It includes all the ship data entries that are valid, and in many cases details the range of values that they can be set to.

For quaternions, see [EliteWiki] here but beware that they are a little mindbending until you get used to them...
User avatar
Svengali
Commander
Commander
Posts: 2370
Joined: Sat Oct 20, 2007 2:52 pm

Re: oxp Testing

Post by Svengali »

mandoman wrote:
mandoman, the JS scripts you have presented so far have no chance of working. They are completely non-JS. You will need to take some time to look at the documentation in the wiki referring to scripts and the JavaScript handlers for Oolite. Before even that, I would recommend reading online tutorials about JavaScript, so that you at least get the syntax part right. Blindly copy pasting code does not help, you need to know how things get put together. It will then be much easier for us to help you, too.
That is to whom I refer as considering me persona non grata. When it came right down to it, the only thing I learned from those tutorials is that they are not quite unlike the code used in Oolite. :)

Perhaps he is right, but i'm stubborn enough not to back down now, especially after reading your advice.
Heh! I'd think a_c is absolutely right. Wrong Syntax simply won't work and just by seeing the shipdata I'd think start to get your head around this one before frickling around with JS. Syntax is important for the chinese spy chips in your box. Example? Try to misspell the <body> tag in HTML or don't close the tags.

Syntax is a set of rules, one missing commata or semicolon can stop things from working in JS and XML/OpenStep (all plists) and the same goes for using brackets or calling methods/functions without taking care of the order of arguments or using wrong types. JS tutorials/docs and the Wiki docs will give you these infos. Probably the difficult part is to understand the documentation. Reading the docs needs a specific way of thinking - this can't be explained easily, but imagine you would want to buy some food in a foreign land without the possibility to use gestures. It's the same here. Oolite expects things in a specific way AND a specific order.

But hey - it's only errors. They can be fixed. Nobody was hurt and none of the innocent semicolons was abused in that process.
User avatar
Capt. Murphy
Commodore
Commodore
Posts: 1127
Joined: Fri Feb 25, 2011 8:46 am
Location: UK South Coast.

Re: oxp Testing

Post by Capt. Murphy »

There is a bit of chicken and egg syndrome in learning the Oolite script interface from scratch.

Everybody has a preferred method of learning, but for me the way to go was looking at existing OXP's scripts (ones that are well commented are good), whilst referring to http://wiki.alioth.net/index.php/Script ... JavaScript and it's linked pages to understand how the scripts link with the game's code and a general JS tutorial site to understand and learn the syntax, commands and inbuilt functions of JS.

For what you are trying to do Mandoman it is essential that you understand the difference between worldscripts and shipscripts, and how Oolite's system of Event Handler's works. You'll also need to get your head around how the AI works which is another kettle of fish and a bit of a headpain to say the least.

I think I posted in your other thread but to make your ship work you'll need.

1) A worldscript - it's job is to check conditions when the player arrives in a system and/or launches from a station and if these conditions are met spawn 1 or more of your UFO's via it's unique role (as defined in shipdata.plist).

2) A custom AI along with possibly a shipscript again both referenced in the shipdata.plist. These will control what the UFO does once it's spawned and in reaction to events around it.
[EliteWiki] Capt. Murphy's OXPs
External JavaScript resources - W3Schools & Mozilla Developer Network
Win 7 64bit, Intel Core i5 with HD3000 (driver rev. 8.15.10.2696 - March 2012), Oolite 1.76.1
User avatar
mandoman
---- E L I T E ----
---- E L I T E ----
Posts: 1375
Joined: Thu Apr 28, 2011 3:17 pm

Re: oxp Testing

Post by mandoman »

OK, I understand what I'm trying to do, but also understand that I haven't got a handle on it. I knew those lines I asked about weren't going to work, but it wasn't until after I made that post that I came to the realization. I'm working on it. I've read, and reread, and studied all of the references to scripts, worldscripts, shipscripts, and about any other script I could find, but one of these days I may understand what I'm reading. Working on it. Don't worry, I'm not even going to think of releasing anything until I've got it working perfectly. Heck, I can't even get the game to spawn the ship, so I've got a ways to go. Thanks for all the suggestions, and advice. :)
Mandotech Industries Wiki Page.

http://wiki.alioth.net/index.php/User:Mandoman
User avatar
Fatleaf
Intergalactic Spam Assassin
Intergalactic Spam Assassin
Posts: 1988
Joined: Tue Jun 08, 2010 5:11 am
Location: In analysis mode on Phaelon
Contact:

Re: oxp Testing

Post by Fatleaf »

Check your inbox :wink:
Find out about the early influences of Fatleaf here. Also his OXP's!
Holds the Ooniversal record for "Thread Necromancy"
User avatar
mandoman
---- E L I T E ----
---- E L I T E ----
Posts: 1375
Joined: Thu Apr 28, 2011 3:17 pm

Re: oxp Testing

Post by mandoman »

Fatleaf wrote:
Check your inbox :wink:
I still am amazed how you pulled that off. :D
Mandotech Industries Wiki Page.

http://wiki.alioth.net/index.php/User:Mandoman
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Re: oxp Testing

Post by Smivs »

Leafy mentioned a log error regarding the texture (.png).
Change your 'Texture' folder to Textures' (plural) and it will work :wink:
Commander Smivs, the friendliest Gourd this side of Riedquat.
User avatar
mandoman
---- E L I T E ----
---- E L I T E ----
Posts: 1375
Joined: Thu Apr 28, 2011 3:17 pm

Re: oxp Testing

Post by mandoman »

Smivs wrote:
Leafy mentioned a log error regarding the texture (.png).
Change your 'Texture' folder to Textures' (plural) and it will work :wink:
Maaaaaan!! When am I going to get that stupid little detail right? You would think that I could at least remember how to name folders. Sheesh!! :o :oops:

Thanks Smivs. :)
Mandotech Industries Wiki Page.

http://wiki.alioth.net/index.php/User:Mandoman
Post Reply