3 Chain Fishing
ghoulslash edited this page 2020-11-11 15:51:09 -07:00

Chain Fishing

This adds the chain fishing feature to emerald, where reeling in consecutive pokemon species increases the number of chances of it being shiny by up to 41 total times (1 + 2 * streak)

Open src/wild_encounter.c

1. We need 3 new EWRAM_DATA variables:

+ EWRAM_DATA u8 gChainFishingStreak = 0;
+ EWRAM_DATA static u16 sLastFishingSpecies = 0;
+ EWRAM_DATA bool8 gIsFishingEncounter = FALSE;   //same as in dizzyegg's item expansion repo

2. Add the non-static EWRAM_DATA variables to include/wild_encounter.h:

+ extern u8 gChainFishingStreak;
+ extern bool8 gIsFishingEncounter;

3. Find the function FishingWildEncounter and make the following edits

void FishingWildEncounter(u8 rod)
{
    u16 species;

+   gIsFishingEncounter = TRUE; //must be set before mon is created
    if (CheckFeebas() == TRUE)
    {
        u8 level = ChooseWildMonLevel(&gWildFeebasRoute119Data);
        species = gWildFeebasRoute119Data.species;
        CreateWildMon(species, level);
    }
    else
    {
        species = GenerateFishingWildMon(gWildMonHeaders[GetCurrentMapWildMonHeaderId()].fishingMonsInfo, rod);
    }

+    if (species == sLastFishingSpecies)
+    {
+        if (gChainFishingStreak < 20)
+            gChainFishingStreak++;
+    }
+    else
+    {
+        gChainFishingStreak = 0;    //reeling in different species resets chain fish counter
+    }
+
+    sLastFishingSpecies = species;
    IncrementGameStat(GAME_STAT_FISHING_CAPTURES);
    SetPokemonAnglerSpecies(species);
    BattleSetup_StartWildBattle();

4. Reset the chain counter

  • Open src/battle_main.c
    • add #include "wild_encounter.h" to the top
    • find the function, FreeResetData_ReturnToOvOrDoEvolutions and change to the following:
    if (!gPaletteFade.active)
    {
+        gIsFishingEncounter = FALSE;
        ResetSpriteData();
        //etc
gChainFishingStreak = 0;
  • Open src/fieldmap.c
    • add #include "wild_encounter.h" to the top
    • find the function InitMap and add the following to the top to reset when the player changes maps
gChainFishingStreak = 0;

5. Increase the shiny rate

  • Open src/pokemon.c
  • add #include "wild_encounter.h" to the top
  • Find the function CreateBoxMon
  • define u32 shinyValue; at the top
  • remove Line 2207, SetBoxMonData(boxMon, MON_DATA_PERSONALITY, &personality);
  • edit the personality generation section underneath else //Player is the OT to:
    else //Player is the OT
    {
+        u32 rolls = 0;
+        u32 shinyRolls = 0;

        value = gSaveBlock2Ptr->playerTrainerId[0]
              | (gSaveBlock2Ptr->playerTrainerId[1] << 8)
              | (gSaveBlock2Ptr->playerTrainerId[2] << 16)
              | (gSaveBlock2Ptr->playerTrainerId[3] << 24);

+        #ifdef ITEM_SHINY_CHARM
+        if (CheckBagHasItem(ITEM_SHINY_CHARM, 1))
+            shinyRolls += 3;  //if you have the shiny charm, add 3 more rolls
+        #endif
+
+        if (gIsFishingEncounter)
+            shinyRolls += 1 + 2 * gChainFishingStreak; //1 + 2 rolls per streak count. max 41
+
+        if (shinyRolls)
+        {
+            do {
+                personality = Random32();
+                shinyValue = HIHALF(value) ^ LOHALF(value) ^ HIHALF(personality) ^ LOHALF(personality);
+                rolls++;
+            } while (shinyValue >= SHINY_ODDS && rolls < shinyRolls);
        }
    }

+    SetBoxMonData(boxMon, MON_DATA_PERSONALITY, &personality);
   SetBoxMonData(boxMon, MON_DATA_OT_ID, &value);
   //etc...