Discovery Gaming Community
Random Missions: An Ongoing Tutorial-Guide - Printable Version

+- Discovery Gaming Community (https://discoverygc.com/forums)
+-- Forum: Discovery Development (https://discoverygc.com/forums/forumdisplay.php?fid=7)
+--- Forum: Discovery Mod General Discussion (https://discoverygc.com/forums/forumdisplay.php?fid=37)
+--- Thread: Random Missions: An Ongoing Tutorial-Guide (/showthread.php?tid=66248)



Random Missions: An Ongoing Tutorial-Guide - Taneru - 09-14-2011

Firstly, before I begin, I would like to make note that this 'tutorial', if you wish to call it that, is not going to be like most tutorials you may have read before. I am not writing this with full knowledge of the entirety of Random Mission system, though by the time this is complete, I certainly expect to have at least a portion of that knowledge, if not most of it.

There are few tutorials out there that touch on the area of Freelancer's Random Mission system, and when I first took a look at it, I could see why. Those that do tend to be oriented towards the inclusion of missions for newly created NPC factions, or adding missions into new systems. This tutorial is not about that.

What this guide is about is the examination and alteration of the Random Mission system to allow for new mission types, as well as enhancements to existing mission types. Before we attempt to make any changes to the mission system, though, we need to know how it works.
Keep in mind that it is very likely there is more to the Random Mission system than this, and as I am only trying to explain what I see and understand at the time of writing, some of what I say here may not be completely accurate. As I understand more of the code, I may end up rewriting sections if they turn out to be incorrect. So, do not take what I say to be the absolute truth, though I will do my best to keep it as correct as possible.

Part 1: The Mission Tree

Freelancer's Random Mission system seems to use a branching data structure system that is commonly referred to in Computer Science as a 'tree'. It is called this because of the way it stores data in linked 'nodes'. Beginning from a 'root' node, each node contains both information and a link to one or more subsequent nodes(These links only go one way). These nodes, in turn, may link to more nodes, which yet again link to even more nodes.
In Freelancer's case, these nodes will eventually all link to certain specific nodes which I am going to refer to as 'end' nodes. These nodes do not have any 'child' nodes(When referring to two linked nodes in a tree, the first node is called the 'parent', while the one the parent links to is called the 'child'), so once Freelancer reaches that node, the mission is finished being generated.
Freelancer uses the branching nature of this data structure to allow it to generate missions which are essentially unique by simply varying the path it takes from the root node to the end nodes. There is a theoretical limit to the number of 'unique' missions that can be generated, due to the nature of the tree data structure, but there are enough branching nodes and other varying elements like NPC AI that the limit does not matter.

The simplest way for us to understand the Random Mission system is to trace our way through it, and as such, the place to begin is at the root node.
Code:
[DocumentationNode]
node_id = 2
documentation = RANDOM_MISSION
child_node = 247

There are three types of nodes used in the Random Mission system, and the two most common types are DataNodes and DecisionNodes. The root node is of the third, less common type; a DocumentationNode. DataNodes store information used to generate the mission, whereas DecisionNodes are where the tree branches into two paths. DataNodes all have a maximum of one child, though some have none, and DecisionNodes have exactly two, though in some cases, both child nodes are the same node. DocumentationNodes are similar to DataNodes, but the information they contain appears to be used for reference purposes when writing the system, rather than generating the missions.

While the node_id and child_node data fields are common throughout the entire Random Mission system, the documentation data field is unique to DocumentationNodes. For the root node, it has the value of RANDOM_MISSION, which, combined with the root node's id value, leads me to believe that the node with the id of 1(which is not in the Vignette Params file) deals with the Single Player Campaign, with both nodes being children of a root node for Freelancer's entire mission system of 0(the first element in most data structures is normally assigned the id of 0). This is simply speculation, however.

From the root node, we continue our trace upwards to its child node.
Code:
[DataNode]
node_id = 247
comm_sequence = IN_SPACE_NOT_IN_SYSTEM, PLAYER, 1.000000, 15.000000, 20.000000, BASE, rmb_flytosystem
comm_sequence = LEFT_COMBAT_AREA, PLAYERS_IN_RANGE, 1.000000, 0.500000, 1.000000, BASE, rmb_outofbattle
comm_sequence = REENTERED_COMBAT_AREA, PLAYERS_IN_RANGE, 1.000000, 0.500000, 1.000000, BASE, rmb_reenterbattle
comm_sequence = GLOBAL_FAIL_COMBAT_RANGE, ALL_PLAYERS, 1.000000, 1.000000, 5.000000, BASE, rmb_fail_combatrange
comm_sequence = GLOBAL_FAIL_DESTROYED_CRITICAL_LOOT, ALL_PLAYERS, 1.000000, 1.000000, 5.000000, BASE, rmb_fail_destroyedloot
comm_sequence = GLOBAL_FAIL_OTHER, ALL_PLAYERS, 1.000000, 1.000000, 5.000000, BASE, rmb_fail_outoflives
child_node = 461
As you can see, this node is a DataNode and, in this case, contains six comm_sequence entries in addition to the standard node_id and child_node data fields. As you can probably guess, these new data fields deal with comm messages you receive. While the purpose of the numbers are currently unknown to me, the rest of the lines are fairly clear. The first part is the trigger for the comm message, and the next is who the comm message is sent to. The last two indicate the base of origin of the message, and the audio message to be played.
For example, the first of the comm_sequence lines will trigger if the player is in space, but not in the same system as the mission, resulting in the base sending them the familiar message "Proceed to the target system, the path has been marked on your navmap."

I will resume this tomorrow, and will probably end up rewriting a lot of it.


Random Missions: An Ongoing Tutorial-Guide - (ツ) - 09-15-2011

' Wrote:Firstly, before I begin......

I have a big thumbs-up-situation over here!
Keep on writing this guide....