You are not logged in.
Hi there! So, I am trying to figure out how to add a new consumable item that changes a Pokemon's DVs to a predetermined set of values (e.g. perfect DVs, shiny DVs, or particular Hidden Power DVs). I know I would need to replace a Teru-Sama for each iteration of this new item. I have been looking at the code for the vitamins (Protein, Calcium, etc.) in item_effects.asm, figuring my new item would be a variation of that. However, I am not sure how to proceed from here.
I don't remember, what DV values stand for or practically, how they differ from IV values. Do Protein, Calcium etc. improve these? Also are you sure you don't want to modify the IV values instead since by changing those, you could change the pokemon to improve better by leveling up, perhaps change it to shiny from non-shiny etc. ? Nevertheless, you could apply the following technic for altering both DV and IV values.
When you for example use Protein, the game should write somewhere (in G/S, at the start of $D000+ in ram) the index of the pokemon you selected. If you for example give Protein to your third party pokemon, this index is 02 if I remember correctly. By knowing this index and where the DV/IV values are stored for the party pokemon (https://datacrystal.romhacking.net/wiki … 1_Settings), you can write an asm routine that just re-writes the data in the ram address where the DV/IV values of this pokemon are stored (that you give your Teru-Sama replaced item for).
The routine could be something like this
ld a, D002 (imaginative address where the index of the selected party pokemon from the menu is stored) ld hl, DA35 (address where the HP EV for 1st party pokemon is stored) ld bc, 0030 (addresses' difference between HP EV for each party pokemon) call @find_HP_EV_addr jr @do_stuff_to_replace_DV/IV_values @find_HP_EV_addr and a,a ret z dec a add hl, bc jr @find_HP_EV_addr
Here EV_values_addr is a code that basically finds the address for the DV/IV values of the selected pokemon. This kind of routine is already implemented in the game in rom bank 0, so you could use the original implementation as well.
And if you hack pokecrystal disassembly, you should not (or even can't ?) refer straight to addresses (like D002), but rather refer to them by the name they're called.
Last edited by Miksy91 (2017-10-01 12:06:23)