summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIdain <luiscarlosholguinperez@outlook.com>2021-06-16 00:21:24 -0400
committerIdain <luiscarlosholguinperez@outlook.com>2021-06-16 00:21:24 -0400
commite0e20ec7bfd64654ecfb4cfcda144e6e526fa4fe (patch)
tree63bdd418202597122f88ee57b3c378efe9bab7b5
parent6111d6a6623f063999fec7a1e538118565b7a94f (diff)
Fixing small error + Adding an index.
-rw-r--r--Modify-existing-gender-formula.md92
1 files changed, 37 insertions, 55 deletions
diff --git a/Modify-existing-gender-formula.md b/Modify-existing-gender-formula.md
index be0d3b5..1457bd8 100644
--- a/Modify-existing-gender-formula.md
+++ b/Modify-existing-gender-formula.md
@@ -1,13 +1,13 @@
-Starting in Generation 3, a Pokémon's gender is independent of its stats. That's not the case, however, in Generation 2.
+Starting in Generation 3, a Pokémon's gender is independent of its stats. However, that's not the case in Generation 2.
![Gender Formula](https://cdn.discordapp.com/attachments/661624398394163201/826841329781964820/unknown.png)
-In Generation 2, the gender of a Pokémon is dictated by its Attack DVs (which become IVs in later generations). With this formula, a female Pokémon has worse stats than male Pokémon. For 1:3 and Female Gender ratios, female Pokémon have decent DVs, and the only way to get a perfect DV female Pokémon is if the gender ratio is Female.
+In this generation a Pokémon's gender is dictated by its Attack DV (which became IVs in later generations). With this formula, a female Pokémon has worse stats than a male Pokémon. For 1:3 and Female Gender ratios, female Pokémon have a decent Attack DV, and the only way to get a perfect DV female Pokémon is if the gender ratio is Female.
This tutorial teaches how to modify the existing gender ratio formula to make females have decent stats as their male counterparts. We will use the following formula instead of relying solely on the Attack DV (Note that Spc = Special):
-`~(Atk DV & 1) << 1 + (Def DV & 1) << 2 + ~(Spc DV & 1) << 3`
+`~(Atk DV & 1) << 1 | (Def DV & 1) << 2 | ~(Spc DV & 1) << 3`
-Here's a chart showing what are the stats of female Pokémon in each of the gender ratios:
+Here's a chart showing the DVs needed to for a Pokémon to be female with the new formula:
```
M:F
7:1 : Female = Odd Atk, Even Def, and Odd Spc
@@ -17,81 +17,63 @@ M:F
```
This means that perfect DV Pokémon are always male for 7M:1F and 3M:1F gender ratios and female for 1M:1F and 1M:3F gender ratios.
-With that out of the way, here's how to edit the gender formula. Edit `GetGender` in [engine/pokemon/mon_stats.asm](https://github.com/pret/pokecrystal/blob/master/engine/pokemon/mon_stats.asm):
+With that out of the way, here's how to edit the gender formula.
+
+## Contents
+1. [Replace the existing formula with a new one](#1-replace-the-existing-formula-with-a-new-one)
-```diff
-GetGender:
-; Return the gender of a given monster (wCurPartyMon/wCurOTMon/wCurWildMon).
-; When calling this function, a should be set to an appropriate wMonType value.
-; return values:
-; a = 1: f = nc|nz; male
-; a = 0: f = nc|z; female
-; f = c: genderless
+## 1. Replace the existing formula with a new one
-; This is determined by comparing the Attack and Speed DVs
-; with the species' gender ratio.
+Edit `GetGender` in [engine/pokemon/mon_stats.asm](../blob/master/engine/pokemon/mon_stats.asm):
-...
+```diff
+ GetGender:
+ ...
-.DVs:
-; sBoxMon data is read directly from SRAM.
- ld a, [wMonType]
+ .DVs:
+ ; sBoxMon data is read directly from SRAM.
+ ld a, [wMonType]
cp BOXMON
ld a, BANK(sBox)
call z, OpenSRAM
-; Attack DV
- ld a, [hli]
+ ; Attack DV
+- ld a, [hli]
- and $f0
- ld b, a
-; Speed DV
- ld a, [hl]
- and $f0
- swap a
++ ld a, [hl]
+ cpl
-+ and $10
-+ swap a
-+ add a ; Atk DV << 1
-+ ld b, a ; Store it in register b
++ and $10
++ swap a
++ add a ; ~(Atk DV & 1) << 1
++ ld b, a ; Store it in register b
+; Defense DV
-+ ld a, [hli]
-+ and $1
-+ add a ; Def DV << 1
-+ add a ; Def DV << 2
-+ or b ; Add (Atk DV << 1) + (Def DV << 2)
-+ ld b, a ; Store result in b.
++ ld a, [hli]
++ and $1
++ add a ; Def DV << 1
++ add a ; Def DV << 2
++ or b ; ~(Atk DV & 1) << 1 | (Def DV & 1) << 2
++ ld b, a ; Store result in b.
+; Special DV
-+ ld a, [hl]
++ ld a, [hl]
+ cpl
-+ and $1
-+ add a ; Spec DV << 1
-+ add a ; Spec DV << 2
-+ add a ; Spec DV << 3
-+ or b ; Add (Spec DV << 3)
++ and $1
++ add a ; ~(Spc DV & 1) << 1
++ add a ; ~(Spc DV & 1) << 2
++ add a ; ~(Spc DV & 1) << 3
++ or b ; ~(Atk DV & 1) << 1 | (Def DV & 1) << 2 | ~(Spc DV & 1) << 3
+ swap a
-+ ld b, a ; Again, stored in b.
++ ld b, a ; Again, stored in b.
-; Put our DVs together.
- or b
- ld b, a
-
-; Close SRAM if we were dealing with a sBoxMon.
- ld a, [wMonType]
- cp BOXMON
- call z, CloseSRAM
-
-; We need the gender ratio to do anything with this.
- push bc
- ld a, [wCurPartySpecies]
- dec a
- ld hl, BaseData + BASE_GENDER
- ld bc, BASE_DATA_SIZE
- call AddNTimes
- pop bc
-
- ld a, BANK(BaseData)
- call GetFarByte
+ ...
```
And that's it! Here are some screenshots of the Pokémon. DVs are displayed for reference and for verifying that they have the correct gender.