• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Script✓] Set the nickname of a pokémon to the [player] var?

222
Posts
6
Years
    • Seen Nov 18, 2023
    Hey, this might be a weird request, but I am trying to manually set the nickname of a pokemon to a preset variable (namely the player name) by completely bypassing special 0x9E. Is there any way to do this at all? I'm pretty sure I remember there being a pointer to the playername but I'm not quite sure what that was...
     
    Last edited:

    DrFuji

    [I]Heiki Hecchara‌‌[/I]
    1,691
    Posts
    14
    Years
  • Changing a Pokemon's nickname to the player's name is pretty simple to do through copying bytes in the the game's memory and easily be done in XSE. Here's a script that will give the player two Bulbasaurs and change the first one's name to the player's name:

    Code:
    #dynamic 0x800000
    
    #org @start
    setflag 0x828
    givepokemon 0x1 0x1 0x0 0x0 0x0 0x0
    givepokemon 0x1 0x1 0x0 0x0 0x0 0x0
    copybyte 0x0202428C 0x02024298
    copybyte 0x0202428D 0x02024299
    copybyte 0x0202428E 0x0202429A
    copybyte 0x0202428F 0x0202429B
    copybyte 0x02024290 0x0202429C
    copybyte 0x02024291 0x0202429D
    copybyte 0x02024292 0x0202429E
    writebytetooffset 0xFF 0x02024293
    writebytetooffset 0xFF 0x02024294
    writebytetooffset 0xFF 0x02024295
    end

    In this script I'm copying the original trainer name from the Pokemon's data and overwriting the nickname data. As the trainer name can only be a maximum of seven letters we then need to pad the last three letters with 0xFF just in case the Pokemon's name is longer that that. If the Pokemon was traded it will have the trader's trainer name but it should be fine in 99% of cases. If the Pokemon you're trying to assign the name to isn't the first one in your party you will have to add 0x64 to each of the pointers for each Pokemon until you reach the party member you want to nickname. You could also give a Pokemon a static name just by using the writebytetooffset command if you wanted a Pokemon to have a specific name that wasn't the trainer's.

    This script is designed for FireRed but it can be ported over to Emerald like this though I haven't tested it:
    Code:
    copybyte 0x020244F4 0x02024500
    copybyte 0x020244F5 0x02024501
    copybyte 0x020244F6 0x02024502
    copybyte 0x020244F7 0x02024503
    copybyte 0x020244F8 0x02024504
    copybyte 0x020244F9 0x02024505
    copybyte 0x020244FA 0x02024506
    writebytetooffset 0xFF 0x020244FB
    writebytetooffset 0xFF 0x020244FC
    writebytetooffset 0xFF 0x020244FD

    Hopefully that's what you're after!
     
    222
    Posts
    6
    Years
    • Seen Nov 18, 2023
    Thank you so much! This was exactly what I needed!

    You could also give a Pokemon a static name just by using the writebytetooffset command if you wanted a Pokemon to have a specific name that wasn't the trainer's!

    Hey, sorry to bother you again, but could I possibly see an example of this using a string pointer? I don't think I quite grasp the functions of copybyte and writebytetooffset yet. When reading a static string, do I have to iterate every letter in the name by increasing the offset by 1?

    Also, I'm pretty sure I'd have to figure out the size of the party in order to write the nickname to the right one. So my question is, when a pkmn is added to the party, is the size of your party updated directly when givepokemon is called? Or by some other command I have to call or wait to execute before I can run my own logic?

    Also, what is your source for the pointers of your Pokemon? Is it possible to edit other things as well like nature and gender? If you could provide a link to where you got your data structure info from that would be great!

    Thanks!

    EDIT: I found the article on data structures. I'm curious to know how one could prevent bad eggs because the data structures have checksums and if I edit things like nature that might radically change. Or does that only check some things and not the sort of things I'm changing?
     
    Last edited:

    DrFuji

    [I]Heiki Hecchara‌‌[/I]
    1,691
    Posts
    14
    Years
  • Hey, sorry to bother you again, but could I possibly see an example of this using a string pointer? I don't think I quite grasp the functions of copybyte and writebytetooffset yet. When reading a static string, do I have to iterate every letter in the name by increasing the offset by 1?

    Yep, each byte corresponds to a single letter so we need to begin with the first byte and increase it by one until we're done. Writebytetooffset is pretty simple to use as it just overwrites a byte value in the game's RAM with a value of your choice. Copybyte on the other hand take a byte from the RAM, indicated by the second pointer in the command and copies it over the first pointer in the command. You can read the game's RAM by clicking 'Tools > Memory Viewer' in VBA and putting in the pointers you want. Since you asked for it, here's an example of me naming the first Pokemon in my FireRed party 'Chemical'. Since its a static name and I know exactly what name is being given (unlike your trainer name request) I can just write it in hexadecimal:
    Code:
    writebytetooffset 0xBD 0x0202428C // C
    writebytetooffset 0xDC 0x0202428D // h
    writebytetooffset 0xD9 0x0202428E // e
    writebytetooffset 0xE1 0x0202428F // m
    writebytetooffset 0xDD 0x02024290 // i
    writebytetooffset 0xD7 0x02024291 // c
    writebytetooffset 0xD5 0x02024292 // a
    writebytetooffset 0xE0 0x02024293 // l
    writebytetooffset 0xFF 0x02024294 // null
    writebytetooffset 0xFF 0x02024295 // null

    Here's a list of all the hex values and what their corresponding letter is, thanks to diegoisawesome's XSE tutorial:

    Spoiler:


    Also, I'm pretty sure I'd have to figure out the size of the party in order to write the nickname to the right one. So my question is, when a pkmn is added to the party, is the size of your party updated directly when givepokemon is called? Or by some other command I have to call or wait to execute before I can run my own logic?

    Your party number updates the instant you receive a Pokemon which you can then put into a variable by using the command 'countpokemon'. You will have to make sure that the player doesn't already have a full party otherwise the Pokemon that you're trying to edit will be sent to the PC. I'd suggest making a script that looks like this:

    Spoiler:


    Also, what is your source for the pointers of your Pokemon? Is it possible to edit other things as well like nature and gender? If you could provide a link to where you got your data structure info from that would be great!

    Thanks!

    I know what bytes I need to edit thanks to this post which gives the party Pokemon positions in the RAM and this page which lets me know which byte corresponds to what information. Unfortunately, as you've found out, most of the juicy stuff is in the data substructures which is well protected with checksums and a modulo operation which isn't easily done via scripting.

    You'd be able to easily change a Pokemon's nature and gender by messing around with the Pokemon's personality value but you'll need to be careful as minor edits can have big changes that a player might notice if they've had the Pokemon before having its data be edited.

    EDIT: I found the article on data structures. I'm curious to know how one could prevent bad eggs because the data structures have checksums and if I edit things like nature that might radically change. Or does that only check some things and not the sort of things I'm changing?

    You're in luck, DoesntKnowHowToPlay broke the encryption with just a few simple hex edits a few years ago, opening it up all sorts of editing. Some of the data, as noted in the Bulbapedia article, is calculated through bits rather than bytes so it is more difficult to alter those attributes through pure scripting and requires ASM unless you want to get crafty with variable mathematics. If you're using FR you can also use JPAN's Hacked Engine to edit parts of the substructure data pretty easily as well as do a couple of dozen other nifty things so I would definitely recommend it if you're interested.
     
    222
    Posts
    6
    Years
    • Seen Nov 18, 2023
    If you're using FR you can also use JPAN's Hacked Engine to edit parts of the substructure data pretty easily as well as do a couple of dozen other nifty things so I would definitely recommend it if you're interested.

    Absolutely amazing. Not only does it give me as a hacker a lot more ability to create scripted wild battles (which I needed to do anyways) but it somehow patched seamlessly into my existing hack. Thank you so much!

    One more thing though, if I wanted to fake a simple evolution by changing the species ID of the Pokémon to the species of another one, would there be any caveats to using this method, assuming I'm using JPAN's engine? Even better, has a less hacky way to script an evolution been made since this post?

    Thanks and sorry for being an idiot pleb.
     

    DrFuji

    [I]Heiki Hecchara‌‌[/I]
    1,691
    Posts
    14
    Years
  • Absolutely amazing. Not only does it give me as a hacker a lot more ability to create scripted wild battles (which I needed to do anyways) but it somehow patched seamlessly into my existing hack. Thank you so much!

    One more thing though, if I wanted to fake a simple evolution by changing the species ID of the Pokémon to the species of another one, would there be any caveats to using this method, assuming I'm using JPAN's engine? Even better, has a less hacky way to script an evolution been made since this post?

    Thanks and sorry for being an idiot pleb.

    I've never tried that special in JPAN's engine so unfortunately I'm not really in a position to say much about it. The only downside that I can think of from looking at it is that there won't be any evolution graphics. As for less hacky ways to script an evolution... ¯\_(ツ)_/¯

    There's literally no reason to apologise and even less to call yourself an idiot pleb. Keep asking as many questions as you want~
     
    Back
    Top