Creating a mission (setting mission objectives)

The place to discuss scripting and game modifications for X Rebirth.

Moderators: Scripting / Modding Moderators, Moderators for English X Forum

strude
Posts: 1435
Joined: Wed, 3. Aug 05, 08:15
x4

Creating a mission (setting mission objectives)

Post by strude » Thu, 27. Aug 15, 05:12

So, who would like to give me the basic run down on creating a mission and making it appear in game?

I've looked as some of the vanilla mission scripts, but struggle to make out the difference between just what's required to simply get a mission running and what's required for the particular vanilla mission I'm examining.

I'm confident I'll be able to work out the functional part of what I want to do (probably), but I'm struggling to figure out just how to get a new mission registered, started and ended.

Regards

Simon
Last edited by strude on Tue, 1. Sep 15, 16:44, edited 1 time in total.
Gaming PC: Gigabyte H270M-D3H | i7 7700 | 16Gb DDR4 | Gigabyte GTX1060 6Gb OC | Asus Xonar DGX | Window 10 Home 64bit | Samsung 256Gb SSD

Clownmug
Posts: 256
Joined: Wed, 11. Dec 13, 03:39
x4

Post by Clownmug » Thu, 27. Aug 15, 09:52

I don't know if I can explain it properly or thoroughly enough, but here's my take on how the vanilla missions work.

For most missions you have two md scripts that are important. The first is the GenericMissions.xml md script. Every time the player changes zones the "SelectOffer" cue from this script will choose a few potential mission offers to generate. If you want a mission to appear, just add a new <signal_cue> like this:

Code: Select all

<diff>
	<add sel="//cue[@name='SelectOffer']/actions/do_any">
		<signal_cue cue="md.GM_Your_Mission.StartGeneric" weight="100 * quota.deliver" />
	</add>
</diff>
The other important md script is the generic mission file itself. In the above example it's "GM_Your_Mission". First, the "StartGeneric" cue which was signalled by "GenericMissions.SelectOffer" checks all the stations to see which can take mission offers, then it randomly picks one to start setting up the mission. This is when a new cue based on the "Start" library is created.

The "Start" library has several cues that are used for setting up the mission. You can usually tell what the cue does based on its name. There's usually one or more "Check_Variation" cue which does stuff like check the area for enemy ships to use as targets. Then there's the "Do_Start_Mission" cue. In this cue, each of the "Check_Variation" cues are signalled to see if they can create a valid mission. If at least one is valid, a variation will be randomly signalled again to setup the actual mission.

Now that the "Do_Start_Mission" cue has picked a variation to setup, it can proceed to run its child cues. The first few cues are used to setup the mission briefing and the conversation with the npc offering the mission. For example, the "AddOfferSteps" cue sets the objectives for the mission briefing and the "ConversationStart" cue sets what the npc will say when the player opens the offer. After all these cues run, your actual mission offer will appear on the station.

Then there's the "MissionAccepted" cue. This is where the actual mission is created. For a lot of the vanilla missions, each step of the mission creates a new cue based on a RML md script (reusable mission library?). The parameters for these libraries are usually set by the "Check_Variation" cue that was used. Once a cue is completed it will either signal another cue for the next step in the mission or they will signal "MissionEnded". The mission either fails or is completed based on the results of this cue.

strude
Posts: 1435
Joined: Wed, 3. Aug 05, 08:15
x4

Post by strude » Thu, 27. Aug 15, 13:26

Thanks for your post. I'll take a look at the vanilla files and see if I can follow what you described.
Gaming PC: Gigabyte H270M-D3H | i7 7700 | 16Gb DDR4 | Gigabyte GTX1060 6Gb OC | Asus Xonar DGX | Window 10 Home 64bit | Samsung 256Gb SSD

strude
Posts: 1435
Joined: Wed, 3. Aug 05, 08:15
x4

Post by strude » Tue, 1. Sep 15, 16:43

Been looking through the files and trying a few things out.

I always seem to end up with an invalid mission objective.

