The PokéCommunity Forums  

Go Back   The PokéCommunity Forums > Fan Games > Binary ROM Hacking
Reload this Page Script Set the nickname of a pokémon to the [player] var?

Notices
For all updates, view the main page.

Binary ROM Hacking Need a helping hand or just want to talk about binary ROM hacks? Get comments and answers to any ROM Hacking-related problems, questions or thoughts you have here.

Ad Content
Reply
 
Thread Tools
  #1   Link to this post, but load the entire thread.  
Old June 21st, 2018 (8:35 PM). Edited June 24th, 2018 by hjk321.
hjk321's Avatar
hjk321 hjk321 is offline
 
Join Date: Sep 2017
Posts: 219
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...
Reply With Quote
  #2   Link to this post, but load the entire thread.  
Old June 22nd, 2018 (4:21 AM).
DrFuji's Avatar
DrFuji DrFuji is offline
Heiki Hecchara‌‌
 
Join Date: Sep 2009
Location: Aussie
Age: 30
Gender: Male
Nature: Jolly
Posts: 1,693
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!
__________________
Reply With Quote
  #3   Link to this post, but load the entire thread.  
Old June 22nd, 2018 (7:47 AM). Edited June 22nd, 2018 by hjk321.
hjk321's Avatar
hjk321 hjk321 is offline
 
Join Date: Sep 2017
Posts: 219
Thank you so much! This was exactly what I needed!

Quote:
Originally Posted by DrFuji View Post
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?
Reply With Quote
  #4   Link to this post, but load the entire thread.  
Old June 22nd, 2018 (8:16 PM).
DrFuji's Avatar
DrFuji DrFuji is offline
Heiki Hecchara‌‌
 
Join Date: Sep 2009
Location: Aussie
Age: 30
Gender: Male
Nature: Jolly
Posts: 1,693
Quote:
Originally Posted by hjk321 View Post
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:
00=
01=À
02=Á
03=Â
04=Ç
05=È
06=É
07=Ê
08=Ë
09=Ì
0B=Î
0C=Ï
0D=Ò
0E=Ó
0F=Ô
10=Æ
11=Ù
12=Ú
13=Û
14=Ñ
15=ß
16=à
17=á
19=ç
1A=è
1B=é
1C=ê
1D=ë
1E=ì
20=î
21=ï
22=ò
23=ó
24=ô
25=æ
26=ù
27=ú
28=û
29=ñ
2A=º
2B=ª
2C=·
2D=&
2E=+
34=[Lv]
35==
36=;
51=¿
52=¡
53=[PK]
54=[MN]
55=[PO]
56=[Ke]
57=[BL]
58=[OC]
59=[K]
5A=Í
5B=%
5C=(
5D=)
68=â
6F=í
79=[u]
7A=[D]
7B=[L]
7C=[R]
A1=0
A2=1
A3=2
A4=3
A5=4
A6=5
A7=6
A8=7
A9=8
AA=9
AB=!
AC=?
AD=.
AE=-
AF=·
B0=[...]
B1="
B2=["]
B3='
B4=[']
B5=[m]
B6=[f]
B7=$
B8=,
B9=[x]
BA=/
BB=A
BC=B
BD=C
BE=D
BF=E
C0=F
C1=G
C2=H
C3=I
C4=J
C5=K
C6=L
C7=M
C8=N
C9=O
CA=P
CB=Q
CC=R
CD=S
CE=T
CF=U
D0=V
D1=W
D2=X
D3=Y
D4=Z
D5=a
D6=b
D7=c
D8=d
D9=e
DA=f
DB=g
DC=h
DD=i
DE=j
DF=k
E0=l
E1=m
E2=n
E3=o
E4=p
E5=q
E6=r
E7=s
E8=t
E9=u
EA=v
EB=w
EC=x
ED=y
EE=z
EF=[>]
F0=:
F1=Ä
F2=Ö
F3=Ü
F4=ä
F5=ö
F6=ü
F7=[u]
F8=[d]
F9=[l]
FA=\l
FB=\p
FC=\c
FD=\v
FE=\n
FF=\x


Quote:
Originally Posted by hjk321 View Post
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:
#dynamic 0x800000

#org @start
countpokemon // The number of Pokemon in the player's party is put into variable 0x800D
compare 0x800D 0x6 // Comparing 0x800D to 0x6 (a full party)
if 0x1 goto @FullParty // If 0x800D is equal to 0x6 the script branches off
givepokemon 0x1 0x5 0x0 0x0 0x0 0x0
countpokemon
copyvar 0x8000 0x800D // Copying the value of 0x800D over to 0x8000 as 0x800D is a temporary variable
compare 0x8000 0x1 // Checking if the player only has one Pokemon in their party, this would be the Bulbasaur they just received
if 0x1 goto @FirstPokemon // If this is true, the script branches off
compare 0x8000 0x2
if 0x1 goto @Second Pokemon
compare 0x8000 0x3
if 0x1 got @ThirdPokemon
...


Quote:
Originally Posted by hjk321 View Post
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 View Post
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.
__________________
Reply With Quote
  #5   Link to this post, but load the entire thread.  
Old June 23rd, 2018 (6:01 AM).
hjk321's Avatar
hjk321 hjk321 is offline
 
Join Date: Sep 2017
Posts: 219
Quote:
Originally Posted by DrFuji View Post
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.
Reply With Quote
  #6   Link to this post, but load the entire thread.  
Old June 23rd, 2018 (8:28 PM).
DrFuji's Avatar
DrFuji DrFuji is offline
Heiki Hecchara‌‌
 
Join Date: Sep 2009
Location: Aussie
Age: 30
Gender: Male
Nature: Jolly
Posts: 1,693
Quote:
Originally Posted by hjk321 View Post
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~
__________________
Reply With Quote
Reply

Quick Reply

Join the conversation!

Create an account to post a reply in this thread, participate in other discussions, and more!

Create a PokéCommunity Account
Ad Content
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 9:14 AM.