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

Creating misssion oxp

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

Moderators: another_commander, winston

User avatar
Thargoid
Thargoid
Thargoid
Posts: 5525
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

explosive_shrapnel is actually a defined entity in the shipdata.plist of the OXP, which is spawned (multiple times) by the death_action of the ship (in the same plist). To replace it with a cargo pod full of gold (or multiples thereof, or a different item that scoops as gold) you'll need to define such an entity in the same way, and then spawn that.

It's not difficult, and you can use the explosive_shrapnel entity as an example template. But it's a little more complicated than just changing the explosive_shrapnel in the death_actions line to Gold.
User avatar
Rustybolts
---- E L I T E ----
---- E L I T E ----
Posts: 293
Joined: Sun Jun 07, 2009 6:22 pm
Location: UK

Post by Rustybolts »

Thargoid wrote:
explosive_shrapnel is actually a defined entity in the shipdata.plist of the OXP, which is spawned (multiple times) by the death_action of the ship (in the same plist). To replace it with a cargo pod full of gold (or multiples thereof, or a different item that scoops as gold) you'll need to define such an entity in the same way, and then spawn that.

It's not difficult, and you can use the explosive_shrapnel entity as an example template. But it's a little more complicated than just changing the explosive_shrapnel in the death_actions line to Gold.
So i've discovered thank you for confirming. Another idea i have had is to try this

Code: Select all

<key>death_actions</key> 
		<array> 
		<string>set: mission_bolts_targetdead TRUE</string> 
		<key>script_actions</key>
		<array>
		<string>awardCargo: 20 gold</string>
		<string>commsMessage: scooped 20 gold</string>
		</array>
		</array> 
*edit* dont work
maybe

Code: Select all

<key>death_actions</key> 
		<array> 
		<string>set: mission_bolts_targetdead TRUE</string> 
		<string>awardCargo: 20 gold</string>
		<string>commsMessage: scooped 20 gold</string>
		</array> 
*edit* Displays comms message but doesnt award the cargo
so instead in script i have

Code: Select all

{
					conditions = (
						"mission_bolts_targetdead equal TRUE",
						"mission_bolts equal STAGE1"
					);
					do =(
						"awardCargo: 20 gold",
						"set: mission_bolts STAGE2"
					);
				}
Above script and with the comms message in death actions in shipdata it appears as though you have scooped it. (sort of) :D
STE.+ Firefly/Dragonfly + BlackJacksbullion v.1.23 link below.
http://www.mediafire.com/?sharekey=ca16 ... f6e8ebb871
Image
User avatar
LittleBear
---- E L I T E ----
---- E L I T E ----
Posts: 2867
Joined: Tue Apr 04, 2006 7:02 pm
Location: On a survey mission for GalCop. Ship: Cobra Corvette: Hidden Dragon Rated: Deadly.

Post by LittleBear »

You can do it by spawning a special pod (a shipdata entry like_shiped to a normal pod but with a unique entry name). Spawn one of these. Add a JS to it that awards the gold when scooped. If you check the Mining Pods in Random Hits, you can use that code. These pods are lauched by the mining machines. The player can scoop them and gets a ton of minerals and a ton of machinary (the pod). But nicking GalMine's stuff is against the law, so the player also gets an increase in legal status. The JS script awards the minerals and the fine. So you could mod that to just award the gold but take out the line fining the player for pilfering. :wink:
OXPS : The Assassins Guild, Asteroid Storm, The Bank of the Black Monks, Random Hits, The Galactic Almanac, Renegade Pirates can be downloaded from the Elite Wiki here.
User avatar
Rustybolts
---- E L I T E ----
---- E L I T E ----
Posts: 293
Joined: Sun Jun 07, 2009 6:22 pm
Location: UK

Post by Rustybolts »

LittleBear wrote:
You can do it by spawning a special pod (a shipdata entry like_shiped to a normal pod but with a unique entry name). Spawn one of these. Add a JS to it that awards the gold when scooped. If you check the Mining Pods in Random Hits, you can use that code. These pods are lauched by the mining machines. The player can scoop them and gets a ton of minerals and a ton of machinary (the pod). But nicking GalMine's stuff is against the law, so the player also gets an increase in legal status. The JS script awards the minerals and the fine. So you could mod that to just award the gold but take out the line fining the player for pilfering. :wink:
Thanks for all your help.
If the player ship has full cargo he won't be able to receive his award, so i may stick to the sloppy method i came up with. Although i will be looking at your above suggestion so i know how to do in future when i attempt js.
STE.+ Firefly/Dragonfly + BlackJacksbullion v.1.23 link below.
http://www.mediafire.com/?sharekey=ca16 ... f6e8ebb871
Image
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:

Post by Commander McLane »

Rustybolts wrote:

Code: Select all

