Quote:
Originally Posted by hjk321
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:
Quote:
Originally Posted by hjk321
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:
Quote:
Originally Posted by hjk321
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.
Quote:
Originally Posted by hjk321
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.