1 2
11 12 13
Editor, Expert player (2080)
Joined: 6/15/2005
Posts: 3284
merrp wrote:
Also, what exactly is going on in that part of the video? Is it faster to enter a map on fadeout?
The next area will not load until the music fades out (unless the next area's music is the same as what is currently playing). So getting off/on the bike to fade the music before actually getting there saves some time.
merrp
She/Her
Player (20)
Joined: 7/31/2019
Posts: 56
I've uploaded my latest bk2 here: http://tasvideos.org/userfiles/info/58269355444860970
merrp
She/Her
Player (20)
Joined: 7/31/2019
Posts: 56
Also, although it's not related to my Any% TAS, here is a proof of concept demonstrating loading dynamic map, tileset & script data via ACE: https://youtu.be/K4CyB-iXjR0 Link to video
Editor, Expert player (2080)
Joined: 6/15/2005
Posts: 3284
After analyzing the stats during battle as well as Water Gun / Mud Shot usage, I am pretty sure that it is better not to get Strength or Secret Power. Neither of them seem to achieve a whole lot (all they seem to do is turn three crits into non-crits (Edit: I mean Strength eliminates three messages, could be crit messages or super effective messages)). Also, if you skip the hiker in Rusturf Tunnel, you can do the whole thing post-Team Aqua without running out of PP. I'll post a custom encode using my Lua script with the stats pasted on as a reference when I get around to it. Edit: Link to video Here is the custom encode showing the stats of Mudkip/Marshtomp as well as all the enemy Pokemon. I also put down the damage values (before crit/stab/type) for various attacks, stat stages, and for physical types whether the badge stat boost is present. Note that despite the coloring, Mud-Slap will never get STAB (at least, during the time when it is normally used), whereas Mud Shot and Water Gun will always get STAB. I used this to make a Water Gun / Mud Shot PP count, and found that if you skip the Hiker in Rusturf Tunnel, you have just enough to use without needing to refresh PP or learn another move, after Team Aqua in Slateport:
Pokefan
Plusle: mudshot  1
Minun: mudshot  2

Pokefan
Minun: mudshot  3
Plusle: mudshot  4

Brendan
Slugma: mudshot  5
Grovyle: tackle/mudshot   6
Wingull: tackle

Triathlete
Magnemite: watergun  1

Psychic
Abra: tackle

Wally
Ralts: watergun   2

Youngster
Zigzagoon: watergun 3
Gulpin: mudshot  7

Wattson
Voltorb: mudshot  8
Electrike: mudshot  9
Magneton: mudshot  10
Manectric: mudshot  11

Hiker
Geodude: watergun  4
Numel: watergun  5

2x solrock: 2x watergun  7

(Hiker)
(Geodude: watergun)
(Geodude: watergun)
(Machop: watergun)

Magma
Numel: watergun     8   * (strength saves a message)
Zubat: watergun (torrent)  9

Magma Admin
Numel: watergun    10   * (strength saves a message)
Poochyena: watergun (torrent)  11
Zubat: crit tackle    * (strength saves a message)
Numel: watergun   12

Magma Leader
Mightyena: watergun (torrent)   13
Zubat: watergun (torrent)   14
Camerupt: watergun   15

Flannery
Numel: mudshot 13
Slugma: watergun 16
Camerupt: watergun 17
Torkoal: watergun 18

Cooltrainer
Swellow: 2x watergun  20

Cooltrainer
Spinda: tackle, mudshot  13

Cooltrainer
Zangoose: tackle, mudshot 14

Norman
Spinda: watergun  21
Vigoroth: watergun 22
Linoone: watergun 23
Slaking: 2x watergun 25
merrp
She/Her
Player (20)
Joined: 7/31/2019
Posts: 56
Oh wow! That's super helpful! I will work this into the route this weekend. A few strategy concerns though: - If I don't fight the Hiker, it alters my final EV distribution. Most importantly, it leaves me 1 Attack EV short -- I'd just have to fight 3 Solrock instead of 2 Solrock + 1 Zigzagoon. On the other hand, less Defense EVs might mean I don't need a Qualot Berry - When do I get X Attacks, for Maxie/Norman? If I go and get them right after Wattson, I'll have to backtrack and travel the route twice, as opposed to once if I go after Flannery. This leads into: - You have a few moves marked as (Torrent). Do I not need X Attacks at all for Maxie, if I'm in Torrent range? Also I'm not sure if I can get into Torrent range for the Admin fight *and* also have Maxie's Mightyena not knock me out first turn. I might be able to manipulate it into using Sand-Attack, and take the accuracy loss though Ideally, I'd like the route to be: Wattson Meteor Falls Mt. Chimney Desert Verdanturf (buy X Attacks & Fluffy Tails) Pick up HP Up Teleport to Petalburg but it might have to be: Wattson Verdanturf Pick up HP Up Meteor Falls Mt Chimney Desert Petalburg
Editor, Expert player (2080)
Joined: 6/15/2005
Posts: 3284
merrp wrote:
- When do I get X Attacks, for Maxie/Norman?
Water is special type so you would get and use X Special, like you are already doing. I put stat stages for the physical types (for which you use X Attacks) in case it comes in handy for anything, but, looking at the strategy, it doesn't seem to be the case.
merrp wrote:
Also I'm not sure if I can get into Torrent range for the Admin fight *and* also have Maxie's Mightyena not knock me out first turn.
Oh, fair enough. Then replace "water gun (torrent)" with Mud Shot. It is also OHKO without crit and no Torrent is needed now. BTW, the crit tackle on Zubat requires some luck; it needs to be a 97%+ crit which is 1/64 chance.
merrp
She/Her
Player (20)
Joined: 7/31/2019
Posts: 56
Sorry, I meant to say X special, my bad. 1/64 isn't that bad. And yeah, do I still need the X Special for Maxie, or can I skip it?
Editor, Expert player (2080)
Joined: 6/15/2005
Posts: 3284
merrp wrote:
And yeah, do I still need the X Special for Maxie, or can I skip it?
Well, you can skip it. It's just that, without X Special, Mightyena takes two hits to defeat (Tackle + Torrent Water Gun), and Zubat needs a critical hit.
merrp
She/Her
Player (20)
Joined: 7/31/2019
Posts: 56
I'll see if it's workable to skip it until after Maxie. I'm pretty sure that with the AI, Mightyena will always Bite if in KO range, so I the Water Gun on it will have to be with the Quick Claw.
Editor, Expert player (2080)
Joined: 6/15/2005
Posts: 3284
I'm currently checking to see if there is a starting seed that makes it feasible to generate a wild encounter Pokemon with 0x3110 as its IV (lower word) and also with the correct PID. merrp, did you consider the strat of getting 0x3110 as experience at any point?
merrp
She/Her
Player (20)
Joined: 7/31/2019
Posts: 56
I did look into it a bit. There are a few candidate experience groups for which that amount of experience is fairly quick to acquire. There's a brief post about it a few pages back. Iirc, solrock and swablu at certain locations were catchable with close to the right amount of experience. I'm just not sure if it's actually faster. It would still require 4 Pokemon in the end (corruption target + dummy + pomeg + bootstrap) for single corruption. It also adds on the time of finding a frame to generate the Pokemon (which is usually less than a second) and a few battles to gain a precise amount of experience, which might be hard to create, I'm not sure. It takes away the time needed to grab the HP Ups and proteins (on the order of a minute total). Note that even if I didn't need the HP Up on Route 116, I'd still have to go to Verdanturf for Fluffy Tails as it is the only mart that sells them. So, it comes down to whether some additional battles are faster than getting those items, and like so many things with Emerald, I can't really say for sure which is faster unless I actually TAS it. As for generating seeds, you can influence the starting seed both by waiting inside the naming screen, and pressing buttons inside it. I.e, pressing A on a frame advances the timer that will become the seed by slightly more/less than if you did not press A that frame. It's a bit finicky and applies to all buttons not just A. Are you checking just method 1 Pokemon or wild Pokemon too?
merrp
She/Her
Player (20)
Joined: 7/31/2019
Posts: 56
Ugh, the thing with looking at wild PIDs is that because every frame gain or lost affects the RNG, the timing of when you could catch a wild Pokemon changes significantly and the search space is actually massive. Are you looking specifically at wild encounters soon after Mudkip? Maybe it's a good idea to run some sort of feasibility check--look at all 4 billion wild PIDs, and find what percentage satisfy those properties. That would give us a rough estimate of how much time would be added (a 1 in 1000 would take on average 1000 frames). Just simulate the RNG for every possible encounter in an area with rate 20. I have code to do this; when I get around to it I'll update this post with this information. Note: it's less than 4 billion ofc, because not every frame triggers an encounter and thus some PIDs are unreachable (bar using Sweet Scent). Finding out the exact number requires simming the entire RNG space.
Editor, Expert player (2080)
Joined: 6/15/2005
Posts: 3284
I'm searching both for a good Mudkip in addition to the wild encounter. Note that the proper wild encounter has a very low chance of occurring. To get the proper IV requires a 1/65536 chance; the proper PID: 1/3 chance; and the chance of triggering it: 1/9 * 1/2. To simplify things, I only aim for Mudkip with 30-31 Atk IV, 31 SpAtk IV and Spe IV is at least 5 (or at least 20 if Spe- Nature). Nature is SpAtk+ with any one of Def-, Spe-, SpDef-. I aim only for the third move to be 0x3110, not the fourth (which is possible, but requires double-corruption, and leaves less backup in case the moves don't work out), and I assume that Method 2 is in effect. (Almost all wild encounters use Method 2.) I ran a search using a C++ program and got a few results. I'm looking at two of them right now (sorry, I couldn't be bothered to clean up this formatting):
Initseed: 3f87 Delay: 89 nat19 h21 a31 b1 s25 c31 d9
228118f0
IV bytes: 3334 3110 PID: 14f83d42 nat5 spec33 Cycle: 80113(0)*

