New Ship's Role

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

New Ship's Role

Post by mandoman »

I have made a saucer type ship that I was thinking would be a up-to-now unknown to GalCop, the Empire, and the Federation, but have been mortal enemies of the Thargoids for a long time. I call it the UFOship. I would like it to only appear under certain conditions, such as when a certain number of Thargoid ships are present, and then only in a factor of chance. I have the model all worked out, with a dat file, and png, but that's about it. I tried following some scripts, and plists made for Thargoid Warships by other oxpers, but though those ships seem to have no problems, the UFOship doesn't even parse out as an entity. The game keeps insisting their should be a shipyard.plist for the UFOship, but I have no intentions of players having access to owning one. Am I going beyond what I'm allowed to create? It does indicate in Latest.Log:
14:42:13.049 [script.unpermittedMethod]: ***** SCRIPT ERROR: in Test.0.do.1.do.0.conditions.0 ("thargoid_number lessthan 2"), method "thargoid_number" not allowed.
14:42:13.049 [script.unpermittedMethod]: ***** SCRIPT ERROR: in Test.0.do.1.do.1.conditions.0 ("thargoid_number greaterthan 5"), method "thargoid_number" not allowed.
That seems to be in response to the script.plist trying to make the UFOship hunt the Thargoid ships, and any other ship that fires on it. If not fired upon, it will not retaliate, but will always attack any Thargoid ships present. I don't intend for them to be present in all Thargoid encounters, just every now and then, under certain conditions.

Maybe this isn't even a doable project, I don't know. I guess I'm asking if it is doable, and if someone could give it look for me.

I have the UFOship.oxp zipped, and was wondering if anyone with know-how in this type of oxp would take a look at it, and tell me where I've gone wrong. Any help is very much appreciated.
Mandotech Industries Wiki Page.

http://wiki.alioth.net/index.php/User:Mandoman
User avatar
Ironfist
Commander
Commander
Posts: 218
Joined: Tue Jun 28, 2011 2:16 pm
Location: London

Re: New Ship's Role

Post by Ironfist »

Mandoman,

A bit difficult to say without seeing the full script, but it looks like the process is assuming thargoid_number is the name of a routine rather than a number. This might be true if there is a routine called thargoid_number which checks for the number of thargoid ships in the system. Could you post the full script so we can check the rest of the syntax.

Ironfist
64bit Mint 10 and Win 8 64bit on E8400 at 3.6GHz - ATI HD5750 graphics.
Concentration is the ability to think of absolutely nothing when it is absolutely necessary.
User avatar
Zieman
---- E L I T E ----
---- E L I T E ----
Posts: 680
Joined: Tue Sep 01, 2009 11:55 pm
Location: in maZe

Re: New Ship's Role

Post by Zieman »

Looks like Oolite doesn't "know" what this thargoid_number in your script is.

If you're using JavaScript, you could define a variable called thargoid_number for your script, then the condition could work. Something like:

Code: Select all

this.shipExitedWitchspace = function()
    {
        var thargoid_number = countShipsWithPrimaryRole(thargoid);
     * your other code *
    }
   
* rest of the script *
Meh, I'm not sure about the usage of countShipsWithPrimaryRole function, Thargoid or some other who actually knows something about JS can correct me if I'm wrong here...
...and keep it under lightspeed!

Friendliest Meteor Police that side of Riedquat

[EliteWiki] Far Arm ships
[EliteWiki] Z-ships
[EliteWiki] Baakili Far Trader
[EliteWiki] Tin of SPAM
User avatar
mandoman
---- E L I T E ----
---- E L I T E ----
Posts: 1375
Joined: Thu Apr 28, 2011 3:17 pm

Re: New Ship's Role

Post by mandoman »

Ironfist wrote:
Mandoman,

A bit difficult to say without seeing the full script, but it looks like the process is assuming thargoid_number is the name of a routine rather than a number. This might be true if there is a routine called thargoid_number which checks for the number of thargoid ships in the system. Could you post the full script so we can check the rest of the syntax.

Ironfist
Oh sure. Here it is:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Test</key>
<array>