The vanilla missions that I've looked at all use something like the following

Code: Select all

                <do_if value="$UpdateBriefing">
                  <update_mission cue="$MissionCue">
                    <briefing>
                      <objective step="$StartStep" action="objective.scan" text="$ObjectiveText"/>
                    </briefing>
                  </update_mission>
                </do_if>
I use the action type objective.custom, which then requires me to specify the attributes "customaction" and "customicon". I've just inserted text for the customaction field and referenced a vanilla icon name for the customicon field. I tend to think that customaction needs to reference something specified in another file, but I have no idea what that is suppose to reference. There is an actions folder (assets/fx/gui/actions) that contains zipped files with action names, but I have no idea about what those files do. Uncompressing them doesn't provide anything readily usable.

Can you provide me any assistance in this area, or should a make a new post so others might see?
Gaming PC: Gigabyte H270M-D3H | i7 7700 | 16Gb DDR4 | Gigabyte GTX1060 6Gb OC | Asus Xonar DGX | Window 10 Home 64bit | Samsung 256Gb SSD

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 13937
Joined: Sun, 20. Nov 05, 23:45
x4

Post by UniTrader » Tue, 1. Sep 15, 16:47

I think I have some vague ideas for this but can't look it up currently - will answer later
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 13937
Joined: Sun, 20. Nov 05, 23:45
x4

Post by UniTrader » Tue, 1. Sep 15, 17:39

Did you first create a Mission Objective? you need one before you can update it. (refer to <set_objective/> )

for the custom icon look into the libraries/icons.xml and either use one of the existent ones or add your own there.
the compressed files you mentoined are probably the Vanilla Action icons (gzipped dds files)

for the custom action you need to input a string, so either use customaction="'Your Objective'" (note the '' inside the "") or do it properly by using the text file and refer to entries there like customaction="{123,456}"
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)

strude
Posts: 1435
Joined: Wed, 3. Aug 05, 08:15
x4

Post by strude » Wed, 2. Sep 15, 11:21

Thanks UT. After I made this post, I realised I'd been stung by the missing one set of quotes for the customaction attribute, but I'd mostly shut everything down by then, so didn't fire things up to test it out. Will do that shortly and see if things come together.

I had set the customicon attribute to one of the named icons in the libraries/icon.xml file. I've just realised I was getting the same error for that field too (cannot evaluate expression or something to that effect), so I'll probably need the two sets of quotes for that field too.
Gaming PC: Gigabyte H270M-D3H | i7 7700 | 16Gb DDR4 | Gigabyte GTX1060 6Gb OC | Asus Xonar DGX | Window 10 Home 64bit | Samsung 256Gb SSD

strude
Posts: 1435
Joined: Wed, 3. Aug 05, 08:15
x4

Post by strude » Fri, 4. Sep 15, 12:35

Just quickly, can I do something like this?

Code: Select all

<set_value name="$MissionText" exact="$MissionText + $Some_other_text"/>
Is that supported or is there a better way that I don't know about? Otherwise I'll just make a temp variable and do something like this

Code: Select all

<set_value name="$MissionTextTemp" exact="$MissionText + @Some_other_text"/>
<set_value name="$MissionText" exact="$MissionTextTemp"/>
<remove_value name="$MissionTextTemp"/>
Gaming PC: Gigabyte H270M-D3H | i7 7700 | 16Gb DDR4 | Gigabyte GTX1060 6Gb OC | Asus Xonar DGX | Window 10 Home 64bit | Samsung 256Gb SSD

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 13937
Joined: Sun, 20. Nov 05, 23:45
x4

Post by UniTrader » Fri, 4. Sep 15, 12:43

You can do this but there are also other ways:
'%1 %2'.[$MissionText, $someothertext]
<replace_text /> command

Choose the one which suits your needs best
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)

strude
Posts: 1435
Joined: Wed, 3. Aug 05, 08:15
x4

Post by strude » Fri, 4. Sep 15, 12:48

