Jump to content

How to Manipulate the RNG


Vykan12
 Share

Recommended Posts

Ever wanted to manipulate FE6-8’s RNG without constantly using guesswork and savestates? No? Well too bad. Here’s a guide on how to use a simple RNG script so that you can manipulate hits, level-ups, crits, etc, deterministically and with minimal effort. Sounds very technical, but it’s much, MUCH easier than you think it is. I’ll do the best to make this guide idiot-proof regardless.

First, you need an emulator that runs lua scripts. I highly recommend Visual Boy Advance re-recording V23.5a (http://code.google.com/p/vba-rerecording/downloads/detail?name=vba-rerecording-svn394-win32.7z&can=2&q=) but most of the newer versions of VBA on this page will work as well. Make sure to unzip the file you downloaded. If you don’t know how to do that, stop reading. You should end up with something like this:

VBAdownload.jpg

I recommend you create a folder and call it VBA to store these 3 items. Believe it or not, I’ve had problems with the emulator by putting it into an unnamed new folder. Probably has to do with vista sucking.

When you open a rom, make savestates, etc, folders will automatically be made for storing these things. Your VBA folder will probably end up looking like this:

VBAdownload2.jpg

Second, you’ll need RNG scripts. For now I’ll link to the FE8 scripts (http://tasvideos.org/forum/viewtopic.php?p=278325#278325) since scripts for the other GBA games are harder to find. Simply visit the link and download the first script, titled “rngdisplay”.

I’ll assume you have a working Fire Emblem: The Sacred Stones (U) rom. They’re not hard to find, but I can’t link you to them for copyright reasons.

Hopefully that wasn’t too scary! Now let’s begin.

Load your rom, start a chapter, make a savestate. I recommend you turn off battle animations, though it’s optional. For the purposes of this guide I’ll start at the prologue.

Prologue1.png

Now we want to run the script. Go tools -> lua scripting -> new lua window.

Luawindow1.jpg

Now click browse

Luawindow2.jpg

Find wherever you placed “rngscript” and double click.

VBAdownload3.jpg

If you’ve done everything correctly you should get the following:

Prologue2.png

What I’m pointing at in red is of paramount usefulness: You see the previous 3 RNs, and the next 10 RNs. This means you can follow the game’s RNG at all times! This alone will set you apart from those who reset abuse for their luck manipulation.

There are still 2 important things you need to learn, though.

How the RNG advances

When a player lands a hit, the game typically uses 3 RNs: hit, hit, crit. Even if the player’s crit is 0, an RN will still be used to check its value. However, when a player misses, the game will only use 2 RNs: hit, hit. All of what I said is also true for the enemy.

Here’s a very common scenario to consider: you have a high avoid unit such as Eirika who double attacks an enemy, and the enemy fails to hit. The RN sequence would be as follows:

1: Hit

2: Hit

3: Crit

--

4: Enemy Hit

5: Enemy Hit

--

6: Hit

7: Hit

8: Crit

Thus, when Eirika attacks, 8 RNs will be used. Now let’s say she also levels up from this fight. Now instead of 8 RNs, 15 consecutive RNs will be use. The RNG will check each stat in exactly the same order the game presents, namely:

9: Hp

10: Str

11: Skl

12: Spd

13: Def

14: Res

15: Luck

How can we use this to our advantage? Simple: with knowledge of hitrates, critrates, and even growth rates, you can figure out the acceptable values for the manipulated RN. Let me illustrate this by manipulating a critical for Eirika.

EirikaAttack1.png

[spoiler=“Note”] If the information on the left-hand script bothers you, it can easily be removed. Find “rngdisplay”, right click edit, and remove these lines from the code:

       gui.text(0,0,"Player")
       gui.text(0,8,"Hit: " .. memory.readbyte(phit))
       gui.text(0,16,"Damage: " .. memory.readbyte(pdmg))
       gui.text(0,24,"Crit: " .. memory.readbyte(pcrt))
       gui.text(0,40,"Enemy")
       gui.text(0,48,"Hit: " .. memory.readbyte(ehit))
       gui.text(0,56,"Damage: " .. memory.readbyte(edmg))
       gui.text(0,64,"Crit: " .. memory.readbyte(ecrt))

For the remainder of this guide my pictures have this removed, meaning no hit/damage/crit information on the LHS of the screen.

Look at the next 3 RNs:

1- Hit (38)

2- Hit (30)

Since (30 + 38) / 2 = 34 < 100, Eirika will hit, meaning the game will check if she crits.

3- Crit (7)

Since 7 < 14, Eirika will crit.

Since Eirika attacking uses 3 RNs, you already know the next RN is 96.

What’s weird is that in FE8, when a character lands a critical hit, an extra RN is used to see if they’ll use silencer (the skill that makes thieves instantly kill an enemy). I have no idea why this is, I’d say it’s a programming oversight.

In other words, Eirika’s first attack alone is using 4 RNs.

1- Hit (38)

2- Hit (30)

(Hit lands, so crit check)

3- Crit (7)

(Crit lands, so silencer check)

4- Silencer (96)

If you play out the whole sequence, 9 RNs will be used.

5- Enemy hit (55)

6- Enemy hit (85)

(Since (55+85)/2 = 70 > 39, the enemy misses and no crit check is done)

7- Hit (10)

8- Hit (10)

(Since (10+10)/2 = 10 < 100, there’s a hit)

9- Crit (89)

(Since 89 > 14, there is no crit)

After Eirika kills the brigand, the next RN will be 26.

EirikaAttack2.png

If you count how many RNs are between 38 and 26, you’ll notice 9 RNs were used, just as predicted.

Now for the more complicated stuff: Certain promoted classes have skills (eg/ pierce). These skill activations are checked after the hit but before the crit. For example, if you have a wyvern knight Vanessa attacking, she will burn RNs as follows:

1-Hit

2- Hit

3- Pierce (if hit lands)

4- Crit (if hit lands)

5- Silencer (if crit lands)

If that doesn’t make your head spin, having Vanessa attack a general will add even more complexity because of Great Shield. I’m not sure, but I think the sequence goes as follows:

1- Hit

2- Hit

3- Great shield (if it activates then the rest of Vanessa’s attack is ignored)

4- Pierce (if hit lands)

5- Crit (if hit lands)

6- Silencer (if crit lands)

It should come as no surprise that hundreds of RNs are used on enemy phases. It’s important to keep track of what RNs are responsible for what, otherwise you’ll likely screw up a manipulation.

Speaking of enemy phase, the game uses an RN every time an enemy moves. RNs are also used to determine the stat variation in starting and reinforcement enemies. This means that enemy stat deviations are manipulable.

That pretty much covers it, moving on:

How to Manipulate the RNG

You’re aware of how the game uses RNs to determine outcomes, but how do you manipulate the RNG to your advantage? Simple: by exploiting the game’s path drawing algorithm.

Since I’m lazy I’m going to copy-paste the explanation I gave on TASVideos:

Luck is manipulated in the run by abusing the game’s path drawing algorithm. When there are multiple ways to reach the same location (eg/ by pressing a diagonal input), the game’s random number generator determines which path to take. In fact, the path drawing algorithm is quite straightforward. For a simple diagonal path, random numbers between 0-49 will force the path to end horizontally, whereas RNs between 50-99 will force the path to end vertically.

Horizontallyendingpath.png

Verticallyendingpath.png

As you can clearly see, there are 2 different paths for a simple diagonal input

It should come as no surprise that the most efficient way to burn RNs is to draw a diagonal path as far as a character can move, then “wobble” the cursor back and forth between 2 spots, forcing the RNG to make as many decisions about the path drawn as possible.

If you’re at all confused, don’t worry. Applying this knowledge is amazingly simple.

Unfortunately the prologue is a horrible place to manipulate the RNG because it’s such a narrow map. The cursor doesn’t have the freedom to make decisions about how you form a diagonal path. Continue to chapter 1 and select Eirika:

C1RNG1.png

The next RN is 80. How can we burn an RN so that the next RN is 39? Simple, move the cursor diagonally (In this case I moved it diagonally up-left).

C1RNG2.png

Awesome, right? But how do you do it again? Just as simple. Undo your move (in this case move diagonally down-right), and repeat the original diagonal move (up-left).

C1RNG3.png

So now you’ve burned 2 RNs since starting the chapter. You can repeat this procedure as necessary to burn as many RNs as you want!

Unfortunately, making perfectly diagonal moves is pretty tricky. Often the game will register the movement inputs separately, and no RN will be burnt. With a bit of practice this won’t be a major issue, but it is annoying to deal with. If you really want 100% reliability, you could program 1 button to handle multiple button presses (eg/ down + right), but I don’t think it’s worth it.

OK, but Vykan… it’s very slow to burn 1 RN at a time like this, and I’m trying to manipulate something crazy! How do I speed up the process?

The key is to make a long diagonal path and “wobble” the cursor. The longer the diagonal path, the better. Let me illustrate this with Seth. Since this involves 5 pictures in a row I’m putting them in spoiler tags to save space.

[spoiler=“Seth RN Burn”]

Seth1.png

Seth2.png

Seth3.png

Seth4.png

Seth5.png

In 2 moves I manage to get Seth to burn 11 RNs! With this approach, if I were to continue wobbling, he’d burn about 5 RNs every time the cursor lands on a movable square.

There are 2 major drawbacks to this method, though: One, you can’t know for sure how many RNs any individual “wobble” will use. The value will often vary by +-2 from the average, sometimes more. Second, it’s very easy to skip over the RN you were trying to land on. In general, it’s a good idea to wobble until an RN comes up that you like, then burn one at a time until you reach it.

Last thing I’ll say: if you want to optimize wobbling, a flier is your best choice. The higher movement the unit has, the more RNs they can burn. Not only that, the diagonality of the path makes a huge difference. This is why RN burning in long corridors or around enemies is inefficient. The is also why the fact that fliers ignore most terrain is a huge boon for pulling off this RN burning technique. It all has to do with the number of decisions the RNG has to make about the path it is forming from the unit to the cursor’s present location.

Who Wants More?

That pretty much covers the basics of RNG manipulation using lua scripts for the GBA games. Perhaps this seems like a lot of information at first, but with some practice and experimentation, manipulating the RNG will become second nature to you.

If any section so far is unclear, I’ll try and clarify. I may also post a video tutorial with a voice-over since that’s the best way of teaching this. There are also more complicated RN exploits you can pull using RNG tables (useful for chaining together improbable occurrences), an enemy phase script (greatly facilitates enemy phase manipulations), and even a way of manipulating the RNG directly through memory watch (this is basically cheating though). I’ll cover these if enough interest is shown in them.

Link to comment
Share on other sites

Also, an important thing to note is that in FE6 only, there is a slight rounding error present, meaning that RN results of 100 are possible - this means that even attacks with 100 hit can miss, although this is very rare. You should also point out the same RNs are used for level ups, and about the order in which they occur after the combat results

Edited by Toothache
Link to comment
Share on other sites

I don't know if it's known already, but since this doesn't work in fe11/12, we have to use clock abuse, but was it known that the game uses an Rn each time you visit a shop? You can use a savepoint & enter, leave the shop until your Rn's are favorable. Or do Fe11/12 give you a fresh set of Rn's if you restart the game? Great guide btw, though I won't use it. Still Great. =)

Link to comment
Share on other sites

  • 5 months later...

I'm surprised this isn't getting more attention... Would be immensely useful in drafts for those who place no restrictions on themselves in terms of RNG abusing.

A while ago Roland made an improved RNGDisplay script (topic), even has a video showing a conditional search feature it has. In other words, you can make the script do things like tell you when's the nearest RNG sequence where value 1 is <50, value 2 is =3, etc. Also, RNGDisplay works for all the GBAFE games since the RNG addresses are the same in all 3 games.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...