<!-- witchspace conditions -->
<dict>
<key>conditions</key>
<array>
<string>status_string equal STATUS_EXITING_WITCHSPACE</string>
</array>
<key>do</key>
<array>
<string>checkForShips: ufoship_ship</string>
<dict>
<key>conditions</key>
<array>
<string>shipsFound_number equal 0</string>
</array>
<key>do</key>
<array>
<dict>
<key>conditions</key>
<array>
<string>thargoid_number lessthan 2</string>
<string>planet_number equal -1</string>
<string>d100_number lessthan 20</string><!-- 20% chance of a ufo_ship in witchspace -->
</array>
<key>do</key>
<array>
<string>addShips: ufo_ship</string>
</array>
</dict>
<dict>
<key>conditions</key>
<array>
<string>thargoid_number greaterthan 5</string>
<string>planet_number equal -1</string>
<string>d100_number lessthan 75</string><!-- 95% chance of a ufo_ship in witchspace -->
</array>
<key>do</key>
<array>
<string>addShips: ufo_ship</string>
</array>
</dict>
</array>
</dict>
</array>
</dict>
</array>
</dict>
</plist>

Like I said, I kind of borrowed that from the Thargoid Carrier oxp, the creator to whom I would of course give credit in the final edition.
Zieman wrote:
Looks like Oolite doesn't "know" what this thargoid_number in your script is.

If you're using JavaScript, you could define a variable called thargoid_number for your script, then the condition could work. Something like:

Code:
this.shipExitedWitchspace = function()
{
var thargoid_number = countShipsWithPrimaryRole(thargoid);
* your other code *
}

* rest of the script *


Meh, I'm not sure about the usage of countShipsWithPrimaryRole function, Thargoid or some other who actually knows something about JS can correct me if I'm wrong here...

Zieman
I could certainly change it to Java Script. I do like Java Script better than the Apple.

Oh, those high percentage numbers will be much reduced, I was just putting it up high to try to trigger the ship appearance, you know, just to see it it WOULD appear.
Last edited by mandoman on Mon Oct 24, 2011 4:25 am, edited 2 times in total.
Mandotech Industries Wiki Page.

http://wiki.alioth.net/index.php/User:Mandoman
User avatar
CommonSenseOTB
---- E L I T E ----
---- E L I T E ----
Posts: 1397
Joined: Wed May 04, 2011 10:42 am
Location: Saskatchewan, Canada

Re: New Ship's Role

Post by CommonSenseOTB »

Mandoman, legacy scripts were obsolete 3 years ago. Does legacy scripting even actually work properly today? Use javascript man, so people can help you and there are so many good examples to study from by opening up oxps and looking. Oh, and what became of your sunbat oxp? All that work for nothing? Svengali has a new oxp out for adjusting textures in-game. You should try it out on the sunbat, make the adjustments and release it. Let people enjoy it! :D
Take an idea from one person and twist or modify it in a different way as a return suggestion so another person can see a part of it that can apply to the oxp they are working on.


CommonSense 'Outside-the-Box' Design Studios Ltd.
WIKI+OXPs
User avatar
Mauiby de Fug
---- E L I T E ----
---- E L I T E ----
Posts: 847
Joined: Tue Sep 07, 2010 2:23 pm

Re: New Ship's Role

Post by Mauiby de Fug »

