|
Generation 1 & 2 RBY and GSC Resources and Tutorials. Mostly for disassembly. |
|
Thread Tools | Display Modes |
![]() |
#1 |
Johto Region Champion
![]() ![]() Join Date: Jul 2013
Location: Johto
Age: 29
Posts: 779
![]() ![]() ![]() ![]() ![]() |
![]()
NOTE: So far, this has worked great in testing. But let me know if anything weird happens.
PREFACE: ======== So you know how the newer games have a handy script code you can use to check whether or not a Pokémon in your party knows a particular skill? Well, Gen II doesn't have one of those, and that makes it really annoying to try and add new things like Dive or Secret Power or whatever else you want to do. So in this tutorial, I will show you how to modify one of the unused "special" commands and turn it into a very useful "Check Attack" command. WHAT THIS DOES ============== This script works by calling an existing ASM routine that was originally called by things like "using surf" and the like, except instead of checking for hardcoded values it will let you choose which skill to check for in the script, and it will return a value of "true" or "false" the same as other normal commands, making it very easy to use in a script. APPLYING THE CODE ================ We will start by repointing the old unused special (it just said "Now on Debug") to some blank space, so that we can insert our new script. You need to place this hack in Bank 3, since that is where the exising scripts were (and there is plenty of room for this small routine there, so it shouldn't be a problem). Anyway, the pointer we are looking for is found at xC383 in Pokémon Gold. It is a normal 3-byte pointer, so it can technically point to any bank. In this example, I will be repointing it to xFD12. So we will type 03 12 7D over the old pointer and save it. Now we will go to xFD12 and enter the new routine. So you will type: Code:
FA 73 D1 57 CD 87 47 38 06 3E 01 EA 73 D1 C9 3E 00 EA 73 D1 C9 That is the already compiled version, to make it quicker to put in. For those interested, the actual ASM instructions are: Code:
ld a,(d173) // Gets the value of the skill from the VAR ld d,a // The original routine needs the skill in register D, so we put it there call 4787 // Calls the existing "Does a Pokemon have this skill?" routine JR C, $06 // If the Pokémon does not have the skill, the C flag is set, so jump ahead to that case ld a,01 // Load A with $01, the value for "true" ld (d173),a // Put this value back in the VAR so we can check it with the "if" commands like normal ret // Return to the script, because we are done ld a,00 // If the Pokémon didn't have the skill, we jump here to load A with "false" ld (d173),a // Write A to the VAR so we can check it in the script ret // Return to the script, because we are done USING THIS IN A SCRIPT =================== To use the new check code in a script, all you have to do is this: Code:
loadvar 0x?? ' Skill number to check for special 0x6E APPLICATION EXAMPLE ================= Here is an example of how to use these new commands in an actual script. Code:
#org 0x15CBEE '----------------------------------- faceplayer loadfont loadvar 0x21 special 0x6E if true 0x4C29 ' 0x15CC29 2writetext 0x4C7E ' 0x15CC7E closetext loadmovesprites end #org 0x15CC29 '----------------------------------- 2writetext 0x4E49 ' 0x15CE49 closetext loadmovesprites end #org 0x15CC7E = BILL: You do not\nhave TACKLE.\e #org 0x15CE49 = BILL: TACKLE ME!\e In case anyone wants to use this, but doesn't feel confident adding an ASM routine for some reason, I've attached an IPS patch that will apply this hack to the offsets I used in the example. So if you apply this when starting a new hack, you should be fine. If you are applying it to an existing hack, make sure that the area at xFD12 is free space (00s). Let me know if anyone has any problems with this or if someone
__________________
|
![]() |
![]() |
Sponsored Links |
Tags |
adding, check attack, code, gold, script, [Tutorial] |
Thread Tools | |
Display Modes | |
|
|