UniTrader wrote:'%1 %2'.[$MissionText, $someothertext]
So I'd use that like

Code: Select all

<set_value name="$MissionText" exact="'%1 %2'.[$MissionText, $someothertext]
Gaming PC: Gigabyte H270M-D3H | i7 7700 | 16Gb DDR4 | Gigabyte GTX1060 6Gb OC | Asus Xonar DGX | Window 10 Home 64bit | Samsung 256Gb SSD

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 13937
Joined: Sun, 20. Nov 05, 23:45
x4

Post by UniTrader » Fri, 4. Sep 15, 17:16

Exactly - would write more but its a bit cumbersome to type XML tags on the phone
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)

Xenon_Slayer
EGOSOFT
EGOSOFT
Posts: 11319
Joined: Sat, 9. Nov 02, 12:45
x4

Post by Xenon_Slayer » Fri, 4. Sep 15, 17:36

You could simply have:

Code: Select all

<set_value name="$MissionText" exact="$MissionText + $OtherText"/>
Or if you're feeling really fancy

Code: Select all

<set_value name="$MissionText" operation="add" exact="$OtherText"/>

strude
Posts: 1435
Joined: Wed, 3. Aug 05, 08:15
x4

Post by strude » Sat, 5. Sep 15, 02:21

Xenon_Slayer wrote:You could simply have:

Code: Select all

<set_value name="$MissionText" exact="$MissionText + $OtherText"/>
Or if you're feeling really fancy

Code: Select all

<set_value name="$MissionText" operation="add" exact="$OtherText"/>
The secone one looks more elegant. :D

The first was what I started with, but wasn't sure about using $MissionText in the expression since that was the variable I was assigning to.
Gaming PC: Gigabyte H270M-D3H | i7 7700 | 16Gb DDR4 | Gigabyte GTX1060 6Gb OC | Asus Xonar DGX | Window 10 Home 64bit | Samsung 256Gb SSD

strude
Posts: 1435
Joined: Wed, 3. Aug 05, 08:15
x4

Post by strude » Sun, 6. Sep 15, 04:00

This mod is actually progressing quite well, thanks everyone for the pointers!

Some more questions though.

If I add missions to the game, I assume that will affect the save game (i.e. save="true" in content.xml)? If I want to allow an uninstall for this mod, how would I go about tracking down the missions I've created to remove them before uninstall? Or would it be best to just say no uninstall and leave save="true". I'd prefer not to do that as it might dissuade people from tying out the mod.

Also since I may have Xenon_Slayer's ear for a minute :D (Y'all can answer too if you know the answer, but it might be a more internal code type question.)

I'm actually creating upkeep missions, however the only generic type missiontype I can find is missiontype.other, which doesn't register as an upkeep mission, and all the upkeep mission types are for a purpose. Any chance we can get a generic missiontype.upkeep_other? At the moment I use the missiontype.upkeep_hirenpc, which seems to do the job. Can you tell me if using that missiontype will have any adverse effects? Or should I be doing it a different way.
Gaming PC: Gigabyte H270M-D3H | i7 7700 | 16Gb DDR4 | Gigabyte GTX1060 6Gb OC | Asus Xonar DGX | Window 10 Home 64bit | Samsung 256Gb SSD

Xenon_Slayer
EGOSOFT
EGOSOFT
Posts: 11319
Joined: Sat, 9. Nov 02, 12:45
x4

Post by Xenon_Slayer » Mon, 7. Sep 15, 14:32

I've not played around with extensions much (at least beyond the official stuff). When it comes to the MD I think it is simply if the MD file exists, so do the cues and these will be saved. Remove that MD file, all the cues disappear when you next load the savegame.

Of course, that can lead to some objects from the missions being left behind e.g ships/NPCs. But the mission entry itself and its cues will be cleaned up.


As for the upkeep missions, it should be fine to reuse of those mission types. Those are mainly for things like icons, not tracking the mission.

Post Reply

Return to “X Rebirth - Scripts and Modding”