NERPs scripting with ogun's tool

From RRU Knowledge Base

This article is an unfinished work in progress or contains transferred information that needs to be rewritten or reformatted to fit our standards. Please excuse the mess and do not mark for deletion.

To do: Wording, formatting, dead-end page, this should resemble an actual tutorial

This tutorial will teach you how to use Ogun's npl assembler/disassembler/compiler to create an NPL file for your level.

The following things are assumed about the user, who are going to use the tutorial:

basic knowledge in: modding Lego Rock Raiders and using the command line

used operating system: Windows

The reasons for creating a npl file for a level can be found here.

Part 1: Compiling a ".npl" file

First, grab ogun's tool: here. If you suck with command lines, extract the zip's contents onto your desktop, not into a folder on your desktop. Otherwise, extract contents anywhere. Now, create a text file in the directory you placed the npl tool and name it test.txt. Open it in your favorite text editor (nothing fancy like Microsoft word though), and paste this into it:

[code]TRUE ? SetTutorialFlags 0 TRUE ? SetMessagePermit 1

Check for level fail

TRUE ? SetR1 0 GetToolstoresBuilt = 0 ? AddR1 1 GetMinifiguresOnLevel = 0 ? AddR1 1 GetR1 = 2 ? SetLevelFail

Check for level success
GetCrystalsCurrentlyStored > 199 ? SetLevelCompleted

GetMinifiguresOnLevel = 3 ? SetLevelCompleted[/code]

Ok, rename the file to test.nrn Great, You're more than halfway there! Now, open up a command prompt. Navigate to the directory you placed the npl tool. (If you placed it on the desktop, then all you have to do is type cd Desktop if you are using vista/windows 7. Should be pretty much the same for all windows OSs.). And type:

[code]npl -c test.nrn -o test.npl[/code]

(You do not necessarily have to rename your txt file to nrn, although for the sake of following the guide, do so the first few times.) Finally, place the resulting npl in your level folder (don't forget to rename it accordingly!) and test your level. If you did it right,you will win once you teleport down 3 rock raiders.

Part 2: Intro to goal scripting

Good, now we know how to compile our scripts into gibberish that the game executes. So, I shall begin teaching you goal scripting itself.

Example 1. - The basics

So, create your text file. Add this:

[code]TRUE ? SetTutorialFlags 0[/code]

According to the wiki, that disables all "game tutorial functions." Now this goes in:

[code]TRUE ? SetMessagePermit 1[/code]

According to the wiki, that "Enables the game to show messages as needed." Ok, so there is all the "boring necessary code". Now, we will write a lose level check.

[code]TRUE ? SetR1 0[/code]

This sets the first register to 0. What are these registers? They just are variables for you to use, explained on the lowest level.

[code]GetToolStoresBuilt = 0 ? AddR1 1[/code]

Here we encounter several things. GetToolStoreBuilt = 0 asks the game how many tool stores are built, then checks to see if that is equal to 0. The '?' Means, If true, then do this. AddR1 1 tells the game to increase the value of register 1 by 1. So that line increases the value of register 1 by 1 if there are no toolstores on the level.

[code]GetMinifiguresOnLevel = 0 ? AddR1 1[/code]

It is exactly the same as above, only here it checks if the number of mini-figures is equal to zero.

[code]GetR1 = 2 ? SetLevelFail[/code]

GetR1 = 2 checks if register 1 has a value of true. The only way that can occur in this script is if there are no tool stores in the level and no mini-figures in the level. SetLevelFail tells the game that you lost the level. Now for the victory condition.

[code]GetCrystalsCurrentlyStored > 9 ? SetLevelCompleted[/code]

GetCrystalsCurrentlyStored checks how many crystals are in the level. If that is greater than 9, for example the value is 10, then you win the level because of SetLevelComplete. Although no level that comes with the game does this, you can set a collect ore objective simply by changing the last line to:

[code]GetOreCurrentlyStored > 99 ? SetLevelCompleted[/code]

Here is how you can set level fail on 0 or less air:

[code]GetOxygenLevel < 1 ? SetLevelFail[/code]

Get oxygen level simply asks the game how much oxygen there is, then it checks if it is less than 1. If so, it then tells the game that you failed the level.

Example 2 - Slimy slugs based on rock raider count.

Just create your text file and fill it with all the lose-win code you wish.

[code]TRUE ? SetR2 0[/code]

First, we set register 2 to 0. Register 2 will be used to keep track of how many conditions were met for slugs to emerge.

[code]GetMiniFiguresOnLevel > 5 ? AddR2 1[/code]

This is the first condition. 6 or more raiders must be teleported down to the level before the stream of invasion notices can begin.

[code]GetSlugsOnLevel = 0 ? AddR2 1[/code]

This is condition 2. It checks if there are 0 slugs on the level.

[code]GetR2 = 2 ? GenerateSlug[/code]

Now it checks if both of these conditions are met. If so, it generates a slug with GenerateSlug. You can spice up this script to make invasions more random by adding this line before the check:

[code]GetRandom100 = 1 ? AddR2 1[/code]

And changing the check to this:

[code]GetR2 = 3 ? GenerateSlug[/code]

Oh wait, a new name has occurred. GetRandom100 supposedly generates a random number that is no greater than 100. We then tell the game that if that random number happens to equal 1, then another condition is met. I suggest you make a whole new level in the map creator solely for the purpose of trying this out. And by the way, here is a modified version of the script above that I use to tease the player in the upcoming version of my map, Karnanga:

[code];Simple slimy slug script. I use it to freak out the player. TRUE ? SetR2 0 GetMiniFiguresOnLevel > 9 ? AddR2 1 GetMiniFiguresOnLevel < 21 ? AddR2 1 GetRandom100 = 1 ? AddR2 1 GetR2 = 3 ? GenerateSlug[/code] You should be able to figure out that this makes slugs randomly come out as long as the player has more than 9 raiders, but less than 21.

Warning, certain levels that come with the game will not work with your custom npl file. For optimal testing conditions, make your own level and test the npl in that.