summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Shiny-Creation-With-a-Flag.md50
1 files changed, 50 insertions, 0 deletions
diff --git a/Shiny-Creation-With-a-Flag.md b/Shiny-Creation-With-a-Flag.md
new file mode 100644
index 0000000..d2b3519
--- /dev/null
+++ b/Shiny-Creation-With-a-Flag.md
@@ -0,0 +1,50 @@
+## Create Shiny Pokemon with a Flag
+
+### 1. Create a flag
+
+Define a flag named `FLAG_SHINY_CREATION` in `include/constants/flags.h`
+
+### 2. Make it do something
+
+1. Open [pokemon.c](../blob/master/src/pokemon.c) and find `CreateBoxMon`
+2. Make the following changes:
+
+```diff
+- SetBoxMonData(boxMon, MON_DATA_PERSONALITY, &personality);
+
+ //Determine original trainer ID
+ if (otIdType == OT_ID_RANDOM_NO_SHINY) //Pokemon cannot be shiny
+ {
+ u32 shinyValue;
+ do
+ {
+ value = Random32();
+ shinyValue = HIHALF(value) ^ LOHALF(value) ^ HIHALF(personality) ^ LOHALF(personality);
+ } while (shinyValue < SHINY_ODDS);
+ }
+ else if (otIdType == OT_ID_PRESET) //Pokemon has a preset OT ID
+ {
+ value = fixedOtId;
+ }
+ else //Player is the OT
+ {
+ value = gSaveBlock2Ptr->playerTrainerId[0]
+ | (gSaveBlock2Ptr->playerTrainerId[1] << 8)
+ | (gSaveBlock2Ptr->playerTrainerId[2] << 16)
+ | (gSaveBlock2Ptr->playerTrainerId[3] << 24);
+
++ if (FlagGet(FLAG_SHINY_CREATION))
++ {
++ u8 nature = personality % NUM_NATURES; // keep current nature
++ do {
++ personality = Random32();
++ personality = ((((Random() % SHINY_ODDS) ^ (HIHALF(value) ^ LOHALF(value))) ^ LOHALF(personality)) << 16) | LOHALF(personality);
++ } while (nature != GetNatureFromPersonality(personality));
++ }
+ }
+
+
++ SetBoxMonData(boxMon, MON_DATA_PERSONALITY, &personality);
+```
+
+`FLAG_SHINY_CREATION` is NOT cleared internally because you might want to make multiple shiny pokemon. Feel free to add `FlagClear(FLAG_SHINY_CREATION)` at the end of `CreateBoxMon` to make sure only one shiny mon is created.