They do indeed still work (is that not why they're called legacy scripts, or have I missed something?), and as far as I know, changes to Oolite are supposed to ensure that this does not change. But it is far more restrictive and incomprehensible, and much much more can be accomplished with Javascript!
User avatar
mandoman
---- E L I T E ----
---- E L I T E ----
Posts: 1375
Joined: Thu Apr 28, 2011 3:17 pm

Re: New Ship's Role

Post by mandoman »

CommonSenseOTB wrote:
Mandoman, legacy scripts were obsolete 3 years ago. Does legacy scripting even actually work properly today? Use javascript man, so people can help you and there are so many good examples to study from by opening up oxps and looking. Oh, and what became of your sunbat oxp? All that work for nothing? Svengali has a new oxp out for adjusting textures in-game. You should try it out on the sunbat, make the adjustments and release it. Let people enjoy it! :D
I did exactly that, though I haven't tried it yet. I'll post Latest.Log report on the attempt after I reload it into the AddOns folder. This is the script.js I made:

this.name = "UFOship Script"
this.author = "mandoman"
this.copyright = "(C) 2011 Me."
this.licence = "CC-NC-by-SA 2.0"
this.description = "Sets all Thargoid ships as primary target.";
this.version = "1.0 alpha 1"
this.UFOshipExitedWitchspace = function(attackthargoidships)
{
var thargoid_number = countShipsWithPrimaryRole(thargoid);
thargoid_numberlessthan2 = 20% chance of a ufoship in witchspace;
thargoid_numbergreaterthan2 = 30% chance of a ufoship in witchspace;
thargoid_numbergreaterthan10 = 70% chance of a ufoship in witchspace
{
Log("Initialising OXP " + name)
}

Well, I want to release the SunBat, but I was hoping to get permission from the author of the Behemoth.oxp to make one of the SunBat functions as a Navy Picket ship. Because it's so hard to see. I haven't heard back from him since he said he would take a look at it. Not sure what to do now. I have it running on my own Oolite game, and the SunBat has shown up in all of the color textures except the Navy Picket texture. I would suppose that means I haven't entered something in correctly, though I get no errors about it on the Latest.Log. I'll have to try out Svengali's texture adjuster, if I can figure out how to make it work. That seems to be about three quarters of the battle for me. It's fun, though. :)
Mandotech Industries Wiki Page.

http://wiki.alioth.net/index.php/User:Mandoman
User avatar
Capt. Murphy
Commodore
Commodore
Posts: 1127
Joined: Fri Feb 25, 2011 8:46 am
Location: UK South Coast.

Re: New Ship's Role

Post by Capt. Murphy »

I think you'll need two scripts Mandoman. What you've posted definitely won't work as is.

1 worldscript that controls when the UFO will be spawned (by checking for Thargoid numbers on launching from the station or exiting witchspace), and another ship script that will control each UFO finding and targeting the nearest Thargoid ship, which is probably best done in combination with an interlinked unique AI.
[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: New Ship's Role

Post by mandoman »

Capt. Murphy wrote:
I think you'll need two scripts Mandoman. What you've posted definitely won't work as is.

1 worldscript that controls when the UFO will be spawned (by checking for Thargoid numbers on launching from the station or exiting witchspace), and another ship script that will control each UFO finding and targeting the nearest Thargoid ship, which is probably best done in combination with an interlinked unique AI.
Yeah, it didn't work, for sure. I opened up the script.js in the Z-Handler.oxp to get some examples, and I came up with this:

this.name = "UFOship Script"
this.author = "mandoman"
this.copyright = "(C) 2011 Me."
this.licence = "CC-NC-by-SA 2.0"
this.description = "Sets all Thargoid ships as primary target.";
this.version = "1.0 alpha 1"

this.shipAttacksThargoids = function(attack);
{
log(this.UFOship, "Will exit from Witchspace:" + UFOship);
if (less than 2 thargoid ships are present === "20% chance")
{
}
}
this.UFOshipWillExitFromWitchspace = function()
{
log(this.UFOship, "Will exit from Witchspace:" + UFOship);
if (more than 2 thargoid ships are present === "30% chance")
{
}
}
this.UFOshipWillExitFromWitchspace = function()
{
log(this.UFOship, "Will exit from Witchspace:" + UFOship);
if (more than 10 thargoid ships are present === "60% chance")
{
}
}
this.UFOshipWillExitFromWitchspace = function()
{
log(this.UFOship, "Will attack thargoid:" + attack.thargoid);
}


this.UFOshipWillAttackThargoid = function()
{
log(this.UFOship, "Will attack missile:" + attack.missile);
if (Missile attacks UFOship === "attack missile")
{
}
{
this.UFOshipWillAttackMissile = function()
{
log(this.UFOship, "Will attack any ship:" + attack.any ship);
if (Any ship attacks UFOship === "attack any ship")
{
}
{
this.UFOshipWillAttackAnyShip = function()
{
log(this.UFOship, "Will enter Witchspace:" + enter.Witchspace);
if (All thargoids are destroyed === "enter Witchspace")
{
}
{
this.UFOshipWillEnterWitchspace = function()

Then I started getting the error reports from Latest.log. It says there is a syntax error in line 8, but from what I can tell, I wrote it very close to a similar command in the Z-Handler script.js. Here are the Latest.log error reports:

01:37:22.057 [shipData.load.begin]: Loading ship data.
01:37:22.559 [shipData.merge.failed]: ***** ERROR: one or more shipdata.plist entries have like_ship references that cannot be resolved: GW-constore
01:37:23.576 [shipData.load.error]: ***** ERROR: the shipdata.plist entry "GW-radars" specifies non-existent model "td-radars.dat".
01:37:25.866 [script.javaScript.exception.syntaxError]: ***** JavaScript exception (UFOship.anon-script): SyntaxError: syntax error
01:37:25.866 [script.javaScript.exception.syntaxError]: /home/mandoman/.Oolite/AddOns/UFOship.oxp/Config/script.js, line 8: this.shipAttacksThargoids = function(attack);
01:37:25.866 [script.javaScript.load.failed]: ***** Error loading JavaScript script /home/mandoman/.Oolite/AddOns/UFOship.oxp/Config/script.js -- compilation failed

I don't know what all that is about the "GW-radars", but the sytaxErrors come right after.
Mandotech Industries Wiki Page.

http://wiki.alioth.net/index.php/User:Mandoman
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6626
Joined: Wed Feb 28, 2007 7:54 am

Re: New Ship's Role

Post by 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.
User avatar
mandoman
---- E L I T E ----
---- E L I T E ----
Posts: 1375
Joined: Thu Apr 28, 2011 3:17 pm

Re: New Ship's Role

Post by mandoman »

another_commander 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.
OK, thanks.
Mandotech Industries Wiki Page.

http://wiki.alioth.net/index.php/User:Mandoman
User avatar
mandoman
---- E L I T E ----
---- E L I T E ----
Posts: 1375
Joined: Thu Apr 28, 2011 3:17 pm

Re: New Ship's Role

Post by mandoman »

I think I got it, though I'm not sure how to test it. It isn't drawing any unusual attention in Latest.log, other than to list it as installed. No more script errors. I did as recommended, and studied a tutorial on Javascript, and it didn't take long for me to understand what I was doing wrong. Capt. Murphy, I can see what you meant about it not having a chance the way I had it before. I tend to rush into things that are interesting to me, so I get tangled up fairly easily. I actually ended up making a "Scripts" folder, with four different .js scripts. I tried to use the commands as the tutorial suggested, and also by looking at what others had done (there ARE some differences between them, and the tutorial). For one thing, the tutorial I was studying was showing how to use Javascript within HTML, so I kind of had to phase out all the HTML references to understand any of the Java Script commands, and reactions. After a bit, I started changing my .js script, and began to see that just one .js was not going to do it. I had to make a .js for each entity that interacts with the UFOship, as well as one for the UFOship. I came up with UFOship.js, thargoid.js, missile.js, and aggressor.js. After pouring over what I'd done a few million times, I entered it back into AddOns, held the Shift key down, and clicked on Oolite. I then shut it down to look at all the errors I was sure would pop up in Latest.log, and danged if there were any there at all. Now, I know that doesn't mean that the oxp is working perfectly, but I still have to get a handle on how to run that oxp tester. I never yet have been able to look at one of my oxp ships without just running the game in such a way that I could buy the ship, and try it out. More ignorance on my part. I actually enjoy HTML, and Javascript, even if I'm crappy with it. :)
User avatar
Capt. Murphy
Commodore
Commodore
Posts: 1127
Joined: Fri Feb 25, 2011 8:46 am
Location: UK South Coast.

Re: New Ship's Role

Post by Capt. Murphy »

Nice one Mandoman - the online JS tutorials are good for understanding the syntax of JS and also the use of it's inbuilt functions (things like Math.random etc).

For Oolite you also need to get your head around around the game engine hooks onto your scripts, which is normally via blocks of code in functions defined under an event handler. Your code is run everytime the event happens in Oolite. For example code to check conditions and spawn a custom role ship would often be found in a...

Code: Select all

this.shipWillExitWitchspace = function()
{
     // Your code here
}

....code block which runs every time the player is about to exit witch space.

You can also have your own functions that are not defined by an Oolite event handler, but their code would normally be called from elsewhere within the script or in the case of a ship script potentially from the AI.plist of that ship.
[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
Gimi
---- E L I T E ----
---- E L I T E ----
Posts: 2073
Joined: Tue Aug 29, 2006 5:02 pm
Location: Norway

Re: New Ship's Role

Post by Gimi »

Mandoman, without the slightest knowledge of Java-script, I am going to forward some advice that Ahruman seems quite adamant about. Please use unique non-generic names for your scripts and plists. This to avoid conflicts with other OXP's. So rather than "missile.js", use "myoxp_missile.js".
"A brilliant game of blasting and trading... Truly a mega-game... The game of a lifetime."
(Gold Medal Award, Zzap!64 May 1985).
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: New Ship's Role

Post by Eric Walch »

Gimi wrote:
I am going to forward some advice that Ahruman seems quite adamant about. Please use unique non-generic names for your scripts and plists. This to avoid conflicts with other OXP's. So rather than "missile.js", use "myoxp_missile.js".
Same is true for ship keys in shipdata.plist. e.g. when I look in the shipdata of the wip version of 'XeptatisSword', I see keys that are just waiting to generate name conflicts: 'array', 'target', 'projection', 'spike' etc. When two oxps use the same name for their ship reference, only one will load in game and the other will get quite different 'ships' than expected. Or none at all because of other roles in that other oxp.
Post Reply