<key>death_actions</key> 
		<array> 
		<string>set: mission_bolts_targetdead TRUE</string> 
		<string>awardCargo: 20 gold</string>
		<string>commsMessage: scooped 20 gold</string>
		</array> 
*edit* Displays comms message but doesnt award the cargo
so instead in script i have

Code: Select all

{
					conditions = (
						"mission_bolts_targetdead equal TRUE",
						"mission_bolts equal STAGE1"
					);
					do =(
						"awardCargo: 20 gold",
						"set: mission_bolts STAGE2"
					);
				}
As you already discovered there is no need to insert script_actions into death_actions. Both are essentially the same, the only difference is the moment they are triggered. (See the Scripts within shipdata-page for more info on this.)

Therefore the above solution works. The reason it doesn't (and also the below version shouldn't) is a syntax error in the awardCargo: method. Again quoting from the methods-documentation, this time the Player rewards and penalties / Cargo-section:

Code: Select all

awardCargo: <amount> <Commodity name>
// awards a quantity of the cargo named
// the cargo name must match the name in commodities.plist exactly
// only positive numbers are allowed.
The hint is the second point. The names in commodities.plist are capitalized. Therefore the correct syntax is:

Code: Select all

		<string>awardCargo: 20 Gold</string>
User avatar
Rustybolts
---- E L I T E ----
---- E L I T E ----
Posts: 293
Joined: Sun Jun 07, 2009 6:22 pm
Location: UK

Post by Rustybolts »

Commander McLane wrote:
Rustybolts wrote:

Code: Select all

<key>death_actions</key> 
		<array> 
		<string>set: mission_bolts_targetdead TRUE</string> 
		<string>awardCargo: 20 gold</string>
		<string>commsMessage: scooped 20 gold</string>
		</array> 
*edit* Displays comms message but doesnt award the cargo
so instead in script i have

Code: Select all

{
					conditions = (
						"mission_bolts_targetdead equal TRUE",
						"mission_bolts equal STAGE1"
					);
					do =(
						"awardCargo: 20 gold",
						"set: mission_bolts STAGE2"
					);
				}
As you already discovered there is no need to insert script_actions into death_actions. Both are essentially the same, the only difference is the moment they are triggered. (See the Scripts within shipdata-page for more info on this.)

Therefore the above solution works. The reason it doesn't (and also the below version shouldn't) is a syntax error in the awardCargo: method. Again quoting from the methods-documentation, this time the Player rewards and penalties / Cargo-section:

Code: Select all

awardCargo: <amount> <Commodity name>
// awards a quantity of the cargo named
// the cargo name must match the name in commodities.plist exactly
// only positive numbers are allowed.
The hint is the second point. The names in commodities.plist are capitalized. Therefore the correct syntax is:

Code: Select all

		<string>awardCargo: 20 Gold</string>
Just checked my working script.plist and i had gold and not Gold but it still works.
Must only be in shipdata you need the complete correct syntax eg Gold.
By doing it in the script sometimes there is a delay upto 10secs from killing ship to awarding gold. It may have awarded it quicker by applying it in death actions, i dunno any thoughts?
STE.+ Firefly/Dragonfly + BlackJacksbullion v.1.23 link below.
http://www.mediafire.com/?sharekey=ca16 ... f6e8ebb871
Image
User avatar
Cmdr James
Commodore
Commodore
Posts: 1357
Joined: Tue Jun 05, 2007 10:43 pm
Location: Berlin

Post by Cmdr James »

Something that works but is wrong might not work on all platforms, or on all versions. There may well be a fix in a future version that might stop your OXP from working properly.
User avatar
Rustybolts
---- E L I T E ----
---- E L I T E ----
Posts: 293
Joined: Sun Jun 07, 2009 6:22 pm
Location: UK

Post by Rustybolts »

Cmdr James wrote:
Something that works but is wrong might not work on all platforms, or on all versions. There may well be a fix in a future version that might stop your OXP from working properly.
Ty for advice will change and re-upload
STE.+ Firefly/Dragonfly + BlackJacksbullion v.1.23 link below.
http://www.mediafire.com/?sharekey=ca16 ... f6e8ebb871
Image
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:

Post by Commander McLane »

Rustybolts wrote:
By doing it in the script sometimes there is a delay upto 10secs from killing ship to awarding gold. It may have awarded it quicker by applying it in death actions, i dunno any thoughts?
Well noticed. This is because of the way the scripting engine is working. Your script is in legacy (plist) format. Plist scripts are executed by the engine at intervals of roughly 10 seconds by a so-called "tickle". There are ways of forcing an immediate execution, but it is not advisable to use these ways, because on every tickle all scripts are executed. And generally the 10-second-interval should be something everybody can rely on.

The death_actions, while technically working as a script, are not triggered by a timer, but by the death of the entity they are ascribed to. And this can happen anytime, of course.

