Anybody got opcodes for the givepokemon command? (0x79)
Turns out changing the Pokemon level is simple enough, but it's just that number and nothing else.
You're heading in the right direction.
Check the FireRed script command reference in my signature. In its appendix is a brief section on how to find the pointer to any script command's ASM. Find it, and then follow it, and bam! There's your ASM.
So I thought: If we have the opcodes to the givepokemon command, we could create another custom routine which would enter the level as a word instead of byte, and make it do the level and other necessary calculations on it's own.
Precisely.
You may find this information useful when trying to understand the givepokemon ASM:
The ASM routine at 0x080698F8 extracts a halfword argument from the script currently being read, and stores it in r0.
The ASM routine at 0x0806E568 will check if the value in r0 is a reference to a variable (above 0x3FFF, basically). If so, it extracts that value and stores it in r0. Otherwise, r0 is untouched.
Game Freak uses the above two as follows:
call 0x080698F8
lsl r0, r0, #0x10
lsr r0, r0, #0x10 // this and above line force to halfword. redundant, but hey.
call 0x0806E568
// And now r0 equals the specified word-or-variable argument.
0x0806E6D0 grabs the value of a variable or flag referred to by r0.
And finally, a tip: don't edit givepokemon itself, as that will break compatibility with XSE. Instead, create a copy to be called using "callasm". You will not be able to read in arguments from the script itself, but you could have it work any number of different ways. (For example, have it check the values of pre-specified variables that you would set just prior to the "callasm"; or have it load the values of the four script banks, if you wish to pass in dword arguments...)
EDIT: Oh, one more thing. Givepokemon actually sets certain script variables and possibly flags depending on where the Pokemon ends up. It sets 0x4037 (IIRC) to the PC box a Pokemon is sent to (if the party is full), and it sets LASTRESULT to 0x0 if the Pokemon was stored to the party, 0x1 if to the PC, and 0x2 if both the party and the PC are full (no Pokemon given).