Initseed: f988 Delay: 99 nat17 h2 a30 b26 s22 c31 d10
bf9379af
IV bytes: 3318 3110 PID: 0677682f nat1 spec84 Cycle: 80087(12)*
Both have a target cycle of around 80000-80200, which places it approximately at Route 104 after using Teleport, when trying to get the ferry to Dewford Town. Before I proceed, can anyone confirm whether having these glitch moves is permissible? (all hex) 1st move - 1300 (Route 104 w/o pkrs) or 1100 (Route 102 w/o pkrs) 2nd move - One of A184, A183, 9984, 9983 (double corruption) or E184, E183, D984, D983 (single corruption) 4th move - One of 3334, 3318 (double corruption) or 7334, 7318 (single corruption)
merrp
She/Her
Player (20)
Joined: 7/31/2019
Posts: 56
Sounds good! I'm sorry that I haven't had a lot of time lately to put into this. If I get the chance, I'll let you know if those moves work. By method 2, I assume the calculator you're using computes PID the exact same way the game does, right? I've seen on other sites that there is some misinformation regarding how wild Pokemon are generated. The actual function that's called is CreateMonWithNature, in https://github.com/pret/pokeemerald/blob/master/src/pokemon.c It picks the nature *first*, then re-rolls the PID until it matches. Sometimes I've seen it (falsely) stated that the reroll happens a fixed number of times. (This is probably a really unnecessary concern sorry, I just wanted to make sure) The target cycle you mentioned sounds like it's in a good place, if the glitch moves are permissible. Could you tell me the value of the RNG at the target cycle(s)? That way I can set up an environment in mGBA to catch it, and corrupt it with hex editing to see if it works. Alternatively, just the initial RNG seed at new game and the number of offset cycles.
Editor, Expert player (2080)
Joined: 6/15/2005
Posts: 3284
Yes, I know for wilds it picks the nature to roll and then rolls the PID until it matches the nature. By "method 2" (I think it's actually called method H2 elsewhere) I'm referring to the pattern where there is a vblank in between the PID and the IVs. The position of the vblank can change at random but the game usually uses this vblank positioning. So the random numbers look like this:
#1:
228118f0 <- encounter trigger (this is cycle 80106 of seed 0x3F87)
40311ea3 <- species
615215da
b3381a45 <- nature to roll
3d4295d4 <- pid low
14f8c3b7 <- pid high
9017775e <- vblank
b110d779 <- ivs 1st three  
e668fcf8 <- ivs 2nd three

#2:
bf9379af <- encounter trigger (this is cycle 80068 of seed 0xF988)
0d3881f6 <- species
d2ecaa31
fd85c550 <- nature to roll
9ff3c383
daae893a
26fc7a25
6455a834
1df0d697
70b7c0be
4beb5559
a30ad558
12ae06eb
fef6ec82
b9beafcd
354fb0bc
682fe87f <- pid low
06771086 <- pid high
d55f3d81 <- vblank
3110de60 <- ivs 1st three 
66304f53 <- ivs 2nd three
merrp
She/Her
Player (20)
Joined: 7/31/2019
Posts: 56
Oh, that. IIRC, that's not actually random, but can be predicted. I think it's due to the game rolling the RNG for something else. I'll look into how. Whenever I've simulated wild Pokemon, I've never had to deal with that, which is weird--either I got very lucky or I ended up factoring it in when I based the code off of pokeemerald. Just to clarify, do you mean a whole extra frame/VBlank, and not just an extra RNG cycle? If it's the former, that's very bizarre. If it's the latter, then it almost certainly has to be caused by something in the encounter "chain" of using the RNG because I do not think other random events (i.e random cries on a route) can occur when an encounter is about to happen. This narrows down the number of functions where the extra cycle is consumed since there are only a few calls to Random in the call chain for wild encounters.
Editor, Expert player (2080)
Joined: 6/15/2005
Posts: 3284
Here is the script I use to examine the RNG: http://tasvideos.org/userfiles/info/58692469321661997 During wild Pokemon generation, the game usually inserts a frame break in between PID generation and IV generation. In some cases (usually when the game rolls for PID a lot), this frame break may occur in other places, such as during the rolls for PID. I'm currently planning out how to write a Lua script using BizHawk forms so I can integrate all my scripts together instead of having a hundred separate files.
merrp
She/Her
Player (20)
Joined: 7/31/2019
Posts: 56
Well, that definitely sounds like the vblank interrupt firing in the middle of PID/IV creation. It still seems strange to me because in the pokeemerald Discord, we theorized that PID rerolling could not ever cause a variable frame delay. The loop itself is very fast, only about 50 instructions, and the longest possible re-roll for all 2^32 seeds is about 400 iterations of that loop. So the PID rerolling shouldn't influence the timing at all because the delay is negligible compared to a frame. I'm curious as to what that extra frame is caused by then. Maybe it's more complicated than I remember and the PID is saved somewhere and IV generation is delayed until the next frame? Yeah, bizhawk scripting all of my scripts gets really annoying. I run BizHawk through Wine so opening scripts can be buggy. I know you had some nice-looking ones that I'll check out. Some of the memory addresses would have to be changed to match JP's memory map--have you had any trouble doing that?
Joined: 1/6/2012
Posts: 51
Location: France
FractalFusion wrote:
Before I proceed, can anyone confirm whether having these glitch moves is permissible? (all hex) 1st move - 1300 (Route 104 w/o pkrs) or 1100 (Route 102 w/o pkrs) 2nd move - One of A184, A183, 9984, 9983 (double corruption) or E184, E183, D984, D983 (single corruption) 4th move - One of 3334, 3318 (double corruption) or 7334, 7318 (single corruption)
From what I tested, 0xD984,0xD983 (2nd Move),0x3334 and 0x3318 (4th move) are not good as they freeze the game, whereas all the other moves do not seem to have any specific effect over the battle (moves work well and items too).
Editor, Expert player (2080)
Joined: 6/15/2005
Posts: 3284
I fixed the Lua script for the RNG analyzer and cleaned up some code: http://tasvideos.org/userfiles/info/58732884454006571 Turns out the previous one depends on "tables.lua", which I didn't provide. I rewrote it so it is in one file.
merrp wrote:
Some of the memory addresses would have to be changed to match JP's memory map--have you had any trouble doing that?
For the major addresses, I've already accounted for every single Gen 3 version (Ruby/Sapphire/Emerald/FireRed/LeafGreen and U/J for each). It's based on a previous script which I used in the VBA days. For things like Quick Claw or all the stuff you put in emerald-jp.lua, I haven't done it yet, though.
merrp
She/Her
Player (20)
Joined: 7/31/2019
Posts: 56
All of the stuff in emerald-jp is based off my disassembly of JP Emerald, which made finding the addresses a lot easier since you can compare functions to US Emerald (which is 99% decompiled and has most variables labeled) to find matches. That's located at https://github.com/arantonitis/pokeemerald-jp Quick Claw just looks at something called the "random turn number", which is pretty much only used for quick claw and set per turn. The battle damage and crit chances are based on the damage and the crit flags. It'd be nice to have one script that can examine almost everything, in or out of battle. I'm not very good with displays in lua.
Player (75)
Joined: 8/26/2015
Posts: 70
Is it possible to set Bizhawk to have the RTC clock fail like on a real console without using cheats? I've heard that it's a net benefit to have that as it reduces (or removes?) random calls on your Pokenav. I made the following cheat to emulate it in the US version in the meantime, but I'd rather set it up legitimately if possible. 03000DB8:0021 - set sErrorStatus (rtc.c) to (RTC_ERR_POWER_FAILURE | RTC_INIT_ERROR) I've also found a couple of things to do with text printing when exploring the game's memory, that could make TASing a bit easier. All addresses are for the US version.
  • Two main TextPrinters used, as far as I looked: one for shops and one for most other things.
  • The main TextPrinter used is at 0x020201B0
  • The shop TextPrinter used is at 0x02020264
  • Out of battle, there's a two-frame delay between the main TextPrinter becoming active, and being able to speed up text printing
  • If the state (at offset +0x1C) is 2 or 3, an A press will advance text.
I haven't found a reliable condition for when to press A to close a textbox yet. Once you have this, it should be pretty easy to write an automatic text-advance lua script and speed up TASing significantly.
merrp
She/Her
Player (20)
Joined: 7/31/2019
Posts: 56
In gamedb/gamedb_gba.txt in your Bizhawk folder, search for emerald, you'll see that rtc_enabled is set to 1. I tried changing that by removing it, but it seemed not to have an effect. Maybe Bizhawk isn't actually using the setting? Random pokenav calls also seem to be RNG dependent, as usually if you run into one that's not scripted (your dad's call going to Dewford, Roxanne calling you after Brendan 3, Wally calling you before Route 113), delaying a frame or to to land on the tile you'd receive the call on skips it. The texbox stuff is great! From my limited scripting experience, I think message boxes can be closed once the script pointer moves on from the "msgbox" command, so looking at the address of the script pointer could be a viable option. The relevant script contexts are sScriptContext1 at 0x03000E40 and sScriptContext2 at 0x03000EB8 (for JP Emerald).
Player (75)
Joined: 8/26/2015
Posts: 70
Quick lua script prototype, toggled by pressing K: https://gist.github.com/adituv/c45b80bb74dbe4815f737def015ff4fb This script handles automatically advancing text from the main printer, both in and out of battle. In-battle it has a few unnecessary inputs but I do not think they lose time; this is because of auto-advancing textboxes. This should be easy to fix once we locate gTextFlags. I tried to make it able to handle loading savestates gracefully, but this doesn't work well with seeking from savestate in Tastudio, so be careful with it.
merrp
She/Her
Player (20)
Joined: 7/31/2019
Posts: 56
in JP, gTextFlags is at 0x030030B4 Or did you mean for US?
1 2
11 12 13