You find more general information on how scripts work in the wiki as well, notably on the OXP_howto, OXP_howto_plist, and in case of script.plist and the modalities of its executions, the Script.plist-page (the information about the 10-second-intervalls is in its Structure-section).

And by the way, JavaScript-scripts are handled completely differently. They are not triggered by a timer every 10 seconds, but by certain pre-defined events. Which (among other things) means that anything ascribed to the event of a ship being destroyed will be executed immediatly. Actually, this is exactly what happens with your death_actions, because all types of scripts within shipdata.plist are automatically translated and handled as JS-scripts by the engine.

Out of curiosity: Why are you bothering to script in the (deprecated) legacy plist-system in the first place? Why not learning JS-scripting right from the onset of your career as an OXPer? It is way more powerful than the legacy plist-system, which gives you only very limited possibilities for things you can do. A good place to start learning would of course be the Scripting_Oolite_with_JavaScript-page in the wiki, which gives a first overview and links to all relevant information.

And again I strongly suggest you study all this information linked to here in the wiki. It is there for a reason, and people have invested their time and their goodwill to put it there in a structured way. :)
User avatar
Rustybolts
---- E L I T E ----
---- E L I T E ----
Posts: 293
Joined: Sun Jun 07, 2009 6:22 pm
Location: UK

Post by Rustybolts »

I started writing legacy as at hand i could find more information on how to script this way. Also from making ships it was a little bit more familiar to me. At first glance on the wiki it mainly deals with legacy unless you delve a little deeper. any questions i have asked on the forum i have already searched on the wiki either through not understanding or the text not being clear enough i have then found the forum to be more helpfull. It was always my intention to learn java script and have since doing my oxp found out some information in this regard in thanks partly to do with kind peeps pointing me in the right direction. Now i have a working oxp, to learn java script my first task will be to convert it.

Many thanks
STE.+ Firefly/Dragonfly + BlackJacksbullion v.1.23 link below.
http://www.mediafire.com/?sharekey=ca16 ... f6e8ebb871
Image
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:

Post by Commander McLane »

Rustybolts wrote:
Now i have a working oxp, to learn java script my first task will be to convert it.
That's a very good idea and first step. :)

And the information is really there. As said above, the general information is the first thing you should study, followed by the object model (although this is a little outdated). If you've understood the concept of events, the list of event handlers gives you a good clue what kind of events there are in Oolite. Finally all documents which start with "Oolite JavaScript Reference" (all available through the Category:Oolite_scripting-page) contain the necessary information about properties (values you can read and/or manipulate) and methods (commands you can give in the case of any event). And that's basically it.

Just jump right into it and have fun! :D
User avatar
Rustybolts
---- E L I T E ----
---- E L I T E ----
Posts: 293
Joined: Sun Jun 07, 2009 6:22 pm
Location: UK

Post by Rustybolts »

Commander McLane wrote:
Rustybolts wrote:
Now i have a working oxp, to learn java script my first task will be to convert it.
That's a very good idea and first step. :)

And the information is really there. As said above, the general information is the first thing you should study, followed by the object model (although this is a little outdated). If you've understood the concept of events, the list of event handlers gives you a good clue what kind of events there are in Oolite. Finally all documents which start with "Oolite JavaScript Reference" (all available through the Category:Oolite_scripting-page) contain the necessary information about properties (values you can read and/or manipulate) and methods (commands you can give in the case of any event). And that's basically it.

Just jump right into it and have fun! :D
Any ideas on a basic javascript mission oxp i can study as i find it easier to learn by taking apart someone else's script. The only one i can think of is scourge of the black baron is this a good one to dissect?
STE.+ Firefly/Dragonfly + BlackJacksbullion v.1.23 link below.
http://www.mediafire.com/?sharekey=ca16 ... f6e8ebb871
Image
User avatar
Svengali
Commander
Commander
Posts: 2370
Joined: Sat Oct 20, 2007 2:52 pm

Post by Svengali »

Take a look in Eric's demoScript.js (included in UPS-courier). This shows and explains a bit more how to set up a missionscreen and do the populating. It is specially designed to avoid the clashes between oxps.
User avatar
Rustybolts
---- E L I T E ----
---- E L I T E ----
Posts: 293
Joined: Sun Jun 07, 2009 6:22 pm
Location: UK

Post by Rustybolts »

Svengali wrote:
Take a look in Eric's demoScript.js (included in UPS-courier). This shows and explains a bit more how to set up a missionscreen and do the populating. It is specially designed to avoid the clashes between oxps.
ty n1
STE.+ Firefly/Dragonfly + BlackJacksbullion v.1.23 link below.
http://www.mediafire.com/?sharekey=ca16 ... f6e8ebb871
Image
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5525
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

Or have a look at the mission in my Aquatics OXP.
Post Reply